blob: 029a741fd9f258e863545195b17ba045d8649e8a [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>
Alessandro Rubinic1558b52009-09-20 23:28:24 +020021#include <linux/mtd/onenand.h>
Alessandro Rubini63234712009-07-29 18:51:56 +020022#include <linux/mtd/partitions.h>
Linus Walleijd088f672012-01-25 14:37:58 +010023#include <linux/i2c.h>
Alessandro Rubini63234712009-07-29 18:51:56 +020024#include <linux/io.h>
Jamie Iles42ab5302011-09-27 20:25:51 +010025#include <asm/hardware/vic.h>
Alessandro Rubini63234712009-07-29 18:51:56 +020026#include <asm/sizes.h>
Alessandro Rubini28ad94e2009-07-02 19:06:47 +010027#include <asm/mach-types.h>
28#include <asm/mach/arch.h>
29#include <asm/mach/irq.h>
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +020030#include <asm/mach/flash.h>
Linus Walleijb9576622012-01-11 09:46:59 +010031#include <asm/mach/time.h>
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +010032
Linus Walleij0f332862011-08-22 08:33:30 +010033#include <plat/gpio-nomadik.h>
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +010034#include <plat/mtu.h>
35
Alessandro Rubini63234712009-07-29 18:51:56 +020036#include <mach/nand.h>
37#include <mach/fsmc.h>
Alessandro Rubini28ad94e2009-07-02 19:06:47 +010038
Linus Walleij61b38752011-11-28 12:20:53 +010039#include "cpu-8815.h"
40
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +010041/* Initial value for SRC control register: all timers use MXTAL/8 source */
42#define SRC_CR_INIT_MASK 0x00007fff
43#define SRC_CR_INIT_VAL 0x2aaa8000
44
Daniel Mack3ad2f3f2010-02-03 08:01:28 +080045/* These addresses span 16MB, so use three individual pages */
Alessandro Rubini63234712009-07-29 18:51:56 +020046static struct resource nhk8815_nand_resources[] = {
47 {
48 .name = "nand_addr",
49 .start = NAND_IO_ADDR,
50 .end = NAND_IO_ADDR + 0xfff,
51 .flags = IORESOURCE_MEM,
52 }, {
53 .name = "nand_cmd",
54 .start = NAND_IO_CMD,
55 .end = NAND_IO_CMD + 0xfff,
56 .flags = IORESOURCE_MEM,
57 }, {
58 .name = "nand_data",
59 .start = NAND_IO_DATA,
60 .end = NAND_IO_DATA + 0xfff,
61 .flags = IORESOURCE_MEM,
62 }
63};
64
65static int nhk8815_nand_init(void)
66{
67 /* FSMC setup for nand chip select (8-bit nand in 8815NHK) */
68 writel(0x0000000E, FSMC_PCR(0));
69 writel(0x000D0A00, FSMC_PMEM(0));
70 writel(0x00100A00, FSMC_PATT(0));
71
72 /* enable access to the chip select area */
73 writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0));
74
75 return 0;
76}
77
78/*
79 * These partitions are the same as those used in the 2.6.20 release
80 * shipped by the vendor; the first two partitions are mandated
81 * by the boot ROM, and the bootloader area is somehow oversized...
82 */
83static struct mtd_partition nhk8815_partitions[] = {
84 {
85 .name = "X-Loader(NAND)",
86 .offset = 0,
87 .size = SZ_256K,
88 }, {
89 .name = "MemInit(NAND)",
90 .offset = MTDPART_OFS_APPEND,
91 .size = SZ_256K,
92 }, {
93 .name = "BootLoader(NAND)",
94 .offset = MTDPART_OFS_APPEND,
95 .size = SZ_2M,
96 }, {
97 .name = "Kernel zImage(NAND)",
98 .offset = MTDPART_OFS_APPEND,
99 .size = 3 * SZ_1M,
100 }, {
101 .name = "Root Filesystem(NAND)",
102 .offset = MTDPART_OFS_APPEND,
103 .size = 22 * SZ_1M,
104 }, {
105 .name = "User Filesystem(NAND)",
106 .offset = MTDPART_OFS_APPEND,
107 .size = MTDPART_SIZ_FULL,
108 }
109};
110
111static struct nomadik_nand_platform_data nhk8815_nand_data = {
112 .parts = nhk8815_partitions,
113 .nparts = ARRAY_SIZE(nhk8815_partitions),
114 .options = NAND_COPYBACK | NAND_CACHEPRG | NAND_NO_PADDING \
Brian Norris1826dbc2012-05-01 17:12:55 -0700115 | NAND_NO_READRDY,
Alessandro Rubini63234712009-07-29 18:51:56 +0200116 .init = nhk8815_nand_init,
117};
118
119static struct platform_device nhk8815_nand_device = {
120 .name = "nomadik_nand",
121 .dev = {
122 .platform_data = &nhk8815_nand_data,
123 },
124 .resource = nhk8815_nand_resources,
125 .num_resources = ARRAY_SIZE(nhk8815_nand_resources),
126};
127
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200128/* These are the partitions for the OneNand device, different from above */
129static struct mtd_partition nhk8815_onenand_partitions[] = {
130 {
131 .name = "X-Loader(OneNAND)",
132 .offset = 0,
133 .size = SZ_256K,
134 }, {
135 .name = "MemInit(OneNAND)",
136 .offset = MTDPART_OFS_APPEND,
137 .size = SZ_256K,
138 }, {
139 .name = "BootLoader(OneNAND)",
140 .offset = MTDPART_OFS_APPEND,
141 .size = SZ_2M-SZ_256K,
142 }, {
143 .name = "SysImage(OneNAND)",
144 .offset = MTDPART_OFS_APPEND,
145 .size = 4 * SZ_1M,
146 }, {
147 .name = "Root Filesystem(OneNAND)",
148 .offset = MTDPART_OFS_APPEND,
149 .size = 22 * SZ_1M,
150 }, {
151 .name = "User Filesystem(OneNAND)",
152 .offset = MTDPART_OFS_APPEND,
153 .size = MTDPART_SIZ_FULL,
154 }
155};
156
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200157static struct onenand_platform_data nhk8815_onenand_data = {
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200158 .parts = nhk8815_onenand_partitions,
159 .nr_parts = ARRAY_SIZE(nhk8815_onenand_partitions),
160};
161
162static struct resource nhk8815_onenand_resource[] = {
163 {
164 .start = 0x30000000,
165 .end = 0x30000000 + SZ_128K - 1,
166 .flags = IORESOURCE_MEM,
167 },
168};
169
170static struct platform_device nhk8815_onenand_device = {
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200171 .name = "onenand-flash",
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200172 .id = -1,
173 .dev = {
174 .platform_data = &nhk8815_onenand_data,
175 },
176 .resource = nhk8815_onenand_resource,
177 .num_resources = ARRAY_SIZE(nhk8815_onenand_resource),
178};
179
180static void __init nhk8815_onenand_init(void)
181{
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200182#ifdef CONFIG_MTD_ONENAND
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200183 /* Set up SMCS0 for OneNand */
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200184 writel(0x000030db, FSMC_BCR(0));
185 writel(0x02100551, FSMC_BTR(0));
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200186#endif
187}
Alessandro Rubini63234712009-07-29 18:51:56 +0200188
Alessandro Rubini725b1f92009-07-02 15:29:32 +0100189static struct resource nhk8815_eth_resources[] = {
190 {
191 .name = "smc91x-regs",
192 .start = 0x34000000 + 0x300,
193 .end = 0x34000000 + SZ_64K - 1,
194 .flags = IORESOURCE_MEM,
195 }, {
196 .start = NOMADIK_GPIO_TO_IRQ(115),
197 .end = NOMADIK_GPIO_TO_IRQ(115),
198 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
199 }
200};
201
202static struct platform_device nhk8815_eth_device = {
203 .name = "smc91x",
204 .resource = nhk8815_eth_resources,
205 .num_resources = ARRAY_SIZE(nhk8815_eth_resources),
206};
207
208static int __init nhk8815_eth_init(void)
209{
210 int gpio_nr = 115; /* hardwired in the board */
211 int err;
212
213 err = gpio_request(gpio_nr, "eth_irq");
214 if (!err) err = nmk_gpio_set_mode(gpio_nr, NMK_GPIO_ALT_GPIO);
215 if (!err) err = gpio_direction_input(gpio_nr);
216 if (err)
217 pr_err("Error %i in %s\n", err, __func__);
218 return err;
219}
220device_initcall(nhk8815_eth_init);
221
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100222static struct platform_device *nhk8815_platform_devices[] __initdata = {
Alessandro Rubini63234712009-07-29 18:51:56 +0200223 &nhk8815_nand_device,
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200224 &nhk8815_onenand_device,
Alessandro Rubini725b1f92009-07-02 15:29:32 +0100225 &nhk8815_eth_device,
226 /* will add more devices */
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100227};
228
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +0100229static void __init nomadik_timer_init(void)
230{
231 u32 src_cr;
232
233 /* Configure timer sources in "system reset controller" ctrl reg */
234 src_cr = readl(io_p2v(NOMADIK_SRC_BASE));
235 src_cr &= SRC_CR_INIT_MASK;
236 src_cr |= SRC_CR_INIT_VAL;
237 writel(src_cr, io_p2v(NOMADIK_SRC_BASE));
238
Linus Walleijb9576622012-01-11 09:46:59 +0100239 nmdk_timer_init(io_p2v(NOMADIK_MTU0_BASE));
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +0100240}
241
242static struct sys_timer nomadik_timer = {
243 .init = nomadik_timer_init,
244};
245
Linus Walleijd088f672012-01-25 14:37:58 +0100246static struct i2c_board_info __initdata nhk8815_i2c0_devices[] = {
247 {
248 I2C_BOARD_INFO("stw4811", 0x2d),
249 },
250};
251
252static struct i2c_board_info __initdata nhk8815_i2c1_devices[] = {
253 {
254 I2C_BOARD_INFO("camera", 0x10),
255 },
256 {
257 I2C_BOARD_INFO("stw5095", 0x1a),
258 },
259 {
260 I2C_BOARD_INFO("lis3lv02dl", 0x1d),
261 },
262};
263
264static struct i2c_board_info __initdata nhk8815_i2c2_devices[] = {
265 {
266 I2C_BOARD_INFO("stw4811-usb", 0x2d),
267 },
268};
269
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100270static void __init nhk8815_platform_init(void)
271{
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100272 cpu8815_platform_init();
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200273 nhk8815_onenand_init();
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100274 platform_add_devices(nhk8815_platform_devices,
275 ARRAY_SIZE(nhk8815_platform_devices));
276
Linus Walleij7c778522012-01-09 12:40:02 +0100277 amba_apb_device_add(NULL, "uart0", NOMADIK_UART0_BASE, SZ_4K, IRQ_UART0, 0, NULL, 0);
278 amba_apb_device_add(NULL, "uart1", NOMADIK_UART1_BASE, SZ_4K, IRQ_UART1, 0, NULL, 0);
Linus Walleijd088f672012-01-25 14:37:58 +0100279
280 i2c_register_board_info(0, nhk8815_i2c0_devices,
281 ARRAY_SIZE(nhk8815_i2c0_devices));
282 i2c_register_board_info(1, nhk8815_i2c1_devices,
283 ARRAY_SIZE(nhk8815_i2c1_devices));
284 i2c_register_board_info(2, nhk8815_i2c2_devices,
285 ARRAY_SIZE(nhk8815_i2c2_devices));
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100286}
287
288MACHINE_START(NOMADIK, "NHK8815")
289 /* Maintainer: ST MicroElectronics */
Nicolas Pitre013b5fb2011-07-05 22:38:14 -0400290 .atag_offset = 0x100,
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100291 .map_io = cpu8815_map_io,
292 .init_irq = cpu8815_init_irq,
Jamie Iles42ab5302011-09-27 20:25:51 +0100293 .handle_irq = vic_handle_irq,
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100294 .timer = &nomadik_timer,
295 .init_machine = nhk8815_platform_init,
Russell King35b47a4052011-11-28 10:48:02 +0000296 .restart = cpu8815_restart,
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100297MACHINE_END