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>
24 #include <mach/hardware.h>
25 #include <mach/setup.h>
27 #define GPIO_RESOURCE(block) \
29 .start = U8500_GPIOBANK##block##_BASE, \
30 .end = U8500_GPIOBANK##block##_BASE + 127, \
31 .flags = IORESOURCE_MEM, \
34 .start = IRQ_GPIO##block, \
35 .end = IRQ_GPIO##block, \
36 .flags = IORESOURCE_IRQ, \
39 #define GPIO_DEVICE(block) \
44 .resource = &u8500_gpio_resources[block * 2], \
46 .platform_data = &u8500_gpio_data[block], \
50 #define GPIO_DATA(_name, first) \
53 .first_gpio = first, \
54 .first_irq = NOMADIK_GPIO_TO_IRQ(first), \
57 static struct nmk_gpio_platform_data u8500_gpio_data[] = {
58 GPIO_DATA("GPIO-0-31", 0),
59 GPIO_DATA("GPIO-32-63", 32), /* 37..63 not routed to pin */
60 GPIO_DATA("GPIO-64-95", 64),
61 GPIO_DATA("GPIO-96-127", 96), /* 97..127 not routed to pin */
62 GPIO_DATA("GPIO-128-159", 128),
63 GPIO_DATA("GPIO-160-191", 160), /* 172..191 not routed to pin */
64 GPIO_DATA("GPIO-192-223", 192),
65 GPIO_DATA("GPIO-224-255", 224), /* 231..255 not routed to pin */
66 GPIO_DATA("GPIO-256-288", 256), /* 258..288 not routed to pin */
69 static struct resource u8500_gpio_resources[] = {
81 static struct platform_device u8500_gpio_devs[] = {
93 static struct platform_device *platform_devs[] __initdata = {
105 #define __IO_DEV_DESC(x, sz) { \
106 .virtual = IO_ADDRESS(x), \
107 .pfn = __phys_to_pfn(x), \
112 /* minimum static i/o mapping required to boot U8500 platforms */
113 static struct map_desc u8500_io_desc[] __initdata = {
114 __IO_DEV_DESC(U8500_UART2_BASE, SZ_4K),
115 __IO_DEV_DESC(U8500_GIC_CPU_BASE, SZ_4K),
116 __IO_DEV_DESC(U8500_GIC_DIST_BASE, SZ_4K),
117 __IO_DEV_DESC(U8500_TWD_BASE, SZ_4K),
118 __IO_DEV_DESC(U8500_SCU_BASE, SZ_4K),
119 __IO_DEV_DESC(U8500_BACKUPRAM0_BASE, SZ_8K),
120 __IO_DEV_DESC(U8500_PRCMU_BASE, SZ_4K),
121 __IO_DEV_DESC(U8500_CLKRST1_BASE, SZ_4K),
122 __IO_DEV_DESC(U8500_CLKRST2_BASE, SZ_4K),
123 __IO_DEV_DESC(U8500_CLKRST3_BASE, SZ_4K),
124 __IO_DEV_DESC(U8500_CLKRST5_BASE, SZ_4K),
125 __IO_DEV_DESC(U8500_CLKRST6_BASE, SZ_4K),
126 __IO_DEV_DESC(U8500_GPIO1_BASE, SZ_4K),
127 __IO_DEV_DESC(U8500_GPIO2_BASE, SZ_4K),
128 __IO_DEV_DESC(U8500_GPIO3_BASE, SZ_4K),
129 __IO_DEV_DESC(U8500_GPIO5_BASE, SZ_4K),
132 static struct map_desc u8500ed_io_desc[] __initdata = {
133 __IO_DEV_DESC(U8500_MTU0_BASE_ED, SZ_4K),
134 __IO_DEV_DESC(U8500_CLKRST7_BASE_ED, SZ_8K),
137 static struct map_desc u8500v1_io_desc[] __initdata = {
138 __IO_DEV_DESC(U8500_MTU0_BASE_V1, SZ_4K),
141 void __init u8500_map_io(void)
143 iotable_init(u8500_io_desc, ARRAY_SIZE(u8500_io_desc));
145 if (cpu_is_u8500ed())
146 iotable_init(u8500ed_io_desc, ARRAY_SIZE(u8500ed_io_desc));
148 iotable_init(u8500v1_io_desc, ARRAY_SIZE(u8500v1_io_desc));
151 void __init u8500_init_irq(void)
153 gic_dist_init(0, __io_address(U8500_GIC_DIST_BASE), 29);
154 gic_cpu_init(0, __io_address(U8500_GIC_CPU_BASE));
158 * This function is called from the board init
160 void __init u8500_init_devices(void)
162 /* Register the platform devices */
163 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
168 static void __init u8500_timer_init(void)
170 #ifdef CONFIG_LOCAL_TIMERS
171 /* Setup the local timer base */
172 twd_base = __io_address(U8500_TWD_BASE);
174 /* Setup the MTU base */
175 if (cpu_is_u8500ed())
176 mtu_base = __io_address(U8500_MTU0_BASE_ED);
178 mtu_base = __io_address(U8500_MTU0_BASE_V1);
183 struct sys_timer u8500_timer = {
184 .init = u8500_timer_init,