spitz.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  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/mtd/physmap.h>
  21. #include <linux/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/mtd/sharpsl.h>
  27. #include <linux/input/matrix_keypad.h>
  28. #include <asm/setup.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/sharpsl_param.h>
  32. #include <asm/hardware/scoop.h>
  33. #include <mach/pxa27x.h>
  34. #include <mach/pxa27x-udc.h>
  35. #include <mach/reset.h>
  36. #include <plat/i2c.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 "generic.h"
  44. #include "devices.h"
  45. #include "sharpsl.h"
  46. static unsigned long spitz_pin_config[] __initdata = {
  47. /* Chip Selects */
  48. GPIO78_nCS_2, /* SCOOP #2 */
  49. GPIO79_nCS_3, /* NAND */
  50. GPIO80_nCS_4, /* SCOOP #1 */
  51. /* LCD - 16bpp Active TFT */
  52. GPIOxx_LCD_TFT_16BPP,
  53. /* PC Card */
  54. GPIO48_nPOE,
  55. GPIO49_nPWE,
  56. GPIO50_nPIOR,
  57. GPIO51_nPIOW,
  58. GPIO85_nPCE_1,
  59. GPIO54_nPCE_2,
  60. GPIO55_nPREG,
  61. GPIO56_nPWAIT,
  62. GPIO57_nIOIS16,
  63. GPIO104_PSKTSEL,
  64. /* I2S */
  65. GPIO28_I2S_BITCLK_OUT,
  66. GPIO29_I2S_SDATA_IN,
  67. GPIO30_I2S_SDATA_OUT,
  68. GPIO31_I2S_SYNC,
  69. /* MMC */
  70. GPIO32_MMC_CLK,
  71. GPIO112_MMC_CMD,
  72. GPIO92_MMC_DAT_0,
  73. GPIO109_MMC_DAT_1,
  74. GPIO110_MMC_DAT_2,
  75. GPIO111_MMC_DAT_3,
  76. /* GPIOs */
  77. GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */
  78. GPIO16_GPIO, /* SPITZ_GPIO_SYNC */
  79. GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */
  80. GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */
  81. GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */
  82. GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */
  83. GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */
  84. GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */
  85. GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */
  86. GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */
  87. /* GPIO matrix keypad */
  88. GPIO88_GPIO, /* column 0 */
  89. GPIO23_GPIO, /* column 1 */
  90. GPIO24_GPIO, /* column 2 */
  91. GPIO25_GPIO, /* column 3 */
  92. GPIO26_GPIO, /* column 4 */
  93. GPIO27_GPIO, /* column 5 */
  94. GPIO52_GPIO, /* column 6 */
  95. GPIO103_GPIO, /* column 7 */
  96. GPIO107_GPIO, /* column 8 */
  97. GPIO108_GPIO, /* column 9 */
  98. GPIO114_GPIO, /* column 10 */
  99. GPIO12_GPIO, /* row 0 */
  100. GPIO17_GPIO, /* row 1 */
  101. GPIO91_GPIO, /* row 2 */
  102. GPIO34_GPIO, /* row 3 */
  103. GPIO36_GPIO, /* row 4 */
  104. GPIO38_GPIO, /* row 5 */
  105. GPIO39_GPIO, /* row 6 */
  106. /* I2C */
  107. GPIO117_I2C_SCL,
  108. GPIO118_I2C_SDA,
  109. GPIO0_GPIO | WAKEUP_ON_EDGE_RISE, /* SPITZ_GPIO_KEY_INT */
  110. GPIO1_GPIO | WAKEUP_ON_EDGE_FALL, /* SPITZ_GPIO_RESET */
  111. };
  112. /*
  113. * Spitz SCOOP Device #1
  114. */
  115. static struct resource spitz_scoop_resources[] = {
  116. [0] = {
  117. .start = 0x10800000,
  118. .end = 0x10800fff,
  119. .flags = IORESOURCE_MEM,
  120. },
  121. };
  122. static struct scoop_config spitz_scoop_setup = {
  123. .io_dir = SPITZ_SCP_IO_DIR,
  124. .io_out = SPITZ_SCP_IO_OUT,
  125. .suspend_clr = SPITZ_SCP_SUS_CLR,
  126. .suspend_set = SPITZ_SCP_SUS_SET,
  127. .gpio_base = SPITZ_SCP_GPIO_BASE,
  128. };
  129. struct platform_device spitzscoop_device = {
  130. .name = "sharp-scoop",
  131. .id = 0,
  132. .dev = {
  133. .platform_data = &spitz_scoop_setup,
  134. },
  135. .num_resources = ARRAY_SIZE(spitz_scoop_resources),
  136. .resource = spitz_scoop_resources,
  137. };
  138. /*
  139. * Spitz SCOOP Device #2
  140. */
  141. static struct resource spitz_scoop2_resources[] = {
  142. [0] = {
  143. .start = 0x08800040,
  144. .end = 0x08800fff,
  145. .flags = IORESOURCE_MEM,
  146. },
  147. };
  148. static struct scoop_config spitz_scoop2_setup = {
  149. .io_dir = SPITZ_SCP2_IO_DIR,
  150. .io_out = SPITZ_SCP2_IO_OUT,
  151. .suspend_clr = SPITZ_SCP2_SUS_CLR,
  152. .suspend_set = SPITZ_SCP2_SUS_SET,
  153. .gpio_base = SPITZ_SCP2_GPIO_BASE,
  154. };
  155. struct platform_device spitzscoop2_device = {
  156. .name = "sharp-scoop",
  157. .id = 1,
  158. .dev = {
  159. .platform_data = &spitz_scoop2_setup,
  160. },
  161. .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
  162. .resource = spitz_scoop2_resources,
  163. };
  164. #define SPITZ_PWR_SD 0x01
  165. #define SPITZ_PWR_CF 0x02
  166. /* Power control is shared with between one of the CF slots and SD */
  167. static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
  168. {
  169. unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
  170. if (new_cpr & 0x0007) {
  171. gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
  172. if (!(cpr & 0x0002) && !(cpr & 0x0004))
  173. mdelay(5);
  174. if (device == SPITZ_PWR_CF)
  175. cpr |= 0x0002;
  176. if (device == SPITZ_PWR_SD)
  177. cpr |= 0x0004;
  178. write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
  179. } else {
  180. if (device == SPITZ_PWR_CF)
  181. cpr &= ~0x0002;
  182. if (device == SPITZ_PWR_SD)
  183. cpr &= ~0x0004;
  184. if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
  185. write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
  186. mdelay(1);
  187. gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
  188. } else {
  189. write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
  190. }
  191. }
  192. }
  193. static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
  194. {
  195. /* Only need to override behaviour for slot 0 */
  196. if (nr == 0)
  197. spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
  198. else
  199. write_scoop_reg(scoop, SCOOP_CPR, cpr);
  200. }
  201. static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
  202. {
  203. .dev = &spitzscoop_device.dev,
  204. .irq = SPITZ_IRQ_GPIO_CF_IRQ,
  205. .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
  206. .cd_irq_str = "PCMCIA0 CD",
  207. },{
  208. .dev = &spitzscoop2_device.dev,
  209. .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
  210. .cd_irq = -1,
  211. },
  212. };
  213. static struct scoop_pcmcia_config spitz_pcmcia_config = {
  214. .devs = &spitz_pcmcia_scoop[0],
  215. .num_devs = 2,
  216. .power_ctrl = spitz_pcmcia_pwr,
  217. };
  218. /*
  219. * Spitz Keyboard Device
  220. */
  221. #define SPITZ_KEY_CALENDAR KEY_F1
  222. #define SPITZ_KEY_ADDRESS KEY_F2
  223. #define SPITZ_KEY_FN KEY_F3
  224. #define SPITZ_KEY_CANCEL KEY_F4
  225. #define SPITZ_KEY_EXOK KEY_F5
  226. #define SPITZ_KEY_EXCANCEL KEY_F6
  227. #define SPITZ_KEY_EXJOGDOWN KEY_F7
  228. #define SPITZ_KEY_EXJOGUP KEY_F8
  229. #define SPITZ_KEY_JAP1 KEY_LEFTALT
  230. #define SPITZ_KEY_JAP2 KEY_RIGHTCTRL
  231. #define SPITZ_KEY_SYNC KEY_F9
  232. #define SPITZ_KEY_MAIL KEY_F10
  233. #define SPITZ_KEY_OK KEY_F11
  234. #define SPITZ_KEY_MENU KEY_F12
  235. static const uint32_t spitzkbd_keymap[] = {
  236. KEY(0, 0, KEY_LEFTCTRL),
  237. KEY(0, 1, KEY_1),
  238. KEY(0, 2, KEY_3),
  239. KEY(0, 3, KEY_5),
  240. KEY(0, 4, KEY_6),
  241. KEY(0, 5, KEY_7),
  242. KEY(0, 6, KEY_9),
  243. KEY(0, 7, KEY_0),
  244. KEY(0, 8, KEY_BACKSPACE),
  245. KEY(0, 9, SPITZ_KEY_EXOK), /* EXOK */
  246. KEY(0, 10, SPITZ_KEY_EXCANCEL), /* EXCANCEL */
  247. KEY(1, 1, KEY_2),
  248. KEY(1, 2, KEY_4),
  249. KEY(1, 3, KEY_R),
  250. KEY(1, 4, KEY_Y),
  251. KEY(1, 5, KEY_8),
  252. KEY(1, 6, KEY_I),
  253. KEY(1, 7, KEY_O),
  254. KEY(1, 8, KEY_P),
  255. KEY(1, 9, SPITZ_KEY_EXJOGDOWN), /* EXJOGDOWN */
  256. KEY(1, 10, SPITZ_KEY_EXJOGUP), /* EXJOGUP */
  257. KEY(2, 0, KEY_TAB),
  258. KEY(2, 1, KEY_Q),
  259. KEY(2, 2, KEY_E),
  260. KEY(2, 3, KEY_T),
  261. KEY(2, 4, KEY_G),
  262. KEY(2, 5, KEY_U),
  263. KEY(2, 6, KEY_J),
  264. KEY(2, 7, KEY_K),
  265. KEY(3, 0, SPITZ_KEY_ADDRESS), /* ADDRESS */
  266. KEY(3, 1, KEY_W),
  267. KEY(3, 2, KEY_S),
  268. KEY(3, 3, KEY_F),
  269. KEY(3, 4, KEY_V),
  270. KEY(3, 5, KEY_H),
  271. KEY(3, 6, KEY_M),
  272. KEY(3, 7, KEY_L),
  273. KEY(3, 9, KEY_RIGHTSHIFT),
  274. KEY(4, 0, SPITZ_KEY_CALENDAR), /* CALENDAR */
  275. KEY(4, 1, KEY_A),
  276. KEY(4, 2, KEY_D),
  277. KEY(4, 3, KEY_C),
  278. KEY(4, 4, KEY_B),
  279. KEY(4, 5, KEY_N),
  280. KEY(4, 6, KEY_DOT),
  281. KEY(4, 8, KEY_ENTER),
  282. KEY(4, 9, KEY_LEFTSHIFT),
  283. KEY(5, 0, SPITZ_KEY_MAIL), /* MAIL */
  284. KEY(5, 1, KEY_Z),
  285. KEY(5, 2, KEY_X),
  286. KEY(5, 3, KEY_MINUS),
  287. KEY(5, 4, KEY_SPACE),
  288. KEY(5, 5, KEY_COMMA),
  289. KEY(5, 7, KEY_UP),
  290. KEY(5, 10, SPITZ_KEY_FN), /* FN */
  291. KEY(6, 0, KEY_SYSRQ),
  292. KEY(6, 1, SPITZ_KEY_JAP1), /* JAP1 */
  293. KEY(6, 2, SPITZ_KEY_JAP2), /* JAP2 */
  294. KEY(6, 3, SPITZ_KEY_CANCEL), /* CANCEL */
  295. KEY(6, 4, SPITZ_KEY_OK), /* OK */
  296. KEY(6, 5, SPITZ_KEY_MENU), /* MENU */
  297. KEY(6, 6, KEY_LEFT),
  298. KEY(6, 7, KEY_DOWN),
  299. KEY(6, 8, KEY_RIGHT),
  300. };
  301. static const struct matrix_keymap_data spitzkbd_keymap_data = {
  302. .keymap = spitzkbd_keymap,
  303. .keymap_size = ARRAY_SIZE(spitzkbd_keymap),
  304. };
  305. static const uint32_t spitzkbd_row_gpios[] =
  306. { 12, 17, 91, 34, 36, 38, 39 };
  307. static const uint32_t spitzkbd_col_gpios[] =
  308. { 88, 23, 24, 25, 26, 27, 52, 103, 107, 108, 114 };
  309. static struct matrix_keypad_platform_data spitzkbd_pdata = {
  310. .keymap_data = &spitzkbd_keymap_data,
  311. .row_gpios = spitzkbd_row_gpios,
  312. .col_gpios = spitzkbd_col_gpios,
  313. .num_row_gpios = ARRAY_SIZE(spitzkbd_row_gpios),
  314. .num_col_gpios = ARRAY_SIZE(spitzkbd_col_gpios),
  315. .col_scan_delay_us = 10,
  316. .debounce_ms = 10,
  317. .wakeup = 1,
  318. };
  319. static struct platform_device spitzkbd_device = {
  320. .name = "matrix-keypad",
  321. .id = -1,
  322. .dev = {
  323. .platform_data = &spitzkbd_pdata,
  324. },
  325. };
  326. static struct gpio_keys_button spitz_gpio_keys[] = {
  327. {
  328. .type = EV_PWR,
  329. .code = KEY_SUSPEND,
  330. .gpio = SPITZ_GPIO_ON_KEY,
  331. .desc = "On Off",
  332. .wakeup = 1,
  333. },
  334. /* Two buttons detecting the lid state */
  335. {
  336. .type = EV_SW,
  337. .code = 0,
  338. .gpio = SPITZ_GPIO_SWA,
  339. .desc = "Display Down",
  340. },
  341. {
  342. .type = EV_SW,
  343. .code = 1,
  344. .gpio = SPITZ_GPIO_SWB,
  345. .desc = "Lid Closed",
  346. },
  347. };
  348. static struct gpio_keys_platform_data spitz_gpio_keys_platform_data = {
  349. .buttons = spitz_gpio_keys,
  350. .nbuttons = ARRAY_SIZE(spitz_gpio_keys),
  351. };
  352. static struct platform_device spitz_gpio_keys_device = {
  353. .name = "gpio-keys",
  354. .id = -1,
  355. .dev = {
  356. .platform_data = &spitz_gpio_keys_platform_data,
  357. },
  358. };
  359. /*
  360. * Spitz LEDs
  361. */
  362. static struct gpio_led spitz_gpio_leds[] = {
  363. {
  364. .name = "spitz:amber:charge",
  365. .default_trigger = "sharpsl-charge",
  366. .gpio = SPITZ_GPIO_LED_ORANGE,
  367. },
  368. {
  369. .name = "spitz:green:hddactivity",
  370. .default_trigger = "ide-disk",
  371. .gpio = SPITZ_GPIO_LED_GREEN,
  372. },
  373. };
  374. static struct gpio_led_platform_data spitz_gpio_leds_info = {
  375. .leds = spitz_gpio_leds,
  376. .num_leds = ARRAY_SIZE(spitz_gpio_leds),
  377. };
  378. static struct platform_device spitzled_device = {
  379. .name = "leds-gpio",
  380. .id = -1,
  381. .dev = {
  382. .platform_data = &spitz_gpio_leds_info,
  383. },
  384. };
  385. #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
  386. static struct pxa2xx_spi_master spitz_spi_info = {
  387. .num_chipselect = 3,
  388. };
  389. static void spitz_wait_for_hsync(void)
  390. {
  391. while (gpio_get_value(SPITZ_GPIO_HSYNC))
  392. cpu_relax();
  393. while (!gpio_get_value(SPITZ_GPIO_HSYNC))
  394. cpu_relax();
  395. }
  396. static struct ads7846_platform_data spitz_ads7846_info = {
  397. .model = 7846,
  398. .vref_delay_usecs = 100,
  399. .x_plate_ohms = 419,
  400. .y_plate_ohms = 486,
  401. .pressure_max = 1024,
  402. .gpio_pendown = SPITZ_GPIO_TP_INT,
  403. .wait_for_sync = spitz_wait_for_hsync,
  404. };
  405. static struct pxa2xx_spi_chip spitz_ads7846_chip = {
  406. .gpio_cs = SPITZ_GPIO_ADS7846_CS,
  407. };
  408. static void spitz_bl_kick_battery(void)
  409. {
  410. void (*kick_batt)(void);
  411. kick_batt = symbol_get(sharpsl_battery_kick);
  412. if (kick_batt) {
  413. kick_batt();
  414. symbol_put(sharpsl_battery_kick);
  415. }
  416. }
  417. static struct corgi_lcd_platform_data spitz_lcdcon_info = {
  418. .init_mode = CORGI_LCD_MODE_VGA,
  419. .max_intensity = 0x2f,
  420. .default_intensity = 0x1f,
  421. .limit_mask = 0x0b,
  422. .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT,
  423. .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON,
  424. .kick_battery = spitz_bl_kick_battery,
  425. };
  426. static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
  427. .gpio_cs = SPITZ_GPIO_LCDCON_CS,
  428. };
  429. static struct pxa2xx_spi_chip spitz_max1111_chip = {
  430. .gpio_cs = SPITZ_GPIO_MAX1111_CS,
  431. };
  432. static struct spi_board_info spitz_spi_devices[] = {
  433. {
  434. .modalias = "ads7846",
  435. .max_speed_hz = 1200000,
  436. .bus_num = 2,
  437. .chip_select = 0,
  438. .platform_data = &spitz_ads7846_info,
  439. .controller_data= &spitz_ads7846_chip,
  440. .irq = gpio_to_irq(SPITZ_GPIO_TP_INT),
  441. }, {
  442. .modalias = "corgi-lcd",
  443. .max_speed_hz = 50000,
  444. .bus_num = 2,
  445. .chip_select = 1,
  446. .platform_data = &spitz_lcdcon_info,
  447. .controller_data= &spitz_lcdcon_chip,
  448. }, {
  449. .modalias = "max1111",
  450. .max_speed_hz = 450000,
  451. .bus_num = 2,
  452. .chip_select = 2,
  453. .controller_data= &spitz_max1111_chip,
  454. },
  455. };
  456. static void __init spitz_init_spi(void)
  457. {
  458. if (machine_is_akita()) {
  459. spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
  460. spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
  461. }
  462. pxa2xx_set_spi_info(2, &spitz_spi_info);
  463. spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
  464. }
  465. #else
  466. static inline void spitz_init_spi(void) {}
  467. #endif
  468. /*
  469. * MMC/SD Device
  470. *
  471. * The card detect interrupt isn't debounced so we delay it by 250ms
  472. * to give the card a chance to fully insert/eject.
  473. */
  474. static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
  475. {
  476. struct pxamci_platform_data* p_d = dev->platform_data;
  477. if (( 1 << vdd) & p_d->ocr_mask)
  478. spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
  479. else
  480. spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
  481. }
  482. static struct pxamci_platform_data spitz_mci_platform_data = {
  483. .detect_delay_ms = 250,
  484. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  485. .setpower = spitz_mci_setpower,
  486. .gpio_card_detect = SPITZ_GPIO_nSD_DETECT,
  487. .gpio_card_ro = SPITZ_GPIO_nSD_WP,
  488. .gpio_power = -1,
  489. };
  490. /*
  491. * USB Host (OHCI)
  492. */
  493. static int spitz_ohci_init(struct device *dev)
  494. {
  495. int err;
  496. err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
  497. if (err)
  498. return err;
  499. /* Only Port 2 is connected
  500. * Setup USB Port 2 Output Control Register
  501. */
  502. UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
  503. return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
  504. }
  505. static void spitz_ohci_exit(struct device *dev)
  506. {
  507. gpio_free(SPITZ_GPIO_USB_HOST);
  508. }
  509. static struct pxaohci_platform_data spitz_ohci_platform_data = {
  510. .port_mode = PMM_NPS_MODE,
  511. .init = spitz_ohci_init,
  512. .exit = spitz_ohci_exit,
  513. .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
  514. .power_budget = 150,
  515. };
  516. /*
  517. * Irda
  518. */
  519. static struct pxaficp_platform_data spitz_ficp_platform_data = {
  520. /* .gpio_pwdown is set in spitz_init() and akita_init() accordingly */
  521. .transceiver_cap = IR_SIRMODE | IR_OFF,
  522. };
  523. /*
  524. * Spitz PXA Framebuffer
  525. */
  526. static struct pxafb_mode_info spitz_pxafb_modes[] = {
  527. {
  528. .pixclock = 19231,
  529. .xres = 480,
  530. .yres = 640,
  531. .bpp = 16,
  532. .hsync_len = 40,
  533. .left_margin = 46,
  534. .right_margin = 125,
  535. .vsync_len = 3,
  536. .upper_margin = 1,
  537. .lower_margin = 0,
  538. .sync = 0,
  539. },{
  540. .pixclock = 134617,
  541. .xres = 240,
  542. .yres = 320,
  543. .bpp = 16,
  544. .hsync_len = 20,
  545. .left_margin = 20,
  546. .right_margin = 46,
  547. .vsync_len = 2,
  548. .upper_margin = 1,
  549. .lower_margin = 0,
  550. .sync = 0,
  551. },
  552. };
  553. static struct pxafb_mach_info spitz_pxafb_info = {
  554. .modes = &spitz_pxafb_modes[0],
  555. .num_modes = 2,
  556. .fixed_modes = 1,
  557. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
  558. };
  559. static struct mtd_partition sharpsl_nand_partitions[] = {
  560. {
  561. .name = "System Area",
  562. .offset = 0,
  563. .size = 7 * 1024 * 1024,
  564. },
  565. {
  566. .name = "Root Filesystem",
  567. .offset = 7 * 1024 * 1024,
  568. },
  569. {
  570. .name = "Home Filesystem",
  571. .offset = MTDPART_OFS_APPEND,
  572. .size = MTDPART_SIZ_FULL,
  573. },
  574. };
  575. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  576. static struct nand_bbt_descr sharpsl_bbt = {
  577. .options = 0,
  578. .offs = 4,
  579. .len = 2,
  580. .pattern = scan_ff_pattern
  581. };
  582. static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
  583. .badblock_pattern = &sharpsl_bbt,
  584. .partitions = sharpsl_nand_partitions,
  585. .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions),
  586. };
  587. static struct resource sharpsl_nand_resources[] = {
  588. {
  589. .start = 0x0C000000,
  590. .end = 0x0C000FFF,
  591. .flags = IORESOURCE_MEM,
  592. },
  593. };
  594. static struct platform_device sharpsl_nand_device = {
  595. .name = "sharpsl-nand",
  596. .id = -1,
  597. .resource = sharpsl_nand_resources,
  598. .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
  599. .dev.platform_data = &sharpsl_nand_platform_data,
  600. };
  601. static struct mtd_partition sharpsl_rom_parts[] = {
  602. {
  603. .name ="Boot PROM Filesystem",
  604. .offset = 0x00140000,
  605. .size = MTDPART_SIZ_FULL,
  606. },
  607. };
  608. static struct physmap_flash_data sharpsl_rom_data = {
  609. .width = 2,
  610. .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
  611. .parts = sharpsl_rom_parts,
  612. };
  613. static struct resource sharpsl_rom_resources[] = {
  614. {
  615. .start = 0x00000000,
  616. .end = 0x007fffff,
  617. .flags = IORESOURCE_MEM,
  618. },
  619. };
  620. static struct platform_device sharpsl_rom_device = {
  621. .name = "physmap-flash",
  622. .id = -1,
  623. .resource = sharpsl_rom_resources,
  624. .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
  625. .dev.platform_data = &sharpsl_rom_data,
  626. };
  627. static struct platform_device *devices[] __initdata = {
  628. &spitzscoop_device,
  629. &spitzkbd_device,
  630. &spitz_gpio_keys_device,
  631. &spitzled_device,
  632. &sharpsl_nand_device,
  633. &sharpsl_rom_device,
  634. };
  635. static void spitz_poweroff(void)
  636. {
  637. arm_machine_restart('g', NULL);
  638. }
  639. static void spitz_restart(char mode, const char *cmd)
  640. {
  641. /* Bootloader magic for a reboot */
  642. if((MSC0 & 0xffff0000) == 0x7ff00000)
  643. MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
  644. spitz_poweroff();
  645. }
  646. static void __init common_init(void)
  647. {
  648. init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0);
  649. pm_power_off = spitz_poweroff;
  650. arm_pm_restart = spitz_restart;
  651. if (machine_is_spitz()) {
  652. sharpsl_nand_partitions[1].size = 5 * 1024 * 1024;
  653. } else if (machine_is_akita()) {
  654. sharpsl_nand_partitions[1].size = 58 * 1024 * 1024;
  655. } else if (machine_is_borzoi()) {
  656. sharpsl_nand_partitions[1].size = 32 * 1024 * 1024;
  657. }
  658. PMCR = 0x00;
  659. /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
  660. PCFR |= PCFR_OPDE;
  661. pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
  662. pxa_set_ffuart_info(NULL);
  663. pxa_set_btuart_info(NULL);
  664. pxa_set_stuart_info(NULL);
  665. spitz_init_spi();
  666. platform_add_devices(devices, ARRAY_SIZE(devices));
  667. pxa_set_mci_info(&spitz_mci_platform_data);
  668. pxa_set_ohci_info(&spitz_ohci_platform_data);
  669. pxa_set_ficp_info(&spitz_ficp_platform_data);
  670. set_pxa_fb_info(&spitz_pxafb_info);
  671. pxa_set_i2c_info(NULL);
  672. }
  673. #if defined(CONFIG_MACH_AKITA) || defined(CONFIG_MACH_BORZOI)
  674. static struct nand_bbt_descr sharpsl_akita_bbt = {
  675. .options = 0,
  676. .offs = 4,
  677. .len = 1,
  678. .pattern = scan_ff_pattern
  679. };
  680. static struct nand_ecclayout akita_oobinfo = {
  681. .eccbytes = 24,
  682. .eccpos = {
  683. 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11,
  684. 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23,
  685. 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37},
  686. .oobfree = {{0x08, 0x09}}
  687. };
  688. #endif
  689. #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
  690. static void __init spitz_init(void)
  691. {
  692. spitz_ficp_platform_data.gpio_pwdown = SPITZ_GPIO_IR_ON;
  693. #ifdef CONFIG_MACH_BORZOI
  694. if (machine_is_borzoi()) {
  695. sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt;
  696. sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo;
  697. }
  698. #endif
  699. platform_scoop_config = &spitz_pcmcia_config;
  700. common_init();
  701. platform_device_register(&spitzscoop2_device);
  702. }
  703. #endif
  704. #ifdef CONFIG_MACH_AKITA
  705. /*
  706. * Akita IO Expander
  707. */
  708. static struct pca953x_platform_data akita_ioexp = {
  709. .gpio_base = AKITA_IOEXP_GPIO_BASE,
  710. };
  711. static struct i2c_board_info akita_i2c_board_info[] = {
  712. {
  713. .type = "max7310",
  714. .addr = 0x18,
  715. .platform_data = &akita_ioexp,
  716. }, {
  717. .type = "wm8750",
  718. .addr = 0x1b,
  719. },
  720. };
  721. static void __init akita_init(void)
  722. {
  723. spitz_ficp_platform_data.gpio_pwdown = AKITA_GPIO_IR_ON;
  724. sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt;
  725. sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo;
  726. /* We just pretend the second element of the array doesn't exist */
  727. spitz_pcmcia_config.num_devs = 1;
  728. platform_scoop_config = &spitz_pcmcia_config;
  729. i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
  730. common_init();
  731. }
  732. #endif
  733. static void __init fixup_spitz(struct machine_desc *desc,
  734. struct tag *tags, char **cmdline, struct meminfo *mi)
  735. {
  736. sharpsl_save_param();
  737. mi->nr_banks = 1;
  738. mi->bank[0].start = 0xa0000000;
  739. mi->bank[0].node = 0;
  740. mi->bank[0].size = (64*1024*1024);
  741. }
  742. #ifdef CONFIG_MACH_SPITZ
  743. MACHINE_START(SPITZ, "SHARP Spitz")
  744. .phys_io = 0x40000000,
  745. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  746. .fixup = fixup_spitz,
  747. .map_io = pxa_map_io,
  748. .init_irq = pxa27x_init_irq,
  749. .init_machine = spitz_init,
  750. .timer = &pxa_timer,
  751. MACHINE_END
  752. #endif
  753. #ifdef CONFIG_MACH_BORZOI
  754. MACHINE_START(BORZOI, "SHARP Borzoi")
  755. .phys_io = 0x40000000,
  756. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  757. .fixup = fixup_spitz,
  758. .map_io = pxa_map_io,
  759. .init_irq = pxa27x_init_irq,
  760. .init_machine = spitz_init,
  761. .timer = &pxa_timer,
  762. MACHINE_END
  763. #endif
  764. #ifdef CONFIG_MACH_AKITA
  765. MACHINE_START(AKITA, "SHARP Akita")
  766. .phys_io = 0x40000000,
  767. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  768. .fixup = fixup_spitz,
  769. .map_io = pxa_map_io,
  770. .init_irq = pxa27x_init_irq,
  771. .init_machine = akita_init,
  772. .timer = &pxa_timer,
  773. MACHINE_END
  774. #endif