tosa.c 21 KB

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