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/partitions.h>
23 #include <asm/sizes.h>
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/irq.h>
27 #include <mach/setup.h>
28 #include <mach/nand.h>
29 #include <mach/fsmc.h>
32 /* These adresses span 16MB, so use three individual pages */
33 static struct resource nhk8815_nand_resources[] = {
36 .start = NAND_IO_ADDR,
37 .end = NAND_IO_ADDR + 0xfff,
38 .flags = IORESOURCE_MEM,
42 .end = NAND_IO_CMD + 0xfff,
43 .flags = IORESOURCE_MEM,
46 .start = NAND_IO_DATA,
47 .end = NAND_IO_DATA + 0xfff,
48 .flags = IORESOURCE_MEM,
52 static int nhk8815_nand_init(void)
54 /* FSMC setup for nand chip select (8-bit nand in 8815NHK) */
55 writel(0x0000000E, FSMC_PCR(0));
56 writel(0x000D0A00, FSMC_PMEM(0));
57 writel(0x00100A00, FSMC_PATT(0));
59 /* enable access to the chip select area */
60 writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0));
66 * These partitions are the same as those used in the 2.6.20 release
67 * shipped by the vendor; the first two partitions are mandated
68 * by the boot ROM, and the bootloader area is somehow oversized...
70 static struct mtd_partition nhk8815_partitions[] = {
72 .name = "X-Loader(NAND)",
76 .name = "MemInit(NAND)",
77 .offset = MTDPART_OFS_APPEND,
80 .name = "BootLoader(NAND)",
81 .offset = MTDPART_OFS_APPEND,
84 .name = "Kernel zImage(NAND)",
85 .offset = MTDPART_OFS_APPEND,
88 .name = "Root Filesystem(NAND)",
89 .offset = MTDPART_OFS_APPEND,
92 .name = "User Filesystem(NAND)",
93 .offset = MTDPART_OFS_APPEND,
94 .size = MTDPART_SIZ_FULL,
98 static struct nomadik_nand_platform_data nhk8815_nand_data = {
99 .parts = nhk8815_partitions,
100 .nparts = ARRAY_SIZE(nhk8815_partitions),
101 .options = NAND_COPYBACK | NAND_CACHEPRG | NAND_NO_PADDING \
102 | NAND_NO_READRDY | NAND_NO_AUTOINCR,
103 .init = nhk8815_nand_init,
106 static struct platform_device nhk8815_nand_device = {
107 .name = "nomadik_nand",
109 .platform_data = &nhk8815_nand_data,
111 .resource = nhk8815_nand_resources,
112 .num_resources = ARRAY_SIZE(nhk8815_nand_resources),
116 #define __MEM_4K_RESOURCE(x) \
117 .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}
119 static struct amba_device uart0_device = {
120 .dev = { .init_name = "uart0" },
121 __MEM_4K_RESOURCE(NOMADIK_UART0_BASE),
122 .irq = {IRQ_UART0, NO_IRQ},
125 static struct amba_device uart1_device = {
126 .dev = { .init_name = "uart1" },
127 __MEM_4K_RESOURCE(NOMADIK_UART1_BASE),
128 .irq = {IRQ_UART1, NO_IRQ},
131 static struct amba_device *amba_devs[] __initdata = {
136 /* We have a fixed clock alone, by now */
137 static struct clk nhk8815_clk_48 = {
138 .rate = 48*1000*1000,
141 static struct resource nhk8815_eth_resources[] = {
143 .name = "smc91x-regs",
144 .start = 0x34000000 + 0x300,
145 .end = 0x34000000 + SZ_64K - 1,
146 .flags = IORESOURCE_MEM,
148 .start = NOMADIK_GPIO_TO_IRQ(115),
149 .end = NOMADIK_GPIO_TO_IRQ(115),
150 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
154 static struct platform_device nhk8815_eth_device = {
156 .resource = nhk8815_eth_resources,
157 .num_resources = ARRAY_SIZE(nhk8815_eth_resources),
160 static int __init nhk8815_eth_init(void)
162 int gpio_nr = 115; /* hardwired in the board */
165 err = gpio_request(gpio_nr, "eth_irq");
166 if (!err) err = nmk_gpio_set_mode(gpio_nr, NMK_GPIO_ALT_GPIO);
167 if (!err) err = gpio_direction_input(gpio_nr);
169 pr_err("Error %i in %s\n", err, __func__);
172 device_initcall(nhk8815_eth_init);
174 static struct platform_device *nhk8815_platform_devices[] __initdata = {
175 &nhk8815_nand_device,
177 /* will add more devices */
180 static void __init nhk8815_platform_init(void)
184 cpu8815_platform_init();
185 platform_add_devices(nhk8815_platform_devices,
186 ARRAY_SIZE(nhk8815_platform_devices));
188 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
189 nmdk_clk_create(&nhk8815_clk_48, amba_devs[i]->dev.init_name);
190 amba_device_register(amba_devs[i], &iomem_resource);
194 MACHINE_START(NOMADIK, "NHK8815")
195 /* Maintainer: ST MicroElectronics */
196 .phys_io = NOMADIK_UART0_BASE,
197 .io_pg_offst = (IO_ADDRESS(NOMADIK_UART0_BASE) >> 18) & 0xfffc,
198 .boot_params = 0x100,
199 .map_io = cpu8815_map_io,
200 .init_irq = cpu8815_init_irq,
201 .timer = &nomadik_timer,
202 .init_machine = nhk8815_platform_init,