13 #include <linux/string.h>
14 #include <linux/kernel.h>
26 #define ONENAND_IO_SIZE SZ_128K
30 static struct resource gpmc_onenand_resource = {
35 .name =
"omap2-onenand",
38 .resource = &gpmc_onenand_resource,
41 static int omap2_onenand_set_async_mode(
int cs,
void __iomem *onenand_base)
48 const int t_avdp = 12;
49 const int t_aavdh = 7;
75 t.cs_rd_off =
t.oe_off;
79 t.adv_wr_off =
t.adv_rd_off;
82 t.wr_data_mux_bus =
t.we_on;
106 static void set_onenand_cfg(
void __iomem *onenand_base,
int latency,
107 int sync_read,
int sync_write,
int hf,
int vhf)
135 void __iomem *onenand_base,
bool *clk_dep)
151 switch ((ver >> 4) & 0xf) {
180 const int t_cer = 15;
181 const int t_avdp = 12;
182 const int t_cez = 20;
184 const int t_wpl = 40;
185 const int t_wph = 30;
186 int min_gpmc_clk_period, t_ces, t_avds, t_avdh, t_ach, t_aavdh, t_rdyo;
187 int div, fclk_offset_ns, fclk_offset, gpmc_clk_ns,
latency;
188 int first_time = 0, hf = 0, vhf = 0, sync_read = 0, sync_write = 0;
190 int cs = cfg->
cs, freq = *freq_ptr;
192 bool clk_dep =
false;
200 return omap2_onenand_set_async_mode(cs, onenand_base);
204 err = omap2_onenand_set_async_mode(cs, onenand_base);
207 freq = omap2_onenand_get_freq(cfg, onenand_base, &clk_dep);
213 min_gpmc_clk_period = 9600;
222 min_gpmc_clk_period = 12000;
231 min_gpmc_clk_period = 15000;
240 min_gpmc_clk_period = 18500;
253 if (gpmc_clk_ns < 15)
255 if (gpmc_clk_ns < 12)
261 else if (gpmc_clk_ns >= 25)
267 if (gpmc_clk_ns < 12) {
270 }
else if (gpmc_clk_ns < 15) {
273 }
else if (gpmc_clk_ns < 25) {
283 set_onenand_cfg(onenand_base, latency,
284 sync_read, sync_write, hf, vhf);
312 t.sync_clk = min_gpmc_clk_period;
317 t.page_burst_access = gpmc_clk_ns;
323 if (
t.oe_on <=
t.adv_rd_off)
327 t.cs_rd_off =
t.oe_off;
334 t.adv_wr_off =
t.adv_rd_off;
336 t.we_off =
t.cs_rd_off;
337 t.cs_wr_off =
t.cs_rd_off;
338 t.wr_cycle =
t.rd_cycle;
343 t.wr_access =
t.access;
353 t.wr_data_mux_bus =
t.we_on;
378 set_onenand_cfg(onenand_base, latency, sync_read, sync_write, hf, vhf);
385 static int gpmc_onenand_setup(
void __iomem *onenand_base,
int *freq_ptr)
390 if (omap2_onenand_set_sync_mode(gpmc_onenand_data, onenand_base,
392 dev_err(dev,
"Unable to set synchronous mode\n");
403 gpmc_onenand_data = _onenand_data;
405 gpmc_onenand_device.
dev.platform_data = gpmc_onenand_data;
415 (
unsigned long *)&gpmc_onenand_resource.
start);
417 pr_err(
"%s: Cannot request GPMC CS\n", __func__);
421 gpmc_onenand_resource.
end = gpmc_onenand_resource.
start +
425 pr_err(
"%s: Unable to register OneNAND device\n", __func__);