tosa.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  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/spi/spi.h>
  34. #include <asm/setup.h>
  35. #include <asm/mach-types.h>
  36. #include <mach/pxa25x.h>
  37. #include <mach/reset.h>
  38. #include <mach/irda.h>
  39. #include <plat/i2c.h>
  40. #include <mach/mmc.h>
  41. #include <mach/udc.h>
  42. #include <mach/tosa_bt.h>
  43. #include <mach/pxa2xx_spi.h>
  44. #include <mach/audio.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 int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
  219. {
  220. int err;
  221. err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
  222. if (err) {
  223. printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
  224. goto err_gpio_int;
  225. }
  226. err = gpio_direction_input(TOSA_GPIO_nSD_INT);
  227. if (err)
  228. goto err_gpio_int_dir;
  229. return 0;
  230. err_gpio_int_dir:
  231. gpio_free(TOSA_GPIO_nSD_INT);
  232. err_gpio_int:
  233. return err;
  234. }
  235. static void tosa_mci_exit(struct device *dev, void *data)
  236. {
  237. gpio_free(TOSA_GPIO_nSD_INT);
  238. }
  239. static struct pxamci_platform_data tosa_mci_platform_data = {
  240. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  241. .init = tosa_mci_init,
  242. .exit = tosa_mci_exit,
  243. .gpio_card_detect = TOSA_GPIO_nSD_DETECT,
  244. .gpio_card_ro = TOSA_GPIO_SD_WP,
  245. .gpio_power = TOSA_GPIO_PWR_ON,
  246. };
  247. /*
  248. * Irda
  249. */
  250. static void tosa_irda_transceiver_mode(struct device *dev, int mode)
  251. {
  252. if (mode & IR_OFF) {
  253. gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
  254. pxa2xx_transceiver_mode(dev, mode);
  255. gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
  256. } else {
  257. pxa2xx_transceiver_mode(dev, mode);
  258. gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
  259. }
  260. }
  261. static int tosa_irda_startup(struct device *dev)
  262. {
  263. int ret;
  264. ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
  265. if (ret)
  266. goto err_tx;
  267. ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
  268. if (ret)
  269. goto err_tx_dir;
  270. ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
  271. if (ret)
  272. goto err_pwr;
  273. ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
  274. if (ret)
  275. goto err_pwr_dir;
  276. tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
  277. return 0;
  278. err_pwr_dir:
  279. gpio_free(TOSA_GPIO_IR_POWERDWN);
  280. err_pwr:
  281. err_tx_dir:
  282. gpio_free(TOSA_GPIO_IRDA_TX);
  283. err_tx:
  284. return ret;
  285. }
  286. static void tosa_irda_shutdown(struct device *dev)
  287. {
  288. tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
  289. gpio_free(TOSA_GPIO_IR_POWERDWN);
  290. gpio_free(TOSA_GPIO_IRDA_TX);
  291. }
  292. static struct pxaficp_platform_data tosa_ficp_platform_data = {
  293. .gpio_pwdown = -1,
  294. .transceiver_cap = IR_SIRMODE | IR_OFF,
  295. .transceiver_mode = tosa_irda_transceiver_mode,
  296. .startup = tosa_irda_startup,
  297. .shutdown = tosa_irda_shutdown,
  298. };
  299. /*
  300. * Tosa AC IN
  301. */
  302. static int tosa_power_init(struct device *dev)
  303. {
  304. int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
  305. if (ret)
  306. goto err_gpio_req;
  307. ret = gpio_direction_input(TOSA_GPIO_AC_IN);
  308. if (ret)
  309. goto err_gpio_in;
  310. return 0;
  311. err_gpio_in:
  312. gpio_free(TOSA_GPIO_AC_IN);
  313. err_gpio_req:
  314. return ret;
  315. }
  316. static void tosa_power_exit(struct device *dev)
  317. {
  318. gpio_free(TOSA_GPIO_AC_IN);
  319. }
  320. static int tosa_power_ac_online(void)
  321. {
  322. return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
  323. }
  324. static char *tosa_ac_supplied_to[] = {
  325. "main-battery",
  326. "backup-battery",
  327. "jacket-battery",
  328. };
  329. static struct pda_power_pdata tosa_power_data = {
  330. .init = tosa_power_init,
  331. .is_ac_online = tosa_power_ac_online,
  332. .exit = tosa_power_exit,
  333. .supplied_to = tosa_ac_supplied_to,
  334. .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
  335. };
  336. static struct resource tosa_power_resource[] = {
  337. {
  338. .name = "ac",
  339. .start = gpio_to_irq(TOSA_GPIO_AC_IN),
  340. .end = gpio_to_irq(TOSA_GPIO_AC_IN),
  341. .flags = IORESOURCE_IRQ |
  342. IORESOURCE_IRQ_HIGHEDGE |
  343. IORESOURCE_IRQ_LOWEDGE,
  344. },
  345. };
  346. static struct platform_device tosa_power_device = {
  347. .name = "pda-power",
  348. .id = -1,
  349. .dev.platform_data = &tosa_power_data,
  350. .resource = tosa_power_resource,
  351. .num_resources = ARRAY_SIZE(tosa_power_resource),
  352. };
  353. /*
  354. * Tosa Keyboard
  355. */
  356. static struct platform_device tosakbd_device = {
  357. .name = "tosa-keyboard",
  358. .id = -1,
  359. };
  360. static struct gpio_keys_button tosa_gpio_keys[] = {
  361. /*
  362. * Two following keys are directly tied to "ON" button of tosa. Why?
  363. * The first one can be used as a wakeup source, the second can't;
  364. * also the first one is OR of ac_powered and on_button.
  365. */
  366. {
  367. .type = EV_PWR,
  368. .code = KEY_RESERVED,
  369. .gpio = TOSA_GPIO_POWERON,
  370. .desc = "Poweron",
  371. .wakeup = 1,
  372. .active_low = 1,
  373. },
  374. {
  375. .type = EV_PWR,
  376. .code = KEY_SUSPEND,
  377. .gpio = TOSA_GPIO_ON_KEY,
  378. .desc = "On key",
  379. /*
  380. * can't be used as wakeup
  381. * .wakeup = 1,
  382. */
  383. .active_low = 1,
  384. },
  385. {
  386. .type = EV_KEY,
  387. .code = TOSA_KEY_RECORD,
  388. .gpio = TOSA_GPIO_RECORD_BTN,
  389. .desc = "Record Button",
  390. .wakeup = 1,
  391. .active_low = 1,
  392. },
  393. {
  394. .type = EV_KEY,
  395. .code = TOSA_KEY_SYNC,
  396. .gpio = TOSA_GPIO_SYNC,
  397. .desc = "Sync Button",
  398. .wakeup = 1,
  399. .active_low = 1,
  400. },
  401. {
  402. .type = EV_SW,
  403. .code = SW_HEADPHONE_INSERT,
  404. .gpio = TOSA_GPIO_EAR_IN,
  405. .desc = "HeadPhone insert",
  406. .active_low = 1,
  407. .debounce_interval = 300,
  408. },
  409. };
  410. static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
  411. .buttons = tosa_gpio_keys,
  412. .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
  413. };
  414. static struct platform_device tosa_gpio_keys_device = {
  415. .name = "gpio-keys",
  416. .id = -1,
  417. .dev = {
  418. .platform_data = &tosa_gpio_keys_platform_data,
  419. },
  420. };
  421. /*
  422. * Tosa LEDs
  423. */
  424. static struct gpio_led tosa_gpio_leds[] = {
  425. {
  426. .name = "tosa:amber:charge",
  427. .default_trigger = "main-battery-charging",
  428. .gpio = TOSA_GPIO_CHRG_ERR_LED,
  429. },
  430. {
  431. .name = "tosa:green:mail",
  432. .default_trigger = "nand-disk",
  433. .gpio = TOSA_GPIO_NOTE_LED,
  434. },
  435. {
  436. .name = "tosa:dual:wlan",
  437. .default_trigger = "none",
  438. .gpio = TOSA_GPIO_WLAN_LED,
  439. },
  440. {
  441. .name = "tosa:blue:bluetooth",
  442. .default_trigger = "tosa-bt",
  443. .gpio = TOSA_GPIO_BT_LED,
  444. },
  445. };
  446. static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
  447. .leds = tosa_gpio_leds,
  448. .num_leds = ARRAY_SIZE(tosa_gpio_leds),
  449. };
  450. static struct platform_device tosaled_device = {
  451. .name = "leds-gpio",
  452. .id = -1,
  453. .dev = {
  454. .platform_data = &tosa_gpio_leds_platform_data,
  455. },
  456. };
  457. /*
  458. * Toshiba Mobile IO Controller
  459. */
  460. static struct resource tc6393xb_resources[] = {
  461. [0] = {
  462. .start = TOSA_LCDC_PHYS,
  463. .end = TOSA_LCDC_PHYS + 0x3ffffff,
  464. .flags = IORESOURCE_MEM,
  465. },
  466. [1] = {
  467. .start = TOSA_IRQ_GPIO_TC6393XB_INT,
  468. .end = TOSA_IRQ_GPIO_TC6393XB_INT,
  469. .flags = IORESOURCE_IRQ,
  470. },
  471. };
  472. static int tosa_tc6393xb_enable(struct platform_device *dev)
  473. {
  474. int rc;
  475. rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
  476. if (rc)
  477. goto err_req_pclr;
  478. rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
  479. if (rc)
  480. goto err_req_suspend;
  481. rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "tc6393xb l3v");
  482. if (rc)
  483. goto err_req_l3v;
  484. rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
  485. if (rc)
  486. goto err_dir_l3v;
  487. rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
  488. if (rc)
  489. goto err_dir_suspend;
  490. rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
  491. if (rc)
  492. goto err_dir_pclr;
  493. mdelay(1);
  494. gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
  495. mdelay(10);
  496. gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
  497. gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
  498. return 0;
  499. err_dir_pclr:
  500. err_dir_suspend:
  501. err_dir_l3v:
  502. gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
  503. err_req_l3v:
  504. gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
  505. err_req_suspend:
  506. gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
  507. err_req_pclr:
  508. return rc;
  509. }
  510. static int tosa_tc6393xb_disable(struct platform_device *dev)
  511. {
  512. gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
  513. gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
  514. gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
  515. return 0;
  516. }
  517. static int tosa_tc6393xb_resume(struct platform_device *dev)
  518. {
  519. gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
  520. mdelay(10);
  521. gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
  522. mdelay(10);
  523. return 0;
  524. }
  525. static int tosa_tc6393xb_suspend(struct platform_device *dev)
  526. {
  527. gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
  528. gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
  529. return 0;
  530. }
  531. static struct mtd_partition tosa_nand_partition[] = {
  532. {
  533. .name = "smf",
  534. .offset = 0,
  535. .size = 7 * 1024 * 1024,
  536. },
  537. {
  538. .name = "root",
  539. .offset = MTDPART_OFS_APPEND,
  540. .size = 28 * 1024 * 1024,
  541. },
  542. {
  543. .name = "home",
  544. .offset = MTDPART_OFS_APPEND,
  545. .size = MTDPART_SIZ_FULL,
  546. },
  547. };
  548. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  549. static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = {
  550. .options = 0,
  551. .offs = 4,
  552. .len = 2,
  553. .pattern = scan_ff_pattern
  554. };
  555. static struct tmio_nand_data tosa_tc6393xb_nand_config = {
  556. .num_partitions = ARRAY_SIZE(tosa_nand_partition),
  557. .partition = tosa_nand_partition,
  558. .badblock_pattern = &tosa_tc6393xb_nand_bbt,
  559. };
  560. static int tosa_tc6393xb_setup(struct platform_device *dev)
  561. {
  562. int rc;
  563. rc = gpio_request(TOSA_GPIO_CARD_VCC_ON, "CARD_VCC_ON");
  564. if (rc)
  565. goto err_req;
  566. rc = gpio_direction_output(TOSA_GPIO_CARD_VCC_ON, 1);
  567. if (rc)
  568. goto err_dir;
  569. return rc;
  570. err_dir:
  571. gpio_free(TOSA_GPIO_CARD_VCC_ON);
  572. err_req:
  573. return rc;
  574. }
  575. static void tosa_tc6393xb_teardown(struct platform_device *dev)
  576. {
  577. gpio_free(TOSA_GPIO_CARD_VCC_ON);
  578. }
  579. #ifdef CONFIG_MFD_TC6393XB
  580. static struct fb_videomode tosa_tc6393xb_lcd_mode[] = {
  581. {
  582. .xres = 480,
  583. .yres = 640,
  584. .pixclock = 0x002cdf00,/* PLL divisor */
  585. .left_margin = 0x004c,
  586. .right_margin = 0x005b,
  587. .upper_margin = 0x0001,
  588. .lower_margin = 0x000d,
  589. .hsync_len = 0x0002,
  590. .vsync_len = 0x0001,
  591. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  592. .vmode = FB_VMODE_NONINTERLACED,
  593. },{
  594. .xres = 240,
  595. .yres = 320,
  596. .pixclock = 0x00e7f203,/* PLL divisor */
  597. .left_margin = 0x0024,
  598. .right_margin = 0x002f,
  599. .upper_margin = 0x0001,
  600. .lower_margin = 0x000d,
  601. .hsync_len = 0x0002,
  602. .vsync_len = 0x0001,
  603. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  604. .vmode = FB_VMODE_NONINTERLACED,
  605. }
  606. };
  607. static struct tmio_fb_data tosa_tc6393xb_fb_config = {
  608. .lcd_set_power = tc6393xb_lcd_set_power,
  609. .lcd_mode = tc6393xb_lcd_mode,
  610. .num_modes = ARRAY_SIZE(tosa_tc6393xb_lcd_mode),
  611. .modes = &tosa_tc6393xb_lcd_mode[0],
  612. .height = 82,
  613. .width = 60,
  614. };
  615. #endif
  616. static struct tc6393xb_platform_data tosa_tc6393xb_data = {
  617. .scr_pll2cr = 0x0cc1,
  618. .scr_gper = 0x3300,
  619. .irq_base = IRQ_BOARD_START,
  620. .gpio_base = TOSA_TC6393XB_GPIO_BASE,
  621. .setup = tosa_tc6393xb_setup,
  622. .teardown = tosa_tc6393xb_teardown,
  623. .enable = tosa_tc6393xb_enable,
  624. .disable = tosa_tc6393xb_disable,
  625. .suspend = tosa_tc6393xb_suspend,
  626. .resume = tosa_tc6393xb_resume,
  627. .nand_data = &tosa_tc6393xb_nand_config,
  628. #ifdef CONFIG_MFD_TC6393XB
  629. .fb_data = &tosa_tc6393xb_fb_config,
  630. #endif
  631. .resume_restore = 1,
  632. };
  633. static struct platform_device tc6393xb_device = {
  634. .name = "tc6393xb",
  635. .id = -1,
  636. .dev = {
  637. .platform_data = &tosa_tc6393xb_data,
  638. },
  639. .num_resources = ARRAY_SIZE(tc6393xb_resources),
  640. .resource = tc6393xb_resources,
  641. };
  642. static struct tosa_bt_data tosa_bt_data = {
  643. .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
  644. .gpio_reset = TOSA_GPIO_BT_RESET,
  645. };
  646. static struct platform_device tosa_bt_device = {
  647. .name = "tosa-bt",
  648. .id = -1,
  649. .dev.platform_data = &tosa_bt_data,
  650. };
  651. static struct pxa2xx_spi_master pxa_ssp_master_info = {
  652. .num_chipselect = 1,
  653. };
  654. static struct spi_board_info spi_board_info[] __initdata = {
  655. {
  656. .modalias = "tosa-lcd",
  657. // .platform_data
  658. .max_speed_hz = 28750,
  659. .bus_num = 2,
  660. .chip_select = 0,
  661. .mode = SPI_MODE_0,
  662. },
  663. };
  664. static struct mtd_partition sharpsl_rom_parts[] = {
  665. {
  666. .name ="Boot PROM Filesystem",
  667. .offset = 0x00160000,
  668. .size = MTDPART_SIZ_FULL,
  669. },
  670. };
  671. static struct physmap_flash_data sharpsl_rom_data = {
  672. .width = 2,
  673. .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
  674. .parts = sharpsl_rom_parts,
  675. };
  676. static struct resource sharpsl_rom_resources[] = {
  677. {
  678. .start = 0x00000000,
  679. .end = 0x007fffff,
  680. .flags = IORESOURCE_MEM,
  681. },
  682. };
  683. static struct platform_device sharpsl_rom_device = {
  684. .name = "physmap-flash",
  685. .id = -1,
  686. .resource = sharpsl_rom_resources,
  687. .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
  688. .dev.platform_data = &sharpsl_rom_data,
  689. };
  690. static struct platform_device *devices[] __initdata = {
  691. &tosascoop_device,
  692. &tosascoop_jc_device,
  693. &tc6393xb_device,
  694. &tosa_power_device,
  695. &tosakbd_device,
  696. &tosa_gpio_keys_device,
  697. &tosaled_device,
  698. &tosa_bt_device,
  699. &sharpsl_rom_device,
  700. };
  701. static void tosa_poweroff(void)
  702. {
  703. arm_machine_restart('g', NULL);
  704. }
  705. static void tosa_restart(char mode, const char *cmd)
  706. {
  707. /* Bootloader magic for a reboot */
  708. if((MSC0 & 0xffff0000) == 0x7ff00000)
  709. MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
  710. tosa_poweroff();
  711. }
  712. static void __init tosa_init(void)
  713. {
  714. int dummy;
  715. pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
  716. gpio_set_wake(MFP_PIN_GPIO1, 1);
  717. /* We can't pass to gpio-keys since it will drop the Reset altfunc */
  718. init_gpio_reset(TOSA_GPIO_ON_RESET, 0, 0);
  719. pm_power_off = tosa_poweroff;
  720. arm_pm_restart = tosa_restart;
  721. PCFR |= PCFR_OPDE;
  722. /* enable batt_fault */
  723. PMCR = 0x01;
  724. dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
  725. dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
  726. dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
  727. tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
  728. pxa_set_mci_info(&tosa_mci_platform_data);
  729. pxa_set_udc_info(&udc_info);
  730. pxa_set_ficp_info(&tosa_ficp_platform_data);
  731. pxa_set_i2c_info(NULL);
  732. pxa_set_ac97_info(NULL);
  733. platform_scoop_config = &tosa_pcmcia_config;
  734. pxa2xx_set_spi_info(2, &pxa_ssp_master_info);
  735. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  736. clk_add_alias("CLK_CK3P6MI", tc6393xb_device.name, "GPIO11_CLK", NULL);
  737. platform_add_devices(devices, ARRAY_SIZE(devices));
  738. }
  739. static void __init fixup_tosa(struct machine_desc *desc,
  740. struct tag *tags, char **cmdline, struct meminfo *mi)
  741. {
  742. sharpsl_save_param();
  743. mi->nr_banks=1;
  744. mi->bank[0].start = 0xa0000000;
  745. mi->bank[0].node = 0;
  746. mi->bank[0].size = (64*1024*1024);
  747. }
  748. MACHINE_START(TOSA, "SHARP Tosa")
  749. .phys_io = 0x40000000,
  750. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  751. .fixup = fixup_tosa,
  752. .map_io = pxa_map_io,
  753. .init_irq = pxa25x_init_irq,
  754. .init_machine = tosa_init,
  755. .timer = &pxa_timer,
  756. MACHINE_END