11 #include <linux/string.h>
12 #include <linux/types.h>
13 #include <linux/errno.h>
17 #include <linux/export.h>
25 static u8 async_cs, sync_cs;
26 static unsigned refclk_psec;
35 next_clk(
unsigned t1_NS,
unsigned t2_ps,
unsigned fclk_ps)
37 unsigned t1_ps = t1_NS * 1000;
40 if ((t1_ps + fclk_ps) < t2_ps)
43 t1_f = (t1_ps + fclk_ps - 1) / fclk_ps;
44 t2_f = (t2_ps + fclk_ps - 1) / fclk_ps;
49 return (t2_f * fclk_ps) / 1000;
54 static int tusb_set_async_mode(
unsigned sysclk_ps,
unsigned fclk_ps)
57 unsigned t_acsnh_advnh = sysclk_ps + 3000;
65 t.adv_on = next_clk(
t.cs_on, t_acsnh_advnh - 7000, fclk_ps);
72 t.adv_rd_off = next_clk(
t.adv_on, t_acsnh_advnh, fclk_ps);
75 t.oe_on = next_clk(
t.adv_on, t_acsnh_advnh + 1000, fclk_ps);
78 tmp =
t.oe_on * 1000 + 300;
79 t.access = next_clk(
t.oe_on, tmp, fclk_ps);
82 tmp =
t.access * 1000;
83 t.oe_off = next_clk(
t.access, tmp, fclk_ps);
85 t.cs_rd_off =
t.oe_off;
87 tmp =
t.cs_rd_off * 1000 + 7000 ;
88 t.rd_cycle = next_clk(
t.cs_rd_off, tmp, fclk_ps);
95 t.adv_wr_off =
t.adv_rd_off;
98 t.we_on = next_clk(
t.adv_wr_off, t_acsnh_advnh + 1000, fclk_ps);
101 tmp =
t.we_on * 1000 + 300;
102 t.we_off = next_clk(
t.we_on, tmp, fclk_ps);
104 t.cs_wr_off =
t.we_off;
106 tmp =
t.cs_wr_off * 1000 + 7000 ;
107 t.wr_cycle = next_clk(
t.cs_wr_off, tmp, fclk_ps);
112 static int tusb_set_sync_mode(
unsigned sysclk_ps,
unsigned fclk_ps)
115 unsigned t_scsnh_advnh = sysclk_ps + 3000;
122 t.adv_on = next_clk(
t.cs_on, t_scsnh_advnh - 7000, fclk_ps);
126 tmp = (
t.sync_clk + fclk_ps - 1) / fclk_ps;
131 t.page_burst_access = (fclk_ps *
tmp) / 1000;
138 t.adv_rd_off = next_clk(
t.adv_on, t_scsnh_advnh, fclk_ps);
141 tmp = (
t.adv_rd_off * 1000) + (3 * fclk_ps);
142 t.oe_on = next_clk(
t.adv_on, tmp, fclk_ps);
145 tmp = (
t.oe_on * 1000) + (5 * fclk_ps);
146 t.access = next_clk(
t.oe_on, tmp, fclk_ps);
149 tmp = (
t.access * 1000) + (1 * fclk_ps);
150 t.oe_off = next_clk(
t.access, tmp, fclk_ps);
152 t.cs_rd_off =
t.oe_off;
154 tmp =
t.cs_rd_off * 1000 + 7000 ;
155 t.rd_cycle = next_clk(
t.cs_rd_off, tmp, fclk_ps);
162 t.adv_wr_off =
t.adv_rd_off;
165 tmp = (
t.adv_wr_off * 1000) + (3 * fclk_ps);
166 t.we_on = next_clk(
t.adv_wr_off, tmp, fclk_ps);
169 tmp = (
t.we_on * 1000) + (6 * fclk_ps);
170 t.we_off = next_clk(
t.we_on, tmp, fclk_ps);
172 t.cs_wr_off =
t.we_off;
174 tmp =
t.cs_wr_off * 1000 + 7000 ;
175 t.wr_cycle = next_clk(
t.cs_wr_off, tmp, fclk_ps);
185 static const char error[] =
186 KERN_ERR "tusb6010 %s retime error %d\n";
192 if (!refclk_psec || fclk_ps == 0)
197 status = tusb_set_async_mode(sysclk_ps, fclk_ps);
199 printk(error,
"async", status);
202 status = tusb_set_sync_mode(sysclk_ps, fclk_ps);
204 printk(error,
"sync", status);
210 static struct resource tusb_resources[] = {
226 static u64 tusb_dmamask = ~(
u32)0;
232 .dma_mask = &tusb_dmamask,
233 .coherent_dma_mask = 0xffffffff,
236 .resource = tusb_resources,
243 unsigned ps_refclk,
unsigned waitpin,
245 unsigned irq,
unsigned dmachan)
249 KERN_ERR "tusb6010 init error %d, %d\n";
253 &tusb_resources[0].
start);
258 tusb_resources[0].
end = tusb_resources[0].
start + 0x9ff;
274 &tusb_resources[1].start);
279 tusb_resources[1].
end = tusb_resources[1].
start + 0x9ff;
310 refclk_psec = ps_refclk;
322 tusb_device.
dev.platform_data =
data;
326 tusb_device.
dev.dma_mask =
NULL;
329 if (dmachan & (1 << 0))
330 omap_mux_init_signal(
"sys_ndmareq0", 0);
331 if (dmachan & (1 << 1))
332 omap_mux_init_signal(
"sys_ndmareq1", 0);
333 if (dmachan & (1 << 2))
334 omap_mux_init_signal(
"sys_ndmareq2", 0);
335 if (dmachan & (1 << 3))
336 omap_mux_init_signal(
"sys_ndmareq3", 0);
337 if (dmachan & (1 << 4))
338 omap_mux_init_signal(
"sys_ndmareq4", 0);
339 if (dmachan & (1 << 5))
340 omap_mux_init_signal(
"sys_ndmareq5", 0);