tosa.c 21 KB

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