poodle.c 12 KB

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