Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-loki/common.c |
| 3 | * |
| 4 | * Core functions for Marvell Loki (88RC8480) SoCs |
| 5 | * |
| 6 | * This file is licensed under the terms of the GNU General Public |
| 7 | * License version 2. This program is licensed "as is" without any |
| 8 | * warranty of any kind, whether express or implied. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/serial_8250.h> |
| 15 | #include <linux/mbus.h> |
| 16 | #include <linux/mv643xx_eth.h> |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 17 | #include <linux/dma-mapping.h> |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 18 | #include <asm/page.h> |
| 19 | #include <asm/timex.h> |
| 20 | #include <asm/mach/map.h> |
| 21 | #include <asm/mach/time.h> |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 22 | #include <mach/bridge-regs.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 23 | #include <mach/loki.h> |
Lennert Buytenhek | 6f088f1 | 2008-08-09 13:44:58 +0200 | [diff] [blame] | 24 | #include <plat/orion_nand.h> |
| 25 | #include <plat/time.h> |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame^] | 26 | #include <plat/common.h> |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 27 | #include "common.h" |
| 28 | |
| 29 | /***************************************************************************** |
| 30 | * I/O Address Mapping |
| 31 | ****************************************************************************/ |
| 32 | static struct map_desc loki_io_desc[] __initdata = { |
| 33 | { |
| 34 | .virtual = LOKI_REGS_VIRT_BASE, |
| 35 | .pfn = __phys_to_pfn(LOKI_REGS_PHYS_BASE), |
| 36 | .length = LOKI_REGS_SIZE, |
| 37 | .type = MT_DEVICE, |
| 38 | }, |
| 39 | }; |
| 40 | |
| 41 | void __init loki_map_io(void) |
| 42 | { |
| 43 | iotable_init(loki_io_desc, ARRAY_SIZE(loki_io_desc)); |
| 44 | } |
| 45 | |
| 46 | |
| 47 | /***************************************************************************** |
| 48 | * GE0 |
| 49 | ****************************************************************************/ |
| 50 | struct mv643xx_eth_shared_platform_data loki_ge0_shared_data = { |
| 51 | .t_clk = LOKI_TCLK, |
| 52 | .dram = &loki_mbus_dram_info, |
| 53 | }; |
| 54 | |
| 55 | static struct resource loki_ge0_shared_resources[] = { |
| 56 | { |
| 57 | .name = "ge0 base", |
| 58 | .start = GE0_PHYS_BASE + 0x2000, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 59 | .end = GE0_PHYS_BASE + SZ_16K - 1, |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 60 | .flags = IORESOURCE_MEM, |
| 61 | }, |
| 62 | }; |
| 63 | |
| 64 | static struct platform_device loki_ge0_shared = { |
| 65 | .name = MV643XX_ETH_SHARED_NAME, |
| 66 | .id = 0, |
| 67 | .dev = { |
| 68 | .platform_data = &loki_ge0_shared_data, |
| 69 | }, |
| 70 | .num_resources = 1, |
| 71 | .resource = loki_ge0_shared_resources, |
| 72 | }; |
| 73 | |
| 74 | static struct resource loki_ge0_resources[] = { |
| 75 | { |
| 76 | .name = "ge0 irq", |
| 77 | .start = IRQ_LOKI_GBE_A_INT, |
| 78 | .end = IRQ_LOKI_GBE_A_INT, |
| 79 | .flags = IORESOURCE_IRQ, |
| 80 | }, |
| 81 | }; |
| 82 | |
| 83 | static struct platform_device loki_ge0 = { |
| 84 | .name = MV643XX_ETH_NAME, |
| 85 | .id = 0, |
| 86 | .num_resources = 1, |
| 87 | .resource = loki_ge0_resources, |
Nicolas Pitre | a49a018 | 2009-05-22 16:53:40 -0400 | [diff] [blame] | 88 | .dev = { |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 89 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Nicolas Pitre | a49a018 | 2009-05-22 16:53:40 -0400 | [diff] [blame] | 90 | }, |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | void __init loki_ge0_init(struct mv643xx_eth_platform_data *eth_data) |
| 94 | { |
| 95 | eth_data->shared = &loki_ge0_shared; |
| 96 | loki_ge0.dev.platform_data = eth_data; |
| 97 | |
| 98 | writel(0x00079220, GE0_VIRT_BASE + 0x20b0); |
| 99 | platform_device_register(&loki_ge0_shared); |
| 100 | platform_device_register(&loki_ge0); |
| 101 | } |
| 102 | |
| 103 | |
| 104 | /***************************************************************************** |
| 105 | * GE1 |
| 106 | ****************************************************************************/ |
| 107 | struct mv643xx_eth_shared_platform_data loki_ge1_shared_data = { |
| 108 | .t_clk = LOKI_TCLK, |
| 109 | .dram = &loki_mbus_dram_info, |
| 110 | }; |
| 111 | |
| 112 | static struct resource loki_ge1_shared_resources[] = { |
| 113 | { |
| 114 | .name = "ge1 base", |
| 115 | .start = GE1_PHYS_BASE + 0x2000, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 116 | .end = GE1_PHYS_BASE + SZ_16K - 1, |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 117 | .flags = IORESOURCE_MEM, |
| 118 | }, |
| 119 | }; |
| 120 | |
| 121 | static struct platform_device loki_ge1_shared = { |
| 122 | .name = MV643XX_ETH_SHARED_NAME, |
| 123 | .id = 1, |
| 124 | .dev = { |
| 125 | .platform_data = &loki_ge1_shared_data, |
| 126 | }, |
| 127 | .num_resources = 1, |
| 128 | .resource = loki_ge1_shared_resources, |
| 129 | }; |
| 130 | |
| 131 | static struct resource loki_ge1_resources[] = { |
| 132 | { |
| 133 | .name = "ge1 irq", |
| 134 | .start = IRQ_LOKI_GBE_B_INT, |
| 135 | .end = IRQ_LOKI_GBE_B_INT, |
| 136 | .flags = IORESOURCE_IRQ, |
| 137 | }, |
| 138 | }; |
| 139 | |
| 140 | static struct platform_device loki_ge1 = { |
| 141 | .name = MV643XX_ETH_NAME, |
| 142 | .id = 1, |
| 143 | .num_resources = 1, |
| 144 | .resource = loki_ge1_resources, |
Nicolas Pitre | a49a018 | 2009-05-22 16:53:40 -0400 | [diff] [blame] | 145 | .dev = { |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 146 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Nicolas Pitre | a49a018 | 2009-05-22 16:53:40 -0400 | [diff] [blame] | 147 | }, |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | void __init loki_ge1_init(struct mv643xx_eth_platform_data *eth_data) |
| 151 | { |
| 152 | eth_data->shared = &loki_ge1_shared; |
| 153 | loki_ge1.dev.platform_data = eth_data; |
| 154 | |
| 155 | writel(0x00079220, GE1_VIRT_BASE + 0x20b0); |
| 156 | platform_device_register(&loki_ge1_shared); |
| 157 | platform_device_register(&loki_ge1); |
| 158 | } |
| 159 | |
| 160 | |
| 161 | /***************************************************************************** |
| 162 | * SAS/SATA |
| 163 | ****************************************************************************/ |
| 164 | static struct resource loki_sas_resources[] = { |
| 165 | { |
| 166 | .name = "mvsas0 mem", |
| 167 | .start = SAS0_PHYS_BASE, |
| 168 | .end = SAS0_PHYS_BASE + 0x01ff, |
| 169 | .flags = IORESOURCE_MEM, |
| 170 | }, { |
| 171 | .name = "mvsas0 irq", |
| 172 | .start = IRQ_LOKI_SAS_A, |
| 173 | .end = IRQ_LOKI_SAS_A, |
| 174 | .flags = IORESOURCE_IRQ, |
| 175 | }, { |
| 176 | .name = "mvsas1 mem", |
| 177 | .start = SAS1_PHYS_BASE, |
| 178 | .end = SAS1_PHYS_BASE + 0x01ff, |
| 179 | .flags = IORESOURCE_MEM, |
| 180 | }, { |
| 181 | .name = "mvsas1 irq", |
| 182 | .start = IRQ_LOKI_SAS_B, |
| 183 | .end = IRQ_LOKI_SAS_B, |
| 184 | .flags = IORESOURCE_IRQ, |
| 185 | }, |
| 186 | }; |
| 187 | |
| 188 | static struct platform_device loki_sas = { |
| 189 | .name = "mvsas", |
| 190 | .id = 0, |
| 191 | .dev = { |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 192 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 193 | }, |
| 194 | .num_resources = ARRAY_SIZE(loki_sas_resources), |
| 195 | .resource = loki_sas_resources, |
| 196 | }; |
| 197 | |
| 198 | void __init loki_sas_init(void) |
| 199 | { |
| 200 | writel(0x8300f707, DDR_REG(0x1424)); |
| 201 | platform_device_register(&loki_sas); |
| 202 | } |
| 203 | |
| 204 | |
| 205 | /***************************************************************************** |
| 206 | * UART0 |
| 207 | ****************************************************************************/ |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 208 | void __init loki_uart0_init(void) |
| 209 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame^] | 210 | orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE, |
| 211 | IRQ_LOKI_UART0, LOKI_TCLK); |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 212 | } |
| 213 | |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 214 | /***************************************************************************** |
| 215 | * UART1 |
| 216 | ****************************************************************************/ |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 217 | void __init loki_uart1_init(void) |
| 218 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame^] | 219 | orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE, |
| 220 | IRQ_LOKI_UART1, LOKI_TCLK); |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | |
| 224 | /***************************************************************************** |
| 225 | * Time handling |
| 226 | ****************************************************************************/ |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 227 | void __init loki_init_early(void) |
| 228 | { |
| 229 | orion_time_set_base(TIMER_VIRT_BASE); |
| 230 | } |
| 231 | |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 232 | static void loki_timer_init(void) |
| 233 | { |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 234 | orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR, |
| 235 | IRQ_LOKI_BRIDGE, LOKI_TCLK); |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | struct sys_timer loki_timer = { |
| 239 | .init = loki_timer_init, |
| 240 | }; |
| 241 | |
| 242 | |
| 243 | /***************************************************************************** |
| 244 | * General |
| 245 | ****************************************************************************/ |
| 246 | void __init loki_init(void) |
| 247 | { |
| 248 | printk(KERN_INFO "Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK); |
| 249 | |
| 250 | loki_setup_cpu_mbus(); |
| 251 | } |