Magnus Damm | 7f627f0 | 2012-05-16 15:44:58 +0900 | [diff] [blame^] | 1 | /* |
| 2 | * Emma Mobile EV2 processor support |
| 3 | * |
| 4 | * Copyright (C) 2012 Magnus Damm |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | #include <linux/kernel.h> |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/interrupt.h> |
| 22 | #include <linux/irq.h> |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/delay.h> |
| 25 | #include <linux/input.h> |
| 26 | #include <linux/io.h> |
| 27 | #include <mach/hardware.h> |
| 28 | #include <mach/common.h> |
| 29 | #include <mach/emev2.h> |
| 30 | #include <mach/irqs.h> |
| 31 | #include <asm/mach-types.h> |
| 32 | #include <asm/mach/arch.h> |
| 33 | #include <asm/mach/map.h> |
| 34 | #include <asm/mach/time.h> |
| 35 | #include <asm/hardware/gic.h> |
| 36 | |
| 37 | /* UART */ |
| 38 | static struct resource uart0_resources[] = { |
| 39 | [0] = { |
| 40 | .start = 0xe1020000, |
| 41 | .end = 0xe1020037, |
| 42 | .flags = IORESOURCE_MEM, |
| 43 | }, |
| 44 | [1] = { |
| 45 | .start = 40, |
| 46 | .flags = IORESOURCE_IRQ, |
| 47 | } |
| 48 | }; |
| 49 | |
| 50 | static struct platform_device uart0_device = { |
| 51 | .name = "serial8250-em", |
| 52 | .id = 0, |
| 53 | .num_resources = ARRAY_SIZE(uart0_resources), |
| 54 | .resource = uart0_resources, |
| 55 | }; |
| 56 | |
| 57 | static struct resource uart1_resources[] = { |
| 58 | [0] = { |
| 59 | .start = 0xe1030000, |
| 60 | .end = 0xe1030037, |
| 61 | .flags = IORESOURCE_MEM, |
| 62 | }, |
| 63 | [1] = { |
| 64 | .start = 41, |
| 65 | .flags = IORESOURCE_IRQ, |
| 66 | } |
| 67 | }; |
| 68 | |
| 69 | static struct platform_device uart1_device = { |
| 70 | .name = "serial8250-em", |
| 71 | .id = 1, |
| 72 | .num_resources = ARRAY_SIZE(uart1_resources), |
| 73 | .resource = uart1_resources, |
| 74 | }; |
| 75 | |
| 76 | static struct resource uart2_resources[] = { |
| 77 | [0] = { |
| 78 | .start = 0xe1040000, |
| 79 | .end = 0xe1040037, |
| 80 | .flags = IORESOURCE_MEM, |
| 81 | }, |
| 82 | [1] = { |
| 83 | .start = 42, |
| 84 | .flags = IORESOURCE_IRQ, |
| 85 | } |
| 86 | }; |
| 87 | |
| 88 | static struct platform_device uart2_device = { |
| 89 | .name = "serial8250-em", |
| 90 | .id = 2, |
| 91 | .num_resources = ARRAY_SIZE(uart2_resources), |
| 92 | .resource = uart2_resources, |
| 93 | }; |
| 94 | |
| 95 | static struct resource uart3_resources[] = { |
| 96 | [0] = { |
| 97 | .start = 0xe1050000, |
| 98 | .end = 0xe1050037, |
| 99 | .flags = IORESOURCE_MEM, |
| 100 | }, |
| 101 | [1] = { |
| 102 | .start = 43, |
| 103 | .flags = IORESOURCE_IRQ, |
| 104 | } |
| 105 | }; |
| 106 | |
| 107 | static struct platform_device uart3_device = { |
| 108 | .name = "serial8250-em", |
| 109 | .id = 3, |
| 110 | .num_resources = ARRAY_SIZE(uart3_resources), |
| 111 | .resource = uart3_resources, |
| 112 | }; |
| 113 | |
| 114 | /* STI */ |
| 115 | static struct resource sti_resources[] = { |
| 116 | [0] = { |
| 117 | .name = "STI", |
| 118 | .start = 0xe0180000, |
| 119 | .end = 0xe0180053, |
| 120 | .flags = IORESOURCE_MEM, |
| 121 | }, |
| 122 | [1] = { |
| 123 | .start = 157, |
| 124 | .flags = IORESOURCE_IRQ, |
| 125 | }, |
| 126 | }; |
| 127 | |
| 128 | static struct platform_device sti_device = { |
| 129 | .name = "em_sti", |
| 130 | .id = 0, |
| 131 | .resource = sti_resources, |
| 132 | .num_resources = ARRAY_SIZE(sti_resources), |
| 133 | }; |
| 134 | |
| 135 | static struct platform_device *emev2_early_devices[] __initdata = { |
| 136 | &uart0_device, |
| 137 | &uart1_device, |
| 138 | &uart2_device, |
| 139 | &uart3_device, |
| 140 | }; |
| 141 | |
| 142 | static struct platform_device *emev2_late_devices[] __initdata = { |
| 143 | &sti_device, |
| 144 | }; |
| 145 | |
| 146 | void __init emev2_add_standard_devices(void) |
| 147 | { |
| 148 | emev2_clock_init(); |
| 149 | |
| 150 | platform_add_devices(emev2_early_devices, |
| 151 | ARRAY_SIZE(emev2_early_devices)); |
| 152 | |
| 153 | platform_add_devices(emev2_late_devices, |
| 154 | ARRAY_SIZE(emev2_late_devices)); |
| 155 | } |
| 156 | |
| 157 | void __init emev2_add_early_devices(void) |
| 158 | { |
| 159 | shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */ |
| 160 | |
| 161 | early_platform_add_devices(emev2_early_devices, |
| 162 | ARRAY_SIZE(emev2_early_devices)); |
| 163 | |
| 164 | /* setup early console here as well */ |
| 165 | shmobile_setup_console(); |
| 166 | } |
| 167 | |
| 168 | void __init emev2_init_irq(void) |
| 169 | { |
| 170 | void __iomem *gic_dist_base; |
| 171 | void __iomem *gic_cpu_base; |
| 172 | |
| 173 | /* Static mappings, never released */ |
| 174 | gic_dist_base = ioremap(0xe0028000, PAGE_SIZE); |
| 175 | gic_cpu_base = ioremap(0xe0020000, PAGE_SIZE); |
| 176 | BUG_ON(!gic_dist_base || !gic_cpu_base); |
| 177 | |
| 178 | /* Use GIC to handle interrupts */ |
| 179 | gic_init(0, 29, gic_dist_base, gic_cpu_base); |
| 180 | } |