spitz.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008
  1. /*
  2. * Support for Sharp SL-Cxx00 Series of PDAs
  3. * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi)
  4. *
  5. * Copyright (c) 2005 Richard Purdie
  6. *
  7. * Based on Sharp's 2.4 kernel patches/lubbock.c
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/delay.h>
  17. #include <linux/gpio_keys.h>
  18. #include <linux/gpio.h>
  19. #include <linux/leds.h>
  20. #include <linux/i2c.h>
  21. #include <linux/i2c/pca953x.h>
  22. #include <linux/spi/spi.h>
  23. #include <linux/spi/ads7846.h>
  24. #include <linux/spi/corgi_lcd.h>
  25. #include <linux/mtd/physmap.h>
  26. #include <linux/mtd/sharpsl.h>
  27. #include <linux/input/matrix_keypad.h>
  28. #include <linux/regulator/machine.h>
  29. #include <asm/setup.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/sharpsl_param.h>
  33. #include <asm/hardware/scoop.h>
  34. #include <mach/pxa27x.h>
  35. #include <mach/pxa27x-udc.h>
  36. #include <mach/reset.h>
  37. #include <mach/irda.h>
  38. #include <mach/mmc.h>
  39. #include <mach/ohci.h>
  40. #include <mach/pxafb.h>
  41. #include <mach/pxa2xx_spi.h>
  42. #include <mach/spitz.h>
  43. #include <mach/sharpsl_pm.h>
  44. #include <plat/i2c.h>
  45. #include "generic.h"
  46. #include "devices.h"
  47. /******************************************************************************
  48. * Pin configuration
  49. ******************************************************************************/
  50. static unsigned long spitz_pin_config[] __initdata = {
  51. /* Chip Selects */
  52. GPIO78_nCS_2, /* SCOOP #2 */
  53. GPIO79_nCS_3, /* NAND */
  54. GPIO80_nCS_4, /* SCOOP #1 */
  55. /* LCD - 16bpp Active TFT */
  56. GPIOxx_LCD_TFT_16BPP,
  57. /* PC Card */
  58. GPIO48_nPOE,
  59. GPIO49_nPWE,
  60. GPIO50_nPIOR,
  61. GPIO51_nPIOW,
  62. GPIO85_nPCE_1,
  63. GPIO54_nPCE_2,
  64. GPIO55_nPREG,
  65. GPIO56_nPWAIT,
  66. GPIO57_nIOIS16,
  67. GPIO104_PSKTSEL,
  68. /* I2S */
  69. GPIO28_I2S_BITCLK_OUT,
  70. GPIO29_I2S_SDATA_IN,
  71. GPIO30_I2S_SDATA_OUT,
  72. GPIO31_I2S_SYNC,
  73. /* MMC */
  74. GPIO32_MMC_CLK,
  75. GPIO112_MMC_CMD,
  76. GPIO92_MMC_DAT_0,
  77. GPIO109_MMC_DAT_1,
  78. GPIO110_MMC_DAT_2,
  79. GPIO111_MMC_DAT_3,
  80. /* GPIOs */
  81. GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */
  82. GPIO16_GPIO, /* SPITZ_GPIO_SYNC */
  83. GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */
  84. GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */
  85. GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */
  86. GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */
  87. GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */
  88. GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */
  89. GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */
  90. GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */
  91. /* GPIO matrix keypad */
  92. GPIO88_GPIO, /* column 0 */
  93. GPIO23_GPIO, /* column 1 */
  94. GPIO24_GPIO, /* column 2 */
  95. GPIO25_GPIO, /* column 3 */
  96. GPIO26_GPIO, /* column 4 */
  97. GPIO27_GPIO, /* column 5 */
  98. GPIO52_GPIO, /* column 6 */
  99. GPIO103_GPIO, /* column 7 */
  100. GPIO107_GPIO, /* column 8 */
  101. GPIO108_GPIO, /* column 9 */
  102. GPIO114_GPIO, /* column 10 */
  103. GPIO12_GPIO, /* row 0 */
  104. GPIO17_GPIO, /* row 1 */
  105. GPIO91_GPIO, /* row 2 */
  106. GPIO34_GPIO, /* row 3 */
  107. GPIO36_GPIO, /* row 4 */
  108. GPIO38_GPIO, /* row 5 */
  109. GPIO39_GPIO, /* row 6 */
  110. /* I2C */
  111. GPIO117_I2C_SCL,
  112. GPIO118_I2C_SDA,
  113. GPIO0_GPIO | WAKEUP_ON_EDGE_RISE, /* SPITZ_GPIO_KEY_INT */
  114. GPIO1_GPIO | WAKEUP_ON_EDGE_FALL, /* SPITZ_GPIO_RESET */
  115. };
  116. /******************************************************************************
  117. * Scoop GPIO expander
  118. ******************************************************************************/
  119. #if defined(CONFIG_SHARP_SCOOP) || defined(CONFIG_SHARP_SCOOP_MODULE)
  120. /* SCOOP Device #1 */
  121. static struct resource spitz_scoop_1_resources[] = {
  122. [0] = {
  123. .start = 0x10800000,
  124. .end = 0x10800fff,
  125. .flags = IORESOURCE_MEM,
  126. },
  127. };
  128. static struct scoop_config spitz_scoop_1_setup = {
  129. .io_dir = SPITZ_SCP_IO_DIR,
  130. .io_out = SPITZ_SCP_IO_OUT,
  131. .suspend_clr = SPITZ_SCP_SUS_CLR,
  132. .suspend_set = SPITZ_SCP_SUS_SET,
  133. .gpio_base = SPITZ_SCP_GPIO_BASE,
  134. };
  135. struct platform_device spitz_scoop_1_device = {
  136. .name = "sharp-scoop",
  137. .id = 0,
  138. .dev = {
  139. .platform_data = &spitz_scoop_1_setup,
  140. },
  141. .num_resources = ARRAY_SIZE(spitz_scoop_1_resources),
  142. .resource = spitz_scoop_1_resources,
  143. };
  144. /* SCOOP Device #2 */
  145. static struct resource spitz_scoop_2_resources[] = {
  146. [0] = {
  147. .start = 0x08800040,
  148. .end = 0x08800fff,
  149. .flags = IORESOURCE_MEM,
  150. },
  151. };
  152. static struct scoop_config spitz_scoop_2_setup = {
  153. .io_dir = SPITZ_SCP2_IO_DIR,
  154. .io_out = SPITZ_SCP2_IO_OUT,
  155. .suspend_clr = SPITZ_SCP2_SUS_CLR,
  156. .suspend_set = SPITZ_SCP2_SUS_SET,
  157. .gpio_base = SPITZ_SCP2_GPIO_BASE,
  158. };
  159. struct platform_device spitz_scoop_2_device = {
  160. .name = "sharp-scoop",
  161. .id = 1,
  162. .dev = {
  163. .platform_data = &spitz_scoop_2_setup,
  164. },
  165. .num_resources = ARRAY_SIZE(spitz_scoop_2_resources),
  166. .resource = spitz_scoop_2_resources,
  167. };
  168. static void __init spitz_scoop_init(void)
  169. {
  170. platform_device_register(&spitz_scoop_1_device);
  171. /* Akita doesn't have the second SCOOP chip */
  172. if (!machine_is_akita())
  173. platform_device_register(&spitz_scoop_2_device);
  174. }
  175. /* Power control is shared with between one of the CF slots and SD */
  176. static void spitz_card_pwr_ctrl(uint8_t enable, uint8_t new_cpr)
  177. {
  178. unsigned short cpr;
  179. unsigned long flags;
  180. if (new_cpr & 0x7) {
  181. gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
  182. mdelay(5);
  183. }
  184. local_irq_save(flags);
  185. cpr = read_scoop_reg(&spitz_scoop_1_device.dev, SCOOP_CPR);
  186. if (enable & new_cpr)
  187. cpr |= new_cpr;
  188. else
  189. cpr &= ~enable;
  190. write_scoop_reg(&spitz_scoop_1_device.dev, SCOOP_CPR, cpr);
  191. local_irq_restore(flags);
  192. if (!(cpr & 0x7)) {
  193. mdelay(1);
  194. gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
  195. }
  196. }
  197. #else
  198. static inline void spitz_scoop_init(void) {}
  199. static inline void spitz_card_pwr_ctrl(uint8_t enable, uint8_t new_cpr) {}
  200. #endif
  201. /******************************************************************************
  202. * PCMCIA
  203. ******************************************************************************/
  204. #if defined(CONFIG_PCMCIA_PXA2XX) || defined(CONFIG_PCMCIA_PXA2XX_MODULE)
  205. static void spitz_pcmcia_pwr(struct device *scoop, uint16_t cpr, int nr)
  206. {
  207. /* Only need to override behaviour for slot 0 */
  208. if (nr == 0)
  209. spitz_card_pwr_ctrl(
  210. cpr & (SCOOP_CPR_CF_3V | SCOOP_CPR_CF_XV), cpr);
  211. else
  212. write_scoop_reg(scoop, SCOOP_CPR, cpr);
  213. }
  214. static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
  215. {
  216. .dev = &spitz_scoop_1_device.dev,
  217. .irq = SPITZ_IRQ_GPIO_CF_IRQ,
  218. .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
  219. .cd_irq_str = "PCMCIA0 CD",
  220. }, {
  221. .dev = &spitz_scoop_2_device.dev,
  222. .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
  223. .cd_irq = -1,
  224. },
  225. };
  226. static struct scoop_pcmcia_config spitz_pcmcia_config = {
  227. .devs = &spitz_pcmcia_scoop[0],
  228. .num_devs = 2,
  229. .power_ctrl = spitz_pcmcia_pwr,
  230. };
  231. static void __init spitz_pcmcia_init(void)
  232. {
  233. /* Akita has only one PCMCIA slot used */
  234. if (machine_is_akita())
  235. spitz_pcmcia_config.num_devs = 1;
  236. platform_scoop_config = &spitz_pcmcia_config;
  237. }
  238. #else
  239. static inline void spitz_pcmcia_init(void) {}
  240. #endif
  241. /******************************************************************************
  242. * GPIO keyboard
  243. ******************************************************************************/
  244. #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE)
  245. #define SPITZ_KEY_CALENDAR KEY_F1
  246. #define SPITZ_KEY_ADDRESS KEY_F2
  247. #define SPITZ_KEY_FN KEY_F3
  248. #define SPITZ_KEY_CANCEL KEY_F4
  249. #define SPITZ_KEY_EXOK KEY_F5
  250. #define SPITZ_KEY_EXCANCEL KEY_F6
  251. #define SPITZ_KEY_EXJOGDOWN KEY_F7
  252. #define SPITZ_KEY_EXJOGUP KEY_F8
  253. #define SPITZ_KEY_JAP1 KEY_LEFTALT
  254. #define SPITZ_KEY_JAP2 KEY_RIGHTCTRL
  255. #define SPITZ_KEY_SYNC KEY_F9
  256. #define SPITZ_KEY_MAIL KEY_F10
  257. #define SPITZ_KEY_OK KEY_F11
  258. #define SPITZ_KEY_MENU KEY_F12
  259. static const uint32_t spitz_keymap[] = {
  260. KEY(0, 0, KEY_LEFTCTRL),
  261. KEY(0, 1, KEY_1),
  262. KEY(0, 2, KEY_3),
  263. KEY(0, 3, KEY_5),
  264. KEY(0, 4, KEY_6),
  265. KEY(0, 5, KEY_7),
  266. KEY(0, 6, KEY_9),
  267. KEY(0, 7, KEY_0),
  268. KEY(0, 8, KEY_BACKSPACE),
  269. KEY(0, 9, SPITZ_KEY_EXOK), /* EXOK */
  270. KEY(0, 10, SPITZ_KEY_EXCANCEL), /* EXCANCEL */
  271. KEY(1, 1, KEY_2),
  272. KEY(1, 2, KEY_4),
  273. KEY(1, 3, KEY_R),
  274. KEY(1, 4, KEY_Y),
  275. KEY(1, 5, KEY_8),
  276. KEY(1, 6, KEY_I),
  277. KEY(1, 7, KEY_O),
  278. KEY(1, 8, KEY_P),
  279. KEY(1, 9, SPITZ_KEY_EXJOGDOWN), /* EXJOGDOWN */
  280. KEY(1, 10, SPITZ_KEY_EXJOGUP), /* EXJOGUP */
  281. KEY(2, 0, KEY_TAB),
  282. KEY(2, 1, KEY_Q),
  283. KEY(2, 2, KEY_E),
  284. KEY(2, 3, KEY_T),
  285. KEY(2, 4, KEY_G),
  286. KEY(2, 5, KEY_U),
  287. KEY(2, 6, KEY_J),
  288. KEY(2, 7, KEY_K),
  289. KEY(3, 0, SPITZ_KEY_ADDRESS), /* ADDRESS */
  290. KEY(3, 1, KEY_W),
  291. KEY(3, 2, KEY_S),
  292. KEY(3, 3, KEY_F),
  293. KEY(3, 4, KEY_V),
  294. KEY(3, 5, KEY_H),
  295. KEY(3, 6, KEY_M),
  296. KEY(3, 7, KEY_L),
  297. KEY(3, 9, KEY_RIGHTSHIFT),
  298. KEY(4, 0, SPITZ_KEY_CALENDAR), /* CALENDAR */
  299. KEY(4, 1, KEY_A),
  300. KEY(4, 2, KEY_D),
  301. KEY(4, 3, KEY_C),
  302. KEY(4, 4, KEY_B),
  303. KEY(4, 5, KEY_N),
  304. KEY(4, 6, KEY_DOT),
  305. KEY(4, 8, KEY_ENTER),
  306. KEY(4, 9, KEY_LEFTSHIFT),
  307. KEY(5, 0, SPITZ_KEY_MAIL), /* MAIL */
  308. KEY(5, 1, KEY_Z),
  309. KEY(5, 2, KEY_X),
  310. KEY(5, 3, KEY_MINUS),
  311. KEY(5, 4, KEY_SPACE),
  312. KEY(5, 5, KEY_COMMA),
  313. KEY(5, 7, KEY_UP),
  314. KEY(5, 10, SPITZ_KEY_FN), /* FN */
  315. KEY(6, 0, KEY_SYSRQ),
  316. KEY(6, 1, SPITZ_KEY_JAP1), /* JAP1 */
  317. KEY(6, 2, SPITZ_KEY_JAP2), /* JAP2 */
  318. KEY(6, 3, SPITZ_KEY_CANCEL), /* CANCEL */
  319. KEY(6, 4, SPITZ_KEY_OK), /* OK */
  320. KEY(6, 5, SPITZ_KEY_MENU), /* MENU */
  321. KEY(6, 6, KEY_LEFT),
  322. KEY(6, 7, KEY_DOWN),
  323. KEY(6, 8, KEY_RIGHT),
  324. };
  325. static const struct matrix_keymap_data spitz_keymap_data = {
  326. .keymap = spitz_keymap,
  327. .keymap_size = ARRAY_SIZE(spitz_keymap),
  328. };
  329. static const uint32_t spitz_row_gpios[] =
  330. { 12, 17, 91, 34, 36, 38, 39 };
  331. static const uint32_t spitz_col_gpios[] =
  332. { 88, 23, 24, 25, 26, 27, 52, 103, 107, 108, 114 };
  333. static struct matrix_keypad_platform_data spitz_mkp_pdata = {
  334. .keymap_data = &spitz_keymap_data,
  335. .row_gpios = spitz_row_gpios,
  336. .col_gpios = spitz_col_gpios,
  337. .num_row_gpios = ARRAY_SIZE(spitz_row_gpios),
  338. .num_col_gpios = ARRAY_SIZE(spitz_col_gpios),
  339. .col_scan_delay_us = 10,
  340. .debounce_ms = 10,
  341. .wakeup = 1,
  342. };
  343. static struct platform_device spitz_mkp_device = {
  344. .name = "matrix-keypad",
  345. .id = -1,
  346. .dev = {
  347. .platform_data = &spitz_mkp_pdata,
  348. },
  349. };
  350. static void __init spitz_mkp_init(void)
  351. {
  352. platform_device_register(&spitz_mkp_device);
  353. }
  354. #else
  355. static inline void spitz_mkp_init(void) {}
  356. #endif
  357. /******************************************************************************
  358. * GPIO keys
  359. ******************************************************************************/
  360. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  361. static struct gpio_keys_button spitz_gpio_keys[] = {
  362. {
  363. .type = EV_PWR,
  364. .code = KEY_SUSPEND,
  365. .gpio = SPITZ_GPIO_ON_KEY,
  366. .desc = "On Off",
  367. .wakeup = 1,
  368. },
  369. /* Two buttons detecting the lid state */
  370. {
  371. .type = EV_SW,
  372. .code = 0,
  373. .gpio = SPITZ_GPIO_SWA,
  374. .desc = "Display Down",
  375. },
  376. {
  377. .type = EV_SW,
  378. .code = 1,
  379. .gpio = SPITZ_GPIO_SWB,
  380. .desc = "Lid Closed",
  381. },
  382. };
  383. static struct gpio_keys_platform_data spitz_gpio_keys_platform_data = {
  384. .buttons = spitz_gpio_keys,
  385. .nbuttons = ARRAY_SIZE(spitz_gpio_keys),
  386. };
  387. static struct platform_device spitz_gpio_keys_device = {
  388. .name = "gpio-keys",
  389. .id = -1,
  390. .dev = {
  391. .platform_data = &spitz_gpio_keys_platform_data,
  392. },
  393. };
  394. static void __init spitz_keys_init(void)
  395. {
  396. platform_device_register(&spitz_gpio_keys_device);
  397. }
  398. #else
  399. static inline void spitz_keys_init(void) {}
  400. #endif
  401. /******************************************************************************
  402. * LEDs
  403. ******************************************************************************/
  404. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  405. static struct gpio_led spitz_gpio_leds[] = {
  406. {
  407. .name = "spitz:amber:charge",
  408. .default_trigger = "sharpsl-charge",
  409. .gpio = SPITZ_GPIO_LED_ORANGE,
  410. },
  411. {
  412. .name = "spitz:green:hddactivity",
  413. .default_trigger = "ide-disk",
  414. .gpio = SPITZ_GPIO_LED_GREEN,
  415. },
  416. };
  417. static struct gpio_led_platform_data spitz_gpio_leds_info = {
  418. .leds = spitz_gpio_leds,
  419. .num_leds = ARRAY_SIZE(spitz_gpio_leds),
  420. };
  421. static struct platform_device spitz_led_device = {
  422. .name = "leds-gpio",
  423. .id = -1,
  424. .dev = {
  425. .platform_data = &spitz_gpio_leds_info,
  426. },
  427. };
  428. static void __init spitz_leds_init(void)
  429. {
  430. platform_device_register(&spitz_led_device);
  431. }
  432. #else
  433. static inline void spitz_leds_init(void) {}
  434. #endif
  435. /******************************************************************************
  436. * SSP Devices
  437. ******************************************************************************/
  438. #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
  439. static void spitz_ads7846_wait_for_hsync(void)
  440. {
  441. while (gpio_get_value(SPITZ_GPIO_HSYNC))
  442. cpu_relax();
  443. while (!gpio_get_value(SPITZ_GPIO_HSYNC))
  444. cpu_relax();
  445. }
  446. static struct ads7846_platform_data spitz_ads7846_info = {
  447. .model = 7846,
  448. .vref_delay_usecs = 100,
  449. .x_plate_ohms = 419,
  450. .y_plate_ohms = 486,
  451. .pressure_max = 1024,
  452. .gpio_pendown = SPITZ_GPIO_TP_INT,
  453. .wait_for_sync = spitz_ads7846_wait_for_hsync,
  454. };
  455. static struct pxa2xx_spi_chip spitz_ads7846_chip = {
  456. .gpio_cs = SPITZ_GPIO_ADS7846_CS,
  457. };
  458. static void spitz_bl_kick_battery(void)
  459. {
  460. void (*kick_batt)(void);
  461. kick_batt = symbol_get(sharpsl_battery_kick);
  462. if (kick_batt) {
  463. kick_batt();
  464. symbol_put(sharpsl_battery_kick);
  465. }
  466. }
  467. static struct corgi_lcd_platform_data spitz_lcdcon_info = {
  468. .init_mode = CORGI_LCD_MODE_VGA,
  469. .max_intensity = 0x2f,
  470. .default_intensity = 0x1f,
  471. .limit_mask = 0x0b,
  472. .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT,
  473. .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON,
  474. .kick_battery = spitz_bl_kick_battery,
  475. };
  476. static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
  477. .gpio_cs = SPITZ_GPIO_LCDCON_CS,
  478. };
  479. static struct pxa2xx_spi_chip spitz_max1111_chip = {
  480. .gpio_cs = SPITZ_GPIO_MAX1111_CS,
  481. };
  482. static struct spi_board_info spitz_spi_devices[] = {
  483. {
  484. .modalias = "ads7846",
  485. .max_speed_hz = 1200000,
  486. .bus_num = 2,
  487. .chip_select = 0,
  488. .platform_data = &spitz_ads7846_info,
  489. .controller_data = &spitz_ads7846_chip,
  490. .irq = gpio_to_irq(SPITZ_GPIO_TP_INT),
  491. }, {
  492. .modalias = "corgi-lcd",
  493. .max_speed_hz = 50000,
  494. .bus_num = 2,
  495. .chip_select = 1,
  496. .platform_data = &spitz_lcdcon_info,
  497. .controller_data = &spitz_lcdcon_chip,
  498. }, {
  499. .modalias = "max1111",
  500. .max_speed_hz = 450000,
  501. .bus_num = 2,
  502. .chip_select = 2,
  503. .controller_data = &spitz_max1111_chip,
  504. },
  505. };
  506. static struct pxa2xx_spi_master spitz_spi_info = {
  507. .num_chipselect = 3,
  508. };
  509. static void __init spitz_spi_init(void)
  510. {
  511. struct corgi_lcd_platform_data *lcd_data = &spitz_lcdcon_info;
  512. if (machine_is_akita()) {
  513. lcd_data->gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
  514. lcd_data->gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
  515. }
  516. pxa2xx_set_spi_info(2, &spitz_spi_info);
  517. spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
  518. }
  519. #else
  520. static inline void spitz_spi_init(void) {}
  521. #endif
  522. /******************************************************************************
  523. * SD/MMC card controller
  524. ******************************************************************************/
  525. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  526. /*
  527. * NOTE: The card detect interrupt isn't debounced so we delay it by 250ms to
  528. * give the card a chance to fully insert/eject.
  529. */
  530. static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
  531. {
  532. struct pxamci_platform_data* p_d = dev->platform_data;
  533. if ((1 << vdd) & p_d->ocr_mask)
  534. spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, SCOOP_CPR_SD_3V);
  535. else
  536. spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, 0x0);
  537. }
  538. static struct pxamci_platform_data spitz_mci_platform_data = {
  539. .detect_delay_ms = 250,
  540. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  541. .setpower = spitz_mci_setpower,
  542. .gpio_card_detect = SPITZ_GPIO_nSD_DETECT,
  543. .gpio_card_ro = SPITZ_GPIO_nSD_WP,
  544. .gpio_power = -1,
  545. };
  546. static void __init spitz_mmc_init(void)
  547. {
  548. pxa_set_mci_info(&spitz_mci_platform_data);
  549. }
  550. #else
  551. static inline void spitz_mmc_init(void) {}
  552. #endif
  553. /******************************************************************************
  554. * USB Host
  555. ******************************************************************************/
  556. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  557. static int spitz_ohci_init(struct device *dev)
  558. {
  559. int err;
  560. err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
  561. if (err)
  562. return err;
  563. /* Only Port 2 is connected, setup USB Port 2 Output Control Register */
  564. UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
  565. return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
  566. }
  567. static void spitz_ohci_exit(struct device *dev)
  568. {
  569. gpio_free(SPITZ_GPIO_USB_HOST);
  570. }
  571. static struct pxaohci_platform_data spitz_ohci_platform_data = {
  572. .port_mode = PMM_NPS_MODE,
  573. .init = spitz_ohci_init,
  574. .exit = spitz_ohci_exit,
  575. .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
  576. .power_budget = 150,
  577. };
  578. static void __init spitz_uhc_init(void)
  579. {
  580. pxa_set_ohci_info(&spitz_ohci_platform_data);
  581. }
  582. #else
  583. static inline void spitz_uhc_init(void) {}
  584. #endif
  585. /******************************************************************************
  586. * IrDA
  587. ******************************************************************************/
  588. #if defined(CONFIG_PXA_FICP) || defined(CONFIG_PXA_FICP_MODULE)
  589. static struct pxaficp_platform_data spitz_ficp_platform_data = {
  590. .transceiver_cap = IR_SIRMODE | IR_OFF,
  591. };
  592. static void __init spitz_irda_init(void)
  593. {
  594. if (machine_is_akita())
  595. spitz_ficp_platform_data.gpio_pwdown = AKITA_GPIO_IR_ON;
  596. else
  597. spitz_ficp_platform_data.gpio_pwdown = SPITZ_GPIO_IR_ON;
  598. pxa_set_ficp_info(&spitz_ficp_platform_data);
  599. }
  600. #else
  601. static inline void spitz_irda_init(void) {}
  602. #endif
  603. /******************************************************************************
  604. * Framebuffer
  605. ******************************************************************************/
  606. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  607. static struct pxafb_mode_info spitz_pxafb_modes[] = {
  608. {
  609. .pixclock = 19231,
  610. .xres = 480,
  611. .yres = 640,
  612. .bpp = 16,
  613. .hsync_len = 40,
  614. .left_margin = 46,
  615. .right_margin = 125,
  616. .vsync_len = 3,
  617. .upper_margin = 1,
  618. .lower_margin = 0,
  619. .sync = 0,
  620. }, {
  621. .pixclock = 134617,
  622. .xres = 240,
  623. .yres = 320,
  624. .bpp = 16,
  625. .hsync_len = 20,
  626. .left_margin = 20,
  627. .right_margin = 46,
  628. .vsync_len = 2,
  629. .upper_margin = 1,
  630. .lower_margin = 0,
  631. .sync = 0,
  632. },
  633. };
  634. static struct pxafb_mach_info spitz_pxafb_info = {
  635. .modes = spitz_pxafb_modes,
  636. .num_modes = ARRAY_SIZE(spitz_pxafb_modes),
  637. .fixed_modes = 1,
  638. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
  639. };
  640. static void __init spitz_lcd_init(void)
  641. {
  642. set_pxa_fb_info(&spitz_pxafb_info);
  643. }
  644. #else
  645. static inline void spitz_lcd_init(void) {}
  646. #endif
  647. /******************************************************************************
  648. * Framebuffer
  649. ******************************************************************************/
  650. #if defined(CONFIG_MTD_NAND_SHARPSL) || defined(CONFIG_MTD_NAND_SHARPSL_MODULE)
  651. static struct mtd_partition spitz_nand_partitions[] = {
  652. {
  653. .name = "System Area",
  654. .offset = 0,
  655. .size = 7 * 1024 * 1024,
  656. }, {
  657. .name = "Root Filesystem",
  658. .offset = 7 * 1024 * 1024,
  659. }, {
  660. .name = "Home Filesystem",
  661. .offset = MTDPART_OFS_APPEND,
  662. .size = MTDPART_SIZ_FULL,
  663. },
  664. };
  665. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  666. static struct nand_bbt_descr spitz_nand_bbt = {
  667. .options = 0,
  668. .offs = 4,
  669. .len = 2,
  670. .pattern = scan_ff_pattern
  671. };
  672. static struct nand_ecclayout akita_oobinfo = {
  673. .oobfree = { {0x08, 0x09} },
  674. .eccbytes = 24,
  675. .eccpos = {
  676. 0x05, 0x01, 0x02, 0x03, 0x06, 0x07, 0x15, 0x11,
  677. 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23,
  678. 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37,
  679. },
  680. };
  681. static struct sharpsl_nand_platform_data spitz_nand_pdata = {
  682. .badblock_pattern = &spitz_nand_bbt,
  683. .partitions = spitz_nand_partitions,
  684. .nr_partitions = ARRAY_SIZE(spitz_nand_partitions),
  685. };
  686. static struct resource spitz_nand_resources[] = {
  687. {
  688. .start = PXA_CS3_PHYS,
  689. .end = PXA_CS3_PHYS + SZ_4K - 1,
  690. .flags = IORESOURCE_MEM,
  691. },
  692. };
  693. static struct platform_device spitz_nand_device = {
  694. .name = "sharpsl-nand",
  695. .id = -1,
  696. .resource = spitz_nand_resources,
  697. .num_resources = ARRAY_SIZE(spitz_nand_resources),
  698. .dev = {
  699. .platform_data = &spitz_nand_pdata,
  700. }
  701. };
  702. static void __init spitz_nand_init(void)
  703. {
  704. if (machine_is_spitz()) {
  705. spitz_nand_partitions[1].size = 5 * 1024 * 1024;
  706. } else if (machine_is_akita()) {
  707. spitz_nand_partitions[1].size = 58 * 1024 * 1024;
  708. spitz_nand_bbt.len = 1;
  709. spitz_nand_pdata.ecc_layout = &akita_oobinfo;
  710. } else if (machine_is_borzoi()) {
  711. spitz_nand_partitions[1].size = 32 * 1024 * 1024;
  712. spitz_nand_bbt.len = 1;
  713. spitz_nand_pdata.ecc_layout = &akita_oobinfo;
  714. }
  715. platform_device_register(&spitz_nand_device);
  716. }
  717. #else
  718. static inline void spitz_nand_init(void) {}
  719. #endif
  720. /******************************************************************************
  721. * NOR Flash
  722. ******************************************************************************/
  723. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  724. static struct mtd_partition spitz_rom_parts[] = {
  725. {
  726. .name ="Boot PROM Filesystem",
  727. .offset = 0x00140000,
  728. .size = MTDPART_SIZ_FULL,
  729. },
  730. };
  731. static struct physmap_flash_data spitz_rom_data = {
  732. .width = 2,
  733. .nr_parts = ARRAY_SIZE(spitz_rom_parts),
  734. .parts = spitz_rom_parts,
  735. };
  736. static struct resource spitz_rom_resources[] = {
  737. {
  738. .start = PXA_CS0_PHYS,
  739. .end = PXA_CS0_PHYS + SZ_8M - 1,
  740. .flags = IORESOURCE_MEM,
  741. },
  742. };
  743. static struct platform_device spitz_rom_device = {
  744. .name = "physmap-flash",
  745. .id = -1,
  746. .resource = spitz_rom_resources,
  747. .num_resources = ARRAY_SIZE(spitz_rom_resources),
  748. .dev = {
  749. .platform_data = &spitz_rom_data,
  750. },
  751. };
  752. static void __init spitz_nor_init(void)
  753. {
  754. platform_device_register(&spitz_rom_device);
  755. }
  756. #else
  757. static inline void spitz_nor_init(void) {}
  758. #endif
  759. /******************************************************************************
  760. * GPIO expander
  761. ******************************************************************************/
  762. #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
  763. static struct pca953x_platform_data akita_pca953x_pdata = {
  764. .gpio_base = AKITA_IOEXP_GPIO_BASE,
  765. };
  766. static struct i2c_board_info spitz_i2c_devs[] = {
  767. {
  768. .type = "wm8750",
  769. .addr = 0x1b,
  770. }, {
  771. .type = "max7310",
  772. .addr = 0x18,
  773. .platform_data = &akita_pca953x_pdata,
  774. },
  775. };
  776. static struct regulator_consumer_supply isl6271a_consumers[] = {
  777. {
  778. .supply = "vcc_core",
  779. }
  780. };
  781. static struct regulator_init_data isl6271a_info[] = {
  782. {
  783. .constraints = {
  784. .name = "vcc_core range",
  785. .min_uV = 850000,
  786. .max_uV = 1600000,
  787. .always_on = 1,
  788. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  789. },
  790. .consumer_supplies = isl6271a_consumers,
  791. .num_consumer_supplies = ARRAY_SIZE(isl6271a_consumers),
  792. }
  793. };
  794. static struct i2c_board_info spitz_pi2c_devs[] = {
  795. {
  796. .type = "isl6271a",
  797. .addr = 0x0c,
  798. .platform_data = &isl6271a_info,
  799. },
  800. };
  801. static void __init spitz_i2c_init(void)
  802. {
  803. int size = ARRAY_SIZE(spitz_i2c_devs);
  804. /* Only Akita has the max7310 chip */
  805. if (!machine_is_akita())
  806. size--;
  807. pxa_set_i2c_info(NULL);
  808. pxa27x_set_i2c_power_info(NULL);
  809. i2c_register_board_info(0, spitz_i2c_devs, size);
  810. i2c_register_board_info(1, ARRAY_AND_SIZE(spitz_pi2c_devs));
  811. }
  812. #else
  813. static inline void spitz_i2c_init(void) {}
  814. #endif
  815. /******************************************************************************
  816. * Machine init
  817. ******************************************************************************/
  818. static void spitz_poweroff(void)
  819. {
  820. arm_machine_restart('g', NULL);
  821. }
  822. static void spitz_restart(char mode, const char *cmd)
  823. {
  824. /* Bootloader magic for a reboot */
  825. if ((MSC0 & 0xffff0000) == 0x7ff00000)
  826. MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
  827. spitz_poweroff();
  828. }
  829. static void __init spitz_init(void)
  830. {
  831. init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0);
  832. pm_power_off = spitz_poweroff;
  833. arm_pm_restart = spitz_restart;
  834. PMCR = 0x00;
  835. /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
  836. PCFR |= PCFR_OPDE;
  837. pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
  838. pxa_set_ffuart_info(NULL);
  839. pxa_set_btuart_info(NULL);
  840. pxa_set_stuart_info(NULL);
  841. spitz_spi_init();
  842. spitz_scoop_init();
  843. spitz_mkp_init();
  844. spitz_keys_init();
  845. spitz_leds_init();
  846. spitz_mmc_init();
  847. spitz_pcmcia_init();
  848. spitz_irda_init();
  849. spitz_uhc_init();
  850. spitz_lcd_init();
  851. spitz_nor_init();
  852. spitz_nand_init();
  853. spitz_i2c_init();
  854. }
  855. static void __init spitz_fixup(struct machine_desc *desc,
  856. struct tag *tags, char **cmdline, struct meminfo *mi)
  857. {
  858. sharpsl_save_param();
  859. mi->nr_banks = 1;
  860. mi->bank[0].start = 0xa0000000;
  861. mi->bank[0].size = (64*1024*1024);
  862. }
  863. #ifdef CONFIG_MACH_SPITZ
  864. MACHINE_START(SPITZ, "SHARP Spitz")
  865. .fixup = spitz_fixup,
  866. .map_io = pxa_map_io,
  867. .init_irq = pxa27x_init_irq,
  868. .init_machine = spitz_init,
  869. .timer = &pxa_timer,
  870. MACHINE_END
  871. #endif
  872. #ifdef CONFIG_MACH_BORZOI
  873. MACHINE_START(BORZOI, "SHARP Borzoi")
  874. .fixup = spitz_fixup,
  875. .map_io = pxa_map_io,
  876. .init_irq = pxa27x_init_irq,
  877. .init_machine = spitz_init,
  878. .timer = &pxa_timer,
  879. MACHINE_END
  880. #endif
  881. #ifdef CONFIG_MACH_AKITA
  882. MACHINE_START(AKITA, "SHARP Akita")
  883. .fixup = spitz_fixup,
  884. .map_io = pxa_map_io,
  885. .init_irq = pxa27x_init_irq,
  886. .init_machine = spitz_init,
  887. .timer = &pxa_timer,
  888. MACHINE_END
  889. #endif