tosa.c 21 KB

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