poodle.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. /*
  2. * linux/arch/arm/mach-pxa/poodle.c
  3. *
  4. * Support for the SHARP Poodle Board.
  5. *
  6. * Based on:
  7. * linux/arch/arm/mach-pxa/lubbock.c Author: Nicolas Pitre
  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. * Change Log
  14. * 12-Dec-2002 Sharp Corporation for Poodle
  15. * John Lenz <lenz@cs.wisc.edu> updates to 2.6
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/fb.h>
  21. #include <linux/pm.h>
  22. #include <linux/delay.h>
  23. #include <linux/mtd/physmap.h>
  24. #include <linux/gpio.h>
  25. #include <linux/i2c.h>
  26. #include <linux/spi/spi.h>
  27. #include <linux/spi/ads7846.h>
  28. #include <linux/mtd/sharpsl.h>
  29. #include <mach/hardware.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/irq.h>
  32. #include <asm/setup.h>
  33. #include <asm/system.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include <asm/mach/irq.h>
  37. #include <mach/pxa25x.h>
  38. #include <mach/mmc.h>
  39. #include <mach/udc.h>
  40. #include <plat/i2c.h>
  41. #include <mach/irda.h>
  42. #include <mach/poodle.h>
  43. #include <mach/pxafb.h>
  44. #include <mach/sharpsl.h>
  45. #include <mach/ssp.h>
  46. #include <mach/pxa2xx_spi.h>
  47. #include <asm/hardware/scoop.h>
  48. #include <asm/hardware/locomo.h>
  49. #include <asm/mach/sharpsl_param.h>
  50. #include "generic.h"
  51. #include "devices.h"
  52. #include "sharpsl.h"
  53. static unsigned long poodle_pin_config[] __initdata = {
  54. /* I/O */
  55. GPIO79_nCS_3,
  56. GPIO80_nCS_4,
  57. GPIO18_RDY,
  58. /* Clock */
  59. GPIO12_32KHz,
  60. /* SSP1 */
  61. GPIO23_SSP1_SCLK,
  62. GPIO25_SSP1_TXD,
  63. GPIO26_SSP1_RXD,
  64. GPIO24_GPIO, /* POODLE_GPIO_TP_CS - SFRM as chip select */
  65. /* I2S */
  66. GPIO28_I2S_BITCLK_OUT,
  67. GPIO29_I2S_SDATA_IN,
  68. GPIO30_I2S_SDATA_OUT,
  69. GPIO31_I2S_SYNC,
  70. GPIO32_I2S_SYSCLK,
  71. /* Infra-Red */
  72. GPIO47_FICP_TXD,
  73. GPIO46_FICP_RXD,
  74. /* FFUART */
  75. GPIO40_FFUART_DTR,
  76. GPIO41_FFUART_RTS,
  77. GPIO39_FFUART_TXD,
  78. GPIO37_FFUART_DSR,
  79. GPIO34_FFUART_RXD,
  80. GPIO35_FFUART_CTS,
  81. /* LCD */
  82. GPIO58_LCD_LDD_0,
  83. GPIO59_LCD_LDD_1,
  84. GPIO60_LCD_LDD_2,
  85. GPIO61_LCD_LDD_3,
  86. GPIO62_LCD_LDD_4,
  87. GPIO63_LCD_LDD_5,
  88. GPIO64_LCD_LDD_6,
  89. GPIO65_LCD_LDD_7,
  90. GPIO66_LCD_LDD_8,
  91. GPIO67_LCD_LDD_9,
  92. GPIO68_LCD_LDD_10,
  93. GPIO69_LCD_LDD_11,
  94. GPIO70_LCD_LDD_12,
  95. GPIO71_LCD_LDD_13,
  96. GPIO72_LCD_LDD_14,
  97. GPIO73_LCD_LDD_15,
  98. GPIO74_LCD_FCLK,
  99. GPIO75_LCD_LCLK,
  100. GPIO76_LCD_PCLK,
  101. GPIO77_LCD_BIAS,
  102. /* PC Card */
  103. GPIO48_nPOE,
  104. GPIO49_nPWE,
  105. GPIO50_nPIOR,
  106. GPIO51_nPIOW,
  107. GPIO52_nPCE_1,
  108. GPIO53_nPCE_2,
  109. GPIO54_nPSKTSEL,
  110. GPIO55_nPREG,
  111. GPIO56_nPWAIT,
  112. GPIO57_nIOIS16,
  113. /* MMC */
  114. GPIO6_MMC_CLK,
  115. GPIO8_MMC_CS0,
  116. /* GPIO */
  117. GPIO9_GPIO, /* POODLE_GPIO_nSD_DETECT */
  118. GPIO7_GPIO, /* POODLE_GPIO_nSD_WP */
  119. GPIO3_GPIO, /* POODLE_GPIO_SD_PWR */
  120. GPIO33_GPIO, /* POODLE_GPIO_SD_PWR1 */
  121. GPIO20_GPIO, /* POODLE_GPIO_USB_PULLUP */
  122. GPIO22_GPIO, /* POODLE_GPIO_IR_ON */
  123. };
  124. static struct resource poodle_scoop_resources[] = {
  125. [0] = {
  126. .start = 0x10800000,
  127. .end = 0x10800fff,
  128. .flags = IORESOURCE_MEM,
  129. },
  130. };
  131. static struct scoop_config poodle_scoop_setup = {
  132. .io_dir = POODLE_SCOOP_IO_DIR,
  133. .io_out = POODLE_SCOOP_IO_OUT,
  134. .gpio_base = POODLE_SCOOP_GPIO_BASE,
  135. };
  136. struct platform_device poodle_scoop_device = {
  137. .name = "sharp-scoop",
  138. .id = -1,
  139. .dev = {
  140. .platform_data = &poodle_scoop_setup,
  141. },
  142. .num_resources = ARRAY_SIZE(poodle_scoop_resources),
  143. .resource = poodle_scoop_resources,
  144. };
  145. static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
  146. {
  147. .dev = &poodle_scoop_device.dev,
  148. .irq = POODLE_IRQ_GPIO_CF_IRQ,
  149. .cd_irq = POODLE_IRQ_GPIO_CF_CD,
  150. .cd_irq_str = "PCMCIA0 CD",
  151. },
  152. };
  153. static struct scoop_pcmcia_config poodle_pcmcia_config = {
  154. .devs = &poodle_pcmcia_scoop[0],
  155. .num_devs = 1,
  156. };
  157. EXPORT_SYMBOL(poodle_scoop_device);
  158. /* LoCoMo device */
  159. static struct resource locomo_resources[] = {
  160. [0] = {
  161. .start = 0x10000000,
  162. .end = 0x10001fff,
  163. .flags = IORESOURCE_MEM,
  164. },
  165. [1] = {
  166. .start = IRQ_GPIO(10),
  167. .end = IRQ_GPIO(10),
  168. .flags = IORESOURCE_IRQ,
  169. },
  170. };
  171. struct platform_device poodle_locomo_device = {
  172. .name = "locomo",
  173. .id = 0,
  174. .num_resources = ARRAY_SIZE(locomo_resources),
  175. .resource = locomo_resources,
  176. };
  177. EXPORT_SYMBOL(poodle_locomo_device);
  178. #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
  179. static struct pxa2xx_spi_master poodle_spi_info = {
  180. .num_chipselect = 1,
  181. };
  182. static struct ads7846_platform_data poodle_ads7846_info = {
  183. .model = 7846,
  184. .vref_delay_usecs = 100,
  185. .x_plate_ohms = 419,
  186. .y_plate_ohms = 486,
  187. .gpio_pendown = POODLE_GPIO_TP_INT,
  188. };
  189. static struct pxa2xx_spi_chip poodle_ads7846_chip = {
  190. .gpio_cs = POODLE_GPIO_TP_CS,
  191. };
  192. static struct spi_board_info poodle_spi_devices[] = {
  193. {
  194. .modalias = "ads7846",
  195. .max_speed_hz = 10000,
  196. .bus_num = 1,
  197. .platform_data = &poodle_ads7846_info,
  198. .controller_data= &poodle_ads7846_chip,
  199. .irq = gpio_to_irq(POODLE_GPIO_TP_INT),
  200. },
  201. };
  202. static void __init poodle_init_spi(void)
  203. {
  204. pxa2xx_set_spi_info(1, &poodle_spi_info);
  205. spi_register_board_info(ARRAY_AND_SIZE(poodle_spi_devices));
  206. }
  207. #else
  208. static inline void poodle_init_spi(void) {}
  209. #endif
  210. /*
  211. * MMC/SD Device
  212. *
  213. * The card detect interrupt isn't debounced so we delay it by 250ms
  214. * to give the card a chance to fully insert/eject.
  215. */
  216. static struct pxamci_platform_data poodle_mci_platform_data;
  217. static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data)
  218. {
  219. int err;
  220. err = gpio_request(POODLE_GPIO_nSD_DETECT, "nSD_DETECT");
  221. if (err)
  222. goto err_out;
  223. err = gpio_request(POODLE_GPIO_nSD_WP, "nSD_WP");
  224. if (err)
  225. goto err_free_1;
  226. err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR");
  227. if (err)
  228. goto err_free_2;
  229. err = gpio_request(POODLE_GPIO_SD_PWR1, "SD_PWR1");
  230. if (err)
  231. goto err_free_3;
  232. gpio_direction_input(POODLE_GPIO_nSD_DETECT);
  233. gpio_direction_input(POODLE_GPIO_nSD_WP);
  234. gpio_direction_output(POODLE_GPIO_SD_PWR, 0);
  235. gpio_direction_output(POODLE_GPIO_SD_PWR1, 0);
  236. poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
  237. err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
  238. IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  239. "MMC card detect", data);
  240. if (err) {
  241. pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
  242. __func__);
  243. goto err_free_4;
  244. }
  245. return 0;
  246. err_free_4:
  247. gpio_free(POODLE_GPIO_SD_PWR1);
  248. err_free_3:
  249. gpio_free(POODLE_GPIO_SD_PWR);
  250. err_free_2:
  251. gpio_free(POODLE_GPIO_nSD_WP);
  252. err_free_1:
  253. gpio_free(POODLE_GPIO_nSD_DETECT);
  254. err_out:
  255. return err;
  256. }
  257. static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
  258. {
  259. struct pxamci_platform_data* p_d = dev->platform_data;
  260. if ((1 << vdd) & p_d->ocr_mask) {
  261. gpio_set_value(POODLE_GPIO_SD_PWR, 1);
  262. mdelay(2);
  263. gpio_set_value(POODLE_GPIO_SD_PWR1, 1);
  264. } else {
  265. gpio_set_value(POODLE_GPIO_SD_PWR1, 0);
  266. gpio_set_value(POODLE_GPIO_SD_PWR, 0);
  267. }
  268. }
  269. static int poodle_mci_get_ro(struct device *dev)
  270. {
  271. return !!gpio_get_value(POODLE_GPIO_nSD_WP);
  272. return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
  273. }
  274. static void poodle_mci_exit(struct device *dev, void *data)
  275. {
  276. free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
  277. gpio_free(POODLE_GPIO_SD_PWR1);
  278. gpio_free(POODLE_GPIO_SD_PWR);
  279. gpio_free(POODLE_GPIO_nSD_WP);
  280. gpio_free(POODLE_GPIO_nSD_DETECT);
  281. }
  282. static struct pxamci_platform_data poodle_mci_platform_data = {
  283. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  284. .init = poodle_mci_init,
  285. .get_ro = poodle_mci_get_ro,
  286. .setpower = poodle_mci_setpower,
  287. .exit = poodle_mci_exit,
  288. };
  289. /*
  290. * Irda
  291. */
  292. static void poodle_irda_transceiver_mode(struct device *dev, int mode)
  293. {
  294. gpio_set_value(POODLE_GPIO_IR_ON, mode & IR_OFF);
  295. pxa2xx_transceiver_mode(dev, mode);
  296. }
  297. static int poodle_irda_startup(struct device *dev)
  298. {
  299. int err;
  300. err = gpio_request(POODLE_GPIO_IR_ON, "IR_ON");
  301. if (err)
  302. return err;
  303. gpio_direction_output(POODLE_GPIO_IR_ON, 1);
  304. return 0;
  305. }
  306. static void poodle_irda_shutdown(struct device *dev)
  307. {
  308. gpio_free(POODLE_GPIO_IR_ON);
  309. }
  310. static struct pxaficp_platform_data poodle_ficp_platform_data = {
  311. .transceiver_cap = IR_SIRMODE | IR_OFF,
  312. .transceiver_mode = poodle_irda_transceiver_mode,
  313. .startup = poodle_irda_startup,
  314. .shutdown = poodle_irda_shutdown,
  315. };
  316. /*
  317. * USB Device Controller
  318. */
  319. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  320. /* no connect GPIO; poodle can't tell connection status */
  321. .gpio_pullup = POODLE_GPIO_USB_PULLUP,
  322. };
  323. /* PXAFB device */
  324. static struct pxafb_mode_info poodle_fb_mode = {
  325. .pixclock = 144700,
  326. .xres = 320,
  327. .yres = 240,
  328. .bpp = 16,
  329. .hsync_len = 7,
  330. .left_margin = 11,
  331. .right_margin = 30,
  332. .vsync_len = 2,
  333. .upper_margin = 2,
  334. .lower_margin = 0,
  335. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  336. };
  337. static struct pxafb_mach_info poodle_fb_info = {
  338. .modes = &poodle_fb_mode,
  339. .num_modes = 1,
  340. .lcd_conn = LCD_COLOR_TFT_16BPP,
  341. };
  342. static struct mtd_partition sharpsl_nand_partitions[] = {
  343. {
  344. .name = "System Area",
  345. .offset = 0,
  346. .size = 7 * 1024 * 1024,
  347. },
  348. {
  349. .name = "Root Filesystem",
  350. .offset = 7 * 1024 * 1024,
  351. .size = 22 * 1024 * 1024,
  352. },
  353. {
  354. .name = "Home Filesystem",
  355. .offset = MTDPART_OFS_APPEND,
  356. .size = MTDPART_SIZ_FULL,
  357. },
  358. };
  359. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  360. static struct nand_bbt_descr sharpsl_bbt = {
  361. .options = 0,
  362. .offs = 4,
  363. .len = 2,
  364. .pattern = scan_ff_pattern
  365. };
  366. static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
  367. .badblock_pattern = &sharpsl_bbt,
  368. .partitions = sharpsl_nand_partitions,
  369. .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions),
  370. };
  371. static struct resource sharpsl_nand_resources[] = {
  372. {
  373. .start = 0x0C000000,
  374. .end = 0x0C000FFF,
  375. .flags = IORESOURCE_MEM,
  376. },
  377. };
  378. static struct platform_device sharpsl_nand_device = {
  379. .name = "sharpsl-nand",
  380. .id = -1,
  381. .resource = sharpsl_nand_resources,
  382. .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
  383. .dev.platform_data = &sharpsl_nand_platform_data,
  384. };
  385. static struct mtd_partition sharpsl_rom_parts[] = {
  386. {
  387. .name ="Boot PROM Filesystem",
  388. .offset = 0x00120000,
  389. .size = MTDPART_SIZ_FULL,
  390. },
  391. };
  392. static struct physmap_flash_data sharpsl_rom_data = {
  393. .width = 2,
  394. .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
  395. .parts = sharpsl_rom_parts,
  396. };
  397. static struct resource sharpsl_rom_resources[] = {
  398. {
  399. .start = 0x00000000,
  400. .end = 0x007fffff,
  401. .flags = IORESOURCE_MEM,
  402. },
  403. };
  404. static struct platform_device sharpsl_rom_device = {
  405. .name = "physmap-flash",
  406. .id = -1,
  407. .resource = sharpsl_rom_resources,
  408. .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
  409. .dev.platform_data = &sharpsl_rom_data,
  410. };
  411. static struct platform_device *devices[] __initdata = {
  412. &poodle_locomo_device,
  413. &poodle_scoop_device,
  414. &sharpsl_nand_device,
  415. &sharpsl_rom_device,
  416. };
  417. static struct i2c_board_info __initdata poodle_i2c_devices[] = {
  418. { I2C_BOARD_INFO("wm8731", 0x1b) },
  419. };
  420. static void poodle_poweroff(void)
  421. {
  422. arm_machine_restart('h', NULL);
  423. }
  424. static void poodle_restart(char mode, const char *cmd)
  425. {
  426. arm_machine_restart('h', cmd);
  427. }
  428. static void __init poodle_init(void)
  429. {
  430. int ret = 0;
  431. pm_power_off = poodle_poweroff;
  432. arm_pm_restart = poodle_restart;
  433. PCFR |= PCFR_OPDE;
  434. pxa2xx_mfp_config(ARRAY_AND_SIZE(poodle_pin_config));
  435. platform_scoop_config = &poodle_pcmcia_config;
  436. ret = platform_add_devices(devices, ARRAY_SIZE(devices));
  437. if (ret)
  438. pr_warning("poodle: Unable to register LoCoMo device\n");
  439. set_pxa_fb_parent(&poodle_locomo_device.dev);
  440. set_pxa_fb_info(&poodle_fb_info);
  441. pxa_set_udc_info(&udc_info);
  442. pxa_set_mci_info(&poodle_mci_platform_data);
  443. pxa_set_ficp_info(&poodle_ficp_platform_data);
  444. pxa_set_i2c_info(NULL);
  445. i2c_register_board_info(0, ARRAY_AND_SIZE(poodle_i2c_devices));
  446. poodle_init_spi();
  447. }
  448. static void __init fixup_poodle(struct machine_desc *desc,
  449. struct tag *tags, char **cmdline, struct meminfo *mi)
  450. {
  451. sharpsl_save_param();
  452. mi->nr_banks=1;
  453. mi->bank[0].start = 0xa0000000;
  454. mi->bank[0].node = 0;
  455. mi->bank[0].size = (32*1024*1024);
  456. }
  457. MACHINE_START(POODLE, "SHARP Poodle")
  458. .phys_io = 0x40000000,
  459. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  460. .fixup = fixup_poodle,
  461. .map_io = pxa_map_io,
  462. .init_irq = pxa25x_init_irq,
  463. .timer = &pxa_timer,
  464. .init_machine = poodle_init,
  465. MACHINE_END