tosa.c 18 KB

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