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.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 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 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 platform_device_register(&spitz_scoop_1_device); 208 209 /* Akita doesn't have the second SCOOP chip */ 210 if (!machine_is_akita()) 211 platform_device_register(&spitz_scoop_2_device); 212 } 213 214 /* Power control is shared with between one of the CF slots and SD */ 215 static void __maybe_unused spitz_card_pwr_ctrl(uint8_t enable, uint8_t new_cpr) 216 { 217 unsigned short cpr; 218 unsigned long flags; 219 220 if (new_cpr & 0x7) { 221 gpio_set_value(SPITZ_GPIO_CF_POWER, 1); 222 mdelay(5); 223 } 224 225 local_irq_save(flags); 226 227 cpr = read_scoop_reg(&spitz_scoop_1_device.dev, SCOOP_CPR); 228 229 if (enable & new_cpr) 230 cpr |= new_cpr; 231 else 232 cpr &= ~enable; 233 234 write_scoop_reg(&spitz_scoop_1_device.dev, SCOOP_CPR, cpr); 235 236 local_irq_restore(flags); 237 238 if (!(cpr & 0x7)) { 239 mdelay(1); 240 gpio_set_value(SPITZ_GPIO_CF_POWER, 0); 241 } 242 } 243 244 #else 245 static inline void spitz_scoop_init(void) {} 246 static inline void spitz_card_pwr_ctrl(uint8_t enable, uint8_t new_cpr) {} 247 #endif 248 249 /****************************************************************************** 250 * PCMCIA 251 ******************************************************************************/ 252 #if defined(CONFIG_PCMCIA_PXA2XX) || defined(CONFIG_PCMCIA_PXA2XX_MODULE) 253 static void spitz_pcmcia_pwr(struct device *scoop, uint16_t cpr, int nr) 254 { 255 /* Only need to override behaviour for slot 0 */ 256 if (nr == 0) 257 spitz_card_pwr_ctrl( 258 cpr & (SCOOP_CPR_CF_3V | SCOOP_CPR_CF_XV), cpr); 259 else 260 write_scoop_reg(scoop, SCOOP_CPR, cpr); 261 } 262 263 static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = { 264 { 265 .dev = &spitz_scoop_1_device.dev, 266 .irq = SPITZ_IRQ_GPIO_CF_IRQ, 267 .cd_irq = SPITZ_IRQ_GPIO_CF_CD, 268 .cd_irq_str = "PCMCIA0 CD", 269 }, { 270 .dev = &spitz_scoop_2_device.dev, 271 .irq = SPITZ_IRQ_GPIO_CF2_IRQ, 272 .cd_irq = -1, 273 }, 274 }; 275 276 static struct scoop_pcmcia_config spitz_pcmcia_config = { 277 .devs = &spitz_pcmcia_scoop[0], 278 .num_devs = 2, 279 .power_ctrl = spitz_pcmcia_pwr, 280 }; 281 282 static void __init spitz_pcmcia_init(void) 283 { 284 /* Akita has only one PCMCIA slot used */ 285 if (machine_is_akita()) 286 spitz_pcmcia_config.num_devs = 1; 287 288 platform_scoop_config = &spitz_pcmcia_config; 289 } 290 #else 291 static inline void spitz_pcmcia_init(void) {} 292 #endif 293 294 /****************************************************************************** 295 * GPIO keyboard 296 ******************************************************************************/ 297 #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE) 298 299 #define SPITZ_KEY_CALENDAR KEY_F1 300 #define SPITZ_KEY_ADDRESS KEY_F2 301 #define SPITZ_KEY_FN KEY_F3 302 #define SPITZ_KEY_CANCEL KEY_F4 303 #define SPITZ_KEY_EXOK KEY_F5 304 #define SPITZ_KEY_EXCANCEL KEY_F6 305 #define SPITZ_KEY_EXJOGDOWN KEY_F7 306 #define SPITZ_KEY_EXJOGUP KEY_F8 307 #define SPITZ_KEY_JAP1 KEY_LEFTALT 308 #define SPITZ_KEY_JAP2 KEY_RIGHTCTRL 309 #define SPITZ_KEY_SYNC KEY_F9 310 #define SPITZ_KEY_MAIL KEY_F10 311 #define SPITZ_KEY_OK KEY_F11 312 #define SPITZ_KEY_MENU KEY_F12 313 314 static const uint32_t spitz_keymap[] = { 315 KEY(0, 0, KEY_LEFTCTRL), 316 KEY(0, 1, KEY_1), 317 KEY(0, 2, KEY_3), 318 KEY(0, 3, KEY_5), 319 KEY(0, 4, KEY_6), 320 KEY(0, 5, KEY_7), 321 KEY(0, 6, KEY_9), 322 KEY(0, 7, KEY_0), 323 KEY(0, 8, KEY_BACKSPACE), 324 KEY(0, 9, SPITZ_KEY_EXOK), /* EXOK */ 325 KEY(0, 10, SPITZ_KEY_EXCANCEL), /* EXCANCEL */ 326 KEY(1, 1, KEY_2), 327 KEY(1, 2, KEY_4), 328 KEY(1, 3, KEY_R), 329 KEY(1, 4, KEY_Y), 330 KEY(1, 5, KEY_8), 331 KEY(1, 6, KEY_I), 332 KEY(1, 7, KEY_O), 333 KEY(1, 8, KEY_P), 334 KEY(1, 9, SPITZ_KEY_EXJOGDOWN), /* EXJOGDOWN */ 335 KEY(1, 10, SPITZ_KEY_EXJOGUP), /* EXJOGUP */ 336 KEY(2, 0, KEY_TAB), 337 KEY(2, 1, KEY_Q), 338 KEY(2, 2, KEY_E), 339 KEY(2, 3, KEY_T), 340 KEY(2, 4, KEY_G), 341 KEY(2, 5, KEY_U), 342 KEY(2, 6, KEY_J), 343 KEY(2, 7, KEY_K), 344 KEY(3, 0, SPITZ_KEY_ADDRESS), /* ADDRESS */ 345 KEY(3, 1, KEY_W), 346 KEY(3, 2, KEY_S), 347 KEY(3, 3, KEY_F), 348 KEY(3, 4, KEY_V), 349 KEY(3, 5, KEY_H), 350 KEY(3, 6, KEY_M), 351 KEY(3, 7, KEY_L), 352 KEY(3, 9, KEY_RIGHTSHIFT), 353 KEY(4, 0, SPITZ_KEY_CALENDAR), /* CALENDAR */ 354 KEY(4, 1, KEY_A), 355 KEY(4, 2, KEY_D), 356 KEY(4, 3, KEY_C), 357 KEY(4, 4, KEY_B), 358 KEY(4, 5, KEY_N), 359 KEY(4, 6, KEY_DOT), 360 KEY(4, 8, KEY_ENTER), 361 KEY(4, 9, KEY_LEFTSHIFT), 362 KEY(5, 0, SPITZ_KEY_MAIL), /* MAIL */ 363 KEY(5, 1, KEY_Z), 364 KEY(5, 2, KEY_X), 365 KEY(5, 3, KEY_MINUS), 366 KEY(5, 4, KEY_SPACE), 367 KEY(5, 5, KEY_COMMA), 368 KEY(5, 7, KEY_UP), 369 KEY(5, 10, SPITZ_KEY_FN), /* FN */ 370 KEY(6, 0, KEY_SYSRQ), 371 KEY(6, 1, SPITZ_KEY_JAP1), /* JAP1 */ 372 KEY(6, 2, SPITZ_KEY_JAP2), /* JAP2 */ 373 KEY(6, 3, SPITZ_KEY_CANCEL), /* CANCEL */ 374 KEY(6, 4, SPITZ_KEY_OK), /* OK */ 375 KEY(6, 5, SPITZ_KEY_MENU), /* MENU */ 376 KEY(6, 6, KEY_LEFT), 377 KEY(6, 7, KEY_DOWN), 378 KEY(6, 8, KEY_RIGHT), 379 }; 380 381 static const struct matrix_keymap_data spitz_keymap_data = { 382 .keymap = spitz_keymap, 383 .keymap_size = ARRAY_SIZE(spitz_keymap), 384 }; 385 386 static const uint32_t spitz_row_gpios[] = 387 { 12, 17, 91, 34, 36, 38, 39 }; 388 static const uint32_t spitz_col_gpios[] = 389 { 88, 23, 24, 25, 26, 27, 52, 103, 107, 108, 114 }; 390 391 static struct matrix_keypad_platform_data spitz_mkp_pdata = { 392 .keymap_data = &spitz_keymap_data, 393 .row_gpios = spitz_row_gpios, 394 .col_gpios = spitz_col_gpios, 395 .num_row_gpios = ARRAY_SIZE(spitz_row_gpios), 396 .num_col_gpios = ARRAY_SIZE(spitz_col_gpios), 397 .col_scan_delay_us = 10, 398 .debounce_ms = 10, 399 .wakeup = 1, 400 }; 401 402 static struct platform_device spitz_mkp_device = { 403 .name = "matrix-keypad", 404 .id = -1, 405 .dev = { 406 .platform_data = &spitz_mkp_pdata, 407 }, 408 }; 409 410 static void __init spitz_mkp_init(void) 411 { 412 platform_device_register(&spitz_mkp_device); 413 } 414 #else 415 static inline void spitz_mkp_init(void) {} 416 #endif 417 418 /****************************************************************************** 419 * GPIO keys 420 ******************************************************************************/ 421 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 422 static struct gpio_keys_button spitz_gpio_keys[] = { 423 { 424 .type = EV_PWR, 425 .code = KEY_SUSPEND, 426 .gpio = SPITZ_GPIO_ON_KEY, 427 .desc = "On Off", 428 .wakeup = 1, 429 }, 430 /* Two buttons detecting the lid state */ 431 { 432 .type = EV_SW, 433 .code = 0, 434 .gpio = SPITZ_GPIO_SWA, 435 .desc = "Display Down", 436 }, 437 { 438 .type = EV_SW, 439 .code = 1, 440 .gpio = SPITZ_GPIO_SWB, 441 .desc = "Lid Closed", 442 }, 443 }; 444 445 static struct gpio_keys_platform_data spitz_gpio_keys_platform_data = { 446 .buttons = spitz_gpio_keys, 447 .nbuttons = ARRAY_SIZE(spitz_gpio_keys), 448 }; 449 450 static struct platform_device spitz_gpio_keys_device = { 451 .name = "gpio-keys", 452 .id = -1, 453 .dev = { 454 .platform_data = &spitz_gpio_keys_platform_data, 455 }, 456 }; 457 458 static void __init spitz_keys_init(void) 459 { 460 platform_device_register(&spitz_gpio_keys_device); 461 } 462 #else 463 static inline void spitz_keys_init(void) {} 464 #endif 465 466 /****************************************************************************** 467 * LEDs 468 ******************************************************************************/ 469 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) 470 static const struct software_node spitz_gpio_leds_node = { 471 .name = "spitz-leds", 472 }; 473 474 static const struct property_entry spitz_orange_led_props[] = { 475 PROPERTY_ENTRY_STRING("linux,default-trigger", "sharpsl-charge"), 476 PROPERTY_ENTRY_GPIO("gpios", 477 &spitz_scoop_1_gpiochip_node, 6, GPIO_ACTIVE_HIGH), 478 { } 479 }; 480 481 static const struct software_node spitz_orange_led_node = { 482 .name = "spitz:amber:charge", 483 .parent = &spitz_gpio_leds_node, 484 .properties = spitz_orange_led_props, 485 }; 486 487 static const struct property_entry spitz_green_led_props[] = { 488 PROPERTY_ENTRY_STRING("linux,default-trigger", "disk-activity"), 489 PROPERTY_ENTRY_GPIO("gpios", 490 &spitz_scoop_1_gpiochip_node, 0, GPIO_ACTIVE_HIGH), 491 { } 492 }; 493 494 static const struct software_node spitz_green_led_node = { 495 .name = "spitz:green:hddactivity", 496 .parent = &spitz_gpio_leds_node, 497 .properties = spitz_green_led_props, 498 }; 499 500 static const struct software_node *spitz_gpio_leds_swnodes[] = { 501 &spitz_gpio_leds_node, 502 &spitz_orange_led_node, 503 &spitz_green_led_node, 504 NULL 505 }; 506 507 static void __init spitz_leds_init(void) 508 { 509 struct platform_device_info led_info = { 510 .name = "leds-gpio", 511 .id = PLATFORM_DEVID_NONE, 512 }; 513 struct platform_device *led_dev; 514 int err; 515 516 err = software_node_register_node_group(spitz_gpio_leds_swnodes); 517 if (err) { 518 pr_err("failed to register LED software nodes: %d\n", err); 519 return; 520 } 521 522 led_info.fwnode = software_node_fwnode(&spitz_gpio_leds_node); 523 524 led_dev = platform_device_register_full(&led_info); 525 err = PTR_ERR_OR_ZERO(led_dev); 526 if (err) 527 pr_err("failed to create LED device: %d\n", err); 528 } 529 #else 530 static inline void spitz_leds_init(void) {} 531 #endif 532 533 /****************************************************************************** 534 * SSP Devices 535 ******************************************************************************/ 536 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) 537 538 static const struct property_entry spitz_ads7846_props[] = { 539 PROPERTY_ENTRY_STRING("compatible", "ti,ads7846"), 540 PROPERTY_ENTRY_U32("touchscreen-max-pressure", 1024), 541 PROPERTY_ENTRY_U16("ti,x-plate-ohms", 419), 542 PROPERTY_ENTRY_U16("ti,y-plate-ohms", 486), 543 PROPERTY_ENTRY_U16("ti,vref-delay-usecs", 100), 544 PROPERTY_ENTRY_GPIO("pendown-gpios", &pxa2xx_gpiochip_node, 545 SPITZ_GPIO_TP_INT, GPIO_ACTIVE_LOW), 546 PROPERTY_ENTRY_GPIO("ti,hsync-gpios", &pxa2xx_gpiochip_node, 547 SPITZ_GPIO_HSYNC, GPIO_ACTIVE_LOW), 548 { } 549 }; 550 551 static const struct software_node spitz_ads7846_swnode = { 552 .name = "ads7846", 553 .properties = spitz_ads7846_props, 554 }; 555 556 static const struct property_entry spitz_lcdcon_props[] = { 557 PROPERTY_ENTRY_GPIO("BL_CONT-gpios", 558 &spitz_scoop_2_gpiochip_node, 6, GPIO_ACTIVE_LOW), 559 PROPERTY_ENTRY_GPIO("BL_ON-gpios", 560 &spitz_scoop_2_gpiochip_node, 7, GPIO_ACTIVE_HIGH), 561 { } 562 }; 563 564 static const struct property_entry akita_lcdcon_props[] = { 565 PROPERTY_ENTRY_GPIO("BL_ON-gpios", 566 &akita_max7310_gpiochip_node, 3, GPIO_ACTIVE_HIGH), 567 PROPERTY_ENTRY_GPIO("BL_CONT-gpios", 568 &akita_max7310_gpiochip_node, 4, GPIO_ACTIVE_LOW), 569 { } 570 }; 571 572 static struct software_node spitz_lcdcon_node = { 573 .name = "spitz-lcdcon", 574 }; 575 576 static struct corgi_lcd_platform_data spitz_lcdcon_info = { 577 .init_mode = CORGI_LCD_MODE_VGA, 578 .max_intensity = 0x2f, 579 .default_intensity = 0x1f, 580 .limit_mask = 0x0b, 581 .kick_battery = sharpsl_battery_kick, 582 }; 583 584 static struct spi_board_info spitz_spi_devices[] = { 585 { 586 .modalias = "ads7846", 587 .max_speed_hz = 1200000, 588 .bus_num = 2, 589 .chip_select = 0, 590 .swnode = &spitz_ads7846_swnode, 591 .irq = PXA_GPIO_TO_IRQ(SPITZ_GPIO_TP_INT), 592 }, { 593 .modalias = "corgi-lcd", 594 .max_speed_hz = 50000, 595 .bus_num = 2, 596 .chip_select = 1, 597 .platform_data = &spitz_lcdcon_info, 598 .swnode = &spitz_lcdcon_node, 599 }, { 600 .modalias = "max1111", 601 .max_speed_hz = 450000, 602 .bus_num = 2, 603 .chip_select = 2, 604 }, 605 }; 606 607 static const struct software_node_ref_args spitz_spi_gpio_refs[] = { 608 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, SPITZ_GPIO_ADS7846_CS, 609 GPIO_ACTIVE_LOW), 610 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, SPITZ_GPIO_LCDCON_CS, 611 GPIO_ACTIVE_LOW), 612 SOFTWARE_NODE_REFERENCE(&pxa2xx_gpiochip_node, SPITZ_GPIO_MAX1111_CS, 613 GPIO_ACTIVE_LOW), 614 }; 615 616 static const struct property_entry spitz_spi_properties[] = { 617 PROPERTY_ENTRY_REF_ARRAY("gpios", spitz_spi_gpio_refs), 618 { } 619 }; 620 621 static const struct platform_device_info spitz_spi_device_info = { 622 .name = "pxa2xx-spi", 623 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1 */ 624 .id = 2, 625 .properties = spitz_spi_properties, 626 }; 627 628 static void __init spitz_spi_init(void) 629 { 630 struct platform_device *pd; 631 int err; 632 633 pd = platform_device_register_full(&spitz_spi_device_info); 634 err = PTR_ERR_OR_ZERO(pd); 635 if (err) 636 pr_err("pxa2xx-spi: failed to instantiate SPI controller: %d\n", 637 err); 638 639 spitz_lcdcon_node.properties = machine_is_akita() ? 640 akita_lcdcon_props : spitz_lcdcon_props; 641 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices)); 642 } 643 #else 644 static inline void spitz_spi_init(void) {} 645 #endif 646 647 /****************************************************************************** 648 * SD/MMC card controller 649 ******************************************************************************/ 650 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) 651 /* 652 * NOTE: The card detect interrupt isn't debounced so we delay it by 250ms to 653 * give the card a chance to fully insert/eject. 654 */ 655 static int spitz_mci_setpower(struct device *dev, unsigned int vdd) 656 { 657 struct pxamci_platform_data* p_d = dev->platform_data; 658 659 if ((1 << vdd) & p_d->ocr_mask) 660 spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, SCOOP_CPR_SD_3V); 661 else 662 spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, 0x0); 663 664 return 0; 665 } 666 667 static struct pxamci_platform_data spitz_mci_platform_data = { 668 .detect_delay_ms = 250, 669 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 670 .setpower = spitz_mci_setpower, 671 }; 672 673 static const struct property_entry spitz_mci_props[] __initconst = { 674 PROPERTY_ENTRY_GPIO("cd-gpios", &pxa2xx_gpiochip_node, 675 SPITZ_GPIO_nSD_DETECT, GPIO_ACTIVE_LOW), 676 PROPERTY_ENTRY_GPIO("wp-gpios", &pxa2xx_gpiochip_node, 677 SPITZ_GPIO_nSD_WP, GPIO_ACTIVE_LOW), 678 { } 679 }; 680 681 static void __init spitz_mmc_init(void) 682 { 683 pxa_set_mci_info(&spitz_mci_platform_data, spitz_mci_props); 684 } 685 #else 686 static inline void spitz_mmc_init(void) {} 687 #endif 688 689 /****************************************************************************** 690 * USB Host 691 ******************************************************************************/ 692 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 693 static int spitz_ohci_init(struct device *dev) 694 { 695 int err; 696 697 err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST"); 698 if (err) 699 return err; 700 701 /* Only Port 2 is connected, setup USB Port 2 Output Control Register */ 702 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE; 703 704 return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1); 705 } 706 707 static void spitz_ohci_exit(struct device *dev) 708 { 709 gpio_free(SPITZ_GPIO_USB_HOST); 710 } 711 712 static struct pxaohci_platform_data spitz_ohci_platform_data = { 713 .port_mode = PMM_NPS_MODE, 714 .init = spitz_ohci_init, 715 .exit = spitz_ohci_exit, 716 .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION, 717 .power_budget = 150, 718 }; 719 720 static void __init spitz_uhc_init(void) 721 { 722 pxa_set_ohci_info(&spitz_ohci_platform_data); 723 } 724 #else 725 static inline void spitz_uhc_init(void) {} 726 #endif 727 728 /****************************************************************************** 729 * Framebuffer 730 ******************************************************************************/ 731 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) 732 static struct pxafb_mode_info spitz_pxafb_modes[] = { 733 { 734 .pixclock = 19231, 735 .xres = 480, 736 .yres = 640, 737 .bpp = 16, 738 .hsync_len = 40, 739 .left_margin = 46, 740 .right_margin = 125, 741 .vsync_len = 3, 742 .upper_margin = 1, 743 .lower_margin = 0, 744 .sync = 0, 745 }, { 746 .pixclock = 134617, 747 .xres = 240, 748 .yres = 320, 749 .bpp = 16, 750 .hsync_len = 20, 751 .left_margin = 20, 752 .right_margin = 46, 753 .vsync_len = 2, 754 .upper_margin = 1, 755 .lower_margin = 0, 756 .sync = 0, 757 }, 758 }; 759 760 static struct pxafb_mach_info spitz_pxafb_info = { 761 .modes = spitz_pxafb_modes, 762 .num_modes = ARRAY_SIZE(spitz_pxafb_modes), 763 .fixed_modes = 1, 764 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING, 765 }; 766 767 static void __init spitz_lcd_init(void) 768 { 769 pxa_set_fb_info(NULL, &spitz_pxafb_info); 770 } 771 #else 772 static inline void spitz_lcd_init(void) {} 773 #endif 774 775 /****************************************************************************** 776 * NAND Flash 777 ******************************************************************************/ 778 #if defined(CONFIG_MTD_NAND_SHARPSL) || defined(CONFIG_MTD_NAND_SHARPSL_MODULE) 779 static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; 780 781 static struct nand_bbt_descr spitz_nand_bbt = { 782 .options = 0, 783 .offs = 4, 784 .len = 2, 785 .pattern = scan_ff_pattern 786 }; 787 788 static int akita_ooblayout_ecc(struct mtd_info *mtd, int section, 789 struct mtd_oob_region *oobregion) 790 { 791 if (section > 12) 792 return -ERANGE; 793 794 switch (section % 3) { 795 case 0: 796 oobregion->offset = 5; 797 oobregion->length = 1; 798 break; 799 800 case 1: 801 oobregion->offset = 1; 802 oobregion->length = 3; 803 break; 804 805 case 2: 806 oobregion->offset = 6; 807 oobregion->length = 2; 808 break; 809 } 810 811 oobregion->offset += (section / 3) * 0x10; 812 813 return 0; 814 } 815 816 static int akita_ooblayout_free(struct mtd_info *mtd, int section, 817 struct mtd_oob_region *oobregion) 818 { 819 if (section) 820 return -ERANGE; 821 822 oobregion->offset = 8; 823 oobregion->length = 9; 824 825 return 0; 826 } 827 828 static const struct mtd_ooblayout_ops akita_ooblayout_ops = { 829 .ecc = akita_ooblayout_ecc, 830 .free = akita_ooblayout_free, 831 }; 832 833 static const char * const probes[] = { 834 "cmdlinepart", 835 "ofpart", 836 "sharpslpart", 837 NULL, 838 }; 839 840 static struct sharpsl_nand_platform_data spitz_nand_pdata = { 841 .badblock_pattern = &spitz_nand_bbt, 842 .part_parsers = probes, 843 }; 844 845 static struct resource spitz_nand_resources[] = { 846 { 847 .start = PXA_CS3_PHYS, 848 .end = PXA_CS3_PHYS + SZ_4K - 1, 849 .flags = IORESOURCE_MEM, 850 }, 851 }; 852 853 static struct platform_device spitz_nand_device = { 854 .name = "sharpsl-nand", 855 .id = -1, 856 .resource = spitz_nand_resources, 857 .num_resources = ARRAY_SIZE(spitz_nand_resources), 858 .dev = { 859 .platform_data = &spitz_nand_pdata, 860 } 861 }; 862 863 static void __init spitz_nand_init(void) 864 { 865 if (machine_is_akita() || machine_is_borzoi()) { 866 spitz_nand_bbt.len = 1; 867 spitz_nand_pdata.ecc_layout = &akita_ooblayout_ops; 868 } 869 870 platform_device_register(&spitz_nand_device); 871 } 872 #else 873 static inline void spitz_nand_init(void) {} 874 #endif 875 876 /****************************************************************************** 877 * NOR Flash 878 ******************************************************************************/ 879 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 880 static struct mtd_partition spitz_rom_parts[] = { 881 { 882 .name ="Boot PROM Filesystem", 883 .offset = 0x00140000, 884 .size = MTDPART_SIZ_FULL, 885 }, 886 }; 887 888 static struct physmap_flash_data spitz_rom_data = { 889 .width = 2, 890 .nr_parts = ARRAY_SIZE(spitz_rom_parts), 891 .parts = spitz_rom_parts, 892 }; 893 894 static struct resource spitz_rom_resources[] = { 895 { 896 .start = PXA_CS0_PHYS, 897 .end = PXA_CS0_PHYS + SZ_8M - 1, 898 .flags = IORESOURCE_MEM, 899 }, 900 }; 901 902 static struct platform_device spitz_rom_device = { 903 .name = "physmap-flash", 904 .id = -1, 905 .resource = spitz_rom_resources, 906 .num_resources = ARRAY_SIZE(spitz_rom_resources), 907 .dev = { 908 .platform_data = &spitz_rom_data, 909 }, 910 }; 911 912 static void __init spitz_nor_init(void) 913 { 914 platform_device_register(&spitz_rom_device); 915 } 916 #else 917 static inline void spitz_nor_init(void) {} 918 #endif 919 920 /****************************************************************************** 921 * I2C devices 922 ******************************************************************************/ 923 #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE) 924 static struct pca953x_platform_data akita_pca953x_pdata = { 925 .gpio_base = AKITA_IOEXP_GPIO_BASE, 926 }; 927 928 static struct i2c_board_info spitz_i2c_devs[] = { 929 { 930 .type = "wm8750", 931 .addr = 0x1b, 932 }, { 933 .type = "max7310", 934 .addr = 0x18, 935 .platform_data = &akita_pca953x_pdata, 936 }, 937 }; 938 939 static struct regulator_consumer_supply isl6271a_consumers[] = { 940 REGULATOR_SUPPLY("vcc_core", NULL), 941 }; 942 943 static struct regulator_init_data isl6271a_info[] = { 944 { 945 .constraints = { 946 .name = "vcc_core range", 947 .min_uV = 850000, 948 .max_uV = 1600000, 949 .always_on = 1, 950 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, 951 }, 952 .consumer_supplies = isl6271a_consumers, 953 .num_consumer_supplies = ARRAY_SIZE(isl6271a_consumers), 954 } 955 }; 956 957 static struct i2c_board_info spitz_pi2c_devs[] = { 958 { 959 .type = "isl6271a", 960 .addr = 0x0c, 961 .platform_data = &isl6271a_info, 962 }, 963 }; 964 965 static void __init spitz_i2c_init(void) 966 { 967 int size = ARRAY_SIZE(spitz_i2c_devs); 968 969 /* Only Akita has the max7310 chip */ 970 if (!machine_is_akita()) 971 size--; 972 973 pxa_set_i2c_info(NULL); 974 pxa27x_set_i2c_power_info(NULL); 975 i2c_register_board_info(0, spitz_i2c_devs, size); 976 i2c_register_board_info(1, ARRAY_AND_SIZE(spitz_pi2c_devs)); 977 } 978 #else 979 static inline void spitz_i2c_init(void) {} 980 #endif 981 982 static const struct property_entry spitz_audio_props[] = { 983 PROPERTY_ENTRY_GPIO("mute-l-gpios", &spitz_scoop_1_gpiochip_node, 3, 984 GPIO_ACTIVE_HIGH), 985 PROPERTY_ENTRY_GPIO("mute-r-gpios", &spitz_scoop_1_gpiochip_node, 4, 986 GPIO_ACTIVE_HIGH), 987 PROPERTY_ENTRY_GPIO("mic-gpios", &spitz_scoop_2_gpiochip_node, 8, 988 GPIO_ACTIVE_HIGH), 989 { } 990 }; 991 992 static const struct property_entry akita_audio_props[] = { 993 PROPERTY_ENTRY_GPIO("mute-l-gpios", &spitz_scoop_1_gpiochip_node, 3, 994 GPIO_ACTIVE_HIGH), 995 PROPERTY_ENTRY_GPIO("mute-r-gpios", &spitz_scoop_1_gpiochip_node, 4, 996 GPIO_ACTIVE_HIGH), 997 PROPERTY_ENTRY_GPIO("mic-gpios", &akita_max7310_gpiochip_node, 2, 998 GPIO_ACTIVE_HIGH), 999 { } 1000 }; 1001 1002 /****************************************************************************** 1003 * Audio devices 1004 ******************************************************************************/ 1005 static inline void spitz_audio_init(void) 1006 { 1007 struct platform_device_info audio_info = { 1008 .name = "spitz-audio", 1009 .id = PLATFORM_DEVID_NONE, 1010 .properties = machine_is_akita() ? 1011 akita_audio_props : spitz_audio_props, 1012 }; 1013 1014 platform_device_register_full(&audio_info); 1015 } 1016 1017 /****************************************************************************** 1018 * Machine init 1019 ******************************************************************************/ 1020 static void spitz_poweroff(void) 1021 { 1022 pxa_restart(REBOOT_GPIO, NULL); 1023 } 1024 1025 static void spitz_restart(enum reboot_mode mode, const char *cmd) 1026 { 1027 uint32_t msc0 = __raw_readl(MSC0); 1028 /* Bootloader magic for a reboot */ 1029 if ((msc0 & 0xffff0000) == 0x7ff00000) 1030 __raw_writel((msc0 & 0xffff) | 0x7ee00000, MSC0); 1031 1032 spitz_poweroff(); 1033 } 1034 1035 static void __init spitz_init(void) 1036 { 1037 software_node_register(&spitz_scoop_1_gpiochip_node); 1038 if (machine_is_akita()) 1039 software_node_register(&akita_max7310_gpiochip_node); 1040 else 1041 software_node_register(&spitz_scoop_2_gpiochip_node); 1042 1043 init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0); 1044 pm_power_off = spitz_poweroff; 1045 1046 PMCR = 0x00; 1047 1048 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ 1049 PCFR |= PCFR_OPDE; 1050 1051 pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config)); 1052 1053 pxa_set_ffuart_info(NULL); 1054 pxa_set_btuart_info(NULL); 1055 pxa_set_stuart_info(NULL); 1056 1057 spitz_spi_init(); 1058 spitz_scoop_init(); 1059 spitz_mkp_init(); 1060 spitz_keys_init(); 1061 spitz_leds_init(); 1062 spitz_mmc_init(); 1063 spitz_pcmcia_init(); 1064 spitz_uhc_init(); 1065 spitz_lcd_init(); 1066 spitz_nor_init(); 1067 spitz_nand_init(); 1068 spitz_i2c_init(); 1069 spitz_audio_init(); 1070 1071 regulator_has_full_constraints(); 1072 } 1073 1074 static void __init spitz_fixup(struct tag *tags, char **cmdline) 1075 { 1076 sharpsl_save_param(); 1077 memblock_add(0xa0000000, SZ_64M); 1078 } 1079 1080 #ifdef CONFIG_MACH_SPITZ 1081 MACHINE_START(SPITZ, "SHARP Spitz") 1082 .fixup = spitz_fixup, 1083 .map_io = pxa27x_map_io, 1084 .nr_irqs = PXA_NR_IRQS, 1085 .init_irq = pxa27x_init_irq, 1086 .init_machine = spitz_init, 1087 .init_time = pxa_timer_init, 1088 .restart = spitz_restart, 1089 MACHINE_END 1090 #endif 1091 1092 #ifdef CONFIG_MACH_BORZOI 1093 MACHINE_START(BORZOI, "SHARP Borzoi") 1094 .fixup = spitz_fixup, 1095 .map_io = pxa27x_map_io, 1096 .nr_irqs = PXA_NR_IRQS, 1097 .init_irq = pxa27x_init_irq, 1098 .init_machine = spitz_init, 1099 .init_time = pxa_timer_init, 1100 .restart = spitz_restart, 1101 MACHINE_END 1102 #endif 1103 1104 #ifdef CONFIG_MACH_AKITA 1105 MACHINE_START(AKITA, "SHARP Akita") 1106 .fixup = spitz_fixup, 1107 .map_io = pxa27x_map_io, 1108 .nr_irqs = PXA_NR_IRQS, 1109 .init_irq = pxa27x_init_irq, 1110 .init_machine = spitz_init, 1111 .init_time = pxa_timer_init, 1112 .restart = spitz_restart, 1113 MACHINE_END 1114 #endif 1115
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.