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