aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@nokia.com>2010-12-09 03:48:27 -0500
committerTony Lindgren <tony@atomide.com>2010-12-21 15:05:25 -0500
commita3551f5b0c3ca7aaa053e554e3ee766983b5d713 (patch)
tree76fec6e7169219e26c67ff206713b2d09771e33b /arch/arm
parent4584acc3ee236424b5d0b52f143d980cae3c2be5 (diff)
OMAP2/3: GPMC: put sync_clk value in picoseconds instead of nanoseconds
The calculations done with sync_clk are anyway in picoseconds and switching to picoseconds allows sync_clk values that are not a whole number of nanoseconds - which is sometimes the case. Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-omap2/gpmc-nand.c2
-rw-r--r--arch/arm/mach-omap2/gpmc-onenand.c10
-rw-r--r--arch/arm/mach-omap2/gpmc.c12
-rw-r--r--arch/arm/mach-omap2/usb-tusb6010.c4
-rw-r--r--arch/arm/plat-omap/include/plat/gpmc.h9
5 files changed, 24 insertions, 13 deletions
diff --git a/arch/arm/mach-omap2/gpmc-nand.c b/arch/arm/mach-omap2/gpmc-nand.c
index 722209601927..2bb29c160702 100644
--- a/arch/arm/mach-omap2/gpmc-nand.c
+++ b/arch/arm/mach-omap2/gpmc-nand.c
@@ -41,7 +41,7 @@ static int omap2_nand_gpmc_retime(void)
41 return 0; 41 return 0;
42 42
43 memset(&t, 0, sizeof(t)); 43 memset(&t, 0, sizeof(t));
44 t.sync_clk = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->sync_clk); 44 t.sync_clk = gpmc_nand_data->gpmc_t->sync_clk;
45 t.cs_on = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->cs_on); 45 t.cs_on = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->cs_on);
46 t.adv_on = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->adv_on); 46 t.adv_on = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->adv_on);
47 47
diff --git a/arch/arm/mach-omap2/gpmc-onenand.c b/arch/arm/mach-omap2/gpmc-onenand.c
index 7bb69220adfa..1db606ca007e 100644
--- a/arch/arm/mach-omap2/gpmc-onenand.c
+++ b/arch/arm/mach-omap2/gpmc-onenand.c
@@ -174,7 +174,7 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg,
174 174
175 switch (freq) { 175 switch (freq) {
176 case 83: 176 case 83:
177 min_gpmc_clk_period = 12; /* 83 MHz */ 177 min_gpmc_clk_period = 12000; /* 83 MHz */
178 t_ces = 5; 178 t_ces = 5;
179 t_avds = 4; 179 t_avds = 4;
180 t_avdh = 2; 180 t_avdh = 2;
@@ -183,7 +183,7 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg,
183 t_rdyo = 9; 183 t_rdyo = 9;
184 break; 184 break;
185 case 66: 185 case 66:
186 min_gpmc_clk_period = 15; /* 66 MHz */ 186 min_gpmc_clk_period = 15000; /* 66 MHz */
187 t_ces = 6; 187 t_ces = 6;
188 t_avds = 5; 188 t_avds = 5;
189 t_avdh = 2; 189 t_avdh = 2;
@@ -192,7 +192,7 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg,
192 t_rdyo = 11; 192 t_rdyo = 11;
193 break; 193 break;
194 default: 194 default:
195 min_gpmc_clk_period = 18; /* 54 MHz */ 195 min_gpmc_clk_period = 18500; /* 54 MHz */
196 t_ces = 7; 196 t_ces = 7;
197 t_avds = 7; 197 t_avds = 7;
198 t_avdh = 7; 198 t_avdh = 7;
@@ -271,8 +271,8 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg,
271 t.wr_cycle = t.rd_cycle; 271 t.wr_cycle = t.rd_cycle;
272 if (cpu_is_omap34xx()) { 272 if (cpu_is_omap34xx()) {
273 t.wr_data_mux_bus = gpmc_ticks_to_ns(fclk_offset + 273 t.wr_data_mux_bus = gpmc_ticks_to_ns(fclk_offset +
274 gpmc_ns_to_ticks(min_gpmc_clk_period + 274 gpmc_ps_to_ticks(min_gpmc_clk_period +
275 t_rdyo)); 275 t_rdyo * 1000));
276 t.wr_access = t.access; 276 t.wr_access = t.access;
277 } 277 }
278 } else { 278 } else {
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index f46933bc9373..1b7b3e7d02f7 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -168,6 +168,16 @@ unsigned int gpmc_ns_to_ticks(unsigned int time_ns)
168 return (time_ns * 1000 + tick_ps - 1) / tick_ps; 168 return (time_ns * 1000 + tick_ps - 1) / tick_ps;
169} 169}
170 170
171unsigned int gpmc_ps_to_ticks(unsigned int time_ps)
172{
173 unsigned long tick_ps;
174
175 /* Calculate in picosecs to yield more exact results */
176 tick_ps = gpmc_get_fclk_period();
177
178 return (time_ps + tick_ps - 1) / tick_ps;
179}
180
171unsigned int gpmc_ticks_to_ns(unsigned int ticks) 181unsigned int gpmc_ticks_to_ns(unsigned int ticks)
172{ 182{
173 return ticks * gpmc_get_fclk_period() / 1000; 183 return ticks * gpmc_get_fclk_period() / 1000;
@@ -235,7 +245,7 @@ int gpmc_cs_calc_divider(int cs, unsigned int sync_clk)
235 int div; 245 int div;
236 u32 l; 246 u32 l;
237 247
238 l = sync_clk * 1000 + (gpmc_get_fclk_period() - 1); 248 l = sync_clk + (gpmc_get_fclk_period() - 1);
239 div = l / gpmc_get_fclk_period(); 249 div = l / gpmc_get_fclk_period();
240 if (div > 4) 250 if (div > 4)
241 return -1; 251 return -1;
diff --git a/arch/arm/mach-omap2/usb-tusb6010.c b/arch/arm/mach-omap2/usb-tusb6010.c
index 64a0112b70a5..1e998ea40951 100644
--- a/arch/arm/mach-omap2/usb-tusb6010.c
+++ b/arch/arm/mach-omap2/usb-tusb6010.c
@@ -120,8 +120,8 @@ static int tusb_set_sync_mode(unsigned sysclk_ps, unsigned fclk_ps)
120 t.adv_on = next_clk(t.cs_on, t_scsnh_advnh - 7000, fclk_ps); 120 t.adv_on = next_clk(t.cs_on, t_scsnh_advnh - 7000, fclk_ps);
121 121
122 /* GPMC_CLK rate = fclk rate / div */ 122 /* GPMC_CLK rate = fclk rate / div */
123 t.sync_clk = 12 /* 11.1 nsec */; 123 t.sync_clk = 11100 /* 11.1 nsec */;
124 tmp = (t.sync_clk * 1000 + fclk_ps - 1) / fclk_ps; 124 tmp = (t.sync_clk + fclk_ps - 1) / fclk_ps;
125 if (tmp > 4) 125 if (tmp > 4)
126 return -ERANGE; 126 return -ERANGE;
127 if (tmp <= 0) 127 if (tmp <= 0)
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h b/arch/arm/plat-omap/include/plat/gpmc.h
index 9fd99b9e40ab..85ded598853e 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -80,12 +80,12 @@
80#define GPMC_PREFETCH_STATUS_COUNT(val) (val & 0x00003fff) 80#define GPMC_PREFETCH_STATUS_COUNT(val) (val & 0x00003fff)
81 81
82/* 82/*
83 * Note that all values in this struct are in nanoseconds, while 83 * Note that all values in this struct are in nanoseconds except sync_clk
84 * the register values are in gpmc_fck cycles. 84 * (which is in picoseconds), while the register values are in gpmc_fck cycles.
85 */ 85 */
86struct gpmc_timings { 86struct gpmc_timings {
87 /* Minimum clock period for synchronous mode */ 87 /* Minimum clock period for synchronous mode (in picoseconds) */
88 u16 sync_clk; 88 u32 sync_clk;
89 89
90 /* Chip-select signal timings corresponding to GPMC_CS_CONFIG2 */ 90 /* Chip-select signal timings corresponding to GPMC_CS_CONFIG2 */
91 u16 cs_on; /* Assertion time */ 91 u16 cs_on; /* Assertion time */
@@ -117,6 +117,7 @@ struct gpmc_timings {
117}; 117};
118 118
119extern unsigned int gpmc_ns_to_ticks(unsigned int time_ns); 119extern unsigned int gpmc_ns_to_ticks(unsigned int time_ns);
120extern unsigned int gpmc_ps_to_ticks(unsigned int time_ps);
120extern unsigned int gpmc_ticks_to_ns(unsigned int ticks); 121extern unsigned int gpmc_ticks_to_ns(unsigned int ticks);
121extern unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns); 122extern unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns);
122extern unsigned long gpmc_get_fclk_period(void); 123extern unsigned long gpmc_get_fclk_period(void);