blob: 7b76ce01c21dd3aa3b4cad36ce2431f3c8350900 [file] [log] [blame]
Juha Yrjolaaa62e902009-05-28 13:23:52 -07001/*
2 * linux/arch/arm/mach-omap2/gpmc-onenand.c
3 *
4 * Copyright (C) 2006 - 2009 Nokia Corporation
5 * Contacts: Juha Yrjola
6 * Tony Lindgren
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
Paul Gortmakerd44b28c2011-07-31 10:52:44 -040013#include <linux/string.h>
Juha Yrjolaaa62e902009-05-28 13:23:52 -070014#include <linux/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/mtd/onenand_regs.h>
17#include <linux/io.h>
Tony Lindgrene639cd52014-11-20 12:11:25 -080018#include <linux/omap-gpmc.h>
Arnd Bergmann22037472012-08-24 15:21:06 +020019#include <linux/platform_data/mtd-onenand-omap2.h>
Afzal Mohammed46376882012-06-05 10:11:48 +053020#include <linux/err.h>
Juha Yrjolaaa62e902009-05-28 13:23:52 -070021
22#include <asm/mach/flash.h>
23
Tony Lindgrendbc04162012-08-31 10:59:07 -070024#include "soc.h"
25
Afzal Mohammed681988b2012-08-30 12:53:23 -070026#define ONENAND_IO_SIZE SZ_128K
27
Afzal Mohammed46376882012-06-05 10:11:48 +053028#define ONENAND_FLAG_SYNCREAD (1 << 0)
29#define ONENAND_FLAG_SYNCWRITE (1 << 1)
30#define ONENAND_FLAG_HF (1 << 2)
31#define ONENAND_FLAG_VHF (1 << 3)
32
33static unsigned onenand_flags;
34static unsigned latency;
Afzal Mohammed46376882012-06-05 10:11:48 +053035
Juha Yrjolaaa62e902009-05-28 13:23:52 -070036static struct omap_onenand_platform_data *gpmc_onenand_data;
37
Afzal Mohammed681988b2012-08-30 12:53:23 -070038static struct resource gpmc_onenand_resource = {
39 .flags = IORESOURCE_MEM,
40};
41
Juha Yrjolaaa62e902009-05-28 13:23:52 -070042static struct platform_device gpmc_onenand_device = {
43 .name = "omap2-onenand",
44 .id = -1,
Afzal Mohammed681988b2012-08-30 12:53:23 -070045 .num_resources = 1,
46 .resource = &gpmc_onenand_resource,
Juha Yrjolaaa62e902009-05-28 13:23:52 -070047};
48
Jon Hunterc3be5b42013-02-21 13:46:22 -060049static struct gpmc_settings onenand_async = {
Jon Hunter3aef65e2013-02-21 12:42:22 -060050 .device_width = GPMC_DEVWIDTH_16BIT,
Jon Hunterc3be5b42013-02-21 13:46:22 -060051 .mux_add_data = GPMC_MUX_AD,
52};
53
54static struct gpmc_settings onenand_sync = {
55 .burst_read = true,
Jon Hunter3aef65e2013-02-21 12:42:22 -060056 .burst_wrap = true,
57 .burst_len = GPMC_BURST_16,
58 .device_width = GPMC_DEVWIDTH_16BIT,
Jon Hunterc3be5b42013-02-21 13:46:22 -060059 .mux_add_data = GPMC_MUX_AD,
Jon Hunter3aef65e2013-02-21 12:42:22 -060060 .wait_pin = 0,
Jon Hunterc3be5b42013-02-21 13:46:22 -060061};
62
Jon Hunterbe9f10c2013-02-21 15:20:53 -060063static void omap2_onenand_calc_async_timings(struct gpmc_timings *t)
Juha Yrjolaaa62e902009-05-28 13:23:52 -070064{
Afzal Mohammed4f4426f2012-11-09 18:05:17 +053065 struct gpmc_device_timings dev_t;
Juha Yrjolaaa62e902009-05-28 13:23:52 -070066 const int t_cer = 15;
67 const int t_avdp = 12;
68 const int t_aavdh = 7;
69 const int t_ce = 76;
70 const int t_aa = 76;
71 const int t_oe = 20;
72 const int t_cez = 20; /* max of t_cez, t_oez */
Juha Yrjolaaa62e902009-05-28 13:23:52 -070073 const int t_wpl = 40;
74 const int t_wph = 30;
75
Afzal Mohammed4f4426f2012-11-09 18:05:17 +053076 memset(&dev_t, 0, sizeof(dev_t));
Juha Yrjolaaa62e902009-05-28 13:23:52 -070077
Afzal Mohammed4f4426f2012-11-09 18:05:17 +053078 dev_t.t_avdp_r = max_t(int, t_avdp, t_cer) * 1000;
79 dev_t.t_avdp_w = dev_t.t_avdp_r;
80 dev_t.t_aavdh = t_aavdh * 1000;
81 dev_t.t_aa = t_aa * 1000;
82 dev_t.t_ce = t_ce * 1000;
83 dev_t.t_oe = t_oe * 1000;
84 dev_t.t_cez_r = t_cez * 1000;
85 dev_t.t_cez_w = dev_t.t_cez_r;
86 dev_t.t_wpl = t_wpl * 1000;
87 dev_t.t_wph = t_wph * 1000;
Juha Yrjolaaa62e902009-05-28 13:23:52 -070088
Jon Hunterc3be5b42013-02-21 13:46:22 -060089 gpmc_calc_timings(t, &onenand_async, &dev_t);
Afzal Mohammed46376882012-06-05 10:11:48 +053090}
91
Afzal Mohammed46376882012-06-05 10:11:48 +053092static void omap2_onenand_set_async_mode(void __iomem *onenand_base)
93{
94 u32 reg;
Adrian Hunter6d453e82009-06-23 13:30:24 +030095
96 /* Ensure sync read and sync write are disabled */
97 reg = readw(onenand_base + ONENAND_REG_SYS_CFG1);
98 reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE;
99 writew(reg, onenand_base + ONENAND_REG_SYS_CFG1);
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700100}
101
Afzal Mohammed46376882012-06-05 10:11:48 +0530102static void set_onenand_cfg(void __iomem *onenand_base)
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700103{
104 u32 reg;
105
106 reg = readw(onenand_base + ONENAND_REG_SYS_CFG1);
107 reg &= ~((0x7 << ONENAND_SYS_CFG1_BRL_SHIFT) | (0x7 << 9));
108 reg |= (latency << ONENAND_SYS_CFG1_BRL_SHIFT) |
109 ONENAND_SYS_CFG1_BL_16;
Afzal Mohammed46376882012-06-05 10:11:48 +0530110 if (onenand_flags & ONENAND_FLAG_SYNCREAD)
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700111 reg |= ONENAND_SYS_CFG1_SYNC_READ;
112 else
113 reg &= ~ONENAND_SYS_CFG1_SYNC_READ;
Afzal Mohammed46376882012-06-05 10:11:48 +0530114 if (onenand_flags & ONENAND_FLAG_SYNCWRITE)
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700115 reg |= ONENAND_SYS_CFG1_SYNC_WRITE;
116 else
117 reg &= ~ONENAND_SYS_CFG1_SYNC_WRITE;
Afzal Mohammed46376882012-06-05 10:11:48 +0530118 if (onenand_flags & ONENAND_FLAG_HF)
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700119 reg |= ONENAND_SYS_CFG1_HF;
120 else
121 reg &= ~ONENAND_SYS_CFG1_HF;
Afzal Mohammed46376882012-06-05 10:11:48 +0530122 if (onenand_flags & ONENAND_FLAG_VHF)
Adrian Hunter1435ca02011-02-07 10:46:58 +0200123 reg |= ONENAND_SYS_CFG1_VHF;
124 else
125 reg &= ~ONENAND_SYS_CFG1_VHF;
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700126 writew(reg, onenand_base + ONENAND_REG_SYS_CFG1);
127}
128
Adrian Hunter5714b7e2011-02-07 10:47:00 +0200129static int omap2_onenand_get_freq(struct omap_onenand_platform_data *cfg,
Jon Hunter757ef792012-06-28 13:41:29 -0500130 void __iomem *onenand_base)
Adrian Hunter5714b7e2011-02-07 10:47:00 +0200131{
132 u16 ver = readw(onenand_base + ONENAND_REG_VERSION_ID);
Jon Hunter757ef792012-06-28 13:41:29 -0500133 int freq;
Adrian Hunter5714b7e2011-02-07 10:47:00 +0200134
135 switch ((ver >> 4) & 0xf) {
136 case 0:
137 freq = 40;
138 break;
139 case 1:
140 freq = 54;
141 break;
142 case 2:
143 freq = 66;
144 break;
145 case 3:
146 freq = 83;
147 break;
148 case 4:
149 freq = 104;
150 break;
151 default:
Tony Lindgrene7b11dc2016-01-05 12:04:20 -0800152 pr_err("onenand rate not detected, bad GPMC async timings?\n");
153 freq = 0;
Adrian Hunter5714b7e2011-02-07 10:47:00 +0200154 }
155
156 return freq;
157}
158
Jon Hunterbe9f10c2013-02-21 15:20:53 -0600159static void omap2_onenand_calc_sync_timings(struct gpmc_timings *t,
160 unsigned int flags,
161 int freq)
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700162{
Afzal Mohammed4f4426f2012-11-09 18:05:17 +0530163 struct gpmc_device_timings dev_t;
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700164 const int t_cer = 15;
165 const int t_avdp = 12;
166 const int t_cez = 20; /* max of t_cez, t_oez */
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700167 const int t_wpl = 40;
168 const int t_wph = 30;
169 int min_gpmc_clk_period, t_ces, t_avds, t_avdh, t_ach, t_aavdh, t_rdyo;
Afzal Mohammed4f4426f2012-11-09 18:05:17 +0530170 int div, gpmc_clk_ns;
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700171
Jon Hunterbe9f10c2013-02-21 15:20:53 -0600172 if (flags & ONENAND_SYNC_READ)
Afzal Mohammed46376882012-06-05 10:11:48 +0530173 onenand_flags = ONENAND_FLAG_SYNCREAD;
Jon Hunterbe9f10c2013-02-21 15:20:53 -0600174 else if (flags & ONENAND_SYNC_READWRITE)
Afzal Mohammed46376882012-06-05 10:11:48 +0530175 onenand_flags = ONENAND_FLAG_SYNCREAD | ONENAND_FLAG_SYNCWRITE;
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700176
177 switch (freq) {
Adrian Hunter49314452010-12-09 11:22:50 +0200178 case 104:
179 min_gpmc_clk_period = 9600; /* 104 MHz */
180 t_ces = 3;
181 t_avds = 4;
182 t_avdh = 2;
183 t_ach = 3;
184 t_aavdh = 6;
Adrian Hunter1435ca02011-02-07 10:46:58 +0200185 t_rdyo = 6;
Adrian Hunter49314452010-12-09 11:22:50 +0200186 break;
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700187 case 83:
Adrian Huntera3551f52010-12-09 10:48:27 +0200188 min_gpmc_clk_period = 12000; /* 83 MHz */
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700189 t_ces = 5;
190 t_avds = 4;
191 t_avdh = 2;
192 t_ach = 6;
193 t_aavdh = 6;
194 t_rdyo = 9;
195 break;
196 case 66:
Adrian Huntera3551f52010-12-09 10:48:27 +0200197 min_gpmc_clk_period = 15000; /* 66 MHz */
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700198 t_ces = 6;
199 t_avds = 5;
200 t_avdh = 2;
201 t_ach = 6;
202 t_aavdh = 6;
203 t_rdyo = 11;
204 break;
205 default:
Adrian Huntera3551f52010-12-09 10:48:27 +0200206 min_gpmc_clk_period = 18500; /* 54 MHz */
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700207 t_ces = 7;
208 t_avds = 7;
209 t_avdh = 7;
210 t_ach = 9;
211 t_aavdh = 7;
212 t_rdyo = 15;
Afzal Mohammed46376882012-06-05 10:11:48 +0530213 onenand_flags &= ~ONENAND_FLAG_SYNCWRITE;
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700214 break;
215 }
216
Afzal Mohammed1b47ca12012-08-19 18:29:45 +0530217 div = gpmc_calc_divider(min_gpmc_clk_period);
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700218 gpmc_clk_ns = gpmc_ticks_to_ns(div);
Russell King6a53bc72015-05-14 16:18:46 +0100219 if (gpmc_clk_ns < 15) /* >66MHz */
Afzal Mohammed46376882012-06-05 10:11:48 +0530220 onenand_flags |= ONENAND_FLAG_HF;
221 else
222 onenand_flags &= ~ONENAND_FLAG_HF;
Russell King6a53bc72015-05-14 16:18:46 +0100223 if (gpmc_clk_ns < 12) /* >83MHz */
Afzal Mohammed46376882012-06-05 10:11:48 +0530224 onenand_flags |= ONENAND_FLAG_VHF;
225 else
226 onenand_flags &= ~ONENAND_FLAG_VHF;
227 if (onenand_flags & ONENAND_FLAG_VHF)
Adrian Hunter1435ca02011-02-07 10:46:58 +0200228 latency = 8;
Afzal Mohammed46376882012-06-05 10:11:48 +0530229 else if (onenand_flags & ONENAND_FLAG_HF)
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700230 latency = 6;
231 else if (gpmc_clk_ns >= 25) /* 40 MHz*/
232 latency = 3;
233 else
234 latency = 4;
235
Afzal Mohammed46376882012-06-05 10:11:48 +0530236 /* Set synchronous read timings */
Afzal Mohammed4f4426f2012-11-09 18:05:17 +0530237 memset(&dev_t, 0, sizeof(dev_t));
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700238
Jon Hunter3aef65e2013-02-21 12:42:22 -0600239 if (onenand_flags & ONENAND_FLAG_SYNCREAD)
240 onenand_sync.sync_read = true;
Afzal Mohammed46376882012-06-05 10:11:48 +0530241 if (onenand_flags & ONENAND_FLAG_SYNCWRITE) {
Jon Hunterc3be5b42013-02-21 13:46:22 -0600242 onenand_sync.sync_write = true;
Jon Hunter3aef65e2013-02-21 12:42:22 -0600243 onenand_sync.burst_write = true;
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700244 } else {
Afzal Mohammed4f4426f2012-11-09 18:05:17 +0530245 dev_t.t_avdp_w = max(t_avdp, t_cer) * 1000;
246 dev_t.t_wpl = t_wpl * 1000;
247 dev_t.t_wph = t_wph * 1000;
248 dev_t.t_aavdh = t_aavdh * 1000;
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700249 }
Afzal Mohammed4f4426f2012-11-09 18:05:17 +0530250 dev_t.ce_xdelay = true;
251 dev_t.avd_xdelay = true;
252 dev_t.oe_xdelay = true;
253 dev_t.we_xdelay = true;
254 dev_t.clk = min_gpmc_clk_period;
255 dev_t.t_bacc = dev_t.clk;
256 dev_t.t_ces = t_ces * 1000;
257 dev_t.t_avds = t_avds * 1000;
258 dev_t.t_avdh = t_avdh * 1000;
259 dev_t.t_ach = t_ach * 1000;
260 dev_t.cyc_iaa = (latency + 1);
261 dev_t.t_cez_r = t_cez * 1000;
262 dev_t.t_cez_w = dev_t.t_cez_r;
263 dev_t.cyc_aavdh_oe = 1;
264 dev_t.t_rdyo = t_rdyo * 1000 + min_gpmc_clk_period;
265
Jon Hunterc3be5b42013-02-21 13:46:22 -0600266 gpmc_calc_timings(t, &onenand_sync, &dev_t);
Afzal Mohammed46376882012-06-05 10:11:48 +0530267}
268
Afzal Mohammed46376882012-06-05 10:11:48 +0530269static int omap2_onenand_setup_async(void __iomem *onenand_base)
270{
271 struct gpmc_timings t;
272 int ret;
273
Tony Lindgrene7b11dc2016-01-05 12:04:20 -0800274 /*
275 * Note that we need to keep sync_write set for the call to
276 * omap2_onenand_set_async_mode() to work to detect the onenand
277 * supported clock rate for the sync timings.
278 */
Aaro Koskinen1dc1c332013-09-20 23:01:06 +0300279 if (gpmc_onenand_data->of_node) {
Jon Hunter32cde0b2013-02-25 11:37:58 -0600280 gpmc_read_settings_dt(gpmc_onenand_data->of_node,
281 &onenand_async);
Aaro Koskinen1dc1c332013-09-20 23:01:06 +0300282 if (onenand_async.sync_read || onenand_async.sync_write) {
283 if (onenand_async.sync_write)
284 gpmc_onenand_data->flags |=
285 ONENAND_SYNC_READWRITE;
286 else
287 gpmc_onenand_data->flags |= ONENAND_SYNC_READ;
288 onenand_async.sync_read = false;
Aaro Koskinen1dc1c332013-09-20 23:01:06 +0300289 }
290 }
Jon Hunter32cde0b2013-02-25 11:37:58 -0600291
Jon Hunterbe9f10c2013-02-21 15:20:53 -0600292 omap2_onenand_calc_async_timings(&t);
Afzal Mohammed46376882012-06-05 10:11:48 +0530293
Jon Hunter3aef65e2013-02-21 12:42:22 -0600294 ret = gpmc_cs_program_settings(gpmc_onenand_data->cs, &onenand_async);
295 if (ret < 0)
296 return ret;
297
Robert ABEL2e676902015-02-27 16:56:53 +0100298 ret = gpmc_cs_set_timings(gpmc_onenand_data->cs, &t, &onenand_async);
Russell King71856842013-03-13 20:44:21 +0000299 if (ret < 0)
Afzal Mohammed46376882012-06-05 10:11:48 +0530300 return ret;
301
302 omap2_onenand_set_async_mode(onenand_base);
303
304 return 0;
305}
306
307static int omap2_onenand_setup_sync(void __iomem *onenand_base, int *freq_ptr)
308{
309 int ret, freq = *freq_ptr;
310 struct gpmc_timings t;
Afzal Mohammed46376882012-06-05 10:11:48 +0530311
312 if (!freq) {
313 /* Very first call freq is not known */
Jon Hunter757ef792012-06-28 13:41:29 -0500314 freq = omap2_onenand_get_freq(gpmc_onenand_data, onenand_base);
Tony Lindgrene7b11dc2016-01-05 12:04:20 -0800315 if (!freq)
316 return -ENODEV;
Afzal Mohammed46376882012-06-05 10:11:48 +0530317 set_onenand_cfg(onenand_base);
318 }
319
Jon Hunter32cde0b2013-02-25 11:37:58 -0600320 if (gpmc_onenand_data->of_node) {
321 gpmc_read_settings_dt(gpmc_onenand_data->of_node,
322 &onenand_sync);
323 } else {
324 /*
325 * FIXME: Appears to be legacy code from initial ONENAND commit.
326 * Unclear what boards this is for and if this can be removed.
327 */
328 if (!cpu_is_omap34xx())
329 onenand_sync.wait_on_read = true;
330 }
Jon Hunter3aef65e2013-02-21 12:42:22 -0600331
Jon Hunterbe9f10c2013-02-21 15:20:53 -0600332 omap2_onenand_calc_sync_timings(&t, gpmc_onenand_data->flags, freq);
Afzal Mohammed46376882012-06-05 10:11:48 +0530333
Jon Hunter3aef65e2013-02-21 12:42:22 -0600334 ret = gpmc_cs_program_settings(gpmc_onenand_data->cs, &onenand_sync);
335 if (ret < 0)
336 return ret;
337
Robert ABEL2e676902015-02-27 16:56:53 +0100338 ret = gpmc_cs_set_timings(gpmc_onenand_data->cs, &t, &onenand_sync);
Russell King71856842013-03-13 20:44:21 +0000339 if (ret < 0)
Afzal Mohammed46376882012-06-05 10:11:48 +0530340 return ret;
341
342 set_onenand_cfg(onenand_base);
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700343
Adrian Hunter3ad2d862011-02-07 10:46:59 +0200344 *freq_ptr = freq;
345
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700346 return 0;
347}
348
Adrian Hunter3ad2d862011-02-07 10:46:59 +0200349static int gpmc_onenand_setup(void __iomem *onenand_base, int *freq_ptr)
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700350{
351 struct device *dev = &gpmc_onenand_device.dev;
Afzal Mohammed46376882012-06-05 10:11:48 +0530352 unsigned l = ONENAND_SYNC_READ | ONENAND_SYNC_READWRITE;
353 int ret;
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700354
Afzal Mohammed46376882012-06-05 10:11:48 +0530355 ret = omap2_onenand_setup_async(onenand_base);
356 if (ret) {
357 dev_err(dev, "unable to set to async mode\n");
358 return ret;
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700359 }
360
Afzal Mohammed46376882012-06-05 10:11:48 +0530361 if (!(gpmc_onenand_data->flags & l))
362 return 0;
363
364 ret = omap2_onenand_setup_sync(onenand_base, freq_ptr);
365 if (ret)
366 dev_err(dev, "unable to set to sync mode\n");
367 return ret;
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700368}
369
Ezequiel Garciafaf5d2f2013-01-25 09:23:10 -0300370void gpmc_onenand_init(struct omap_onenand_platform_data *_onenand_data)
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700371{
Afzal Mohammed681988b2012-08-30 12:53:23 -0700372 int err;
Ezequiel Garciadf25cb42013-02-12 16:22:22 -0300373 struct device *dev = &gpmc_onenand_device.dev;
Afzal Mohammed681988b2012-08-30 12:53:23 -0700374
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700375 gpmc_onenand_data = _onenand_data;
376 gpmc_onenand_data->onenand_setup = gpmc_onenand_setup;
377 gpmc_onenand_device.dev.platform_data = gpmc_onenand_data;
378
379 if (cpu_is_omap24xx() &&
380 (gpmc_onenand_data->flags & ONENAND_SYNC_READWRITE)) {
Ezequiel Garcia7ab91592013-02-12 16:22:23 -0300381 dev_warn(dev, "OneNAND using only SYNC_READ on 24xx\n");
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700382 gpmc_onenand_data->flags &= ~ONENAND_SYNC_READWRITE;
383 gpmc_onenand_data->flags |= ONENAND_SYNC_READ;
384 }
385
Afzal Mohammedeb77b6a2012-10-05 11:39:54 +0530386 if (cpu_is_omap34xx())
387 gpmc_onenand_data->flags |= ONENAND_IN_OMAP34XX;
388 else
389 gpmc_onenand_data->flags &= ~ONENAND_IN_OMAP34XX;
390
Afzal Mohammed681988b2012-08-30 12:53:23 -0700391 err = gpmc_cs_request(gpmc_onenand_data->cs, ONENAND_IO_SIZE,
392 (unsigned long *)&gpmc_onenand_resource.start);
393 if (err < 0) {
Ezequiel Garciadf25cb42013-02-12 16:22:22 -0300394 dev_err(dev, "Cannot request GPMC CS %d, error %d\n",
395 gpmc_onenand_data->cs, err);
Afzal Mohammed681988b2012-08-30 12:53:23 -0700396 return;
397 }
398
399 gpmc_onenand_resource.end = gpmc_onenand_resource.start +
400 ONENAND_IO_SIZE - 1;
401
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700402 if (platform_device_register(&gpmc_onenand_device) < 0) {
Ezequiel Garciadf25cb42013-02-12 16:22:22 -0300403 dev_err(dev, "Unable to register OneNAND device\n");
Afzal Mohammed681988b2012-08-30 12:53:23 -0700404 gpmc_cs_free(gpmc_onenand_data->cs);
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700405 return;
406 }
407}