spitz.c 25 KB

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