tosa.c 19 KB

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