aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Hunter <jon-hunter@ti.com>2013-02-21 16:20:53 -0500
committerJon Hunter <jon-hunter@ti.com>2013-04-01 15:53:40 -0400
commitbe9f10c04fb13d32fc30d599c1971a10916a2209 (patch)
tree8ca8daaa1e79c3f04cc930ad589b4d50fff29226
parentf5d8edaf1d06e922a3c3d75c52ef5628ceec32c4 (diff)
ARM: OMAP2+: Simplify code configuring ONENAND devices
The OMAP2+ code that configures the GPMC for ONENAND devices is copying structures between functions unnecessarily. Avoid this by passing pointers instead and simplify the code. A pointer to structure "omap_onenand_platform_data" is passed to the function omap2_onenand_calc_sync_timings(), but only the flags member of the structure is used. Simplify the code by only passing the flags member and not the entire structure. Signed-off-by: Jon Hunter <jon-hunter@ti.com> Tested-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
-rw-r--r--arch/arm/mach-omap2/gpmc-onenand.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/arch/arm/mach-omap2/gpmc-onenand.c b/arch/arm/mach-omap2/gpmc-onenand.c
index 4c917522d248..db52c4b28f8b 100644
--- a/arch/arm/mach-omap2/gpmc-onenand.c
+++ b/arch/arm/mach-omap2/gpmc-onenand.c
@@ -47,10 +47,9 @@ static struct platform_device gpmc_onenand_device = {
47 .resource = &gpmc_onenand_resource, 47 .resource = &gpmc_onenand_resource,
48}; 48};
49 49
50static struct gpmc_timings omap2_onenand_calc_async_timings(void) 50static void omap2_onenand_calc_async_timings(struct gpmc_timings *t)
51{ 51{
52 struct gpmc_device_timings dev_t; 52 struct gpmc_device_timings dev_t;
53 struct gpmc_timings t;
54 53
55 const int t_cer = 15; 54 const int t_cer = 15;
56 const int t_avdp = 12; 55 const int t_avdp = 12;
@@ -76,9 +75,7 @@ static struct gpmc_timings omap2_onenand_calc_async_timings(void)
76 dev_t.t_wpl = t_wpl * 1000; 75 dev_t.t_wpl = t_wpl * 1000;
77 dev_t.t_wph = t_wph * 1000; 76 dev_t.t_wph = t_wph * 1000;
78 77
79 gpmc_calc_timings(&t, &dev_t); 78 gpmc_calc_timings(t, &dev_t);
80
81 return t;
82} 79}
83 80
84static int gpmc_set_async_mode(int cs, struct gpmc_timings *t) 81static int gpmc_set_async_mode(int cs, struct gpmc_timings *t)
@@ -158,12 +155,11 @@ static int omap2_onenand_get_freq(struct omap_onenand_platform_data *cfg,
158 return freq; 155 return freq;
159} 156}
160 157
161static struct gpmc_timings 158static void omap2_onenand_calc_sync_timings(struct gpmc_timings *t,
162omap2_onenand_calc_sync_timings(struct omap_onenand_platform_data *cfg, 159 unsigned int flags,
163 int freq) 160 int freq)
164{ 161{
165 struct gpmc_device_timings dev_t; 162 struct gpmc_device_timings dev_t;
166 struct gpmc_timings t;
167 const int t_cer = 15; 163 const int t_cer = 15;
168 const int t_avdp = 12; 164 const int t_avdp = 12;
169 const int t_cez = 20; /* max of t_cez, t_oez */ 165 const int t_cez = 20; /* max of t_cez, t_oez */
@@ -172,9 +168,9 @@ omap2_onenand_calc_sync_timings(struct omap_onenand_platform_data *cfg,
172 int min_gpmc_clk_period, t_ces, t_avds, t_avdh, t_ach, t_aavdh, t_rdyo; 168 int min_gpmc_clk_period, t_ces, t_avds, t_avdh, t_ach, t_aavdh, t_rdyo;
173 int div, gpmc_clk_ns; 169 int div, gpmc_clk_ns;
174 170
175 if (cfg->flags & ONENAND_SYNC_READ) 171 if (flags & ONENAND_SYNC_READ)
176 onenand_flags = ONENAND_FLAG_SYNCREAD; 172 onenand_flags = ONENAND_FLAG_SYNCREAD;
177 else if (cfg->flags & ONENAND_SYNC_READWRITE) 173 else if (flags & ONENAND_SYNC_READWRITE)
178 onenand_flags = ONENAND_FLAG_SYNCREAD | ONENAND_FLAG_SYNCWRITE; 174 onenand_flags = ONENAND_FLAG_SYNCREAD | ONENAND_FLAG_SYNCWRITE;
179 175
180 switch (freq) { 176 switch (freq) {
@@ -265,9 +261,7 @@ omap2_onenand_calc_sync_timings(struct omap_onenand_platform_data *cfg,
265 dev_t.cyc_aavdh_oe = 1; 261 dev_t.cyc_aavdh_oe = 1;
266 dev_t.t_rdyo = t_rdyo * 1000 + min_gpmc_clk_period; 262 dev_t.t_rdyo = t_rdyo * 1000 + min_gpmc_clk_period;
267 263
268 gpmc_calc_timings(&t, &dev_t); 264 gpmc_calc_timings(t, &dev_t);
269
270 return t;
271} 265}
272 266
273static int gpmc_set_sync_mode(int cs, struct gpmc_timings *t) 267static int gpmc_set_sync_mode(int cs, struct gpmc_timings *t)
@@ -300,7 +294,7 @@ static int omap2_onenand_setup_async(void __iomem *onenand_base)
300 294
301 omap2_onenand_set_async_mode(onenand_base); 295 omap2_onenand_set_async_mode(onenand_base);
302 296
303 t = omap2_onenand_calc_async_timings(); 297 omap2_onenand_calc_async_timings(&t);
304 298
305 ret = gpmc_set_async_mode(gpmc_onenand_data->cs, &t); 299 ret = gpmc_set_async_mode(gpmc_onenand_data->cs, &t);
306 if (ret < 0) 300 if (ret < 0)
@@ -322,7 +316,7 @@ static int omap2_onenand_setup_sync(void __iomem *onenand_base, int *freq_ptr)
322 set_onenand_cfg(onenand_base); 316 set_onenand_cfg(onenand_base);
323 } 317 }
324 318
325 t = omap2_onenand_calc_sync_timings(gpmc_onenand_data, freq); 319 omap2_onenand_calc_sync_timings(&t, gpmc_onenand_data->flags, freq);
326 320
327 ret = gpmc_set_sync_mode(gpmc_onenand_data->cs, &t); 321 ret = gpmc_set_sync_mode(gpmc_onenand_data->cs, &t);
328 if (ret < 0) 322 if (ret < 0)