2 +++ b/arch/arm/mach-cns3xxx/laguna.c
5 + * Gateworks Corporation Laguna Platform
7 + * Copyright 2000 Deep Blue Solutions Ltd
8 + * Copyright 2008 ARM Limited
9 + * Copyright 2008 Cavium Networks
11 + * Copyright 2010 MontaVista Software, LLC.
12 + * Anton Vorontsov <avorontsov@mvista.com>
13 + * Copyright 2011 Gateworks Corporation
14 + * Chris Lang <clang@gateworks.com>
16 + * This file is free software; you can redistribute it and/or modify
17 + * it under the terms of the GNU General Public License, Version 2, as
18 + * published by the Free Software Foundation.
21 +#include <linux/init.h>
22 +#include <linux/kernel.h>
23 +#include <linux/compiler.h>
24 +#include <linux/io.h>
25 +#include <linux/dma-mapping.h>
26 +#include <linux/serial_core.h>
27 +#include <linux/serial_8250.h>
28 +#include <linux/platform_device.h>
29 +#include <linux/mtd/mtd.h>
30 +#include <linux/mtd/physmap.h>
31 +#include <linux/mtd/partitions.h>
32 +#include <linux/leds.h>
33 +#include <linux/i2c.h>
34 +#include <linux/i2c/at24.h>
35 +#include <linux/i2c/pca953x.h>
36 +#include <linux/spi/spi.h>
37 +#include <linux/spi/flash.h>
38 +#include <linux/if_ether.h>
39 +#include <asm/setup.h>
40 +#include <asm/mach-types.h>
41 +#include <asm/mach/arch.h>
42 +#include <asm/mach/map.h>
43 +#include <asm/mach/time.h>
44 +#include <mach/hardware.h>
45 +#include <mach/cns3xxx.h>
46 +#include <mach/irqs.h>
52 +#define ETH0_LOAD BIT(0)
53 +#define ETH1_LOAD BIT(1)
54 +#define ETH2_LOAD BIT(2)
55 +#define SATA0_LOAD BIT(3)
56 +#define SATA1_LOAD BIT(4)
57 +#define PCM_LOAD BIT(5)
58 +#define I2S_LOAD BIT(6)
59 +#define SPI0_LOAD BIT(7)
60 +#define SPI1_LOAD BIT(8)
61 +#define PCIE0_LOAD BIT(9)
62 +#define PCIE1_LOAD BIT(10)
63 +#define USB0_LOAD BIT(11)
64 +#define USB1_LOAD BIT(12)
65 +#define USB1_ROUTE BIT(13)
66 +#define SD_LOAD BIT(14)
67 +#define UART0_LOAD BIT(15)
68 +#define UART1_LOAD BIT(16)
69 +#define UART2_LOAD BIT(17)
70 +#define MPCI0_LOAD BIT(18)
71 +#define MPCI1_LOAD BIT(19)
72 +#define MPCI2_LOAD BIT(20)
73 +#define MPCI3_LOAD BIT(21)
74 +#define FP_BUT_LOAD BIT(22)
75 +#define FP_BUT_HEADER_LOAD BIT(23)
76 +#define FP_LED_LOAD BIT(24)
77 +#define FP_LED_HEADER_LOAD BIT(25)
78 +#define FP_TAMPER_LOAD BIT(26)
79 +#define HEADER_33V_LOAD BIT(27)
80 +#define SATA_POWER_LOAD BIT(28)
81 +#define FP_POWER_LOAD BIT(29)
82 +#define GPIO_HEADER_LOAD BIT(30)
83 +#define GSP_BAT_LOAD BIT(31)
86 +#define FAN_LOAD BIT(0)
87 +#define SPI_FLASH_LOAD BIT(1)
88 +#define NOR_FLASH_LOAD BIT(2)
89 +#define GPS_LOAD BIT(3)
90 +#define SUPPLY_5V_LOAD BIT(6)
91 +#define SUPPLY_33V_LOAD BIT(7)
93 +struct laguna_board_info {
101 +static struct laguna_board_info laguna_info __initdata;
106 +static struct mtd_partition laguna_nor_partitions[] = {
111 + .mask_flags = MTD_WRITEABLE,
119 + .offset = SZ_256K + SZ_128K,
122 + .size = SZ_16M - SZ_256K - SZ_128K - SZ_2M,
123 + .offset = SZ_256K + SZ_128K + SZ_2M,
127 +static struct physmap_flash_data laguna_nor_pdata = {
129 + .parts = laguna_nor_partitions,
130 + .nr_parts = ARRAY_SIZE(laguna_nor_partitions),
133 +static struct resource laguna_nor_res = {
134 + .start = CNS3XXX_FLASH_BASE,
135 + .end = CNS3XXX_FLASH_BASE + SZ_128M - 1,
136 + .flags = IORESOURCE_MEM | IORESOURCE_MEM_32BIT,
139 +static struct platform_device laguna_nor_pdev = {
140 + .name = "physmap-flash",
142 + .resource = &laguna_nor_res,
143 + .num_resources = 1,
145 + .platform_data = &laguna_nor_pdata,
152 +static struct mtd_partition laguna_spi_partitions[] = {
157 + .mask_flags = MTD_WRITEABLE,
164 + .size = SZ_1M + SZ_512K,
168 + .size = SZ_16M - SZ_2M,
173 +static struct flash_platform_data laguna_spi_pdata = {
174 + .parts = laguna_spi_partitions,
175 + .nr_parts = ARRAY_SIZE(laguna_spi_partitions),
178 +static struct spi_board_info __initdata laguna_spi_devices[] = {
180 + .modalias = "m25p80",
181 + .platform_data = &laguna_spi_pdata,
182 + .max_speed_hz = 50000000,
188 +static struct platform_device laguna_spi_controller = {
189 + .name = "cns3xxx_spi",
195 +static struct gpio_led laguna_gpio_leds[] = {
197 + .name = "user1", /* Green Led */
201 + .name = "user2", /* Red Led */
205 + .name = "pwr1", /* Green Led */
209 + .name = "pwr2", /* Yellow Led */
213 + .name = "txd1", /* Green Led */
217 + .name = "txd2", /* Yellow Led */
221 + .name = "rxd1", /* Green Led */
225 + .name = "rxd2", /* Yellow Led */
229 + .name = "ser1", /* Green Led */
233 + .name = "ser2", /* Yellow Led */
237 + .name = "enet1", /* Green Led */
241 + .name = "enet2", /* Yellow Led */
245 + .name = "sig1_1", /* Green Led */
249 + .name = "sig1_2", /* Yellow Led */
253 + .name = "sig2_1", /* Green Led */
257 + .name = "sig2_2", /* Yellow Led */
261 + .name = "sig3_1", /* Green Led */
265 + .name = "sig3_2", /* Yellow Led */
269 + .name = "net1", /*Green Led */
273 + .name = "net2", /* Red Led */
277 + .name = "mod1", /* Green Led */
281 + .name = "mod2", /* Red Led */
287 +static struct gpio_led_platform_data laguna_gpio_leds_data = {
289 + .leds = laguna_gpio_leds,
292 +static struct platform_device laguna_gpio_leds_device = {
293 + .name = "leds-gpio",
295 + .dev.platform_data = &laguna_gpio_leds_data,
301 +static struct cns3xxx_plat_info laguna_net_data = {
310 +static struct platform_device laguna_net_device = {
311 + .name = "cns3xxx_eth",
313 + .dev.platform_data = &laguna_net_data,
319 +static void __init laguna_early_serial_setup(void)
321 +#ifdef CONFIG_SERIAL_8250_CONSOLE
322 + static struct uart_port laguna_serial_port = {
323 + .membase = (void __iomem *)CNS3XXX_UART0_BASE_VIRT,
324 + .mapbase = CNS3XXX_UART0_BASE,
325 + .irq = IRQ_CNS3XXX_UART0,
326 + .iotype = UPIO_MEM,
327 + .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
329 + .uartclk = 24000000,
331 + .type = PORT_16550A,
335 + early_serial_setup(&laguna_serial_port);
339 +static struct resource laguna_uart_resources[] = {
341 + .start = CNS3XXX_UART0_BASE,
342 + .end = CNS3XXX_UART0_BASE + SZ_4K - 1,
343 + .flags = IORESOURCE_MEM
345 + .start = CNS3XXX_UART2_BASE,
346 + .end = CNS3XXX_UART2_BASE + SZ_4K - 1,
347 + .flags = IORESOURCE_MEM
349 + .start = CNS3XXX_UART2_BASE,
350 + .end = CNS3XXX_UART2_BASE + SZ_4K - 1,
351 + .flags = IORESOURCE_MEM
355 +static struct plat_serial8250_port laguna_uart_data[] = {
357 + .membase = (char*) (CNS3XXX_UART0_BASE_VIRT),
358 + .mapbase = (CNS3XXX_UART0_BASE),
359 + .irq = IRQ_CNS3XXX_UART0,
360 + .iotype = UPIO_MEM,
361 + .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE | UPF_NO_TXEN_TEST,
363 + .uartclk = 24000000,
364 + .type = PORT_16550A,
366 + .membase = (char*) (CNS3XXX_UART1_BASE_VIRT),
367 + .mapbase = (CNS3XXX_UART1_BASE),
368 + .irq = IRQ_CNS3XXX_UART1,
369 + .iotype = UPIO_MEM,
370 + .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE | UPF_NO_TXEN_TEST,
372 + .uartclk = 24000000,
373 + .type = PORT_16550A,
375 + .membase = (char*) (CNS3XXX_UART2_BASE_VIRT),
376 + .mapbase = (CNS3XXX_UART2_BASE),
377 + .irq = IRQ_CNS3XXX_UART2,
378 + .iotype = UPIO_MEM,
379 + .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE | UPF_NO_TXEN_TEST,
381 + .uartclk = 24000000,
382 + .type = PORT_16550A,
386 +static struct platform_device laguna_uart = {
387 + .name = "serial8250",
388 + .id = PLAT8250_DEV_PLATFORM,
389 + .dev.platform_data = laguna_uart_data,
390 + .num_resources = 3,
391 + .resource = laguna_uart_resources
397 +static struct resource cns3xxx_usb_ehci_resources[] = {
399 + .start = CNS3XXX_USB_BASE,
400 + .end = CNS3XXX_USB_BASE + SZ_16M - 1,
401 + .flags = IORESOURCE_MEM,
404 + .start = IRQ_CNS3XXX_USB_EHCI,
405 + .flags = IORESOURCE_IRQ,
409 +static u64 cns3xxx_usb_ehci_dma_mask = DMA_BIT_MASK(32);
411 +static struct platform_device cns3xxx_usb_ehci_device = {
412 + .name = "cns3xxx-ehci",
413 + .num_resources = ARRAY_SIZE(cns3xxx_usb_ehci_resources),
414 + .resource = cns3xxx_usb_ehci_resources,
416 + .dma_mask = &cns3xxx_usb_ehci_dma_mask,
417 + .coherent_dma_mask = DMA_BIT_MASK(32),
421 +static struct resource cns3xxx_usb_ohci_resources[] = {
423 + .start = CNS3XXX_USB_OHCI_BASE,
424 + .end = CNS3XXX_USB_OHCI_BASE + SZ_16M - 1,
425 + .flags = IORESOURCE_MEM,
428 + .start = IRQ_CNS3XXX_USB_OHCI,
429 + .flags = IORESOURCE_IRQ,
433 +static u64 cns3xxx_usb_ohci_dma_mask = DMA_BIT_MASK(32);
435 +static struct platform_device cns3xxx_usb_ohci_device = {
436 + .name = "cns3xxx-ohci",
437 + .num_resources = ARRAY_SIZE(cns3xxx_usb_ohci_resources),
438 + .resource = cns3xxx_usb_ohci_resources,
440 + .dma_mask = &cns3xxx_usb_ohci_dma_mask,
441 + .coherent_dma_mask = DMA_BIT_MASK(32),
445 +static struct resource cns3xxx_usb_otg_resources[] = {
447 + .start = CNS3XXX_USBOTG_BASE,
448 + .end = CNS3XXX_USBOTG_BASE + SZ_16M - 1,
449 + .flags = IORESOURCE_MEM,
452 + .start = IRQ_CNS3XXX_USB_OTG,
453 + .flags = IORESOURCE_IRQ,
457 +static u64 cns3xxx_usb_otg_dma_mask = DMA_BIT_MASK(32);
459 +static struct platform_device cns3xxx_usb_otg_device = {
461 + .num_resources = ARRAY_SIZE(cns3xxx_usb_otg_resources),
462 + .resource = cns3xxx_usb_otg_resources,
464 + .dma_mask = &cns3xxx_usb_otg_dma_mask,
465 + .coherent_dma_mask = DMA_BIT_MASK(32),
472 +static struct resource laguna_i2c_resource[] = {
474 + .start = CNS3XXX_SSP_BASE + 0x20,
476 + .flags = IORESOURCE_MEM,
478 + .start = IRQ_CNS3XXX_I2C,
479 + .flags = IORESOURCE_IRQ,
483 +static struct platform_device laguna_i2c_controller = {
484 + .name = "cns3xxx-i2c",
485 + .num_resources = 2,
486 + .resource = laguna_i2c_resource,
489 +static struct memory_accessor *at24_mem_acc;
491 +static void at24_setup(struct memory_accessor *mem_acc, void *context)
495 + at24_mem_acc = mem_acc;
497 + /* Read MAC addresses */
498 + if (at24_mem_acc->read(at24_mem_acc, buf, 0x100, 6) == 6)
499 + memcpy(&laguna_net_data.hwaddr[0], buf, ETH_ALEN);
500 + if (at24_mem_acc->read(at24_mem_acc, buf, 0x106, 6) == 6)
501 + memcpy(&laguna_net_data.hwaddr[1], buf, ETH_ALEN);
502 + if (at24_mem_acc->read(at24_mem_acc, buf, 0x10C, 6) == 6)
503 + memcpy(&laguna_net_data.hwaddr[2], buf, ETH_ALEN);
504 + if (at24_mem_acc->read(at24_mem_acc, buf, 0x112, 6) == 6)
505 + memcpy(&laguna_net_data.hwaddr[3], buf, ETH_ALEN);
507 + /* Read out Model Information */
508 + if (at24_mem_acc->read(at24_mem_acc, buf, 0x130, 16) == 16)
509 + memcpy(&laguna_info.model, buf, 16);
510 + if (at24_mem_acc->read(at24_mem_acc, buf, 0x140, 1) == 1)
511 + memcpy(&laguna_info.nor_flash_size, buf, 1);
512 + if (at24_mem_acc->read(at24_mem_acc, buf, 0x141, 1) == 1)
513 + memcpy(&laguna_info.spi_flash_size, buf, 1);
514 + if (at24_mem_acc->read(at24_mem_acc, buf, 0x142, 4) == 4)
515 + memcpy(&laguna_info.config_bitmap, buf, 4);
516 + if (at24_mem_acc->read(at24_mem_acc, buf, 0x146, 4) == 4)
517 + memcpy(&laguna_info.config2_bitmap, buf, 4);
520 +static struct at24_platform_data laguna_eeprom_info = {
523 + .flags = AT24_FLAG_READONLY,
524 + .setup = at24_setup,
527 +static struct pca953x_platform_data laguna_pca_data = {
532 +static struct pca953x_platform_data laguna_pca2_data = {
537 +static struct i2c_board_info __initdata laguna_i2c_devices[] = {
539 + I2C_BOARD_INFO("pca9555", 0x23),
540 + .platform_data = &laguna_pca_data,
542 + I2C_BOARD_INFO("pca9555", 0x27),
543 + .platform_data = &laguna_pca2_data,
545 + I2C_BOARD_INFO("gsp", 0x29),
547 + I2C_BOARD_INFO ("24c08",0x50),
548 + .platform_data = &laguna_eeprom_info,
550 + I2C_BOARD_INFO("ds1672", 0x68),
558 +static struct resource laguna_watchdog_resource[] = {
560 + .start = CNS3XXX_TC11MP_TWD_BASE,
561 + .end = CNS3XXX_TC11MP_TWD_BASE + SZ_4K - 1,
562 + .flags = IORESOURCE_MEM,
564 + .start = IRQ_LOCALWDOG,
565 + .end = IRQ_LOCALWDOG,
566 + .flags = IORESOURCE_IRQ,
570 +static struct platform_device laguna_watchdog = {
571 + .name = "mpcore_wdt",
573 + .num_resources = ARRAY_SIZE(laguna_watchdog_resource),
574 + .resource = laguna_watchdog_resource,
581 +static void __init laguna_init(void)
583 + platform_device_register(&laguna_watchdog);
585 + platform_device_register(&laguna_i2c_controller);
587 + i2c_register_board_info(0, laguna_i2c_devices,
588 + ARRAY_SIZE(laguna_i2c_devices));
591 + pm_power_off = cns3xxx_power_off;
594 +static struct map_desc laguna_io_desc[] __initdata = {
596 + .virtual = CNS3XXX_UART0_BASE_VIRT,
597 + .pfn = __phys_to_pfn(CNS3XXX_UART0_BASE),
601 + .virtual = CNS3XXX_UART1_BASE_VIRT,
602 + .pfn = __phys_to_pfn(CNS3XXX_UART1_BASE),
606 + .virtual = CNS3XXX_UART2_BASE_VIRT,
607 + .pfn = __phys_to_pfn(CNS3XXX_UART2_BASE),
613 +static void __init laguna_map_io(void)
616 + iotable_init(laguna_io_desc, ARRAY_SIZE(laguna_io_desc));
618 + laguna_early_serial_setup();
622 +static int __init laguna_model_setup(void)
626 + u8 pcie_bitmap = 0;
628 + printk("Running on Gateworks Laguna %s\n", laguna_info.model);
630 + if (strncmp(laguna_info.model, "GW", 2) == 0) {
631 + if (laguna_info.config_bitmap & ETH0_LOAD)
632 + laguna_net_data.ports |= BIT(0);
633 + if (laguna_info.config_bitmap & ETH1_LOAD)
634 + laguna_net_data.ports |= BIT(1);
635 + if (laguna_info.config_bitmap & ETH2_LOAD)
636 + laguna_net_data.ports |= BIT(2);
637 + if (laguna_net_data.ports)
638 + platform_device_register(&laguna_net_device);
640 + if ((laguna_info.config_bitmap & SATA0_LOAD) ||
641 + (laguna_info.config_bitmap & SATA1_LOAD))
642 + cns3xxx_ahci_init();
644 + if (laguna_info.config_bitmap & (PCIE0_LOAD))
645 + pcie_bitmap |= 0x1;
647 + if (laguna_info.config_bitmap & (PCIE1_LOAD))
648 + pcie_bitmap |= 0x2;
650 + cns3xxx_pcie_init(pcie_bitmap);
652 + if (laguna_info.config_bitmap & (USB0_LOAD)) {
653 + cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB);
655 + /* DRVVBUS pins share with GPIOA */
656 + mem = (void __iomem *)(CNS3XXX_MISC_BASE_VIRT + 0x0014);
657 + reg = __raw_readl(mem);
659 + __raw_writel(reg, mem);
662 + mem = (void __iomem *)(CNS3XXX_MISC_BASE_VIRT + 0x0808);
663 + reg = __raw_readl(mem);
665 + __raw_writel(reg, mem);
667 + platform_device_register(&cns3xxx_usb_otg_device);
670 + if (laguna_info.config_bitmap & (USB1_LOAD)) {
671 + platform_device_register(&cns3xxx_usb_ehci_device);
672 + platform_device_register(&cns3xxx_usb_ohci_device);
675 + if (laguna_info.config_bitmap & (SD_LOAD))
676 + cns3xxx_sdhci_init();
678 + if (laguna_info.config_bitmap & (UART0_LOAD))
679 + laguna_uart.num_resources = 1;
680 + if (laguna_info.config_bitmap & (UART1_LOAD))
681 + laguna_uart.num_resources = 2;
682 + if (laguna_info.config_bitmap & (UART2_LOAD))
683 + laguna_uart.num_resources = 3;
684 + platform_device_register(&laguna_uart);
686 + if (laguna_info.config2_bitmap & (NOR_FLASH_LOAD)) {
687 + switch (laguna_info.nor_flash_size) {
689 + laguna_nor_partitions[3].size = SZ_8M - SZ_256K - SZ_128K - SZ_2M;
690 + laguna_nor_res.end = CNS3XXX_FLASH_BASE + SZ_8M - 1;
693 + laguna_nor_partitions[3].size = SZ_16M - SZ_256K - SZ_128K - SZ_2M;
694 + laguna_nor_res.end = CNS3XXX_FLASH_BASE + SZ_16M - 1;
697 + laguna_nor_partitions[3].size = SZ_32M - SZ_256K - SZ_128K - SZ_2M;
698 + laguna_nor_res.end = CNS3XXX_FLASH_BASE + SZ_32M - 1;
701 + laguna_nor_partitions[3].size = SZ_64M - SZ_256K - SZ_128K - SZ_2M;
702 + laguna_nor_res.end = CNS3XXX_FLASH_BASE + SZ_64M - 1;
705 + laguna_nor_partitions[3].size = SZ_128M - SZ_256K - SZ_128K - SZ_2M;
706 + laguna_nor_res.end = CNS3XXX_FLASH_BASE + SZ_128M - 1;
709 + platform_device_register(&laguna_nor_pdev);
712 + if (laguna_info.config2_bitmap & (SPI_FLASH_LOAD)) {
713 + switch (laguna_info.spi_flash_size) {
715 + laguna_spi_partitions[3].size = SZ_4M - SZ_2M;
718 + laguna_spi_partitions[3].size = SZ_8M - SZ_2M;
721 + laguna_spi_partitions[3].size = SZ_16M - SZ_2M;
724 + laguna_spi_partitions[3].size = SZ_32M - SZ_2M;
727 + laguna_spi_partitions[3].size = SZ_64M - SZ_2M;
730 + spi_register_board_info(laguna_spi_devices, ARRAY_SIZE(laguna_spi_devices));
733 + if ((laguna_info.config_bitmap & SPI0_LOAD) ||
734 + (laguna_info.config_bitmap & SPI1_LOAD))
735 + platform_device_register(&laguna_spi_controller);
738 + * Do any model specific setup not known by the bitmap by matching
739 + * the first 6 characters of the model name
742 + if (strncmp(laguna_info.model, "GW2388", 6) == 0) {
743 + laguna_gpio_leds_data.num_leds = 2;
744 + } else if (strncmp(laguna_info.model, "GW2380", 6) == 0) {
745 + laguna_gpio_leds[0].gpio = 107;
746 + laguna_gpio_leds[1].gpio = 106;
747 + laguna_gpio_leds_data.num_leds = 2;
749 + platform_device_register(&laguna_gpio_leds_device);
751 + // Do some defaults here, not sure what yet
756 +late_initcall(laguna_model_setup);
758 +MACHINE_START(GW2388, "Gateworks Corporation Laguna Platform")
759 + .boot_params = 0x00000100,
760 + .map_io = laguna_map_io,
761 + .init_irq = cns3xxx_init_irq,
762 + .timer = &cns3xxx_timer,
763 + .init_machine = laguna_init,
765 --- a/arch/arm/mach-cns3xxx/Kconfig
766 +++ b/arch/arm/mach-cns3xxx/Kconfig
767 @@ -10,4 +10,13 @@ config MACH_CNS3420VB
768 This is a platform with an on-board ARM11 MPCore and has support
769 for USB, USB-OTG, MMC/SD/SDIO, SATA, PCI-E, etc.
772 + bool "Support for Gateworks Laguna Platform"
773 + select MIGHT_HAVE_PCI
775 + Include support for the Gateworks Laguna Platform
777 + This is a platform with an on-board ARM11 MPCore and has support
778 + for USB, USB-OTG, MMC/SD/SDIO, SATA, PCI-E, I2C, GIG, etc.
781 --- a/arch/arm/mach-cns3xxx/core.c
782 +++ b/arch/arm/mach-cns3xxx/core.c
784 #include <asm/mach/time.h>
785 #include <asm/mach/irq.h>
786 #include <asm/hardware/gic.h>
787 +#include <asm/smp_twd.h>
788 #include <mach/cns3xxx.h>
791 @@ -60,11 +61,24 @@ static struct map_desc cns3xxx_io_desc[]
792 .pfn = __phys_to_pfn(CNS3XXX_PM_BASE),
796 + .virtual = CNS3XXX_SWITCH_BASE_VIRT,
797 + .pfn = __phys_to_pfn(CNS3XXX_SWITCH_BASE),
801 + .virtual = CNS3XXX_SSP_BASE_VIRT,
802 + .pfn = __phys_to_pfn(CNS3XXX_SSP_BASE),
808 void __init cns3xxx_map_io(void)
810 +#ifdef CONFIG_LOCAL_TIMERS
811 + twd_base = (void __iomem *) CNS3XXX_TC11MP_TWD_BASE_VIRT;
813 iotable_init(cns3xxx_io_desc, ARRAY_SIZE(cns3xxx_io_desc));
816 --- a/arch/arm/Kconfig
817 +++ b/arch/arm/Kconfig
818 @@ -313,6 +313,7 @@ config ARCH_CLPS711X
820 bool "Cavium Networks CNS3XXX family"
822 + select ARCH_WANT_OPTIONAL_GPIOLIB
823 select GENERIC_CLOCKEVENTS
825 select MIGHT_HAVE_PCI
827 +++ b/arch/arm/mach-cns3xxx/include/mach/gpio.h
830 + * arch/arm/mach-cns3xxx/include/mach/gpio.h
832 + * CNS3xxx GPIO wrappers for arch-neutral GPIO calls
834 + * Copyright 2011 Gateworks Corporation
835 + * Chris Lang <clang@gateworks.com>
837 + * Based on IXP implementation by Milan Svoboda <msvoboda@ra.rockwell.com>
838 + * Based on PXA implementation by Philipp Zabel <philipp.zabel@gmail.com>
840 + * This program is free software; you can redistribute it and/or modify
841 + * it under the terms of the GNU General Public License as published by
842 + * the Free Software Foundation; either version 2 of the License, or
843 + * (at your option) any later version.
845 + * This program is distributed in the hope that it will be useful,
846 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
847 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
848 + * GNU General Public License for more details.
850 + * You should have received a copy of the GNU General Public License
851 + * along with this program; if not, write to the Free Software
852 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
856 +#ifndef __ASM_ARCH_CNS3XXX_GPIO_H
857 +#define __ASM_ARCH_CNS3XXX_GPIO_H
859 +#include <linux/kernel.h>
860 +#include <linux/io.h>
861 +#include <mach/hardware.h>
862 +#include <asm-generic/gpio.h> /* cansleep wrappers */
864 +#define NR_BUILTIN_GPIO 64
866 +#define CNS3XXX_GPIO_IN 0x0
867 +#define CNS3XXX_GPIO_OUT 0x1
869 +#define CNS3XXX_GPIO_LO 0
870 +#define CNS3XXX_GPIO_HI 1
872 +#define CNS3XXX_GPIO_OUTPUT 0x00
873 +#define CNS3XXX_GPIO_INPUT 0x04
874 +#define CNS3XXX_GPIO_DIR 0x08
875 +#define CNS3XXX_GPIO_SET 0x10
876 +#define CNS3XXX_GPIO_CLEAR 0x14
878 +static inline void gpio_line_get(u8 line, int *value)
881 + *value = ((__raw_readl(CNS3XXX_GPIOA_BASE_VIRT + CNS3XXX_GPIO_INPUT) >> line) & 0x1);
883 + *value = ((__raw_readl(CNS3XXX_GPIOB_BASE_VIRT + CNS3XXX_GPIO_INPUT) >> (line - 32)) & 0x1);
886 +static inline void gpio_line_set(u8 line, int value)
890 + __raw_writel((1 << line), CNS3XXX_GPIOA_BASE_VIRT + CNS3XXX_GPIO_SET);
892 + __raw_writel((1 << line), CNS3XXX_GPIOA_BASE_VIRT + CNS3XXX_GPIO_CLEAR);
895 + __raw_writel((1 << line), CNS3XXX_GPIOB_BASE_VIRT + CNS3XXX_GPIO_SET);
897 + __raw_writel((1 << line), CNS3XXX_GPIOB_BASE_VIRT + CNS3XXX_GPIO_CLEAR);
901 +static inline int gpio_get_value(unsigned gpio)
903 + if (gpio < NR_BUILTIN_GPIO)
906 + gpio_line_get(gpio, &value);
910 + return __gpio_get_value(gpio);
913 +static inline void gpio_set_value(unsigned gpio, int value)
915 + if (gpio < NR_BUILTIN_GPIO)
916 + gpio_line_set(gpio, value);
918 + __gpio_set_value(gpio, value);
921 +#define gpio_cansleep __gpio_cansleep
923 +extern int gpio_to_irq(int gpio);
924 +extern int irq_to_gpio(int gpio);
927 --- a/arch/arm/mach-cns3xxx/Makefile
928 +++ b/arch/arm/mach-cns3xxx/Makefile
930 obj-$(CONFIG_ARCH_CNS3XXX) += core.o pm.o devices.o
931 obj-$(CONFIG_PCI) += pcie.o
932 obj-$(CONFIG_MACH_CNS3420VB) += cns3420vb.o
933 +obj-$(CONFIG_MACH_GW2388) += laguna.o
934 obj-$(CONFIG_SMP) += platsmp.o headsmp.o
935 obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
936 obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
937 --- a/arch/arm/tools/mach-types
938 +++ b/arch/arm/tools/mach-types
939 @@ -438,6 +438,7 @@ icontrol MACH_ICONTROL ICONTROL 2624
940 qsd8x50a_st1_5 MACH_QSD8X50A_ST1_5 QSD8X50A_ST1_5 2627
941 mx23evk MACH_MX23EVK MX23EVK 2629
942 ap4evb MACH_AP4EVB AP4EVB 2630
943 +gw2388 MACH_GW2388 GW2388 2635
944 mityomapl138 MACH_MITYOMAPL138 MITYOMAPL138 2650
945 guruplug MACH_GURUPLUG GURUPLUG 2659
946 spear310 MACH_SPEAR310 SPEAR310 2660
947 --- a/arch/arm/mach-cns3xxx/pcie.c
948 +++ b/arch/arm/mach-cns3xxx/pcie.c
949 @@ -365,7 +365,7 @@ static int cns3xxx_pcie_abort_handler(un
953 -static int __init cns3xxx_pcie_init(void)
954 +int cns3xxx_pcie_init(u8 bitmap)
958 @@ -373,6 +373,9 @@ static int __init cns3xxx_pcie_init(void
959 "imprecise external abort");
961 for (i = 0; i < ARRAY_SIZE(cns3xxx_pcie); i++) {
962 + if (!(bitmap & (1 << i)))
965 iotable_init(cns3xxx_pcie[i].cfg_bases,
966 ARRAY_SIZE(cns3xxx_pcie[i].cfg_bases));
967 cns3xxx_pcie_check_link(&cns3xxx_pcie[i]);
968 @@ -384,4 +387,3 @@ static int __init cns3xxx_pcie_init(void
972 -device_initcall(cns3xxx_pcie_init);
973 --- a/arch/arm/mach-cns3xxx/cns3420vb.c
974 +++ b/arch/arm/mach-cns3xxx/cns3420vb.c
975 @@ -175,6 +175,8 @@ static void __init cns3420_init(void)
977 cns3xxx_sdhci_init();
979 + cns3xxx_pcie_init(0x3);
981 pm_power_off = cns3xxx_power_off;
984 --- a/arch/arm/mach-cns3xxx/include/mach/platform.h
985 +++ b/arch/arm/mach-cns3xxx/include/mach/platform.h
986 @@ -22,5 +22,7 @@ struct cns3xxx_plat_info {
990 +extern int cns3xxx_pcie_init(u8 bitmap);
992 #endif /* __ASM_ARCH_PLATFORM_H */