lubbock.c 13 KB

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