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/mach/map.h>
23 #include <mach/hardware.h>
24 #include <mach/setup.h>
26 #define GPIO_RESOURCE(block) \
28 .start = U8500_GPIOBANK##block##_BASE, \
29 .end = U8500_GPIOBANK##block##_BASE + 127, \
30 .flags = IORESOURCE_MEM, \
33 .start = IRQ_GPIO##block, \
34 .end = IRQ_GPIO##block, \
35 .flags = IORESOURCE_IRQ, \
38 #define GPIO_DEVICE(block) \
43 .resource = &u8500_gpio_resources[block * 2], \
45 .platform_data = &u8500_gpio_data[block], \
49 #define GPIO_DATA(_name, first) \
52 .first_gpio = first, \
53 .first_irq = NOMADIK_GPIO_TO_IRQ(first), \
56 static struct nmk_gpio_platform_data u8500_gpio_data[] = {
57 GPIO_DATA("GPIO-0-31", 0),
58 GPIO_DATA("GPIO-32-63", 32), /* 37..63 not routed to pin */
59 GPIO_DATA("GPIO-64-95", 64),
60 GPIO_DATA("GPIO-96-127", 96), /* 97..127 not routed to pin */
61 GPIO_DATA("GPIO-128-159", 128),
62 GPIO_DATA("GPIO-160-191", 160), /* 172..191 not routed to pin */
63 GPIO_DATA("GPIO-192-223", 192),
64 GPIO_DATA("GPIO-224-255", 224), /* 231..255 not routed to pin */
65 GPIO_DATA("GPIO-256-288", 256), /* 258..288 not routed to pin */
68 static struct resource u8500_gpio_resources[] = {
80 static struct platform_device u8500_gpio_devs[] = {
92 static struct platform_device *platform_devs[] __initdata = {
104 /* minimum static i/o mapping required to boot U8500 platforms */
105 static struct map_desc u8500_io_desc[] __initdata = {
106 __IO_DEV_DESC(U8500_PRCMU_BASE, SZ_4K),
107 __IO_DEV_DESC(U8500_GPIO0_BASE, SZ_4K),
108 __IO_DEV_DESC(U8500_GPIO1_BASE, SZ_4K),
109 __IO_DEV_DESC(U8500_GPIO2_BASE, SZ_4K),
110 __IO_DEV_DESC(U8500_GPIO3_BASE, SZ_4K),
113 static struct map_desc u8500ed_io_desc[] __initdata = {
114 __IO_DEV_DESC(U8500_MTU0_BASE_ED, SZ_4K),
115 __IO_DEV_DESC(U8500_CLKRST7_BASE_ED, SZ_8K),
118 static struct map_desc u8500v1_io_desc[] __initdata = {
119 __IO_DEV_DESC(U8500_MTU0_BASE, SZ_4K),
122 void __init u8500_map_io(void)
126 iotable_init(u8500_io_desc, ARRAY_SIZE(u8500_io_desc));
128 if (cpu_is_u8500ed())
129 iotable_init(u8500ed_io_desc, ARRAY_SIZE(u8500ed_io_desc));
131 iotable_init(u8500v1_io_desc, ARRAY_SIZE(u8500v1_io_desc));
135 * This function is called from the board init
137 void __init u8500_init_devices(void)
139 /* Register the platform devices */
140 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
145 static void __init u8500_timer_init(void)
147 #ifdef CONFIG_LOCAL_TIMERS
148 /* Setup the local timer base */
149 twd_base = __io_address(U8500_TWD_BASE);
151 /* Setup the MTU base */
152 if (cpu_is_u8500ed())
153 mtu_base = __io_address(U8500_MTU0_BASE_ED);
155 mtu_base = __io_address(U8500_MTU0_BASE);
160 struct sys_timer u8500_timer = {
161 .init = u8500_timer_init,