1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-pxa/lubbock.c
5 * Support for the Intel DBPXA250 Development Platform.
7 * Author: Nicolas Pitre
8 * Created: Jun 15, 2001
9 * Copyright: MontaVista Software Inc.
11 #include <linux/clkdev.h>
12 #include <linux/gpio.h>
13 #include <linux/gpio/gpio-reg.h>
14 #include <linux/gpio/machine.h>
15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
19 #include <linux/platform_device.h>
20 #include <linux/syscore_ops.h>
21 #include <linux/major.h>
23 #include <linux/interrupt.h>
24 #include <linux/mtd/mtd.h>
25 #include <linux/mtd/partitions.h>
26 #include <linux/smc91x.h>
27 #include <linux/slab.h>
28 #include <linux/leds.h>
30 #include <linux/spi/spi.h>
31 #include <linux/spi/ads7846.h>
32 #include <linux/spi/pxa2xx_spi.h>
34 #include <asm/setup.h>
35 #include <asm/memory.h>
36 #include <asm/mach-types.h>
38 #include <linux/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>
45 #include <asm/hardware/sa1111.h>
48 #include <linux/platform_data/asoc-pxa.h>
51 #include <linux/platform_data/irda-pxaficp.h>
52 #include <linux/platform_data/video-pxafb.h>
53 #include <linux/platform_data/mmc-pxamci.h>
60 static unsigned long lubbock_pin_config[] __initdata = {
61 GPIO15_nCS_1, /* CS1 - Flash */
62 GPIO78_nCS_2, /* CS2 - Baseboard FGPA */
63 GPIO79_nCS_3, /* CS3 - SMC ethernet */
64 GPIO80_nCS_4, /* CS4 - SA1111 */
73 GPIO29_AC97_SDATA_IN_0,
74 GPIO30_AC97_SDATA_OUT,
77 /* LCD - 16bpp DSTN */
78 GPIOxx_LCD_DSTN_16BPP,
106 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
109 #define LUB_HEXLED __LUB_REG(LUBBOCK_FPGA_PHYS + 0x010)
111 void lubbock_set_hexled(uint32_t value)
116 static struct gpio_chip *lubbock_misc_wr_gc;
118 static void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
120 unsigned long m = mask, v = set;
121 lubbock_misc_wr_gc->set_multiple(lubbock_misc_wr_gc, &m, &v);
124 static int lubbock_udc_is_connected(void)
126 return (LUB_MISC_RD & (1 << 9)) == 0;
129 static struct pxa2xx_udc_mach_info udc_info __initdata = {
130 .udc_is_connected = lubbock_udc_is_connected,
131 // no D+ pullup; lubbock can't connect/disconnect in software
134 static struct resource lubbock_udc_resources[] = {
135 DEFINE_RES_MEM(0x40600000, 0x10000),
136 DEFINE_RES_IRQ(IRQ_USB),
137 DEFINE_RES_IRQ(LUBBOCK_USB_IRQ),
138 DEFINE_RES_IRQ(LUBBOCK_USB_DISC_IRQ),
141 /* GPIOs for SA1111 PCMCIA */
142 static struct gpiod_lookup_table sa1111_pcmcia_gpio_table = {
145 { "sa1111", 0, "a0vpp", GPIO_ACTIVE_HIGH },
146 { "sa1111", 1, "a1vpp", GPIO_ACTIVE_HIGH },
147 { "sa1111", 2, "a0vcc", GPIO_ACTIVE_HIGH },
148 { "sa1111", 3, "a1vcc", GPIO_ACTIVE_HIGH },
149 { "lubbock", 14, "b0vcc", GPIO_ACTIVE_HIGH },
150 { "lubbock", 15, "b1vcc", GPIO_ACTIVE_HIGH },
155 static void lubbock_init_pcmcia(void)
159 gpiod_add_lookup_table(&sa1111_pcmcia_gpio_table);
161 /* Add an alias for the SA1111 PCMCIA clock */
162 clk = clk_get_sys("pxa2xx-pcmcia", NULL);
164 clkdev_create(clk, NULL, "1800");
169 static struct resource sa1111_resources[] = {
173 .flags = IORESOURCE_MEM,
176 .start = LUBBOCK_SA1111_IRQ,
177 .end = LUBBOCK_SA1111_IRQ,
178 .flags = IORESOURCE_IRQ,
182 static struct sa1111_platform_data sa1111_info = {
183 .irq_base = LUBBOCK_SA1111_IRQ_BASE,
184 .disable_devs = SA1111_DEVID_SAC,
187 static struct platform_device sa1111_device = {
190 .num_resources = ARRAY_SIZE(sa1111_resources),
191 .resource = sa1111_resources,
193 .platform_data = &sa1111_info,
197 /* ADS7846 is connected through SSP ... and if your board has J5 populated,
198 * you can select it to replace the ucb1400 by switching the touchscreen cable
199 * (to J5) and poking board registers (as done below). Else it's only useful
200 * for the temperature sensors.
202 static struct pxa2xx_spi_controller pxa_ssp_master_info = {
206 static int lubbock_ads7846_pendown_state(void)
208 /* TS_BUSY is bit 8 in LUB_MISC_RD, but pendown is irq-only */
212 static struct ads7846_platform_data ads_info = {
214 .vref_delay_usecs = 100, /* internal, no cap */
215 .get_pendown_state = lubbock_ads7846_pendown_state,
216 // .x_plate_ohms = 500, /* GUESS! */
217 // .y_plate_ohms = 500, /* GUESS! */
220 static struct gpiod_lookup_table ads7846_cs_gpios = {
223 GPIO_LOOKUP("lubbock", 11, "cs", GPIO_ACTIVE_LOW),
228 static struct pxa2xx_spi_chip ads_hw = {
233 static struct spi_board_info spi_board_info[] __initdata = { {
234 .modalias = "ads7846",
235 .platform_data = &ads_info,
236 .controller_data = &ads_hw,
237 .irq = LUBBOCK_BB_IRQ,
238 .max_speed_hz = 120000 /* max sample rate at 3V */
239 * 26 /* command + data + overhead */,
245 static struct resource smc91x_resources[] = {
247 .name = "smc91x-regs",
250 .flags = IORESOURCE_MEM,
253 .start = LUBBOCK_ETH_IRQ,
254 .end = LUBBOCK_ETH_IRQ,
255 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
258 .name = "smc91x-attrib",
261 .flags = IORESOURCE_MEM,
265 static struct smc91x_platdata lubbock_smc91x_info = {
266 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT | SMC91X_IO_SHIFT_2,
269 static struct platform_device smc91x_device = {
272 .num_resources = ARRAY_SIZE(smc91x_resources),
273 .resource = smc91x_resources,
275 .platform_data = &lubbock_smc91x_info,
279 static struct resource flash_resources[] = {
283 .flags = IORESOURCE_MEM,
287 .end = 0x04000000 + SZ_64M - 1,
288 .flags = IORESOURCE_MEM,
292 static struct mtd_partition lubbock_partitions[] = {
294 .name = "Bootloader",
297 .mask_flags = MTD_WRITEABLE /* force read-only */
301 .offset = 0x00040000,
303 .name = "Filesystem",
304 .size = MTDPART_SIZ_FULL,
309 static struct flash_platform_data lubbock_flash_data[2] = {
311 .map_name = "cfi_probe",
312 .parts = lubbock_partitions,
313 .nr_parts = ARRAY_SIZE(lubbock_partitions),
315 .map_name = "cfi_probe",
321 static struct platform_device lubbock_flash_device[2] = {
323 .name = "pxa2xx-flash",
326 .platform_data = &lubbock_flash_data[0],
328 .resource = &flash_resources[0],
332 .name = "pxa2xx-flash",
335 .platform_data = &lubbock_flash_data[1],
337 .resource = &flash_resources[1],
342 static struct resource lubbock_cplds_resources[] = {
344 .start = LUBBOCK_FPGA_PHYS + 0xc0,
345 .end = LUBBOCK_FPGA_PHYS + 0xe0 - 1,
346 .flags = IORESOURCE_MEM,
349 .start = PXA_GPIO_TO_IRQ(0),
350 .end = PXA_GPIO_TO_IRQ(0),
351 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
354 .start = LUBBOCK_IRQ(0),
355 .end = LUBBOCK_IRQ(6),
356 .flags = IORESOURCE_IRQ,
360 static struct platform_device lubbock_cplds_device = {
361 .name = "pxa_cplds_irqs",
363 .resource = &lubbock_cplds_resources[0],
368 static struct platform_device *devices[] __initdata = {
371 &lubbock_flash_device[0],
372 &lubbock_flash_device[1],
373 &lubbock_cplds_device,
376 static struct pxafb_mode_info sharp_lm8v31_mode = {
387 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
391 static struct pxafb_mach_info sharp_lm8v31 = {
392 .modes = &sharp_lm8v31_mode,
396 .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
397 LCD_AC_BIAS_FREQ(255),
400 #define MMC_POLL_RATE msecs_to_jiffies(1000)
402 static irq_handler_t mmc_detect_int;
403 static void *mmc_detect_int_data;
404 static struct timer_list mmc_timer;
406 static void lubbock_mmc_poll(struct timer_list *unused)
410 /* clear any previous irq state, then ... */
411 local_irq_save(flags);
412 LUB_IRQ_SET_CLR &= ~(1 << 0);
413 local_irq_restore(flags);
415 /* poll until mmc/sd card is removed */
416 if (LUB_IRQ_SET_CLR & (1 << 0))
417 mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
419 (void) mmc_detect_int(LUBBOCK_SD_IRQ, mmc_detect_int_data);
420 enable_irq(LUBBOCK_SD_IRQ);
424 static irqreturn_t lubbock_detect_int(int irq, void *data)
426 /* IRQ is level triggered; disable, and poll for removal */
428 mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
430 return mmc_detect_int(irq, data);
433 static int lubbock_mci_init(struct device *dev,
434 irq_handler_t detect_int,
437 /* detect card insert/eject */
438 mmc_detect_int = detect_int;
439 mmc_detect_int_data = data;
440 timer_setup(&mmc_timer, lubbock_mmc_poll, 0);
441 return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
442 0, "lubbock-sd-detect", data);
445 static int lubbock_mci_get_ro(struct device *dev)
447 return (LUB_MISC_RD & (1 << 2)) != 0;
450 static void lubbock_mci_exit(struct device *dev, void *data)
452 free_irq(LUBBOCK_SD_IRQ, data);
453 del_timer_sync(&mmc_timer);
456 static struct pxamci_platform_data lubbock_mci_platform_data = {
457 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
458 .detect_delay_ms = 10,
459 .init = lubbock_mci_init,
460 .get_ro = lubbock_mci_get_ro,
461 .exit = lubbock_mci_exit,
464 static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
468 local_irq_save(flags);
469 if (mode & IR_SIRMODE) {
470 lubbock_set_misc_wr(BIT(4), 0);
471 } else if (mode & IR_FIRMODE) {
472 lubbock_set_misc_wr(BIT(4), BIT(4));
474 pxa2xx_transceiver_mode(dev, mode);
475 local_irq_restore(flags);
478 static struct pxaficp_platform_data lubbock_ficp_platform_data = {
480 .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
481 .transceiver_mode = lubbock_irda_transceiver_mode,
484 static void __init lubbock_init(void)
486 int flashboot = (LUB_CONF_SWITCHES & 1);
488 pxa2xx_mfp_config(ARRAY_AND_SIZE(lubbock_pin_config));
490 lubbock_misc_wr_gc = gpio_reg_init(NULL, (void *)&LUB_MISC_WR,
491 -1, 16, "lubbock", 0, LUB_MISC_WR,
493 if (IS_ERR(lubbock_misc_wr_gc)) {
494 pr_err("Lubbock: unable to register lubbock GPIOs: %ld\n",
495 PTR_ERR(lubbock_misc_wr_gc));
496 lubbock_misc_wr_gc = NULL;
499 pxa_set_ffuart_info(NULL);
500 pxa_set_btuart_info(NULL);
501 pxa_set_stuart_info(NULL);
503 lubbock_init_pcmcia();
505 clk_add_alias("SA1111_CLK", NULL, "GPIO11_CLK", NULL);
506 /* lubbock has two extra IRQs */
507 pxa25x_device_udc.resource = lubbock_udc_resources;
508 pxa25x_device_udc.num_resources = ARRAY_SIZE(lubbock_udc_resources);
509 pxa_set_udc_info(&udc_info);
510 pxa_set_fb_info(NULL, &sharp_lm8v31);
511 pxa_set_mci_info(&lubbock_mci_platform_data);
512 pxa_set_ficp_info(&lubbock_ficp_platform_data);
513 pxa_set_ac97_info(NULL);
515 lubbock_flash_data[0].width = lubbock_flash_data[1].width =
516 (__raw_readl(BOOT_DEF) & 1) ? 2 : 4;
517 /* Compensate for the nROMBT switch which swaps the flash banks */
518 printk(KERN_NOTICE "Lubbock configured to boot from %s (bank %d)\n",
519 flashboot?"Flash":"ROM", flashboot);
521 lubbock_flash_data[flashboot^1].name = "application-flash";
522 lubbock_flash_data[flashboot].name = "boot-rom";
523 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
525 gpiod_add_lookup_table(&ads7846_cs_gpios);
527 pxa2xx_set_spi_info(1, &pxa_ssp_master_info);
528 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
531 static struct map_desc lubbock_io_desc[] __initdata = {
533 .virtual = LUBBOCK_FPGA_VIRT,
534 .pfn = __phys_to_pfn(LUBBOCK_FPGA_PHYS),
535 .length = 0x00100000,
540 static void __init lubbock_map_io(void)
543 iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
549 * Driver for the 8 discrete LEDs available for general use:
550 * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
551 * so be sure to not monkey with them here.
554 #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
556 struct led_classdev cdev;
561 * The triggers lines up below will only be used if the
562 * LED triggers are compiled in.
564 static const struct {
568 { "lubbock:D28", "default-on", },
569 { "lubbock:D27", "cpu0", },
570 { "lubbock:D26", "heartbeat" },
578 static void lubbock_led_set(struct led_classdev *cdev,
579 enum led_brightness b)
581 struct lubbock_led *led = container_of(cdev,
582 struct lubbock_led, cdev);
583 u32 reg = LUB_DISC_BLNK_LED;
590 LUB_DISC_BLNK_LED = reg;
593 static enum led_brightness lubbock_led_get(struct led_classdev *cdev)
595 struct lubbock_led *led = container_of(cdev,
596 struct lubbock_led, cdev);
597 u32 reg = LUB_DISC_BLNK_LED;
599 return (reg & led->mask) ? LED_FULL : LED_OFF;
602 static int __init lubbock_leds_init(void)
606 if (!machine_is_lubbock())
610 LUB_DISC_BLNK_LED |= 0xff;
611 for (i = 0; i < ARRAY_SIZE(lubbock_leds); i++) {
612 struct lubbock_led *led;
614 led = kzalloc(sizeof(*led), GFP_KERNEL);
618 led->cdev.name = lubbock_leds[i].name;
619 led->cdev.brightness_set = lubbock_led_set;
620 led->cdev.brightness_get = lubbock_led_get;
621 led->cdev.default_trigger = lubbock_leds[i].trigger;
624 if (led_classdev_register(NULL, &led->cdev) < 0) {
634 * Since we may have triggers on any subsystem, defer registration
635 * until after subsystem_init.
637 fs_initcall(lubbock_leds_init);
640 MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
641 /* Maintainer: MontaVista Software Inc. */
642 .map_io = lubbock_map_io,
643 .nr_irqs = LUBBOCK_NR_IRQS,
644 .init_irq = pxa25x_init_irq,
645 .handle_irq = pxa25x_handle_irq,
646 .init_time = pxa_timer_init,
647 .init_machine = lubbock_init,
648 .restart = pxa_restart,