lubbock.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. /*
  2. * linux/arch/arm/mach-pxa/lubbock.c
  3. *
  4. * Support for the Intel DBPXA250 Development Platform.
  5. *
  6. * Author: Nicolas Pitre
  7. * Created: Jun 15, 2001
  8. * Copyright: MontaVista Software Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/sysdev.h>
  19. #include <linux/major.h>
  20. #include <linux/fb.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/mtd/mtd.h>
  23. #include <linux/mtd/partitions.h>
  24. #include <linux/smc91x.h>
  25. #include <linux/spi/spi.h>
  26. #include <linux/spi/ads7846.h>
  27. #include <asm/arch/pxa2xx_spi.h>
  28. #include <asm/setup.h>
  29. #include <asm/memory.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/hardware.h>
  32. #include <asm/irq.h>
  33. #include <asm/sizes.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include <asm/mach/irq.h>
  37. #include <asm/mach/flash.h>
  38. #include <asm/hardware/sa1111.h>
  39. #include <asm/arch/pxa-regs.h>
  40. #include <asm/arch/pxa2xx-regs.h>
  41. #include <asm/arch/mfp-pxa25x.h>
  42. #include <asm/arch/audio.h>
  43. #include <asm/arch/lubbock.h>
  44. #include <asm/arch/udc.h>
  45. #include <asm/arch/irda.h>
  46. #include <asm/arch/pxafb.h>
  47. #include <asm/arch/mmc.h>
  48. #include "generic.h"
  49. #include "devices.h"
  50. static unsigned long lubbock_pin_config[] __initdata = {
  51. GPIO15_nCS_1, /* CS1 - Flash */
  52. GPIO79_nCS_3, /* CS3 - SMC ethernet */
  53. /* SSP data pins */
  54. GPIO23_SSP1_SCLK,
  55. GPIO25_SSP1_TXD,
  56. GPIO26_SSP1_RXD,
  57. /* BTUART */
  58. GPIO42_BTUART_RXD,
  59. GPIO43_BTUART_TXD,
  60. GPIO44_BTUART_CTS,
  61. GPIO45_BTUART_RTS,
  62. /* PC Card */
  63. GPIO48_nPOE,
  64. GPIO49_nPWE,
  65. GPIO50_nPIOR,
  66. GPIO51_nPIOW,
  67. GPIO52_nPCE_1,
  68. GPIO53_nPCE_2,
  69. GPIO54_nPSKTSEL,
  70. GPIO55_nPREG,
  71. GPIO56_nPWAIT,
  72. GPIO57_nIOIS16,
  73. /* MMC */
  74. GPIO6_MMC_CLK,
  75. GPIO8_MMC_CS0,
  76. /* wakeup */
  77. GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
  78. };
  79. #define LUB_MISC_WR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
  80. void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
  81. {
  82. unsigned long flags;
  83. local_irq_save(flags);
  84. LUB_MISC_WR = (LUB_MISC_WR & ~mask) | (set & mask);
  85. local_irq_restore(flags);
  86. }
  87. EXPORT_SYMBOL(lubbock_set_misc_wr);
  88. static unsigned long lubbock_irq_enabled;
  89. static void lubbock_mask_irq(unsigned int irq)
  90. {
  91. int lubbock_irq = (irq - LUBBOCK_IRQ(0));
  92. LUB_IRQ_MASK_EN = (lubbock_irq_enabled &= ~(1 << lubbock_irq));
  93. }
  94. static void lubbock_unmask_irq(unsigned int irq)
  95. {
  96. int lubbock_irq = (irq - LUBBOCK_IRQ(0));
  97. /* the irq can be acknowledged only if deasserted, so it's done here */
  98. LUB_IRQ_SET_CLR &= ~(1 << lubbock_irq);
  99. LUB_IRQ_MASK_EN = (lubbock_irq_enabled |= (1 << lubbock_irq));
  100. }
  101. static struct irq_chip lubbock_irq_chip = {
  102. .name = "FPGA",
  103. .ack = lubbock_mask_irq,
  104. .mask = lubbock_mask_irq,
  105. .unmask = lubbock_unmask_irq,
  106. };
  107. static void lubbock_irq_handler(unsigned int irq, struct irq_desc *desc)
  108. {
  109. unsigned long pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
  110. do {
  111. GEDR(0) = GPIO_bit(0); /* clear our parent irq */
  112. if (likely(pending)) {
  113. irq = LUBBOCK_IRQ(0) + __ffs(pending);
  114. desc = irq_desc + irq;
  115. desc_handle_irq(irq, desc);
  116. }
  117. pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
  118. } while (pending);
  119. }
  120. static void __init lubbock_init_irq(void)
  121. {
  122. int irq;
  123. pxa25x_init_irq();
  124. /* setup extra lubbock irqs */
  125. for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_LAST_IRQ; irq++) {
  126. set_irq_chip(irq, &lubbock_irq_chip);
  127. set_irq_handler(irq, handle_level_irq);
  128. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  129. }
  130. set_irq_chained_handler(IRQ_GPIO(0), lubbock_irq_handler);
  131. set_irq_type(IRQ_GPIO(0), IRQT_FALLING);
  132. }
  133. #ifdef CONFIG_PM
  134. static int lubbock_irq_resume(struct sys_device *dev)
  135. {
  136. LUB_IRQ_MASK_EN = lubbock_irq_enabled;
  137. return 0;
  138. }
  139. static struct sysdev_class lubbock_irq_sysclass = {
  140. .name = "cpld_irq",
  141. .resume = lubbock_irq_resume,
  142. };
  143. static struct sys_device lubbock_irq_device = {
  144. .cls = &lubbock_irq_sysclass,
  145. };
  146. static int __init lubbock_irq_device_init(void)
  147. {
  148. int ret = -ENODEV;
  149. if (machine_is_lubbock()) {
  150. ret = sysdev_class_register(&lubbock_irq_sysclass);
  151. if (ret == 0)
  152. ret = sysdev_register(&lubbock_irq_device);
  153. }
  154. return ret;
  155. }
  156. device_initcall(lubbock_irq_device_init);
  157. #endif
  158. static int lubbock_udc_is_connected(void)
  159. {
  160. return (LUB_MISC_RD & (1 << 9)) == 0;
  161. }
  162. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  163. .udc_is_connected = lubbock_udc_is_connected,
  164. // no D+ pullup; lubbock can't connect/disconnect in software
  165. };
  166. static struct resource sa1111_resources[] = {
  167. [0] = {
  168. .start = 0x10000000,
  169. .end = 0x10001fff,
  170. .flags = IORESOURCE_MEM,
  171. },
  172. [1] = {
  173. .start = LUBBOCK_SA1111_IRQ,
  174. .end = LUBBOCK_SA1111_IRQ,
  175. .flags = IORESOURCE_IRQ,
  176. },
  177. };
  178. static struct platform_device sa1111_device = {
  179. .name = "sa1111",
  180. .id = -1,
  181. .num_resources = ARRAY_SIZE(sa1111_resources),
  182. .resource = sa1111_resources,
  183. };
  184. /* ADS7846 is connected through SSP ... and if your board has J5 populated,
  185. * you can select it to replace the ucb1400 by switching the touchscreen cable
  186. * (to J5) and poking board registers (as done below). Else it's only useful
  187. * for the temperature sensors.
  188. */
  189. static struct pxa2xx_spi_master pxa_ssp_master_info = {
  190. .num_chipselect = 0,
  191. };
  192. static int lubbock_ads7846_pendown_state(void)
  193. {
  194. /* TS_BUSY is bit 8 in LUB_MISC_RD, but pendown is irq-only */
  195. return 0;
  196. }
  197. static struct ads7846_platform_data ads_info = {
  198. .model = 7846,
  199. .vref_delay_usecs = 100, /* internal, no cap */
  200. .get_pendown_state = lubbock_ads7846_pendown_state,
  201. // .x_plate_ohms = 500, /* GUESS! */
  202. // .y_plate_ohms = 500, /* GUESS! */
  203. };
  204. static void ads7846_cs(u32 command)
  205. {
  206. static const unsigned TS_nCS = 1 << 11;
  207. lubbock_set_misc_wr(TS_nCS, (command == PXA2XX_CS_ASSERT) ? 0 : TS_nCS);
  208. }
  209. static struct pxa2xx_spi_chip ads_hw = {
  210. .tx_threshold = 1,
  211. .rx_threshold = 2,
  212. .cs_control = ads7846_cs,
  213. };
  214. static struct spi_board_info spi_board_info[] __initdata = { {
  215. .modalias = "ads7846",
  216. .platform_data = &ads_info,
  217. .controller_data = &ads_hw,
  218. .irq = LUBBOCK_BB_IRQ,
  219. .max_speed_hz = 120000 /* max sample rate at 3V */
  220. * 26 /* command + data + overhead */,
  221. .bus_num = 1,
  222. .chip_select = 0,
  223. },
  224. };
  225. static struct resource smc91x_resources[] = {
  226. [0] = {
  227. .name = "smc91x-regs",
  228. .start = 0x0c000c00,
  229. .end = 0x0c0fffff,
  230. .flags = IORESOURCE_MEM,
  231. },
  232. [1] = {
  233. .start = LUBBOCK_ETH_IRQ,
  234. .end = LUBBOCK_ETH_IRQ,
  235. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  236. },
  237. [2] = {
  238. .name = "smc91x-attrib",
  239. .start = 0x0e000000,
  240. .end = 0x0e0fffff,
  241. .flags = IORESOURCE_MEM,
  242. },
  243. };
  244. static struct smc91x_platdata lubbock_smc91x_info = {
  245. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT | SMC91X_IO_SHIFT_2,
  246. };
  247. static struct platform_device smc91x_device = {
  248. .name = "smc91x",
  249. .id = -1,
  250. .num_resources = ARRAY_SIZE(smc91x_resources),
  251. .resource = smc91x_resources,
  252. .dev = {
  253. .platform_data = &lubbock_smc91x_info,
  254. },
  255. };
  256. static struct resource flash_resources[] = {
  257. [0] = {
  258. .start = 0x00000000,
  259. .end = SZ_64M - 1,
  260. .flags = IORESOURCE_MEM,
  261. },
  262. [1] = {
  263. .start = 0x04000000,
  264. .end = 0x04000000 + SZ_64M - 1,
  265. .flags = IORESOURCE_MEM,
  266. },
  267. };
  268. static struct mtd_partition lubbock_partitions[] = {
  269. {
  270. .name = "Bootloader",
  271. .size = 0x00040000,
  272. .offset = 0,
  273. .mask_flags = MTD_WRITEABLE /* force read-only */
  274. },{
  275. .name = "Kernel",
  276. .size = 0x00100000,
  277. .offset = 0x00040000,
  278. },{
  279. .name = "Filesystem",
  280. .size = MTDPART_SIZ_FULL,
  281. .offset = 0x00140000
  282. }
  283. };
  284. static struct flash_platform_data lubbock_flash_data[2] = {
  285. {
  286. .map_name = "cfi_probe",
  287. .parts = lubbock_partitions,
  288. .nr_parts = ARRAY_SIZE(lubbock_partitions),
  289. }, {
  290. .map_name = "cfi_probe",
  291. .parts = NULL,
  292. .nr_parts = 0,
  293. }
  294. };
  295. static struct platform_device lubbock_flash_device[2] = {
  296. {
  297. .name = "pxa2xx-flash",
  298. .id = 0,
  299. .dev = {
  300. .platform_data = &lubbock_flash_data[0],
  301. },
  302. .resource = &flash_resources[0],
  303. .num_resources = 1,
  304. },
  305. {
  306. .name = "pxa2xx-flash",
  307. .id = 1,
  308. .dev = {
  309. .platform_data = &lubbock_flash_data[1],
  310. },
  311. .resource = &flash_resources[1],
  312. .num_resources = 1,
  313. },
  314. };
  315. static struct platform_device *devices[] __initdata = {
  316. &sa1111_device,
  317. &smc91x_device,
  318. &lubbock_flash_device[0],
  319. &lubbock_flash_device[1],
  320. };
  321. static struct pxafb_mode_info sharp_lm8v31_mode = {
  322. .pixclock = 270000,
  323. .xres = 640,
  324. .yres = 480,
  325. .bpp = 16,
  326. .hsync_len = 1,
  327. .left_margin = 3,
  328. .right_margin = 3,
  329. .vsync_len = 1,
  330. .upper_margin = 0,
  331. .lower_margin = 0,
  332. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  333. .cmap_greyscale = 0,
  334. };
  335. static struct pxafb_mach_info sharp_lm8v31 = {
  336. .modes = &sharp_lm8v31_mode,
  337. .num_modes = 1,
  338. .cmap_inverse = 0,
  339. .cmap_static = 0,
  340. .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
  341. LCD_AC_BIAS_FREQ(255),
  342. };
  343. #define MMC_POLL_RATE msecs_to_jiffies(1000)
  344. static void lubbock_mmc_poll(unsigned long);
  345. static irq_handler_t mmc_detect_int;
  346. static struct timer_list mmc_timer = {
  347. .function = lubbock_mmc_poll,
  348. };
  349. static void lubbock_mmc_poll(unsigned long data)
  350. {
  351. unsigned long flags;
  352. /* clear any previous irq state, then ... */
  353. local_irq_save(flags);
  354. LUB_IRQ_SET_CLR &= ~(1 << 0);
  355. local_irq_restore(flags);
  356. /* poll until mmc/sd card is removed */
  357. if (LUB_IRQ_SET_CLR & (1 << 0))
  358. mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
  359. else {
  360. (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data);
  361. enable_irq(LUBBOCK_SD_IRQ);
  362. }
  363. }
  364. static irqreturn_t lubbock_detect_int(int irq, void *data)
  365. {
  366. /* IRQ is level triggered; disable, and poll for removal */
  367. disable_irq(irq);
  368. mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
  369. return mmc_detect_int(irq, data);
  370. }
  371. static int lubbock_mci_init(struct device *dev,
  372. irq_handler_t detect_int,
  373. void *data)
  374. {
  375. /* detect card insert/eject */
  376. mmc_detect_int = detect_int;
  377. init_timer(&mmc_timer);
  378. mmc_timer.data = (unsigned long) data;
  379. return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
  380. IRQF_SAMPLE_RANDOM, "lubbock-sd-detect", data);
  381. }
  382. static int lubbock_mci_get_ro(struct device *dev)
  383. {
  384. return (LUB_MISC_RD & (1 << 2)) != 0;
  385. }
  386. static void lubbock_mci_exit(struct device *dev, void *data)
  387. {
  388. free_irq(LUBBOCK_SD_IRQ, data);
  389. del_timer_sync(&mmc_timer);
  390. }
  391. static struct pxamci_platform_data lubbock_mci_platform_data = {
  392. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  393. .detect_delay = 1,
  394. .init = lubbock_mci_init,
  395. .get_ro = lubbock_mci_get_ro,
  396. .exit = lubbock_mci_exit,
  397. };
  398. static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
  399. {
  400. unsigned long flags;
  401. local_irq_save(flags);
  402. if (mode & IR_SIRMODE) {
  403. LUB_MISC_WR &= ~(1 << 4);
  404. } else if (mode & IR_FIRMODE) {
  405. LUB_MISC_WR |= 1 << 4;
  406. }
  407. pxa2xx_transceiver_mode(dev, mode);
  408. local_irq_restore(flags);
  409. }
  410. static struct pxaficp_platform_data lubbock_ficp_platform_data = {
  411. .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
  412. .transceiver_mode = lubbock_irda_transceiver_mode,
  413. };
  414. static void __init lubbock_init(void)
  415. {
  416. int flashboot = (LUB_CONF_SWITCHES & 1);
  417. pxa2xx_mfp_config(ARRAY_AND_SIZE(lubbock_pin_config));
  418. pxa_set_udc_info(&udc_info);
  419. set_pxa_fb_info(&sharp_lm8v31);
  420. pxa_set_mci_info(&lubbock_mci_platform_data);
  421. pxa_set_ficp_info(&lubbock_ficp_platform_data);
  422. pxa_set_ac97_info(NULL);
  423. lubbock_flash_data[0].width = lubbock_flash_data[1].width =
  424. (BOOT_DEF & 1) ? 2 : 4;
  425. /* Compensate for the nROMBT switch which swaps the flash banks */
  426. printk(KERN_NOTICE "Lubbock configured to boot from %s (bank %d)\n",
  427. flashboot?"Flash":"ROM", flashboot);
  428. lubbock_flash_data[flashboot^1].name = "application-flash";
  429. lubbock_flash_data[flashboot].name = "boot-rom";
  430. (void) platform_add_devices(devices, ARRAY_SIZE(devices));
  431. pxa2xx_set_spi_info(1, &pxa_ssp_master_info);
  432. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  433. }
  434. static struct map_desc lubbock_io_desc[] __initdata = {
  435. { /* CPLD */
  436. .virtual = LUBBOCK_FPGA_VIRT,
  437. .pfn = __phys_to_pfn(LUBBOCK_FPGA_PHYS),
  438. .length = 0x00100000,
  439. .type = MT_DEVICE
  440. }
  441. };
  442. static void __init lubbock_map_io(void)
  443. {
  444. pxa_map_io();
  445. iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
  446. PCFR |= PCFR_OPDE;
  447. }
  448. MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
  449. /* Maintainer: MontaVista Software Inc. */
  450. .phys_io = 0x40000000,
  451. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  452. .map_io = lubbock_map_io,
  453. .init_irq = lubbock_init_irq,
  454. .timer = &pxa_timer,
  455. .init_machine = lubbock_init,
  456. MACHINE_END