2 * Copyright STMicroelectronics, 2007.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include <linux/types.h>
20 #include <linux/init.h>
21 #include <linux/device.h>
22 #include <linux/amba/bus.h>
23 #include <linux/platform_device.h>
25 #include <linux/slab.h>
26 #include <linux/irq.h>
27 #include <linux/dma-mapping.h>
28 #include <linux/platform_data/clk-nomadik.h>
30 #include <plat/gpio-nomadik.h>
31 #include <mach/hardware.h>
32 #include <mach/irqs.h>
33 #include <asm/mach/map.h>
34 #include <asm/hardware/vic.h>
36 #include <asm/cacheflush.h>
37 #include <asm/hardware/cache-l2x0.h>
41 /* The 8815 has 4 GPIO blocks, let's register them immediately */
42 static resource_size_t __initdata cpu8815_gpio_base[] = {
49 static struct platform_device *
50 cpu8815_add_gpio(int id, resource_size_t addr, int irq,
51 struct nmk_gpio_platform_data *pdata)
53 struct resource resources[] = {
57 .flags = IORESOURCE_MEM,
62 .flags = IORESOURCE_IRQ,
66 return platform_device_register_resndata(NULL, "gpio", id,
67 resources, ARRAY_SIZE(resources),
68 pdata, sizeof(*pdata));
71 void cpu8815_add_gpios(resource_size_t *base, int num, int irq,
72 struct nmk_gpio_platform_data *pdata)
77 for (i = 0; i < num; i++, first += 32, irq++) {
78 pdata->first_gpio = first;
79 pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first);
82 cpu8815_add_gpio(i, base[i], irq, pdata);
87 cpu8815_add_pinctrl(struct device *parent, const char *name)
89 struct platform_device_info pdevinfo = {
95 platform_device_register_full(&pdevinfo);
98 static int __init cpu8815_init(void)
100 struct nmk_gpio_platform_data pdata = {
101 /* No custom data yet */
104 cpu8815_add_gpios(cpu8815_gpio_base, ARRAY_SIZE(cpu8815_gpio_base),
106 cpu8815_add_pinctrl(NULL, "pinctrl-stn8815");
107 amba_apb_device_add(NULL, "rng", NOMADIK_RNG_BASE, SZ_4K, 0, 0, NULL, 0);
108 amba_apb_device_add(NULL, "rtc-pl031", NOMADIK_RTC_BASE, SZ_4K, IRQ_RTC_RTT, 0, NULL, 0);
111 arch_initcall(cpu8815_init);
113 /* All SoC devices live in the same area (see hardware.h) */
114 static struct map_desc nomadik_io_desc[] __initdata = {
116 .virtual = NOMADIK_IO_VIRTUAL,
117 .pfn = __phys_to_pfn(NOMADIK_IO_PHYSICAL),
118 .length = NOMADIK_IO_SIZE,
121 /* static ram and secured ram may be added later */
124 void __init cpu8815_map_io(void)
126 iotable_init(nomadik_io_desc, ARRAY_SIZE(nomadik_io_desc));
129 void __init cpu8815_init_irq(void)
131 /* This modified VIC cell has two register blocks, at 0 and 0x20 */
132 vic_init(io_p2v(NOMADIK_IC_BASE + 0x00), IRQ_VIC_START + 0, ~0, 0);
133 vic_init(io_p2v(NOMADIK_IC_BASE + 0x20), IRQ_VIC_START + 32, ~0, 0);
136 * Init clocks here so that they are available for system timer
143 * This function is called from the board init ("init_machine").
145 void __init cpu8815_platform_init(void)
147 #ifdef CONFIG_CACHE_L2X0
148 /* At full speed latency must be >=2, so 0x249 in low bits */
149 l2x0_init(io_p2v(NOMADIK_L2CC_BASE), 0x00730249, 0xfe000fff);
154 void cpu8815_restart(char mode, const char *cmd)
156 void __iomem *src_rstsr = io_p2v(NOMADIK_SRC_BASE + 0x18);
158 /* FIXME: use egpio when implemented */
160 /* Write anything to Reset status register */
161 writel(1, src_rstsr);