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