aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2012-04-13 08:34:31 -0400
committerPaul Walmsley <paul@pwsan.com>2012-04-13 08:34:31 -0400
commit31cde0447d779c1b4ae9feb51dc917d6e287de2b (patch)
tree5dcd6127f60a2319b28c57a594129499107bde70 /arch
parent6cc1a7387d94deda3267f8a75c668fe679f09b2c (diff)
ARM: OMAP1: board files: deduplicate and clean some NAND-related code
The H2, H3, Perseus2, and FSample board files all contain the same duplicated code to handle NAND commands. That code is missing some casts around conversions from unsigned long to void __iomem *. Consolidate the duplicated code into a new file, arch/arm/mach-omap1/board-nand.c. Resolve the sparse warnings by adding appropriate casts: arch/arm/mach-omap1/board-h2.c:193:9: warning: incorrect type in argument 1 (different base types) arch/arm/mach-omap1/board-h2.c:193:9: expected void const volatile [noderef] <asn:2>*<noident> arch/arm/mach-omap1/board-h2.c:193:9: got unsigned long arch/arm/mach-omap1/board-perseus2.c:157:9: warning: incorrect type in argument 1 (different base types) arch/arm/mach-omap1/board-perseus2.c:157:9: expected void const volatile [noderef] <asn:2>*<noident> arch/arm/mach-omap1/board-perseus2.c:157:9: got unsigned long arch/arm/mach-omap1/board-fsample.c:199:9: warning: incorrect type in argument 1 (different base types) arch/arm/mach-omap1/board-fsample.c:199:9: expected void const volatile [noderef] <asn:2>*<noident> arch/arm/mach-omap1/board-fsample.c:199:9: got unsigned long arch/arm/mach-omap1/board-h3.c:195:9: warning: incorrect type in argument 1 (different base types) arch/arm/mach-omap1/board-h3.c:195:9: expected void const volatile [noderef] <asn:2>*<noident> arch/arm/mach-omap1/board-h3.c:195:9: got unsigned long Thanks to Arnd Bergmann <arnd@arndb.de> for suggesting a cleaner implementation of omap1_nand_cmd_ctl(), avoiding some casts. Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Brian Swetland <swetland@google.com> Cc: Imre Deak <imre.deak@nokia.com> Cc: Greg Lonnon <glonnon@ridgerun.com> Cc: Kevin Hilman <kjh@hilman.org> Cc: Kevin Hilman <khilman@ti.com> Cc: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap1/Makefile10
-rw-r--r--arch/arm/mach-omap1/board-fsample.c16
-rw-r--r--arch/arm/mach-omap1/board-h2.c17
-rw-r--r--arch/arm/mach-omap1/board-h3.c16
-rw-r--r--arch/arm/mach-omap1/board-nand.c37
-rw-r--r--arch/arm/mach-omap1/board-perseus2.c16
-rw-r--r--arch/arm/mach-omap1/common.h4
7 files changed, 51 insertions, 65 deletions
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index 20d65af64580..398e9e53e189 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -31,13 +31,15 @@ usb-fs-$(CONFIG_USB) := usb.o
31obj-y += $(usb-fs-m) $(usb-fs-y) 31obj-y += $(usb-fs-m) $(usb-fs-y)
32 32
33# Specific board support 33# Specific board support
34obj-$(CONFIG_MACH_OMAP_H2) += board-h2.o board-h2-mmc.o 34obj-$(CONFIG_MACH_OMAP_H2) += board-h2.o board-h2-mmc.o \
35 board-nand.o
35obj-$(CONFIG_MACH_OMAP_INNOVATOR) += board-innovator.o 36obj-$(CONFIG_MACH_OMAP_INNOVATOR) += board-innovator.o
36obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o 37obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o
37obj-$(CONFIG_MACH_OMAP_PERSEUS2) += board-perseus2.o 38obj-$(CONFIG_MACH_OMAP_PERSEUS2) += board-perseus2.o board-nand.o
38obj-$(CONFIG_MACH_OMAP_FSAMPLE) += board-fsample.o 39obj-$(CONFIG_MACH_OMAP_FSAMPLE) += board-fsample.o board-nand.o
39obj-$(CONFIG_MACH_OMAP_OSK) += board-osk.o 40obj-$(CONFIG_MACH_OMAP_OSK) += board-osk.o
40obj-$(CONFIG_MACH_OMAP_H3) += board-h3.o board-h3-mmc.o 41obj-$(CONFIG_MACH_OMAP_H3) += board-h3.o board-h3-mmc.o \
42 board-nand.o
41obj-$(CONFIG_MACH_VOICEBLUE) += board-voiceblue.o 43obj-$(CONFIG_MACH_VOICEBLUE) += board-voiceblue.o
42obj-$(CONFIG_MACH_OMAP_PALMTE) += board-palmte.o 44obj-$(CONFIG_MACH_OMAP_PALMTE) += board-palmte.o
43obj-$(CONFIG_MACH_OMAP_PALMZ71) += board-palmz71.o 45obj-$(CONFIG_MACH_OMAP_PALMZ71) += board-palmz71.o
diff --git a/arch/arm/mach-omap1/board-fsample.c b/arch/arm/mach-omap1/board-fsample.c
index 80bd43c7f4ec..4a4afb371022 100644
--- a/arch/arm/mach-omap1/board-fsample.c
+++ b/arch/arm/mach-omap1/board-fsample.c
@@ -185,20 +185,6 @@ static struct platform_device nor_device = {
185 .resource = &nor_resource, 185 .resource = &nor_resource,
186}; 186};
187 187
188static void nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
189{
190 struct nand_chip *this = mtd->priv;
191 unsigned long mask;
192
193 if (cmd == NAND_CMD_NONE)
194 return;
195
196 mask = (ctrl & NAND_CLE) ? 0x02 : 0;
197 if (ctrl & NAND_ALE)
198 mask |= 0x04;
199 writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
200}
201
202#define FSAMPLE_NAND_RB_GPIO_PIN 62 188#define FSAMPLE_NAND_RB_GPIO_PIN 62
203 189
204static int nand_dev_ready(struct mtd_info *mtd) 190static int nand_dev_ready(struct mtd_info *mtd)
@@ -216,7 +202,7 @@ static struct platform_nand_data nand_data = {
216 .part_probe_types = part_probes, 202 .part_probe_types = part_probes,
217 }, 203 },
218 .ctrl = { 204 .ctrl = {
219 .cmd_ctrl = nand_cmd_ctl, 205 .cmd_ctrl = omap1_nand_cmd_ctl,
220 .dev_ready = nand_dev_ready, 206 .dev_ready = nand_dev_ready,
221 }, 207 },
222}; 208};
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index 553a2e535764..057ec13f0649 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -179,20 +179,6 @@ static struct mtd_partition h2_nand_partitions[] = {
179 }, 179 },
180}; 180};
181 181
182static void h2_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
183{
184 struct nand_chip *this = mtd->priv;
185 unsigned long mask;
186
187 if (cmd == NAND_CMD_NONE)
188 return;
189
190 mask = (ctrl & NAND_CLE) ? 0x02 : 0;
191 if (ctrl & NAND_ALE)
192 mask |= 0x04;
193 writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
194}
195
196#define H2_NAND_RB_GPIO_PIN 62 182#define H2_NAND_RB_GPIO_PIN 62
197 183
198static int h2_nand_dev_ready(struct mtd_info *mtd) 184static int h2_nand_dev_ready(struct mtd_info *mtd)
@@ -212,9 +198,8 @@ static struct platform_nand_data h2_nand_platdata = {
212 .part_probe_types = h2_part_probes, 198 .part_probe_types = h2_part_probes,
213 }, 199 },
214 .ctrl = { 200 .ctrl = {
215 .cmd_ctrl = h2_nand_cmd_ctl, 201 .cmd_ctrl = omap1_nand_cmd_ctl,
216 .dev_ready = h2_nand_dev_ready, 202 .dev_ready = h2_nand_dev_ready,
217
218 }, 203 },
219}; 204};
220 205
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index 4c19f4c06851..f6ddf8759657 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -181,20 +181,6 @@ static struct mtd_partition nand_partitions[] = {
181 }, 181 },
182}; 182};
183 183
184static void nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
185{
186 struct nand_chip *this = mtd->priv;
187 unsigned long mask;
188
189 if (cmd == NAND_CMD_NONE)
190 return;
191
192 mask = (ctrl & NAND_CLE) ? 0x02 : 0;
193 if (ctrl & NAND_ALE)
194 mask |= 0x04;
195 writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
196}
197
198#define H3_NAND_RB_GPIO_PIN 10 184#define H3_NAND_RB_GPIO_PIN 10
199 185
200static int nand_dev_ready(struct mtd_info *mtd) 186static int nand_dev_ready(struct mtd_info *mtd)
@@ -214,7 +200,7 @@ static struct platform_nand_data nand_platdata = {
214 .part_probe_types = part_probes, 200 .part_probe_types = part_probes,
215 }, 201 },
216 .ctrl = { 202 .ctrl = {
217 .cmd_ctrl = nand_cmd_ctl, 203 .cmd_ctrl = omap1_nand_cmd_ctl,
218 .dev_ready = nand_dev_ready, 204 .dev_ready = nand_dev_ready,
219 205
220 }, 206 },
diff --git a/arch/arm/mach-omap1/board-nand.c b/arch/arm/mach-omap1/board-nand.c
new file mode 100644
index 000000000000..4d0835327d20
--- /dev/null
+++ b/arch/arm/mach-omap1/board-nand.c
@@ -0,0 +1,37 @@
1/*
2 * linux/arch/arm/mach-omap1/board-nand.c
3 *
4 * Common OMAP1 board NAND code
5 *
6 * Copyright (C) 2004, 2012 Texas Instruments, Inc.
7 * Copyright (C) 2002 MontaVista Software, Inc.
8 * Copyright (C) 2001 RidgeRun, Inc.
9 * Author: RidgeRun, Inc.
10 * Greg Lonnon (glonnon@ridgerun.com) or info@ridgerun.com
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16#include <linux/kernel.h>
17#include <linux/io.h>
18#include <linux/mtd/mtd.h>
19#include <linux/mtd/nand.h>
20
21#include "common.h"
22
23void omap1_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
24{
25 struct nand_chip *this = mtd->priv;
26 unsigned long mask;
27
28 if (cmd == NAND_CMD_NONE)
29 return;
30
31 mask = (ctrl & NAND_CLE) ? 0x02 : 0;
32 if (ctrl & NAND_ALE)
33 mask |= 0x04;
34
35 writeb(cmd, this->IO_ADDR_W + mask);
36}
37
diff --git a/arch/arm/mach-omap1/board-perseus2.c b/arch/arm/mach-omap1/board-perseus2.c
index 76d4ee05a814..a2c88890e767 100644
--- a/arch/arm/mach-omap1/board-perseus2.c
+++ b/arch/arm/mach-omap1/board-perseus2.c
@@ -143,20 +143,6 @@ static struct platform_device nor_device = {
143 .resource = &nor_resource, 143 .resource = &nor_resource,
144}; 144};
145 145
146static void nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
147{
148 struct nand_chip *this = mtd->priv;
149 unsigned long mask;
150
151 if (cmd == NAND_CMD_NONE)
152 return;
153
154 mask = (ctrl & NAND_CLE) ? 0x02 : 0;
155 if (ctrl & NAND_ALE)
156 mask |= 0x04;
157 writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
158}
159
160#define P2_NAND_RB_GPIO_PIN 62 146#define P2_NAND_RB_GPIO_PIN 62
161 147
162static int nand_dev_ready(struct mtd_info *mtd) 148static int nand_dev_ready(struct mtd_info *mtd)
@@ -174,7 +160,7 @@ static struct platform_nand_data nand_data = {
174 .part_probe_types = part_probes, 160 .part_probe_types = part_probes,
175 }, 161 },
176 .ctrl = { 162 .ctrl = {
177 .cmd_ctrl = nand_cmd_ctl, 163 .cmd_ctrl = omap1_nand_cmd_ctl,
178 .dev_ready = nand_dev_ready, 164 .dev_ready = nand_dev_ready,
179 }, 165 },
180}; 166};
diff --git a/arch/arm/mach-omap1/common.h b/arch/arm/mach-omap1/common.h
index a90b9d7e749a..8cc616e6f54a 100644
--- a/arch/arm/mach-omap1/common.h
+++ b/arch/arm/mach-omap1/common.h
@@ -27,6 +27,7 @@
27#define __ARCH_ARM_MACH_OMAP1_COMMON_H 27#define __ARCH_ARM_MACH_OMAP1_COMMON_H
28 28
29#include <plat/common.h> 29#include <plat/common.h>
30#include <linux/mtd/mtd.h>
30 31
31#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850) 32#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
32void omap7xx_map_io(void); 33void omap7xx_map_io(void);
@@ -58,6 +59,9 @@ void omap1_restart(char, const char *);
58 59
59extern void __init omap_check_revision(void); 60extern void __init omap_check_revision(void);
60 61
62extern void omap1_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
63 unsigned int ctrl);
64
61extern struct sys_timer omap1_timer; 65extern struct sys_timer omap1_timer;
62extern bool omap_32k_timer_init(void); 66extern bool omap_32k_timer_init(void);
63 67