spitz.c 20 KB

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