1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Support for Sharp SL-Cxx00 Series of PDAs 4 * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi) 5 * 6 * Copyright (c) 2005 Richard Purdie 7 * 8 * Based on Sharp's 2.4 kernel patches/lubbock.c 9 */ 10 11 #include <linux/kernel.h> 12 #include <linux/platform_device.h> 13 #include <linux/delay.h> 14 #include <linux/gpio_keys.h> 15 #include <linux/gpio/legacy.h> 16 #include <linux/gpio/machine.h> 17 #include <linux/gpio/property.h> 18 #include <linux/leds.h> 19 #include <linux/i2c.h> 20 #include <linux/platform_data/i2c-pxa.h> 21 #include <linux/platform_data/pca953x.h> 22 #include <linux/property.h> 23 #include <linux/spi/spi.h> 24 #include <linux/spi/ads7846.h> 25 #include <linux/spi/corgi_lcd.h> 26 #include <linux/mtd/sharpsl.h> 27 #include <linux/mtd/physmap.h> 28 #include <linux/input-event-codes.h> 29 #include <linux/input/matrix_keypad.h> 30 #include <linux/regulator/machine.h> 31 #include <linux/io.h> 32 #include <linux/property.h> 33 #include <linux/reboot.h> 34 #include <linux/memblock.h> 35 36 #include <asm/setup.h> 37 #include <asm/mach-types.h> 38 #include <asm/mach/arch.h> 39 #include <asm/mach/sharpsl_param.h> 40 #include <asm/hardware/scoop.h> 41 42 #include "pxa27x.h" 43 #include "pxa27x-udc.h" 44 #include "reset.h" 45 #include <linux/platform_data/mmc-pxamci.h> 46 #include <linux/platform_data/usb-ohci-pxa27x.h> 47 #include <linux/platform_data/video-pxafb.h> 48 #include "spitz.h" 49 #include "sharpsl_pm.h" 50 #include "smemc.h" 51 52 #include "generic.h" 53 #include "devices.h" 54 55 /****************************************************************************** 56 * Pin configuration 57 ******************************************************************************/ 58 static unsigned long spitz_pin_config[] __initdata = { 59 /* Chip Selects */ 60 GPIO78_nCS_2, /* SCOOP #2 */ 61 GPIO79_nCS_3, /* NAND */ 62 GPIO80_nCS_4, /* SCOOP #1 */ 63 64 /* LCD - 16bpp Active TFT */ 65 GPIOxx_LCD_TFT_16BPP, 66 67 /* PC Card */ 68 GPIO48_nPOE, 69 GPIO49_nPWE, 70 GPIO50_nPIOR, 71 GPIO51_nPIOW, 72 GPIO85_nPCE_1, 73 GPIO54_nPCE_2, 74 GPIO55_nPREG, 75 GPIO56_nPWAIT, 76 GPIO57_nIOIS16, 77 GPIO104_PSKTSEL, 78 79 /* I2S */ 80 GPIO28_I2S_BITCLK_OUT, 81 GPIO29_I2S_SDATA_IN, 82 GPIO30_I2S_SDATA_OUT, 83 GPIO31_I2S_SYNC, 84 85 /* MMC */ 86 GPIO32_MMC_CLK, 87 GPIO112_MMC_CMD, 88 GPIO92_MMC_DAT_0, 89 GPIO109_MMC_DAT_1, 90 GPIO110_MMC_DAT_2, 91 GPIO111_MMC_DAT_3, 92 93 /* GPIOs */ 94 GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */ 95 GPIO16_GPIO, /* SPITZ_GPIO_SYNC */ 96 GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */ 97 GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */ 98 GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */ 99 GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */ 100 GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */ 101 GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */ 102 GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */ 103 GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */ 104 105 /* GPIO matrix keypad */ 106 GPIO88_GPIO, /* column 0 */ 107 GPIO23_GPIO, /* column 1 */ 108 GPIO24_GPIO, /* column 2 */ 109 GPIO25_GPIO, /* column 3 */ 110 GPIO26_GPIO, /* column 4 */ 111 GPIO27_GPIO, /* column 5 */ 112 GPIO52_GPIO, /* column 6 */ 113 GPIO103_GPIO, /* column 7 */ 114 GPIO107_GPIO, /* column 8 */ 115 GPIO108_GPIO, /* column 9 */ 116 GPIO114_GPIO, /* column 10 */ 117 GPIO12_GPIO, /* row 0 */ 118 GPIO17_GPIO, /* row 1 */ 119 GPIO91_GPIO, /* row 2 */ 120 GPIO34_GPIO, /* row 3 */ 121 GPIO36_GPIO, /* row 4 */ 122 GPIO38_GPIO, /* row 5 */ 123 GPIO39_GPIO, /* row 6 */ 124 125 /* I2C */ 126 GPIO117_I2C_SCL, 127 GPIO118_I2C_SDA, 128 129 GPIO0_GPIO | WAKEUP_ON_EDGE_RISE, /* SPITZ_GPIO_KEY_INT */ 130 GPIO1_GPIO | WAKEUP_ON_EDGE_FALL, /* SPITZ_GPIO_RESET */ 131 }; 132 133 static const struct software_node spitz_scoop_1_gpiochip_node = { 134 .name = "sharp-scoop.0", 135 }; 136 137 /* Only on Spitz */ 138 static const struct software_node spitz_scoop_2_gpiochip_node = { 139 .name = "sharp-scoop.1", 140 }; 141 142 /* Only on Akita */ 143 static const struct software_node akita_max7310_gpiochip_node = { 144 .name = "i2c-max7310", 145 }; 146 147 /****************************************************************************** 148 * Scoop GPIO expander 149 ******************************************************************************/ 150 #if defined(CONFIG_SHARP_SCOOP) || defined(CONFIG_SHARP_SCOOP_MODULE) 151 /* SCOOP Device #1 */ 152 static struct resource spitz_scoop_1_resources[] = { 153 [0] = { 154 .start = 0x10800000, 155 .end = 0x10800fff, 156 .flags = IORESOURCE_MEM, 157 }, 158 }; 159 160 static struct scoop_config spitz_scoop_1_setup = { 161 .io_dir = SPITZ_SCP_IO_DIR, 162 .io_out = SPITZ_SCP_IO_OUT, 163 .suspend_clr = SPITZ_SCP_SUS_CLR, 164 .suspend_set = SPITZ_SCP_SUS_SET, 165 .gpio_base = SPITZ_SCP_GPIO_BASE, 166 }; 167 168 static struct platform_device spitz_scoop_1_device = { 169 .name = "sharp-scoop", 170 .id = 0, 171 .dev = { 172 .platform_data = &spitz_scoop_1_setup, 173 }, 174 .num_resources = ARRAY_SIZE(spitz_scoop_1_resources), 175 .resource = spitz_scoop_1_resources, 176 }; 177 178 /* SCOOP Device #2 */ 179 static struct resource spitz_scoop_2_resources[] = { 180 [0] = { 181 .start = 0x08800040, 182 .end = 0x08800fff, 183 .flags = IORESOURCE_MEM, 184 }, 185 }; 186 187 static struct scoop_config spitz_scoop_2_setup = { 188 .io_dir = SPITZ_SCP2_IO_DIR, 189 .io_out = SPITZ_SCP2_IO_OUT, 190 .suspend_clr = SPITZ_SCP2_SUS_CLR, 191 .suspend_set = SPITZ_SCP2_SUS_SET, 192 .gpio_base = SPITZ_SCP2_GPIO_BASE, 193 }; 194 195 static struct platform_device spitz_scoop_2_device = { 196 .name = "sharp-scoop", 197 .id = 1, 198 .dev = { 199 .platform_data = &spitz_scoop_2_setup, 200 }, 201 .num_resources = ARRAY_SIZE(spitz_scoop_2_resources), 202 .resource = spitz_scoop_2_resources, 203 }; 204 205 static void __init spitz_scoop_init(void) 206 { 207 spitz_scoop_1_device.dev.fwnode = software_node_fwnode(&spitz_scoop_1_gpiochip_node); 208 platform_device_register(&spitz_scoop_1_device); 209 210 /* Akita doesn't have the second SCOOP chip */ 211 if (!machine_is_akita()) { 212 spitz_scoop_2_device.dev.fwnode = software_node_fwnode( 213 &spitz_scoop_2_gpiochip_node); 214 platform_device_register(&spitz_scoop_2_device); 215 } 216 } 217 218 /* Power control is shared with between one of the CF slots and SD */ 219 static void __maybe_unused spitz_card_pwr_ctrl(uint8_t enable, uint8_t new_cpr) 220 { 221 unsigned short cpr; 222 unsigned long flags; 223 224 if (new_cpr & 0x7) { 225 gpio_set_value(SPITZ_GPIO_CF_POWER, 1); 226 mdelay(5); 227 } 228 229 local_irq_save(flags); 230 231 cpr = read_scoop_reg(&spitz_scoop_1_device.dev, SCOOP_CPR); 232 233 if (enable & new_cpr) 234 cpr |= new_cpr; 235 else 236 cpr &= ~enable; 237 238 write_scoop_reg(&spitz_scoop_1_device.dev, SCOOP_CPR, cpr); 239 240 local_irq_restore(flags); 241 242 if (!(cpr & 0x7)) { 243 mdelay(1); 244 gpio_set_value(SPITZ_GPIO_CF_POWER, 0); 245 } 246 } 247 248 #else 249 static inline void spitz_scoop_init(void) {} 250 static inline void spitz_card_pwr_ctrl(uint8_t enable, uint8_t new_cpr) {} 251 #endif 252 253 /****************************************************************************** 254 * PCMCIA 255 ******************************************************************************/ 256 #if defined(CONFIG_PCMCIA_PXA2XX) || defined(CONFIG_PCMCIA_PXA2XX_MODULE) 257 static void spitz_pcmcia_pwr(struct device *scoop, uint16_t cpr, int nr) 258 { 259 /* Only need to override behaviour for slot 0 */ 260 if (nr == 0) 261 spitz_card_pwr_ctrl( 262 cpr & (SCOOP_CPR_CF_3V | SCOOP_CPR_CF_XV), cpr); 263 else 264 write_scoop_reg(scoop, SCOOP_CPR, cpr); 265 } 266 267 static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = { 268 { 269 .dev = &spitz_scoop_1_device.dev, 270 .irq = SPITZ_IRQ_GPIO_CF_IRQ, 271 .cd_irq = SPITZ_IRQ_GPIO_CF_CD, 272 .cd_irq_str = "PCMCIA0 CD", 273 }, { 274 .dev = &spitz_scoop_2_device.dev, 275 .irq = SPITZ_IRQ_GPIO_CF2_IRQ, 276 .cd_irq = -1, 277 }, 278 }; 279 280 static struct scoop_pcmcia_config spitz_pcmcia_config = { 281 .devs = &spitz_pcmcia_scoop[0], 282 .num_devs = 2, 283 .power_ctrl = spitz_pcmcia_pwr, 284 }; 285 286 static void __init spitz_pcmcia_init(void) 287 { 288 /* Akita has only one PCMCIA slot used */ 289 if (machine_is_akita()) 290 spitz_pcmcia_config.num_devs = 1; 291 292 platform_scoop_config = &spitz_pcmcia_config; 293 } 294 #else 295 static inline void spitz_pcmcia_init(void) {} 296 #endif 297 298 /****************************************************************************** 299 * GPIO keyboard 300 ******************************************************************************/ 301 #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE) 302 303 #define SPITZ_KEY_CALENDAR KEY_F1 304 #define SPITZ_KEY_ADDRESS KEY_F2 305 #define SPITZ_KEY_FN KEY_F3 306 #define SPITZ_KEY_CANCEL KEY_F4 307 #define SPITZ_KEY_EXOK KEY_F5 308 #define SPITZ_KEY_EXCANCEL KEY_F6 309 #define SPITZ_KEY_EXJOGDOWN KEY_F7 310 #define SPITZ_KEY_EXJOGUP KEY_F8 311 #define SPITZ_KEY_JAP1 KEY_LEFTALT 312 #define SPITZ_KEY_JAP2 KEY_RIGHTCTRL 313 #define SPITZ_KEY_SYNC KEY_F9 314 #define SPITZ_KEY_MAIL KEY_F10 315 #define SPITZ_KEY_OK KEY_F11 316 #define SPITZ_KEY_MENU KEY_F12 317 318 static const uint32_t spitz_keymap[] = { 319 KEY(0, 0, KEY_LEFTCTRL), 320 KEY(0, 1, KEY_1), 321 KEY(0, 2, KEY_3), 322 KEY(0, 3, KEY_5), 323 KEY(0, 4, KEY_6), 324 KEY(0, 5, KEY_7), 325 KEY(0, 6, KEY_9), 326 KEY(0, 7, KEY_0), 327 KEY(0, 8, KEY_BACKSPACE), 328 KEY(0, 9, SPITZ_KEY_EXOK), /* EXOK */ 329 KEY(0, 10, SPITZ_KEY_EXCANCEL), /* EXCANCEL */ 330 KEY(1, 1, KEY_2), 331 KEY(1, 2, KEY_4), 332 KEY(1, 3, KEY_R), 333 KEY(1, 4, KEY_Y), 334 KEY(1, 5, KEY_8), 335 KEY(1, 6, KEY_I), 336 KEY(1, 7, KEY_O), 337 KEY(1, 8, KEY_P), 338 KEY(1, 9, SPITZ_KEY_EXJOGDOWN), /* EXJOGDOWN */ 339 KEY(1, 10, SPITZ_KEY_EXJOGUP), /* EXJOGUP */ 340 KEY(2, 0, KEY_TAB), 341 KEY(2, 1, KEY_Q), 342 KEY(2, 2, KEY_E), 343 KEY(2, 3, KEY_T), 344 KEY(2, 4, KEY_G), 345 KEY(2, 5, KEY_U), 346 KEY(2, 6, KEY_J), 347 KEY(2, 7, KEY_K), 348 KEY(3, 0, SPITZ_KEY_ADDRESS), /* ADDRESS */ 349 KEY(3, 1, KEY_W), 350 KEY(3, 2, KEY_S), 351 KEY(3, 3, KEY_F), 352 KEY(3, 4, KEY_V), 353 KEY(3, 5, KEY_H), 354 KEY(3, 6, KEY_M), 355 KEY(3, 7, KEY_L), 356 KEY(3, 9, KEY_RIGHTSHIFT), 357 KEY(4, 0, SPITZ_KEY_CALENDAR), /* CALENDAR */ 358 KEY(4, 1, KEY_A), 359 KEY(4, 2, KEY_D), 360 KEY(4, 3, KEY_C), 361 KEY(4, 4, KEY_B), 362 KEY(4, 5, KEY_N), 363 KEY(4, 6, KEY_DOT), 364 KEY(4, 8, KEY_ENTER), 365 KEY(4, 9, KEY_LEFTSHIFT), 366 KEY(5, 0, SPITZ_KEY_MAIL), /* MAIL */ 367 KEY(5, 1, KEY_Z), 368 KEY(5, 2, KEY_X), 369 KEY(5, 3, KEY_MINUS), 370 KEY(5, 4, KEY_SPACE), 371 KEY(5, 5, KEY_COMMA), 372 KEY(5, 7, KEY_UP), 373 KEY(5, 10, SPITZ_KEY_FN), /* FN */ 374 KEY(6, 0, KEY_SYSRQ), 375 KEY(6, 1, SPITZ_KEY_JAP1), /* JAP1 */ 376 KEY(6, 2, SPITZ_KEY_JAP2), /* JAP2 */ 377 KEY(6, 3, SPITZ_KEY_CANCEL), /* CANCEL */ 378 KEY(6, 4, SPITZ_KEY_OK), /* OK */ 379 KEY(6, 5, SPITZ_KEY_MENU), /* MENU */ 380 KEY(6, 6, KEY_LEFT), 381 KEY(6, 7, KEY_DOWN), 382 KEY(6, 8, KEY_RIGHT), 383 }; 384 385 static const struct software_node_ref_args spitz_mkp_row_gpios[] = { 386 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 12, GPIO_ACTIVE_HIGH), 387 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 17, GPIO_ACTIVE_HIGH), 388 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 91, GPIO_ACTIVE_HIGH), 389 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 34, GPIO_ACTIVE_HIGH), 390 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 36, GPIO_ACTIVE_HIGH), 391 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 38, GPIO_ACTIVE_HIGH), 392 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 39, GPIO_ACTIVE_HIGH), 393 }; 394 395 static const struct software_node_ref_args spitz_mkp_col_gpios[] = { 396 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 88, GPIO_ACTIVE_HIGH), 397 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 23, GPIO_ACTIVE_HIGH), 398 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 24, GPIO_ACTIVE_HIGH), 399 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 25, GPIO_ACTIVE_HIGH), 400 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 26, GPIO_ACTIVE_HIGH), 401 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 27, GPIO_ACTIVE_HIGH), 402 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 52, GPIO_ACTIVE_HIGH), 403 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 103, GPIO_ACTIVE_HIGH), 404 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 107, GPIO_ACTIVE_HIGH), 405 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 108, GPIO_ACTIVE_HIGH), 406 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, 114, GPIO_ACTIVE_HIGH), 407 }; 408 409 static const struct property_entry spitz_mkp_properties[] = { 410 PROPERTY_ENTRY_U32_ARRAY("linux,keymap", spitz_keymap), 411 PROPERTY_ENTRY_REF_ARRAY("row-gpios", spitz_mkp_row_gpios), 412 PROPERTY_ENTRY_REF_ARRAY("col-gpios", spitz_mkp_col_gpios), 413 PROPERTY_ENTRY_U32("col-scan-delay-us", 10), 414 PROPERTY_ENTRY_U32("debounce-delay-ms", 10), 415 PROPERTY_ENTRY_BOOL("wakeup-source"), 416 { } 417 }; 418 419 static const struct platform_device_info spitz_mkp_info __initconst = { 420 .name = "matrix-keypad", 421 .id = PLATFORM_DEVID_NONE, 422 .properties = spitz_mkp_properties, 423 }; 424 425 426 static void __init spitz_mkp_init(void) 427 { 428 struct platform_device *pd; 429 int err; 430 431 pd = platform_device_register_full(&spitz_mkp_info); 432 err = PTR_ERR_OR_ZERO(pd); 433 if (err) 434 pr_err("failed to create keypad device: %d\n", err); 435 } 436 #else 437 static inline void spitz_mkp_init(void) {} 438 #endif 439 440 /****************************************************************************** 441 * GPIO keys 442 ******************************************************************************/ 443 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 444 static const struct software_node spitz_gpio_keys_node = { 445 .name = "spitz-gpio-keys", 446 }; 447 448 static const struct property_entry spitz_suspend_key_props[] = { 449 PROPERTY_ENTRY_U32("linux,input-type", EV_PWR), 450 PROPERTY_ENTRY_U32("linux,code", KEY_SUSPEND), 451 PROPERTY_ENTRY_GPIO("gpios", &pxa2xx_gpiochip_node, 452 SPITZ_GPIO_ON_KEY, GPIO_ACTIVE_HIGH), 453 PROPERTY_ENTRY_STRING("label", "On Off"), 454 PROPERTY_ENTRY_BOOL("wakeup-source"), 455 { } 456 }; 457 458 static const struct software_node spitz_suspend_key_node = { 459 .parent = &spitz_gpio_keys_node, 460 .properties = spitz_suspend_key_props, 461 }; 462 463 static const struct property_entry spitz_sw1_props[] = { 464 PROPERTY_ENTRY_U32("linux,input-type", EV_SW), 465 PROPERTY_ENTRY_U32("linux,code", 0), 466 PROPERTY_ENTRY_GPIO("gpios", &pxa2xx_gpiochip_node, 467 SPITZ_GPIO_SWA, GPIO_ACTIVE_HIGH), 468 PROPERTY_ENTRY_STRING("label", "Display Down"), 469 { } 470 }; 471 472 static const struct software_node spitz_sw1_node = { 473 .parent = &spitz_gpio_keys_node, 474 .properties = spitz_sw1_props, 475 }; 476 477 static const struct property_entry spitz_sw2_props[] = { 478 PROPERTY_ENTRY_U32("linux,input-type", EV_SW), 479 PROPERTY_ENTRY_U32("linux,code", 1), 480 PROPERTY_ENTRY_GPIO("gpios", &pxa2xx_gpiochip_node, 481 SPITZ_GPIO_SWB, GPIO_ACTIVE_HIGH), 482 PROPERTY_ENTRY_STRING("label", "Lid Closed"), 483 { } 484 }; 485 486 static const struct software_node spitz_sw2_node = { 487 .parent = &spitz_gpio_keys_node, 488 .properties = spitz_sw2_props, 489 }; 490 491 static const struct software_node *spitz_gpio_keys_swnodes[] = { 492 &spitz_gpio_keys_node, 493 &spitz_suspend_key_node, 494 &spitz_sw1_node, 495 &spitz_sw2_node, 496 NULL 497 }; 498 499 static void __init spitz_keys_init(void) 500 { 501 struct platform_device_info keys_info = { 502 .name = "gpio-keys", 503 .id = PLATFORM_DEVID_NONE, 504 }; 505 struct platform_device *pd; 506 int err; 507 508 err = software_node_register_node_group(spitz_gpio_keys_swnodes); 509 if (err) { 510 pr_err("failed to register gpio-keys software nodes: %d\n", err); 511 return; 512 } 513 514 keys_info.fwnode = software_node_fwnode(&spitz_gpio_keys_node); 515 516 pd = platform_device_register_full(&keys_info); 517 err = PTR_ERR_OR_ZERO(pd); 518 if (err) 519 pr_err("failed to create gpio-keys device: %d\n", err); 520 } 521 #else 522 static inline void spitz_keys_init(void) {} 523 #endif 524 525 /****************************************************************************** 526 * LEDs 527 ******************************************************************************/ 528 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) 529 static const struct software_node spitz_gpio_leds_node = { 530 .name = "spitz-leds", 531 }; 532 533 static const struct property_entry spitz_orange_led_props[] = { 534 PROPERTY_ENTRY_STRING("linux,default-trigger", "sharpsl-charge"), 535 PROPERTY_ENTRY_GPIO("gpios", 536 &spitz_scoop_1_gpiochip_node, 6, GPIO_ACTIVE_HIGH), 537 { } 538 }; 539 540 static const struct software_node spitz_orange_led_node = { 541 .name = "spitz:amber:charge", 542 .parent = &spitz_gpio_leds_node, 543 .properties = spitz_orange_led_props, 544 }; 545 546 static const struct property_entry spitz_green_led_props[] = { 547 PROPERTY_ENTRY_STRING("linux,default-trigger", "disk-activity"), 548 PROPERTY_ENTRY_GPIO("gpios", 549 &spitz_scoop_1_gpiochip_node, 0, GPIO_ACTIVE_HIGH), 550 { } 551 }; 552 553 static const struct software_node spitz_green_led_node = { 554 .name = "spitz:green:hddactivity", 555 .parent = &spitz_gpio_leds_node, 556 .properties = spitz_green_led_props, 557 }; 558 559 static const struct software_node *spitz_gpio_leds_swnodes[] = { 560 &spitz_gpio_leds_node, 561 &spitz_orange_led_node, 562 &spitz_green_led_node, 563 NULL 564 }; 565 566 static void __init spitz_leds_init(void) 567 { 568 struct platform_device_info led_info = { 569 .name = "leds-gpio", 570 .id = PLATFORM_DEVID_NONE, 571 }; 572 struct platform_device *led_dev; 573 int err; 574 575 err = software_node_register_node_group(spitz_gpio_leds_swnodes); 576 if (err) { 577 pr_err("failed to register LED software nodes: %d\n", err); 578 return; 579 } 580 581 led_info.fwnode = software_node_fwnode(&spitz_gpio_leds_node); 582 583 led_dev = platform_device_register_full(&led_info); 584 err = PTR_ERR_OR_ZERO(led_dev); 585 if (err) 586 pr_err("failed to create LED device: %d\n", err); 587 } 588 #else 589 static inline void spitz_leds_init(void) {} 590 #endif 591 592 /****************************************************************************** 593 * SSP Devices 594 ******************************************************************************/ 595 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) 596 597 static const struct property_entry spitz_ads7846_props[] = { 598 PROPERTY_ENTRY_STRING("compatible", "ti,ads7846"), 599 PROPERTY_ENTRY_U32("touchscreen-max-pressure", 1024), 600 PROPERTY_ENTRY_U16("ti,x-plate-ohms", 419), 601 PROPERTY_ENTRY_U16("ti,y-plate-ohms", 486), 602 PROPERTY_ENTRY_U16("ti,vref-delay-usecs", 100), 603 PROPERTY_ENTRY_GPIO("pendown-gpios", &pxa2xx_gpiochip_node, 604 SPITZ_GPIO_TP_INT, GPIO_ACTIVE_LOW), 605 PROPERTY_ENTRY_GPIO("ti,hsync-gpios", &pxa2xx_gpiochip_node, 606 SPITZ_GPIO_HSYNC, GPIO_ACTIVE_LOW), 607 { } 608 }; 609 610 static const struct software_node spitz_ads7846_swnode = { 611 .name = "ads7846", 612 .properties = spitz_ads7846_props, 613 }; 614 615 static const struct property_entry spitz_lcdcon_props[] = { 616 PROPERTY_ENTRY_GPIO("BL_CONT-gpios", 617 &spitz_scoop_2_gpiochip_node, 6, GPIO_ACTIVE_LOW), 618 PROPERTY_ENTRY_GPIO("BL_ON-gpios", 619 &spitz_scoop_2_gpiochip_node, 7, GPIO_ACTIVE_HIGH), 620 { } 621 }; 622 623 static const struct property_entry akita_lcdcon_props[] = { 624 PROPERTY_ENTRY_GPIO("BL_ON-gpios", 625 &akita_max7310_gpiochip_node, 3, GPIO_ACTIVE_HIGH), 626 PROPERTY_ENTRY_GPIO("BL_CONT-gpios", 627 &akita_max7310_gpiochip_node, 4, GPIO_ACTIVE_LOW), 628 { } 629 }; 630 631 static struct software_node spitz_lcdcon_node = { 632 .name = "spitz-lcdcon", 633 }; 634 635 static struct corgi_lcd_platform_data spitz_lcdcon_info = { 636 .init_mode = CORGI_LCD_MODE_VGA, 637 .max_intensity = 0x2f, 638 .default_intensity = 0x1f, 639 .limit_mask = 0x0b, 640 .kick_battery = sharpsl_battery_kick, 641 }; 642 643 static struct spi_board_info spitz_spi_devices[] = { 644 { 645 .modalias = "ads7846", 646 .max_speed_hz = 1200000, 647 .bus_num = 2, 648 .chip_select = 0, 649 .swnode = &spitz_ads7846_swnode, 650 .irq = PXA_GPIO_TO_IRQ(SPITZ_GPIO_TP_INT), 651 }, { 652 .modalias = "corgi-lcd", 653 .max_speed_hz = 50000, 654 .bus_num = 2, 655 .chip_select = 1, 656 .platform_data = &spitz_lcdcon_info, 657 .swnode = &spitz_lcdcon_node, 658 }, { 659 .modalias = "max1111", 660 .max_speed_hz = 450000, 661 .bus_num = 2, 662 .chip_select = 2, 663 }, 664 }; 665 666 static const struct software_node_ref_args spitz_spi_gpio_refs[] = { 667 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, SPITZ_GPIO_ADS7846_CS, 668 GPIO_ACTIVE_LOW), 669 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, SPITZ_GPIO_LCDCON_CS, 670 GPIO_ACTIVE_LOW), 671 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, SPITZ_GPIO_MAX1111_CS, 672 GPIO_ACTIVE_LOW), 673 }; 674 675 static const struct property_entry spitz_spi_properties[] = { 676 PROPERTY_ENTRY_REF_ARRAY("gpios", spitz_spi_gpio_refs), 677 { } 678 }; 679 680 static const struct platform_device_info spitz_spi_device_info = { 681 .name = "pxa2xx-spi", 682 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1 */ 683 .id = 2, 684 .properties = spitz_spi_properties, 685 }; 686 687 static void __init spitz_spi_init(void) 688 { 689 struct platform_device *pd; 690 int err; 691 692 pd = platform_device_register_full(&spitz_spi_device_info); 693 err = PTR_ERR_OR_ZERO(pd); 694 if (err) 695 pr_err("pxa2xx-spi: failed to instantiate SPI controller: %d\n", 696 err); 697 698 spitz_lcdcon_node.properties = machine_is_akita() ? 699 akita_lcdcon_props : spitz_lcdcon_props; 700 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices)); 701 } 702 #else 703 static inline void spitz_spi_init(void) {} 704 #endif 705 706 /****************************************************************************** 707 * SD/MMC card controller 708 ******************************************************************************/ 709 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) 710 /* 711 * NOTE: The card detect interrupt isn't debounced so we delay it by 250ms to 712 * give the card a chance to fully insert/eject. 713 */ 714 static int spitz_mci_setpower(struct device *dev, unsigned int vdd) 715 { 716 struct pxamci_platform_data* p_d = dev->platform_data; 717 718 if ((1 << vdd) & p_d->ocr_mask) 719 spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, SCOOP_CPR_SD_3V); 720 else 721 spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, 0x0); 722 723 return 0; 724 } 725 726 static struct pxamci_platform_data spitz_mci_platform_data = { 727 .detect_delay_ms = 250, 728 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 729 .setpower = spitz_mci_setpower, 730 }; 731 732 static const struct property_entry spitz_mci_props[] __initconst = { 733 PROPERTY_ENTRY_GPIO("cd-gpios", &pxa2xx_gpiochip_node, 734 SPITZ_GPIO_nSD_DETECT, GPIO_ACTIVE_LOW), 735 PROPERTY_ENTRY_GPIO("wp-gpios", &pxa2xx_gpiochip_node, 736 SPITZ_GPIO_nSD_WP, GPIO_ACTIVE_LOW), 737 { } 738 }; 739 740 static void __init spitz_mmc_init(void) 741 { 742 pxa_set_mci_info(&spitz_mci_platform_data, spitz_mci_props); 743 } 744 #else 745 static inline void spitz_mmc_init(void) {} 746 #endif 747 748 /****************************************************************************** 749 * USB Host 750 ******************************************************************************/ 751 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 752 static int spitz_ohci_init(struct device *dev) 753 { 754 int err; 755 756 err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST"); 757 if (err) 758 return err; 759 760 /* Only Port 2 is connected, setup USB Port 2 Output Control Register */ 761 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE; 762 763 return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1); 764 } 765 766 static void spitz_ohci_exit(struct device *dev) 767 { 768 gpio_free(SPITZ_GPIO_USB_HOST); 769 } 770 771 static struct pxaohci_platform_data spitz_ohci_platform_data = { 772 .port_mode = PMM_NPS_MODE, 773 .init = spitz_ohci_init, 774 .exit = spitz_ohci_exit, 775 .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION, 776 .power_budget = 150, 777 }; 778 779 static void __init spitz_uhc_init(void) 780 { 781 pxa_set_ohci_info(&spitz_ohci_platform_data); 782 } 783 #else 784 static inline void spitz_uhc_init(void) {} 785 #endif 786 787 /****************************************************************************** 788 * Framebuffer 789 ******************************************************************************/ 790 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) 791 static struct pxafb_mode_info spitz_pxafb_modes[] = { 792 { 793 .pixclock = 19231, 794 .xres = 480, 795 .yres = 640, 796 .bpp = 16, 797 .hsync_len = 40, 798 .left_margin = 46, 799 .right_margin = 125, 800 .vsync_len = 3, 801 .upper_margin = 1, 802 .lower_margin = 0, 803 .sync = 0, 804 }, { 805 .pixclock = 134617, 806 .xres = 240, 807 .yres = 320, 808 .bpp = 16, 809 .hsync_len = 20, 810 .left_margin = 20, 811 .right_margin = 46, 812 .vsync_len = 2, 813 .upper_margin = 1, 814 .lower_margin = 0, 815 .sync = 0, 816 }, 817 }; 818 819 static struct pxafb_mach_info spitz_pxafb_info = { 820 .modes = spitz_pxafb_modes, 821 .num_modes = ARRAY_SIZE(spitz_pxafb_modes), 822 .fixed_modes = 1, 823 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING, 824 }; 825 826 static void __init spitz_lcd_init(void) 827 { 828 pxa_set_fb_info(NULL, &spitz_pxafb_info); 829 } 830 #else 831 static inline void spitz_lcd_init(void) {} 832 #endif 833 834 /****************************************************************************** 835 * NAND Flash 836 ******************************************************************************/ 837 #if defined(CONFIG_MTD_NAND_SHARPSL) || defined(CONFIG_MTD_NAND_SHARPSL_MODULE) 838 static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; 839 840 static struct nand_bbt_descr spitz_nand_bbt = { 841 .options = 0, 842 .offs = 4, 843 .len = 2, 844 .pattern = scan_ff_pattern 845 }; 846 847 static int akita_ooblayout_ecc(struct mtd_info *mtd, int section, 848 struct mtd_oob_region *oobregion) 849 { 850 if (section > 12) 851 return -ERANGE; 852 853 switch (section % 3) { 854 case 0: 855 oobregion->offset = 5; 856 oobregion->length = 1; 857 break; 858 859 case 1: 860 oobregion->offset = 1; 861 oobregion->length = 3; 862 break; 863 864 case 2: 865 oobregion->offset = 6; 866 oobregion->length = 2; 867 break; 868 } 869 870 oobregion->offset += (section / 3) * 0x10; 871 872 return 0; 873 } 874 875 static int akita_ooblayout_free(struct mtd_info *mtd, int section, 876 struct mtd_oob_region *oobregion) 877 { 878 if (section) 879 return -ERANGE; 880 881 oobregion->offset = 8; 882 oobregion->length = 9; 883 884 return 0; 885 } 886 887 static const struct mtd_ooblayout_ops akita_ooblayout_ops = { 888 .ecc = akita_ooblayout_ecc, 889 .free = akita_ooblayout_free, 890 }; 891 892 static const char * const probes[] = { 893 "cmdlinepart", 894 "ofpart", 895 "sharpslpart", 896 NULL, 897 }; 898 899 static struct sharpsl_nand_platform_data spitz_nand_pdata = { 900 .badblock_pattern = &spitz_nand_bbt, 901 .part_parsers = probes, 902 }; 903 904 static struct resource spitz_nand_resources[] = { 905 { 906 .start = PXA_CS3_PHYS, 907 .end = PXA_CS3_PHYS + SZ_4K - 1, 908 .flags = IORESOURCE_MEM, 909 }, 910 }; 911 912 static struct platform_device spitz_nand_device = { 913 .name = "sharpsl-nand", 914 .id = -1, 915 .resource = spitz_nand_resources, 916 .num_resources = ARRAY_SIZE(spitz_nand_resources), 917 .dev = { 918 .platform_data = &spitz_nand_pdata, 919 } 920 }; 921 922 static void __init spitz_nand_init(void) 923 { 924 if (machine_is_akita() || machine_is_borzoi()) { 925 spitz_nand_bbt.len = 1; 926 spitz_nand_pdata.ecc_layout = &akita_ooblayout_ops; 927 } 928 929 platform_device_register(&spitz_nand_device); 930 } 931 #else 932 static inline void spitz_nand_init(void) {} 933 #endif 934 935 /****************************************************************************** 936 * NOR Flash 937 ******************************************************************************/ 938 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 939 static struct mtd_partition spitz_rom_parts[] = { 940 { 941 .name ="Boot PROM Filesystem", 942 .offset = 0x00140000, 943 .size = MTDPART_SIZ_FULL, 944 }, 945 }; 946 947 static struct physmap_flash_data spitz_rom_data = { 948 .width = 2, 949 .nr_parts = ARRAY_SIZE(spitz_rom_parts), 950 .parts = spitz_rom_parts, 951 }; 952 953 static struct resource spitz_rom_resources[] = { 954 { 955 .start = PXA_CS0_PHYS, 956 .end = PXA_CS0_PHYS + SZ_8M - 1, 957 .flags = IORESOURCE_MEM, 958 }, 959 }; 960 961 static struct platform_device spitz_rom_device = { 962 .name = "physmap-flash", 963 .id = -1, 964 .resource = spitz_rom_resources, 965 .num_resources = ARRAY_SIZE(spitz_rom_resources), 966 .dev = { 967 .platform_data = &spitz_rom_data, 968 }, 969 }; 970 971 static void __init spitz_nor_init(void) 972 { 973 platform_device_register(&spitz_rom_device); 974 } 975 #else 976 static inline void spitz_nor_init(void) {} 977 #endif 978 979 /****************************************************************************** 980 * I2C devices 981 ******************************************************************************/ 982 #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE) 983 static struct pca953x_platform_data akita_pca953x_pdata = { 984 .gpio_base = AKITA_IOEXP_GPIO_BASE, 985 }; 986 987 static struct i2c_board_info spitz_i2c_devs[] = { 988 { 989 .type = "wm8750", 990 .addr = 0x1b, 991 }, { 992 .type = "max7310", 993 .addr = 0x18, 994 .platform_data = &akita_pca953x_pdata, 995 .swnode = &akita_max7310_gpiochip_node, 996 }, 997 }; 998 999 static struct regulator_consumer_supply isl6271a_consumers[] = { 1000 REGULATOR_SUPPLY("vcc_core", NULL), 1001 }; 1002 1003 static struct regulator_init_data isl6271a_info[] = { 1004 { 1005 .constraints = { 1006 .name = "vcc_core range", 1007 .min_uV = 850000, 1008 .max_uV = 1600000, 1009 .always_on = 1, 1010 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, 1011 }, 1012 .consumer_supplies = isl6271a_consumers, 1013 .num_consumer_supplies = ARRAY_SIZE(isl6271a_consumers), 1014 } 1015 }; 1016 1017 static struct i2c_board_info spitz_pi2c_devs[] = { 1018 { 1019 .type = "isl6271a", 1020 .addr = 0x0c, 1021 .platform_data = &isl6271a_info, 1022 }, 1023 }; 1024 1025 static void __init spitz_i2c_init(void) 1026 { 1027 int size = ARRAY_SIZE(spitz_i2c_devs); 1028 1029 /* Only Akita has the max7310 chip */ 1030 if (!machine_is_akita()) 1031 size--; 1032 1033 pxa_set_i2c_info(NULL); 1034 pxa27x_set_i2c_power_info(NULL); 1035 i2c_register_board_info(0, spitz_i2c_devs, size); 1036 i2c_register_board_info(1, ARRAY_AND_SIZE(spitz_pi2c_devs)); 1037 } 1038 #else 1039 static inline void spitz_i2c_init(void) {} 1040 #endif 1041 1042 static const struct property_entry spitz_audio_props[] = { 1043 PROPERTY_ENTRY_GPIO("mute-l-gpios", &spitz_scoop_1_gpiochip_node, 3, 1044 GPIO_ACTIVE_HIGH), 1045 PROPERTY_ENTRY_GPIO("mute-r-gpios", &spitz_scoop_1_gpiochip_node, 4, 1046 GPIO_ACTIVE_HIGH), 1047 PROPERTY_ENTRY_GPIO("mic-gpios", &spitz_scoop_2_gpiochip_node, 8, 1048 GPIO_ACTIVE_HIGH), 1049 { } 1050 }; 1051 1052 static const struct property_entry akita_audio_props[] = { 1053 PROPERTY_ENTRY_GPIO("mute-l-gpios", &spitz_scoop_1_gpiochip_node, 3, 1054 GPIO_ACTIVE_HIGH), 1055 PROPERTY_ENTRY_GPIO("mute-r-gpios", &spitz_scoop_1_gpiochip_node, 4, 1056 GPIO_ACTIVE_HIGH), 1057 PROPERTY_ENTRY_GPIO("mic-gpios", &akita_max7310_gpiochip_node, 2, 1058 GPIO_ACTIVE_HIGH), 1059 { } 1060 }; 1061 1062 /****************************************************************************** 1063 * Audio devices 1064 ******************************************************************************/ 1065 static inline void spitz_audio_init(void) 1066 { 1067 struct platform_device_info audio_info = { 1068 .name = "spitz-audio", 1069 .id = PLATFORM_DEVID_NONE, 1070 .properties = machine_is_akita() ? 1071 akita_audio_props : spitz_audio_props, 1072 }; 1073 1074 platform_device_register_full(&audio_info); 1075 } 1076 1077 /****************************************************************************** 1078 * Machine init 1079 ******************************************************************************/ 1080 static void spitz_poweroff(void) 1081 { 1082 pxa_restart(REBOOT_GPIO, NULL); 1083 } 1084 1085 static void spitz_restart(enum reboot_mode mode, const char *cmd) 1086 { 1087 uint32_t msc0 = __raw_readl(MSC0); 1088 /* Bootloader magic for a reboot */ 1089 if ((msc0 & 0xffff0000) == 0x7ff00000) 1090 __raw_writel((msc0 & 0xffff) | 0x7ee00000, MSC0); 1091 1092 spitz_poweroff(); 1093 } 1094 1095 static void __init spitz_init(void) 1096 { 1097 software_node_register(&spitz_scoop_1_gpiochip_node); 1098 if (machine_is_akita()) 1099 software_node_register(&akita_max7310_gpiochip_node); 1100 else 1101 software_node_register(&spitz_scoop_2_gpiochip_node); 1102 1103 init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0); 1104 register_platform_power_off(spitz_poweroff); 1105 1106 PMCR = 0x00; 1107 1108 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ 1109 PCFR |= PCFR_OPDE; 1110 1111 pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config)); 1112 1113 pxa_set_ffuart_info(NULL); 1114 pxa_set_btuart_info(NULL); 1115 pxa_set_stuart_info(NULL); 1116 1117 spitz_spi_init(); 1118 spitz_scoop_init(); 1119 spitz_mkp_init(); 1120 spitz_keys_init(); 1121 spitz_leds_init(); 1122 spitz_mmc_init(); 1123 spitz_pcmcia_init(); 1124 spitz_uhc_init(); 1125 spitz_lcd_init(); 1126 spitz_nor_init(); 1127 spitz_nand_init(); 1128 spitz_i2c_init(); 1129 spitz_audio_init(); 1130 1131 regulator_has_full_constraints(); 1132 } 1133 1134 static void __init spitz_fixup(struct tag *tags, char **cmdline) 1135 { 1136 sharpsl_save_param(); 1137 memblock_add(0xa0000000, SZ_64M); 1138 } 1139 1140 #ifdef CONFIG_MACH_SPITZ 1141 MACHINE_START(SPITZ, "SHARP Spitz") 1142 .fixup = spitz_fixup, 1143 .map_io = pxa27x_map_io, 1144 .nr_irqs = PXA_NR_IRQS, 1145 .init_irq = pxa27x_init_irq, 1146 .init_machine = spitz_init, 1147 .init_time = pxa_timer_init, 1148 .restart = spitz_restart, 1149 MACHINE_END 1150 #endif 1151 1152 #ifdef CONFIG_MACH_BORZOI 1153 MACHINE_START(BORZOI, "SHARP Borzoi") 1154 .fixup = spitz_fixup, 1155 .map_io = pxa27x_map_io, 1156 .nr_irqs = PXA_NR_IRQS, 1157 .init_irq = pxa27x_init_irq, 1158 .init_machine = spitz_init, 1159 .init_time = pxa_timer_init, 1160 .restart = spitz_restart, 1161 MACHINE_END 1162 #endif 1163 1164 #ifdef CONFIG_MACH_AKITA 1165 MACHINE_START(AKITA, "SHARP Akita") 1166 .fixup = spitz_fixup, 1167 .map_io = pxa27x_map_io, 1168 .nr_irqs = PXA_NR_IRQS, 1169 .init_irq = pxa27x_init_irq, 1170 .init_machine = spitz_init, 1171 .init_time = pxa_timer_init, 1172 .restart = spitz_restart, 1173 MACHINE_END 1174 #endif 1175