poodle.c 10 KB

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