blob: b79b3846935a0f8450924e1ff9e9c57bfc88be9b [file] [log] [blame]
Alessandro Rubini28ad94e2009-07-02 19:06:47 +01001/*
2 * Copyright STMicroelectronics, 2007.
3 *
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.
8 *
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.
13 *
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
17 */
18
19#include <linux/types.h>
20#include <linux/init.h>
21#include <linux/device.h>
Alessandro Rubini2ec1d352009-07-02 15:29:12 +010022#include <linux/amba/bus.h>
Rabin Vincent3e3c62c2010-03-03 04:52:34 +010023#include <linux/platform_device.h>
Russell King35b47a4052011-11-28 10:48:02 +000024#include <linux/io.h>
Alessandro Rubini28ad94e2009-07-02 19:06:47 +010025
Linus Walleij0f332862011-08-22 08:33:30 +010026#include <plat/gpio-nomadik.h>
Alessandro Rubini28ad94e2009-07-02 19:06:47 +010027#include <mach/hardware.h>
28#include <mach/irqs.h>
29#include <asm/mach/map.h>
30#include <asm/hardware/vic.h>
31
Alessandro Rubini0b260fd2009-07-02 15:29:43 +010032#include <asm/cacheflush.h>
33#include <asm/hardware/cache-l2x0.h>
34
Linus Walleijba327b12010-05-26 07:38:54 +010035#include "clock.h"
Linus Walleij61b38752011-11-28 12:20:53 +010036#include "cpu-8815.h"
Linus Walleijba327b12010-05-26 07:38:54 +010037
Russell King53d68af2011-12-18 15:28:51 +000038static AMBA_APB_DEVICE(cpu8815_amba_rng, "rng", 0, NOMADIK_RNG_BASE, { }, NULL);
Alessandro Rubinid2392ba2009-12-19 19:46:33 +080039
Alessandro Rubini2ec1d352009-07-02 15:29:12 +010040static struct amba_device *amba_devs[] __initdata = {
Russell King53d68af2011-12-18 15:28:51 +000041 &cpu8815_amba_rng_device
Alessandro Rubini2ec1d352009-07-02 15:29:12 +010042};
43
Linus Walleij056c78d2012-01-09 11:42:39 +010044/* The 8815 has 4 GPIO blocks, let's register them immediately */
45static resource_size_t __initdata cpu8815_gpio_base[] = {
46 NOMADIK_GPIO0_BASE,
47 NOMADIK_GPIO1_BASE,
48 NOMADIK_GPIO2_BASE,
49 NOMADIK_GPIO3_BASE,
50};
51
52static struct platform_device *
53cpu8815_add_gpio(int id, resource_size_t addr, int irq,
54 struct nmk_gpio_platform_data *pdata)
55{
56 struct resource resources[] = {
57 {
58 .start = addr,
59 .end = addr + 127,
60 .flags = IORESOURCE_MEM,
61 },
62 {
63 .start = irq,
64 .end = irq,
65 .flags = IORESOURCE_IRQ,
66 }
67 };
68
69 return platform_device_register_resndata(NULL, "gpio", id,
70 resources, ARRAY_SIZE(resources),
71 pdata, sizeof(*pdata));
72}
73
74void cpu8815_add_gpios(resource_size_t *base, int num, int irq,
75 struct nmk_gpio_platform_data *pdata)
76{
77 int first = 0;
78 int i;
79
80 for (i = 0; i < num; i++, first += 32, irq++) {
81 pdata->first_gpio = first;
82 pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first);
83 pdata->num_gpio = 32;
84
85 cpu8815_add_gpio(i, base[i], irq, pdata);
86 }
87}
88
Alessandro Rubini2ec1d352009-07-02 15:29:12 +010089static int __init cpu8815_init(void)
90{
91 int i;
Linus Walleij056c78d2012-01-09 11:42:39 +010092 struct nmk_gpio_platform_data pdata = {
93 /* No custom data yet */
94 };
Alessandro Rubini2ec1d352009-07-02 15:29:12 +010095
Linus Walleij056c78d2012-01-09 11:42:39 +010096 cpu8815_add_gpios(cpu8815_gpio_base, ARRAY_SIZE(cpu8815_gpio_base),
97 IRQ_GPIO0, &pdata);
Alessandro Rubini2ec1d352009-07-02 15:29:12 +010098 for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
99 amba_device_register(amba_devs[i], &iomem_resource);
100 return 0;
101}
102arch_initcall(cpu8815_init);
103
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100104/* All SoC devices live in the same area (see hardware.h) */
105static struct map_desc nomadik_io_desc[] __initdata = {
106 {
107 .virtual = NOMADIK_IO_VIRTUAL,
108 .pfn = __phys_to_pfn(NOMADIK_IO_PHYSICAL),
109 .length = NOMADIK_IO_SIZE,
110 .type = MT_DEVICE,
111 }
112 /* static ram and secured ram may be added later */
113};
114
115void __init cpu8815_map_io(void)
116{
117 iotable_init(nomadik_io_desc, ARRAY_SIZE(nomadik_io_desc));
118}
119
120void __init cpu8815_init_irq(void)
121{
122 /* This modified VIC cell has two register blocks, at 0 and 0x20 */
123 vic_init(io_p2v(NOMADIK_IC_BASE + 0x00), IRQ_VIC_START + 0, ~0, 0);
124 vic_init(io_p2v(NOMADIK_IC_BASE + 0x20), IRQ_VIC_START + 32, ~0, 0);
Linus Walleijba327b12010-05-26 07:38:54 +0100125
126 /*
127 * Init clocks here so that they are available for system timer
128 * initialization.
129 */
130 clk_init();
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100131}
132
133/*
134 * This function is called from the board init ("init_machine").
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100135 */
136 void __init cpu8815_platform_init(void)
137{
Alessandro Rubini0b260fd2009-07-02 15:29:43 +0100138#ifdef CONFIG_CACHE_L2X0
139 /* At full speed latency must be >=2, so 0x249 in low bits */
140 l2x0_init(io_p2v(NOMADIK_L2CC_BASE), 0x00730249, 0xfe000fff);
141#endif
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100142 return;
143}
Russell King35b47a4052011-11-28 10:48:02 +0000144
145void cpu8815_restart(char mode, const char *cmd)
146{
147 void __iomem *src_rstsr = io_p2v(NOMADIK_SRC_BASE + 0x18);
148
149 /* FIXME: use egpio when implemented */
150
151 /* Write anything to Reset status register */
152 writel(1, src_rstsr);
153}