]>
Commit | Line | Data |
---|---|---|
28ad94ec AR |
1 | /* |
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> | |
2ec1d359 | 22 | #include <linux/amba/bus.h> |
3e3c62ca | 23 | #include <linux/platform_device.h> |
35b47a40 | 24 | #include <linux/io.h> |
28ad94ec | 25 | |
0f332861 | 26 | #include <plat/gpio-nomadik.h> |
28ad94ec AR |
27 | #include <mach/hardware.h> |
28 | #include <mach/irqs.h> | |
29 | #include <asm/mach/map.h> | |
30 | #include <asm/hardware/vic.h> | |
31 | ||
0b260fd4 AR |
32 | #include <asm/cacheflush.h> |
33 | #include <asm/hardware/cache-l2x0.h> | |
34 | ||
ba327b1e | 35 | #include "clock.h" |
61b38753 | 36 | #include "cpu-8815.h" |
ba327b1e | 37 | |
056c78d3 | 38 | static AMBA_APB_DEVICE(cpu8815_amba_rng, "rng", 0, NOMADIK_RNG_BASE, { }, NULL); |
3e3c62ca | 39 | |
056c78d3 LW |
40 | static struct amba_device *amba_devs[] __initdata = { |
41 | &cpu8815_amba_rng_device | |
2ec1d359 AR |
42 | }; |
43 | ||
056c78d3 LW |
44 | /* The 8815 has 4 GPIO blocks, let's register them immediately */ |
45 | static resource_size_t __initdata cpu8815_gpio_base[] = { | |
46 | NOMADIK_GPIO0_BASE, | |
47 | NOMADIK_GPIO1_BASE, | |
48 | NOMADIK_GPIO2_BASE, | |
49 | NOMADIK_GPIO3_BASE, | |
3e3c62ca | 50 | }; |
2ec1d359 | 51 | |
056c78d3 LW |
52 | static struct platform_device * |
53 | cpu8815_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 | } | |
2ec1d359 | 73 | |
056c78d3 LW |
74 | void 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; | |
d2392ba0 | 79 | |
056c78d3 LW |
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; | |
3e3c62ca | 84 | |
056c78d3 LW |
85 | cpu8815_add_gpio(i, base[i], irq, pdata); |
86 | } | |
87 | } | |
2ec1d359 AR |
88 | |
89 | static int __init cpu8815_init(void) | |
90 | { | |
91 | int i; | |
056c78d3 LW |
92 | struct nmk_gpio_platform_data pdata = { |
93 | /* No custom data yet */ | |
94 | }; | |
2ec1d359 | 95 | |
056c78d3 LW |
96 | cpu8815_add_gpios(cpu8815_gpio_base, ARRAY_SIZE(cpu8815_gpio_base), |
97 | IRQ_GPIO0, &pdata); | |
2ec1d359 AR |
98 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) |
99 | amba_device_register(amba_devs[i], &iomem_resource); | |
100 | return 0; | |
101 | } | |
102 | arch_initcall(cpu8815_init); | |
103 | ||
28ad94ec AR |
104 | /* All SoC devices live in the same area (see hardware.h) */ |
105 | static 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 | ||
115 | void __init cpu8815_map_io(void) | |
116 | { | |
117 | iotable_init(nomadik_io_desc, ARRAY_SIZE(nomadik_io_desc)); | |
118 | } | |
119 | ||
120 | void __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); | |
ba327b1e LW |
125 | |
126 | /* | |
127 | * Init clocks here so that they are available for system timer | |
128 | * initialization. | |
129 | */ | |
130 | clk_init(); | |
28ad94ec AR |
131 | } |
132 | ||
133 | /* | |
134 | * This function is called from the board init ("init_machine"). | |
28ad94ec AR |
135 | */ |
136 | void __init cpu8815_platform_init(void) | |
137 | { | |
0b260fd4 AR |
138 | #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 | |
28ad94ec AR |
142 | return; |
143 | } | |
35b47a40 RK |
144 | |
145 | void 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 | } |