2 * Copyright (C) 2008-2009 ST-Ericsson
4 * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
11 #include <linux/types.h>
12 #include <linux/init.h>
13 #include <linux/device.h>
14 #include <linux/amba/bus.h>
15 #include <linux/irq.h>
16 #include <linux/gpio.h>
17 #include <linux/platform_device.h>
20 #include <asm/localtimer.h>
21 #include <asm/hardware/gic.h>
22 #include <asm/mach/map.h>
23 #include <asm/hardware/cache-l2x0.h>
25 #include <mach/hardware.h>
26 #include <mach/setup.h>
28 #define GPIO_RESOURCE(block) \
30 .start = U8500_GPIOBANK##block##_BASE, \
31 .end = U8500_GPIOBANK##block##_BASE + 127, \
32 .flags = IORESOURCE_MEM, \
35 .start = IRQ_GPIO##block, \
36 .end = IRQ_GPIO##block, \
37 .flags = IORESOURCE_IRQ, \
40 #define GPIO_DEVICE(block) \
45 .resource = &u8500_gpio_resources[block * 2], \
47 .platform_data = &u8500_gpio_data[block], \
51 #define GPIO_DATA(_name, first) \
54 .first_gpio = first, \
55 .first_irq = NOMADIK_GPIO_TO_IRQ(first), \
58 static struct nmk_gpio_platform_data u8500_gpio_data[] = {
59 GPIO_DATA("GPIO-0-31", 0),
60 GPIO_DATA("GPIO-32-63", 32), /* 37..63 not routed to pin */
61 GPIO_DATA("GPIO-64-95", 64),
62 GPIO_DATA("GPIO-96-127", 96), /* 97..127 not routed to pin */
63 GPIO_DATA("GPIO-128-159", 128),
64 GPIO_DATA("GPIO-160-191", 160), /* 172..191 not routed to pin */
65 GPIO_DATA("GPIO-192-223", 192),
66 GPIO_DATA("GPIO-224-255", 224), /* 231..255 not routed to pin */
67 GPIO_DATA("GPIO-256-288", 256), /* 258..288 not routed to pin */
70 static struct resource u8500_gpio_resources[] = {
82 static struct platform_device u8500_gpio_devs[] = {
94 static struct platform_device *platform_devs[] __initdata = {
106 #define __IO_DEV_DESC(x, sz) { \
107 .virtual = IO_ADDRESS(x), \
108 .pfn = __phys_to_pfn(x), \
113 /* minimum static i/o mapping required to boot U8500 platforms */
114 static struct map_desc u8500_io_desc[] __initdata = {
115 __IO_DEV_DESC(U8500_UART2_BASE, SZ_4K),
116 __IO_DEV_DESC(U8500_GIC_CPU_BASE, SZ_4K),
117 __IO_DEV_DESC(U8500_GIC_DIST_BASE, SZ_4K),
118 __IO_DEV_DESC(U8500_TWD_BASE, SZ_4K),
119 __IO_DEV_DESC(U8500_SCU_BASE, SZ_4K),
120 __IO_DEV_DESC(U8500_BACKUPRAM0_BASE, SZ_8K),
121 __IO_DEV_DESC(U8500_PRCMU_BASE, SZ_4K),
122 __IO_DEV_DESC(U8500_CLKRST1_BASE, SZ_4K),
123 __IO_DEV_DESC(U8500_CLKRST2_BASE, SZ_4K),
124 __IO_DEV_DESC(U8500_CLKRST3_BASE, SZ_4K),
125 __IO_DEV_DESC(U8500_CLKRST5_BASE, SZ_4K),
126 __IO_DEV_DESC(U8500_CLKRST6_BASE, SZ_4K),
127 __IO_DEV_DESC(U8500_GPIO1_BASE, SZ_4K),
128 __IO_DEV_DESC(U8500_GPIO2_BASE, SZ_4K),
129 __IO_DEV_DESC(U8500_GPIO3_BASE, SZ_4K),
130 __IO_DEV_DESC(U8500_GPIO5_BASE, SZ_4K),
131 __IO_DEV_DESC(U8500_L2CC_BASE, SZ_4K),
134 static struct map_desc u8500ed_io_desc[] __initdata = {
135 __IO_DEV_DESC(U8500_MTU0_BASE_ED, SZ_4K),
136 __IO_DEV_DESC(U8500_CLKRST7_BASE_ED, SZ_8K),
139 static struct map_desc u8500v1_io_desc[] __initdata = {
140 __IO_DEV_DESC(U8500_MTU0_BASE_V1, SZ_4K),
143 void __init u8500_map_io(void)
145 iotable_init(u8500_io_desc, ARRAY_SIZE(u8500_io_desc));
147 if (cpu_is_u8500ed())
148 iotable_init(u8500ed_io_desc, ARRAY_SIZE(u8500ed_io_desc));
150 iotable_init(u8500v1_io_desc, ARRAY_SIZE(u8500v1_io_desc));
153 void __init u8500_init_irq(void)
155 gic_dist_init(0, __io_address(U8500_GIC_DIST_BASE), 29);
156 gic_cpu_init(0, __io_address(U8500_GIC_CPU_BASE));
160 * This function is called from the board init
162 void __init u8500_init_devices(void)
164 /* Register the platform devices */
165 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
170 static void __init u8500_timer_init(void)
172 #ifdef CONFIG_LOCAL_TIMERS
173 /* Setup the local timer base */
174 twd_base = __io_address(U8500_TWD_BASE);
176 /* Setup the MTU base */
177 if (cpu_is_u8500ed())
178 mtu_base = __io_address(U8500_MTU0_BASE_ED);
180 mtu_base = __io_address(U8500_MTU0_BASE_V1);
185 struct sys_timer u8500_timer = {
186 .init = u8500_timer_init,
189 #ifdef CONFIG_CACHE_L2X0
190 static int u8500_l2x0_init(void)
192 void __iomem *l2x0_base;
194 l2x0_base = __io_address(U8500_L2CC_BASE);
196 /* 64KB way size, 8 way associativity, force WA */
197 l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff);
201 early_initcall(u8500_l2x0_init);