Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Support for HP iPAQ hx4700 PDAs. |
| 3 | * |
| 4 | * Copyright (c) 2008-2009 Philipp Zabel |
| 5 | * |
| 6 | * Based on code: |
| 7 | * Copyright (c) 2004 Hewlett-Packard Company. |
| 8 | * Copyright (c) 2005 SDG Systems, LLC |
| 9 | * Copyright (c) 2006 Anton Vorontsov <cbou@mail.ru> |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License version 2 as |
| 13 | * published by the Free Software Foundation. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/delay.h> |
| 21 | #include <linux/fb.h> |
| 22 | #include <linux/gpio.h> |
| 23 | #include <linux/gpio_keys.h> |
| 24 | #include <linux/input.h> |
| 25 | #include <linux/lcd.h> |
| 26 | #include <linux/mfd/htc-egpio.h> |
| 27 | #include <linux/mfd/asic3.h> |
| 28 | #include <linux/mtd/physmap.h> |
| 29 | #include <linux/pda_power.h> |
| 30 | #include <linux/pwm_backlight.h> |
| 31 | #include <linux/regulator/bq24022.h> |
| 32 | #include <linux/regulator/machine.h> |
Philipp Zabel | 6ea0414 | 2009-05-28 07:15:18 +0200 | [diff] [blame] | 33 | #include <linux/regulator/max1586.h> |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 34 | #include <linux/spi/ads7846.h> |
| 35 | #include <linux/spi/spi.h> |
| 36 | #include <linux/usb/gpio_vbus.h> |
| 37 | |
| 38 | #include <mach/hardware.h> |
| 39 | #include <asm/mach-types.h> |
| 40 | #include <asm/mach/arch.h> |
| 41 | |
| 42 | #include <mach/pxa27x.h> |
| 43 | #include <mach/hx4700.h> |
| 44 | #include <plat/i2c.h> |
| 45 | #include <mach/irda.h> |
| 46 | #include <mach/pxa2xx_spi.h> |
| 47 | |
Philipp Zabel | e2c509c | 2009-08-07 17:01:04 +0200 | [diff] [blame] | 48 | #include <video/platform_lcd.h> |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 49 | #include <video/w100fb.h> |
| 50 | |
| 51 | #include "devices.h" |
| 52 | #include "generic.h" |
| 53 | |
| 54 | /* Physical address space information */ |
| 55 | |
| 56 | #define ATI_W3220_PHYS PXA_CS2_PHYS /* ATI Imageon 3220 Graphics */ |
| 57 | #define ASIC3_PHYS PXA_CS3_PHYS |
| 58 | #define ASIC3_SD_PHYS (PXA_CS3_PHYS + 0x02000000) |
| 59 | |
| 60 | static unsigned long hx4700_pin_config[] __initdata = { |
| 61 | |
| 62 | /* SDRAM and Static Memory I/O Signals */ |
| 63 | GPIO20_nSDCS_2, |
| 64 | GPIO21_nSDCS_3, |
| 65 | GPIO15_nCS_1, |
| 66 | GPIO78_nCS_2, /* W3220 */ |
| 67 | GPIO79_nCS_3, /* ASIC3 */ |
| 68 | GPIO80_nCS_4, |
| 69 | GPIO33_nCS_5, /* EGPIO, WLAN */ |
| 70 | |
| 71 | /* PC CARD */ |
| 72 | GPIO48_nPOE, |
| 73 | GPIO49_nPWE, |
| 74 | GPIO50_nPIOR, |
| 75 | GPIO51_nPIOW, |
| 76 | GPIO54_nPCE_2, |
| 77 | GPIO55_nPREG, |
| 78 | GPIO56_nPWAIT, |
| 79 | GPIO57_nIOIS16, |
| 80 | GPIO85_nPCE_1, |
| 81 | GPIO104_PSKTSEL, |
| 82 | |
| 83 | /* I2C */ |
| 84 | GPIO117_I2C_SCL, |
| 85 | GPIO118_I2C_SDA, |
| 86 | |
| 87 | /* FFUART (RS-232) */ |
| 88 | GPIO34_FFUART_RXD, |
| 89 | GPIO35_FFUART_CTS, |
| 90 | GPIO36_FFUART_DCD, |
| 91 | GPIO37_FFUART_DSR, |
| 92 | GPIO38_FFUART_RI, |
| 93 | GPIO39_FFUART_TXD, |
| 94 | GPIO40_FFUART_DTR, |
| 95 | GPIO41_FFUART_RTS, |
| 96 | |
| 97 | /* BTUART */ |
| 98 | GPIO42_BTUART_RXD, |
| 99 | GPIO43_BTUART_TXD, |
| 100 | GPIO44_BTUART_CTS, |
| 101 | GPIO45_BTUART_RTS, |
| 102 | |
| 103 | /* PWM 1 (Backlight) */ |
| 104 | GPIO17_PWM1_OUT, |
| 105 | |
| 106 | /* I2S */ |
| 107 | GPIO28_I2S_BITCLK_OUT, |
| 108 | GPIO29_I2S_SDATA_IN, |
| 109 | GPIO30_I2S_SDATA_OUT, |
| 110 | GPIO31_I2S_SYNC, |
| 111 | GPIO113_I2S_SYSCLK, |
| 112 | |
| 113 | /* SSP 1 (NavPoint) */ |
| 114 | GPIO23_SSP1_SCLK, |
| 115 | GPIO24_SSP1_SFRM, |
| 116 | GPIO25_SSP1_TXD, |
| 117 | GPIO26_SSP1_RXD, |
| 118 | |
| 119 | /* SSP 2 (TSC2046) */ |
| 120 | GPIO19_SSP2_SCLK, |
| 121 | GPIO86_SSP2_RXD, |
| 122 | GPIO87_SSP2_TXD, |
| 123 | GPIO88_GPIO, |
| 124 | |
| 125 | /* HX4700 specific input GPIOs */ |
| 126 | GPIO12_GPIO, /* ASIC3_IRQ */ |
| 127 | GPIO13_GPIO, /* W3220_IRQ */ |
| 128 | GPIO14_GPIO, /* nWLAN_IRQ */ |
| 129 | |
| 130 | GPIO10_GPIO, /* GSM_IRQ */ |
| 131 | GPIO13_GPIO, /* CPLD_IRQ */ |
| 132 | GPIO107_GPIO, /* DS1WM_IRQ */ |
| 133 | GPIO108_GPIO, /* GSM_READY */ |
| 134 | GPIO58_GPIO, /* TSC2046_nPENIRQ */ |
| 135 | GPIO66_GPIO, /* nSDIO_IRQ */ |
| 136 | }; |
| 137 | |
| 138 | #define HX4700_GPIO_IN(num, _desc) \ |
| 139 | { .gpio = (num), .dir = 0, .desc = (_desc) } |
| 140 | #define HX4700_GPIO_OUT(num, _init, _desc) \ |
| 141 | { .gpio = (num), .dir = 1, .init = (_init), .desc = (_desc) } |
| 142 | struct gpio_ress { |
| 143 | unsigned gpio : 8; |
| 144 | unsigned dir : 1; |
| 145 | unsigned init : 1; |
| 146 | char *desc; |
| 147 | }; |
| 148 | |
| 149 | static int hx4700_gpio_request(struct gpio_ress *gpios, int size) |
| 150 | { |
| 151 | int i, rc = 0; |
| 152 | int gpio; |
| 153 | int dir; |
| 154 | |
| 155 | for (i = 0; (!rc) && (i < size); i++) { |
| 156 | gpio = gpios[i].gpio; |
| 157 | dir = gpios[i].dir; |
| 158 | rc = gpio_request(gpio, gpios[i].desc); |
| 159 | if (rc) { |
| 160 | pr_err("Error requesting GPIO %d(%s) : %d\n", |
| 161 | gpio, gpios[i].desc, rc); |
| 162 | continue; |
| 163 | } |
| 164 | if (dir) |
| 165 | gpio_direction_output(gpio, gpios[i].init); |
| 166 | else |
| 167 | gpio_direction_input(gpio); |
| 168 | } |
| 169 | while ((rc) && (--i >= 0)) |
| 170 | gpio_free(gpios[i].gpio); |
| 171 | return rc; |
| 172 | } |
| 173 | |
| 174 | /* |
| 175 | * IRDA |
| 176 | */ |
| 177 | |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 178 | static struct pxaficp_platform_data ficp_info = { |
Marek Vasut | c4bd017 | 2009-07-17 12:50:43 +0200 | [diff] [blame] | 179 | .gpio_pwdown = GPIO105_HX4700_nIR_ON, |
| 180 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 181 | }; |
| 182 | |
| 183 | /* |
| 184 | * GPIO Keys |
| 185 | */ |
| 186 | |
| 187 | #define INIT_KEY(_code, _gpio, _active_low, _desc) \ |
| 188 | { \ |
| 189 | .code = KEY_##_code, \ |
| 190 | .gpio = _gpio, \ |
| 191 | .active_low = _active_low, \ |
| 192 | .desc = _desc, \ |
| 193 | .type = EV_KEY, \ |
| 194 | .wakeup = 1, \ |
| 195 | } |
| 196 | |
| 197 | static struct gpio_keys_button gpio_keys_buttons[] = { |
| 198 | INIT_KEY(POWER, GPIO0_HX4700_nKEY_POWER, 1, "Power button"), |
| 199 | INIT_KEY(MAIL, GPIO94_HX4700_KEY_MAIL, 0, "Mail button"), |
| 200 | INIT_KEY(ADDRESSBOOK, GPIO99_HX4700_KEY_CONTACTS,0, "Contacts button"), |
| 201 | INIT_KEY(RECORD, GPIOD6_nKEY_RECORD, 1, "Record button"), |
| 202 | INIT_KEY(CALENDAR, GPIOD1_nKEY_CALENDAR, 1, "Calendar button"), |
| 203 | INIT_KEY(HOMEPAGE, GPIOD3_nKEY_HOME, 1, "Home button"), |
| 204 | }; |
| 205 | |
| 206 | static struct gpio_keys_platform_data gpio_keys_data = { |
| 207 | .buttons = gpio_keys_buttons, |
| 208 | .nbuttons = ARRAY_SIZE(gpio_keys_buttons), |
| 209 | }; |
| 210 | |
| 211 | static struct platform_device gpio_keys = { |
| 212 | .name = "gpio-keys", |
| 213 | .dev = { |
| 214 | .platform_data = &gpio_keys_data, |
| 215 | }, |
| 216 | .id = -1, |
| 217 | }; |
| 218 | |
| 219 | /* |
| 220 | * ASIC3 |
| 221 | */ |
| 222 | |
| 223 | static u16 asic3_gpio_config[] = { |
| 224 | /* ASIC3 GPIO banks A and B along with some of C and D |
| 225 | implement the buffering for the CF slot. */ |
| 226 | ASIC3_CONFIG_GPIO(0, 1, 1, 0), |
| 227 | ASIC3_CONFIG_GPIO(1, 1, 1, 0), |
| 228 | ASIC3_CONFIG_GPIO(2, 1, 1, 0), |
| 229 | ASIC3_CONFIG_GPIO(3, 1, 1, 0), |
| 230 | ASIC3_CONFIG_GPIO(4, 1, 1, 0), |
| 231 | ASIC3_CONFIG_GPIO(5, 1, 1, 0), |
| 232 | ASIC3_CONFIG_GPIO(6, 1, 1, 0), |
| 233 | ASIC3_CONFIG_GPIO(7, 1, 1, 0), |
| 234 | ASIC3_CONFIG_GPIO(8, 1, 1, 0), |
| 235 | ASIC3_CONFIG_GPIO(9, 1, 1, 0), |
| 236 | ASIC3_CONFIG_GPIO(10, 1, 1, 0), |
| 237 | ASIC3_CONFIG_GPIO(11, 1, 1, 0), |
| 238 | ASIC3_CONFIG_GPIO(12, 1, 1, 0), |
| 239 | ASIC3_CONFIG_GPIO(13, 1, 1, 0), |
| 240 | ASIC3_CONFIG_GPIO(14, 1, 1, 0), |
| 241 | ASIC3_CONFIG_GPIO(15, 1, 1, 0), |
| 242 | |
| 243 | ASIC3_CONFIG_GPIO(16, 1, 1, 0), |
| 244 | ASIC3_CONFIG_GPIO(17, 1, 1, 0), |
| 245 | ASIC3_CONFIG_GPIO(18, 1, 1, 0), |
| 246 | ASIC3_CONFIG_GPIO(19, 1, 1, 0), |
| 247 | ASIC3_CONFIG_GPIO(20, 1, 1, 0), |
| 248 | ASIC3_CONFIG_GPIO(21, 1, 1, 0), |
| 249 | ASIC3_CONFIG_GPIO(22, 1, 1, 0), |
| 250 | ASIC3_CONFIG_GPIO(23, 1, 1, 0), |
| 251 | ASIC3_CONFIG_GPIO(24, 1, 1, 0), |
| 252 | ASIC3_CONFIG_GPIO(25, 1, 1, 0), |
| 253 | ASIC3_CONFIG_GPIO(26, 1, 1, 0), |
| 254 | ASIC3_CONFIG_GPIO(27, 1, 1, 0), |
| 255 | ASIC3_CONFIG_GPIO(28, 1, 1, 0), |
| 256 | ASIC3_CONFIG_GPIO(29, 1, 1, 0), |
| 257 | ASIC3_CONFIG_GPIO(30, 1, 1, 0), |
| 258 | ASIC3_CONFIG_GPIO(31, 1, 1, 0), |
| 259 | |
| 260 | /* GPIOC - CF, LEDs, SD */ |
| 261 | ASIC3_GPIOC0_LED0, /* red */ |
| 262 | ASIC3_GPIOC1_LED1, /* green */ |
| 263 | ASIC3_GPIOC2_LED2, /* blue */ |
| 264 | ASIC3_GPIOC4_CF_nCD, |
| 265 | ASIC3_GPIOC5_nCIOW, |
| 266 | ASIC3_GPIOC6_nCIOR, |
| 267 | ASIC3_GPIOC7_nPCE_1, |
| 268 | ASIC3_GPIOC8_nPCE_2, |
| 269 | ASIC3_GPIOC9_nPOE, |
| 270 | ASIC3_GPIOC10_nPWE, |
| 271 | ASIC3_GPIOC11_PSKTSEL, |
| 272 | ASIC3_GPIOC12_nPREG, |
| 273 | ASIC3_GPIOC13_nPWAIT, |
| 274 | ASIC3_GPIOC14_nPIOIS16, |
| 275 | ASIC3_GPIOC15_nPIOR, |
| 276 | |
| 277 | /* GPIOD: input GPIOs, CF */ |
| 278 | ASIC3_GPIOD11_nCIOIS16, |
| 279 | ASIC3_GPIOD12_nCWAIT, |
| 280 | ASIC3_GPIOD15_nPIOW, |
| 281 | }; |
| 282 | |
| 283 | static struct resource asic3_resources[] = { |
| 284 | /* GPIO part */ |
| 285 | [0] = { |
| 286 | .start = ASIC3_PHYS, |
| 287 | .end = ASIC3_PHYS + ASIC3_MAP_SIZE_16BIT - 1, |
| 288 | .flags = IORESOURCE_MEM, |
| 289 | }, |
| 290 | [1] = { |
| 291 | .start = gpio_to_irq(GPIO12_HX4700_ASIC3_IRQ), |
| 292 | .end = gpio_to_irq(GPIO12_HX4700_ASIC3_IRQ), |
| 293 | .flags = IORESOURCE_IRQ, |
| 294 | }, |
| 295 | /* SD part */ |
| 296 | [2] = { |
| 297 | .start = ASIC3_SD_PHYS, |
| 298 | .end = ASIC3_SD_PHYS + ASIC3_MAP_SIZE_16BIT - 1, |
| 299 | .flags = IORESOURCE_MEM, |
| 300 | }, |
| 301 | [3] = { |
| 302 | .start = gpio_to_irq(GPIO66_HX4700_ASIC3_nSDIO_IRQ), |
| 303 | .end = gpio_to_irq(GPIO66_HX4700_ASIC3_nSDIO_IRQ), |
| 304 | .flags = IORESOURCE_IRQ, |
| 305 | }, |
| 306 | }; |
| 307 | |
| 308 | static struct asic3_platform_data asic3_platform_data = { |
| 309 | .gpio_config = asic3_gpio_config, |
| 310 | .gpio_config_num = ARRAY_SIZE(asic3_gpio_config), |
| 311 | .irq_base = IRQ_BOARD_START, |
| 312 | .gpio_base = HX4700_ASIC3_GPIO_BASE, |
| 313 | }; |
| 314 | |
| 315 | static struct platform_device asic3 = { |
| 316 | .name = "asic3", |
| 317 | .id = -1, |
| 318 | .resource = asic3_resources, |
| 319 | .num_resources = ARRAY_SIZE(asic3_resources), |
| 320 | .dev = { |
| 321 | .platform_data = &asic3_platform_data, |
| 322 | }, |
| 323 | }; |
| 324 | |
| 325 | /* |
| 326 | * EGPIO |
| 327 | */ |
| 328 | |
| 329 | static struct resource egpio_resources[] = { |
| 330 | [0] = { |
| 331 | .start = PXA_CS5_PHYS, |
| 332 | .end = PXA_CS5_PHYS + 0x4 - 1, |
| 333 | .flags = IORESOURCE_MEM, |
| 334 | }, |
| 335 | }; |
| 336 | |
| 337 | static struct htc_egpio_chip egpio_chips[] = { |
| 338 | [0] = { |
| 339 | .reg_start = 0, |
| 340 | .gpio_base = HX4700_EGPIO_BASE, |
| 341 | .num_gpios = 8, |
| 342 | .direction = HTC_EGPIO_OUTPUT, |
| 343 | }, |
| 344 | }; |
| 345 | |
| 346 | static struct htc_egpio_platform_data egpio_info = { |
| 347 | .reg_width = 16, |
| 348 | .bus_width = 16, |
| 349 | .chip = egpio_chips, |
| 350 | .num_chips = ARRAY_SIZE(egpio_chips), |
| 351 | }; |
| 352 | |
| 353 | static struct platform_device egpio = { |
| 354 | .name = "htc-egpio", |
| 355 | .id = -1, |
| 356 | .resource = egpio_resources, |
| 357 | .num_resources = ARRAY_SIZE(egpio_resources), |
| 358 | .dev = { |
| 359 | .platform_data = &egpio_info, |
| 360 | }, |
| 361 | }; |
| 362 | |
| 363 | /* |
| 364 | * LCD - Sony display connected to ATI Imageon w3220 |
| 365 | */ |
| 366 | |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 367 | static void sony_lcd_init(void) |
| 368 | { |
| 369 | gpio_set_value(GPIO84_HX4700_LCD_SQN, 1); |
| 370 | gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0); |
| 371 | gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 0); |
| 372 | gpio_set_value(GPIO70_HX4700_LCD_SLIN1, 0); |
| 373 | gpio_set_value(GPIO62_HX4700_LCD_nRESET, 0); |
| 374 | mdelay(10); |
| 375 | gpio_set_value(GPIO59_HX4700_LCD_PC1, 0); |
| 376 | gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0); |
| 377 | mdelay(20); |
| 378 | |
| 379 | gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 1); |
| 380 | mdelay(5); |
| 381 | gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 1); |
| 382 | |
| 383 | /* FIXME: init w3220 registers here */ |
| 384 | |
| 385 | mdelay(5); |
| 386 | gpio_set_value(GPIO70_HX4700_LCD_SLIN1, 1); |
| 387 | mdelay(10); |
| 388 | gpio_set_value(GPIO62_HX4700_LCD_nRESET, 1); |
| 389 | mdelay(10); |
| 390 | gpio_set_value(GPIO59_HX4700_LCD_PC1, 1); |
| 391 | mdelay(10); |
| 392 | gpio_set_value(GPIO112_HX4700_LCD_N2V7_7V3_ON, 1); |
| 393 | } |
| 394 | |
| 395 | static void sony_lcd_off(void) |
| 396 | { |
| 397 | gpio_set_value(GPIO59_HX4700_LCD_PC1, 0); |
| 398 | gpio_set_value(GPIO62_HX4700_LCD_nRESET, 0); |
| 399 | mdelay(10); |
| 400 | gpio_set_value(GPIO112_HX4700_LCD_N2V7_7V3_ON, 0); |
| 401 | mdelay(10); |
| 402 | gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 0); |
| 403 | mdelay(10); |
| 404 | gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0); |
| 405 | } |
| 406 | |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 407 | #ifdef CONFIG_PM |
| 408 | static void w3220_lcd_suspend(struct w100fb_par *wfb) |
| 409 | { |
| 410 | sony_lcd_off(); |
| 411 | } |
| 412 | |
| 413 | static void w3220_lcd_resume(struct w100fb_par *wfb) |
| 414 | { |
| 415 | sony_lcd_init(); |
| 416 | } |
| 417 | #else |
| 418 | #define w3220_lcd_resume NULL |
| 419 | #define w3220_lcd_suspend NULL |
| 420 | #endif |
| 421 | |
| 422 | static struct w100_tg_info w3220_tg_info = { |
| 423 | .suspend = w3220_lcd_suspend, |
| 424 | .resume = w3220_lcd_resume, |
| 425 | }; |
| 426 | |
| 427 | /* W3220_VGA QVGA */ |
| 428 | static struct w100_gen_regs w3220_regs = { |
| 429 | .lcd_format = 0x00000003, |
| 430 | .lcdd_cntl1 = 0x00000000, |
| 431 | .lcdd_cntl2 = 0x0003ffff, |
| 432 | .genlcd_cntl1 = 0x00abf003, /* 0x00fff003 */ |
| 433 | .genlcd_cntl2 = 0x00000003, |
| 434 | .genlcd_cntl3 = 0x000102aa, |
| 435 | }; |
| 436 | |
| 437 | static struct w100_mode w3220_modes[] = { |
| 438 | { |
| 439 | .xres = 480, |
| 440 | .yres = 640, |
| 441 | .left_margin = 15, |
| 442 | .right_margin = 16, |
| 443 | .upper_margin = 8, |
| 444 | .lower_margin = 7, |
| 445 | .crtc_ss = 0x00000000, |
| 446 | .crtc_ls = 0xa1ff01f9, /* 0x21ff01f9 */ |
| 447 | .crtc_gs = 0xc0000000, /* 0x40000000 */ |
| 448 | .crtc_vpos_gs = 0x0000028f, |
| 449 | .crtc_ps1_active = 0x00000000, /* 0x41060010 */ |
| 450 | .crtc_rev = 0, |
| 451 | .crtc_dclk = 0x80000000, |
| 452 | .crtc_gclk = 0x040a0104, |
| 453 | .crtc_goe = 0, |
| 454 | .pll_freq = 95, |
| 455 | .pixclk_divider = 4, |
| 456 | .pixclk_divider_rotated = 4, |
| 457 | .pixclk_src = CLK_SRC_PLL, |
| 458 | .sysclk_divider = 0, |
| 459 | .sysclk_src = CLK_SRC_PLL, |
| 460 | }, |
| 461 | { |
| 462 | .xres = 240, |
| 463 | .yres = 320, |
| 464 | .left_margin = 9, |
| 465 | .right_margin = 8, |
| 466 | .upper_margin = 5, |
| 467 | .lower_margin = 4, |
| 468 | .crtc_ss = 0x80150014, |
| 469 | .crtc_ls = 0xa0fb00f7, |
| 470 | .crtc_gs = 0xc0080007, |
| 471 | .crtc_vpos_gs = 0x00080007, |
| 472 | .crtc_rev = 0x0000000a, |
| 473 | .crtc_dclk = 0x81700030, |
| 474 | .crtc_gclk = 0x8015010f, |
| 475 | .crtc_goe = 0x00000000, |
| 476 | .pll_freq = 95, |
| 477 | .pixclk_divider = 4, |
| 478 | .pixclk_divider_rotated = 4, |
| 479 | .pixclk_src = CLK_SRC_PLL, |
| 480 | .sysclk_divider = 0, |
| 481 | .sysclk_src = CLK_SRC_PLL, |
| 482 | }, |
| 483 | }; |
| 484 | |
| 485 | struct w100_mem_info w3220_mem_info = { |
| 486 | .ext_cntl = 0x09640011, |
| 487 | .sdram_mode_reg = 0x00600021, |
| 488 | .ext_timing_cntl = 0x1a001545, /* 0x15001545 */ |
| 489 | .io_cntl = 0x7ddd7333, |
| 490 | .size = 0x1fffff, |
| 491 | }; |
| 492 | |
| 493 | struct w100_bm_mem_info w3220_bm_mem_info = { |
| 494 | .ext_mem_bw = 0x50413e01, |
| 495 | .offset = 0, |
| 496 | .ext_timing_ctl = 0x00043f7f, |
| 497 | .ext_cntl = 0x00000010, |
| 498 | .mode_reg = 0x00250000, |
| 499 | .io_cntl = 0x0fff0000, |
| 500 | .config = 0x08301480, |
| 501 | }; |
| 502 | |
| 503 | static struct w100_gpio_regs w3220_gpio_info = { |
| 504 | .init_data1 = 0xdfe00100, /* GPIO_DATA */ |
| 505 | .gpio_dir1 = 0xffff0000, /* GPIO_CNTL1 */ |
| 506 | .gpio_oe1 = 0x00000000, /* GPIO_CNTL2 */ |
| 507 | .init_data2 = 0x00000000, /* GPIO_DATA2 */ |
| 508 | .gpio_dir2 = 0x00000000, /* GPIO_CNTL3 */ |
| 509 | .gpio_oe2 = 0x00000000, /* GPIO_CNTL4 */ |
| 510 | }; |
| 511 | |
| 512 | static struct w100fb_mach_info w3220_info = { |
| 513 | .tg = &w3220_tg_info, |
| 514 | .mem = &w3220_mem_info, |
| 515 | .bm_mem = &w3220_bm_mem_info, |
| 516 | .gpio = &w3220_gpio_info, |
| 517 | .regs = &w3220_regs, |
| 518 | .modelist = w3220_modes, |
| 519 | .num_modes = 2, |
| 520 | .xtal_freq = 16000000, |
| 521 | }; |
| 522 | |
| 523 | static struct resource w3220_resources[] = { |
| 524 | [0] = { |
| 525 | .start = ATI_W3220_PHYS, |
| 526 | .end = ATI_W3220_PHYS + 0x00ffffff, |
| 527 | .flags = IORESOURCE_MEM, |
| 528 | }, |
| 529 | }; |
| 530 | |
| 531 | static struct platform_device w3220 = { |
| 532 | .name = "w100fb", |
| 533 | .id = -1, |
| 534 | .dev = { |
| 535 | .platform_data = &w3220_info, |
| 536 | }, |
| 537 | .num_resources = ARRAY_SIZE(w3220_resources), |
| 538 | .resource = w3220_resources, |
| 539 | }; |
| 540 | |
Philipp Zabel | e2c509c | 2009-08-07 17:01:04 +0200 | [diff] [blame] | 541 | static void hx4700_lcd_set_power(struct plat_lcd_data *pd, unsigned int power) |
| 542 | { |
| 543 | if (power) |
| 544 | sony_lcd_init(); |
| 545 | else |
| 546 | sony_lcd_off(); |
| 547 | } |
| 548 | |
| 549 | static struct plat_lcd_data hx4700_lcd_data = { |
| 550 | .set_power = hx4700_lcd_set_power, |
| 551 | }; |
| 552 | |
| 553 | static struct platform_device hx4700_lcd = { |
| 554 | .name = "platform-lcd", |
| 555 | .id = -1, |
| 556 | .dev = { |
| 557 | .platform_data = &hx4700_lcd_data, |
| 558 | .parent = &w3220.dev, |
| 559 | }, |
| 560 | }; |
| 561 | |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 562 | /* |
| 563 | * Backlight |
| 564 | */ |
| 565 | |
| 566 | static struct platform_pwm_backlight_data backlight_data = { |
| 567 | .pwm_id = 1, |
| 568 | .max_brightness = 200, |
| 569 | .dft_brightness = 100, |
| 570 | .pwm_period_ns = 30923, |
| 571 | }; |
| 572 | |
| 573 | static struct platform_device backlight = { |
| 574 | .name = "pwm-backlight", |
| 575 | .id = -1, |
| 576 | .dev = { |
| 577 | .parent = &pxa27x_device_pwm1.dev, |
| 578 | .platform_data = &backlight_data, |
| 579 | }, |
| 580 | }; |
| 581 | |
| 582 | /* |
| 583 | * USB "Transceiver" |
| 584 | */ |
| 585 | |
| 586 | static struct gpio_vbus_mach_info gpio_vbus_info = { |
| 587 | .gpio_pullup = GPIO76_HX4700_USBC_PUEN, |
| 588 | .gpio_vbus = GPIOD14_nUSBC_DETECT, |
| 589 | .gpio_vbus_inverted = 1, |
| 590 | }; |
| 591 | |
| 592 | static struct platform_device gpio_vbus = { |
| 593 | .name = "gpio-vbus", |
| 594 | .id = -1, |
| 595 | .dev = { |
| 596 | .platform_data = &gpio_vbus_info, |
| 597 | }, |
| 598 | }; |
| 599 | |
| 600 | /* |
| 601 | * Touchscreen - TSC2046 connected to SSP2 |
| 602 | */ |
| 603 | |
| 604 | static const struct ads7846_platform_data tsc2046_info = { |
| 605 | .model = 7846, |
| 606 | .vref_delay_usecs = 100, |
Paul Parsons | 10d5d99 | 2009-11-14 16:54:12 +0000 | [diff] [blame] | 607 | .pressure_max = 1024, |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 608 | .debounce_max = 10, |
| 609 | .debounce_tol = 3, |
| 610 | .debounce_rep = 1, |
| 611 | .gpio_pendown = GPIO58_HX4700_TSC2046_nPENIRQ, |
| 612 | }; |
| 613 | |
| 614 | static struct pxa2xx_spi_chip tsc2046_chip = { |
| 615 | .tx_threshold = 1, |
| 616 | .rx_threshold = 2, |
| 617 | .timeout = 64, |
| 618 | .gpio_cs = GPIO88_HX4700_TSC2046_CS, |
| 619 | }; |
| 620 | |
| 621 | static struct spi_board_info tsc2046_board_info[] __initdata = { |
| 622 | { |
| 623 | .modalias = "ads7846", |
| 624 | .bus_num = 2, |
| 625 | .max_speed_hz = 2600000, /* 100 kHz sample rate */ |
| 626 | .irq = gpio_to_irq(GPIO58_HX4700_TSC2046_nPENIRQ), |
| 627 | .platform_data = &tsc2046_info, |
| 628 | .controller_data = &tsc2046_chip, |
| 629 | }, |
| 630 | }; |
| 631 | |
| 632 | static struct pxa2xx_spi_master pxa_ssp2_master_info = { |
| 633 | .num_chipselect = 1, |
| 634 | .clock_enable = CKEN_SSP2, |
| 635 | .enable_dma = 1, |
| 636 | }; |
| 637 | |
| 638 | /* |
| 639 | * External power |
| 640 | */ |
| 641 | |
| 642 | static int power_supply_init(struct device *dev) |
| 643 | { |
| 644 | return gpio_request(GPIOD9_nAC_IN, "AC charger detect"); |
| 645 | } |
| 646 | |
| 647 | static int hx4700_is_ac_online(void) |
| 648 | { |
| 649 | return !gpio_get_value(GPIOD9_nAC_IN); |
| 650 | } |
| 651 | |
| 652 | static void power_supply_exit(struct device *dev) |
| 653 | { |
| 654 | gpio_free(GPIOD9_nAC_IN); |
| 655 | } |
| 656 | |
| 657 | static char *hx4700_supplicants[] = { |
| 658 | "ds2760-battery.0", "backup-battery" |
| 659 | }; |
| 660 | |
| 661 | static struct pda_power_pdata power_supply_info = { |
| 662 | .init = power_supply_init, |
| 663 | .is_ac_online = hx4700_is_ac_online, |
| 664 | .exit = power_supply_exit, |
| 665 | .supplied_to = hx4700_supplicants, |
| 666 | .num_supplicants = ARRAY_SIZE(hx4700_supplicants), |
| 667 | }; |
| 668 | |
| 669 | static struct resource power_supply_resources[] = { |
| 670 | [0] = { |
| 671 | .name = "ac", |
| 672 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | |
| 673 | IORESOURCE_IRQ_LOWEDGE, |
| 674 | .start = gpio_to_irq(GPIOD9_nAC_IN), |
| 675 | .end = gpio_to_irq(GPIOD9_nAC_IN), |
| 676 | }, |
| 677 | [1] = { |
| 678 | .name = "usb", |
| 679 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | |
| 680 | IORESOURCE_IRQ_LOWEDGE, |
| 681 | .start = gpio_to_irq(GPIOD14_nUSBC_DETECT), |
| 682 | .end = gpio_to_irq(GPIOD14_nUSBC_DETECT), |
| 683 | }, |
| 684 | }; |
| 685 | |
| 686 | static struct platform_device power_supply = { |
| 687 | .name = "pda-power", |
| 688 | .id = -1, |
| 689 | .dev = { |
| 690 | .platform_data = &power_supply_info, |
| 691 | }, |
| 692 | .resource = power_supply_resources, |
| 693 | .num_resources = ARRAY_SIZE(power_supply_resources), |
| 694 | }; |
| 695 | |
| 696 | /* |
| 697 | * Battery charger |
| 698 | */ |
| 699 | |
| 700 | static struct regulator_consumer_supply bq24022_consumers[] = { |
| 701 | { |
| 702 | .dev = &gpio_vbus.dev, |
| 703 | .supply = "vbus_draw", |
| 704 | }, |
| 705 | { |
| 706 | .dev = &power_supply.dev, |
| 707 | .supply = "ac_draw", |
| 708 | }, |
| 709 | }; |
| 710 | |
| 711 | static struct regulator_init_data bq24022_init_data = { |
| 712 | .constraints = { |
| 713 | .max_uA = 500000, |
| 714 | .valid_ops_mask = REGULATOR_CHANGE_CURRENT, |
| 715 | }, |
| 716 | .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers), |
| 717 | .consumer_supplies = bq24022_consumers, |
| 718 | }; |
| 719 | |
| 720 | static struct bq24022_mach_info bq24022_info = { |
| 721 | .gpio_nce = GPIO72_HX4700_BQ24022_nCHARGE_EN, |
| 722 | .gpio_iset2 = GPIO96_HX4700_BQ24022_ISET2, |
| 723 | .init_data = &bq24022_init_data, |
| 724 | }; |
| 725 | |
| 726 | static struct platform_device bq24022 = { |
| 727 | .name = "bq24022", |
| 728 | .id = -1, |
| 729 | .dev = { |
| 730 | .platform_data = &bq24022_info, |
| 731 | }, |
| 732 | }; |
| 733 | |
| 734 | /* |
| 735 | * StrataFlash |
| 736 | */ |
| 737 | |
| 738 | static void hx4700_set_vpp(struct map_info *map, int vpp) |
| 739 | { |
| 740 | gpio_set_value(GPIO91_HX4700_FLASH_VPEN, vpp); |
| 741 | } |
| 742 | |
| 743 | static struct resource strataflash_resource = { |
| 744 | .start = PXA_CS0_PHYS, |
| 745 | .end = PXA_CS0_PHYS + SZ_128M - 1, |
| 746 | .flags = IORESOURCE_MEM, |
| 747 | }; |
| 748 | |
| 749 | static struct physmap_flash_data strataflash_data = { |
| 750 | .width = 4, |
| 751 | .set_vpp = hx4700_set_vpp, |
| 752 | }; |
| 753 | |
| 754 | static struct platform_device strataflash = { |
| 755 | .name = "physmap-flash", |
| 756 | .id = -1, |
| 757 | .resource = &strataflash_resource, |
| 758 | .num_resources = 1, |
| 759 | .dev = { |
| 760 | .platform_data = &strataflash_data, |
| 761 | }, |
| 762 | }; |
| 763 | |
| 764 | /* |
Philipp Zabel | 6ea0414 | 2009-05-28 07:15:18 +0200 | [diff] [blame] | 765 | * Maxim MAX1587A on PI2C |
| 766 | */ |
| 767 | |
| 768 | static struct regulator_consumer_supply max1587a_consumer = { |
| 769 | .supply = "vcc_core", |
| 770 | }; |
| 771 | |
| 772 | static struct regulator_init_data max1587a_v3_info = { |
| 773 | .constraints = { |
| 774 | .name = "vcc_core range", |
| 775 | .min_uV = 900000, |
| 776 | .max_uV = 1705000, |
| 777 | .always_on = 1, |
| 778 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, |
| 779 | }, |
| 780 | .num_consumer_supplies = 1, |
| 781 | .consumer_supplies = &max1587a_consumer, |
| 782 | }; |
| 783 | |
| 784 | static struct max1586_subdev_data max1587a_subdev = { |
| 785 | .name = "vcc_core", |
| 786 | .id = MAX1586_V3, |
| 787 | .platform_data = &max1587a_v3_info, |
| 788 | }; |
| 789 | |
| 790 | static struct max1586_platform_data max1587a_info = { |
| 791 | .num_subdevs = 1, |
| 792 | .subdevs = &max1587a_subdev, |
| 793 | .v3_gain = MAX1586_GAIN_R24_3k32, /* 730..1550 mV */ |
| 794 | }; |
| 795 | |
| 796 | static struct i2c_board_info __initdata pi2c_board_info[] = { |
| 797 | { |
| 798 | I2C_BOARD_INFO("max1586", 0x14), |
| 799 | .platform_data = &max1587a_info, |
| 800 | }, |
| 801 | }; |
| 802 | |
| 803 | /* |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 804 | * PCMCIA |
| 805 | */ |
| 806 | |
| 807 | static struct platform_device pcmcia = { |
| 808 | .name = "hx4700-pcmcia", |
| 809 | .dev = { |
| 810 | .parent = &asic3.dev, |
| 811 | }, |
| 812 | }; |
| 813 | |
| 814 | /* |
| 815 | * Platform devices |
| 816 | */ |
| 817 | |
| 818 | static struct platform_device *devices[] __initdata = { |
| 819 | &asic3, |
| 820 | &gpio_keys, |
| 821 | &backlight, |
| 822 | &w3220, |
Dmitry Artamonow | 19d6c13 | 2009-11-25 14:33:15 +0300 | [diff] [blame] | 823 | &hx4700_lcd, |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 824 | &egpio, |
| 825 | &bq24022, |
| 826 | &gpio_vbus, |
| 827 | &power_supply, |
| 828 | &strataflash, |
| 829 | &pcmcia, |
| 830 | }; |
| 831 | |
Eric Miao | 1847347 | 2009-06-07 23:05:45 +0800 | [diff] [blame] | 832 | static struct gpio_ress global_gpios[] = { |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 833 | HX4700_GPIO_IN(GPIO12_HX4700_ASIC3_IRQ, "ASIC3_IRQ"), |
| 834 | HX4700_GPIO_IN(GPIO13_HX4700_W3220_IRQ, "W3220_IRQ"), |
| 835 | HX4700_GPIO_IN(GPIO14_HX4700_nWLAN_IRQ, "WLAN_IRQ"), |
| 836 | HX4700_GPIO_OUT(GPIO59_HX4700_LCD_PC1, 1, "LCD_PC1"), |
| 837 | HX4700_GPIO_OUT(GPIO62_HX4700_LCD_nRESET, 1, "LCD_RESET"), |
| 838 | HX4700_GPIO_OUT(GPIO70_HX4700_LCD_SLIN1, 1, "LCD_SLIN1"), |
| 839 | HX4700_GPIO_OUT(GPIO84_HX4700_LCD_SQN, 1, "LCD_SQN"), |
| 840 | HX4700_GPIO_OUT(GPIO110_HX4700_LCD_LVDD_3V3_ON, 1, "LCD_LVDD"), |
| 841 | HX4700_GPIO_OUT(GPIO111_HX4700_LCD_AVDD_3V3_ON, 1, "LCD_AVDD"), |
| 842 | HX4700_GPIO_OUT(GPIO32_HX4700_RS232_ON, 1, "RS232_ON"), |
| 843 | HX4700_GPIO_OUT(GPIO71_HX4700_ASIC3_nRESET, 1, "ASIC3_nRESET"), |
| 844 | HX4700_GPIO_OUT(GPIO82_HX4700_EUART_RESET, 1, "EUART_RESET"), |
| 845 | HX4700_GPIO_OUT(GPIO105_HX4700_nIR_ON, 1, "nIR_EN"), |
| 846 | }; |
| 847 | |
| 848 | static void __init hx4700_init(void) |
| 849 | { |
| 850 | pxa2xx_mfp_config(ARRAY_AND_SIZE(hx4700_pin_config)); |
| 851 | hx4700_gpio_request(ARRAY_AND_SIZE(global_gpios)); |
| 852 | |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 853 | pxa_set_ffuart_info(NULL); |
| 854 | pxa_set_btuart_info(NULL); |
| 855 | pxa_set_stuart_info(NULL); |
| 856 | |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 857 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 858 | |
| 859 | pxa_set_ficp_info(&ficp_info); |
| 860 | pxa27x_set_i2c_power_info(NULL); |
| 861 | pxa_set_i2c_info(NULL); |
Philipp Zabel | 6ea0414 | 2009-05-28 07:15:18 +0200 | [diff] [blame] | 862 | i2c_register_board_info(1, ARRAY_AND_SIZE(pi2c_board_info)); |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 863 | pxa2xx_set_spi_info(2, &pxa_ssp2_master_info); |
| 864 | spi_register_board_info(ARRAY_AND_SIZE(tsc2046_board_info)); |
| 865 | |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 866 | gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 0); |
| 867 | mdelay(10); |
| 868 | gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 1); |
| 869 | mdelay(10); |
| 870 | } |
| 871 | |
| 872 | MACHINE_START(H4700, "HP iPAQ HX4700") |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 873 | .boot_params = 0xa0000100, |
Marek Vasut | 851982c | 2010-10-11 02:20:19 +0200 | [diff] [blame] | 874 | .map_io = pxa27x_map_io, |
Haojian Zhuang | 6ac6b81 | 2010-08-20 15:23:59 +0800 | [diff] [blame] | 875 | .nr_irqs = HX4700_NR_IRQS, |
Philipp Zabel | d3ca195 | 2009-05-28 07:05:18 +0200 | [diff] [blame] | 876 | .init_irq = pxa27x_init_irq, |
| 877 | .init_machine = hx4700_init, |
| 878 | .timer = &pxa_timer, |
| 879 | MACHINE_END |