Anton Vorontsov | e94cdef | 2010-03-26 21:19:02 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Cavium Networks CNS3420 Validation Board |
| 3 | * |
| 4 | * Copyright 2000 Deep Blue Solutions Ltd |
| 5 | * Copyright 2008 ARM Limited |
| 6 | * Copyright 2008 Cavium Networks |
| 7 | * Scott Shu |
| 8 | * Copyright 2010 MontaVista Software, LLC. |
| 9 | * Anton Vorontsov <avorontsov@mvista.com> |
| 10 | * |
| 11 | * This file is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License, Version 2, as |
| 13 | * published by the Free Software Foundation. |
| 14 | */ |
| 15 | |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/compiler.h> |
| 19 | #include <linux/io.h> |
Mac Lin | cf36797 | 2010-11-23 00:32:44 +0800 | [diff] [blame] | 20 | #include <linux/dma-mapping.h> |
Anton Vorontsov | e94cdef | 2010-03-26 21:19:02 +0300 | [diff] [blame] | 21 | #include <linux/serial_core.h> |
| 22 | #include <linux/serial_8250.h> |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/mtd/mtd.h> |
| 25 | #include <linux/mtd/physmap.h> |
| 26 | #include <linux/mtd/partitions.h> |
| 27 | #include <asm/setup.h> |
| 28 | #include <asm/mach-types.h> |
| 29 | #include <asm/mach/arch.h> |
| 30 | #include <asm/mach/map.h> |
| 31 | #include <asm/mach/time.h> |
Anton Vorontsov | e94cdef | 2010-03-26 21:19:02 +0300 | [diff] [blame] | 32 | #include <mach/cns3xxx.h> |
| 33 | #include <mach/irqs.h> |
| 34 | #include "core.h" |
Anton Vorontsov | 6279d0e | 2010-05-28 13:14:44 +0400 | [diff] [blame] | 35 | #include "devices.h" |
Anton Vorontsov | e94cdef | 2010-03-26 21:19:02 +0300 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * NOR Flash |
| 39 | */ |
| 40 | static struct mtd_partition cns3420_nor_partitions[] = { |
| 41 | { |
| 42 | .name = "uboot", |
| 43 | .size = 0x00040000, |
| 44 | .offset = 0, |
| 45 | .mask_flags = MTD_WRITEABLE, |
| 46 | }, { |
| 47 | .name = "kernel", |
| 48 | .size = 0x004C0000, |
| 49 | .offset = MTDPART_OFS_APPEND, |
| 50 | }, { |
| 51 | .name = "filesystem", |
| 52 | .size = 0x7000000, |
| 53 | .offset = MTDPART_OFS_APPEND, |
| 54 | }, { |
| 55 | .name = "filesystem2", |
| 56 | .size = 0x0AE0000, |
| 57 | .offset = MTDPART_OFS_APPEND, |
| 58 | }, { |
| 59 | .name = "ubootenv", |
| 60 | .size = MTDPART_SIZ_FULL, |
| 61 | .offset = MTDPART_OFS_APPEND, |
| 62 | }, |
| 63 | }; |
| 64 | |
| 65 | static struct physmap_flash_data cns3420_nor_pdata = { |
| 66 | .width = 2, |
| 67 | .parts = cns3420_nor_partitions, |
| 68 | .nr_parts = ARRAY_SIZE(cns3420_nor_partitions), |
| 69 | }; |
| 70 | |
| 71 | static struct resource cns3420_nor_res = { |
| 72 | .start = CNS3XXX_FLASH_BASE, |
| 73 | .end = CNS3XXX_FLASH_BASE + SZ_128M - 1, |
| 74 | .flags = IORESOURCE_MEM | IORESOURCE_MEM_32BIT, |
| 75 | }; |
| 76 | |
| 77 | static struct platform_device cns3420_nor_pdev = { |
| 78 | .name = "physmap-flash", |
| 79 | .id = 0, |
| 80 | .resource = &cns3420_nor_res, |
| 81 | .num_resources = 1, |
| 82 | .dev = { |
| 83 | .platform_data = &cns3420_nor_pdata, |
| 84 | }, |
| 85 | }; |
| 86 | |
| 87 | /* |
| 88 | * UART |
| 89 | */ |
| 90 | static void __init cns3420_early_serial_setup(void) |
| 91 | { |
| 92 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
| 93 | static struct uart_port cns3420_serial_port = { |
| 94 | .membase = (void __iomem *)CNS3XXX_UART0_BASE_VIRT, |
| 95 | .mapbase = CNS3XXX_UART0_BASE, |
| 96 | .irq = IRQ_CNS3XXX_UART0, |
| 97 | .iotype = UPIO_MEM, |
| 98 | .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE, |
| 99 | .regshift = 2, |
| 100 | .uartclk = 24000000, |
| 101 | .line = 0, |
| 102 | .type = PORT_16550A, |
| 103 | .fifosize = 16, |
| 104 | }; |
| 105 | |
| 106 | early_serial_setup(&cns3420_serial_port); |
| 107 | #endif |
| 108 | } |
| 109 | |
| 110 | /* |
Mac Lin | cf36797 | 2010-11-23 00:32:44 +0800 | [diff] [blame] | 111 | * USB |
| 112 | */ |
| 113 | static struct resource cns3xxx_usb_ehci_resources[] = { |
| 114 | [0] = { |
| 115 | .start = CNS3XXX_USB_BASE, |
| 116 | .end = CNS3XXX_USB_BASE + SZ_16M - 1, |
| 117 | .flags = IORESOURCE_MEM, |
| 118 | }, |
| 119 | [1] = { |
| 120 | .start = IRQ_CNS3XXX_USB_EHCI, |
| 121 | .flags = IORESOURCE_IRQ, |
| 122 | }, |
| 123 | }; |
| 124 | |
| 125 | static u64 cns3xxx_usb_ehci_dma_mask = DMA_BIT_MASK(32); |
| 126 | |
| 127 | static struct platform_device cns3xxx_usb_ehci_device = { |
| 128 | .name = "cns3xxx-ehci", |
| 129 | .num_resources = ARRAY_SIZE(cns3xxx_usb_ehci_resources), |
| 130 | .resource = cns3xxx_usb_ehci_resources, |
| 131 | .dev = { |
| 132 | .dma_mask = &cns3xxx_usb_ehci_dma_mask, |
| 133 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 134 | }, |
| 135 | }; |
| 136 | |
| 137 | static struct resource cns3xxx_usb_ohci_resources[] = { |
| 138 | [0] = { |
| 139 | .start = CNS3XXX_USB_OHCI_BASE, |
| 140 | .end = CNS3XXX_USB_OHCI_BASE + SZ_16M - 1, |
| 141 | .flags = IORESOURCE_MEM, |
| 142 | }, |
| 143 | [1] = { |
| 144 | .start = IRQ_CNS3XXX_USB_OHCI, |
| 145 | .flags = IORESOURCE_IRQ, |
| 146 | }, |
| 147 | }; |
| 148 | |
| 149 | static u64 cns3xxx_usb_ohci_dma_mask = DMA_BIT_MASK(32); |
| 150 | |
| 151 | static struct platform_device cns3xxx_usb_ohci_device = { |
| 152 | .name = "cns3xxx-ohci", |
| 153 | .num_resources = ARRAY_SIZE(cns3xxx_usb_ohci_resources), |
| 154 | .resource = cns3xxx_usb_ohci_resources, |
| 155 | .dev = { |
| 156 | .dma_mask = &cns3xxx_usb_ohci_dma_mask, |
| 157 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 158 | }, |
| 159 | }; |
| 160 | |
| 161 | /* |
Anton Vorontsov | e94cdef | 2010-03-26 21:19:02 +0300 | [diff] [blame] | 162 | * Initialization |
| 163 | */ |
| 164 | static struct platform_device *cns3420_pdevs[] __initdata = { |
| 165 | &cns3420_nor_pdev, |
Mac Lin | cf36797 | 2010-11-23 00:32:44 +0800 | [diff] [blame] | 166 | &cns3xxx_usb_ehci_device, |
| 167 | &cns3xxx_usb_ohci_device, |
Anton Vorontsov | e94cdef | 2010-03-26 21:19:02 +0300 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | static void __init cns3420_init(void) |
| 171 | { |
Anton Vorontsov | 93e85d8 | 2011-07-06 16:45:09 +0400 | [diff] [blame] | 172 | cns3xxx_l2x0_init(); |
| 173 | |
Anton Vorontsov | e94cdef | 2010-03-26 21:19:02 +0300 | [diff] [blame] | 174 | platform_add_devices(cns3420_pdevs, ARRAY_SIZE(cns3420_pdevs)); |
| 175 | |
Anton Vorontsov | 23f5cac | 2010-03-25 23:10:58 +0300 | [diff] [blame] | 176 | cns3xxx_ahci_init(); |
Anton Vorontsov | 6279d0e | 2010-05-28 13:14:44 +0400 | [diff] [blame] | 177 | cns3xxx_sdhci_init(); |
| 178 | |
Anton Vorontsov | e94cdef | 2010-03-26 21:19:02 +0300 | [diff] [blame] | 179 | pm_power_off = cns3xxx_power_off; |
| 180 | } |
| 181 | |
| 182 | static struct map_desc cns3420_io_desc[] __initdata = { |
| 183 | { |
| 184 | .virtual = CNS3XXX_UART0_BASE_VIRT, |
| 185 | .pfn = __phys_to_pfn(CNS3XXX_UART0_BASE), |
| 186 | .length = SZ_4K, |
| 187 | .type = MT_DEVICE, |
| 188 | }, |
| 189 | }; |
| 190 | |
| 191 | static void __init cns3420_map_io(void) |
| 192 | { |
| 193 | cns3xxx_map_io(); |
| 194 | iotable_init(cns3420_io_desc, ARRAY_SIZE(cns3420_io_desc)); |
| 195 | |
| 196 | cns3420_early_serial_setup(); |
| 197 | } |
| 198 | |
| 199 | MACHINE_START(CNS3420VB, "Cavium Networks CNS3420 Validation Board") |
Nicolas Pitre | 03e6720 | 2011-07-05 22:38:11 -0400 | [diff] [blame] | 200 | .atag_offset = 0x100, |
Anton Vorontsov | e94cdef | 2010-03-26 21:19:02 +0300 | [diff] [blame] | 201 | .map_io = cns3420_map_io, |
| 202 | .init_irq = cns3xxx_init_irq, |
| 203 | .timer = &cns3xxx_timer, |
| 204 | .init_machine = cns3420_init, |
Russell King | 3921470 | 2011-11-05 15:32:23 +0000 | [diff] [blame^] | 205 | .restart = cns3xxx_restart, |
Anton Vorontsov | e94cdef | 2010-03-26 21:19:02 +0300 | [diff] [blame] | 206 | MACHINE_END |