blob: 59c1dbb686c923a1027fc94ec87bc221e4e697d3 [file] [log] [blame]
Alessandro Rubini28ad94e2009-07-02 19:06:47 +01001/*
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>
Alessandro Rubini725b1f92009-07-02 15:29:32 +010017#include <linux/interrupt.h>
18#include <linux/gpio.h>
Alessandro Rubini63234712009-07-29 18:51:56 +020019#include <linux/mtd/mtd.h>
20#include <linux/mtd/nand.h>
21#include <linux/mtd/partitions.h>
22#include <linux/io.h>
23#include <asm/sizes.h>
Alessandro Rubini28ad94e2009-07-02 19:06:47 +010024#include <asm/mach-types.h>
25#include <asm/mach/arch.h>
26#include <asm/mach/irq.h>
27#include <mach/setup.h>
Alessandro Rubini63234712009-07-29 18:51:56 +020028#include <mach/nand.h>
29#include <mach/fsmc.h>
Alessandro Rubini28ad94e2009-07-02 19:06:47 +010030#include "clock.h"
31
Alessandro Rubini63234712009-07-29 18:51:56 +020032/* These adresses span 16MB, so use three individual pages */
33static struct resource nhk8815_nand_resources[] = {
34 {
35 .name = "nand_addr",
36 .start = NAND_IO_ADDR,
37 .end = NAND_IO_ADDR + 0xfff,
38 .flags = IORESOURCE_MEM,
39 }, {
40 .name = "nand_cmd",
41 .start = NAND_IO_CMD,
42 .end = NAND_IO_CMD + 0xfff,
43 .flags = IORESOURCE_MEM,
44 }, {
45 .name = "nand_data",
46 .start = NAND_IO_DATA,
47 .end = NAND_IO_DATA + 0xfff,
48 .flags = IORESOURCE_MEM,
49 }
50};
51
52static int nhk8815_nand_init(void)
53{
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));
58
59 /* enable access to the chip select area */
60 writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0));
61
62 return 0;
63}
64
65/*
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...
69 */
70static struct mtd_partition nhk8815_partitions[] = {
71 {
72 .name = "X-Loader(NAND)",
73 .offset = 0,
74 .size = SZ_256K,
75 }, {
76 .name = "MemInit(NAND)",
77 .offset = MTDPART_OFS_APPEND,
78 .size = SZ_256K,
79 }, {
80 .name = "BootLoader(NAND)",
81 .offset = MTDPART_OFS_APPEND,
82 .size = SZ_2M,
83 }, {
84 .name = "Kernel zImage(NAND)",
85 .offset = MTDPART_OFS_APPEND,
86 .size = 3 * SZ_1M,
87 }, {
88 .name = "Root Filesystem(NAND)",
89 .offset = MTDPART_OFS_APPEND,
90 .size = 22 * SZ_1M,
91 }, {
92 .name = "User Filesystem(NAND)",
93 .offset = MTDPART_OFS_APPEND,
94 .size = MTDPART_SIZ_FULL,
95 }
96};
97
98static 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,
104};
105
106static struct platform_device nhk8815_nand_device = {
107 .name = "nomadik_nand",
108 .dev = {
109 .platform_data = &nhk8815_nand_data,
110 },
111 .resource = nhk8815_nand_resources,
112 .num_resources = ARRAY_SIZE(nhk8815_nand_resources),
113};
114
115
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100116#define __MEM_4K_RESOURCE(x) \
117 .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}
118
119static struct amba_device uart0_device = {
120 .dev = { .init_name = "uart0" },
121 __MEM_4K_RESOURCE(NOMADIK_UART0_BASE),
122 .irq = {IRQ_UART0, NO_IRQ},
123};
124
125static struct amba_device uart1_device = {
126 .dev = { .init_name = "uart1" },
127 __MEM_4K_RESOURCE(NOMADIK_UART1_BASE),
128 .irq = {IRQ_UART1, NO_IRQ},
129};
130
131static struct amba_device *amba_devs[] __initdata = {
132 &uart0_device,
133 &uart1_device,
134};
135
136/* We have a fixed clock alone, by now */
137static struct clk nhk8815_clk_48 = {
138 .rate = 48*1000*1000,
139};
140
Alessandro Rubini725b1f92009-07-02 15:29:32 +0100141static struct resource nhk8815_eth_resources[] = {
142 {
143 .name = "smc91x-regs",
144 .start = 0x34000000 + 0x300,
145 .end = 0x34000000 + SZ_64K - 1,
146 .flags = IORESOURCE_MEM,
147 }, {
148 .start = NOMADIK_GPIO_TO_IRQ(115),
149 .end = NOMADIK_GPIO_TO_IRQ(115),
150 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
151 }
152};
153
154static struct platform_device nhk8815_eth_device = {
155 .name = "smc91x",
156 .resource = nhk8815_eth_resources,
157 .num_resources = ARRAY_SIZE(nhk8815_eth_resources),
158};
159
160static int __init nhk8815_eth_init(void)
161{
162 int gpio_nr = 115; /* hardwired in the board */
163 int err;
164
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);
168 if (err)
169 pr_err("Error %i in %s\n", err, __func__);
170 return err;
171}
172device_initcall(nhk8815_eth_init);
173
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100174static struct platform_device *nhk8815_platform_devices[] __initdata = {
Alessandro Rubini63234712009-07-29 18:51:56 +0200175 &nhk8815_nand_device,
Alessandro Rubini725b1f92009-07-02 15:29:32 +0100176 &nhk8815_eth_device,
177 /* will add more devices */
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100178};
179
180static void __init nhk8815_platform_init(void)
181{
182 int i;
183
184 cpu8815_platform_init();
185 platform_add_devices(nhk8815_platform_devices,
186 ARRAY_SIZE(nhk8815_platform_devices));
187
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);
191 }
192}
193
194MACHINE_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,
203MACHINE_END