poodle.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  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 <mach/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 void ads7846_cs(u32 command)
  189. {
  190. gpio_set_value(POODLE_GPIO_TP_CS, !(command == PXA2XX_CS_ASSERT));
  191. }
  192. static struct pxa2xx_spi_chip poodle_ads7846_chip = {
  193. .cs_control = ads7846_cs,
  194. };
  195. static struct spi_board_info poodle_spi_devices[] = {
  196. {
  197. .modalias = "ads7846",
  198. .max_speed_hz = 10000,
  199. .bus_num = 1,
  200. .platform_data = &poodle_ads7846_info,
  201. .controller_data= &poodle_ads7846_chip,
  202. .irq = gpio_to_irq(POODLE_GPIO_TP_INT),
  203. },
  204. };
  205. static void __init poodle_init_spi(void)
  206. {
  207. int err;
  208. err = gpio_request(POODLE_GPIO_TP_CS, "ADS7846_CS");
  209. if (err)
  210. return;
  211. gpio_direction_output(POODLE_GPIO_TP_CS, 1);
  212. pxa2xx_set_spi_info(1, &poodle_spi_info);
  213. spi_register_board_info(ARRAY_AND_SIZE(poodle_spi_devices));
  214. }
  215. #else
  216. static inline void poodle_init_spi(void) {}
  217. #endif
  218. /*
  219. * MMC/SD Device
  220. *
  221. * The card detect interrupt isn't debounced so we delay it by 250ms
  222. * to give the card a chance to fully insert/eject.
  223. */
  224. static struct pxamci_platform_data poodle_mci_platform_data;
  225. static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data)
  226. {
  227. int err;
  228. err = gpio_request(POODLE_GPIO_nSD_DETECT, "nSD_DETECT");
  229. if (err)
  230. goto err_out;
  231. err = gpio_request(POODLE_GPIO_nSD_WP, "nSD_WP");
  232. if (err)
  233. goto err_free_1;
  234. err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR");
  235. if (err)
  236. goto err_free_2;
  237. err = gpio_request(POODLE_GPIO_SD_PWR1, "SD_PWR1");
  238. if (err)
  239. goto err_free_3;
  240. gpio_direction_input(POODLE_GPIO_nSD_DETECT);
  241. gpio_direction_input(POODLE_GPIO_nSD_WP);
  242. gpio_direction_output(POODLE_GPIO_SD_PWR, 0);
  243. gpio_direction_output(POODLE_GPIO_SD_PWR1, 0);
  244. poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
  245. err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
  246. IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  247. "MMC card detect", data);
  248. if (err) {
  249. pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
  250. __func__);
  251. goto err_free_4;
  252. }
  253. return 0;
  254. err_free_4:
  255. gpio_free(POODLE_GPIO_SD_PWR1);
  256. err_free_3:
  257. gpio_free(POODLE_GPIO_SD_PWR);
  258. err_free_2:
  259. gpio_free(POODLE_GPIO_nSD_WP);
  260. err_free_1:
  261. gpio_free(POODLE_GPIO_nSD_DETECT);
  262. err_out:
  263. return err;
  264. }
  265. static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
  266. {
  267. struct pxamci_platform_data* p_d = dev->platform_data;
  268. if ((1 << vdd) & p_d->ocr_mask) {
  269. gpio_set_value(POODLE_GPIO_SD_PWR, 1);
  270. mdelay(2);
  271. gpio_set_value(POODLE_GPIO_SD_PWR1, 1);
  272. } else {
  273. gpio_set_value(POODLE_GPIO_SD_PWR1, 0);
  274. gpio_set_value(POODLE_GPIO_SD_PWR, 0);
  275. }
  276. }
  277. static int poodle_mci_get_ro(struct device *dev)
  278. {
  279. return !!gpio_get_value(POODLE_GPIO_nSD_WP);
  280. return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
  281. }
  282. static void poodle_mci_exit(struct device *dev, void *data)
  283. {
  284. free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
  285. gpio_free(POODLE_GPIO_SD_PWR1);
  286. gpio_free(POODLE_GPIO_SD_PWR);
  287. gpio_free(POODLE_GPIO_nSD_WP);
  288. gpio_free(POODLE_GPIO_nSD_DETECT);
  289. }
  290. static struct pxamci_platform_data poodle_mci_platform_data = {
  291. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  292. .init = poodle_mci_init,
  293. .get_ro = poodle_mci_get_ro,
  294. .setpower = poodle_mci_setpower,
  295. .exit = poodle_mci_exit,
  296. };
  297. /*
  298. * Irda
  299. */
  300. static void poodle_irda_transceiver_mode(struct device *dev, int mode)
  301. {
  302. gpio_set_value(POODLE_GPIO_IR_ON, mode & IR_OFF);
  303. pxa2xx_transceiver_mode(dev, mode);
  304. }
  305. static int poodle_irda_startup(struct device *dev)
  306. {
  307. int err;
  308. err = gpio_request(POODLE_GPIO_IR_ON, "IR_ON");
  309. if (err)
  310. return err;
  311. gpio_direction_output(POODLE_GPIO_IR_ON, 1);
  312. return 0;
  313. }
  314. static void poodle_irda_shutdown(struct device *dev)
  315. {
  316. gpio_free(POODLE_GPIO_IR_ON);
  317. }
  318. static struct pxaficp_platform_data poodle_ficp_platform_data = {
  319. .transceiver_cap = IR_SIRMODE | IR_OFF,
  320. .transceiver_mode = poodle_irda_transceiver_mode,
  321. .startup = poodle_irda_startup,
  322. .shutdown = poodle_irda_shutdown,
  323. };
  324. /*
  325. * USB Device Controller
  326. */
  327. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  328. /* no connect GPIO; poodle can't tell connection status */
  329. .gpio_pullup = POODLE_GPIO_USB_PULLUP,
  330. };
  331. /* PXAFB device */
  332. static struct pxafb_mode_info poodle_fb_mode = {
  333. .pixclock = 144700,
  334. .xres = 320,
  335. .yres = 240,
  336. .bpp = 16,
  337. .hsync_len = 7,
  338. .left_margin = 11,
  339. .right_margin = 30,
  340. .vsync_len = 2,
  341. .upper_margin = 2,
  342. .lower_margin = 0,
  343. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  344. };
  345. static struct pxafb_mach_info poodle_fb_info = {
  346. .modes = &poodle_fb_mode,
  347. .num_modes = 1,
  348. .lcd_conn = LCD_COLOR_TFT_16BPP,
  349. };
  350. static struct mtd_partition sharpsl_nand_partitions[] = {
  351. {
  352. .name = "System Area",
  353. .offset = 0,
  354. .size = 7 * 1024 * 1024,
  355. },
  356. {
  357. .name = "Root Filesystem",
  358. .offset = 7 * 1024 * 1024,
  359. .size = 22 * 1024 * 1024,
  360. },
  361. {
  362. .name = "Home Filesystem",
  363. .offset = MTDPART_OFS_APPEND,
  364. .size = MTDPART_SIZ_FULL,
  365. },
  366. };
  367. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  368. static struct nand_bbt_descr sharpsl_bbt = {
  369. .options = 0,
  370. .offs = 4,
  371. .len = 2,
  372. .pattern = scan_ff_pattern
  373. };
  374. static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
  375. .badblock_pattern = &sharpsl_bbt,
  376. .partitions = sharpsl_nand_partitions,
  377. .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions),
  378. };
  379. static struct resource sharpsl_nand_resources[] = {
  380. {
  381. .start = 0x0C000000,
  382. .end = 0x0C000FFF,
  383. .flags = IORESOURCE_MEM,
  384. },
  385. };
  386. static struct platform_device sharpsl_nand_device = {
  387. .name = "sharpsl-nand",
  388. .id = -1,
  389. .resource = sharpsl_nand_resources,
  390. .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
  391. .dev.platform_data = &sharpsl_nand_platform_data,
  392. };
  393. static struct mtd_partition sharpsl_rom_parts[] = {
  394. {
  395. .name ="Boot PROM Filesystem",
  396. .offset = 0x00120000,
  397. .size = MTDPART_SIZ_FULL,
  398. },
  399. };
  400. static struct physmap_flash_data sharpsl_rom_data = {
  401. .width = 2,
  402. .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
  403. .parts = sharpsl_rom_parts,
  404. };
  405. static struct resource sharpsl_rom_resources[] = {
  406. {
  407. .start = 0x00000000,
  408. .end = 0x007fffff,
  409. .flags = IORESOURCE_MEM,
  410. },
  411. };
  412. static struct platform_device sharpsl_rom_device = {
  413. .name = "physmap-flash",
  414. .id = -1,
  415. .resource = sharpsl_rom_resources,
  416. .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
  417. .dev.platform_data = &sharpsl_rom_data,
  418. };
  419. static struct platform_device *devices[] __initdata = {
  420. &poodle_locomo_device,
  421. &poodle_scoop_device,
  422. &sharpsl_nand_device,
  423. &sharpsl_rom_device,
  424. };
  425. static void poodle_poweroff(void)
  426. {
  427. arm_machine_restart('h', NULL);
  428. }
  429. static void poodle_restart(char mode, const char *cmd)
  430. {
  431. arm_machine_restart('h', cmd);
  432. }
  433. static void __init poodle_init(void)
  434. {
  435. int ret = 0;
  436. pm_power_off = poodle_poweroff;
  437. arm_pm_restart = poodle_restart;
  438. PCFR |= PCFR_OPDE;
  439. pxa2xx_mfp_config(ARRAY_AND_SIZE(poodle_pin_config));
  440. platform_scoop_config = &poodle_pcmcia_config;
  441. ret = platform_add_devices(devices, ARRAY_SIZE(devices));
  442. if (ret)
  443. pr_warning("poodle: Unable to register LoCoMo device\n");
  444. set_pxa_fb_parent(&poodle_locomo_device.dev);
  445. set_pxa_fb_info(&poodle_fb_info);
  446. pxa_set_udc_info(&udc_info);
  447. pxa_set_mci_info(&poodle_mci_platform_data);
  448. pxa_set_ficp_info(&poodle_ficp_platform_data);
  449. pxa_set_i2c_info(NULL);
  450. poodle_init_spi();
  451. }
  452. static void __init fixup_poodle(struct machine_desc *desc,
  453. struct tag *tags, char **cmdline, struct meminfo *mi)
  454. {
  455. sharpsl_save_param();
  456. mi->nr_banks=1;
  457. mi->bank[0].start = 0xa0000000;
  458. mi->bank[0].node = 0;
  459. mi->bank[0].size = (32*1024*1024);
  460. }
  461. MACHINE_START(POODLE, "SHARP Poodle")
  462. .phys_io = 0x40000000,
  463. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  464. .fixup = fixup_poodle,
  465. .map_io = pxa_map_io,
  466. .init_irq = pxa25x_init_irq,
  467. .timer = &pxa_timer,
  468. .init_machine = poodle_init,
  469. MACHINE_END