Commit | Line | Data |
---|---|---|
28ad94ec AR |
1 | /* |
2 | * linux/arch/arm/mach-nomadik/board-8815nhk.c | |
3 | * | |
4 | * Copyright (C) STMicroelectronics | |
5 | * | |
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. | |
9 | * | |
10 | * NHK15 board specifc driver definition | |
11 | */ | |
12 | #include <linux/types.h> | |
13 | #include <linux/kernel.h> | |
14 | #include <linux/init.h> | |
15 | #include <linux/platform_device.h> | |
16 | #include <linux/amba/bus.h> | |
725b1f9d AR |
17 | #include <linux/interrupt.h> |
18 | #include <linux/gpio.h> | |
63234717 AR |
19 | #include <linux/mtd/mtd.h> |
20 | #include <linux/mtd/nand.h> | |
c1558b55 | 21 | #include <linux/mtd/onenand.h> |
63234717 AR |
22 | #include <linux/mtd/partitions.h> |
23 | #include <linux/io.h> | |
42ab5304 | 24 | #include <asm/hardware/vic.h> |
63234717 | 25 | #include <asm/sizes.h> |
28ad94ec AR |
26 | #include <asm/mach-types.h> |
27 | #include <asm/mach/arch.h> | |
28 | #include <asm/mach/irq.h> | |
8b85e7cb | 29 | #include <asm/mach/flash.h> |
b9576623 | 30 | #include <asm/mach/time.h> |
59b559d7 | 31 | |
0f332861 | 32 | #include <plat/gpio-nomadik.h> |
59b559d7 SK |
33 | #include <plat/mtu.h> |
34 | ||
63234717 AR |
35 | #include <mach/nand.h> |
36 | #include <mach/fsmc.h> | |
28ad94ec | 37 | |
61b38753 LW |
38 | #include "cpu-8815.h" |
39 | ||
59b559d7 SK |
40 | /* Initial value for SRC control register: all timers use MXTAL/8 source */ |
41 | #define SRC_CR_INIT_MASK 0x00007fff | |
42 | #define SRC_CR_INIT_VAL 0x2aaa8000 | |
43 | ||
3ad2f3fb | 44 | /* These addresses span 16MB, so use three individual pages */ |
63234717 AR |
45 | static struct resource nhk8815_nand_resources[] = { |
46 | { | |
47 | .name = "nand_addr", | |
48 | .start = NAND_IO_ADDR, | |
49 | .end = NAND_IO_ADDR + 0xfff, | |
50 | .flags = IORESOURCE_MEM, | |
51 | }, { | |
52 | .name = "nand_cmd", | |
53 | .start = NAND_IO_CMD, | |
54 | .end = NAND_IO_CMD + 0xfff, | |
55 | .flags = IORESOURCE_MEM, | |
56 | }, { | |
57 | .name = "nand_data", | |
58 | .start = NAND_IO_DATA, | |
59 | .end = NAND_IO_DATA + 0xfff, | |
60 | .flags = IORESOURCE_MEM, | |
61 | } | |
62 | }; | |
63 | ||
64 | static int nhk8815_nand_init(void) | |
65 | { | |
66 | /* FSMC setup for nand chip select (8-bit nand in 8815NHK) */ | |
67 | writel(0x0000000E, FSMC_PCR(0)); | |
68 | writel(0x000D0A00, FSMC_PMEM(0)); | |
69 | writel(0x00100A00, FSMC_PATT(0)); | |
70 | ||
71 | /* enable access to the chip select area */ | |
72 | writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0)); | |
73 | ||
74 | return 0; | |
75 | } | |
76 | ||
77 | /* | |
78 | * These partitions are the same as those used in the 2.6.20 release | |
79 | * shipped by the vendor; the first two partitions are mandated | |
80 | * by the boot ROM, and the bootloader area is somehow oversized... | |
81 | */ | |
82 | static struct mtd_partition nhk8815_partitions[] = { | |
83 | { | |
84 | .name = "X-Loader(NAND)", | |
85 | .offset = 0, | |
86 | .size = SZ_256K, | |
87 | }, { | |
88 | .name = "MemInit(NAND)", | |
89 | .offset = MTDPART_OFS_APPEND, | |
90 | .size = SZ_256K, | |
91 | }, { | |
92 | .name = "BootLoader(NAND)", | |
93 | .offset = MTDPART_OFS_APPEND, | |
94 | .size = SZ_2M, | |
95 | }, { | |
96 | .name = "Kernel zImage(NAND)", | |
97 | .offset = MTDPART_OFS_APPEND, | |
98 | .size = 3 * SZ_1M, | |
99 | }, { | |
100 | .name = "Root Filesystem(NAND)", | |
101 | .offset = MTDPART_OFS_APPEND, | |
102 | .size = 22 * SZ_1M, | |
103 | }, { | |
104 | .name = "User Filesystem(NAND)", | |
105 | .offset = MTDPART_OFS_APPEND, | |
106 | .size = MTDPART_SIZ_FULL, | |
107 | } | |
108 | }; | |
109 | ||
110 | static struct nomadik_nand_platform_data nhk8815_nand_data = { | |
111 | .parts = nhk8815_partitions, | |
112 | .nparts = ARRAY_SIZE(nhk8815_partitions), | |
113 | .options = NAND_COPYBACK | NAND_CACHEPRG | NAND_NO_PADDING \ | |
1826dbcc | 114 | | NAND_NO_READRDY, |
63234717 AR |
115 | .init = nhk8815_nand_init, |
116 | }; | |
117 | ||
118 | static struct platform_device nhk8815_nand_device = { | |
119 | .name = "nomadik_nand", | |
120 | .dev = { | |
121 | .platform_data = &nhk8815_nand_data, | |
122 | }, | |
123 | .resource = nhk8815_nand_resources, | |
124 | .num_resources = ARRAY_SIZE(nhk8815_nand_resources), | |
125 | }; | |
126 | ||
8b85e7cb AR |
127 | /* These are the partitions for the OneNand device, different from above */ |
128 | static struct mtd_partition nhk8815_onenand_partitions[] = { | |
129 | { | |
130 | .name = "X-Loader(OneNAND)", | |
131 | .offset = 0, | |
132 | .size = SZ_256K, | |
133 | }, { | |
134 | .name = "MemInit(OneNAND)", | |
135 | .offset = MTDPART_OFS_APPEND, | |
136 | .size = SZ_256K, | |
137 | }, { | |
138 | .name = "BootLoader(OneNAND)", | |
139 | .offset = MTDPART_OFS_APPEND, | |
140 | .size = SZ_2M-SZ_256K, | |
141 | }, { | |
142 | .name = "SysImage(OneNAND)", | |
143 | .offset = MTDPART_OFS_APPEND, | |
144 | .size = 4 * SZ_1M, | |
145 | }, { | |
146 | .name = "Root Filesystem(OneNAND)", | |
147 | .offset = MTDPART_OFS_APPEND, | |
148 | .size = 22 * SZ_1M, | |
149 | }, { | |
150 | .name = "User Filesystem(OneNAND)", | |
151 | .offset = MTDPART_OFS_APPEND, | |
152 | .size = MTDPART_SIZ_FULL, | |
153 | } | |
154 | }; | |
155 | ||
c1558b55 | 156 | static struct onenand_platform_data nhk8815_onenand_data = { |
8b85e7cb AR |
157 | .parts = nhk8815_onenand_partitions, |
158 | .nr_parts = ARRAY_SIZE(nhk8815_onenand_partitions), | |
159 | }; | |
160 | ||
161 | static struct resource nhk8815_onenand_resource[] = { | |
162 | { | |
163 | .start = 0x30000000, | |
164 | .end = 0x30000000 + SZ_128K - 1, | |
165 | .flags = IORESOURCE_MEM, | |
166 | }, | |
167 | }; | |
168 | ||
169 | static struct platform_device nhk8815_onenand_device = { | |
c1558b55 | 170 | .name = "onenand-flash", |
8b85e7cb AR |
171 | .id = -1, |
172 | .dev = { | |
173 | .platform_data = &nhk8815_onenand_data, | |
174 | }, | |
175 | .resource = nhk8815_onenand_resource, | |
176 | .num_resources = ARRAY_SIZE(nhk8815_onenand_resource), | |
177 | }; | |
178 | ||
179 | static void __init nhk8815_onenand_init(void) | |
180 | { | |
c1558b55 | 181 | #ifdef CONFIG_MTD_ONENAND |
8b85e7cb | 182 | /* Set up SMCS0 for OneNand */ |
c1558b55 AR |
183 | writel(0x000030db, FSMC_BCR(0)); |
184 | writel(0x02100551, FSMC_BTR(0)); | |
8b85e7cb AR |
185 | #endif |
186 | } | |
63234717 | 187 | |
725b1f9d AR |
188 | static struct resource nhk8815_eth_resources[] = { |
189 | { | |
190 | .name = "smc91x-regs", | |
191 | .start = 0x34000000 + 0x300, | |
192 | .end = 0x34000000 + SZ_64K - 1, | |
193 | .flags = IORESOURCE_MEM, | |
194 | }, { | |
195 | .start = NOMADIK_GPIO_TO_IRQ(115), | |
196 | .end = NOMADIK_GPIO_TO_IRQ(115), | |
197 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING, | |
198 | } | |
199 | }; | |
200 | ||
201 | static struct platform_device nhk8815_eth_device = { | |
202 | .name = "smc91x", | |
203 | .resource = nhk8815_eth_resources, | |
204 | .num_resources = ARRAY_SIZE(nhk8815_eth_resources), | |
205 | }; | |
206 | ||
207 | static int __init nhk8815_eth_init(void) | |
208 | { | |
209 | int gpio_nr = 115; /* hardwired in the board */ | |
210 | int err; | |
211 | ||
212 | err = gpio_request(gpio_nr, "eth_irq"); | |
213 | if (!err) err = nmk_gpio_set_mode(gpio_nr, NMK_GPIO_ALT_GPIO); | |
214 | if (!err) err = gpio_direction_input(gpio_nr); | |
215 | if (err) | |
216 | pr_err("Error %i in %s\n", err, __func__); | |
217 | return err; | |
218 | } | |
219 | device_initcall(nhk8815_eth_init); | |
220 | ||
28ad94ec | 221 | static struct platform_device *nhk8815_platform_devices[] __initdata = { |
63234717 | 222 | &nhk8815_nand_device, |
8b85e7cb | 223 | &nhk8815_onenand_device, |
725b1f9d AR |
224 | &nhk8815_eth_device, |
225 | /* will add more devices */ | |
28ad94ec AR |
226 | }; |
227 | ||
59b559d7 SK |
228 | static void __init nomadik_timer_init(void) |
229 | { | |
230 | u32 src_cr; | |
231 | ||
232 | /* Configure timer sources in "system reset controller" ctrl reg */ | |
233 | src_cr = readl(io_p2v(NOMADIK_SRC_BASE)); | |
234 | src_cr &= SRC_CR_INIT_MASK; | |
235 | src_cr |= SRC_CR_INIT_VAL; | |
236 | writel(src_cr, io_p2v(NOMADIK_SRC_BASE)); | |
237 | ||
b9576623 | 238 | nmdk_timer_init(io_p2v(NOMADIK_MTU0_BASE)); |
59b559d7 SK |
239 | } |
240 | ||
241 | static struct sys_timer nomadik_timer = { | |
242 | .init = nomadik_timer_init, | |
243 | }; | |
244 | ||
28ad94ec AR |
245 | static void __init nhk8815_platform_init(void) |
246 | { | |
28ad94ec | 247 | cpu8815_platform_init(); |
8b85e7cb | 248 | nhk8815_onenand_init(); |
28ad94ec AR |
249 | platform_add_devices(nhk8815_platform_devices, |
250 | ARRAY_SIZE(nhk8815_platform_devices)); | |
251 | ||
7c77852d LW |
252 | amba_apb_device_add(NULL, "uart0", NOMADIK_UART0_BASE, SZ_4K, IRQ_UART0, 0, NULL, 0); |
253 | amba_apb_device_add(NULL, "uart1", NOMADIK_UART1_BASE, SZ_4K, IRQ_UART1, 0, NULL, 0); | |
28ad94ec AR |
254 | } |
255 | ||
256 | MACHINE_START(NOMADIK, "NHK8815") | |
257 | /* Maintainer: ST MicroElectronics */ | |
013b5fb2 | 258 | .atag_offset = 0x100, |
28ad94ec AR |
259 | .map_io = cpu8815_map_io, |
260 | .init_irq = cpu8815_init_irq, | |
42ab5304 | 261 | .handle_irq = vic_handle_irq, |
28ad94ec AR |
262 | .timer = &nomadik_timer, |
263 | .init_machine = nhk8815_platform_init, | |
35b47a40 | 264 | .restart = cpu8815_restart, |
28ad94ec | 265 | MACHINE_END |