tosa.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970
  1. /*
  2. * Support for Sharp SL-C6000x PDAs
  3. * Model: (Tosa)
  4. *
  5. * Copyright (c) 2005 Dirk Opfer
  6. *
  7. * Based on code written by Sharp/Lineo for 2.4 kernels
  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/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/major.h>
  18. #include <linux/fs.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/delay.h>
  21. #include <linux/fb.h>
  22. #include <linux/mmc/host.h>
  23. #include <linux/mfd/tc6393xb.h>
  24. #include <linux/mfd/tmio.h>
  25. #include <linux/mtd/nand.h>
  26. #include <linux/mtd/partitions.h>
  27. #include <linux/mtd/physmap.h>
  28. #include <linux/pm.h>
  29. #include <linux/gpio_keys.h>
  30. #include <linux/input.h>
  31. #include <linux/gpio.h>
  32. #include <linux/pda_power.h>
  33. #include <linux/spi/spi.h>
  34. #include <linux/spi/pxa2xx_spi.h>
  35. #include <linux/input/matrix_keypad.h>
  36. #include <linux/i2c/pxa-i2c.h>
  37. #include <asm/setup.h>
  38. #include <asm/mach-types.h>
  39. #include <mach/pxa25x.h>
  40. #include <mach/reset.h>
  41. #include <mach/irda.h>
  42. #include <mach/mmc.h>
  43. #include <mach/udc.h>
  44. #include <mach/tosa_bt.h>
  45. #include <mach/audio.h>
  46. #include <mach/smemc.h>
  47. #include <asm/mach/arch.h>
  48. #include <mach/tosa.h>
  49. #include <asm/hardware/scoop.h>
  50. #include <asm/mach/sharpsl_param.h>
  51. #include "generic.h"
  52. #include "clock.h"
  53. #include "devices.h"
  54. static unsigned long tosa_pin_config[] = {
  55. GPIO78_nCS_2, /* Scoop */
  56. GPIO80_nCS_4, /* tg6393xb */
  57. GPIO33_nCS_5, /* Scoop */
  58. // GPIO76 CARD_VCC_ON1
  59. GPIO19_GPIO, /* Reset out */
  60. GPIO1_RST | WAKEUP_ON_EDGE_FALL,
  61. GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */
  62. GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */
  63. GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */
  64. GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */
  65. GPIO20_GPIO, /* EAR_IN */
  66. GPIO22_GPIO, /* On */
  67. GPIO5_GPIO, /* USB_IN */
  68. GPIO32_GPIO, /* Pen IRQ */
  69. GPIO7_GPIO, /* Jacket Detect */
  70. GPIO14_GPIO, /* BAT0_CRG */
  71. GPIO12_GPIO, /* BAT1_CRG */
  72. GPIO17_GPIO, /* BAT0_LOW */
  73. GPIO84_GPIO, /* BAT1_LOW */
  74. GPIO38_GPIO, /* BAT_LOCK */
  75. GPIO11_3_6MHz,
  76. GPIO15_GPIO, /* TC6393XB IRQ */
  77. GPIO18_RDY,
  78. GPIO27_GPIO, /* LCD Sync */
  79. /* MMC */
  80. GPIO6_MMC_CLK,
  81. GPIO8_MMC_CS0,
  82. GPIO9_GPIO, /* Detect */
  83. GPIO10_GPIO, /* nSD_INT */
  84. /* CF */
  85. GPIO13_GPIO, /* CD_IRQ */
  86. GPIO21_GPIO, /* Main Slot IRQ */
  87. GPIO36_GPIO, /* Jacket Slot IRQ */
  88. GPIO48_nPOE,
  89. GPIO49_nPWE,
  90. GPIO50_nPIOR,
  91. GPIO51_nPIOW,
  92. GPIO52_nPCE_1,
  93. GPIO53_nPCE_2,
  94. GPIO54_nPSKTSEL,
  95. GPIO55_nPREG,
  96. GPIO56_nPWAIT,
  97. GPIO57_nIOIS16,
  98. /* AC97 */
  99. GPIO31_AC97_SYNC,
  100. GPIO30_AC97_SDATA_OUT,
  101. GPIO28_AC97_BITCLK,
  102. GPIO29_AC97_SDATA_IN_0,
  103. // GPIO79 nAUD_IRQ
  104. /* FFUART */
  105. GPIO34_FFUART_RXD,
  106. GPIO35_FFUART_CTS,
  107. GPIO37_FFUART_DSR,
  108. GPIO39_FFUART_TXD,
  109. GPIO40_FFUART_DTR,
  110. GPIO41_FFUART_RTS,
  111. /* BTUART */
  112. GPIO42_BTUART_RXD,
  113. GPIO43_BTUART_TXD,
  114. GPIO44_BTUART_CTS,
  115. GPIO45_BTUART_RTS,
  116. /* Keybd */
  117. GPIO58_GPIO | MFP_LPM_DRIVE_LOW, /* Column 0 */
  118. GPIO59_GPIO | MFP_LPM_DRIVE_LOW, /* Column 1 */
  119. GPIO60_GPIO | MFP_LPM_DRIVE_LOW, /* Column 2 */
  120. GPIO61_GPIO | MFP_LPM_DRIVE_LOW, /* Column 3 */
  121. GPIO62_GPIO | MFP_LPM_DRIVE_LOW, /* Column 4 */
  122. GPIO63_GPIO | MFP_LPM_DRIVE_LOW, /* Column 5 */
  123. GPIO64_GPIO | MFP_LPM_DRIVE_LOW, /* Column 6 */
  124. GPIO65_GPIO | MFP_LPM_DRIVE_LOW, /* Column 7 */
  125. GPIO66_GPIO | MFP_LPM_DRIVE_LOW, /* Column 8 */
  126. GPIO67_GPIO | MFP_LPM_DRIVE_LOW, /* Column 9 */
  127. GPIO68_GPIO | MFP_LPM_DRIVE_LOW, /* Column 10 */
  128. GPIO69_GPIO | MFP_LPM_DRIVE_LOW, /* Row 0 */
  129. GPIO70_GPIO | MFP_LPM_DRIVE_LOW, /* Row 1 */
  130. GPIO71_GPIO | MFP_LPM_DRIVE_LOW, /* Row 2 */
  131. GPIO72_GPIO | MFP_LPM_DRIVE_LOW, /* Row 3 */
  132. GPIO73_GPIO | MFP_LPM_DRIVE_LOW, /* Row 4 */
  133. GPIO74_GPIO | MFP_LPM_DRIVE_LOW, /* Row 5 */
  134. GPIO75_GPIO | MFP_LPM_DRIVE_LOW, /* Row 6 */
  135. /* SPI */
  136. GPIO81_SSP2_CLK_OUT,
  137. GPIO82_SSP2_FRM_OUT,
  138. GPIO83_SSP2_TXD,
  139. /* IrDA is managed in other way */
  140. GPIO46_GPIO,
  141. GPIO47_GPIO,
  142. };
  143. /*
  144. * SCOOP Device
  145. */
  146. static struct resource tosa_scoop_resources[] = {
  147. [0] = {
  148. .start = TOSA_CF_PHYS,
  149. .end = TOSA_CF_PHYS + 0xfff,
  150. .flags = IORESOURCE_MEM,
  151. },
  152. };
  153. static struct scoop_config tosa_scoop_setup = {
  154. .io_dir = TOSA_SCOOP_IO_DIR,
  155. .gpio_base = TOSA_SCOOP_GPIO_BASE,
  156. };
  157. static struct platform_device tosascoop_device = {
  158. .name = "sharp-scoop",
  159. .id = 0,
  160. .dev = {
  161. .platform_data = &tosa_scoop_setup,
  162. },
  163. .num_resources = ARRAY_SIZE(tosa_scoop_resources),
  164. .resource = tosa_scoop_resources,
  165. };
  166. /*
  167. * SCOOP Device Jacket
  168. */
  169. static struct resource tosa_scoop_jc_resources[] = {
  170. [0] = {
  171. .start = TOSA_SCOOP_PHYS + 0x40,
  172. .end = TOSA_SCOOP_PHYS + 0xfff,
  173. .flags = IORESOURCE_MEM,
  174. },
  175. };
  176. static struct scoop_config tosa_scoop_jc_setup = {
  177. .io_dir = TOSA_SCOOP_JC_IO_DIR,
  178. .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
  179. };
  180. static struct platform_device tosascoop_jc_device = {
  181. .name = "sharp-scoop",
  182. .id = 1,
  183. .dev = {
  184. .platform_data = &tosa_scoop_jc_setup,
  185. .parent = &tosascoop_device.dev,
  186. },
  187. .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
  188. .resource = tosa_scoop_jc_resources,
  189. };
  190. /*
  191. * PCMCIA
  192. */
  193. static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
  194. {
  195. .dev = &tosascoop_device.dev,
  196. .irq = TOSA_IRQ_GPIO_CF_IRQ,
  197. .cd_irq = TOSA_IRQ_GPIO_CF_CD,
  198. .cd_irq_str = "PCMCIA0 CD",
  199. },{
  200. .dev = &tosascoop_jc_device.dev,
  201. .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
  202. .cd_irq = -1,
  203. },
  204. };
  205. static struct scoop_pcmcia_config tosa_pcmcia_config = {
  206. .devs = &tosa_pcmcia_scoop[0],
  207. .num_devs = 2,
  208. };
  209. /*
  210. * USB Device Controller
  211. */
  212. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  213. .gpio_pullup = TOSA_GPIO_USB_PULLUP,
  214. .gpio_vbus = TOSA_GPIO_USB_IN,
  215. .gpio_vbus_inverted = 1,
  216. };
  217. /*
  218. * MMC/SD Device
  219. */
  220. static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
  221. {
  222. int err;
  223. err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
  224. if (err) {
  225. printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
  226. goto err_gpio_int;
  227. }
  228. err = gpio_direction_input(TOSA_GPIO_nSD_INT);
  229. if (err)
  230. goto err_gpio_int_dir;
  231. return 0;
  232. err_gpio_int_dir:
  233. gpio_free(TOSA_GPIO_nSD_INT);
  234. err_gpio_int:
  235. return err;
  236. }
  237. static void tosa_mci_exit(struct device *dev, void *data)
  238. {
  239. gpio_free(TOSA_GPIO_nSD_INT);
  240. }
  241. static struct pxamci_platform_data tosa_mci_platform_data = {
  242. .detect_delay_ms = 250,
  243. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  244. .init = tosa_mci_init,
  245. .exit = tosa_mci_exit,
  246. .gpio_card_detect = TOSA_GPIO_nSD_DETECT,
  247. .gpio_card_ro = TOSA_GPIO_SD_WP,
  248. .gpio_power = TOSA_GPIO_PWR_ON,
  249. };
  250. /*
  251. * Irda
  252. */
  253. static void tosa_irda_transceiver_mode(struct device *dev, int mode)
  254. {
  255. if (mode & IR_OFF) {
  256. gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
  257. pxa2xx_transceiver_mode(dev, mode);
  258. gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
  259. } else {
  260. pxa2xx_transceiver_mode(dev, mode);
  261. gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
  262. }
  263. }
  264. static int tosa_irda_startup(struct device *dev)
  265. {
  266. int ret;
  267. ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
  268. if (ret)
  269. goto err_tx;
  270. ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
  271. if (ret)
  272. goto err_tx_dir;
  273. ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
  274. if (ret)
  275. goto err_pwr;
  276. ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
  277. if (ret)
  278. goto err_pwr_dir;
  279. tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
  280. return 0;
  281. err_pwr_dir:
  282. gpio_free(TOSA_GPIO_IR_POWERDWN);
  283. err_pwr:
  284. err_tx_dir:
  285. gpio_free(TOSA_GPIO_IRDA_TX);
  286. err_tx:
  287. return ret;
  288. }
  289. static void tosa_irda_shutdown(struct device *dev)
  290. {
  291. tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
  292. gpio_free(TOSA_GPIO_IR_POWERDWN);
  293. gpio_free(TOSA_GPIO_IRDA_TX);
  294. }
  295. static struct pxaficp_platform_data tosa_ficp_platform_data = {
  296. .gpio_pwdown = -1,
  297. .transceiver_cap = IR_SIRMODE | IR_OFF,
  298. .transceiver_mode = tosa_irda_transceiver_mode,
  299. .startup = tosa_irda_startup,
  300. .shutdown = tosa_irda_shutdown,
  301. };
  302. /*
  303. * Tosa AC IN
  304. */
  305. static int tosa_power_init(struct device *dev)
  306. {
  307. int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
  308. if (ret)
  309. goto err_gpio_req;
  310. ret = gpio_direction_input(TOSA_GPIO_AC_IN);
  311. if (ret)
  312. goto err_gpio_in;
  313. return 0;
  314. err_gpio_in:
  315. gpio_free(TOSA_GPIO_AC_IN);
  316. err_gpio_req:
  317. return ret;
  318. }
  319. static void tosa_power_exit(struct device *dev)
  320. {
  321. gpio_free(TOSA_GPIO_AC_IN);
  322. }
  323. static int tosa_power_ac_online(void)
  324. {
  325. return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
  326. }
  327. static char *tosa_ac_supplied_to[] = {
  328. "main-battery",
  329. "backup-battery",
  330. "jacket-battery",
  331. };
  332. static struct pda_power_pdata tosa_power_data = {
  333. .init = tosa_power_init,
  334. .is_ac_online = tosa_power_ac_online,
  335. .exit = tosa_power_exit,
  336. .supplied_to = tosa_ac_supplied_to,
  337. .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
  338. };
  339. static struct resource tosa_power_resource[] = {
  340. {
  341. .name = "ac",
  342. .start = gpio_to_irq(TOSA_GPIO_AC_IN),
  343. .end = gpio_to_irq(TOSA_GPIO_AC_IN),
  344. .flags = IORESOURCE_IRQ |
  345. IORESOURCE_IRQ_HIGHEDGE |
  346. IORESOURCE_IRQ_LOWEDGE,
  347. },
  348. };
  349. static struct platform_device tosa_power_device = {
  350. .name = "pda-power",
  351. .id = -1,
  352. .dev.platform_data = &tosa_power_data,
  353. .resource = tosa_power_resource,
  354. .num_resources = ARRAY_SIZE(tosa_power_resource),
  355. };
  356. /*
  357. * Tosa Keyboard
  358. */
  359. static const uint32_t tosakbd_keymap[] = {
  360. KEY(0, 2, KEY_W),
  361. KEY(0, 6, KEY_K),
  362. KEY(0, 7, KEY_BACKSPACE),
  363. KEY(0, 8, KEY_P),
  364. KEY(1, 1, KEY_Q),
  365. KEY(1, 2, KEY_E),
  366. KEY(1, 3, KEY_T),
  367. KEY(1, 4, KEY_Y),
  368. KEY(1, 6, KEY_O),
  369. KEY(1, 7, KEY_I),
  370. KEY(1, 8, KEY_COMMA),
  371. KEY(2, 1, KEY_A),
  372. KEY(2, 2, KEY_D),
  373. KEY(2, 3, KEY_G),
  374. KEY(2, 4, KEY_U),
  375. KEY(2, 6, KEY_L),
  376. KEY(2, 7, KEY_ENTER),
  377. KEY(2, 8, KEY_DOT),
  378. KEY(3, 1, KEY_Z),
  379. KEY(3, 2, KEY_C),
  380. KEY(3, 3, KEY_V),
  381. KEY(3, 4, KEY_J),
  382. KEY(3, 5, TOSA_KEY_ADDRESSBOOK),
  383. KEY(3, 6, TOSA_KEY_CANCEL),
  384. KEY(3, 7, TOSA_KEY_CENTER),
  385. KEY(3, 8, TOSA_KEY_OK),
  386. KEY(3, 9, KEY_LEFTSHIFT),
  387. KEY(4, 1, KEY_S),
  388. KEY(4, 2, KEY_R),
  389. KEY(4, 3, KEY_B),
  390. KEY(4, 4, KEY_N),
  391. KEY(4, 5, TOSA_KEY_CALENDAR),
  392. KEY(4, 6, TOSA_KEY_HOMEPAGE),
  393. KEY(4, 7, KEY_LEFTCTRL),
  394. KEY(4, 8, TOSA_KEY_LIGHT),
  395. KEY(4, 10, KEY_RIGHTSHIFT),
  396. KEY(5, 1, KEY_TAB),
  397. KEY(5, 2, KEY_SLASH),
  398. KEY(5, 3, KEY_H),
  399. KEY(5, 4, KEY_M),
  400. KEY(5, 5, TOSA_KEY_MENU),
  401. KEY(5, 7, KEY_UP),
  402. KEY(5, 11, TOSA_KEY_FN),
  403. KEY(6, 1, KEY_X),
  404. KEY(6, 2, KEY_F),
  405. KEY(6, 3, KEY_SPACE),
  406. KEY(6, 4, KEY_APOSTROPHE),
  407. KEY(6, 5, TOSA_KEY_MAIL),
  408. KEY(6, 6, KEY_LEFT),
  409. KEY(6, 7, KEY_DOWN),
  410. KEY(6, 8, KEY_RIGHT),
  411. };
  412. static struct matrix_keymap_data tosakbd_keymap_data = {
  413. .keymap = tosakbd_keymap,
  414. .keymap_size = ARRAY_SIZE(tosakbd_keymap),
  415. };
  416. static const int tosakbd_col_gpios[] =
  417. { 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68 };
  418. static const int tosakbd_row_gpios[] =
  419. { 69, 70, 71, 72, 73, 74, 75 };
  420. static struct matrix_keypad_platform_data tosakbd_pdata = {
  421. .keymap_data = &tosakbd_keymap_data,
  422. .row_gpios = tosakbd_row_gpios,
  423. .col_gpios = tosakbd_col_gpios,
  424. .num_row_gpios = ARRAY_SIZE(tosakbd_row_gpios),
  425. .num_col_gpios = ARRAY_SIZE(tosakbd_col_gpios),
  426. .col_scan_delay_us = 10,
  427. .debounce_ms = 10,
  428. .wakeup = 1,
  429. };
  430. static struct platform_device tosakbd_device = {
  431. .name = "matrix-keypad",
  432. .id = -1,
  433. .dev = {
  434. .platform_data = &tosakbd_pdata,
  435. },
  436. };
  437. static struct gpio_keys_button tosa_gpio_keys[] = {
  438. /*
  439. * Two following keys are directly tied to "ON" button of tosa. Why?
  440. * The first one can be used as a wakeup source, the second can't;
  441. * also the first one is OR of ac_powered and on_button.
  442. */
  443. {
  444. .type = EV_PWR,
  445. .code = KEY_RESERVED,
  446. .gpio = TOSA_GPIO_POWERON,
  447. .desc = "Poweron",
  448. .wakeup = 1,
  449. .active_low = 1,
  450. },
  451. {
  452. .type = EV_PWR,
  453. .code = KEY_SUSPEND,
  454. .gpio = TOSA_GPIO_ON_KEY,
  455. .desc = "On key",
  456. /*
  457. * can't be used as wakeup
  458. * .wakeup = 1,
  459. */
  460. .active_low = 1,
  461. },
  462. {
  463. .type = EV_KEY,
  464. .code = TOSA_KEY_RECORD,
  465. .gpio = TOSA_GPIO_RECORD_BTN,
  466. .desc = "Record Button",
  467. .wakeup = 1,
  468. .active_low = 1,
  469. },
  470. {
  471. .type = EV_KEY,
  472. .code = TOSA_KEY_SYNC,
  473. .gpio = TOSA_GPIO_SYNC,
  474. .desc = "Sync Button",
  475. .wakeup = 1,
  476. .active_low = 1,
  477. },
  478. {
  479. .type = EV_SW,
  480. .code = SW_HEADPHONE_INSERT,
  481. .gpio = TOSA_GPIO_EAR_IN,
  482. .desc = "HeadPhone insert",
  483. .active_low = 1,
  484. .debounce_interval = 300,
  485. },
  486. };
  487. static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
  488. .buttons = tosa_gpio_keys,
  489. .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
  490. };
  491. static struct platform_device tosa_gpio_keys_device = {
  492. .name = "gpio-keys",
  493. .id = -1,
  494. .dev = {
  495. .platform_data = &tosa_gpio_keys_platform_data,
  496. },
  497. };
  498. /*
  499. * Tosa LEDs
  500. */
  501. static struct gpio_led tosa_gpio_leds[] = {
  502. {
  503. .name = "tosa:amber:charge",
  504. .default_trigger = "main-battery-charging",
  505. .gpio = TOSA_GPIO_CHRG_ERR_LED,
  506. },
  507. {
  508. .name = "tosa:green:mail",
  509. .default_trigger = "nand-disk",
  510. .gpio = TOSA_GPIO_NOTE_LED,
  511. },
  512. {
  513. .name = "tosa:dual:wlan",
  514. .default_trigger = "none",
  515. .gpio = TOSA_GPIO_WLAN_LED,
  516. },
  517. {
  518. .name = "tosa:blue:bluetooth",
  519. .default_trigger = "tosa-bt",
  520. .gpio = TOSA_GPIO_BT_LED,
  521. },
  522. };
  523. static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
  524. .leds = tosa_gpio_leds,
  525. .num_leds = ARRAY_SIZE(tosa_gpio_leds),
  526. };
  527. static struct platform_device tosaled_device = {
  528. .name = "leds-gpio",
  529. .id = -1,
  530. .dev = {
  531. .platform_data = &tosa_gpio_leds_platform_data,
  532. },
  533. };
  534. /*
  535. * Toshiba Mobile IO Controller
  536. */
  537. static struct resource tc6393xb_resources[] = {
  538. [0] = {
  539. .start = TOSA_LCDC_PHYS,
  540. .end = TOSA_LCDC_PHYS + 0x3ffffff,
  541. .flags = IORESOURCE_MEM,
  542. },
  543. [1] = {
  544. .start = TOSA_IRQ_GPIO_TC6393XB_INT,
  545. .end = TOSA_IRQ_GPIO_TC6393XB_INT,
  546. .flags = IORESOURCE_IRQ,
  547. },
  548. };
  549. static int tosa_tc6393xb_enable(struct platform_device *dev)
  550. {
  551. int rc;
  552. rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
  553. if (rc)
  554. goto err_req_pclr;
  555. rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
  556. if (rc)
  557. goto err_req_suspend;
  558. rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "tc6393xb l3v");
  559. if (rc)
  560. goto err_req_l3v;
  561. rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
  562. if (rc)
  563. goto err_dir_l3v;
  564. rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
  565. if (rc)
  566. goto err_dir_suspend;
  567. rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
  568. if (rc)
  569. goto err_dir_pclr;
  570. mdelay(1);
  571. gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
  572. mdelay(10);
  573. gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
  574. gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
  575. return 0;
  576. err_dir_pclr:
  577. err_dir_suspend:
  578. err_dir_l3v:
  579. gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
  580. err_req_l3v:
  581. gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
  582. err_req_suspend:
  583. gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
  584. err_req_pclr:
  585. return rc;
  586. }
  587. static int tosa_tc6393xb_disable(struct platform_device *dev)
  588. {
  589. gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
  590. gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
  591. gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
  592. return 0;
  593. }
  594. static int tosa_tc6393xb_resume(struct platform_device *dev)
  595. {
  596. gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
  597. mdelay(10);
  598. gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
  599. mdelay(10);
  600. return 0;
  601. }
  602. static int tosa_tc6393xb_suspend(struct platform_device *dev)
  603. {
  604. gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
  605. gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
  606. return 0;
  607. }
  608. static struct mtd_partition tosa_nand_partition[] = {
  609. {
  610. .name = "smf",
  611. .offset = 0,
  612. .size = 7 * 1024 * 1024,
  613. },
  614. {
  615. .name = "root",
  616. .offset = MTDPART_OFS_APPEND,
  617. .size = 28 * 1024 * 1024,
  618. },
  619. {
  620. .name = "home",
  621. .offset = MTDPART_OFS_APPEND,
  622. .size = MTDPART_SIZ_FULL,
  623. },
  624. };
  625. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  626. static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = {
  627. .options = 0,
  628. .offs = 4,
  629. .len = 2,
  630. .pattern = scan_ff_pattern
  631. };
  632. static struct tmio_nand_data tosa_tc6393xb_nand_config = {
  633. .num_partitions = ARRAY_SIZE(tosa_nand_partition),
  634. .partition = tosa_nand_partition,
  635. .badblock_pattern = &tosa_tc6393xb_nand_bbt,
  636. };
  637. static int tosa_tc6393xb_setup(struct platform_device *dev)
  638. {
  639. int rc;
  640. rc = gpio_request(TOSA_GPIO_CARD_VCC_ON, "CARD_VCC_ON");
  641. if (rc)
  642. goto err_req;
  643. rc = gpio_direction_output(TOSA_GPIO_CARD_VCC_ON, 1);
  644. if (rc)
  645. goto err_dir;
  646. return rc;
  647. err_dir:
  648. gpio_free(TOSA_GPIO_CARD_VCC_ON);
  649. err_req:
  650. return rc;
  651. }
  652. static void tosa_tc6393xb_teardown(struct platform_device *dev)
  653. {
  654. gpio_free(TOSA_GPIO_CARD_VCC_ON);
  655. }
  656. #ifdef CONFIG_MFD_TC6393XB
  657. static struct fb_videomode tosa_tc6393xb_lcd_mode[] = {
  658. {
  659. .xres = 480,
  660. .yres = 640,
  661. .pixclock = 0x002cdf00,/* PLL divisor */
  662. .left_margin = 0x004c,
  663. .right_margin = 0x005b,
  664. .upper_margin = 0x0001,
  665. .lower_margin = 0x000d,
  666. .hsync_len = 0x0002,
  667. .vsync_len = 0x0001,
  668. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  669. .vmode = FB_VMODE_NONINTERLACED,
  670. },{
  671. .xres = 240,
  672. .yres = 320,
  673. .pixclock = 0x00e7f203,/* PLL divisor */
  674. .left_margin = 0x0024,
  675. .right_margin = 0x002f,
  676. .upper_margin = 0x0001,
  677. .lower_margin = 0x000d,
  678. .hsync_len = 0x0002,
  679. .vsync_len = 0x0001,
  680. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  681. .vmode = FB_VMODE_NONINTERLACED,
  682. }
  683. };
  684. static struct tmio_fb_data tosa_tc6393xb_fb_config = {
  685. .lcd_set_power = tc6393xb_lcd_set_power,
  686. .lcd_mode = tc6393xb_lcd_mode,
  687. .num_modes = ARRAY_SIZE(tosa_tc6393xb_lcd_mode),
  688. .modes = &tosa_tc6393xb_lcd_mode[0],
  689. .height = 82,
  690. .width = 60,
  691. };
  692. #endif
  693. static struct tc6393xb_platform_data tosa_tc6393xb_data = {
  694. .scr_pll2cr = 0x0cc1,
  695. .scr_gper = 0x3300,
  696. .irq_base = IRQ_BOARD_START,
  697. .gpio_base = TOSA_TC6393XB_GPIO_BASE,
  698. .setup = tosa_tc6393xb_setup,
  699. .teardown = tosa_tc6393xb_teardown,
  700. .enable = tosa_tc6393xb_enable,
  701. .disable = tosa_tc6393xb_disable,
  702. .suspend = tosa_tc6393xb_suspend,
  703. .resume = tosa_tc6393xb_resume,
  704. .nand_data = &tosa_tc6393xb_nand_config,
  705. #ifdef CONFIG_MFD_TC6393XB
  706. .fb_data = &tosa_tc6393xb_fb_config,
  707. #endif
  708. .resume_restore = 1,
  709. };
  710. static struct platform_device tc6393xb_device = {
  711. .name = "tc6393xb",
  712. .id = -1,
  713. .dev = {
  714. .platform_data = &tosa_tc6393xb_data,
  715. },
  716. .num_resources = ARRAY_SIZE(tc6393xb_resources),
  717. .resource = tc6393xb_resources,
  718. };
  719. static struct tosa_bt_data tosa_bt_data = {
  720. .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
  721. .gpio_reset = TOSA_GPIO_BT_RESET,
  722. };
  723. static struct platform_device tosa_bt_device = {
  724. .name = "tosa-bt",
  725. .id = -1,
  726. .dev.platform_data = &tosa_bt_data,
  727. };
  728. static struct pxa2xx_spi_master pxa_ssp_master_info = {
  729. .num_chipselect = 1,
  730. };
  731. static struct spi_board_info spi_board_info[] __initdata = {
  732. {
  733. .modalias = "tosa-lcd",
  734. // .platform_data
  735. .max_speed_hz = 28750,
  736. .bus_num = 2,
  737. .chip_select = 0,
  738. .mode = SPI_MODE_0,
  739. },
  740. };
  741. static struct mtd_partition sharpsl_rom_parts[] = {
  742. {
  743. .name ="Boot PROM Filesystem",
  744. .offset = 0x00160000,
  745. .size = MTDPART_SIZ_FULL,
  746. },
  747. };
  748. static struct physmap_flash_data sharpsl_rom_data = {
  749. .width = 2,
  750. .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
  751. .parts = sharpsl_rom_parts,
  752. };
  753. static struct resource sharpsl_rom_resources[] = {
  754. {
  755. .start = 0x00000000,
  756. .end = 0x007fffff,
  757. .flags = IORESOURCE_MEM,
  758. },
  759. };
  760. static struct platform_device sharpsl_rom_device = {
  761. .name = "physmap-flash",
  762. .id = -1,
  763. .resource = sharpsl_rom_resources,
  764. .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
  765. .dev.platform_data = &sharpsl_rom_data,
  766. };
  767. static struct platform_device wm9712_device = {
  768. .name = "wm9712-codec",
  769. .id = -1,
  770. };
  771. static struct platform_device *devices[] __initdata = {
  772. &tosascoop_device,
  773. &tosascoop_jc_device,
  774. &tc6393xb_device,
  775. &tosa_power_device,
  776. &tosakbd_device,
  777. &tosa_gpio_keys_device,
  778. &tosaled_device,
  779. &tosa_bt_device,
  780. &sharpsl_rom_device,
  781. &wm9712_device,
  782. };
  783. static void tosa_poweroff(void)
  784. {
  785. arm_machine_restart('g', NULL);
  786. }
  787. static void tosa_restart(char mode, const char *cmd)
  788. {
  789. uint32_t msc0 = __raw_readl(MSC0);
  790. /* Bootloader magic for a reboot */
  791. if((msc0 & 0xffff0000) == 0x7ff00000)
  792. __raw_writel((msc0 & 0xffff) | 0x7ee00000, MSC0);
  793. tosa_poweroff();
  794. }
  795. static void __init tosa_init(void)
  796. {
  797. int dummy;
  798. pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
  799. pxa_set_ffuart_info(NULL);
  800. pxa_set_btuart_info(NULL);
  801. pxa_set_stuart_info(NULL);
  802. gpio_set_wake(MFP_PIN_GPIO1, 1);
  803. /* We can't pass to gpio-keys since it will drop the Reset altfunc */
  804. init_gpio_reset(TOSA_GPIO_ON_RESET, 0, 0);
  805. pm_power_off = tosa_poweroff;
  806. arm_pm_restart = tosa_restart;
  807. PCFR |= PCFR_OPDE;
  808. /* enable batt_fault */
  809. PMCR = 0x01;
  810. dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
  811. dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
  812. dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
  813. pxa_set_mci_info(&tosa_mci_platform_data);
  814. pxa_set_udc_info(&udc_info);
  815. pxa_set_ficp_info(&tosa_ficp_platform_data);
  816. pxa_set_i2c_info(NULL);
  817. pxa_set_ac97_info(NULL);
  818. platform_scoop_config = &tosa_pcmcia_config;
  819. pxa2xx_set_spi_info(2, &pxa_ssp_master_info);
  820. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  821. clk_add_alias("CLK_CK3P6MI", tc6393xb_device.name, "GPIO11_CLK", NULL);
  822. platform_add_devices(devices, ARRAY_SIZE(devices));
  823. }
  824. static void __init fixup_tosa(struct machine_desc *desc,
  825. struct tag *tags, char **cmdline, struct meminfo *mi)
  826. {
  827. sharpsl_save_param();
  828. mi->nr_banks=1;
  829. mi->bank[0].start = 0xa0000000;
  830. mi->bank[0].size = (64*1024*1024);
  831. }
  832. MACHINE_START(TOSA, "SHARP Tosa")
  833. .fixup = fixup_tosa,
  834. .map_io = pxa25x_map_io,
  835. .nr_irqs = TOSA_NR_IRQS,
  836. .init_irq = pxa25x_init_irq,
  837. .init_machine = tosa_init,
  838. .timer = &pxa_timer,
  839. MACHINE_END