tosa.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  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/pm.h>
  28. #include <linux/gpio_keys.h>
  29. #include <linux/input.h>
  30. #include <linux/gpio.h>
  31. #include <linux/pda_power.h>
  32. #include <linux/rfkill.h>
  33. #include <asm/setup.h>
  34. #include <asm/mach-types.h>
  35. #include <asm/arch/pxa2xx-regs.h>
  36. #include <asm/arch/mfp-pxa25x.h>
  37. #include <asm/arch/irda.h>
  38. #include <asm/arch/i2c.h>
  39. #include <asm/arch/mmc.h>
  40. #include <asm/arch/udc.h>
  41. #include <asm/arch/tosa_bt.h>
  42. #include <asm/mach/arch.h>
  43. #include <asm/arch/tosa.h>
  44. #include <asm/hardware/scoop.h>
  45. #include <asm/mach/sharpsl_param.h>
  46. #include "generic.h"
  47. #include "devices.h"
  48. static unsigned long tosa_pin_config[] = {
  49. GPIO78_nCS_2, /* Scoop */
  50. GPIO80_nCS_4, /* tg6393xb */
  51. GPIO33_nCS_5, /* Scoop */
  52. // GPIO76 CARD_VCC_ON1
  53. GPIO19_GPIO, /* Reset out */
  54. GPIO1_RST | WAKEUP_ON_EDGE_FALL,
  55. GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */
  56. GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */
  57. GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */
  58. GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */
  59. GPIO20_GPIO, /* EAR_IN */
  60. GPIO22_GPIO, /* On */
  61. GPIO5_GPIO, /* USB_IN */
  62. GPIO32_GPIO, /* Pen IRQ */
  63. GPIO7_GPIO, /* Jacket Detect */
  64. GPIO14_GPIO, /* BAT0_CRG */
  65. GPIO12_GPIO, /* BAT1_CRG */
  66. GPIO17_GPIO, /* BAT0_LOW */
  67. GPIO84_GPIO, /* BAT1_LOW */
  68. GPIO38_GPIO, /* BAT_LOCK */
  69. GPIO11_3_6MHz,
  70. GPIO15_GPIO, /* TC6393XB IRQ */
  71. GPIO18_RDY,
  72. GPIO27_GPIO, /* LCD Sync */
  73. /* MMC */
  74. GPIO6_MMC_CLK,
  75. GPIO8_MMC_CS0,
  76. GPIO9_GPIO, /* Detect */
  77. GPIO10_GPIO, /* nSD_INT */
  78. /* CF */
  79. GPIO13_GPIO, /* CD_IRQ */
  80. GPIO21_GPIO, /* Main Slot IRQ */
  81. GPIO36_GPIO, /* Jacket Slot IRQ */
  82. GPIO48_nPOE,
  83. GPIO49_nPWE,
  84. GPIO50_nPIOR,
  85. GPIO51_nPIOW,
  86. GPIO52_nPCE_1,
  87. GPIO53_nPCE_2,
  88. GPIO54_nPSKTSEL,
  89. GPIO55_nPREG,
  90. GPIO56_nPWAIT,
  91. GPIO57_nIOIS16,
  92. /* AC97 */
  93. GPIO31_AC97_SYNC,
  94. GPIO30_AC97_SDATA_OUT,
  95. GPIO28_AC97_BITCLK,
  96. GPIO29_AC97_SDATA_IN_0,
  97. // GPIO79 nAUD_IRQ
  98. /* FFUART */
  99. GPIO34_FFUART_RXD,
  100. GPIO35_FFUART_CTS,
  101. GPIO37_FFUART_DSR,
  102. GPIO39_FFUART_TXD,
  103. GPIO40_FFUART_DTR,
  104. GPIO41_FFUART_RTS,
  105. /* BTUART */
  106. GPIO42_BTUART_RXD,
  107. GPIO43_BTUART_TXD,
  108. GPIO44_BTUART_CTS,
  109. GPIO45_BTUART_RTS,
  110. /* Keybd */
  111. GPIO58_GPIO | MFP_LPM_DRIVE_LOW,
  112. GPIO59_GPIO | MFP_LPM_DRIVE_LOW,
  113. GPIO60_GPIO | MFP_LPM_DRIVE_LOW,
  114. GPIO61_GPIO | MFP_LPM_DRIVE_LOW,
  115. GPIO62_GPIO | MFP_LPM_DRIVE_LOW,
  116. GPIO63_GPIO | MFP_LPM_DRIVE_LOW,
  117. GPIO64_GPIO | MFP_LPM_DRIVE_LOW,
  118. GPIO65_GPIO | MFP_LPM_DRIVE_LOW,
  119. GPIO66_GPIO | MFP_LPM_DRIVE_LOW,
  120. GPIO67_GPIO | MFP_LPM_DRIVE_LOW,
  121. GPIO68_GPIO | MFP_LPM_DRIVE_LOW,
  122. GPIO69_GPIO | MFP_LPM_DRIVE_LOW,
  123. GPIO70_GPIO | MFP_LPM_DRIVE_LOW,
  124. GPIO71_GPIO | MFP_LPM_DRIVE_LOW,
  125. GPIO72_GPIO | MFP_LPM_DRIVE_LOW,
  126. GPIO73_GPIO | MFP_LPM_DRIVE_LOW,
  127. GPIO74_GPIO | MFP_LPM_DRIVE_LOW,
  128. GPIO75_GPIO | MFP_LPM_DRIVE_LOW,
  129. /* SPI */
  130. GPIO81_SSP2_CLK_OUT,
  131. GPIO82_SSP2_FRM_OUT,
  132. GPIO83_SSP2_TXD,
  133. /* IrDA is managed in other way */
  134. GPIO46_GPIO,
  135. GPIO47_GPIO,
  136. };
  137. /*
  138. * SCOOP Device
  139. */
  140. static struct resource tosa_scoop_resources[] = {
  141. [0] = {
  142. .start = TOSA_CF_PHYS,
  143. .end = TOSA_CF_PHYS + 0xfff,
  144. .flags = IORESOURCE_MEM,
  145. },
  146. };
  147. static struct scoop_config tosa_scoop_setup = {
  148. .io_dir = TOSA_SCOOP_IO_DIR,
  149. .gpio_base = TOSA_SCOOP_GPIO_BASE,
  150. };
  151. static struct platform_device tosascoop_device = {
  152. .name = "sharp-scoop",
  153. .id = 0,
  154. .dev = {
  155. .platform_data = &tosa_scoop_setup,
  156. },
  157. .num_resources = ARRAY_SIZE(tosa_scoop_resources),
  158. .resource = tosa_scoop_resources,
  159. };
  160. /*
  161. * SCOOP Device Jacket
  162. */
  163. static struct resource tosa_scoop_jc_resources[] = {
  164. [0] = {
  165. .start = TOSA_SCOOP_PHYS + 0x40,
  166. .end = TOSA_SCOOP_PHYS + 0xfff,
  167. .flags = IORESOURCE_MEM,
  168. },
  169. };
  170. static struct scoop_config tosa_scoop_jc_setup = {
  171. .io_dir = TOSA_SCOOP_JC_IO_DIR,
  172. .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
  173. };
  174. static struct platform_device tosascoop_jc_device = {
  175. .name = "sharp-scoop",
  176. .id = 1,
  177. .dev = {
  178. .platform_data = &tosa_scoop_jc_setup,
  179. .parent = &tosascoop_device.dev,
  180. },
  181. .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
  182. .resource = tosa_scoop_jc_resources,
  183. };
  184. /*
  185. * PCMCIA
  186. */
  187. static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
  188. {
  189. .dev = &tosascoop_device.dev,
  190. .irq = TOSA_IRQ_GPIO_CF_IRQ,
  191. .cd_irq = TOSA_IRQ_GPIO_CF_CD,
  192. .cd_irq_str = "PCMCIA0 CD",
  193. },{
  194. .dev = &tosascoop_jc_device.dev,
  195. .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
  196. .cd_irq = -1,
  197. },
  198. };
  199. static struct scoop_pcmcia_config tosa_pcmcia_config = {
  200. .devs = &tosa_pcmcia_scoop[0],
  201. .num_devs = 2,
  202. };
  203. /*
  204. * USB Device Controller
  205. */
  206. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  207. .gpio_pullup = TOSA_GPIO_USB_PULLUP,
  208. .gpio_vbus = TOSA_GPIO_USB_IN,
  209. .gpio_vbus_inverted = 1,
  210. };
  211. /*
  212. * MMC/SD Device
  213. */
  214. static struct pxamci_platform_data tosa_mci_platform_data;
  215. static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
  216. {
  217. int err;
  218. tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
  219. err = gpio_request(TOSA_GPIO_nSD_DETECT, "MMC/SD card detect");
  220. if (err) {
  221. printk(KERN_ERR "tosa_mci_init: can't request nSD_DETECT gpio\n");
  222. goto err_gpio_detect;
  223. }
  224. err = gpio_direction_input(TOSA_GPIO_nSD_DETECT);
  225. if (err)
  226. goto err_gpio_detect_dir;
  227. err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
  228. IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  229. "MMC/SD card detect", data);
  230. if (err) {
  231. printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
  232. goto err_irq;
  233. }
  234. err = gpio_request(TOSA_GPIO_SD_WP, "SD Write Protect");
  235. if (err) {
  236. printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n");
  237. goto err_gpio_wp;
  238. }
  239. err = gpio_direction_input(TOSA_GPIO_SD_WP);
  240. if (err)
  241. goto err_gpio_wp_dir;
  242. err = gpio_request(TOSA_GPIO_PWR_ON, "SD Power");
  243. if (err) {
  244. printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
  245. goto err_gpio_pwr;
  246. }
  247. err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0);
  248. if (err)
  249. goto err_gpio_pwr_dir;
  250. err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
  251. if (err) {
  252. printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
  253. goto err_gpio_int;
  254. }
  255. err = gpio_direction_input(TOSA_GPIO_nSD_INT);
  256. if (err)
  257. goto err_gpio_int_dir;
  258. return 0;
  259. err_gpio_int_dir:
  260. gpio_free(TOSA_GPIO_nSD_INT);
  261. err_gpio_int:
  262. err_gpio_pwr_dir:
  263. gpio_free(TOSA_GPIO_PWR_ON);
  264. err_gpio_pwr:
  265. err_gpio_wp_dir:
  266. gpio_free(TOSA_GPIO_SD_WP);
  267. err_gpio_wp:
  268. free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
  269. err_irq:
  270. err_gpio_detect_dir:
  271. gpio_free(TOSA_GPIO_nSD_DETECT);
  272. err_gpio_detect:
  273. return err;
  274. }
  275. static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
  276. {
  277. struct pxamci_platform_data* p_d = dev->platform_data;
  278. if (( 1 << vdd) & p_d->ocr_mask) {
  279. gpio_set_value(TOSA_GPIO_PWR_ON, 1);
  280. } else {
  281. gpio_set_value(TOSA_GPIO_PWR_ON, 0);
  282. }
  283. }
  284. static int tosa_mci_get_ro(struct device *dev)
  285. {
  286. return gpio_get_value(TOSA_GPIO_SD_WP);
  287. }
  288. static void tosa_mci_exit(struct device *dev, void *data)
  289. {
  290. gpio_free(TOSA_GPIO_nSD_INT);
  291. gpio_free(TOSA_GPIO_PWR_ON);
  292. gpio_free(TOSA_GPIO_SD_WP);
  293. free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
  294. gpio_free(TOSA_GPIO_nSD_DETECT);
  295. }
  296. static struct pxamci_platform_data tosa_mci_platform_data = {
  297. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  298. .init = tosa_mci_init,
  299. .get_ro = tosa_mci_get_ro,
  300. .setpower = tosa_mci_setpower,
  301. .exit = tosa_mci_exit,
  302. };
  303. /*
  304. * Irda
  305. */
  306. static void tosa_irda_transceiver_mode(struct device *dev, int mode)
  307. {
  308. if (mode & IR_OFF) {
  309. gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
  310. pxa2xx_transceiver_mode(dev, mode);
  311. gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
  312. } else {
  313. pxa2xx_transceiver_mode(dev, mode);
  314. gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
  315. }
  316. }
  317. static int tosa_irda_startup(struct device *dev)
  318. {
  319. int ret;
  320. ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
  321. if (ret)
  322. goto err_tx;
  323. ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
  324. if (ret)
  325. goto err_tx_dir;
  326. ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
  327. if (ret)
  328. goto err_pwr;
  329. ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
  330. if (ret)
  331. goto err_pwr_dir;
  332. tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
  333. return 0;
  334. err_pwr_dir:
  335. gpio_free(TOSA_GPIO_IR_POWERDWN);
  336. err_pwr:
  337. err_tx_dir:
  338. gpio_free(TOSA_GPIO_IRDA_TX);
  339. err_tx:
  340. return ret;
  341. }
  342. static void tosa_irda_shutdown(struct device *dev)
  343. {
  344. tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
  345. gpio_free(TOSA_GPIO_IR_POWERDWN);
  346. gpio_free(TOSA_GPIO_IRDA_TX);
  347. }
  348. static struct pxaficp_platform_data tosa_ficp_platform_data = {
  349. .transceiver_cap = IR_SIRMODE | IR_OFF,
  350. .transceiver_mode = tosa_irda_transceiver_mode,
  351. .startup = tosa_irda_startup,
  352. .shutdown = tosa_irda_shutdown,
  353. };
  354. /*
  355. * Tosa AC IN
  356. */
  357. static int tosa_power_init(struct device *dev)
  358. {
  359. int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
  360. if (ret)
  361. goto err_gpio_req;
  362. ret = gpio_direction_input(TOSA_GPIO_AC_IN);
  363. if (ret)
  364. goto err_gpio_in;
  365. return 0;
  366. err_gpio_in:
  367. gpio_free(TOSA_GPIO_AC_IN);
  368. err_gpio_req:
  369. return ret;
  370. }
  371. static void tosa_power_exit(struct device *dev)
  372. {
  373. gpio_free(TOSA_GPIO_AC_IN);
  374. }
  375. static int tosa_power_ac_online(void)
  376. {
  377. return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
  378. }
  379. static char *tosa_ac_supplied_to[] = {
  380. "main-battery",
  381. "backup-battery",
  382. "jacket-battery",
  383. };
  384. static struct pda_power_pdata tosa_power_data = {
  385. .init = tosa_power_init,
  386. .is_ac_online = tosa_power_ac_online,
  387. .exit = tosa_power_exit,
  388. .supplied_to = tosa_ac_supplied_to,
  389. .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
  390. };
  391. static struct resource tosa_power_resource[] = {
  392. {
  393. .name = "ac",
  394. .start = gpio_to_irq(TOSA_GPIO_AC_IN),
  395. .end = gpio_to_irq(TOSA_GPIO_AC_IN),
  396. .flags = IORESOURCE_IRQ |
  397. IORESOURCE_IRQ_HIGHEDGE |
  398. IORESOURCE_IRQ_LOWEDGE,
  399. },
  400. };
  401. static struct platform_device tosa_power_device = {
  402. .name = "pda-power",
  403. .id = -1,
  404. .dev.platform_data = &tosa_power_data,
  405. .resource = tosa_power_resource,
  406. .num_resources = ARRAY_SIZE(tosa_power_resource),
  407. };
  408. /*
  409. * Tosa Keyboard
  410. */
  411. static struct platform_device tosakbd_device = {
  412. .name = "tosa-keyboard",
  413. .id = -1,
  414. };
  415. static struct gpio_keys_button tosa_gpio_keys[] = {
  416. /*
  417. * Two following keys are directly tied to "ON" button of tosa. Why?
  418. * The first one can be used as a wakeup source, the second can't;
  419. * also the first one is OR of ac_powered and on_button.
  420. */
  421. {
  422. .type = EV_PWR,
  423. .code = KEY_RESERVED,
  424. .gpio = TOSA_GPIO_POWERON,
  425. .desc = "Poweron",
  426. .wakeup = 1,
  427. .active_low = 1,
  428. },
  429. {
  430. .type = EV_PWR,
  431. .code = KEY_SUSPEND,
  432. .gpio = TOSA_GPIO_ON_KEY,
  433. .desc = "On key",
  434. /*
  435. * can't be used as wakeup
  436. * .wakeup = 1,
  437. */
  438. .active_low = 1,
  439. },
  440. {
  441. .type = EV_KEY,
  442. .code = TOSA_KEY_RECORD,
  443. .gpio = TOSA_GPIO_RECORD_BTN,
  444. .desc = "Record Button",
  445. .wakeup = 1,
  446. .active_low = 1,
  447. },
  448. {
  449. .type = EV_KEY,
  450. .code = TOSA_KEY_SYNC,
  451. .gpio = TOSA_GPIO_SYNC,
  452. .desc = "Sync Button",
  453. .wakeup = 1,
  454. .active_low = 1,
  455. },
  456. };
  457. static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
  458. .buttons = tosa_gpio_keys,
  459. .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
  460. };
  461. static struct platform_device tosa_gpio_keys_device = {
  462. .name = "gpio-keys",
  463. .id = -1,
  464. .dev = {
  465. .platform_data = &tosa_gpio_keys_platform_data,
  466. },
  467. };
  468. /*
  469. * Tosa LEDs
  470. */
  471. static struct gpio_led tosa_gpio_leds[] = {
  472. {
  473. .name = "tosa:amber:charge",
  474. .default_trigger = "main-battery-charging",
  475. .gpio = TOSA_GPIO_CHRG_ERR_LED,
  476. },
  477. {
  478. .name = "tosa:green:mail",
  479. .default_trigger = "nand-disk",
  480. .gpio = TOSA_GPIO_NOTE_LED,
  481. },
  482. {
  483. .name = "tosa:dual:wlan",
  484. .default_trigger = "none",
  485. .gpio = TOSA_GPIO_WLAN_LED,
  486. },
  487. {
  488. .name = "tosa:blue:bluetooth",
  489. .default_trigger = "tosa-bt",
  490. .gpio = TOSA_GPIO_BT_LED,
  491. },
  492. };
  493. static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
  494. .leds = tosa_gpio_leds,
  495. .num_leds = ARRAY_SIZE(tosa_gpio_leds),
  496. };
  497. static struct platform_device tosaled_device = {
  498. .name = "leds-gpio",
  499. .id = -1,
  500. .dev = {
  501. .platform_data = &tosa_gpio_leds_platform_data,
  502. },
  503. };
  504. /*
  505. * Toshiba Mobile IO Controller
  506. */
  507. static struct resource tc6393xb_resources[] = {
  508. [0] = {
  509. .start = TOSA_LCDC_PHYS,
  510. .end = TOSA_LCDC_PHYS + 0x3ffffff,
  511. .flags = IORESOURCE_MEM,
  512. },
  513. [1] = {
  514. .start = TOSA_IRQ_GPIO_TC6393XB_INT,
  515. .end = TOSA_IRQ_GPIO_TC6393XB_INT,
  516. .flags = IORESOURCE_IRQ,
  517. },
  518. };
  519. static int tosa_tc6393xb_enable(struct platform_device *dev)
  520. {
  521. int rc;
  522. rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
  523. if (rc)
  524. goto err_req_pclr;
  525. rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
  526. if (rc)
  527. goto err_req_suspend;
  528. rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "l3v");
  529. if (rc)
  530. goto err_req_l3v;
  531. rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
  532. if (rc)
  533. goto err_dir_l3v;
  534. rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
  535. if (rc)
  536. goto err_dir_suspend;
  537. rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
  538. if (rc)
  539. goto err_dir_pclr;
  540. mdelay(1);
  541. gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
  542. mdelay(10);
  543. gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
  544. gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
  545. return 0;
  546. err_dir_pclr:
  547. err_dir_suspend:
  548. err_dir_l3v:
  549. gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
  550. err_req_l3v:
  551. gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
  552. err_req_suspend:
  553. gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
  554. err_req_pclr:
  555. return rc;
  556. }
  557. static int tosa_tc6393xb_disable(struct platform_device *dev)
  558. {
  559. gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
  560. gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
  561. gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
  562. return 0;
  563. }
  564. static int tosa_tc6393xb_resume(struct platform_device *dev)
  565. {
  566. gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
  567. mdelay(10);
  568. gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
  569. mdelay(10);
  570. return 0;
  571. }
  572. static int tosa_tc6393xb_suspend(struct platform_device *dev)
  573. {
  574. gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
  575. gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
  576. return 0;
  577. }
  578. static struct mtd_partition tosa_nand_partition[] = {
  579. {
  580. .name = "smf",
  581. .offset = 0,
  582. .size = 7 * 1024 * 1024,
  583. },
  584. {
  585. .name = "root",
  586. .offset = MTDPART_OFS_APPEND,
  587. .size = 28 * 1024 * 1024,
  588. },
  589. {
  590. .name = "home",
  591. .offset = MTDPART_OFS_APPEND,
  592. .size = MTDPART_SIZ_FULL,
  593. },
  594. };
  595. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  596. static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = {
  597. .options = 0,
  598. .offs = 4,
  599. .len = 2,
  600. .pattern = scan_ff_pattern
  601. };
  602. static struct tmio_nand_data tosa_tc6393xb_nand_config = {
  603. .num_partitions = ARRAY_SIZE(tosa_nand_partition),
  604. .partition = tosa_nand_partition,
  605. .badblock_pattern = &tosa_tc6393xb_nand_bbt,
  606. };
  607. static struct tc6393xb_platform_data tosa_tc6393xb_setup = {
  608. .scr_pll2cr = 0x0cc1,
  609. .scr_gper = 0x3300,
  610. .scr_gpo_dsr =
  611. TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
  612. .scr_gpo_doecr =
  613. TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
  614. .irq_base = IRQ_BOARD_START,
  615. .gpio_base = TOSA_TC6393XB_GPIO_BASE,
  616. .enable = tosa_tc6393xb_enable,
  617. .disable = tosa_tc6393xb_disable,
  618. .suspend = tosa_tc6393xb_suspend,
  619. .resume = tosa_tc6393xb_resume,
  620. .nand_data = &tosa_tc6393xb_nand_config,
  621. };
  622. static struct platform_device tc6393xb_device = {
  623. .name = "tc6393xb",
  624. .id = -1,
  625. .dev = {
  626. .platform_data = &tosa_tc6393xb_setup,
  627. },
  628. .num_resources = ARRAY_SIZE(tc6393xb_resources),
  629. .resource = tc6393xb_resources,
  630. };
  631. static struct tosa_bt_data tosa_bt_data = {
  632. .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
  633. .gpio_reset = TOSA_GPIO_BT_RESET,
  634. };
  635. static struct platform_device tosa_bt_device = {
  636. .name = "tosa-bt",
  637. .id = -1,
  638. .dev.platform_data = &tosa_bt_data,
  639. };
  640. static struct platform_device *devices[] __initdata = {
  641. &tosascoop_device,
  642. &tosascoop_jc_device,
  643. &tc6393xb_device,
  644. &tosa_power_device,
  645. &tosakbd_device,
  646. &tosa_gpio_keys_device,
  647. &tosaled_device,
  648. &tosa_bt_device,
  649. };
  650. static void tosa_poweroff(void)
  651. {
  652. arm_machine_restart('g');
  653. }
  654. static void tosa_restart(char mode)
  655. {
  656. /* Bootloader magic for a reboot */
  657. if((MSC0 & 0xffff0000) == 0x7ff00000)
  658. MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
  659. tosa_poweroff();
  660. }
  661. static void __init tosa_init(void)
  662. {
  663. int dummy;
  664. pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
  665. gpio_set_wake(MFP_PIN_GPIO1, 1);
  666. /* We can't pass to gpio-keys since it will drop the Reset altfunc */
  667. init_gpio_reset(TOSA_GPIO_ON_RESET);
  668. pm_power_off = tosa_poweroff;
  669. arm_pm_restart = tosa_restart;
  670. PCFR |= PCFR_OPDE;
  671. /* enable batt_fault */
  672. PMCR = 0x01;
  673. dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
  674. dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
  675. dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
  676. pxa_set_mci_info(&tosa_mci_platform_data);
  677. pxa_set_udc_info(&udc_info);
  678. pxa_set_ficp_info(&tosa_ficp_platform_data);
  679. pxa_set_i2c_info(NULL);
  680. platform_scoop_config = &tosa_pcmcia_config;
  681. platform_add_devices(devices, ARRAY_SIZE(devices));
  682. }
  683. static void __init fixup_tosa(struct machine_desc *desc,
  684. struct tag *tags, char **cmdline, struct meminfo *mi)
  685. {
  686. sharpsl_save_param();
  687. mi->nr_banks=1;
  688. mi->bank[0].start = 0xa0000000;
  689. mi->bank[0].node = 0;
  690. mi->bank[0].size = (64*1024*1024);
  691. }
  692. MACHINE_START(TOSA, "SHARP Tosa")
  693. .phys_io = 0x40000000,
  694. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  695. .fixup = fixup_tosa,
  696. .map_io = pxa_map_io,
  697. .init_irq = pxa25x_init_irq,
  698. .init_machine = tosa_init,
  699. .timer = &pxa_timer,
  700. MACHINE_END