diff options
author | Mike Rapoport <mike@compulab.co.il> | 2011-04-24 18:09:07 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2011-05-03 05:53:37 -0400 |
commit | 9a3f39ff36e11ea6b6c8b5f90337a864cb7e81f6 (patch) | |
tree | bdce8353ab8670fa603d5ace590c2a467df3537d /arch/arm/mach-omap2/common-board-devices.c | |
parent | fbd8071c188e3053fb318d78214e54d4615d93f2 (diff) |
omap: move detection of NAND CS to common-board-devices
and reduce amount of copy/paste
Signed-off-by: Mike Rapoport <mike@compulab.co.il>
CC: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/common-board-devices.c')
-rw-r--r-- | arch/arm/mach-omap2/common-board-devices.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c index cea31dda3a73..e94903b2c65b 100644 --- a/arch/arm/mach-omap2/common-board-devices.c +++ b/arch/arm/mach-omap2/common-board-devices.c | |||
@@ -29,6 +29,7 @@ | |||
29 | 29 | ||
30 | #include <plat/i2c.h> | 30 | #include <plat/i2c.h> |
31 | #include <plat/mcspi.h> | 31 | #include <plat/mcspi.h> |
32 | #include <plat/nand.h> | ||
32 | 33 | ||
33 | #include "common-board-devices.h" | 34 | #include "common-board-devices.h" |
34 | 35 | ||
@@ -49,6 +50,8 @@ void __init omap_pmic_init(int bus, u32 clkrate, | |||
49 | omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1); | 50 | omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1); |
50 | } | 51 | } |
51 | 52 | ||
53 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \ | ||
54 | defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) | ||
52 | static struct omap2_mcspi_device_config ads7846_mcspi_config = { | 55 | static struct omap2_mcspi_device_config ads7846_mcspi_config = { |
53 | .turbo_mode = 0, | 56 | .turbo_mode = 0, |
54 | .single_channel = 1, /* 0: slave, 1: master */ | 57 | .single_channel = 1, /* 0: slave, 1: master */ |
@@ -104,3 +107,57 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce, | |||
104 | 107 | ||
105 | spi_register_board_info(&ads7846_spi_board_info, 1); | 108 | spi_register_board_info(&ads7846_spi_board_info, 1); |
106 | } | 109 | } |
110 | #else | ||
111 | void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce, | ||
112 | struct ads7846_platform_data *board_pdata) | ||
113 | { | ||
114 | } | ||
115 | #endif | ||
116 | |||
117 | #if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE) | ||
118 | static struct omap_nand_platform_data nand_data = { | ||
119 | .dma_channel = -1, /* disable DMA in OMAP NAND driver */ | ||
120 | }; | ||
121 | |||
122 | void __init omap_nand_flash_init(int options, struct mtd_partition *parts, | ||
123 | int nr_parts) | ||
124 | { | ||
125 | u8 cs = 0; | ||
126 | u8 nandcs = GPMC_CS_NUM + 1; | ||
127 | |||
128 | /* find out the chip-select on which NAND exists */ | ||
129 | while (cs < GPMC_CS_NUM) { | ||
130 | u32 ret = 0; | ||
131 | ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); | ||
132 | |||
133 | if ((ret & 0xC00) == 0x800) { | ||
134 | printk(KERN_INFO "Found NAND on CS%d\n", cs); | ||
135 | if (nandcs > GPMC_CS_NUM) | ||
136 | nandcs = cs; | ||
137 | } | ||
138 | cs++; | ||
139 | } | ||
140 | |||
141 | if (nandcs > GPMC_CS_NUM) { | ||
142 | printk(KERN_INFO "NAND: Unable to find configuration " | ||
143 | "in GPMC\n "); | ||
144 | return; | ||
145 | } | ||
146 | |||
147 | if (nandcs < GPMC_CS_NUM) { | ||
148 | nand_data.cs = nandcs; | ||
149 | nand_data.parts = parts; | ||
150 | nand_data.nr_parts = nr_parts; | ||
151 | nand_data.options = options; | ||
152 | |||
153 | printk(KERN_INFO "Registering NAND on CS%d\n", nandcs); | ||
154 | if (gpmc_nand_init(&nand_data) < 0) | ||
155 | printk(KERN_ERR "Unable to register NAND device\n"); | ||
156 | } | ||
157 | } | ||
158 | #else | ||
159 | void __init omap_nand_flash_init(int options, struct mtd_partition *parts, | ||
160 | int nr_parts) | ||
161 | { | ||
162 | } | ||
163 | #endif | ||