lubbock.c 14 KB

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