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/cns3xxx.h>
45 +#include <mach/irqs.h>
46 +#include <mach/platform.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_resources[] = {
560 + .start = CNS3XXX_TC11MP_TWD_BASE,
561 + .end = CNS3XXX_TC11MP_TWD_BASE + SZ_4K - 1,
562 + .flags = IORESOURCE_MEM,
565 + .start = IRQ_LOCALWDOG,
566 + .end = IRQ_LOCALWDOG,
567 + .flags = IORESOURCE_IRQ,
571 +static struct platform_device laguna_watchdog = {
572 + .name = "mpcore_wdt",
574 + .num_resources = ARRAY_SIZE(laguna_watchdog_resources),
575 + .resource = laguna_watchdog_resources,
582 +static void __init laguna_init(void)
584 + cns3xxx_l2x0_init();
586 + platform_device_register(&laguna_watchdog);
588 + platform_device_register(&laguna_i2c_controller);
590 + i2c_register_board_info(0, laguna_i2c_devices,
591 + ARRAY_SIZE(laguna_i2c_devices));
593 + pm_power_off = cns3xxx_power_off;
596 +static struct map_desc laguna_io_desc[] __initdata = {
598 + .virtual = CNS3XXX_UART0_BASE_VIRT,
599 + .pfn = __phys_to_pfn(CNS3XXX_UART0_BASE),
603 + .virtual = CNS3XXX_UART1_BASE_VIRT,
604 + .pfn = __phys_to_pfn(CNS3XXX_UART1_BASE),
608 + .virtual = CNS3XXX_UART2_BASE_VIRT,
609 + .pfn = __phys_to_pfn(CNS3XXX_UART2_BASE),
615 +static void __init laguna_map_io(void)
618 + iotable_init(laguna_io_desc, ARRAY_SIZE(laguna_io_desc));
619 + 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 @@ -11,4 +11,14 @@ 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 HAVE_ARM_SCU if SMP
774 + select MIGHT_HAVE_PCI
776 + Include support for the Gateworks Laguna Platform
778 + This is a platform with an on-board ARM11 MPCore and has support
779 + for USB, USB-OTG, MMC/SD/SDIO, SATA, PCI-E, I2C, GIG, etc.
782 --- a/arch/arm/mach-cns3xxx/core.c
783 +++ b/arch/arm/mach-cns3xxx/core.c
785 #include <asm/mach/time.h>
786 #include <asm/mach/irq.h>
787 #include <asm/hardware/gic.h>
788 +#include <asm/smp_twd.h>
789 #include <asm/hardware/cache-l2x0.h>
790 #include <mach/cns3xxx.h>
792 @@ -61,11 +62,24 @@ static struct map_desc cns3xxx_io_desc[]
793 .pfn = __phys_to_pfn(CNS3XXX_PM_BASE),
797 + .virtual = CNS3XXX_SWITCH_BASE_VIRT,
798 + .pfn = __phys_to_pfn(CNS3XXX_SWITCH_BASE),
802 + .virtual = CNS3XXX_SSP_BASE_VIRT,
803 + .pfn = __phys_to_pfn(CNS3XXX_SSP_BASE),
809 void __init cns3xxx_map_io(void)
811 +#ifdef CONFIG_LOCAL_TIMERS
812 + twd_base = (void __iomem *) CNS3XXX_TC11MP_TWD_BASE_VIRT;
814 iotable_init(cns3xxx_io_desc, ARRAY_SIZE(cns3xxx_io_desc));
817 --- a/arch/arm/Kconfig
818 +++ b/arch/arm/Kconfig
819 @@ -329,6 +329,7 @@ config ARCH_CLPS711X
821 bool "Cavium Networks CNS3XXX family"
823 + select ARCH_WANT_OPTIONAL_GPIOLIB
824 select GENERIC_CLOCKEVENTS
826 select MIGHT_HAVE_PCI
828 +++ b/arch/arm/mach-cns3xxx/include/mach/gpio.h
831 + * arch/arm/mach-cns3xxx/include/mach/gpio.h
833 + * CNS3xxx GPIO wrappers for arch-neutral GPIO calls
835 + * Copyright 2011 Gateworks Corporation
836 + * Chris Lang <clang@gateworks.com>
838 + * Based on IXP implementation by Milan Svoboda <msvoboda@ra.rockwell.com>
839 + * Based on PXA implementation by Philipp Zabel <philipp.zabel@gmail.com>
841 + * This program is free software; you can redistribute it and/or modify
842 + * it under the terms of the GNU General Public License as published by
843 + * the Free Software Foundation; either version 2 of the License, or
844 + * (at your option) any later version.
846 + * This program is distributed in the hope that it will be useful,
847 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
848 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
849 + * GNU General Public License for more details.
851 + * You should have received a copy of the GNU General Public License
852 + * along with this program; if not, write to the Free Software
853 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
857 +#ifndef __ASM_ARCH_CNS3XXX_GPIO_H
858 +#define __ASM_ARCH_CNS3XXX_GPIO_H
860 +#include <linux/kernel.h>
861 +#include <linux/io.h>
862 +#include <mach/platform.h>
863 +#include <asm-generic/gpio.h> /* cansleep wrappers */
865 +#define NR_BUILTIN_GPIO 64
867 +#define CNS3XXX_GPIO_IN 0x0
868 +#define CNS3XXX_GPIO_OUT 0x1
870 +#define CNS3XXX_GPIO_LO 0
871 +#define CNS3XXX_GPIO_HI 1
873 +#define CNS3XXX_GPIO_OUTPUT 0x00
874 +#define CNS3XXX_GPIO_INPUT 0x04
875 +#define CNS3XXX_GPIO_DIR 0x08
876 +#define CNS3XXX_GPIO_SET 0x10
877 +#define CNS3XXX_GPIO_CLEAR 0x14
879 +static inline void gpio_line_get(u8 line, int *value)
882 + *value = ((__raw_readl(CNS3XXX_GPIOA_BASE_VIRT + CNS3XXX_GPIO_INPUT) >> line) & 0x1);
884 + *value = ((__raw_readl(CNS3XXX_GPIOB_BASE_VIRT + CNS3XXX_GPIO_INPUT) >> (line - 32)) & 0x1);
887 +static inline void gpio_line_set(u8 line, int value)
891 + __raw_writel((1 << line), CNS3XXX_GPIOA_BASE_VIRT + CNS3XXX_GPIO_SET);
893 + __raw_writel((1 << line), CNS3XXX_GPIOA_BASE_VIRT + CNS3XXX_GPIO_CLEAR);
896 + __raw_writel((1 << line), CNS3XXX_GPIOB_BASE_VIRT + CNS3XXX_GPIO_SET);
898 + __raw_writel((1 << line), CNS3XXX_GPIOB_BASE_VIRT + CNS3XXX_GPIO_CLEAR);
902 +static inline int gpio_get_value(unsigned gpio)
904 + if (gpio < NR_BUILTIN_GPIO)
907 + gpio_line_get(gpio, &value);
911 + return __gpio_get_value(gpio);
914 +static inline void gpio_set_value(unsigned gpio, int value)
916 + if (gpio < NR_BUILTIN_GPIO)
917 + gpio_line_set(gpio, value);
919 + __gpio_set_value(gpio, value);
922 +#define gpio_cansleep __gpio_cansleep
924 +extern int gpio_to_irq(int gpio);
925 +extern int irq_to_gpio(int gpio);
928 --- a/arch/arm/mach-cns3xxx/Makefile
929 +++ b/arch/arm/mach-cns3xxx/Makefile
931 obj-$(CONFIG_ARCH_CNS3XXX) += core.o pm.o devices.o
932 obj-$(CONFIG_PCI) += pcie.o
933 obj-$(CONFIG_MACH_CNS3420VB) += cns3420vb.o
934 +obj-$(CONFIG_MACH_GW2388) += laguna.o
935 obj-$(CONFIG_SMP) += platsmp.o headsmp.o
936 obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
937 obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
938 --- a/arch/arm/mach-cns3xxx/pcie.c
939 +++ b/arch/arm/mach-cns3xxx/pcie.c
940 @@ -365,7 +365,7 @@ static int cns3xxx_pcie_abort_handler(un
944 -static int __init cns3xxx_pcie_init(void)
945 +int cns3xxx_pcie_init(u8 bitmap)
949 @@ -376,6 +376,9 @@ static int __init cns3xxx_pcie_init(void
950 "imprecise external abort");
952 for (i = 0; i < ARRAY_SIZE(cns3xxx_pcie); i++) {
953 + if (!(bitmap & (1 << i)))
956 iotable_init(cns3xxx_pcie[i].cfg_bases,
957 ARRAY_SIZE(cns3xxx_pcie[i].cfg_bases));
958 cns3xxx_pcie_check_link(&cns3xxx_pcie[i]);
959 @@ -387,4 +390,3 @@ static int __init cns3xxx_pcie_init(void
963 -device_initcall(cns3xxx_pcie_init);
964 --- a/arch/arm/mach-cns3xxx/cns3420vb.c
965 +++ b/arch/arm/mach-cns3xxx/cns3420vb.c
967 #include <asm/mach/time.h>
968 #include <mach/cns3xxx.h>
969 #include <mach/irqs.h>
970 +#include <mach/platform.h>
974 @@ -198,6 +199,8 @@ static void __init cns3420_init(void)
976 cns3xxx_sdhci_init();
978 + cns3xxx_pcie_init(0x3);
980 pm_power_off = cns3xxx_power_off;
983 --- a/arch/arm/mach-cns3xxx/core.h
984 +++ b/arch/arm/mach-cns3xxx/core.h
986 #define __CNS3XXX_CORE_H
988 extern struct sys_timer cns3xxx_timer;
989 +extern int cns3xxx_pcie_init(u8 bitmap);
991 #ifdef CONFIG_CACHE_L2X0
992 void __init cns3xxx_l2x0_init(void);