lubbock.c 13 KB

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