tosa.c 21 KB

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