spitz.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  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. EXPORT_SYMBOL(spitzscoop_device);
  219. EXPORT_SYMBOL(spitzscoop2_device);
  220. /*
  221. * Spitz Keyboard Device
  222. */
  223. #define SPITZ_KEY_CALENDAR KEY_F1
  224. #define SPITZ_KEY_ADDRESS KEY_F2
  225. #define SPITZ_KEY_FN KEY_F3
  226. #define SPITZ_KEY_CANCEL KEY_F4
  227. #define SPITZ_KEY_EXOK KEY_F5
  228. #define SPITZ_KEY_EXCANCEL KEY_F6
  229. #define SPITZ_KEY_EXJOGDOWN KEY_F7
  230. #define SPITZ_KEY_EXJOGUP KEY_F8
  231. #define SPITZ_KEY_JAP1 KEY_LEFTALT
  232. #define SPITZ_KEY_JAP2 KEY_RIGHTCTRL
  233. #define SPITZ_KEY_SYNC KEY_F9
  234. #define SPITZ_KEY_MAIL KEY_F10
  235. #define SPITZ_KEY_OK KEY_F11
  236. #define SPITZ_KEY_MENU KEY_F12
  237. static const uint32_t spitzkbd_keymap[] = {
  238. KEY(0, 0, KEY_LEFTCTRL),
  239. KEY(0, 1, KEY_1),
  240. KEY(0, 2, KEY_3),
  241. KEY(0, 3, KEY_5),
  242. KEY(0, 4, KEY_6),
  243. KEY(0, 5, KEY_7),
  244. KEY(0, 6, KEY_9),
  245. KEY(0, 7, KEY_0),
  246. KEY(0, 8, KEY_BACKSPACE),
  247. KEY(0, 9, SPITZ_KEY_EXOK), /* EXOK */
  248. KEY(0, 10, SPITZ_KEY_EXCANCEL), /* EXCANCEL */
  249. KEY(1, 1, KEY_2),
  250. KEY(1, 2, KEY_4),
  251. KEY(1, 3, KEY_R),
  252. KEY(1, 4, KEY_Y),
  253. KEY(1, 5, KEY_8),
  254. KEY(1, 6, KEY_I),
  255. KEY(1, 7, KEY_O),
  256. KEY(1, 8, KEY_P),
  257. KEY(1, 9, SPITZ_KEY_EXJOGDOWN), /* EXJOGDOWN */
  258. KEY(1, 10, SPITZ_KEY_EXJOGUP), /* EXJOGUP */
  259. KEY(2, 0, KEY_TAB),
  260. KEY(2, 1, KEY_Q),
  261. KEY(2, 2, KEY_E),
  262. KEY(2, 3, KEY_T),
  263. KEY(2, 4, KEY_G),
  264. KEY(2, 5, KEY_U),
  265. KEY(2, 6, KEY_J),
  266. KEY(2, 7, KEY_K),
  267. KEY(3, 0, SPITZ_KEY_ADDRESS), /* ADDRESS */
  268. KEY(3, 1, KEY_W),
  269. KEY(3, 2, KEY_S),
  270. KEY(3, 3, KEY_F),
  271. KEY(3, 4, KEY_V),
  272. KEY(3, 5, KEY_H),
  273. KEY(3, 6, KEY_M),
  274. KEY(3, 7, KEY_L),
  275. KEY(3, 9, KEY_RIGHTSHIFT),
  276. KEY(4, 0, SPITZ_KEY_CALENDAR), /* CALENDAR */
  277. KEY(4, 1, KEY_A),
  278. KEY(4, 2, KEY_D),
  279. KEY(4, 3, KEY_C),
  280. KEY(4, 4, KEY_B),
  281. KEY(4, 5, KEY_N),
  282. KEY(4, 6, KEY_DOT),
  283. KEY(4, 8, KEY_ENTER),
  284. KEY(4, 9, KEY_LEFTSHIFT),
  285. KEY(5, 0, SPITZ_KEY_MAIL), /* MAIL */
  286. KEY(5, 1, KEY_Z),
  287. KEY(5, 2, KEY_X),
  288. KEY(5, 3, KEY_MINUS),
  289. KEY(5, 4, KEY_SPACE),
  290. KEY(5, 5, KEY_COMMA),
  291. KEY(5, 7, KEY_UP),
  292. KEY(5, 10, SPITZ_KEY_FN), /* FN */
  293. KEY(6, 0, KEY_SYSRQ),
  294. KEY(6, 1, SPITZ_KEY_JAP1), /* JAP1 */
  295. KEY(6, 2, SPITZ_KEY_JAP2), /* JAP2 */
  296. KEY(6, 3, SPITZ_KEY_CANCEL), /* CANCEL */
  297. KEY(6, 4, SPITZ_KEY_OK), /* OK */
  298. KEY(6, 5, SPITZ_KEY_MENU), /* MENU */
  299. KEY(6, 6, KEY_LEFT),
  300. KEY(6, 7, KEY_DOWN),
  301. KEY(6, 8, KEY_RIGHT),
  302. };
  303. static const struct matrix_keymap_data spitzkbd_keymap_data = {
  304. .keymap = spitzkbd_keymap,
  305. .keymap_size = ARRAY_SIZE(spitzkbd_keymap),
  306. };
  307. static const uint32_t spitzkbd_row_gpios[] =
  308. { 12, 17, 91, 34, 36, 38, 39 };
  309. static const uint32_t spitzkbd_col_gpios[] =
  310. { 88, 23, 24, 25, 26, 27, 52, 103, 107, 108, 114 };
  311. static struct matrix_keypad_platform_data spitzkbd_pdata = {
  312. .keymap_data = &spitzkbd_keymap_data,
  313. .row_gpios = spitzkbd_row_gpios,
  314. .col_gpios = spitzkbd_col_gpios,
  315. .num_row_gpios = ARRAY_SIZE(spitzkbd_row_gpios),
  316. .num_col_gpios = ARRAY_SIZE(spitzkbd_col_gpios),
  317. .col_scan_delay_us = 10,
  318. .debounce_ms = 10,
  319. .wakeup = 1,
  320. };
  321. static struct platform_device spitzkbd_device = {
  322. .name = "matrix-keypad",
  323. .id = -1,
  324. .dev = {
  325. .platform_data = &spitzkbd_pdata,
  326. },
  327. };
  328. static struct gpio_keys_button spitz_gpio_keys[] = {
  329. {
  330. .type = EV_PWR,
  331. .code = KEY_SUSPEND,
  332. .gpio = SPITZ_GPIO_ON_KEY,
  333. .desc = "On Off",
  334. .wakeup = 1,
  335. },
  336. /* Two buttons detecting the lid state */
  337. {
  338. .type = EV_SW,
  339. .code = 0,
  340. .gpio = SPITZ_GPIO_SWA,
  341. .desc = "Display Down",
  342. },
  343. {
  344. .type = EV_SW,
  345. .code = 1,
  346. .gpio = SPITZ_GPIO_SWB,
  347. .desc = "Lid Closed",
  348. },
  349. };
  350. static struct gpio_keys_platform_data spitz_gpio_keys_platform_data = {
  351. .buttons = spitz_gpio_keys,
  352. .nbuttons = ARRAY_SIZE(spitz_gpio_keys),
  353. };
  354. static struct platform_device spitz_gpio_keys_device = {
  355. .name = "gpio-keys",
  356. .id = -1,
  357. .dev = {
  358. .platform_data = &spitz_gpio_keys_platform_data,
  359. },
  360. };
  361. /*
  362. * Spitz LEDs
  363. */
  364. static struct gpio_led spitz_gpio_leds[] = {
  365. {
  366. .name = "spitz:amber:charge",
  367. .default_trigger = "sharpsl-charge",
  368. .gpio = SPITZ_GPIO_LED_ORANGE,
  369. },
  370. {
  371. .name = "spitz:green:hddactivity",
  372. .default_trigger = "ide-disk",
  373. .gpio = SPITZ_GPIO_LED_GREEN,
  374. },
  375. };
  376. static struct gpio_led_platform_data spitz_gpio_leds_info = {
  377. .leds = spitz_gpio_leds,
  378. .num_leds = ARRAY_SIZE(spitz_gpio_leds),
  379. };
  380. static struct platform_device spitzled_device = {
  381. .name = "leds-gpio",
  382. .id = -1,
  383. .dev = {
  384. .platform_data = &spitz_gpio_leds_info,
  385. },
  386. };
  387. #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
  388. static struct pxa2xx_spi_master spitz_spi_info = {
  389. .num_chipselect = 3,
  390. };
  391. static void spitz_wait_for_hsync(void)
  392. {
  393. while (gpio_get_value(SPITZ_GPIO_HSYNC))
  394. cpu_relax();
  395. while (!gpio_get_value(SPITZ_GPIO_HSYNC))
  396. cpu_relax();
  397. }
  398. static struct ads7846_platform_data spitz_ads7846_info = {
  399. .model = 7846,
  400. .vref_delay_usecs = 100,
  401. .x_plate_ohms = 419,
  402. .y_plate_ohms = 486,
  403. .pressure_max = 1024,
  404. .gpio_pendown = SPITZ_GPIO_TP_INT,
  405. .wait_for_sync = spitz_wait_for_hsync,
  406. };
  407. static struct pxa2xx_spi_chip spitz_ads7846_chip = {
  408. .gpio_cs = SPITZ_GPIO_ADS7846_CS,
  409. };
  410. static void spitz_bl_kick_battery(void)
  411. {
  412. void (*kick_batt)(void);
  413. kick_batt = symbol_get(sharpsl_battery_kick);
  414. if (kick_batt) {
  415. kick_batt();
  416. symbol_put(sharpsl_battery_kick);
  417. }
  418. }
  419. static struct corgi_lcd_platform_data spitz_lcdcon_info = {
  420. .init_mode = CORGI_LCD_MODE_VGA,
  421. .max_intensity = 0x2f,
  422. .default_intensity = 0x1f,
  423. .limit_mask = 0x0b,
  424. .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT,
  425. .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON,
  426. .kick_battery = spitz_bl_kick_battery,
  427. };
  428. static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
  429. .gpio_cs = SPITZ_GPIO_LCDCON_CS,
  430. };
  431. static struct pxa2xx_spi_chip spitz_max1111_chip = {
  432. .gpio_cs = SPITZ_GPIO_MAX1111_CS,
  433. };
  434. static struct spi_board_info spitz_spi_devices[] = {
  435. {
  436. .modalias = "ads7846",
  437. .max_speed_hz = 1200000,
  438. .bus_num = 2,
  439. .chip_select = 0,
  440. .platform_data = &spitz_ads7846_info,
  441. .controller_data= &spitz_ads7846_chip,
  442. .irq = gpio_to_irq(SPITZ_GPIO_TP_INT),
  443. }, {
  444. .modalias = "corgi-lcd",
  445. .max_speed_hz = 50000,
  446. .bus_num = 2,
  447. .chip_select = 1,
  448. .platform_data = &spitz_lcdcon_info,
  449. .controller_data= &spitz_lcdcon_chip,
  450. }, {
  451. .modalias = "max1111",
  452. .max_speed_hz = 450000,
  453. .bus_num = 2,
  454. .chip_select = 2,
  455. .controller_data= &spitz_max1111_chip,
  456. },
  457. };
  458. static void __init spitz_init_spi(void)
  459. {
  460. if (machine_is_akita()) {
  461. spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
  462. spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
  463. }
  464. pxa2xx_set_spi_info(2, &spitz_spi_info);
  465. spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
  466. }
  467. #else
  468. static inline void spitz_init_spi(void) {}
  469. #endif
  470. /*
  471. * MMC/SD Device
  472. *
  473. * The card detect interrupt isn't debounced so we delay it by 250ms
  474. * to give the card a chance to fully insert/eject.
  475. */
  476. static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
  477. {
  478. struct pxamci_platform_data* p_d = dev->platform_data;
  479. if (( 1 << vdd) & p_d->ocr_mask)
  480. spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
  481. else
  482. spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
  483. }
  484. static struct pxamci_platform_data spitz_mci_platform_data = {
  485. .detect_delay_ms = 250,
  486. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  487. .setpower = spitz_mci_setpower,
  488. .gpio_card_detect = SPITZ_GPIO_nSD_DETECT,
  489. .gpio_card_ro = SPITZ_GPIO_nSD_WP,
  490. .gpio_power = -1,
  491. };
  492. /*
  493. * USB Host (OHCI)
  494. */
  495. static int spitz_ohci_init(struct device *dev)
  496. {
  497. int err;
  498. err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
  499. if (err)
  500. return err;
  501. /* Only Port 2 is connected
  502. * Setup USB Port 2 Output Control Register
  503. */
  504. UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
  505. return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
  506. }
  507. static void spitz_ohci_exit(struct device *dev)
  508. {
  509. gpio_free(SPITZ_GPIO_USB_HOST);
  510. }
  511. static struct pxaohci_platform_data spitz_ohci_platform_data = {
  512. .port_mode = PMM_NPS_MODE,
  513. .init = spitz_ohci_init,
  514. .exit = spitz_ohci_exit,
  515. .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
  516. .power_budget = 150,
  517. };
  518. /*
  519. * Irda
  520. */
  521. static struct pxaficp_platform_data spitz_ficp_platform_data = {
  522. /* .gpio_pwdown is set in spitz_init() and akita_init() accordingly */
  523. .transceiver_cap = IR_SIRMODE | IR_OFF,
  524. };
  525. /*
  526. * Spitz PXA Framebuffer
  527. */
  528. static struct pxafb_mode_info spitz_pxafb_modes[] = {
  529. {
  530. .pixclock = 19231,
  531. .xres = 480,
  532. .yres = 640,
  533. .bpp = 16,
  534. .hsync_len = 40,
  535. .left_margin = 46,
  536. .right_margin = 125,
  537. .vsync_len = 3,
  538. .upper_margin = 1,
  539. .lower_margin = 0,
  540. .sync = 0,
  541. },{
  542. .pixclock = 134617,
  543. .xres = 240,
  544. .yres = 320,
  545. .bpp = 16,
  546. .hsync_len = 20,
  547. .left_margin = 20,
  548. .right_margin = 46,
  549. .vsync_len = 2,
  550. .upper_margin = 1,
  551. .lower_margin = 0,
  552. .sync = 0,
  553. },
  554. };
  555. static struct pxafb_mach_info spitz_pxafb_info = {
  556. .modes = &spitz_pxafb_modes[0],
  557. .num_modes = 2,
  558. .fixed_modes = 1,
  559. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
  560. };
  561. static struct mtd_partition sharpsl_nand_partitions[] = {
  562. {
  563. .name = "System Area",
  564. .offset = 0,
  565. .size = 7 * 1024 * 1024,
  566. },
  567. {
  568. .name = "Root Filesystem",
  569. .offset = 7 * 1024 * 1024,
  570. },
  571. {
  572. .name = "Home Filesystem",
  573. .offset = MTDPART_OFS_APPEND,
  574. .size = MTDPART_SIZ_FULL,
  575. },
  576. };
  577. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  578. static struct nand_bbt_descr sharpsl_bbt = {
  579. .options = 0,
  580. .offs = 4,
  581. .len = 2,
  582. .pattern = scan_ff_pattern
  583. };
  584. static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
  585. .badblock_pattern = &sharpsl_bbt,
  586. .partitions = sharpsl_nand_partitions,
  587. .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions),
  588. };
  589. static struct resource sharpsl_nand_resources[] = {
  590. {
  591. .start = 0x0C000000,
  592. .end = 0x0C000FFF,
  593. .flags = IORESOURCE_MEM,
  594. },
  595. };
  596. static struct platform_device sharpsl_nand_device = {
  597. .name = "sharpsl-nand",
  598. .id = -1,
  599. .resource = sharpsl_nand_resources,
  600. .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
  601. .dev.platform_data = &sharpsl_nand_platform_data,
  602. };
  603. static struct mtd_partition sharpsl_rom_parts[] = {
  604. {
  605. .name ="Boot PROM Filesystem",
  606. .offset = 0x00140000,
  607. .size = MTDPART_SIZ_FULL,
  608. },
  609. };
  610. static struct physmap_flash_data sharpsl_rom_data = {
  611. .width = 2,
  612. .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
  613. .parts = sharpsl_rom_parts,
  614. };
  615. static struct resource sharpsl_rom_resources[] = {
  616. {
  617. .start = 0x00000000,
  618. .end = 0x007fffff,
  619. .flags = IORESOURCE_MEM,
  620. },
  621. };
  622. static struct platform_device sharpsl_rom_device = {
  623. .name = "physmap-flash",
  624. .id = -1,
  625. .resource = sharpsl_rom_resources,
  626. .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
  627. .dev.platform_data = &sharpsl_rom_data,
  628. };
  629. static struct platform_device *devices[] __initdata = {
  630. &spitzscoop_device,
  631. &spitzkbd_device,
  632. &spitz_gpio_keys_device,
  633. &spitzled_device,
  634. &sharpsl_nand_device,
  635. &sharpsl_rom_device,
  636. };
  637. static void spitz_poweroff(void)
  638. {
  639. arm_machine_restart('g', NULL);
  640. }
  641. static void spitz_restart(char mode, const char *cmd)
  642. {
  643. /* Bootloader magic for a reboot */
  644. if((MSC0 & 0xffff0000) == 0x7ff00000)
  645. MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
  646. spitz_poweroff();
  647. }
  648. static void __init common_init(void)
  649. {
  650. init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0);
  651. pm_power_off = spitz_poweroff;
  652. arm_pm_restart = spitz_restart;
  653. if (machine_is_spitz()) {
  654. sharpsl_nand_partitions[1].size = 5 * 1024 * 1024;
  655. } else if (machine_is_akita()) {
  656. sharpsl_nand_partitions[1].size = 58 * 1024 * 1024;
  657. } else if (machine_is_borzoi()) {
  658. sharpsl_nand_partitions[1].size = 32 * 1024 * 1024;
  659. }
  660. PMCR = 0x00;
  661. /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
  662. PCFR |= PCFR_OPDE;
  663. pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
  664. pxa_set_ffuart_info(NULL);
  665. pxa_set_btuart_info(NULL);
  666. pxa_set_stuart_info(NULL);
  667. spitz_init_spi();
  668. platform_add_devices(devices, ARRAY_SIZE(devices));
  669. pxa_set_mci_info(&spitz_mci_platform_data);
  670. pxa_set_ohci_info(&spitz_ohci_platform_data);
  671. pxa_set_ficp_info(&spitz_ficp_platform_data);
  672. set_pxa_fb_info(&spitz_pxafb_info);
  673. pxa_set_i2c_info(NULL);
  674. }
  675. #if defined(CONFIG_MACH_AKITA) || defined(CONFIG_MACH_BORZOI)
  676. static struct nand_bbt_descr sharpsl_akita_bbt = {
  677. .options = 0,
  678. .offs = 4,
  679. .len = 1,
  680. .pattern = scan_ff_pattern
  681. };
  682. static struct nand_ecclayout akita_oobinfo = {
  683. .eccbytes = 24,
  684. .eccpos = {
  685. 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11,
  686. 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23,
  687. 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37},
  688. .oobfree = {{0x08, 0x09}}
  689. };
  690. #endif
  691. #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
  692. static void __init spitz_init(void)
  693. {
  694. spitz_ficp_platform_data.gpio_pwdown = SPITZ_GPIO_IR_ON;
  695. #ifdef CONFIG_MACH_BORZOI
  696. if (machine_is_borzoi()) {
  697. sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt;
  698. sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo;
  699. }
  700. #endif
  701. platform_scoop_config = &spitz_pcmcia_config;
  702. common_init();
  703. platform_device_register(&spitzscoop2_device);
  704. }
  705. #endif
  706. #ifdef CONFIG_MACH_AKITA
  707. /*
  708. * Akita IO Expander
  709. */
  710. static struct pca953x_platform_data akita_ioexp = {
  711. .gpio_base = AKITA_IOEXP_GPIO_BASE,
  712. };
  713. static struct i2c_board_info akita_i2c_board_info[] = {
  714. {
  715. .type = "max7310",
  716. .addr = 0x18,
  717. .platform_data = &akita_ioexp,
  718. }, {
  719. .type = "wm8750",
  720. .addr = 0x1b,
  721. },
  722. };
  723. static void __init akita_init(void)
  724. {
  725. spitz_ficp_platform_data.gpio_pwdown = AKITA_GPIO_IR_ON;
  726. sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt;
  727. sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo;
  728. /* We just pretend the second element of the array doesn't exist */
  729. spitz_pcmcia_config.num_devs = 1;
  730. platform_scoop_config = &spitz_pcmcia_config;
  731. i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
  732. common_init();
  733. }
  734. #endif
  735. static void __init fixup_spitz(struct machine_desc *desc,
  736. struct tag *tags, char **cmdline, struct meminfo *mi)
  737. {
  738. sharpsl_save_param();
  739. mi->nr_banks = 1;
  740. mi->bank[0].start = 0xa0000000;
  741. mi->bank[0].size = (64*1024*1024);
  742. }
  743. #ifdef CONFIG_MACH_SPITZ
  744. MACHINE_START(SPITZ, "SHARP Spitz")
  745. .phys_io = 0x40000000,
  746. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  747. .fixup = fixup_spitz,
  748. .map_io = pxa_map_io,
  749. .init_irq = pxa27x_init_irq,
  750. .init_machine = spitz_init,
  751. .timer = &pxa_timer,
  752. MACHINE_END
  753. #endif
  754. #ifdef CONFIG_MACH_BORZOI
  755. MACHINE_START(BORZOI, "SHARP Borzoi")
  756. .phys_io = 0x40000000,
  757. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  758. .fixup = fixup_spitz,
  759. .map_io = pxa_map_io,
  760. .init_irq = pxa27x_init_irq,
  761. .init_machine = spitz_init,
  762. .timer = &pxa_timer,
  763. MACHINE_END
  764. #endif
  765. #ifdef CONFIG_MACH_AKITA
  766. MACHINE_START(AKITA, "SHARP Akita")
  767. .phys_io = 0x40000000,
  768. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  769. .fixup = fixup_spitz,
  770. .map_io = pxa_map_io,
  771. .init_irq = pxa27x_init_irq,
  772. .init_machine = akita_init,
  773. .timer = &pxa_timer,
  774. MACHINE_END
  775. #endif