poodle.c 10 KB

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