tosa.c 18 KB

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