tosa.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  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/input/matrix_keypad.h>
  35. #include <asm/setup.h>
  36. #include <asm/mach-types.h>
  37. #include <mach/pxa25x.h>
  38. #include <mach/reset.h>
  39. #include <mach/irda.h>
  40. #include <plat/i2c.h>
  41. #include <mach/mmc.h>
  42. #include <mach/udc.h>
  43. #include <mach/tosa_bt.h>
  44. #include <mach/pxa2xx_spi.h>
  45. #include <mach/audio.h>
  46. #include <asm/mach/arch.h>
  47. #include <mach/tosa.h>
  48. #include <asm/hardware/scoop.h>
  49. #include <asm/mach/sharpsl_param.h>
  50. #include "generic.h"
  51. #include "clock.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 pxa2xx_udc_mach_info udc_info __initdata = {
  212. .gpio_pullup = TOSA_GPIO_USB_PULLUP,
  213. .gpio_vbus = TOSA_GPIO_USB_IN,
  214. .gpio_vbus_inverted = 1,
  215. };
  216. /*
  217. * MMC/SD Device
  218. */
  219. static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
  220. {
  221. int err;
  222. err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
  223. if (err) {
  224. printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
  225. goto err_gpio_int;
  226. }
  227. err = gpio_direction_input(TOSA_GPIO_nSD_INT);
  228. if (err)
  229. goto err_gpio_int_dir;
  230. return 0;
  231. err_gpio_int_dir:
  232. gpio_free(TOSA_GPIO_nSD_INT);
  233. err_gpio_int:
  234. return err;
  235. }
  236. static void tosa_mci_exit(struct device *dev, void *data)
  237. {
  238. gpio_free(TOSA_GPIO_nSD_INT);
  239. }
  240. static struct pxamci_platform_data tosa_mci_platform_data = {
  241. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  242. .init = tosa_mci_init,
  243. .exit = tosa_mci_exit,
  244. .gpio_card_detect = TOSA_GPIO_nSD_DETECT,
  245. .gpio_card_ro = TOSA_GPIO_SD_WP,
  246. .gpio_power = TOSA_GPIO_PWR_ON,
  247. };
  248. /*
  249. * Irda
  250. */
  251. static void tosa_irda_transceiver_mode(struct device *dev, int mode)
  252. {
  253. if (mode & IR_OFF) {
  254. gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
  255. pxa2xx_transceiver_mode(dev, mode);
  256. gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
  257. } else {
  258. pxa2xx_transceiver_mode(dev, mode);
  259. gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
  260. }
  261. }
  262. static int tosa_irda_startup(struct device *dev)
  263. {
  264. int ret;
  265. ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
  266. if (ret)
  267. goto err_tx;
  268. ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
  269. if (ret)
  270. goto err_tx_dir;
  271. ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
  272. if (ret)
  273. goto err_pwr;
  274. ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
  275. if (ret)
  276. goto err_pwr_dir;
  277. tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
  278. return 0;
  279. err_pwr_dir:
  280. gpio_free(TOSA_GPIO_IR_POWERDWN);
  281. err_pwr:
  282. err_tx_dir:
  283. gpio_free(TOSA_GPIO_IRDA_TX);
  284. err_tx:
  285. return ret;
  286. }
  287. static void tosa_irda_shutdown(struct device *dev)
  288. {
  289. tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
  290. gpio_free(TOSA_GPIO_IR_POWERDWN);
  291. gpio_free(TOSA_GPIO_IRDA_TX);
  292. }
  293. static struct pxaficp_platform_data tosa_ficp_platform_data = {
  294. .gpio_pwdown = -1,
  295. .transceiver_cap = IR_SIRMODE | IR_OFF,
  296. .transceiver_mode = tosa_irda_transceiver_mode,
  297. .startup = tosa_irda_startup,
  298. .shutdown = tosa_irda_shutdown,
  299. };
  300. /*
  301. * Tosa AC IN
  302. */
  303. static int tosa_power_init(struct device *dev)
  304. {
  305. int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
  306. if (ret)
  307. goto err_gpio_req;
  308. ret = gpio_direction_input(TOSA_GPIO_AC_IN);
  309. if (ret)
  310. goto err_gpio_in;
  311. return 0;
  312. err_gpio_in:
  313. gpio_free(TOSA_GPIO_AC_IN);
  314. err_gpio_req:
  315. return ret;
  316. }
  317. static void tosa_power_exit(struct device *dev)
  318. {
  319. gpio_free(TOSA_GPIO_AC_IN);
  320. }
  321. static int tosa_power_ac_online(void)
  322. {
  323. return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
  324. }
  325. static char *tosa_ac_supplied_to[] = {
  326. "main-battery",
  327. "backup-battery",
  328. "jacket-battery",
  329. };
  330. static struct pda_power_pdata tosa_power_data = {
  331. .init = tosa_power_init,
  332. .is_ac_online = tosa_power_ac_online,
  333. .exit = tosa_power_exit,
  334. .supplied_to = tosa_ac_supplied_to,
  335. .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
  336. };
  337. static struct resource tosa_power_resource[] = {
  338. {
  339. .name = "ac",
  340. .start = gpio_to_irq(TOSA_GPIO_AC_IN),
  341. .end = gpio_to_irq(TOSA_GPIO_AC_IN),
  342. .flags = IORESOURCE_IRQ |
  343. IORESOURCE_IRQ_HIGHEDGE |
  344. IORESOURCE_IRQ_LOWEDGE,
  345. },
  346. };
  347. static struct platform_device tosa_power_device = {
  348. .name = "pda-power",
  349. .id = -1,
  350. .dev.platform_data = &tosa_power_data,
  351. .resource = tosa_power_resource,
  352. .num_resources = ARRAY_SIZE(tosa_power_resource),
  353. };
  354. /*
  355. * Tosa Keyboard
  356. */
  357. static const uint32_t tosakbd_keymap[] = {
  358. KEY(0, 2, KEY_W),
  359. KEY(0, 6, KEY_K),
  360. KEY(0, 7, KEY_BACKSPACE),
  361. KEY(0, 8, KEY_P),
  362. KEY(1, 1, KEY_Q),
  363. KEY(1, 2, KEY_E),
  364. KEY(1, 3, KEY_T),
  365. KEY(1, 4, KEY_Y),
  366. KEY(1, 6, KEY_O),
  367. KEY(1, 7, KEY_I),
  368. KEY(1, 8, KEY_COMMA),
  369. KEY(2, 1, KEY_A),
  370. KEY(2, 2, KEY_D),
  371. KEY(2, 3, KEY_G),
  372. KEY(2, 4, KEY_U),
  373. KEY(2, 6, KEY_L),
  374. KEY(2, 7, KEY_ENTER),
  375. KEY(2, 8, KEY_DOT),
  376. KEY(3, 1, KEY_Z),
  377. KEY(3, 2, KEY_C),
  378. KEY(3, 3, KEY_V),
  379. KEY(3, 4, KEY_J),
  380. KEY(3, 5, TOSA_KEY_ADDRESSBOOK),
  381. KEY(3, 6, TOSA_KEY_CANCEL),
  382. KEY(3, 7, TOSA_KEY_CENTER),
  383. KEY(3, 8, TOSA_KEY_OK),
  384. KEY(3, 9, KEY_LEFTSHIFT),
  385. KEY(4, 1, KEY_S),
  386. KEY(4, 2, KEY_R),
  387. KEY(4, 3, KEY_B),
  388. KEY(4, 4, KEY_N),
  389. KEY(4, 5, TOSA_KEY_CALENDAR),
  390. KEY(4, 6, TOSA_KEY_HOMEPAGE),
  391. KEY(4, 7, KEY_LEFTCTRL),
  392. KEY(4, 8, TOSA_KEY_LIGHT),
  393. KEY(4, 10, KEY_RIGHTSHIFT),
  394. KEY(5, 1, KEY_TAB),
  395. KEY(5, 2, KEY_SLASH),
  396. KEY(5, 3, KEY_H),
  397. KEY(5, 4, KEY_M),
  398. KEY(5, 5, TOSA_KEY_MENU),
  399. KEY(5, 7, KEY_UP),
  400. KEY(5, 11, TOSA_KEY_FN),
  401. KEY(6, 1, KEY_X),
  402. KEY(6, 2, KEY_F),
  403. KEY(6, 3, KEY_SPACE),
  404. KEY(6, 4, KEY_APOSTROPHE),
  405. KEY(6, 5, TOSA_KEY_MAIL),
  406. KEY(6, 6, KEY_LEFT),
  407. KEY(6, 7, KEY_DOWN),
  408. KEY(6, 8, KEY_RIGHT),
  409. };
  410. static struct matrix_keymap_data tosakbd_keymap_data = {
  411. .keymap = tosakbd_keymap,
  412. .keymap_size = ARRAY_SIZE(tosakbd_keymap),
  413. };
  414. static const int tosakbd_col_gpios[] =
  415. { 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68 };
  416. static const int tosakbd_row_gpios[] =
  417. { 69, 70, 71, 72, 73, 74, 75 };
  418. static struct matrix_keypad_platform_data tosakbd_pdata = {
  419. .keymap_data = &tosakbd_keymap_data,
  420. .row_gpios = tosakbd_row_gpios,
  421. .col_gpios = tosakbd_col_gpios,
  422. .num_row_gpios = ARRAY_SIZE(tosakbd_row_gpios),
  423. .num_col_gpios = ARRAY_SIZE(tosakbd_col_gpios),
  424. .col_scan_delay_us = 10,
  425. .debounce_ms = 10,
  426. .wakeup = 1,
  427. };
  428. static struct platform_device tosakbd_device = {
  429. .name = "matrix-keypad",
  430. .id = -1,
  431. .dev = {
  432. .platform_data = &tosakbd_pdata,
  433. },
  434. };
  435. static struct gpio_keys_button tosa_gpio_keys[] = {
  436. /*
  437. * Two following keys are directly tied to "ON" button of tosa. Why?
  438. * The first one can be used as a wakeup source, the second can't;
  439. * also the first one is OR of ac_powered and on_button.
  440. */
  441. {
  442. .type = EV_PWR,
  443. .code = KEY_RESERVED,
  444. .gpio = TOSA_GPIO_POWERON,
  445. .desc = "Poweron",
  446. .wakeup = 1,
  447. .active_low = 1,
  448. },
  449. {
  450. .type = EV_PWR,
  451. .code = KEY_SUSPEND,
  452. .gpio = TOSA_GPIO_ON_KEY,
  453. .desc = "On key",
  454. /*
  455. * can't be used as wakeup
  456. * .wakeup = 1,
  457. */
  458. .active_low = 1,
  459. },
  460. {
  461. .type = EV_KEY,
  462. .code = TOSA_KEY_RECORD,
  463. .gpio = TOSA_GPIO_RECORD_BTN,
  464. .desc = "Record Button",
  465. .wakeup = 1,
  466. .active_low = 1,
  467. },
  468. {
  469. .type = EV_KEY,
  470. .code = TOSA_KEY_SYNC,
  471. .gpio = TOSA_GPIO_SYNC,
  472. .desc = "Sync Button",
  473. .wakeup = 1,
  474. .active_low = 1,
  475. },
  476. {
  477. .type = EV_SW,
  478. .code = SW_HEADPHONE_INSERT,
  479. .gpio = TOSA_GPIO_EAR_IN,
  480. .desc = "HeadPhone insert",
  481. .active_low = 1,
  482. .debounce_interval = 300,
  483. },
  484. };
  485. static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
  486. .buttons = tosa_gpio_keys,
  487. .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
  488. };
  489. static struct platform_device tosa_gpio_keys_device = {
  490. .name = "gpio-keys",
  491. .id = -1,
  492. .dev = {
  493. .platform_data = &tosa_gpio_keys_platform_data,
  494. },
  495. };
  496. /*
  497. * Tosa LEDs
  498. */
  499. static struct gpio_led tosa_gpio_leds[] = {
  500. {
  501. .name = "tosa:amber:charge",
  502. .default_trigger = "main-battery-charging",
  503. .gpio = TOSA_GPIO_CHRG_ERR_LED,
  504. },
  505. {
  506. .name = "tosa:green:mail",
  507. .default_trigger = "nand-disk",
  508. .gpio = TOSA_GPIO_NOTE_LED,
  509. },
  510. {
  511. .name = "tosa:dual:wlan",
  512. .default_trigger = "none",
  513. .gpio = TOSA_GPIO_WLAN_LED,
  514. },
  515. {
  516. .name = "tosa:blue:bluetooth",
  517. .default_trigger = "tosa-bt",
  518. .gpio = TOSA_GPIO_BT_LED,
  519. },
  520. };
  521. static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
  522. .leds = tosa_gpio_leds,
  523. .num_leds = ARRAY_SIZE(tosa_gpio_leds),
  524. };
  525. static struct platform_device tosaled_device = {
  526. .name = "leds-gpio",
  527. .id = -1,
  528. .dev = {
  529. .platform_data = &tosa_gpio_leds_platform_data,
  530. },
  531. };
  532. /*
  533. * Toshiba Mobile IO Controller
  534. */
  535. static struct resource tc6393xb_resources[] = {
  536. [0] = {
  537. .start = TOSA_LCDC_PHYS,
  538. .end = TOSA_LCDC_PHYS + 0x3ffffff,
  539. .flags = IORESOURCE_MEM,
  540. },
  541. [1] = {
  542. .start = TOSA_IRQ_GPIO_TC6393XB_INT,
  543. .end = TOSA_IRQ_GPIO_TC6393XB_INT,
  544. .flags = IORESOURCE_IRQ,
  545. },
  546. };
  547. static int tosa_tc6393xb_enable(struct platform_device *dev)
  548. {
  549. int rc;
  550. rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
  551. if (rc)
  552. goto err_req_pclr;
  553. rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
  554. if (rc)
  555. goto err_req_suspend;
  556. rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "tc6393xb l3v");
  557. if (rc)
  558. goto err_req_l3v;
  559. rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
  560. if (rc)
  561. goto err_dir_l3v;
  562. rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
  563. if (rc)
  564. goto err_dir_suspend;
  565. rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
  566. if (rc)
  567. goto err_dir_pclr;
  568. mdelay(1);
  569. gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
  570. mdelay(10);
  571. gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
  572. gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
  573. return 0;
  574. err_dir_pclr:
  575. err_dir_suspend:
  576. err_dir_l3v:
  577. gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
  578. err_req_l3v:
  579. gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
  580. err_req_suspend:
  581. gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
  582. err_req_pclr:
  583. return rc;
  584. }
  585. static int tosa_tc6393xb_disable(struct platform_device *dev)
  586. {
  587. gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
  588. gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
  589. gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
  590. return 0;
  591. }
  592. static int tosa_tc6393xb_resume(struct platform_device *dev)
  593. {
  594. gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
  595. mdelay(10);
  596. gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
  597. mdelay(10);
  598. return 0;
  599. }
  600. static int tosa_tc6393xb_suspend(struct platform_device *dev)
  601. {
  602. gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
  603. gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
  604. return 0;
  605. }
  606. static struct mtd_partition tosa_nand_partition[] = {
  607. {
  608. .name = "smf",
  609. .offset = 0,
  610. .size = 7 * 1024 * 1024,
  611. },
  612. {
  613. .name = "root",
  614. .offset = MTDPART_OFS_APPEND,
  615. .size = 28 * 1024 * 1024,
  616. },
  617. {
  618. .name = "home",
  619. .offset = MTDPART_OFS_APPEND,
  620. .size = MTDPART_SIZ_FULL,
  621. },
  622. };
  623. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  624. static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = {
  625. .options = 0,
  626. .offs = 4,
  627. .len = 2,
  628. .pattern = scan_ff_pattern
  629. };
  630. static struct tmio_nand_data tosa_tc6393xb_nand_config = {
  631. .num_partitions = ARRAY_SIZE(tosa_nand_partition),
  632. .partition = tosa_nand_partition,
  633. .badblock_pattern = &tosa_tc6393xb_nand_bbt,
  634. };
  635. static int tosa_tc6393xb_setup(struct platform_device *dev)
  636. {
  637. int rc;
  638. rc = gpio_request(TOSA_GPIO_CARD_VCC_ON, "CARD_VCC_ON");
  639. if (rc)
  640. goto err_req;
  641. rc = gpio_direction_output(TOSA_GPIO_CARD_VCC_ON, 1);
  642. if (rc)
  643. goto err_dir;
  644. return rc;
  645. err_dir:
  646. gpio_free(TOSA_GPIO_CARD_VCC_ON);
  647. err_req:
  648. return rc;
  649. }
  650. static void tosa_tc6393xb_teardown(struct platform_device *dev)
  651. {
  652. gpio_free(TOSA_GPIO_CARD_VCC_ON);
  653. }
  654. #ifdef CONFIG_MFD_TC6393XB
  655. static struct fb_videomode tosa_tc6393xb_lcd_mode[] = {
  656. {
  657. .xres = 480,
  658. .yres = 640,
  659. .pixclock = 0x002cdf00,/* PLL divisor */
  660. .left_margin = 0x004c,
  661. .right_margin = 0x005b,
  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. .xres = 240,
  670. .yres = 320,
  671. .pixclock = 0x00e7f203,/* PLL divisor */
  672. .left_margin = 0x0024,
  673. .right_margin = 0x002f,
  674. .upper_margin = 0x0001,
  675. .lower_margin = 0x000d,
  676. .hsync_len = 0x0002,
  677. .vsync_len = 0x0001,
  678. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  679. .vmode = FB_VMODE_NONINTERLACED,
  680. }
  681. };
  682. static struct tmio_fb_data tosa_tc6393xb_fb_config = {
  683. .lcd_set_power = tc6393xb_lcd_set_power,
  684. .lcd_mode = tc6393xb_lcd_mode,
  685. .num_modes = ARRAY_SIZE(tosa_tc6393xb_lcd_mode),
  686. .modes = &tosa_tc6393xb_lcd_mode[0],
  687. .height = 82,
  688. .width = 60,
  689. };
  690. #endif
  691. static struct tc6393xb_platform_data tosa_tc6393xb_data = {
  692. .scr_pll2cr = 0x0cc1,
  693. .scr_gper = 0x3300,
  694. .irq_base = IRQ_BOARD_START,
  695. .gpio_base = TOSA_TC6393XB_GPIO_BASE,
  696. .setup = tosa_tc6393xb_setup,
  697. .teardown = tosa_tc6393xb_teardown,
  698. .enable = tosa_tc6393xb_enable,
  699. .disable = tosa_tc6393xb_disable,
  700. .suspend = tosa_tc6393xb_suspend,
  701. .resume = tosa_tc6393xb_resume,
  702. .nand_data = &tosa_tc6393xb_nand_config,
  703. #ifdef CONFIG_MFD_TC6393XB
  704. .fb_data = &tosa_tc6393xb_fb_config,
  705. #endif
  706. .resume_restore = 1,
  707. };
  708. static struct platform_device tc6393xb_device = {
  709. .name = "tc6393xb",
  710. .id = -1,
  711. .dev = {
  712. .platform_data = &tosa_tc6393xb_data,
  713. },
  714. .num_resources = ARRAY_SIZE(tc6393xb_resources),
  715. .resource = tc6393xb_resources,
  716. };
  717. static struct tosa_bt_data tosa_bt_data = {
  718. .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
  719. .gpio_reset = TOSA_GPIO_BT_RESET,
  720. };
  721. static struct platform_device tosa_bt_device = {
  722. .name = "tosa-bt",
  723. .id = -1,
  724. .dev.platform_data = &tosa_bt_data,
  725. };
  726. static struct pxa2xx_spi_master pxa_ssp_master_info = {
  727. .num_chipselect = 1,
  728. };
  729. static struct spi_board_info spi_board_info[] __initdata = {
  730. {
  731. .modalias = "tosa-lcd",
  732. // .platform_data
  733. .max_speed_hz = 28750,
  734. .bus_num = 2,
  735. .chip_select = 0,
  736. .mode = SPI_MODE_0,
  737. },
  738. };
  739. static struct mtd_partition sharpsl_rom_parts[] = {
  740. {
  741. .name ="Boot PROM Filesystem",
  742. .offset = 0x00160000,
  743. .size = MTDPART_SIZ_FULL,
  744. },
  745. };
  746. static struct physmap_flash_data sharpsl_rom_data = {
  747. .width = 2,
  748. .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
  749. .parts = sharpsl_rom_parts,
  750. };
  751. static struct resource sharpsl_rom_resources[] = {
  752. {
  753. .start = 0x00000000,
  754. .end = 0x007fffff,
  755. .flags = IORESOURCE_MEM,
  756. },
  757. };
  758. static struct platform_device sharpsl_rom_device = {
  759. .name = "physmap-flash",
  760. .id = -1,
  761. .resource = sharpsl_rom_resources,
  762. .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
  763. .dev.platform_data = &sharpsl_rom_data,
  764. };
  765. static struct platform_device *devices[] __initdata = {
  766. &tosascoop_device,
  767. &tosascoop_jc_device,
  768. &tc6393xb_device,
  769. &tosa_power_device,
  770. &tosakbd_device,
  771. &tosa_gpio_keys_device,
  772. &tosaled_device,
  773. &tosa_bt_device,
  774. &sharpsl_rom_device,
  775. };
  776. static void tosa_poweroff(void)
  777. {
  778. arm_machine_restart('g', NULL);
  779. }
  780. static void tosa_restart(char mode, const char *cmd)
  781. {
  782. /* Bootloader magic for a reboot */
  783. if((MSC0 & 0xffff0000) == 0x7ff00000)
  784. MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
  785. tosa_poweroff();
  786. }
  787. static void __init tosa_init(void)
  788. {
  789. int dummy;
  790. pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
  791. pxa_set_ffuart_info(NULL);
  792. pxa_set_btuart_info(NULL);
  793. pxa_set_stuart_info(NULL);
  794. gpio_set_wake(MFP_PIN_GPIO1, 1);
  795. /* We can't pass to gpio-keys since it will drop the Reset altfunc */
  796. init_gpio_reset(TOSA_GPIO_ON_RESET, 0, 0);
  797. pm_power_off = tosa_poweroff;
  798. arm_pm_restart = tosa_restart;
  799. PCFR |= PCFR_OPDE;
  800. /* enable batt_fault */
  801. PMCR = 0x01;
  802. dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
  803. dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
  804. dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
  805. tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
  806. pxa_set_mci_info(&tosa_mci_platform_data);
  807. pxa_set_udc_info(&udc_info);
  808. pxa_set_ficp_info(&tosa_ficp_platform_data);
  809. pxa_set_i2c_info(NULL);
  810. pxa_set_ac97_info(NULL);
  811. platform_scoop_config = &tosa_pcmcia_config;
  812. pxa2xx_set_spi_info(2, &pxa_ssp_master_info);
  813. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  814. clk_add_alias("CLK_CK3P6MI", tc6393xb_device.name, "GPIO11_CLK", NULL);
  815. platform_add_devices(devices, ARRAY_SIZE(devices));
  816. }
  817. static void __init fixup_tosa(struct machine_desc *desc,
  818. struct tag *tags, char **cmdline, struct meminfo *mi)
  819. {
  820. sharpsl_save_param();
  821. mi->nr_banks=1;
  822. mi->bank[0].start = 0xa0000000;
  823. mi->bank[0].node = 0;
  824. mi->bank[0].size = (64*1024*1024);
  825. }
  826. MACHINE_START(TOSA, "SHARP Tosa")
  827. .phys_io = 0x40000000,
  828. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  829. .fixup = fixup_tosa,
  830. .map_io = pxa_map_io,
  831. .init_irq = pxa25x_init_irq,
  832. .init_machine = tosa_init,
  833. .timer = &pxa_timer,
  834. MACHINE_END