tosa.c 20 KB

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