spitz.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  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. GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */
  79. GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */
  80. GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */
  81. GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */
  82. GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */
  83. GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */
  84. GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */
  85. GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */
  86. /* GPIO matrix keypad */
  87. GPIO88_GPIO, /* column 0 */
  88. GPIO23_GPIO, /* column 1 */
  89. GPIO24_GPIO, /* column 2 */
  90. GPIO25_GPIO, /* column 3 */
  91. GPIO26_GPIO, /* column 4 */
  92. GPIO27_GPIO, /* column 5 */
  93. GPIO52_GPIO, /* column 6 */
  94. GPIO103_GPIO, /* column 7 */
  95. GPIO107_GPIO, /* column 8 */
  96. GPIO108_GPIO, /* column 9 */
  97. GPIO114_GPIO, /* column 10 */
  98. GPIO12_GPIO, /* row 0 */
  99. GPIO17_GPIO, /* row 1 */
  100. GPIO91_GPIO, /* row 2 */
  101. GPIO34_GPIO, /* row 3 */
  102. GPIO36_GPIO, /* row 4 */
  103. GPIO38_GPIO, /* row 5 */
  104. GPIO39_GPIO, /* row 6 */
  105. /* I2C */
  106. GPIO117_I2C_SCL,
  107. GPIO118_I2C_SDA,
  108. GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
  109. };
  110. /*
  111. * Spitz SCOOP Device #1
  112. */
  113. static struct resource spitz_scoop_resources[] = {
  114. [0] = {
  115. .start = 0x10800000,
  116. .end = 0x10800fff,
  117. .flags = IORESOURCE_MEM,
  118. },
  119. };
  120. static struct scoop_config spitz_scoop_setup = {
  121. .io_dir = SPITZ_SCP_IO_DIR,
  122. .io_out = SPITZ_SCP_IO_OUT,
  123. .suspend_clr = SPITZ_SCP_SUS_CLR,
  124. .suspend_set = SPITZ_SCP_SUS_SET,
  125. .gpio_base = SPITZ_SCP_GPIO_BASE,
  126. };
  127. struct platform_device spitzscoop_device = {
  128. .name = "sharp-scoop",
  129. .id = 0,
  130. .dev = {
  131. .platform_data = &spitz_scoop_setup,
  132. },
  133. .num_resources = ARRAY_SIZE(spitz_scoop_resources),
  134. .resource = spitz_scoop_resources,
  135. };
  136. /*
  137. * Spitz SCOOP Device #2
  138. */
  139. static struct resource spitz_scoop2_resources[] = {
  140. [0] = {
  141. .start = 0x08800040,
  142. .end = 0x08800fff,
  143. .flags = IORESOURCE_MEM,
  144. },
  145. };
  146. static struct scoop_config spitz_scoop2_setup = {
  147. .io_dir = SPITZ_SCP2_IO_DIR,
  148. .io_out = SPITZ_SCP2_IO_OUT,
  149. .suspend_clr = SPITZ_SCP2_SUS_CLR,
  150. .suspend_set = SPITZ_SCP2_SUS_SET,
  151. .gpio_base = SPITZ_SCP2_GPIO_BASE,
  152. };
  153. struct platform_device spitzscoop2_device = {
  154. .name = "sharp-scoop",
  155. .id = 1,
  156. .dev = {
  157. .platform_data = &spitz_scoop2_setup,
  158. },
  159. .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
  160. .resource = spitz_scoop2_resources,
  161. };
  162. #define SPITZ_PWR_SD 0x01
  163. #define SPITZ_PWR_CF 0x02
  164. /* Power control is shared with between one of the CF slots and SD */
  165. static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
  166. {
  167. unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
  168. if (new_cpr & 0x0007) {
  169. gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
  170. if (!(cpr & 0x0002) && !(cpr & 0x0004))
  171. mdelay(5);
  172. if (device == SPITZ_PWR_CF)
  173. cpr |= 0x0002;
  174. if (device == SPITZ_PWR_SD)
  175. cpr |= 0x0004;
  176. write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
  177. } else {
  178. if (device == SPITZ_PWR_CF)
  179. cpr &= ~0x0002;
  180. if (device == SPITZ_PWR_SD)
  181. cpr &= ~0x0004;
  182. if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
  183. write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
  184. mdelay(1);
  185. gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
  186. } else {
  187. write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
  188. }
  189. }
  190. }
  191. static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
  192. {
  193. /* Only need to override behaviour for slot 0 */
  194. if (nr == 0)
  195. spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
  196. else
  197. write_scoop_reg(scoop, SCOOP_CPR, cpr);
  198. }
  199. static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
  200. {
  201. .dev = &spitzscoop_device.dev,
  202. .irq = SPITZ_IRQ_GPIO_CF_IRQ,
  203. .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
  204. .cd_irq_str = "PCMCIA0 CD",
  205. },{
  206. .dev = &spitzscoop2_device.dev,
  207. .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
  208. .cd_irq = -1,
  209. },
  210. };
  211. static struct scoop_pcmcia_config spitz_pcmcia_config = {
  212. .devs = &spitz_pcmcia_scoop[0],
  213. .num_devs = 2,
  214. .power_ctrl = spitz_pcmcia_pwr,
  215. };
  216. EXPORT_SYMBOL(spitzscoop_device);
  217. EXPORT_SYMBOL(spitzscoop2_device);
  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. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  484. .setpower = spitz_mci_setpower,
  485. .gpio_card_detect = SPITZ_GPIO_nSD_DETECT,
  486. .gpio_card_ro = SPITZ_GPIO_nSD_WP,
  487. .gpio_power = -1,
  488. };
  489. /*
  490. * USB Host (OHCI)
  491. */
  492. static int spitz_ohci_init(struct device *dev)
  493. {
  494. int err;
  495. err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
  496. if (err)
  497. return err;
  498. /* Only Port 2 is connected
  499. * Setup USB Port 2 Output Control Register
  500. */
  501. UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
  502. return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
  503. }
  504. static void spitz_ohci_exit(struct device *dev)
  505. {
  506. gpio_free(SPITZ_GPIO_USB_HOST);
  507. }
  508. static struct pxaohci_platform_data spitz_ohci_platform_data = {
  509. .port_mode = PMM_NPS_MODE,
  510. .init = spitz_ohci_init,
  511. .exit = spitz_ohci_exit,
  512. .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
  513. .power_budget = 150,
  514. };
  515. /*
  516. * Irda
  517. */
  518. static struct pxaficp_platform_data spitz_ficp_platform_data = {
  519. /* .gpio_pwdown is set in spitz_init() and akita_init() accordingly */
  520. .transceiver_cap = IR_SIRMODE | IR_OFF,
  521. };
  522. /*
  523. * Spitz PXA Framebuffer
  524. */
  525. static struct pxafb_mode_info spitz_pxafb_modes[] = {
  526. {
  527. .pixclock = 19231,
  528. .xres = 480,
  529. .yres = 640,
  530. .bpp = 16,
  531. .hsync_len = 40,
  532. .left_margin = 46,
  533. .right_margin = 125,
  534. .vsync_len = 3,
  535. .upper_margin = 1,
  536. .lower_margin = 0,
  537. .sync = 0,
  538. },{
  539. .pixclock = 134617,
  540. .xres = 240,
  541. .yres = 320,
  542. .bpp = 16,
  543. .hsync_len = 20,
  544. .left_margin = 20,
  545. .right_margin = 46,
  546. .vsync_len = 2,
  547. .upper_margin = 1,
  548. .lower_margin = 0,
  549. .sync = 0,
  550. },
  551. };
  552. static struct pxafb_mach_info spitz_pxafb_info = {
  553. .modes = &spitz_pxafb_modes[0],
  554. .num_modes = 2,
  555. .fixed_modes = 1,
  556. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
  557. };
  558. static struct mtd_partition sharpsl_nand_partitions[] = {
  559. {
  560. .name = "System Area",
  561. .offset = 0,
  562. .size = 7 * 1024 * 1024,
  563. },
  564. {
  565. .name = "Root Filesystem",
  566. .offset = 7 * 1024 * 1024,
  567. },
  568. {
  569. .name = "Home Filesystem",
  570. .offset = MTDPART_OFS_APPEND,
  571. .size = MTDPART_SIZ_FULL,
  572. },
  573. };
  574. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  575. static struct nand_bbt_descr sharpsl_bbt = {
  576. .options = 0,
  577. .offs = 4,
  578. .len = 2,
  579. .pattern = scan_ff_pattern
  580. };
  581. static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
  582. .badblock_pattern = &sharpsl_bbt,
  583. .partitions = sharpsl_nand_partitions,
  584. .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions),
  585. };
  586. static struct resource sharpsl_nand_resources[] = {
  587. {
  588. .start = 0x0C000000,
  589. .end = 0x0C000FFF,
  590. .flags = IORESOURCE_MEM,
  591. },
  592. };
  593. static struct platform_device sharpsl_nand_device = {
  594. .name = "sharpsl-nand",
  595. .id = -1,
  596. .resource = sharpsl_nand_resources,
  597. .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
  598. .dev.platform_data = &sharpsl_nand_platform_data,
  599. };
  600. static struct mtd_partition sharpsl_rom_parts[] = {
  601. {
  602. .name ="Boot PROM Filesystem",
  603. .offset = 0x00140000,
  604. .size = MTDPART_SIZ_FULL,
  605. },
  606. };
  607. static struct physmap_flash_data sharpsl_rom_data = {
  608. .width = 2,
  609. .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
  610. .parts = sharpsl_rom_parts,
  611. };
  612. static struct resource sharpsl_rom_resources[] = {
  613. {
  614. .start = 0x00000000,
  615. .end = 0x007fffff,
  616. .flags = IORESOURCE_MEM,
  617. },
  618. };
  619. static struct platform_device sharpsl_rom_device = {
  620. .name = "physmap-flash",
  621. .id = -1,
  622. .resource = sharpsl_rom_resources,
  623. .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
  624. .dev.platform_data = &sharpsl_rom_data,
  625. };
  626. static struct platform_device *devices[] __initdata = {
  627. &spitzscoop_device,
  628. &spitzkbd_device,
  629. &spitz_gpio_keys_device,
  630. &spitzled_device,
  631. &sharpsl_nand_device,
  632. &sharpsl_rom_device,
  633. };
  634. static void spitz_poweroff(void)
  635. {
  636. arm_machine_restart('g', NULL);
  637. }
  638. static void spitz_restart(char mode, const char *cmd)
  639. {
  640. /* Bootloader magic for a reboot */
  641. if((MSC0 & 0xffff0000) == 0x7ff00000)
  642. MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
  643. spitz_poweroff();
  644. }
  645. static void __init common_init(void)
  646. {
  647. init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0);
  648. pm_power_off = spitz_poweroff;
  649. arm_pm_restart = spitz_restart;
  650. if (machine_is_spitz()) {
  651. sharpsl_nand_partitions[1].size = 5 * 1024 * 1024;
  652. } else if (machine_is_akita()) {
  653. sharpsl_nand_partitions[1].size = 58 * 1024 * 1024;
  654. } else if (machine_is_borzoi()) {
  655. sharpsl_nand_partitions[1].size = 32 * 1024 * 1024;
  656. }
  657. PMCR = 0x00;
  658. /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
  659. PCFR |= PCFR_OPDE;
  660. pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
  661. pxa_set_ffuart_info(NULL);
  662. pxa_set_btuart_info(NULL);
  663. pxa_set_stuart_info(NULL);
  664. spitz_init_spi();
  665. platform_add_devices(devices, ARRAY_SIZE(devices));
  666. spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
  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. };
  718. static void __init akita_init(void)
  719. {
  720. spitz_ficp_platform_data.gpio_pwdown = AKITA_GPIO_IR_ON;
  721. sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt;
  722. sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo;
  723. /* We just pretend the second element of the array doesn't exist */
  724. spitz_pcmcia_config.num_devs = 1;
  725. platform_scoop_config = &spitz_pcmcia_config;
  726. i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
  727. common_init();
  728. }
  729. #endif
  730. static void __init fixup_spitz(struct machine_desc *desc,
  731. struct tag *tags, char **cmdline, struct meminfo *mi)
  732. {
  733. sharpsl_save_param();
  734. mi->nr_banks = 1;
  735. mi->bank[0].start = 0xa0000000;
  736. mi->bank[0].node = 0;
  737. mi->bank[0].size = (64*1024*1024);
  738. }
  739. #ifdef CONFIG_MACH_SPITZ
  740. MACHINE_START(SPITZ, "SHARP Spitz")
  741. .phys_io = 0x40000000,
  742. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  743. .fixup = fixup_spitz,
  744. .map_io = pxa_map_io,
  745. .init_irq = pxa27x_init_irq,
  746. .init_machine = spitz_init,
  747. .timer = &pxa_timer,
  748. MACHINE_END
  749. #endif
  750. #ifdef CONFIG_MACH_BORZOI
  751. MACHINE_START(BORZOI, "SHARP Borzoi")
  752. .phys_io = 0x40000000,
  753. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  754. .fixup = fixup_spitz,
  755. .map_io = pxa_map_io,
  756. .init_irq = pxa27x_init_irq,
  757. .init_machine = spitz_init,
  758. .timer = &pxa_timer,
  759. MACHINE_END
  760. #endif
  761. #ifdef CONFIG_MACH_AKITA
  762. MACHINE_START(AKITA, "SHARP Akita")
  763. .phys_io = 0x40000000,
  764. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  765. .fixup = fixup_spitz,
  766. .map_io = pxa_map_io,
  767. .init_irq = pxa27x_init_irq,
  768. .init_machine = akita_init,
  769. .timer = &pxa_timer,
  770. MACHINE_END
  771. #endif