0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/clkdev.h>
0012 #include <linux/gpio.h>
0013 #include <linux/gpio/gpio-reg.h>
0014 #include <linux/gpio/machine.h>
0015 #include <linux/module.h>
0016 #include <linux/kernel.h>
0017 #include <linux/init.h>
0018 #include <linux/io.h>
0019 #include <linux/platform_device.h>
0020 #include <linux/syscore_ops.h>
0021 #include <linux/major.h>
0022 #include <linux/fb.h>
0023 #include <linux/interrupt.h>
0024 #include <linux/mtd/mtd.h>
0025 #include <linux/mtd/partitions.h>
0026 #include <linux/smc91x.h>
0027 #include <linux/slab.h>
0028 #include <linux/leds.h>
0029
0030 #include <linux/spi/spi.h>
0031 #include <linux/spi/ads7846.h>
0032 #include <linux/spi/pxa2xx_spi.h>
0033
0034 #include <asm/setup.h>
0035 #include <asm/memory.h>
0036 #include <asm/mach-types.h>
0037 #include <asm/irq.h>
0038 #include <linux/sizes.h>
0039
0040 #include <asm/mach/arch.h>
0041 #include <asm/mach/map.h>
0042 #include <asm/mach/irq.h>
0043 #include <asm/mach/flash.h>
0044
0045 #include <asm/hardware/sa1111.h>
0046
0047 #include "pxa25x.h"
0048 #include <linux/platform_data/asoc-pxa.h>
0049 #include "lubbock.h"
0050 #include "udc.h"
0051 #include <linux/platform_data/irda-pxaficp.h>
0052 #include <linux/platform_data/video-pxafb.h>
0053 #include <linux/platform_data/mmc-pxamci.h>
0054 #include "pm.h"
0055 #include "smemc.h"
0056
0057 #include "generic.h"
0058 #include "devices.h"
0059
0060 static unsigned long lubbock_pin_config[] __initdata = {
0061 GPIO15_nCS_1,
0062 GPIO78_nCS_2,
0063 GPIO79_nCS_3,
0064 GPIO80_nCS_4,
0065
0066
0067 GPIO23_SSP1_SCLK,
0068 GPIO25_SSP1_TXD,
0069 GPIO26_SSP1_RXD,
0070
0071
0072 GPIO28_AC97_BITCLK,
0073 GPIO29_AC97_SDATA_IN_0,
0074 GPIO30_AC97_SDATA_OUT,
0075 GPIO31_AC97_SYNC,
0076
0077
0078 GPIOxx_LCD_DSTN_16BPP,
0079
0080
0081 GPIO42_BTUART_RXD,
0082 GPIO43_BTUART_TXD,
0083 GPIO44_BTUART_CTS,
0084 GPIO45_BTUART_RTS,
0085
0086
0087 GPIO48_nPOE,
0088 GPIO49_nPWE,
0089 GPIO50_nPIOR,
0090 GPIO51_nPIOW,
0091 GPIO52_nPCE_1,
0092 GPIO53_nPCE_2,
0093 GPIO54_nPSKTSEL,
0094 GPIO55_nPREG,
0095 GPIO56_nPWAIT,
0096 GPIO57_nIOIS16,
0097
0098
0099 GPIO6_MMC_CLK,
0100 GPIO8_MMC_CS0,
0101
0102
0103 GPIO11_3_6MHz,
0104
0105
0106 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
0107 };
0108
0109 #define LUB_HEXLED __LUB_REG(LUBBOCK_FPGA_PHYS + 0x010)
0110
0111 void lubbock_set_hexled(uint32_t value)
0112 {
0113 LUB_HEXLED = value;
0114 }
0115
0116 static struct gpio_chip *lubbock_misc_wr_gc;
0117
0118 static void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
0119 {
0120 unsigned long m = mask, v = set;
0121 lubbock_misc_wr_gc->set_multiple(lubbock_misc_wr_gc, &m, &v);
0122 }
0123
0124 static int lubbock_udc_is_connected(void)
0125 {
0126 return (LUB_MISC_RD & (1 << 9)) == 0;
0127 }
0128
0129 static struct pxa2xx_udc_mach_info udc_info __initdata = {
0130 .udc_is_connected = lubbock_udc_is_connected,
0131
0132 };
0133
0134 static struct resource lubbock_udc_resources[] = {
0135 DEFINE_RES_MEM(0x40600000, 0x10000),
0136 DEFINE_RES_IRQ(IRQ_USB),
0137 DEFINE_RES_IRQ(LUBBOCK_USB_IRQ),
0138 DEFINE_RES_IRQ(LUBBOCK_USB_DISC_IRQ),
0139 };
0140
0141
0142 static struct gpiod_lookup_table sa1111_pcmcia_gpio_table = {
0143 .dev_id = "1800",
0144 .table = {
0145 { "sa1111", 0, "a0vpp", GPIO_ACTIVE_HIGH },
0146 { "sa1111", 1, "a1vpp", GPIO_ACTIVE_HIGH },
0147 { "sa1111", 2, "a0vcc", GPIO_ACTIVE_HIGH },
0148 { "sa1111", 3, "a1vcc", GPIO_ACTIVE_HIGH },
0149 { "lubbock", 14, "b0vcc", GPIO_ACTIVE_HIGH },
0150 { "lubbock", 15, "b1vcc", GPIO_ACTIVE_HIGH },
0151 { },
0152 },
0153 };
0154
0155 static void lubbock_init_pcmcia(void)
0156 {
0157 struct clk *clk;
0158
0159 gpiod_add_lookup_table(&sa1111_pcmcia_gpio_table);
0160
0161
0162 clk = clk_get_sys("pxa2xx-pcmcia", NULL);
0163 if (!IS_ERR(clk)) {
0164 clkdev_create(clk, NULL, "1800");
0165 clk_put(clk);
0166 }
0167 }
0168
0169 static struct resource sa1111_resources[] = {
0170 [0] = {
0171 .start = 0x10000000,
0172 .end = 0x10001fff,
0173 .flags = IORESOURCE_MEM,
0174 },
0175 [1] = {
0176 .start = LUBBOCK_SA1111_IRQ,
0177 .end = LUBBOCK_SA1111_IRQ,
0178 .flags = IORESOURCE_IRQ,
0179 },
0180 };
0181
0182 static struct sa1111_platform_data sa1111_info = {
0183 .irq_base = LUBBOCK_SA1111_IRQ_BASE,
0184 .disable_devs = SA1111_DEVID_SAC,
0185 };
0186
0187 static struct platform_device sa1111_device = {
0188 .name = "sa1111",
0189 .id = -1,
0190 .num_resources = ARRAY_SIZE(sa1111_resources),
0191 .resource = sa1111_resources,
0192 .dev = {
0193 .platform_data = &sa1111_info,
0194 },
0195 };
0196
0197
0198
0199
0200
0201
0202 static struct pxa2xx_spi_controller pxa_ssp_master_info = {
0203 .num_chipselect = 1,
0204 };
0205
0206 static int lubbock_ads7846_pendown_state(void)
0207 {
0208
0209 return 0;
0210 }
0211
0212 static struct ads7846_platform_data ads_info = {
0213 .model = 7846,
0214 .vref_delay_usecs = 100,
0215 .get_pendown_state = lubbock_ads7846_pendown_state,
0216
0217
0218 };
0219
0220 static struct gpiod_lookup_table ads7846_cs_gpios = {
0221 .dev_id = "ads7846",
0222 .table = {
0223 GPIO_LOOKUP("lubbock", 11, "cs", GPIO_ACTIVE_LOW),
0224 {}
0225 },
0226 };
0227
0228 static struct pxa2xx_spi_chip ads_hw = {
0229 .tx_threshold = 1,
0230 .rx_threshold = 2,
0231 };
0232
0233 static struct spi_board_info spi_board_info[] __initdata = { {
0234 .modalias = "ads7846",
0235 .platform_data = &ads_info,
0236 .controller_data = &ads_hw,
0237 .irq = LUBBOCK_BB_IRQ,
0238 .max_speed_hz = 120000
0239 * 26 ,
0240 .bus_num = 1,
0241 .chip_select = 0,
0242 },
0243 };
0244
0245 static struct resource smc91x_resources[] = {
0246 [0] = {
0247 .name = "smc91x-regs",
0248 .start = 0x0c000c00,
0249 .end = 0x0c0fffff,
0250 .flags = IORESOURCE_MEM,
0251 },
0252 [1] = {
0253 .start = LUBBOCK_ETH_IRQ,
0254 .end = LUBBOCK_ETH_IRQ,
0255 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
0256 },
0257 [2] = {
0258 .name = "smc91x-attrib",
0259 .start = 0x0e000000,
0260 .end = 0x0e0fffff,
0261 .flags = IORESOURCE_MEM,
0262 },
0263 };
0264
0265 static struct smc91x_platdata lubbock_smc91x_info = {
0266 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT | SMC91X_IO_SHIFT_2,
0267 };
0268
0269 static struct platform_device smc91x_device = {
0270 .name = "smc91x",
0271 .id = -1,
0272 .num_resources = ARRAY_SIZE(smc91x_resources),
0273 .resource = smc91x_resources,
0274 .dev = {
0275 .platform_data = &lubbock_smc91x_info,
0276 },
0277 };
0278
0279 static struct resource flash_resources[] = {
0280 [0] = {
0281 .start = 0x00000000,
0282 .end = SZ_64M - 1,
0283 .flags = IORESOURCE_MEM,
0284 },
0285 [1] = {
0286 .start = 0x04000000,
0287 .end = 0x04000000 + SZ_64M - 1,
0288 .flags = IORESOURCE_MEM,
0289 },
0290 };
0291
0292 static struct mtd_partition lubbock_partitions[] = {
0293 {
0294 .name = "Bootloader",
0295 .size = 0x00040000,
0296 .offset = 0,
0297 .mask_flags = MTD_WRITEABLE
0298 },{
0299 .name = "Kernel",
0300 .size = 0x00100000,
0301 .offset = 0x00040000,
0302 },{
0303 .name = "Filesystem",
0304 .size = MTDPART_SIZ_FULL,
0305 .offset = 0x00140000
0306 }
0307 };
0308
0309 static struct flash_platform_data lubbock_flash_data[2] = {
0310 {
0311 .map_name = "cfi_probe",
0312 .parts = lubbock_partitions,
0313 .nr_parts = ARRAY_SIZE(lubbock_partitions),
0314 }, {
0315 .map_name = "cfi_probe",
0316 .parts = NULL,
0317 .nr_parts = 0,
0318 }
0319 };
0320
0321 static struct platform_device lubbock_flash_device[2] = {
0322 {
0323 .name = "pxa2xx-flash",
0324 .id = 0,
0325 .dev = {
0326 .platform_data = &lubbock_flash_data[0],
0327 },
0328 .resource = &flash_resources[0],
0329 .num_resources = 1,
0330 },
0331 {
0332 .name = "pxa2xx-flash",
0333 .id = 1,
0334 .dev = {
0335 .platform_data = &lubbock_flash_data[1],
0336 },
0337 .resource = &flash_resources[1],
0338 .num_resources = 1,
0339 },
0340 };
0341
0342 static struct resource lubbock_cplds_resources[] = {
0343 [0] = {
0344 .start = LUBBOCK_FPGA_PHYS + 0xc0,
0345 .end = LUBBOCK_FPGA_PHYS + 0xe0 - 1,
0346 .flags = IORESOURCE_MEM,
0347 },
0348 [1] = {
0349 .start = PXA_GPIO_TO_IRQ(0),
0350 .end = PXA_GPIO_TO_IRQ(0),
0351 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
0352 },
0353 [2] = {
0354 .start = LUBBOCK_IRQ(0),
0355 .end = LUBBOCK_IRQ(6),
0356 .flags = IORESOURCE_IRQ,
0357 },
0358 };
0359
0360 static struct platform_device lubbock_cplds_device = {
0361 .name = "pxa_cplds_irqs",
0362 .id = -1,
0363 .resource = &lubbock_cplds_resources[0],
0364 .num_resources = 3,
0365 };
0366
0367
0368 static struct platform_device *devices[] __initdata = {
0369 &sa1111_device,
0370 &smc91x_device,
0371 &lubbock_flash_device[0],
0372 &lubbock_flash_device[1],
0373 &lubbock_cplds_device,
0374 };
0375
0376 static struct pxafb_mode_info sharp_lm8v31_mode = {
0377 .pixclock = 270000,
0378 .xres = 640,
0379 .yres = 480,
0380 .bpp = 16,
0381 .hsync_len = 1,
0382 .left_margin = 3,
0383 .right_margin = 3,
0384 .vsync_len = 1,
0385 .upper_margin = 0,
0386 .lower_margin = 0,
0387 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
0388 .cmap_greyscale = 0,
0389 };
0390
0391 static struct pxafb_mach_info sharp_lm8v31 = {
0392 .modes = &sharp_lm8v31_mode,
0393 .num_modes = 1,
0394 .cmap_inverse = 0,
0395 .cmap_static = 0,
0396 .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
0397 LCD_AC_BIAS_FREQ(255),
0398 };
0399
0400 #define MMC_POLL_RATE msecs_to_jiffies(1000)
0401
0402 static irq_handler_t mmc_detect_int;
0403 static void *mmc_detect_int_data;
0404 static struct timer_list mmc_timer;
0405
0406 static void lubbock_mmc_poll(struct timer_list *unused)
0407 {
0408 unsigned long flags;
0409
0410
0411 local_irq_save(flags);
0412 LUB_IRQ_SET_CLR &= ~(1 << 0);
0413 local_irq_restore(flags);
0414
0415
0416 if (LUB_IRQ_SET_CLR & (1 << 0))
0417 mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
0418 else {
0419 (void) mmc_detect_int(LUBBOCK_SD_IRQ, mmc_detect_int_data);
0420 enable_irq(LUBBOCK_SD_IRQ);
0421 }
0422 }
0423
0424 static irqreturn_t lubbock_detect_int(int irq, void *data)
0425 {
0426
0427 disable_irq(irq);
0428 mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
0429
0430 return mmc_detect_int(irq, data);
0431 }
0432
0433 static int lubbock_mci_init(struct device *dev,
0434 irq_handler_t detect_int,
0435 void *data)
0436 {
0437
0438 mmc_detect_int = detect_int;
0439 mmc_detect_int_data = data;
0440 timer_setup(&mmc_timer, lubbock_mmc_poll, 0);
0441 return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
0442 0, "lubbock-sd-detect", data);
0443 }
0444
0445 static int lubbock_mci_get_ro(struct device *dev)
0446 {
0447 return (LUB_MISC_RD & (1 << 2)) != 0;
0448 }
0449
0450 static void lubbock_mci_exit(struct device *dev, void *data)
0451 {
0452 free_irq(LUBBOCK_SD_IRQ, data);
0453 del_timer_sync(&mmc_timer);
0454 }
0455
0456 static struct pxamci_platform_data lubbock_mci_platform_data = {
0457 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
0458 .detect_delay_ms = 10,
0459 .init = lubbock_mci_init,
0460 .get_ro = lubbock_mci_get_ro,
0461 .exit = lubbock_mci_exit,
0462 };
0463
0464 static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
0465 {
0466 unsigned long flags;
0467
0468 local_irq_save(flags);
0469 if (mode & IR_SIRMODE) {
0470 lubbock_set_misc_wr(BIT(4), 0);
0471 } else if (mode & IR_FIRMODE) {
0472 lubbock_set_misc_wr(BIT(4), BIT(4));
0473 }
0474 pxa2xx_transceiver_mode(dev, mode);
0475 local_irq_restore(flags);
0476 }
0477
0478 static struct pxaficp_platform_data lubbock_ficp_platform_data = {
0479 .gpio_pwdown = -1,
0480 .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
0481 .transceiver_mode = lubbock_irda_transceiver_mode,
0482 };
0483
0484 static void __init lubbock_init(void)
0485 {
0486 int flashboot = (LUB_CONF_SWITCHES & 1);
0487
0488 pxa2xx_mfp_config(ARRAY_AND_SIZE(lubbock_pin_config));
0489
0490 lubbock_misc_wr_gc = gpio_reg_init(NULL, (void *)&LUB_MISC_WR,
0491 -1, 16, "lubbock", 0, LUB_MISC_WR,
0492 NULL, NULL, NULL);
0493 if (IS_ERR(lubbock_misc_wr_gc)) {
0494 pr_err("Lubbock: unable to register lubbock GPIOs: %ld\n",
0495 PTR_ERR(lubbock_misc_wr_gc));
0496 lubbock_misc_wr_gc = NULL;
0497 }
0498
0499 pxa_set_ffuart_info(NULL);
0500 pxa_set_btuart_info(NULL);
0501 pxa_set_stuart_info(NULL);
0502
0503 lubbock_init_pcmcia();
0504
0505 clk_add_alias("SA1111_CLK", NULL, "GPIO11_CLK", NULL);
0506
0507 pxa25x_device_udc.resource = lubbock_udc_resources;
0508 pxa25x_device_udc.num_resources = ARRAY_SIZE(lubbock_udc_resources);
0509 pxa_set_udc_info(&udc_info);
0510 pxa_set_fb_info(NULL, &sharp_lm8v31);
0511 pxa_set_mci_info(&lubbock_mci_platform_data);
0512 pxa_set_ficp_info(&lubbock_ficp_platform_data);
0513 pxa_set_ac97_info(NULL);
0514
0515 lubbock_flash_data[0].width = lubbock_flash_data[1].width =
0516 (__raw_readl(BOOT_DEF) & 1) ? 2 : 4;
0517
0518 printk(KERN_NOTICE "Lubbock configured to boot from %s (bank %d)\n",
0519 flashboot?"Flash":"ROM", flashboot);
0520
0521 lubbock_flash_data[flashboot^1].name = "application-flash";
0522 lubbock_flash_data[flashboot].name = "boot-rom";
0523 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
0524
0525 gpiod_add_lookup_table(&ads7846_cs_gpios);
0526
0527 pxa2xx_set_spi_info(1, &pxa_ssp_master_info);
0528 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
0529 }
0530
0531 static struct map_desc lubbock_io_desc[] __initdata = {
0532 {
0533 .virtual = LUBBOCK_FPGA_VIRT,
0534 .pfn = __phys_to_pfn(LUBBOCK_FPGA_PHYS),
0535 .length = 0x00100000,
0536 .type = MT_DEVICE
0537 }
0538 };
0539
0540 static void __init lubbock_map_io(void)
0541 {
0542 pxa25x_map_io();
0543 iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
0544
0545 PCFR |= PCFR_OPDE;
0546 }
0547
0548
0549
0550
0551
0552
0553
0554 #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
0555 struct lubbock_led {
0556 struct led_classdev cdev;
0557 u8 mask;
0558 };
0559
0560
0561
0562
0563
0564 static const struct {
0565 const char *name;
0566 const char *trigger;
0567 } lubbock_leds[] = {
0568 { "lubbock:D28", "default-on", },
0569 { "lubbock:D27", "cpu0", },
0570 { "lubbock:D26", "heartbeat" },
0571 { "lubbock:D25", },
0572 { "lubbock:D24", },
0573 { "lubbock:D23", },
0574 { "lubbock:D22", },
0575 { "lubbock:D21", },
0576 };
0577
0578 static void lubbock_led_set(struct led_classdev *cdev,
0579 enum led_brightness b)
0580 {
0581 struct lubbock_led *led = container_of(cdev,
0582 struct lubbock_led, cdev);
0583 u32 reg = LUB_DISC_BLNK_LED;
0584
0585 if (b != LED_OFF)
0586 reg |= led->mask;
0587 else
0588 reg &= ~led->mask;
0589
0590 LUB_DISC_BLNK_LED = reg;
0591 }
0592
0593 static enum led_brightness lubbock_led_get(struct led_classdev *cdev)
0594 {
0595 struct lubbock_led *led = container_of(cdev,
0596 struct lubbock_led, cdev);
0597 u32 reg = LUB_DISC_BLNK_LED;
0598
0599 return (reg & led->mask) ? LED_FULL : LED_OFF;
0600 }
0601
0602 static int __init lubbock_leds_init(void)
0603 {
0604 int i;
0605
0606 if (!machine_is_lubbock())
0607 return -ENODEV;
0608
0609
0610 LUB_DISC_BLNK_LED |= 0xff;
0611 for (i = 0; i < ARRAY_SIZE(lubbock_leds); i++) {
0612 struct lubbock_led *led;
0613
0614 led = kzalloc(sizeof(*led), GFP_KERNEL);
0615 if (!led)
0616 break;
0617
0618 led->cdev.name = lubbock_leds[i].name;
0619 led->cdev.brightness_set = lubbock_led_set;
0620 led->cdev.brightness_get = lubbock_led_get;
0621 led->cdev.default_trigger = lubbock_leds[i].trigger;
0622 led->mask = BIT(i);
0623
0624 if (led_classdev_register(NULL, &led->cdev) < 0) {
0625 kfree(led);
0626 break;
0627 }
0628 }
0629
0630 return 0;
0631 }
0632
0633
0634
0635
0636
0637 fs_initcall(lubbock_leds_init);
0638 #endif
0639
0640 MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
0641
0642 .map_io = lubbock_map_io,
0643 .nr_irqs = LUBBOCK_NR_IRQS,
0644 .init_irq = pxa25x_init_irq,
0645 .handle_irq = pxa25x_handle_irq,
0646 .init_time = pxa_timer_init,
0647 .init_machine = lubbock_init,
0648 .restart = pxa_restart,
0649 MACHINE_END