0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/kernel.h>
0009 #include <linux/init.h>
0010 #include <linux/platform_device.h>
0011 #include <linux/syscore_ops.h>
0012 #include <linux/input.h>
0013 #include <linux/delay.h>
0014 #include <linux/gpio_keys.h>
0015 #include <linux/pwm.h>
0016 #include <linux/pwm_backlight.h>
0017 #include <linux/rtc.h>
0018 #include <linux/leds.h>
0019 #include <linux/gpio.h>
0020 #include <linux/gpio/machine.h>
0021 #include <linux/interrupt.h>
0022 #include <linux/irq.h>
0023 #include <linux/pda_power.h>
0024 #include <linux/power_supply.h>
0025 #include <linux/wm97xx.h>
0026 #include <linux/mtd/physmap.h>
0027 #include <linux/reboot.h>
0028 #include <linux/regulator/fixed.h>
0029 #include <linux/regulator/max1586.h>
0030 #include <linux/slab.h>
0031 #include <linux/platform_data/i2c-pxa.h>
0032
0033 #include <asm/mach-types.h>
0034 #include <asm/mach/arch.h>
0035
0036 #include "pxa27x.h"
0037 #include "regs-rtc.h"
0038 #include <linux/platform_data/keypad-pxa27x.h>
0039 #include <linux/platform_data/video-pxafb.h>
0040 #include <linux/platform_data/mmc-pxamci.h>
0041 #include "udc.h"
0042 #include "pxa27x-udc.h"
0043 #include <linux/platform_data/media/camera-pxa.h>
0044 #include <linux/platform_data/asoc-pxa.h>
0045 #include "smemc.h"
0046
0047 #include "mioa701.h"
0048
0049 #include "generic.h"
0050 #include "devices.h"
0051
0052 static unsigned long mioa701_pin_config[] = {
0053
0054 MIO_CFG_OUT(GPIO9_CHARGE_EN, AF0, DRIVE_LOW),
0055 MIO_CFG_OUT(GPIO18_POWEROFF, AF0, DRIVE_LOW),
0056 MFP_CFG_OUT(GPIO3, AF0, DRIVE_HIGH),
0057 MFP_CFG_OUT(GPIO4, AF0, DRIVE_HIGH),
0058 MIO_CFG_IN(GPIO80_MAYBE_CHARGE_VDROP, AF0),
0059
0060
0061 GPIO16_PWM0_OUT,
0062
0063
0064 GPIO32_MMC_CLK,
0065 GPIO92_MMC_DAT_0,
0066 GPIO109_MMC_DAT_1,
0067 GPIO110_MMC_DAT_2,
0068 GPIO111_MMC_DAT_3,
0069 GPIO112_MMC_CMD,
0070 MIO_CFG_IN(GPIO78_SDIO_RO, AF0),
0071 MIO_CFG_IN(GPIO15_SDIO_INSERT, AF0),
0072 MIO_CFG_OUT(GPIO91_SDIO_EN, AF0, DRIVE_LOW),
0073
0074
0075 MIO_CFG_IN(GPIO13_nUSB_DETECT, AF0),
0076 MIO_CFG_OUT(GPIO22_USB_ENABLE, AF0, DRIVE_LOW),
0077
0078
0079 GPIOxx_LCD_TFT_16BPP,
0080
0081
0082 GPIO12_CIF_DD_7,
0083 GPIO17_CIF_DD_6,
0084 GPIO50_CIF_DD_3,
0085 GPIO51_CIF_DD_2,
0086 GPIO52_CIF_DD_4,
0087 GPIO53_CIF_MCLK,
0088 GPIO54_CIF_PCLK,
0089 GPIO55_CIF_DD_1,
0090 GPIO81_CIF_DD_0,
0091 GPIO82_CIF_DD_5,
0092 GPIO84_CIF_FV,
0093 GPIO85_CIF_LV,
0094 MIO_CFG_OUT(GPIO56_MT9M111_nOE, AF0, DRIVE_LOW),
0095
0096
0097 MIO_CFG_IN(GPIO14_BT_nACTIVITY, AF0),
0098 GPIO44_BTUART_CTS,
0099 GPIO42_BTUART_RXD,
0100 GPIO45_BTUART_RTS,
0101 GPIO43_BTUART_TXD,
0102 MIO_CFG_OUT(GPIO83_BT_ON, AF0, DRIVE_LOW),
0103 MIO_CFG_OUT(GPIO77_BT_UNKNOWN1, AF0, DRIVE_HIGH),
0104 MIO_CFG_OUT(GPIO86_BT_MAYBE_nRESET, AF0, DRIVE_HIGH),
0105
0106
0107 MIO_CFG_OUT(GPIO23_GPS_UNKNOWN1, AF0, DRIVE_LOW),
0108 MIO_CFG_OUT(GPIO26_GPS_ON, AF0, DRIVE_LOW),
0109 MIO_CFG_OUT(GPIO27_GPS_RESET, AF0, DRIVE_LOW),
0110 MIO_CFG_OUT(GPIO106_GPS_UNKNOWN2, AF0, DRIVE_LOW),
0111 MIO_CFG_OUT(GPIO107_GPS_UNKNOWN3, AF0, DRIVE_LOW),
0112 GPIO46_STUART_RXD,
0113 GPIO47_STUART_TXD,
0114
0115
0116 MIO_CFG_OUT(GPIO24_GSM_MOD_RESET_CMD, AF0, DRIVE_LOW),
0117 MIO_CFG_OUT(GPIO88_GSM_nMOD_ON_CMD, AF0, DRIVE_HIGH),
0118 MIO_CFG_OUT(GPIO90_GSM_nMOD_OFF_CMD, AF0, DRIVE_HIGH),
0119 MIO_CFG_OUT(GPIO114_GSM_nMOD_DTE_UART_STATE, AF0, DRIVE_HIGH),
0120 MIO_CFG_IN(GPIO25_GSM_MOD_ON_STATE, AF0),
0121 MIO_CFG_IN(GPIO113_GSM_EVENT, AF0) | WAKEUP_ON_EDGE_BOTH,
0122 GPIO34_FFUART_RXD,
0123 GPIO35_FFUART_CTS,
0124 GPIO36_FFUART_DCD,
0125 GPIO37_FFUART_DSR,
0126 GPIO39_FFUART_TXD,
0127 GPIO40_FFUART_DTR,
0128 GPIO41_FFUART_RTS,
0129
0130
0131 GPIO28_AC97_BITCLK,
0132 GPIO29_AC97_SDATA_IN_0,
0133 GPIO30_AC97_SDATA_OUT,
0134 GPIO31_AC97_SYNC,
0135 GPIO89_AC97_SYSCLK,
0136 MIO_CFG_IN(GPIO12_HPJACK_INSERT, AF0),
0137
0138
0139 MIO_CFG_OUT(GPIO10_LED_nCharging, AF0, DRIVE_HIGH),
0140 MIO_CFG_OUT(GPIO97_LED_nBlue, AF0, DRIVE_HIGH),
0141 MIO_CFG_OUT(GPIO98_LED_nOrange, AF0, DRIVE_HIGH),
0142 MIO_CFG_OUT(GPIO82_LED_nVibra, AF0, DRIVE_HIGH),
0143 MIO_CFG_OUT(GPIO115_LED_nKeyboard, AF0, DRIVE_HIGH),
0144
0145
0146 MIO_CFG_IN(GPIO0_KEY_POWER, AF0) | WAKEUP_ON_EDGE_BOTH,
0147 MIO_CFG_IN(GPIO93_KEY_VOLUME_UP, AF0),
0148 MIO_CFG_IN(GPIO94_KEY_VOLUME_DOWN, AF0),
0149 GPIO100_KP_MKIN_0,
0150 GPIO101_KP_MKIN_1,
0151 GPIO102_KP_MKIN_2,
0152 GPIO103_KP_MKOUT_0,
0153 GPIO104_KP_MKOUT_1,
0154 GPIO105_KP_MKOUT_2,
0155
0156
0157 GPIO117_I2C_SCL,
0158 GPIO118_I2C_SDA,
0159
0160
0161 MFP_CFG_IN(GPIO20, AF0),
0162 MFP_CFG_IN(GPIO21, AF0),
0163 MFP_CFG_IN(GPIO33, AF0),
0164 MFP_CFG_OUT(GPIO49, AF0, DRIVE_HIGH),
0165 MFP_CFG_OUT(GPIO57, AF0, DRIVE_HIGH),
0166 MFP_CFG_IN(GPIO96, AF0),
0167 MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH),
0168 };
0169
0170 static struct pwm_lookup mioa701_pwm_lookup[] = {
0171 PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight", NULL, 4000 * 1024,
0172 PWM_POLARITY_NORMAL),
0173 };
0174
0175
0176 static struct platform_pwm_backlight_data mioa701_backlight_data = {
0177 .max_brightness = 100,
0178 .dft_brightness = 50,
0179 };
0180
0181
0182
0183
0184
0185
0186
0187
0188 static struct pxafb_mode_info mioa701_ltm0305a776c = {
0189 .pixclock = 220000,
0190 .xres = 240,
0191 .yres = 320,
0192 .bpp = 16,
0193 .hsync_len = 4,
0194 .vsync_len = 2,
0195 .left_margin = 6,
0196 .right_margin = 4,
0197 .upper_margin = 5,
0198 .lower_margin = 3,
0199 };
0200
0201 static void mioa701_lcd_power(int on, struct fb_var_screeninfo *si)
0202 {
0203 gpio_set_value(GPIO87_LCD_POWER, on);
0204 }
0205
0206 static struct pxafb_mach_info mioa701_pxafb_info = {
0207 .modes = &mioa701_ltm0305a776c,
0208 .num_modes = 1,
0209 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
0210 .pxafb_lcd_power = mioa701_lcd_power,
0211 };
0212
0213
0214
0215
0216 static const unsigned int mioa701_matrix_keys[] = {
0217 KEY(0, 0, KEY_UP),
0218 KEY(0, 1, KEY_RIGHT),
0219 KEY(0, 2, KEY_MEDIA),
0220 KEY(1, 0, KEY_DOWN),
0221 KEY(1, 1, KEY_ENTER),
0222 KEY(1, 2, KEY_CONNECT),
0223 KEY(2, 0, KEY_LEFT),
0224 KEY(2, 1, KEY_PHONE),
0225 KEY(2, 2, KEY_CAMERA)
0226 };
0227
0228 static struct matrix_keymap_data mioa701_matrix_keymap_data = {
0229 .keymap = mioa701_matrix_keys,
0230 .keymap_size = ARRAY_SIZE(mioa701_matrix_keys),
0231 };
0232
0233 static struct pxa27x_keypad_platform_data mioa701_keypad_info = {
0234 .matrix_key_rows = 3,
0235 .matrix_key_cols = 3,
0236 .matrix_keymap_data = &mioa701_matrix_keymap_data,
0237 };
0238
0239
0240
0241
0242 #define MIO_KEY(key, _gpio, _desc, _wakeup) \
0243 { .code = (key), .gpio = (_gpio), .active_low = 0, \
0244 .desc = (_desc), .type = EV_KEY, .wakeup = (_wakeup) }
0245 static struct gpio_keys_button mioa701_button_table[] = {
0246 MIO_KEY(KEY_EXIT, GPIO0_KEY_POWER, "Power button", 1),
0247 MIO_KEY(KEY_VOLUMEUP, GPIO93_KEY_VOLUME_UP, "Volume up", 0),
0248 MIO_KEY(KEY_VOLUMEDOWN, GPIO94_KEY_VOLUME_DOWN, "Volume down", 0),
0249 MIO_KEY(KEY_HP, GPIO12_HPJACK_INSERT, "HP jack detect", 0)
0250 };
0251
0252 static struct gpio_keys_platform_data mioa701_gpio_keys_data = {
0253 .buttons = mioa701_button_table,
0254 .nbuttons = ARRAY_SIZE(mioa701_button_table),
0255 };
0256
0257
0258
0259
0260 #define ONE_LED(_gpio, _name) \
0261 { .gpio = (_gpio), .name = (_name), .active_low = true }
0262 static struct gpio_led gpio_leds[] = {
0263 ONE_LED(GPIO10_LED_nCharging, "mioa701:charging"),
0264 ONE_LED(GPIO97_LED_nBlue, "mioa701:blue"),
0265 ONE_LED(GPIO98_LED_nOrange, "mioa701:orange"),
0266 ONE_LED(GPIO82_LED_nVibra, "mioa701:vibra"),
0267 ONE_LED(GPIO115_LED_nKeyboard, "mioa701:keyboard")
0268 };
0269
0270 static struct gpio_led_platform_data gpio_led_info = {
0271 .leds = gpio_leds,
0272 .num_leds = ARRAY_SIZE(gpio_leds),
0273 };
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288 static int is_gsm_on(void)
0289 {
0290 int is_on;
0291
0292 is_on = !!gpio_get_value(GPIO25_GSM_MOD_ON_STATE);
0293 return is_on;
0294 }
0295
0296 irqreturn_t gsm_on_irq(int irq, void *p)
0297 {
0298 printk(KERN_DEBUG "Mioa701: GSM status changed to %s\n",
0299 is_gsm_on() ? "on" : "off");
0300 return IRQ_HANDLED;
0301 }
0302
0303 static struct gpio gsm_gpios[] = {
0304 { GPIO25_GSM_MOD_ON_STATE, GPIOF_IN, "GSM state" },
0305 { GPIO113_GSM_EVENT, GPIOF_IN, "GSM event" },
0306 };
0307
0308 static int __init gsm_init(void)
0309 {
0310 int rc;
0311
0312 rc = gpio_request_array(ARRAY_AND_SIZE(gsm_gpios));
0313 if (rc)
0314 goto err_gpio;
0315 rc = request_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), gsm_on_irq,
0316 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
0317 "GSM XS200 Power Irq", NULL);
0318 if (rc)
0319 goto err_irq;
0320
0321 gpio_set_wake(GPIO113_GSM_EVENT, 1);
0322 return 0;
0323
0324 err_irq:
0325 printk(KERN_ERR "Mioa701: Can't request GSM_ON irq\n");
0326 gpio_free_array(ARRAY_AND_SIZE(gsm_gpios));
0327 err_gpio:
0328 printk(KERN_ERR "Mioa701: gsm not available\n");
0329 return rc;
0330 }
0331
0332 static void gsm_exit(void)
0333 {
0334 free_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), NULL);
0335 gpio_free_array(ARRAY_AND_SIZE(gsm_gpios));
0336 }
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359 static int is_usb_connected(void)
0360 {
0361 return !gpio_get_value(GPIO13_nUSB_DETECT);
0362 }
0363
0364 static struct pxa2xx_udc_mach_info mioa701_udc_info = {
0365 .udc_is_connected = is_usb_connected,
0366 .gpio_pullup = GPIO22_USB_ENABLE,
0367 };
0368
0369 static struct gpiod_lookup_table gpio_vbus_gpiod_table = {
0370 .dev_id = "gpio-vbus",
0371 .table = {
0372 GPIO_LOOKUP("gpio-pxa", GPIO13_nUSB_DETECT,
0373 "vbus", GPIO_ACTIVE_LOW),
0374 { },
0375 },
0376 };
0377
0378
0379
0380
0381
0382
0383
0384
0385 static struct pxamci_platform_data mioa701_mci_info = {
0386 .detect_delay_ms = 250,
0387 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
0388 };
0389
0390 static struct gpiod_lookup_table mioa701_mci_gpio_table = {
0391 .dev_id = "pxa2xx-mci.0",
0392 .table = {
0393
0394 GPIO_LOOKUP("gpio-pxa", GPIO15_SDIO_INSERT,
0395 "cd", GPIO_ACTIVE_LOW),
0396
0397 GPIO_LOOKUP("gpio-pxa", GPIO78_SDIO_RO,
0398 "wp", GPIO_ACTIVE_LOW),
0399
0400 GPIO_LOOKUP("gpio-pxa", GPIO91_SDIO_EN,
0401 "power", GPIO_ACTIVE_HIGH),
0402 { },
0403 },
0404 };
0405
0406
0407 static struct resource docg3_resource = {
0408 .start = PXA_CS0_PHYS,
0409 .end = PXA_CS0_PHYS + SZ_8K - 1,
0410 .flags = IORESOURCE_MEM,
0411 };
0412
0413 static struct platform_device docg3 = {
0414 .name = "docg3",
0415 .id = -1,
0416 .resource = &docg3_resource,
0417 .num_resources = 1,
0418 .dev = {
0419 .platform_data = NULL,
0420 },
0421 };
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436 #define RESUME_ENABLE_ADDR 0xa020b000
0437 #define RESUME_ENABLE_VAL 0x0f0f0f0f
0438 #define RESUME_BT_ADDR 0xa020b020
0439 #define RESUME_UNKNOWN_ADDR 0xa020b024
0440 #define RESUME_VECTOR_ADDR 0xa0100000
0441 #define BOOTSTRAP_WORDS mioa701_bootstrap_lg/4
0442
0443 static u32 *save_buffer;
0444
0445 static void install_bootstrap(void)
0446 {
0447 int i;
0448 u32 *rom_bootstrap = phys_to_virt(RESUME_VECTOR_ADDR);
0449 u32 *src = &mioa701_bootstrap;
0450
0451 for (i = 0; i < BOOTSTRAP_WORDS; i++)
0452 rom_bootstrap[i] = src[i];
0453 }
0454
0455
0456 static int mioa701_sys_suspend(void)
0457 {
0458 int i = 0, is_bt_on;
0459 u32 *mem_resume_vector = phys_to_virt(RESUME_VECTOR_ADDR);
0460 u32 *mem_resume_enabler = phys_to_virt(RESUME_ENABLE_ADDR);
0461 u32 *mem_resume_bt = phys_to_virt(RESUME_BT_ADDR);
0462 u32 *mem_resume_unknown = phys_to_virt(RESUME_UNKNOWN_ADDR);
0463
0464
0465 is_bt_on = !!gpio_get_value(GPIO83_BT_ON);
0466 pxa2xx_mfp_set_lpm(GPIO83_BT_ON,
0467 is_bt_on ? MFP_LPM_DRIVE_HIGH : MFP_LPM_DRIVE_LOW);
0468
0469 for (i = 0; i < BOOTSTRAP_WORDS; i++)
0470 save_buffer[i] = mem_resume_vector[i];
0471 save_buffer[i++] = *mem_resume_enabler;
0472 save_buffer[i++] = *mem_resume_bt;
0473 save_buffer[i++] = *mem_resume_unknown;
0474
0475 *mem_resume_enabler = RESUME_ENABLE_VAL;
0476 *mem_resume_bt = is_bt_on;
0477
0478 install_bootstrap();
0479 return 0;
0480 }
0481
0482 static void mioa701_sys_resume(void)
0483 {
0484 int i = 0;
0485 u32 *mem_resume_vector = phys_to_virt(RESUME_VECTOR_ADDR);
0486 u32 *mem_resume_enabler = phys_to_virt(RESUME_ENABLE_ADDR);
0487 u32 *mem_resume_bt = phys_to_virt(RESUME_BT_ADDR);
0488 u32 *mem_resume_unknown = phys_to_virt(RESUME_UNKNOWN_ADDR);
0489
0490 for (i = 0; i < BOOTSTRAP_WORDS; i++)
0491 mem_resume_vector[i] = save_buffer[i];
0492 *mem_resume_enabler = save_buffer[i++];
0493 *mem_resume_bt = save_buffer[i++];
0494 *mem_resume_unknown = save_buffer[i++];
0495 }
0496
0497 static struct syscore_ops mioa701_syscore_ops = {
0498 .suspend = mioa701_sys_suspend,
0499 .resume = mioa701_sys_resume,
0500 };
0501
0502 static int __init bootstrap_init(void)
0503 {
0504 int save_size = mioa701_bootstrap_lg + (sizeof(u32) * 3);
0505
0506 register_syscore_ops(&mioa701_syscore_ops);
0507
0508 save_buffer = kmalloc(save_size, GFP_KERNEL);
0509 if (!save_buffer)
0510 return -ENOMEM;
0511 printk(KERN_INFO "MioA701: allocated %d bytes for bootstrap\n",
0512 save_size);
0513 return 0;
0514 }
0515
0516 static void bootstrap_exit(void)
0517 {
0518 kfree(save_buffer);
0519 unregister_syscore_ops(&mioa701_syscore_ops);
0520
0521 printk(KERN_CRIT "Unregistering mioa701 suspend will hang next"
0522 "resume !!!\n");
0523 }
0524
0525
0526
0527
0528 static char *supplicants[] = {
0529 "mioa701_battery"
0530 };
0531
0532 static int is_ac_connected(void)
0533 {
0534 return gpio_get_value(GPIO96_AC_DETECT);
0535 }
0536
0537 static void mioa701_set_charge(int flags)
0538 {
0539 gpio_set_value(GPIO9_CHARGE_EN, (flags == PDA_POWER_CHARGE_USB));
0540 }
0541
0542 static struct pda_power_pdata power_pdata = {
0543 .is_ac_online = is_ac_connected,
0544 .is_usb_online = is_usb_connected,
0545 .set_charge = mioa701_set_charge,
0546 .supplied_to = supplicants,
0547 .num_supplicants = ARRAY_SIZE(supplicants),
0548 };
0549
0550 static struct resource power_resources[] = {
0551 [0] = {
0552 .name = "ac",
0553 .start = PXA_GPIO_TO_IRQ(GPIO96_AC_DETECT),
0554 .end = PXA_GPIO_TO_IRQ(GPIO96_AC_DETECT),
0555 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
0556 IORESOURCE_IRQ_LOWEDGE,
0557 },
0558 [1] = {
0559 .name = "usb",
0560 .start = PXA_GPIO_TO_IRQ(GPIO13_nUSB_DETECT),
0561 .end = PXA_GPIO_TO_IRQ(GPIO13_nUSB_DETECT),
0562 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
0563 IORESOURCE_IRQ_LOWEDGE,
0564 },
0565 };
0566
0567 static struct platform_device power_dev = {
0568 .name = "pda-power",
0569 .id = -1,
0570 .resource = power_resources,
0571 .num_resources = ARRAY_SIZE(power_resources),
0572 .dev = {
0573 .platform_data = &power_pdata,
0574 },
0575 };
0576
0577 static struct wm97xx_batt_pdata mioa701_battery_data = {
0578 .batt_aux = WM97XX_AUX_ID1,
0579 .temp_aux = -1,
0580 .min_voltage = 0xc00,
0581 .max_voltage = 0xfc0,
0582 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LION,
0583 .batt_div = 1,
0584 .batt_mult = 1,
0585 .batt_name = "mioa701_battery",
0586 };
0587
0588 static struct wm97xx_pdata mioa701_wm97xx_pdata = {
0589 .batt_pdata = &mioa701_battery_data,
0590 };
0591
0592
0593
0594
0595 static struct regulator_consumer_supply max1586_consumers[] = {
0596 REGULATOR_SUPPLY("vcc_core", NULL),
0597 };
0598
0599 static struct regulator_init_data max1586_v3_info = {
0600 .constraints = {
0601 .name = "vcc_core range",
0602 .min_uV = 1000000,
0603 .max_uV = 1705000,
0604 .always_on = 1,
0605 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
0606 },
0607 .num_consumer_supplies = ARRAY_SIZE(max1586_consumers),
0608 .consumer_supplies = max1586_consumers,
0609 };
0610
0611 static struct max1586_subdev_data max1586_subdevs[] = {
0612 { .name = "vcc_core", .id = MAX1586_V3,
0613 .platform_data = &max1586_v3_info },
0614 };
0615
0616 static struct max1586_platform_data max1586_info = {
0617 .subdevs = max1586_subdevs,
0618 .num_subdevs = ARRAY_SIZE(max1586_subdevs),
0619 .v3_gain = MAX1586_GAIN_NO_R24,
0620 };
0621
0622
0623
0624
0625 struct pxacamera_platform_data mioa701_pxacamera_platform_data = {
0626 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
0627 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
0628 .mclk_10khz = 5000,
0629 .sensor_i2c_adapter_id = 0,
0630 .sensor_i2c_address = 0x5d,
0631 };
0632
0633 static struct i2c_board_info __initdata mioa701_pi2c_devices[] = {
0634 {
0635 I2C_BOARD_INFO("max1586", 0x14),
0636 .platform_data = &max1586_info,
0637 },
0638 };
0639
0640
0641 static struct i2c_board_info mioa701_i2c_devices[] = {
0642 {
0643 I2C_BOARD_INFO("mt9m111", 0x5d),
0644 },
0645 };
0646
0647 struct i2c_pxa_platform_data i2c_pdata = {
0648 .fast_mode = 1,
0649 };
0650
0651 static pxa2xx_audio_ops_t mioa701_ac97_info = {
0652 .reset_gpio = 95,
0653 .codec_pdata = { &mioa701_wm97xx_pdata, },
0654 };
0655
0656
0657
0658
0659
0660
0661 #define MIO_PARENT_DEV(var, strname, tparent, pdata) \
0662 static struct platform_device var = { \
0663 .name = strname, \
0664 .id = -1, \
0665 .dev = { \
0666 .platform_data = pdata, \
0667 .parent = tparent, \
0668 }, \
0669 };
0670 #define MIO_SIMPLE_DEV(var, strname, pdata) \
0671 MIO_PARENT_DEV(var, strname, NULL, pdata)
0672
0673 MIO_SIMPLE_DEV(mioa701_gpio_keys, "gpio-keys", &mioa701_gpio_keys_data)
0674 MIO_PARENT_DEV(mioa701_backlight, "pwm-backlight", &pxa27x_device_pwm0.dev,
0675 &mioa701_backlight_data);
0676 MIO_SIMPLE_DEV(mioa701_led, "leds-gpio", &gpio_led_info)
0677 MIO_SIMPLE_DEV(pxa2xx_pcm, "pxa2xx-pcm", NULL)
0678 MIO_SIMPLE_DEV(mioa701_sound, "mioa701-wm9713", NULL)
0679 MIO_SIMPLE_DEV(mioa701_board, "mioa701-board", NULL)
0680 MIO_SIMPLE_DEV(gpio_vbus, "gpio-vbus", NULL);
0681
0682 static struct platform_device *devices[] __initdata = {
0683 &mioa701_gpio_keys,
0684 &mioa701_backlight,
0685 &mioa701_led,
0686 &pxa2xx_pcm,
0687 &mioa701_sound,
0688 &power_dev,
0689 &docg3,
0690 &gpio_vbus,
0691 &mioa701_board,
0692 };
0693
0694 static void mioa701_machine_exit(void);
0695
0696 static void mioa701_poweroff(void)
0697 {
0698 mioa701_machine_exit();
0699 pxa_restart(REBOOT_SOFT, NULL);
0700 }
0701
0702 static void mioa701_restart(enum reboot_mode c, const char *cmd)
0703 {
0704 mioa701_machine_exit();
0705 pxa_restart(REBOOT_SOFT, cmd);
0706 }
0707
0708 static struct gpio global_gpios[] = {
0709 { GPIO9_CHARGE_EN, GPIOF_OUT_INIT_HIGH, "Charger enable" },
0710 { GPIO18_POWEROFF, GPIOF_OUT_INIT_LOW, "Power Off" },
0711 { GPIO87_LCD_POWER, GPIOF_OUT_INIT_LOW, "LCD Power" },
0712 { GPIO56_MT9M111_nOE, GPIOF_OUT_INIT_LOW, "Camera nOE" },
0713 };
0714
0715 static struct regulator_consumer_supply fixed_5v0_consumers[] = {
0716 REGULATOR_SUPPLY("power", "pwm-backlight"),
0717 };
0718
0719 static void __init mioa701_machine_init(void)
0720 {
0721 int rc;
0722
0723 PSLR = 0xff100000;
0724 PCFR = PCFR_DC_EN | PCFR_GPR_EN | PCFR_OPDE;
0725 RTTR = 32768 - 1;
0726 UP2OCR = UP2OCR_HXOE;
0727
0728
0729
0730
0731 __raw_writel(0x7ff02dd8, MSC0);
0732 __raw_writel(0x0001c391, MCMEM0);
0733 __raw_writel(0x0001c391, MCATT0);
0734 __raw_writel(0x0001c391, MCIO0);
0735
0736
0737 pxa2xx_mfp_config(ARRAY_AND_SIZE(mioa701_pin_config));
0738 pxa_set_ffuart_info(NULL);
0739 pxa_set_btuart_info(NULL);
0740 pxa_set_stuart_info(NULL);
0741 rc = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
0742 if (rc)
0743 pr_err("MioA701: Failed to request GPIOs: %d", rc);
0744 bootstrap_init();
0745 pxa_set_fb_info(NULL, &mioa701_pxafb_info);
0746 gpiod_add_lookup_table(&mioa701_mci_gpio_table);
0747 pxa_set_mci_info(&mioa701_mci_info);
0748 pxa_set_keypad_info(&mioa701_keypad_info);
0749 pxa_set_udc_info(&mioa701_udc_info);
0750 pxa_set_ac97_info(&mioa701_ac97_info);
0751 pm_power_off = mioa701_poweroff;
0752 pwm_add_table(mioa701_pwm_lookup, ARRAY_SIZE(mioa701_pwm_lookup));
0753 gpiod_add_lookup_table(&gpio_vbus_gpiod_table);
0754 platform_add_devices(devices, ARRAY_SIZE(devices));
0755 gsm_init();
0756
0757 i2c_register_board_info(0, ARRAY_AND_SIZE(mioa701_i2c_devices));
0758 i2c_register_board_info(1, ARRAY_AND_SIZE(mioa701_pi2c_devices));
0759 pxa_set_i2c_info(&i2c_pdata);
0760 pxa27x_set_i2c_power_info(NULL);
0761 pxa_set_camera_info(&mioa701_pxacamera_platform_data);
0762
0763 regulator_register_always_on(0, "fixed-5.0V", fixed_5v0_consumers,
0764 ARRAY_SIZE(fixed_5v0_consumers),
0765 5000000);
0766 regulator_has_full_constraints();
0767 }
0768
0769 static void mioa701_machine_exit(void)
0770 {
0771 bootstrap_exit();
0772 gsm_exit();
0773 }
0774
0775 MACHINE_START(MIOA701, "MIO A701")
0776 .atag_offset = 0x100,
0777 .map_io = &pxa27x_map_io,
0778 .nr_irqs = PXA_NR_IRQS,
0779 .init_irq = &pxa27x_init_irq,
0780 .handle_irq = &pxa27x_handle_irq,
0781 .init_machine = mioa701_machine_init,
0782 .init_time = pxa_timer_init,
0783 .restart = mioa701_restart,
0784 MACHINE_END