spitz.c 19 KB

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