lubbock.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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/clkdev.h>
  15. #include <linux/gpio.h>
  16. #include <linux/gpio/machine.h>
  17. #include <linux/module.h>
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/io.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/syscore_ops.h>
  23. #include <linux/major.h>
  24. #include <linux/fb.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/mtd/mtd.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <linux/smc91x.h>
  29. #include <linux/slab.h>
  30. #include <linux/leds.h>
  31. #include <linux/spi/spi.h>
  32. #include <linux/spi/ads7846.h>
  33. #include <linux/spi/pxa2xx_spi.h>
  34. #include <asm/setup.h>
  35. #include <asm/memory.h>
  36. #include <asm/mach-types.h>
  37. #include <mach/hardware.h>
  38. #include <asm/irq.h>
  39. #include <asm/sizes.h>
  40. #include <asm/mach/arch.h>
  41. #include <asm/mach/map.h>
  42. #include <asm/mach/irq.h>
  43. #include <asm/mach/flash.h>
  44. #include <asm/hardware/sa1111.h>
  45. #include <mach/pxa25x.h>
  46. #include <mach/audio.h>
  47. #include <mach/lubbock.h>
  48. #include <mach/udc.h>
  49. #include <linux/platform_data/irda-pxaficp.h>
  50. #include <linux/platform_data/video-pxafb.h>
  51. #include <linux/platform_data/mmc-pxamci.h>
  52. #include <mach/pm.h>
  53. #include <mach/smemc.h>
  54. #include "generic.h"
  55. #include "devices.h"
  56. static unsigned long lubbock_pin_config[] __initdata = {
  57. GPIO15_nCS_1, /* CS1 - Flash */
  58. GPIO78_nCS_2, /* CS2 - Baseboard FGPA */
  59. GPIO79_nCS_3, /* CS3 - SMC ethernet */
  60. GPIO80_nCS_4, /* CS4 - SA1111 */
  61. /* SSP data pins */
  62. GPIO23_SSP1_SCLK,
  63. GPIO25_SSP1_TXD,
  64. GPIO26_SSP1_RXD,
  65. /* AC97 */
  66. GPIO28_AC97_BITCLK,
  67. GPIO29_AC97_SDATA_IN_0,
  68. GPIO30_AC97_SDATA_OUT,
  69. GPIO31_AC97_SYNC,
  70. /* LCD - 16bpp DSTN */
  71. GPIOxx_LCD_DSTN_16BPP,
  72. /* BTUART */
  73. GPIO42_BTUART_RXD,
  74. GPIO43_BTUART_TXD,
  75. GPIO44_BTUART_CTS,
  76. GPIO45_BTUART_RTS,
  77. /* PC Card */
  78. GPIO48_nPOE,
  79. GPIO49_nPWE,
  80. GPIO50_nPIOR,
  81. GPIO51_nPIOW,
  82. GPIO52_nPCE_1,
  83. GPIO53_nPCE_2,
  84. GPIO54_nPSKTSEL,
  85. GPIO55_nPREG,
  86. GPIO56_nPWAIT,
  87. GPIO57_nIOIS16,
  88. /* MMC */
  89. GPIO6_MMC_CLK,
  90. GPIO8_MMC_CS0,
  91. /* SA1111 chip */
  92. GPIO11_3_6MHz,
  93. /* wakeup */
  94. GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
  95. };
  96. #define LUB_HEXLED __LUB_REG(LUBBOCK_FPGA_PHYS + 0x010)
  97. #define LUB_MISC_WR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
  98. void lubbock_set_hexled(uint32_t value)
  99. {
  100. LUB_HEXLED = value;
  101. }
  102. void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
  103. {
  104. unsigned long flags;
  105. local_irq_save(flags);
  106. LUB_MISC_WR = (LUB_MISC_WR & ~mask) | (set & mask);
  107. local_irq_restore(flags);
  108. }
  109. EXPORT_SYMBOL(lubbock_set_misc_wr);
  110. static int lubbock_udc_is_connected(void)
  111. {
  112. return (LUB_MISC_RD & (1 << 9)) == 0;
  113. }
  114. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  115. .udc_is_connected = lubbock_udc_is_connected,
  116. // no D+ pullup; lubbock can't connect/disconnect in software
  117. };
  118. static struct resource sa1111_resources[] = {
  119. [0] = {
  120. .start = 0x10000000,
  121. .end = 0x10001fff,
  122. .flags = IORESOURCE_MEM,
  123. },
  124. [1] = {
  125. .start = LUBBOCK_SA1111_IRQ,
  126. .end = LUBBOCK_SA1111_IRQ,
  127. .flags = IORESOURCE_IRQ,
  128. },
  129. };
  130. static struct sa1111_platform_data sa1111_info = {
  131. .irq_base = LUBBOCK_SA1111_IRQ_BASE,
  132. .disable_devs = SA1111_DEVID_SAC,
  133. };
  134. static struct platform_device sa1111_device = {
  135. .name = "sa1111",
  136. .id = -1,
  137. .num_resources = ARRAY_SIZE(sa1111_resources),
  138. .resource = sa1111_resources,
  139. .dev = {
  140. .platform_data = &sa1111_info,
  141. },
  142. };
  143. /* ADS7846 is connected through SSP ... and if your board has J5 populated,
  144. * you can select it to replace the ucb1400 by switching the touchscreen cable
  145. * (to J5) and poking board registers (as done below). Else it's only useful
  146. * for the temperature sensors.
  147. */
  148. static struct pxa2xx_spi_master pxa_ssp_master_info = {
  149. .num_chipselect = 1,
  150. };
  151. static int lubbock_ads7846_pendown_state(void)
  152. {
  153. /* TS_BUSY is bit 8 in LUB_MISC_RD, but pendown is irq-only */
  154. return 0;
  155. }
  156. static struct ads7846_platform_data ads_info = {
  157. .model = 7846,
  158. .vref_delay_usecs = 100, /* internal, no cap */
  159. .get_pendown_state = lubbock_ads7846_pendown_state,
  160. // .x_plate_ohms = 500, /* GUESS! */
  161. // .y_plate_ohms = 500, /* GUESS! */
  162. };
  163. static void ads7846_cs(u32 command)
  164. {
  165. static const unsigned TS_nCS = 1 << 11;
  166. lubbock_set_misc_wr(TS_nCS, (command == PXA2XX_CS_ASSERT) ? 0 : TS_nCS);
  167. }
  168. static struct pxa2xx_spi_chip ads_hw = {
  169. .tx_threshold = 1,
  170. .rx_threshold = 2,
  171. .cs_control = ads7846_cs,
  172. };
  173. static struct spi_board_info spi_board_info[] __initdata = { {
  174. .modalias = "ads7846",
  175. .platform_data = &ads_info,
  176. .controller_data = &ads_hw,
  177. .irq = LUBBOCK_BB_IRQ,
  178. .max_speed_hz = 120000 /* max sample rate at 3V */
  179. * 26 /* command + data + overhead */,
  180. .bus_num = 1,
  181. .chip_select = 0,
  182. },
  183. };
  184. static struct resource smc91x_resources[] = {
  185. [0] = {
  186. .name = "smc91x-regs",
  187. .start = 0x0c000c00,
  188. .end = 0x0c0fffff,
  189. .flags = IORESOURCE_MEM,
  190. },
  191. [1] = {
  192. .start = LUBBOCK_ETH_IRQ,
  193. .end = LUBBOCK_ETH_IRQ,
  194. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  195. },
  196. [2] = {
  197. .name = "smc91x-attrib",
  198. .start = 0x0e000000,
  199. .end = 0x0e0fffff,
  200. .flags = IORESOURCE_MEM,
  201. },
  202. };
  203. static struct smc91x_platdata lubbock_smc91x_info = {
  204. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT | SMC91X_IO_SHIFT_2,
  205. };
  206. static struct platform_device smc91x_device = {
  207. .name = "smc91x",
  208. .id = -1,
  209. .num_resources = ARRAY_SIZE(smc91x_resources),
  210. .resource = smc91x_resources,
  211. .dev = {
  212. .platform_data = &lubbock_smc91x_info,
  213. },
  214. };
  215. static struct resource flash_resources[] = {
  216. [0] = {
  217. .start = 0x00000000,
  218. .end = SZ_64M - 1,
  219. .flags = IORESOURCE_MEM,
  220. },
  221. [1] = {
  222. .start = 0x04000000,
  223. .end = 0x04000000 + SZ_64M - 1,
  224. .flags = IORESOURCE_MEM,
  225. },
  226. };
  227. static struct mtd_partition lubbock_partitions[] = {
  228. {
  229. .name = "Bootloader",
  230. .size = 0x00040000,
  231. .offset = 0,
  232. .mask_flags = MTD_WRITEABLE /* force read-only */
  233. },{
  234. .name = "Kernel",
  235. .size = 0x00100000,
  236. .offset = 0x00040000,
  237. },{
  238. .name = "Filesystem",
  239. .size = MTDPART_SIZ_FULL,
  240. .offset = 0x00140000
  241. }
  242. };
  243. static struct flash_platform_data lubbock_flash_data[2] = {
  244. {
  245. .map_name = "cfi_probe",
  246. .parts = lubbock_partitions,
  247. .nr_parts = ARRAY_SIZE(lubbock_partitions),
  248. }, {
  249. .map_name = "cfi_probe",
  250. .parts = NULL,
  251. .nr_parts = 0,
  252. }
  253. };
  254. static struct platform_device lubbock_flash_device[2] = {
  255. {
  256. .name = "pxa2xx-flash",
  257. .id = 0,
  258. .dev = {
  259. .platform_data = &lubbock_flash_data[0],
  260. },
  261. .resource = &flash_resources[0],
  262. .num_resources = 1,
  263. },
  264. {
  265. .name = "pxa2xx-flash",
  266. .id = 1,
  267. .dev = {
  268. .platform_data = &lubbock_flash_data[1],
  269. },
  270. .resource = &flash_resources[1],
  271. .num_resources = 1,
  272. },
  273. };
  274. static struct resource lubbock_cplds_resources[] = {
  275. [0] = {
  276. .start = LUBBOCK_FPGA_PHYS + 0xc0,
  277. .end = LUBBOCK_FPGA_PHYS + 0xe0 - 1,
  278. .flags = IORESOURCE_MEM,
  279. },
  280. [1] = {
  281. .start = PXA_GPIO_TO_IRQ(0),
  282. .end = PXA_GPIO_TO_IRQ(0),
  283. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  284. },
  285. [2] = {
  286. .start = LUBBOCK_IRQ(0),
  287. .end = LUBBOCK_IRQ(6),
  288. .flags = IORESOURCE_IRQ,
  289. },
  290. };
  291. static struct platform_device lubbock_cplds_device = {
  292. .name = "pxa_cplds_irqs",
  293. .id = -1,
  294. .resource = &lubbock_cplds_resources[0],
  295. .num_resources = 3,
  296. };
  297. static struct platform_device *devices[] __initdata = {
  298. &sa1111_device,
  299. &smc91x_device,
  300. &lubbock_flash_device[0],
  301. &lubbock_flash_device[1],
  302. &lubbock_cplds_device,
  303. };
  304. static struct pxafb_mode_info sharp_lm8v31_mode = {
  305. .pixclock = 270000,
  306. .xres = 640,
  307. .yres = 480,
  308. .bpp = 16,
  309. .hsync_len = 1,
  310. .left_margin = 3,
  311. .right_margin = 3,
  312. .vsync_len = 1,
  313. .upper_margin = 0,
  314. .lower_margin = 0,
  315. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  316. .cmap_greyscale = 0,
  317. };
  318. static struct pxafb_mach_info sharp_lm8v31 = {
  319. .modes = &sharp_lm8v31_mode,
  320. .num_modes = 1,
  321. .cmap_inverse = 0,
  322. .cmap_static = 0,
  323. .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
  324. LCD_AC_BIAS_FREQ(255),
  325. };
  326. #define MMC_POLL_RATE msecs_to_jiffies(1000)
  327. static void lubbock_mmc_poll(unsigned long);
  328. static irq_handler_t mmc_detect_int;
  329. static struct timer_list mmc_timer = {
  330. .function = lubbock_mmc_poll,
  331. };
  332. static void lubbock_mmc_poll(unsigned long data)
  333. {
  334. unsigned long flags;
  335. /* clear any previous irq state, then ... */
  336. local_irq_save(flags);
  337. LUB_IRQ_SET_CLR &= ~(1 << 0);
  338. local_irq_restore(flags);
  339. /* poll until mmc/sd card is removed */
  340. if (LUB_IRQ_SET_CLR & (1 << 0))
  341. mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
  342. else {
  343. (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data);
  344. enable_irq(LUBBOCK_SD_IRQ);
  345. }
  346. }
  347. static irqreturn_t lubbock_detect_int(int irq, void *data)
  348. {
  349. /* IRQ is level triggered; disable, and poll for removal */
  350. disable_irq(irq);
  351. mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
  352. return mmc_detect_int(irq, data);
  353. }
  354. static int lubbock_mci_init(struct device *dev,
  355. irq_handler_t detect_int,
  356. void *data)
  357. {
  358. /* detect card insert/eject */
  359. mmc_detect_int = detect_int;
  360. init_timer(&mmc_timer);
  361. mmc_timer.data = (unsigned long) data;
  362. return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
  363. 0, "lubbock-sd-detect", data);
  364. }
  365. static int lubbock_mci_get_ro(struct device *dev)
  366. {
  367. return (LUB_MISC_RD & (1 << 2)) != 0;
  368. }
  369. static void lubbock_mci_exit(struct device *dev, void *data)
  370. {
  371. free_irq(LUBBOCK_SD_IRQ, data);
  372. del_timer_sync(&mmc_timer);
  373. }
  374. static struct pxamci_platform_data lubbock_mci_platform_data = {
  375. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  376. .detect_delay_ms = 10,
  377. .init = lubbock_mci_init,
  378. .get_ro = lubbock_mci_get_ro,
  379. .exit = lubbock_mci_exit,
  380. .gpio_card_detect = -1,
  381. .gpio_card_ro = -1,
  382. .gpio_power = -1,
  383. };
  384. static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
  385. {
  386. unsigned long flags;
  387. local_irq_save(flags);
  388. if (mode & IR_SIRMODE) {
  389. LUB_MISC_WR &= ~(1 << 4);
  390. } else if (mode & IR_FIRMODE) {
  391. LUB_MISC_WR |= 1 << 4;
  392. }
  393. pxa2xx_transceiver_mode(dev, mode);
  394. local_irq_restore(flags);
  395. }
  396. static struct pxaficp_platform_data lubbock_ficp_platform_data = {
  397. .gpio_pwdown = -1,
  398. .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
  399. .transceiver_mode = lubbock_irda_transceiver_mode,
  400. };
  401. static void __init lubbock_init(void)
  402. {
  403. int flashboot = (LUB_CONF_SWITCHES & 1);
  404. pxa2xx_mfp_config(ARRAY_AND_SIZE(lubbock_pin_config));
  405. pxa_set_ffuart_info(NULL);
  406. pxa_set_btuart_info(NULL);
  407. pxa_set_stuart_info(NULL);
  408. clk_add_alias("SA1111_CLK", NULL, "GPIO11_CLK", NULL);
  409. pxa_set_udc_info(&udc_info);
  410. pxa_set_fb_info(NULL, &sharp_lm8v31);
  411. pxa_set_mci_info(&lubbock_mci_platform_data);
  412. pxa_set_ficp_info(&lubbock_ficp_platform_data);
  413. pxa_set_ac97_info(NULL);
  414. lubbock_flash_data[0].width = lubbock_flash_data[1].width =
  415. (__raw_readl(BOOT_DEF) & 1) ? 2 : 4;
  416. /* Compensate for the nROMBT switch which swaps the flash banks */
  417. printk(KERN_NOTICE "Lubbock configured to boot from %s (bank %d)\n",
  418. flashboot?"Flash":"ROM", flashboot);
  419. lubbock_flash_data[flashboot^1].name = "application-flash";
  420. lubbock_flash_data[flashboot].name = "boot-rom";
  421. (void) platform_add_devices(devices, ARRAY_SIZE(devices));
  422. pxa2xx_set_spi_info(1, &pxa_ssp_master_info);
  423. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  424. }
  425. static struct map_desc lubbock_io_desc[] __initdata = {
  426. { /* CPLD */
  427. .virtual = LUBBOCK_FPGA_VIRT,
  428. .pfn = __phys_to_pfn(LUBBOCK_FPGA_PHYS),
  429. .length = 0x00100000,
  430. .type = MT_DEVICE
  431. }
  432. };
  433. static void __init lubbock_map_io(void)
  434. {
  435. pxa25x_map_io();
  436. iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
  437. PCFR |= PCFR_OPDE;
  438. }
  439. /*
  440. * Driver for the 8 discrete LEDs available for general use:
  441. * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
  442. * so be sure to not monkey with them here.
  443. */
  444. #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
  445. struct lubbock_led {
  446. struct led_classdev cdev;
  447. u8 mask;
  448. };
  449. /*
  450. * The triggers lines up below will only be used if the
  451. * LED triggers are compiled in.
  452. */
  453. static const struct {
  454. const char *name;
  455. const char *trigger;
  456. } lubbock_leds[] = {
  457. { "lubbock:D28", "default-on", },
  458. { "lubbock:D27", "cpu0", },
  459. { "lubbock:D26", "heartbeat" },
  460. { "lubbock:D25", },
  461. { "lubbock:D24", },
  462. { "lubbock:D23", },
  463. { "lubbock:D22", },
  464. { "lubbock:D21", },
  465. };
  466. static void lubbock_led_set(struct led_classdev *cdev,
  467. enum led_brightness b)
  468. {
  469. struct lubbock_led *led = container_of(cdev,
  470. struct lubbock_led, cdev);
  471. u32 reg = LUB_DISC_BLNK_LED;
  472. if (b != LED_OFF)
  473. reg |= led->mask;
  474. else
  475. reg &= ~led->mask;
  476. LUB_DISC_BLNK_LED = reg;
  477. }
  478. static enum led_brightness lubbock_led_get(struct led_classdev *cdev)
  479. {
  480. struct lubbock_led *led = container_of(cdev,
  481. struct lubbock_led, cdev);
  482. u32 reg = LUB_DISC_BLNK_LED;
  483. return (reg & led->mask) ? LED_FULL : LED_OFF;
  484. }
  485. static int __init lubbock_leds_init(void)
  486. {
  487. int i;
  488. if (!machine_is_lubbock())
  489. return -ENODEV;
  490. /* All ON */
  491. LUB_DISC_BLNK_LED |= 0xff;
  492. for (i = 0; i < ARRAY_SIZE(lubbock_leds); i++) {
  493. struct lubbock_led *led;
  494. led = kzalloc(sizeof(*led), GFP_KERNEL);
  495. if (!led)
  496. break;
  497. led->cdev.name = lubbock_leds[i].name;
  498. led->cdev.brightness_set = lubbock_led_set;
  499. led->cdev.brightness_get = lubbock_led_get;
  500. led->cdev.default_trigger = lubbock_leds[i].trigger;
  501. led->mask = BIT(i);
  502. if (led_classdev_register(NULL, &led->cdev) < 0) {
  503. kfree(led);
  504. break;
  505. }
  506. }
  507. return 0;
  508. }
  509. /*
  510. * Since we may have triggers on any subsystem, defer registration
  511. * until after subsystem_init.
  512. */
  513. fs_initcall(lubbock_leds_init);
  514. #endif
  515. MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
  516. /* Maintainer: MontaVista Software Inc. */
  517. .map_io = lubbock_map_io,
  518. .nr_irqs = LUBBOCK_NR_IRQS,
  519. .init_irq = pxa25x_init_irq,
  520. .handle_irq = pxa25x_handle_irq,
  521. .init_time = pxa_timer_init,
  522. .init_machine = lubbock_init,
  523. .restart = pxa_restart,
  524. MACHINE_END