ARM: clps711x: autcpu12: Add support for NOR flash
[deliverable/linux.git] / arch / arm / mach-clps711x / board-autcpu12.c
CommitLineData
1da177e4
LT
1/*
2 * linux/arch/arm/mach-clps711x/autcpu12.c
3 *
4 * (c) 2001 Thomas Gleixner, autronix automation <gleixner@autronix.de>
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/types.h>
23#include <linux/string.h>
24#include <linux/mm.h>
fced80c7 25#include <linux/io.h>
90383e0a 26#include <linux/gpio.h>
ce55754c 27#include <linux/ioport.h>
200daa36 28#include <linux/interrupt.h>
3f0bcaa5 29#include <linux/mtd/physmap.h>
90383e0a
AS
30#include <linux/mtd/partitions.h>
31#include <linux/mtd/nand-gpio.h>
ce55754c 32#include <linux/platform_device.h>
90383e0a 33#include <linux/basic_mmio_gpio.h>
1da177e4 34
a09e64fb 35#include <mach/hardware.h>
1da177e4 36#include <asm/sizes.h>
1da177e4
LT
37#include <asm/setup.h>
38#include <asm/mach-types.h>
39#include <asm/mach/arch.h>
40#include <asm/pgtable.h>
41#include <asm/page.h>
42
43#include <asm/mach/map.h>
a09e64fb 44#include <mach/autcpu12.h>
1da177e4
LT
45
46#include "common.h"
e328b880 47#include "devices.h"
1da177e4 48
3f0bcaa5
AS
49/* NOR flash */
50#define AUTCPU12_FLASH_BASE (CS0_PHYS_BASE)
1da177e4 51
3f0bcaa5 52/* SmartMedia flash */
90383e0a
AS
53#define AUTCPU12_SMC_BASE (CS1_PHYS_BASE + 0x06000000)
54#define AUTCPU12_SMC_SEL_BASE (AUTCPU12_SMC_BASE + 0x10)
55
3f0bcaa5
AS
56/* Ethernet */
57#define AUTCPU12_CS8900_BASE (CS2_PHYS_BASE + 0x300)
58#define AUTCPU12_CS8900_IRQ (IRQ_EINT3)
59
ba18ec21 60/* NAND flash */
90383e0a
AS
61#define AUTCPU12_MMGPIO_BASE (CLPS711X_NR_GPIO)
62#define AUTCPU12_SMC_NCE (AUTCPU12_MMGPIO_BASE + 0) /* Bit 0 */
63#define AUTCPU12_SMC_RDY CLPS711X_GPIO(1, 2)
64#define AUTCPU12_SMC_ALE CLPS711X_GPIO(1, 3)
65#define AUTCPU12_SMC_CLE CLPS711X_GPIO(1, 3)
66
ba18ec21
AS
67/* LCD contrast digital potentiometer */
68#define AUTCPU12_DPOT_CS CLPS711X_GPIO(4, 0)
69#define AUTCPU12_DPOT_CLK CLPS711X_GPIO(4, 1)
70#define AUTCPU12_DPOT_UD CLPS711X_GPIO(4, 2)
71
200daa36
AS
72static struct resource autcpu12_cs8900_resource[] __initdata = {
73 DEFINE_RES_MEM(AUTCPU12_CS8900_BASE, SZ_1K),
74 DEFINE_RES_IRQ(AUTCPU12_CS8900_IRQ),
75};
1da177e4 76
ce55754c
AS
77static struct resource autcpu12_nvram_resource[] __initdata = {
78 DEFINE_RES_MEM_NAMED(AUTCPU12_PHYS_NVRAM, SZ_128K, "SRAM"),
79};
80
81static struct platform_device autcpu12_nvram_pdev __initdata = {
82 .name = "autcpu12_nvram",
83 .id = -1,
84 .resource = autcpu12_nvram_resource,
85 .num_resources = ARRAY_SIZE(autcpu12_nvram_resource),
86};
87
90383e0a
AS
88static struct resource autcpu12_nand_resource[] __initdata = {
89 DEFINE_RES_MEM(AUTCPU12_SMC_BASE, SZ_16),
90};
91
92static struct mtd_partition autcpu12_nand_parts[] __initdata = {
93 {
94 .name = "Flash partition 1",
95 .offset = 0,
96 .size = SZ_8M,
97 },
98 {
99 .name = "Flash partition 2",
100 .offset = MTDPART_OFS_APPEND,
101 .size = MTDPART_SIZ_FULL,
102 },
103};
104
105static void __init autcpu12_adjust_parts(struct gpio_nand_platdata *pdata,
106 size_t sz)
107{
108 switch (sz) {
109 case SZ_16M:
110 case SZ_32M:
111 break;
112 case SZ_64M:
113 case SZ_128M:
114 pdata->parts[0].size = SZ_16M;
115 break;
116 default:
117 pr_warn("Unsupported SmartMedia device size %u\n", sz);
118 break;
119 }
120}
121
122static struct gpio_nand_platdata autcpu12_nand_pdata __initdata = {
123 .gpio_rdy = AUTCPU12_SMC_RDY,
124 .gpio_nce = AUTCPU12_SMC_NCE,
125 .gpio_ale = AUTCPU12_SMC_ALE,
126 .gpio_cle = AUTCPU12_SMC_CLE,
127 .gpio_nwp = -1,
128 .chip_delay = 20,
129 .parts = autcpu12_nand_parts,
130 .num_parts = ARRAY_SIZE(autcpu12_nand_parts),
131 .adjust_parts = autcpu12_adjust_parts,
132};
133
134static struct platform_device autcpu12_nand_pdev __initdata = {
135 .name = "gpio-nand",
136 .id = -1,
137 .resource = autcpu12_nand_resource,
138 .num_resources = ARRAY_SIZE(autcpu12_nand_resource),
139 .dev = {
140 .platform_data = &autcpu12_nand_pdata,
141 },
142};
143
144static struct resource autcpu12_mmgpio_resource[] __initdata = {
145 DEFINE_RES_MEM_NAMED(AUTCPU12_SMC_SEL_BASE, SZ_1, "dat"),
146};
147
148static struct bgpio_pdata autcpu12_mmgpio_pdata __initdata = {
149 .base = AUTCPU12_MMGPIO_BASE,
150 .ngpio = 8,
151};
152
153static struct platform_device autcpu12_mmgpio_pdev __initdata = {
154 .name = "basic-mmio-gpio",
155 .id = -1,
156 .resource = autcpu12_mmgpio_resource,
157 .num_resources = ARRAY_SIZE(autcpu12_mmgpio_resource),
158 .dev = {
159 .platform_data = &autcpu12_mmgpio_pdata,
160 },
161};
162
ba18ec21
AS
163static const struct gpio autcpu12_gpios[] __initconst = {
164 { AUTCPU12_DPOT_CS, GPIOF_OUT_INIT_HIGH, "DPOT CS" },
165 { AUTCPU12_DPOT_CLK, GPIOF_OUT_INIT_LOW, "DPOT CLK" },
166 { AUTCPU12_DPOT_UD, GPIOF_OUT_INIT_LOW, "DPOT UD" },
167};
168
3f0bcaa5
AS
169static struct mtd_partition autcpu12_flash_partitions[] = {
170 {
171 .name = "NOR.0",
172 .offset = 0,
173 .size = MTDPART_SIZ_FULL,
174 },
175};
176
177static struct physmap_flash_data autcpu12_flash_pdata = {
178 .width = 4,
179 .parts = autcpu12_flash_partitions,
180 .nr_parts = ARRAY_SIZE(autcpu12_flash_partitions),
181};
182
183static struct resource autcpu12_flash_resources[] __initdata = {
184 DEFINE_RES_MEM(AUTCPU12_FLASH_BASE, SZ_8M),
185};
186
187static struct platform_device autcpu12_flash_pdev __initdata = {
188 .name = "physmap-flash",
189 .id = 0,
190 .resource = autcpu12_flash_resources,
191 .num_resources = ARRAY_SIZE(autcpu12_flash_resources),
192 .dev = {
193 .platform_data = &autcpu12_flash_pdata,
194 },
195};
196
ce55754c
AS
197static void __init autcpu12_init(void)
198{
e328b880 199 clps711x_devices_init();
3f0bcaa5 200 platform_device_register(&autcpu12_flash_pdev);
dd850f12 201 platform_device_register_simple("video-clps711x", 0, NULL, 0);
200daa36
AS
202 platform_device_register_simple("cs89x0", 0, autcpu12_cs8900_resource,
203 ARRAY_SIZE(autcpu12_cs8900_resource));
90383e0a 204 platform_device_register(&autcpu12_mmgpio_pdev);
ce55754c
AS
205 platform_device_register(&autcpu12_nvram_pdev);
206}
207
90383e0a
AS
208static void __init autcpu12_init_late(void)
209{
ba18ec21
AS
210 gpio_request_array(autcpu12_gpios, ARRAY_SIZE(autcpu12_gpios));
211
90383e0a
AS
212 if (IS_ENABLED(MTD_NAND_GPIO) && IS_ENABLED(GPIO_GENERIC_PLATFORM)) {
213 /* We are need both drivers to handle NAND */
214 platform_device_register(&autcpu12_nand_pdev);
215 }
216}
217
1da177e4 218MACHINE_START(AUTCPU12, "autronix autcpu12")
e9dea0c6 219 /* Maintainer: Thomas Gleixner */
6244fa9c 220 .atag_offset = 0x20000,
0d8be81c 221 .nr_irqs = CLPS711X_NR_IRQS,
200daa36 222 .map_io = clps711x_map_io,
e9dea0c6 223 .init_irq = clps711x_init_irq,
6bb27d73 224 .init_time = clps711x_timer_init,
200daa36 225 .init_machine = autcpu12_init,
90383e0a 226 .init_late = autcpu12_init_late,
99f04c8f 227 .handle_irq = clps711x_handle_irq,
6c000712 228 .restart = clps711x_restart,
1da177e4
LT
229MACHINE_END
230
This page took 0.580177 seconds and 5 git commands to generate.