tosa.c 21 KB

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