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