blob: f14bd3f55218e5372d96e5f57226a75d66068b0c [file] [log] [blame]
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -07001/*
2 * GPMC support functions
3 *
4 * Copyright (C) 2005-2006 Nokia Corporation
5 *
6 * Author: Juha Yrjola
7 *
Santosh Shilimkar44169072009-05-28 14:16:04 -07008 * Copyright (C) 2009 Texas Instruments
9 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
10 *
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -070011 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
Paul Walmsleyfd1dc872008-10-06 15:49:17 +030015#undef DEBUG
16
Sukumar Ghoraidb97eb7d2011-01-28 15:42:05 +053017#include <linux/irq.h>
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -070018#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/err.h>
21#include <linux/clk.h>
Imre Deakf37e4582006-09-25 12:41:33 +030022#include <linux/ioport.h>
23#include <linux/spinlock.h>
Russell Kingfced80c2008-09-06 12:10:45 +010024#include <linux/io.h>
Paul Walmsleyfd1dc872008-10-06 15:49:17 +030025#include <linux/module.h>
Sukumar Ghoraidb97eb7d2011-01-28 15:42:05 +053026#include <linux/interrupt.h>
Afzal Mohammedda496872012-09-23 17:28:25 -060027#include <linux/platform_device.h>
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -070028
Afzal Mohammedbc3668e2012-09-29 12:26:13 +053029#include <linux/platform_data/mtd-nand-omap2.h>
30
Kyungmin Park7f245162006-12-29 16:48:51 -080031#include <asm/mach-types.h>
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -070032
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -070033#include <plat/cpu.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070034#include <plat/sdrc.h>
Afzal Mohammed4be48fd2012-09-23 17:28:24 -060035#include <plat/omap_device.h>
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -070036
Tony Lindgrendbc04162012-08-31 10:59:07 -070037#include "soc.h"
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -070038#include "common.h"
Afzal Mohammed3ef5d002012-10-05 10:37:27 +053039#include "gpmc.h"
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -070040
Afzal Mohammed4be48fd2012-09-23 17:28:24 -060041#define DEVICE_NAME "omap-gpmc"
42
Paul Walmsleyfd1dc872008-10-06 15:49:17 +030043/* GPMC register offsets */
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -070044#define GPMC_REVISION 0x00
45#define GPMC_SYSCONFIG 0x10
46#define GPMC_SYSSTATUS 0x14
47#define GPMC_IRQSTATUS 0x18
48#define GPMC_IRQENABLE 0x1c
49#define GPMC_TIMEOUT_CONTROL 0x40
50#define GPMC_ERR_ADDRESS 0x44
51#define GPMC_ERR_TYPE 0x48
52#define GPMC_CONFIG 0x50
53#define GPMC_STATUS 0x54
54#define GPMC_PREFETCH_CONFIG1 0x1e0
55#define GPMC_PREFETCH_CONFIG2 0x1e4
Thara Gopinath15e02a32008-04-28 16:55:01 +053056#define GPMC_PREFETCH_CONTROL 0x1ec
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -070057#define GPMC_PREFETCH_STATUS 0x1f0
58#define GPMC_ECC_CONFIG 0x1f4
59#define GPMC_ECC_CONTROL 0x1f8
60#define GPMC_ECC_SIZE_CONFIG 0x1fc
Sukumar Ghorai948d38e2010-07-09 09:14:44 +000061#define GPMC_ECC1_RESULT 0x200
Ivan Djelic8d602cf2012-04-26 14:17:49 +020062#define GPMC_ECC_BCH_RESULT_0 0x240 /* not available on OMAP2 */
Afzal Mohammed2fdf0c92012-10-04 15:49:04 +053063#define GPMC_ECC_BCH_RESULT_1 0x244 /* not available on OMAP2 */
64#define GPMC_ECC_BCH_RESULT_2 0x248 /* not available on OMAP2 */
65#define GPMC_ECC_BCH_RESULT_3 0x24c /* not available on OMAP2 */
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -070066
Yegor Yefremov2c65e742012-05-09 08:32:49 -070067/* GPMC ECC control settings */
68#define GPMC_ECC_CTRL_ECCCLEAR 0x100
69#define GPMC_ECC_CTRL_ECCDISABLE 0x000
70#define GPMC_ECC_CTRL_ECCREG1 0x001
71#define GPMC_ECC_CTRL_ECCREG2 0x002
72#define GPMC_ECC_CTRL_ECCREG3 0x003
73#define GPMC_ECC_CTRL_ECCREG4 0x004
74#define GPMC_ECC_CTRL_ECCREG5 0x005
75#define GPMC_ECC_CTRL_ECCREG6 0x006
76#define GPMC_ECC_CTRL_ECCREG7 0x007
77#define GPMC_ECC_CTRL_ECCREG8 0x008
78#define GPMC_ECC_CTRL_ECCREG9 0x009
79
Sukumar Ghorai948d38e2010-07-09 09:14:44 +000080#define GPMC_CS0_OFFSET 0x60
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -070081#define GPMC_CS_SIZE 0x30
Afzal Mohammed2fdf0c92012-10-04 15:49:04 +053082#define GPMC_BCH_SIZE 0x10
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -070083
Imre Deakf37e4582006-09-25 12:41:33 +030084#define GPMC_MEM_START 0x00000000
85#define GPMC_MEM_END 0x3FFFFFFF
86#define BOOT_ROM_SPACE 0x100000 /* 1MB */
87
88#define GPMC_CHUNK_SHIFT 24 /* 16 MB */
89#define GPMC_SECTION_SHIFT 28 /* 128 MB */
90
vimal singh59e9c5a2009-07-13 16:26:24 +053091#define CS_NUM_SHIFT 24
92#define ENABLE_PREFETCH (0x1 << 7)
93#define DMA_MPU_MODE 2
94
Afzal Mohammedda496872012-09-23 17:28:25 -060095#define GPMC_REVISION_MAJOR(l) ((l >> 4) & 0xf)
96#define GPMC_REVISION_MINOR(l) (l & 0xf)
97
98#define GPMC_HAS_WR_ACCESS 0x1
99#define GPMC_HAS_WR_DATA_MUX_BUS 0x2
100
Afzal Mohammed6b6c32f2012-08-30 12:53:23 -0700101/* XXX: Only NAND irq has been considered,currently these are the only ones used
102 */
103#define GPMC_NR_IRQ 2
104
105struct gpmc_client_irq {
106 unsigned irq;
107 u32 bitmask;
108};
109
Rajendra Nayaka2d3e7b2008-09-26 17:47:33 +0530110/* Structure to save gpmc cs context */
111struct gpmc_cs_config {
112 u32 config1;
113 u32 config2;
114 u32 config3;
115 u32 config4;
116 u32 config5;
117 u32 config6;
118 u32 config7;
119 int is_valid;
120};
121
122/*
123 * Structure to save/restore gpmc context
124 * to support core off on OMAP3
125 */
126struct omap3_gpmc_regs {
127 u32 sysconfig;
128 u32 irqenable;
129 u32 timeout_ctrl;
130 u32 config;
131 u32 prefetch_config1;
132 u32 prefetch_config2;
133 u32 prefetch_control;
134 struct gpmc_cs_config cs_context[GPMC_CS_NUM];
135};
136
Afzal Mohammed6b6c32f2012-08-30 12:53:23 -0700137static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
138static struct irq_chip gpmc_irq_chip;
139static unsigned gpmc_irq_start;
140
Imre Deakf37e4582006-09-25 12:41:33 +0300141static struct resource gpmc_mem_root;
142static struct resource gpmc_cs_mem[GPMC_CS_NUM];
Thomas Gleixner87b247c2007-05-10 22:33:04 -0700143static DEFINE_SPINLOCK(gpmc_mem_lock);
Sukumar Ghorai948d38e2010-07-09 09:14:44 +0000144static unsigned int gpmc_cs_map; /* flag for cs which are initialized */
Afzal Mohammedda496872012-09-23 17:28:25 -0600145static struct device *gpmc_dev;
146static int gpmc_irq;
147static resource_size_t phys_base, mem_size;
148static unsigned gpmc_capability;
Paul Walmsleyfd1dc872008-10-06 15:49:17 +0300149static void __iomem *gpmc_base;
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700150
Paul Walmsleyfd1dc872008-10-06 15:49:17 +0300151static struct clk *gpmc_l3_clk;
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700152
Sukumar Ghoraidb97eb7d2011-01-28 15:42:05 +0530153static irqreturn_t gpmc_handle_irq(int irq, void *dev);
154
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700155static void gpmc_write_reg(int idx, u32 val)
156{
157 __raw_writel(val, gpmc_base + idx);
158}
159
160static u32 gpmc_read_reg(int idx)
161{
162 return __raw_readl(gpmc_base + idx);
163}
164
165void gpmc_cs_write_reg(int cs, int idx, u32 val)
166{
167 void __iomem *reg_addr;
168
Sukumar Ghorai948d38e2010-07-09 09:14:44 +0000169 reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx;
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700170 __raw_writel(val, reg_addr);
171}
172
173u32 gpmc_cs_read_reg(int cs, int idx)
174{
Paul Walmsleyfd1dc872008-10-06 15:49:17 +0300175 void __iomem *reg_addr;
176
Sukumar Ghorai948d38e2010-07-09 09:14:44 +0000177 reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx;
Paul Walmsleyfd1dc872008-10-06 15:49:17 +0300178 return __raw_readl(reg_addr);
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700179}
180
Paul Walmsleyfd1dc872008-10-06 15:49:17 +0300181/* TODO: Add support for gpmc_fck to clock framework and use it */
David Brownell1c22cc12006-12-06 17:13:55 -0800182unsigned long gpmc_get_fclk_period(void)
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700183{
Paul Walmsleyfd1dc872008-10-06 15:49:17 +0300184 unsigned long rate = clk_get_rate(gpmc_l3_clk);
185
186 if (rate == 0) {
187 printk(KERN_WARNING "gpmc_l3_clk not enabled\n");
188 return 0;
189 }
190
191 rate /= 1000;
192 rate = 1000000000 / rate; /* In picoseconds */
193
194 return rate;
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700195}
196
197unsigned int gpmc_ns_to_ticks(unsigned int time_ns)
198{
199 unsigned long tick_ps;
200
201 /* Calculate in picosecs to yield more exact results */
202 tick_ps = gpmc_get_fclk_period();
203
204 return (time_ns * 1000 + tick_ps - 1) / tick_ps;
205}
206
Adrian Huntera3551f52010-12-09 10:48:27 +0200207unsigned int gpmc_ps_to_ticks(unsigned int time_ps)
208{
209 unsigned long tick_ps;
210
211 /* Calculate in picosecs to yield more exact results */
212 tick_ps = gpmc_get_fclk_period();
213
214 return (time_ps + tick_ps - 1) / tick_ps;
215}
216
Paul Walmsleyfd1dc872008-10-06 15:49:17 +0300217unsigned int gpmc_ticks_to_ns(unsigned int ticks)
218{
219 return ticks * gpmc_get_fclk_period() / 1000;
220}
221
Kai Svahn23300592007-01-26 12:29:40 -0800222unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns)
223{
224 unsigned long ticks = gpmc_ns_to_ticks(time_ns);
225
226 return ticks * gpmc_get_fclk_period() / 1000;
227}
228
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700229#ifdef DEBUG
230static int set_gpmc_timing_reg(int cs, int reg, int st_bit, int end_bit,
Juha Yrjola2aab6462006-06-26 16:16:21 -0700231 int time, const char *name)
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700232#else
233static int set_gpmc_timing_reg(int cs, int reg, int st_bit, int end_bit,
234 int time)
235#endif
236{
237 u32 l;
238 int ticks, mask, nr_bits;
239
240 if (time == 0)
241 ticks = 0;
242 else
243 ticks = gpmc_ns_to_ticks(time);
244 nr_bits = end_bit - st_bit + 1;
David Brownell1c22cc12006-12-06 17:13:55 -0800245 if (ticks >= 1 << nr_bits) {
246#ifdef DEBUG
247 printk(KERN_INFO "GPMC CS%d: %-10s* %3d ns, %3d ticks >= %d\n",
248 cs, name, time, ticks, 1 << nr_bits);
249#endif
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700250 return -1;
David Brownell1c22cc12006-12-06 17:13:55 -0800251 }
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700252
253 mask = (1 << nr_bits) - 1;
254 l = gpmc_cs_read_reg(cs, reg);
255#ifdef DEBUG
David Brownell1c22cc12006-12-06 17:13:55 -0800256 printk(KERN_INFO
257 "GPMC CS%d: %-10s: %3d ticks, %3lu ns (was %3i ticks) %3d ns\n",
Juha Yrjola2aab6462006-06-26 16:16:21 -0700258 cs, name, ticks, gpmc_get_fclk_period() * ticks / 1000,
David Brownell1c22cc12006-12-06 17:13:55 -0800259 (l >> st_bit) & mask, time);
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700260#endif
261 l &= ~(mask << st_bit);
262 l |= ticks << st_bit;
263 gpmc_cs_write_reg(cs, reg, l);
264
265 return 0;
266}
267
268#ifdef DEBUG
269#define GPMC_SET_ONE(reg, st, end, field) \
270 if (set_gpmc_timing_reg(cs, (reg), (st), (end), \
271 t->field, #field) < 0) \
272 return -1
273#else
274#define GPMC_SET_ONE(reg, st, end, field) \
275 if (set_gpmc_timing_reg(cs, (reg), (st), (end), t->field) < 0) \
276 return -1
277#endif
278
Afzal Mohammed1b47ca12012-08-19 18:29:45 +0530279int gpmc_calc_divider(unsigned int sync_clk)
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700280{
281 int div;
282 u32 l;
283
Adrian Huntera3551f52010-12-09 10:48:27 +0200284 l = sync_clk + (gpmc_get_fclk_period() - 1);
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700285 div = l / gpmc_get_fclk_period();
286 if (div > 4)
287 return -1;
David Brownell1c22cc12006-12-06 17:13:55 -0800288 if (div <= 0)
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700289 div = 1;
290
291 return div;
292}
293
294int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t)
295{
296 int div;
297 u32 l;
298
Afzal Mohammed1b47ca12012-08-19 18:29:45 +0530299 div = gpmc_calc_divider(t->sync_clk);
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700300 if (div < 0)
Paul Walmsleya032d332012-08-03 09:21:10 -0600301 return div;
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700302
303 GPMC_SET_ONE(GPMC_CS_CONFIG2, 0, 3, cs_on);
304 GPMC_SET_ONE(GPMC_CS_CONFIG2, 8, 12, cs_rd_off);
305 GPMC_SET_ONE(GPMC_CS_CONFIG2, 16, 20, cs_wr_off);
306
307 GPMC_SET_ONE(GPMC_CS_CONFIG3, 0, 3, adv_on);
308 GPMC_SET_ONE(GPMC_CS_CONFIG3, 8, 12, adv_rd_off);
309 GPMC_SET_ONE(GPMC_CS_CONFIG3, 16, 20, adv_wr_off);
310
311 GPMC_SET_ONE(GPMC_CS_CONFIG4, 0, 3, oe_on);
312 GPMC_SET_ONE(GPMC_CS_CONFIG4, 8, 12, oe_off);
313 GPMC_SET_ONE(GPMC_CS_CONFIG4, 16, 19, we_on);
314 GPMC_SET_ONE(GPMC_CS_CONFIG4, 24, 28, we_off);
315
316 GPMC_SET_ONE(GPMC_CS_CONFIG5, 0, 4, rd_cycle);
317 GPMC_SET_ONE(GPMC_CS_CONFIG5, 8, 12, wr_cycle);
318 GPMC_SET_ONE(GPMC_CS_CONFIG5, 16, 20, access);
319
320 GPMC_SET_ONE(GPMC_CS_CONFIG5, 24, 27, page_burst_access);
321
Afzal Mohammedda496872012-09-23 17:28:25 -0600322 if (gpmc_capability & GPMC_HAS_WR_DATA_MUX_BUS)
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +0300323 GPMC_SET_ONE(GPMC_CS_CONFIG6, 16, 19, wr_data_mux_bus);
Afzal Mohammedda496872012-09-23 17:28:25 -0600324 if (gpmc_capability & GPMC_HAS_WR_ACCESS)
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +0300325 GPMC_SET_ONE(GPMC_CS_CONFIG6, 24, 28, wr_access);
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +0300326
David Brownell1c22cc12006-12-06 17:13:55 -0800327 /* caller is expected to have initialized CONFIG1 to cover
328 * at least sync vs async
329 */
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700330 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
David Brownell1c22cc12006-12-06 17:13:55 -0800331 if (l & (GPMC_CONFIG1_READTYPE_SYNC | GPMC_CONFIG1_WRITETYPE_SYNC)) {
332#ifdef DEBUG
333 printk(KERN_INFO "GPMC CS%d CLK period is %lu ns (div %d)\n",
334 cs, (div * gpmc_get_fclk_period()) / 1000, div);
335#endif
336 l &= ~0x03;
337 l |= (div - 1);
338 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, l);
339 }
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700340
341 return 0;
342}
343
Imre Deakf37e4582006-09-25 12:41:33 +0300344static void gpmc_cs_enable_mem(int cs, u32 base, u32 size)
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700345{
Imre Deakf37e4582006-09-25 12:41:33 +0300346 u32 l;
347 u32 mask;
348
349 mask = (1 << GPMC_SECTION_SHIFT) - size;
350 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
351 l &= ~0x3f;
352 l = (base >> GPMC_CHUNK_SHIFT) & 0x3f;
353 l &= ~(0x0f << 8);
354 l |= ((mask >> GPMC_CHUNK_SHIFT) & 0x0f) << 8;
Rajendra Nayaka2d3e7b2008-09-26 17:47:33 +0530355 l |= GPMC_CONFIG7_CSVALID;
Imre Deakf37e4582006-09-25 12:41:33 +0300356 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l);
357}
358
359static void gpmc_cs_disable_mem(int cs)
360{
361 u32 l;
362
363 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
Rajendra Nayaka2d3e7b2008-09-26 17:47:33 +0530364 l &= ~GPMC_CONFIG7_CSVALID;
Imre Deakf37e4582006-09-25 12:41:33 +0300365 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l);
366}
367
368static void gpmc_cs_get_memconf(int cs, u32 *base, u32 *size)
369{
370 u32 l;
371 u32 mask;
372
373 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
374 *base = (l & 0x3f) << GPMC_CHUNK_SHIFT;
375 mask = (l >> 8) & 0x0f;
376 *size = (1 << GPMC_SECTION_SHIFT) - (mask << GPMC_CHUNK_SHIFT);
377}
378
379static int gpmc_cs_mem_enabled(int cs)
380{
381 u32 l;
382
383 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
Rajendra Nayaka2d3e7b2008-09-26 17:47:33 +0530384 return l & GPMC_CONFIG7_CSVALID;
Imre Deakf37e4582006-09-25 12:41:33 +0300385}
386
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800387int gpmc_cs_set_reserved(int cs, int reserved)
Imre Deakf37e4582006-09-25 12:41:33 +0300388{
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800389 if (cs > GPMC_CS_NUM)
390 return -ENODEV;
391
Imre Deakf37e4582006-09-25 12:41:33 +0300392 gpmc_cs_map &= ~(1 << cs);
393 gpmc_cs_map |= (reserved ? 1 : 0) << cs;
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800394
395 return 0;
Imre Deakf37e4582006-09-25 12:41:33 +0300396}
397
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800398int gpmc_cs_reserved(int cs)
Imre Deakf37e4582006-09-25 12:41:33 +0300399{
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800400 if (cs > GPMC_CS_NUM)
401 return -ENODEV;
402
Imre Deakf37e4582006-09-25 12:41:33 +0300403 return gpmc_cs_map & (1 << cs);
404}
405
406static unsigned long gpmc_mem_align(unsigned long size)
407{
408 int order;
409
410 size = (size - 1) >> (GPMC_CHUNK_SHIFT - 1);
411 order = GPMC_CHUNK_SHIFT - 1;
412 do {
413 size >>= 1;
414 order++;
415 } while (size);
416 size = 1 << order;
417 return size;
418}
419
420static int gpmc_cs_insert_mem(int cs, unsigned long base, unsigned long size)
421{
422 struct resource *res = &gpmc_cs_mem[cs];
423 int r;
424
425 size = gpmc_mem_align(size);
426 spin_lock(&gpmc_mem_lock);
427 res->start = base;
428 res->end = base + size - 1;
429 r = request_resource(&gpmc_mem_root, res);
430 spin_unlock(&gpmc_mem_lock);
431
432 return r;
433}
434
Afzal Mohammedda496872012-09-23 17:28:25 -0600435static int gpmc_cs_delete_mem(int cs)
436{
437 struct resource *res = &gpmc_cs_mem[cs];
438 int r;
439
440 spin_lock(&gpmc_mem_lock);
441 r = release_resource(&gpmc_cs_mem[cs]);
442 res->start = 0;
443 res->end = 0;
444 spin_unlock(&gpmc_mem_lock);
445
446 return r;
447}
448
Imre Deakf37e4582006-09-25 12:41:33 +0300449int gpmc_cs_request(int cs, unsigned long size, unsigned long *base)
450{
451 struct resource *res = &gpmc_cs_mem[cs];
452 int r = -1;
453
454 if (cs > GPMC_CS_NUM)
455 return -ENODEV;
456
457 size = gpmc_mem_align(size);
458 if (size > (1 << GPMC_SECTION_SHIFT))
459 return -ENOMEM;
460
461 spin_lock(&gpmc_mem_lock);
462 if (gpmc_cs_reserved(cs)) {
463 r = -EBUSY;
464 goto out;
465 }
466 if (gpmc_cs_mem_enabled(cs))
467 r = adjust_resource(res, res->start & ~(size - 1), size);
468 if (r < 0)
469 r = allocate_resource(&gpmc_mem_root, res, size, 0, ~0,
470 size, NULL, NULL);
471 if (r < 0)
472 goto out;
473
Tobias Klauser6d135242009-11-10 18:55:19 -0800474 gpmc_cs_enable_mem(cs, res->start, resource_size(res));
Imre Deakf37e4582006-09-25 12:41:33 +0300475 *base = res->start;
476 gpmc_cs_set_reserved(cs, 1);
477out:
478 spin_unlock(&gpmc_mem_lock);
479 return r;
480}
Paul Walmsleyfd1dc872008-10-06 15:49:17 +0300481EXPORT_SYMBOL(gpmc_cs_request);
Imre Deakf37e4582006-09-25 12:41:33 +0300482
483void gpmc_cs_free(int cs)
484{
485 spin_lock(&gpmc_mem_lock);
Roel Kluine7fdc602009-11-17 14:39:06 -0800486 if (cs >= GPMC_CS_NUM || cs < 0 || !gpmc_cs_reserved(cs)) {
Imre Deakf37e4582006-09-25 12:41:33 +0300487 printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs);
488 BUG();
489 spin_unlock(&gpmc_mem_lock);
490 return;
491 }
492 gpmc_cs_disable_mem(cs);
493 release_resource(&gpmc_cs_mem[cs]);
494 gpmc_cs_set_reserved(cs, 0);
495 spin_unlock(&gpmc_mem_lock);
496}
Paul Walmsleyfd1dc872008-10-06 15:49:17 +0300497EXPORT_SYMBOL(gpmc_cs_free);
Imre Deakf37e4582006-09-25 12:41:33 +0300498
vimal singh59e9c5a2009-07-13 16:26:24 +0530499/**
Sukumar Ghorai948d38e2010-07-09 09:14:44 +0000500 * gpmc_cs_configure - write request to configure gpmc
501 * @cs: chip select number
502 * @cmd: command type
503 * @wval: value to write
504 * @return status of the operation
505 */
506int gpmc_cs_configure(int cs, int cmd, int wval)
507{
508 int err = 0;
509 u32 regval = 0;
510
511 switch (cmd) {
Sukumar Ghoraidb97eb7d2011-01-28 15:42:05 +0530512 case GPMC_ENABLE_IRQ:
513 gpmc_write_reg(GPMC_IRQENABLE, wval);
514 break;
515
Sukumar Ghorai948d38e2010-07-09 09:14:44 +0000516 case GPMC_SET_IRQ_STATUS:
517 gpmc_write_reg(GPMC_IRQSTATUS, wval);
518 break;
519
520 case GPMC_CONFIG_WP:
521 regval = gpmc_read_reg(GPMC_CONFIG);
522 if (wval)
523 regval &= ~GPMC_CONFIG_WRITEPROTECT; /* WP is ON */
524 else
525 regval |= GPMC_CONFIG_WRITEPROTECT; /* WP is OFF */
526 gpmc_write_reg(GPMC_CONFIG, regval);
527 break;
528
529 case GPMC_CONFIG_RDY_BSY:
530 regval = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
531 if (wval)
532 regval |= WR_RD_PIN_MONITORING;
533 else
534 regval &= ~WR_RD_PIN_MONITORING;
535 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, regval);
536 break;
537
538 case GPMC_CONFIG_DEV_SIZE:
539 regval = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
Yegor Yefremov8ef5d842012-01-23 08:32:23 +0100540
541 /* clear 2 target bits */
542 regval &= ~GPMC_CONFIG1_DEVICESIZE(3);
543
544 /* set the proper value */
Sukumar Ghorai948d38e2010-07-09 09:14:44 +0000545 regval |= GPMC_CONFIG1_DEVICESIZE(wval);
Yegor Yefremov8ef5d842012-01-23 08:32:23 +0100546
Sukumar Ghorai948d38e2010-07-09 09:14:44 +0000547 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, regval);
548 break;
549
550 case GPMC_CONFIG_DEV_TYPE:
551 regval = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
552 regval |= GPMC_CONFIG1_DEVICETYPE(wval);
553 if (wval == GPMC_DEVICETYPE_NOR)
554 regval |= GPMC_CONFIG1_MUXADDDATA;
555 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, regval);
556 break;
557
558 default:
559 printk(KERN_ERR "gpmc_configure_cs: Not supported\n");
560 err = -EINVAL;
561 }
562
563 return err;
564}
565EXPORT_SYMBOL(gpmc_cs_configure);
566
Afzal Mohammed52bd1382012-08-30 12:53:22 -0700567void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs)
568{
Afzal Mohammed2fdf0c92012-10-04 15:49:04 +0530569 int i;
570
Afzal Mohammed52bd1382012-08-30 12:53:22 -0700571 reg->gpmc_status = gpmc_base + GPMC_STATUS;
572 reg->gpmc_nand_command = gpmc_base + GPMC_CS0_OFFSET +
573 GPMC_CS_NAND_COMMAND + GPMC_CS_SIZE * cs;
574 reg->gpmc_nand_address = gpmc_base + GPMC_CS0_OFFSET +
575 GPMC_CS_NAND_ADDRESS + GPMC_CS_SIZE * cs;
576 reg->gpmc_nand_data = gpmc_base + GPMC_CS0_OFFSET +
577 GPMC_CS_NAND_DATA + GPMC_CS_SIZE * cs;
578 reg->gpmc_prefetch_config1 = gpmc_base + GPMC_PREFETCH_CONFIG1;
579 reg->gpmc_prefetch_config2 = gpmc_base + GPMC_PREFETCH_CONFIG2;
580 reg->gpmc_prefetch_control = gpmc_base + GPMC_PREFETCH_CONTROL;
581 reg->gpmc_prefetch_status = gpmc_base + GPMC_PREFETCH_STATUS;
582 reg->gpmc_ecc_config = gpmc_base + GPMC_ECC_CONFIG;
583 reg->gpmc_ecc_control = gpmc_base + GPMC_ECC_CONTROL;
584 reg->gpmc_ecc_size_config = gpmc_base + GPMC_ECC_SIZE_CONFIG;
585 reg->gpmc_ecc1_result = gpmc_base + GPMC_ECC1_RESULT;
Afzal Mohammed2fdf0c92012-10-04 15:49:04 +0530586
587 for (i = 0; i < GPMC_BCH_NUM_REMAINDER; i++) {
588 reg->gpmc_bch_result0[i] = gpmc_base + GPMC_ECC_BCH_RESULT_0 +
589 GPMC_BCH_SIZE * i;
590 reg->gpmc_bch_result1[i] = gpmc_base + GPMC_ECC_BCH_RESULT_1 +
591 GPMC_BCH_SIZE * i;
592 reg->gpmc_bch_result2[i] = gpmc_base + GPMC_ECC_BCH_RESULT_2 +
593 GPMC_BCH_SIZE * i;
594 reg->gpmc_bch_result3[i] = gpmc_base + GPMC_ECC_BCH_RESULT_3 +
595 GPMC_BCH_SIZE * i;
596 }
Afzal Mohammed52bd1382012-08-30 12:53:22 -0700597}
598
Afzal Mohammed6b6c32f2012-08-30 12:53:23 -0700599int gpmc_get_client_irq(unsigned irq_config)
600{
601 int i;
602
603 if (hweight32(irq_config) > 1)
604 return 0;
605
606 for (i = 0; i < GPMC_NR_IRQ; i++)
607 if (gpmc_client_irq[i].bitmask & irq_config)
608 return gpmc_client_irq[i].irq;
609
610 return 0;
611}
612
613static int gpmc_irq_endis(unsigned irq, bool endis)
614{
615 int i;
616 u32 regval;
617
618 for (i = 0; i < GPMC_NR_IRQ; i++)
619 if (irq == gpmc_client_irq[i].irq) {
620 regval = gpmc_read_reg(GPMC_IRQENABLE);
621 if (endis)
622 regval |= gpmc_client_irq[i].bitmask;
623 else
624 regval &= ~gpmc_client_irq[i].bitmask;
625 gpmc_write_reg(GPMC_IRQENABLE, regval);
626 break;
627 }
628
629 return 0;
630}
631
632static void gpmc_irq_disable(struct irq_data *p)
633{
634 gpmc_irq_endis(p->irq, false);
635}
636
637static void gpmc_irq_enable(struct irq_data *p)
638{
639 gpmc_irq_endis(p->irq, true);
640}
641
642static void gpmc_irq_noop(struct irq_data *data) { }
643
644static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
645
Afzal Mohammedda496872012-09-23 17:28:25 -0600646static int gpmc_setup_irq(void)
Afzal Mohammed6b6c32f2012-08-30 12:53:23 -0700647{
648 int i;
649 u32 regval;
650
651 if (!gpmc_irq)
652 return -EINVAL;
653
654 gpmc_irq_start = irq_alloc_descs(-1, 0, GPMC_NR_IRQ, 0);
655 if (IS_ERR_VALUE(gpmc_irq_start)) {
656 pr_err("irq_alloc_descs failed\n");
657 return gpmc_irq_start;
658 }
659
660 gpmc_irq_chip.name = "gpmc";
661 gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
662 gpmc_irq_chip.irq_enable = gpmc_irq_enable;
663 gpmc_irq_chip.irq_disable = gpmc_irq_disable;
664 gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
665 gpmc_irq_chip.irq_ack = gpmc_irq_noop;
666 gpmc_irq_chip.irq_mask = gpmc_irq_noop;
667 gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
668
669 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
670 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
671
672 for (i = 0; i < GPMC_NR_IRQ; i++) {
673 gpmc_client_irq[i].irq = gpmc_irq_start + i;
674 irq_set_chip_and_handler(gpmc_client_irq[i].irq,
675 &gpmc_irq_chip, handle_simple_irq);
676 set_irq_flags(gpmc_client_irq[i].irq,
677 IRQF_VALID | IRQF_NOAUTOEN);
678 }
679
680 /* Disable interrupts */
681 gpmc_write_reg(GPMC_IRQENABLE, 0);
682
683 /* clear interrupts */
684 regval = gpmc_read_reg(GPMC_IRQSTATUS);
685 gpmc_write_reg(GPMC_IRQSTATUS, regval);
686
687 return request_irq(gpmc_irq, gpmc_handle_irq, 0, "gpmc", NULL);
688}
689
Afzal Mohammed61687c62012-10-04 14:01:57 +0530690static __devexit int gpmc_free_irq(void)
Afzal Mohammedda496872012-09-23 17:28:25 -0600691{
692 int i;
693
694 if (gpmc_irq)
695 free_irq(gpmc_irq, NULL);
696
697 for (i = 0; i < GPMC_NR_IRQ; i++) {
698 irq_set_handler(gpmc_client_irq[i].irq, NULL);
699 irq_set_chip(gpmc_client_irq[i].irq, &no_irq_chip);
700 irq_modify_status(gpmc_client_irq[i].irq, 0, 0);
701 }
702
703 irq_free_descs(gpmc_irq_start, GPMC_NR_IRQ);
704
705 return 0;
706}
707
708static void __devexit gpmc_mem_exit(void)
709{
710 int cs;
711
712 for (cs = 0; cs < GPMC_CS_NUM; cs++) {
713 if (!gpmc_cs_mem_enabled(cs))
714 continue;
715 gpmc_cs_delete_mem(cs);
716 }
717
718}
719
720static void __devinit gpmc_mem_init(void)
Imre Deakf37e4582006-09-25 12:41:33 +0300721{
722 int cs;
723 unsigned long boot_rom_space = 0;
724
Kyungmin Park7f245162006-12-29 16:48:51 -0800725 /* never allocate the first page, to facilitate bug detection;
726 * even if we didn't boot from ROM.
727 */
728 boot_rom_space = BOOT_ROM_SPACE;
729 /* In apollon the CS0 is mapped as 0x0000 0000 */
730 if (machine_is_omap_apollon())
731 boot_rom_space = 0;
Imre Deakf37e4582006-09-25 12:41:33 +0300732 gpmc_mem_root.start = GPMC_MEM_START + boot_rom_space;
733 gpmc_mem_root.end = GPMC_MEM_END;
734
735 /* Reserve all regions that has been set up by bootloader */
736 for (cs = 0; cs < GPMC_CS_NUM; cs++) {
737 u32 base, size;
738
739 if (!gpmc_cs_mem_enabled(cs))
740 continue;
741 gpmc_cs_get_memconf(cs, &base, &size);
742 if (gpmc_cs_insert_mem(cs, base, size) < 0)
743 BUG();
744 }
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700745}
746
Afzal Mohammedda496872012-09-23 17:28:25 -0600747static __devinit int gpmc_probe(struct platform_device *pdev)
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700748{
Afzal Mohammed6b6c32f2012-08-30 12:53:23 -0700749 u32 l;
Afzal Mohammedda496872012-09-23 17:28:25 -0600750 struct resource *res;
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700751
Afzal Mohammedda496872012-09-23 17:28:25 -0600752 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
753 if (res == NULL)
754 return -ENOENT;
Paul Walmsleyfd1dc872008-10-06 15:49:17 +0300755
Afzal Mohammedda496872012-09-23 17:28:25 -0600756 phys_base = res->start;
757 mem_size = resource_size(res);
Kevin Hilman8d084362010-01-29 14:20:06 -0800758
Afzal Mohammedda496872012-09-23 17:28:25 -0600759 gpmc_base = devm_request_and_ioremap(&pdev->dev, res);
Paul Walmsleyfd1dc872008-10-06 15:49:17 +0300760 if (!gpmc_base) {
Afzal Mohammedda496872012-09-23 17:28:25 -0600761 dev_err(&pdev->dev, "error: request memory / ioremap\n");
762 return -EADDRNOTAVAIL;
763 }
764
765 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
766 if (res == NULL)
767 dev_warn(&pdev->dev, "Failed to get resource: irq\n");
768 else
769 gpmc_irq = res->start;
770
771 gpmc_l3_clk = clk_get(&pdev->dev, "fck");
772 if (IS_ERR(gpmc_l3_clk)) {
773 dev_err(&pdev->dev, "error: clk_get\n");
774 gpmc_irq = 0;
775 return PTR_ERR(gpmc_l3_clk);
Paul Walmsleyfd1dc872008-10-06 15:49:17 +0300776 }
777
Rajendra Nayak4d7cb452012-09-22 02:24:16 -0600778 clk_prepare_enable(gpmc_l3_clk);
Olof Johansson1daa8c12010-01-20 22:39:29 +0000779
Afzal Mohammedda496872012-09-23 17:28:25 -0600780 gpmc_dev = &pdev->dev;
781
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700782 l = gpmc_read_reg(GPMC_REVISION);
Afzal Mohammedda496872012-09-23 17:28:25 -0600783 if (GPMC_REVISION_MAJOR(l) > 0x4)
784 gpmc_capability = GPMC_HAS_WR_ACCESS | GPMC_HAS_WR_DATA_MUX_BUS;
785 dev_info(gpmc_dev, "GPMC revision %d.%d\n", GPMC_REVISION_MAJOR(l),
786 GPMC_REVISION_MINOR(l));
787
Imre Deakf37e4582006-09-25 12:41:33 +0300788 gpmc_mem_init();
Sukumar Ghoraidb97eb7d2011-01-28 15:42:05 +0530789
Afzal Mohammedda496872012-09-23 17:28:25 -0600790 if (IS_ERR_VALUE(gpmc_setup_irq()))
791 dev_warn(gpmc_dev, "gpmc_setup_irq failed\n");
792
793 return 0;
Sukumar Ghoraidb97eb7d2011-01-28 15:42:05 +0530794}
Afzal Mohammedda496872012-09-23 17:28:25 -0600795
Afzal Mohammed61687c62012-10-04 14:01:57 +0530796static __devexit int gpmc_remove(struct platform_device *pdev)
Afzal Mohammedda496872012-09-23 17:28:25 -0600797{
798 gpmc_free_irq();
799 gpmc_mem_exit();
800 gpmc_dev = NULL;
801 return 0;
802}
803
804static struct platform_driver gpmc_driver = {
805 .probe = gpmc_probe,
806 .remove = __devexit_p(gpmc_remove),
807 .driver = {
808 .name = DEVICE_NAME,
809 .owner = THIS_MODULE,
810 },
811};
812
813static __init int gpmc_init(void)
814{
815 return platform_driver_register(&gpmc_driver);
816}
817
818static __exit void gpmc_exit(void)
819{
820 platform_driver_unregister(&gpmc_driver);
821
822}
823
Sukumar Ghoraidb97eb7d2011-01-28 15:42:05 +0530824postcore_initcall(gpmc_init);
Afzal Mohammedda496872012-09-23 17:28:25 -0600825module_exit(gpmc_exit);
Sukumar Ghoraidb97eb7d2011-01-28 15:42:05 +0530826
Afzal Mohammed4be48fd2012-09-23 17:28:24 -0600827static int __init omap_gpmc_init(void)
828{
829 struct omap_hwmod *oh;
830 struct platform_device *pdev;
831 char *oh_name = "gpmc";
832
833 oh = omap_hwmod_lookup(oh_name);
834 if (!oh) {
835 pr_err("Could not look up %s\n", oh_name);
836 return -ENODEV;
837 }
838
839 pdev = omap_device_build(DEVICE_NAME, -1, oh, NULL, 0, NULL, 0, 0);
840 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
841
842 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
843}
844postcore_initcall(omap_gpmc_init);
845
Sukumar Ghoraidb97eb7d2011-01-28 15:42:05 +0530846static irqreturn_t gpmc_handle_irq(int irq, void *dev)
847{
Afzal Mohammed6b6c32f2012-08-30 12:53:23 -0700848 int i;
849 u32 regval;
Sukumar Ghoraidb97eb7d2011-01-28 15:42:05 +0530850
Afzal Mohammed6b6c32f2012-08-30 12:53:23 -0700851 regval = gpmc_read_reg(GPMC_IRQSTATUS);
852
853 if (!regval)
854 return IRQ_NONE;
855
856 for (i = 0; i < GPMC_NR_IRQ; i++)
857 if (regval & gpmc_client_irq[i].bitmask)
858 generic_handle_irq(gpmc_client_irq[i].irq);
859
860 gpmc_write_reg(GPMC_IRQSTATUS, regval);
Sukumar Ghoraidb97eb7d2011-01-28 15:42:05 +0530861
862 return IRQ_HANDLED;
Juha Yrjola4bbbc1a2006-06-26 16:16:16 -0700863}
Rajendra Nayaka2d3e7b2008-09-26 17:47:33 +0530864
865#ifdef CONFIG_ARCH_OMAP3
866static struct omap3_gpmc_regs gpmc_context;
867
Felipe Balbib2fa3b72010-02-15 10:03:33 -0800868void omap3_gpmc_save_context(void)
Rajendra Nayaka2d3e7b2008-09-26 17:47:33 +0530869{
870 int i;
Felipe Balbib2fa3b72010-02-15 10:03:33 -0800871
Rajendra Nayaka2d3e7b2008-09-26 17:47:33 +0530872 gpmc_context.sysconfig = gpmc_read_reg(GPMC_SYSCONFIG);
873 gpmc_context.irqenable = gpmc_read_reg(GPMC_IRQENABLE);
874 gpmc_context.timeout_ctrl = gpmc_read_reg(GPMC_TIMEOUT_CONTROL);
875 gpmc_context.config = gpmc_read_reg(GPMC_CONFIG);
876 gpmc_context.prefetch_config1 = gpmc_read_reg(GPMC_PREFETCH_CONFIG1);
877 gpmc_context.prefetch_config2 = gpmc_read_reg(GPMC_PREFETCH_CONFIG2);
878 gpmc_context.prefetch_control = gpmc_read_reg(GPMC_PREFETCH_CONTROL);
879 for (i = 0; i < GPMC_CS_NUM; i++) {
880 gpmc_context.cs_context[i].is_valid = gpmc_cs_mem_enabled(i);
881 if (gpmc_context.cs_context[i].is_valid) {
882 gpmc_context.cs_context[i].config1 =
883 gpmc_cs_read_reg(i, GPMC_CS_CONFIG1);
884 gpmc_context.cs_context[i].config2 =
885 gpmc_cs_read_reg(i, GPMC_CS_CONFIG2);
886 gpmc_context.cs_context[i].config3 =
887 gpmc_cs_read_reg(i, GPMC_CS_CONFIG3);
888 gpmc_context.cs_context[i].config4 =
889 gpmc_cs_read_reg(i, GPMC_CS_CONFIG4);
890 gpmc_context.cs_context[i].config5 =
891 gpmc_cs_read_reg(i, GPMC_CS_CONFIG5);
892 gpmc_context.cs_context[i].config6 =
893 gpmc_cs_read_reg(i, GPMC_CS_CONFIG6);
894 gpmc_context.cs_context[i].config7 =
895 gpmc_cs_read_reg(i, GPMC_CS_CONFIG7);
896 }
897 }
898}
899
Felipe Balbib2fa3b72010-02-15 10:03:33 -0800900void omap3_gpmc_restore_context(void)
Rajendra Nayaka2d3e7b2008-09-26 17:47:33 +0530901{
902 int i;
Felipe Balbib2fa3b72010-02-15 10:03:33 -0800903
Rajendra Nayaka2d3e7b2008-09-26 17:47:33 +0530904 gpmc_write_reg(GPMC_SYSCONFIG, gpmc_context.sysconfig);
905 gpmc_write_reg(GPMC_IRQENABLE, gpmc_context.irqenable);
906 gpmc_write_reg(GPMC_TIMEOUT_CONTROL, gpmc_context.timeout_ctrl);
907 gpmc_write_reg(GPMC_CONFIG, gpmc_context.config);
908 gpmc_write_reg(GPMC_PREFETCH_CONFIG1, gpmc_context.prefetch_config1);
909 gpmc_write_reg(GPMC_PREFETCH_CONFIG2, gpmc_context.prefetch_config2);
910 gpmc_write_reg(GPMC_PREFETCH_CONTROL, gpmc_context.prefetch_control);
911 for (i = 0; i < GPMC_CS_NUM; i++) {
912 if (gpmc_context.cs_context[i].is_valid) {
913 gpmc_cs_write_reg(i, GPMC_CS_CONFIG1,
914 gpmc_context.cs_context[i].config1);
915 gpmc_cs_write_reg(i, GPMC_CS_CONFIG2,
916 gpmc_context.cs_context[i].config2);
917 gpmc_cs_write_reg(i, GPMC_CS_CONFIG3,
918 gpmc_context.cs_context[i].config3);
919 gpmc_cs_write_reg(i, GPMC_CS_CONFIG4,
920 gpmc_context.cs_context[i].config4);
921 gpmc_cs_write_reg(i, GPMC_CS_CONFIG5,
922 gpmc_context.cs_context[i].config5);
923 gpmc_cs_write_reg(i, GPMC_CS_CONFIG6,
924 gpmc_context.cs_context[i].config6);
925 gpmc_cs_write_reg(i, GPMC_CS_CONFIG7,
926 gpmc_context.cs_context[i].config7);
927 }
928 }
929}
930#endif /* CONFIG_ARCH_OMAP3 */