2 * linux/arch/arm/mach-nomadik/board-8815nhk.c
4 * Copyright (C) STMicroelectronics
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.
10 * NHK15 board specifc driver definition
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>
17 #include <linux/interrupt.h>
18 #include <linux/gpio.h>
19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/nand.h>
21 #include <linux/mtd/onenand.h>
22 #include <linux/mtd/partitions.h>
24 #include <asm/sizes.h>
25 #include <asm/mach-types.h>
26 #include <asm/mach/arch.h>
27 #include <asm/mach/irq.h>
28 #include <asm/mach/flash.h>
30 #include <plat/gpio-nomadik.h>
33 #include <mach/setup.h>
34 #include <mach/nand.h>
35 #include <mach/fsmc.h>
37 /* Initial value for SRC control register: all timers use MXTAL/8 source */
38 #define SRC_CR_INIT_MASK 0x00007fff
39 #define SRC_CR_INIT_VAL 0x2aaa8000
41 /* These addresses span 16MB, so use three individual pages */
42 static struct resource nhk8815_nand_resources
[] = {
45 .start
= NAND_IO_ADDR
,
46 .end
= NAND_IO_ADDR
+ 0xfff,
47 .flags
= IORESOURCE_MEM
,
51 .end
= NAND_IO_CMD
+ 0xfff,
52 .flags
= IORESOURCE_MEM
,
55 .start
= NAND_IO_DATA
,
56 .end
= NAND_IO_DATA
+ 0xfff,
57 .flags
= IORESOURCE_MEM
,
61 static int nhk8815_nand_init(void)
63 /* FSMC setup for nand chip select (8-bit nand in 8815NHK) */
64 writel(0x0000000E, FSMC_PCR(0));
65 writel(0x000D0A00, FSMC_PMEM(0));
66 writel(0x00100A00, FSMC_PATT(0));
68 /* enable access to the chip select area */
69 writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0));
75 * These partitions are the same as those used in the 2.6.20 release
76 * shipped by the vendor; the first two partitions are mandated
77 * by the boot ROM, and the bootloader area is somehow oversized...
79 static struct mtd_partition nhk8815_partitions
[] = {
81 .name
= "X-Loader(NAND)",
85 .name
= "MemInit(NAND)",
86 .offset
= MTDPART_OFS_APPEND
,
89 .name
= "BootLoader(NAND)",
90 .offset
= MTDPART_OFS_APPEND
,
93 .name
= "Kernel zImage(NAND)",
94 .offset
= MTDPART_OFS_APPEND
,
97 .name
= "Root Filesystem(NAND)",
98 .offset
= MTDPART_OFS_APPEND
,
101 .name
= "User Filesystem(NAND)",
102 .offset
= MTDPART_OFS_APPEND
,
103 .size
= MTDPART_SIZ_FULL
,
107 static struct nomadik_nand_platform_data nhk8815_nand_data
= {
108 .parts
= nhk8815_partitions
,
109 .nparts
= ARRAY_SIZE(nhk8815_partitions
),
110 .options
= NAND_COPYBACK
| NAND_CACHEPRG
| NAND_NO_PADDING \
111 | NAND_NO_READRDY
| NAND_NO_AUTOINCR
,
112 .init
= nhk8815_nand_init
,
115 static struct platform_device nhk8815_nand_device
= {
116 .name
= "nomadik_nand",
118 .platform_data
= &nhk8815_nand_data
,
120 .resource
= nhk8815_nand_resources
,
121 .num_resources
= ARRAY_SIZE(nhk8815_nand_resources
),
124 /* These are the partitions for the OneNand device, different from above */
125 static struct mtd_partition nhk8815_onenand_partitions
[] = {
127 .name
= "X-Loader(OneNAND)",
131 .name
= "MemInit(OneNAND)",
132 .offset
= MTDPART_OFS_APPEND
,
135 .name
= "BootLoader(OneNAND)",
136 .offset
= MTDPART_OFS_APPEND
,
137 .size
= SZ_2M
-SZ_256K
,
139 .name
= "SysImage(OneNAND)",
140 .offset
= MTDPART_OFS_APPEND
,
143 .name
= "Root Filesystem(OneNAND)",
144 .offset
= MTDPART_OFS_APPEND
,
147 .name
= "User Filesystem(OneNAND)",
148 .offset
= MTDPART_OFS_APPEND
,
149 .size
= MTDPART_SIZ_FULL
,
153 static struct onenand_platform_data nhk8815_onenand_data
= {
154 .parts
= nhk8815_onenand_partitions
,
155 .nr_parts
= ARRAY_SIZE(nhk8815_onenand_partitions
),
158 static struct resource nhk8815_onenand_resource
[] = {
161 .end
= 0x30000000 + SZ_128K
- 1,
162 .flags
= IORESOURCE_MEM
,
166 static struct platform_device nhk8815_onenand_device
= {
167 .name
= "onenand-flash",
170 .platform_data
= &nhk8815_onenand_data
,
172 .resource
= nhk8815_onenand_resource
,
173 .num_resources
= ARRAY_SIZE(nhk8815_onenand_resource
),
176 static void __init
nhk8815_onenand_init(void)
178 #ifdef CONFIG_MTD_ONENAND
179 /* Set up SMCS0 for OneNand */
180 writel(0x000030db, FSMC_BCR(0));
181 writel(0x02100551, FSMC_BTR(0));
185 #define __MEM_4K_RESOURCE(x) \
186 .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}
188 static struct amba_device uart0_device
= {
189 .dev
= { .init_name
= "uart0" },
190 __MEM_4K_RESOURCE(NOMADIK_UART0_BASE
),
191 .irq
= {IRQ_UART0
, NO_IRQ
},
194 static struct amba_device uart1_device
= {
195 .dev
= { .init_name
= "uart1" },
196 __MEM_4K_RESOURCE(NOMADIK_UART1_BASE
),
197 .irq
= {IRQ_UART1
, NO_IRQ
},
200 static struct amba_device
*amba_devs
[] __initdata
= {
205 static struct resource nhk8815_eth_resources
[] = {
207 .name
= "smc91x-regs",
208 .start
= 0x34000000 + 0x300,
209 .end
= 0x34000000 + SZ_64K
- 1,
210 .flags
= IORESOURCE_MEM
,
212 .start
= NOMADIK_GPIO_TO_IRQ(115),
213 .end
= NOMADIK_GPIO_TO_IRQ(115),
214 .flags
= IORESOURCE_IRQ
| IRQF_TRIGGER_RISING
,
218 static struct platform_device nhk8815_eth_device
= {
220 .resource
= nhk8815_eth_resources
,
221 .num_resources
= ARRAY_SIZE(nhk8815_eth_resources
),
224 static int __init
nhk8815_eth_init(void)
226 int gpio_nr
= 115; /* hardwired in the board */
229 err
= gpio_request(gpio_nr
, "eth_irq");
230 if (!err
) err
= nmk_gpio_set_mode(gpio_nr
, NMK_GPIO_ALT_GPIO
);
231 if (!err
) err
= gpio_direction_input(gpio_nr
);
233 pr_err("Error %i in %s\n", err
, __func__
);
236 device_initcall(nhk8815_eth_init
);
238 static struct platform_device
*nhk8815_platform_devices
[] __initdata
= {
239 &nhk8815_nand_device
,
240 &nhk8815_onenand_device
,
242 /* will add more devices */
245 static void __init
nomadik_timer_init(void)
249 /* Configure timer sources in "system reset controller" ctrl reg */
250 src_cr
= readl(io_p2v(NOMADIK_SRC_BASE
));
251 src_cr
&= SRC_CR_INIT_MASK
;
252 src_cr
|= SRC_CR_INIT_VAL
;
253 writel(src_cr
, io_p2v(NOMADIK_SRC_BASE
));
255 /* Save global pointer to mtu, used by platform timer code */
256 mtu_base
= io_p2v(NOMADIK_MTU0_BASE
);
261 static struct sys_timer nomadik_timer
= {
262 .init
= nomadik_timer_init
,
265 static void __init
nhk8815_platform_init(void)
269 cpu8815_platform_init();
270 nhk8815_onenand_init();
271 platform_add_devices(nhk8815_platform_devices
,
272 ARRAY_SIZE(nhk8815_platform_devices
));
274 for (i
= 0; i
< ARRAY_SIZE(amba_devs
); i
++)
275 amba_device_register(amba_devs
[i
], &iomem_resource
);
278 MACHINE_START(NOMADIK
, "NHK8815")
279 /* Maintainer: ST MicroElectronics */
280 .atag_offset
= 0x100,
281 .map_io
= cpu8815_map_io
,
282 .init_irq
= cpu8815_init_irq
,
283 .timer
= &nomadik_timer
,
284 .init_machine
= nhk8815_platform_init
,