poodle.c 12 KB

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