diff options
author | Andrew Lunn <andrew@lunn.ch> | 2011-12-23 19:24:24 -0500 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2012-05-08 19:33:56 -0400 |
commit | 452503ebc7cc4cce5b9e52cf2f03255365a53234 (patch) | |
tree | ecf09f091b74cad5d40e1d10cbf6df35ad97ef15 | |
parent | 4574b886698dfad6209102fed6136622b5fe1c21 (diff) |
ARM: Orion: Eth: Add clk/clkdev support.
The t_clk is moved from the shared part of the ethernet driver into
the per port section. Each port can have its own gated clock, which it
needs to enable/disable, as oppossed to there being one clock shared
by all ports. In practice, only kirkwood supports this at the moment.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Jamie Lentin <jm@lentin.co.uk>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r-- | arch/arm/mach-dove/common.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/common.c | 12 | ||||
-rw-r--r-- | arch/arm/mach-mv78xx0/common.c | 8 | ||||
-rw-r--r-- | arch/arm/mach-orion5x/common.c | 2 | ||||
-rw-r--r-- | arch/arm/plat-orion/common.c | 26 | ||||
-rw-r--r-- | arch/arm/plat-orion/include/plat/common.h | 13 | ||||
-rw-r--r-- | drivers/net/ethernet/marvell/mv643xx_eth.c | 42 | ||||
-rw-r--r-- | include/linux/mv643xx_eth.h | 1 |
8 files changed, 61 insertions, 46 deletions
diff --git a/arch/arm/mach-dove/common.c b/arch/arm/mach-dove/common.c index da5b4047464d..02766960480d 100644 --- a/arch/arm/mach-dove/common.c +++ b/arch/arm/mach-dove/common.c | |||
@@ -102,8 +102,7 @@ void __init dove_ehci1_init(void) | |||
102 | void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data) | 102 | void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data) |
103 | { | 103 | { |
104 | orion_ge00_init(eth_data, | 104 | orion_ge00_init(eth_data, |
105 | DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM, | 105 | DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM, 0); |
106 | 0, get_tclk()); | ||
107 | } | 106 | } |
108 | 107 | ||
109 | /***************************************************************************** | 108 | /***************************************************************************** |
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c index 476e0b941db7..c22354405297 100644 --- a/arch/arm/mach-kirkwood/common.c +++ b/arch/arm/mach-kirkwood/common.c | |||
@@ -86,14 +86,14 @@ static struct clk __init *kirkwood_register_gate(const char *name, u8 bit_idx) | |||
86 | 86 | ||
87 | void __init kirkwood_clk_init(void) | 87 | void __init kirkwood_clk_init(void) |
88 | { | 88 | { |
89 | struct clk *runit; | 89 | struct clk *runit, *ge0, *ge1; |
90 | 90 | ||
91 | tclk = clk_register_fixed_rate(NULL, "tclk", NULL, | 91 | tclk = clk_register_fixed_rate(NULL, "tclk", NULL, |
92 | CLK_IS_ROOT, kirkwood_tclk); | 92 | CLK_IS_ROOT, kirkwood_tclk); |
93 | 93 | ||
94 | runit = kirkwood_register_gate("runit", CGC_BIT_RUNIT); | 94 | runit = kirkwood_register_gate("runit", CGC_BIT_RUNIT); |
95 | kirkwood_register_gate("ge0", CGC_BIT_GE0); | 95 | ge0 = kirkwood_register_gate("ge0", CGC_BIT_GE0); |
96 | kirkwood_register_gate("ge1", CGC_BIT_GE1); | 96 | ge1 = kirkwood_register_gate("ge1", CGC_BIT_GE1); |
97 | kirkwood_register_gate("sata0", CGC_BIT_SATA0); | 97 | kirkwood_register_gate("sata0", CGC_BIT_SATA0); |
98 | kirkwood_register_gate("sata1", CGC_BIT_SATA1); | 98 | kirkwood_register_gate("sata1", CGC_BIT_SATA1); |
99 | kirkwood_register_gate("usb0", CGC_BIT_USB0); | 99 | kirkwood_register_gate("usb0", CGC_BIT_USB0); |
@@ -110,6 +110,8 @@ void __init kirkwood_clk_init(void) | |||
110 | /* clkdev entries, mapping clks to devices */ | 110 | /* clkdev entries, mapping clks to devices */ |
111 | orion_clkdev_add(NULL, "orion_spi.0", runit); | 111 | orion_clkdev_add(NULL, "orion_spi.0", runit); |
112 | orion_clkdev_add(NULL, "orion_spi.1", runit); | 112 | orion_clkdev_add(NULL, "orion_spi.1", runit); |
113 | orion_clkdev_add(NULL, MV643XX_ETH_NAME ".0", ge0); | ||
114 | orion_clkdev_add(NULL, MV643XX_ETH_NAME ".1", ge1); | ||
113 | } | 115 | } |
114 | 116 | ||
115 | /***************************************************************************** | 117 | /***************************************************************************** |
@@ -131,7 +133,7 @@ void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data) | |||
131 | 133 | ||
132 | orion_ge00_init(eth_data, | 134 | orion_ge00_init(eth_data, |
133 | GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM, | 135 | GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM, |
134 | IRQ_KIRKWOOD_GE00_ERR, kirkwood_tclk); | 136 | IRQ_KIRKWOOD_GE00_ERR); |
135 | } | 137 | } |
136 | 138 | ||
137 | 139 | ||
@@ -145,7 +147,7 @@ void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data) | |||
145 | 147 | ||
146 | orion_ge01_init(eth_data, | 148 | orion_ge01_init(eth_data, |
147 | GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM, | 149 | GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM, |
148 | IRQ_KIRKWOOD_GE01_ERR, kirkwood_tclk); | 150 | IRQ_KIRKWOOD_GE01_ERR); |
149 | } | 151 | } |
150 | 152 | ||
151 | 153 | ||
diff --git a/arch/arm/mach-mv78xx0/common.c b/arch/arm/mach-mv78xx0/common.c index 4c24b46520aa..ad4d037bbcd3 100644 --- a/arch/arm/mach-mv78xx0/common.c +++ b/arch/arm/mach-mv78xx0/common.c | |||
@@ -213,7 +213,7 @@ void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data) | |||
213 | { | 213 | { |
214 | orion_ge00_init(eth_data, | 214 | orion_ge00_init(eth_data, |
215 | GE00_PHYS_BASE, IRQ_MV78XX0_GE00_SUM, | 215 | GE00_PHYS_BASE, IRQ_MV78XX0_GE00_SUM, |
216 | IRQ_MV78XX0_GE_ERR, get_tclk()); | 216 | IRQ_MV78XX0_GE_ERR); |
217 | } | 217 | } |
218 | 218 | ||
219 | 219 | ||
@@ -224,7 +224,7 @@ void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data) | |||
224 | { | 224 | { |
225 | orion_ge01_init(eth_data, | 225 | orion_ge01_init(eth_data, |
226 | GE01_PHYS_BASE, IRQ_MV78XX0_GE01_SUM, | 226 | GE01_PHYS_BASE, IRQ_MV78XX0_GE01_SUM, |
227 | NO_IRQ, get_tclk()); | 227 | NO_IRQ); |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
@@ -248,7 +248,7 @@ void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data) | |||
248 | 248 | ||
249 | orion_ge10_init(eth_data, | 249 | orion_ge10_init(eth_data, |
250 | GE10_PHYS_BASE, IRQ_MV78XX0_GE10_SUM, | 250 | GE10_PHYS_BASE, IRQ_MV78XX0_GE10_SUM, |
251 | NO_IRQ, get_tclk()); | 251 | NO_IRQ); |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
@@ -272,7 +272,7 @@ void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data) | |||
272 | 272 | ||
273 | orion_ge11_init(eth_data, | 273 | orion_ge11_init(eth_data, |
274 | GE11_PHYS_BASE, IRQ_MV78XX0_GE11_SUM, | 274 | GE11_PHYS_BASE, IRQ_MV78XX0_GE11_SUM, |
275 | NO_IRQ, get_tclk()); | 275 | NO_IRQ); |
276 | } | 276 | } |
277 | 277 | ||
278 | /***************************************************************************** | 278 | /***************************************************************************** |
diff --git a/arch/arm/mach-orion5x/common.c b/arch/arm/mach-orion5x/common.c index 2ef82e2f511d..3fc731824e9c 100644 --- a/arch/arm/mach-orion5x/common.c +++ b/arch/arm/mach-orion5x/common.c | |||
@@ -109,7 +109,7 @@ void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data) | |||
109 | { | 109 | { |
110 | orion_ge00_init(eth_data, | 110 | orion_ge00_init(eth_data, |
111 | ORION5X_ETH_PHYS_BASE, IRQ_ORION5X_ETH_SUM, | 111 | ORION5X_ETH_PHYS_BASE, IRQ_ORION5X_ETH_SUM, |
112 | IRQ_ORION5X_ETH_ERR, orion5x_tclk); | 112 | IRQ_ORION5X_ETH_ERR); |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c index bbe50a948710..a33733bb380d 100644 --- a/arch/arm/plat-orion/common.c +++ b/arch/arm/plat-orion/common.c | |||
@@ -43,6 +43,10 @@ void __init orion_clkdev_init(struct clk *tclk) | |||
43 | { | 43 | { |
44 | orion_clkdev_add(NULL, "orion_spi.0", tclk); | 44 | orion_clkdev_add(NULL, "orion_spi.0", tclk); |
45 | orion_clkdev_add(NULL, "orion_spi.1", tclk); | 45 | orion_clkdev_add(NULL, "orion_spi.1", tclk); |
46 | orion_clkdev_add(NULL, MV643XX_ETH_NAME ".0", tclk); | ||
47 | orion_clkdev_add(NULL, MV643XX_ETH_NAME ".1", tclk); | ||
48 | orion_clkdev_add(NULL, MV643XX_ETH_NAME ".2", tclk); | ||
49 | orion_clkdev_add(NULL, MV643XX_ETH_NAME ".3", tclk); | ||
46 | } | 50 | } |
47 | 51 | ||
48 | /* Fill in the resources structure and link it into the platform | 52 | /* Fill in the resources structure and link it into the platform |
@@ -225,13 +229,11 @@ void __init orion_rtc_init(unsigned long mapbase, | |||
225 | ****************************************************************************/ | 229 | ****************************************************************************/ |
226 | static __init void ge_complete( | 230 | static __init void ge_complete( |
227 | struct mv643xx_eth_shared_platform_data *orion_ge_shared_data, | 231 | struct mv643xx_eth_shared_platform_data *orion_ge_shared_data, |
228 | int tclk, | ||
229 | struct resource *orion_ge_resource, unsigned long irq, | 232 | struct resource *orion_ge_resource, unsigned long irq, |
230 | struct platform_device *orion_ge_shared, | 233 | struct platform_device *orion_ge_shared, |
231 | struct mv643xx_eth_platform_data *eth_data, | 234 | struct mv643xx_eth_platform_data *eth_data, |
232 | struct platform_device *orion_ge) | 235 | struct platform_device *orion_ge) |
233 | { | 236 | { |
234 | orion_ge_shared_data->t_clk = tclk; | ||
235 | orion_ge_resource->start = irq; | 237 | orion_ge_resource->start = irq; |
236 | orion_ge_resource->end = irq; | 238 | orion_ge_resource->end = irq; |
237 | eth_data->shared = orion_ge_shared; | 239 | eth_data->shared = orion_ge_shared; |
@@ -282,12 +284,11 @@ static struct platform_device orion_ge00 = { | |||
282 | void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, | 284 | void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, |
283 | unsigned long mapbase, | 285 | unsigned long mapbase, |
284 | unsigned long irq, | 286 | unsigned long irq, |
285 | unsigned long irq_err, | 287 | unsigned long irq_err) |
286 | int tclk) | ||
287 | { | 288 | { |
288 | fill_resources(&orion_ge00_shared, orion_ge00_shared_resources, | 289 | fill_resources(&orion_ge00_shared, orion_ge00_shared_resources, |
289 | mapbase + 0x2000, SZ_16K - 1, irq_err); | 290 | mapbase + 0x2000, SZ_16K - 1, irq_err); |
290 | ge_complete(&orion_ge00_shared_data, tclk, | 291 | ge_complete(&orion_ge00_shared_data, |
291 | orion_ge00_resources, irq, &orion_ge00_shared, | 292 | orion_ge00_resources, irq, &orion_ge00_shared, |
292 | eth_data, &orion_ge00); | 293 | eth_data, &orion_ge00); |
293 | } | 294 | } |
@@ -335,12 +336,11 @@ static struct platform_device orion_ge01 = { | |||
335 | void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, | 336 | void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, |
336 | unsigned long mapbase, | 337 | unsigned long mapbase, |
337 | unsigned long irq, | 338 | unsigned long irq, |
338 | unsigned long irq_err, | 339 | unsigned long irq_err) |
339 | int tclk) | ||
340 | { | 340 | { |
341 | fill_resources(&orion_ge01_shared, orion_ge01_shared_resources, | 341 | fill_resources(&orion_ge01_shared, orion_ge01_shared_resources, |
342 | mapbase + 0x2000, SZ_16K - 1, irq_err); | 342 | mapbase + 0x2000, SZ_16K - 1, irq_err); |
343 | ge_complete(&orion_ge01_shared_data, tclk, | 343 | ge_complete(&orion_ge01_shared_data, |
344 | orion_ge01_resources, irq, &orion_ge01_shared, | 344 | orion_ge01_resources, irq, &orion_ge01_shared, |
345 | eth_data, &orion_ge01); | 345 | eth_data, &orion_ge01); |
346 | } | 346 | } |
@@ -388,12 +388,11 @@ static struct platform_device orion_ge10 = { | |||
388 | void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data, | 388 | void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data, |
389 | unsigned long mapbase, | 389 | unsigned long mapbase, |
390 | unsigned long irq, | 390 | unsigned long irq, |
391 | unsigned long irq_err, | 391 | unsigned long irq_err) |
392 | int tclk) | ||
393 | { | 392 | { |
394 | fill_resources(&orion_ge10_shared, orion_ge10_shared_resources, | 393 | fill_resources(&orion_ge10_shared, orion_ge10_shared_resources, |
395 | mapbase + 0x2000, SZ_16K - 1, irq_err); | 394 | mapbase + 0x2000, SZ_16K - 1, irq_err); |
396 | ge_complete(&orion_ge10_shared_data, tclk, | 395 | ge_complete(&orion_ge10_shared_data, |
397 | orion_ge10_resources, irq, &orion_ge10_shared, | 396 | orion_ge10_resources, irq, &orion_ge10_shared, |
398 | eth_data, &orion_ge10); | 397 | eth_data, &orion_ge10); |
399 | } | 398 | } |
@@ -441,12 +440,11 @@ static struct platform_device orion_ge11 = { | |||
441 | void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, | 440 | void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, |
442 | unsigned long mapbase, | 441 | unsigned long mapbase, |
443 | unsigned long irq, | 442 | unsigned long irq, |
444 | unsigned long irq_err, | 443 | unsigned long irq_err) |
445 | int tclk) | ||
446 | { | 444 | { |
447 | fill_resources(&orion_ge11_shared, orion_ge11_shared_resources, | 445 | fill_resources(&orion_ge11_shared, orion_ge11_shared_resources, |
448 | mapbase + 0x2000, SZ_16K - 1, irq_err); | 446 | mapbase + 0x2000, SZ_16K - 1, irq_err); |
449 | ge_complete(&orion_ge11_shared_data, tclk, | 447 | ge_complete(&orion_ge11_shared_data, |
450 | orion_ge11_resources, irq, &orion_ge11_shared, | 448 | orion_ge11_resources, irq, &orion_ge11_shared, |
451 | eth_data, &orion_ge11); | 449 | eth_data, &orion_ge11); |
452 | } | 450 | } |
diff --git a/arch/arm/plat-orion/include/plat/common.h b/arch/arm/plat-orion/include/plat/common.h index d188a1aa6f56..00d8761c7d28 100644 --- a/arch/arm/plat-orion/include/plat/common.h +++ b/arch/arm/plat-orion/include/plat/common.h | |||
@@ -39,29 +39,26 @@ void __init orion_rtc_init(unsigned long mapbase, | |||
39 | void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, | 39 | void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, |
40 | unsigned long mapbase, | 40 | unsigned long mapbase, |
41 | unsigned long irq, | 41 | unsigned long irq, |
42 | unsigned long irq_err, | 42 | unsigned long irq_err); |
43 | int tclk); | ||
44 | 43 | ||
45 | void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, | 44 | void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, |
46 | unsigned long mapbase, | 45 | unsigned long mapbase, |
47 | unsigned long irq, | 46 | unsigned long irq, |
48 | unsigned long irq_err, | 47 | unsigned long irq_err); |
49 | int tclk); | ||
50 | 48 | ||
51 | void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data, | 49 | void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data, |
52 | unsigned long mapbase, | 50 | unsigned long mapbase, |
53 | unsigned long irq, | 51 | unsigned long irq, |
54 | unsigned long irq_err, | 52 | unsigned long irq_err); |
55 | int tclk); | ||
56 | 53 | ||
57 | void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, | 54 | void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, |
58 | unsigned long mapbase, | 55 | unsigned long mapbase, |
59 | unsigned long irq, | 56 | unsigned long irq, |
60 | unsigned long irq_err, | 57 | unsigned long irq_err); |
61 | int tclk); | ||
62 | 58 | ||
63 | void __init orion_ge00_switch_init(struct dsa_platform_data *d, | 59 | void __init orion_ge00_switch_init(struct dsa_platform_data *d, |
64 | int irq); | 60 | int irq); |
61 | |||
65 | void __init orion_i2c_init(unsigned long mapbase, | 62 | void __init orion_i2c_init(unsigned long mapbase, |
66 | unsigned long irq, | 63 | unsigned long irq, |
67 | unsigned long freq_m); | 64 | unsigned long freq_m); |
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index 5e1ca0f05090..99cd233266ac 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c | |||
@@ -57,6 +57,7 @@ | |||
57 | #include <linux/types.h> | 57 | #include <linux/types.h> |
58 | #include <linux/inet_lro.h> | 58 | #include <linux/inet_lro.h> |
59 | #include <linux/slab.h> | 59 | #include <linux/slab.h> |
60 | #include <linux/clk.h> | ||
60 | 61 | ||
61 | static char mv643xx_eth_driver_name[] = "mv643xx_eth"; | 62 | static char mv643xx_eth_driver_name[] = "mv643xx_eth"; |
62 | static char mv643xx_eth_driver_version[] = "1.4"; | 63 | static char mv643xx_eth_driver_version[] = "1.4"; |
@@ -289,10 +290,10 @@ struct mv643xx_eth_shared_private { | |||
289 | /* | 290 | /* |
290 | * Hardware-specific parameters. | 291 | * Hardware-specific parameters. |
291 | */ | 292 | */ |
292 | unsigned int t_clk; | ||
293 | int extended_rx_coal_limit; | 293 | int extended_rx_coal_limit; |
294 | int tx_bw_control; | 294 | int tx_bw_control; |
295 | int tx_csum_limit; | 295 | int tx_csum_limit; |
296 | |||
296 | }; | 297 | }; |
297 | 298 | ||
298 | #define TX_BW_CONTROL_ABSENT 0 | 299 | #define TX_BW_CONTROL_ABSENT 0 |
@@ -431,6 +432,12 @@ struct mv643xx_eth_private { | |||
431 | int tx_desc_sram_size; | 432 | int tx_desc_sram_size; |
432 | int txq_count; | 433 | int txq_count; |
433 | struct tx_queue txq[8]; | 434 | struct tx_queue txq[8]; |
435 | |||
436 | /* | ||
437 | * Hardware-specific parameters. | ||
438 | */ | ||
439 | struct clk *clk; | ||
440 | unsigned int t_clk; | ||
434 | }; | 441 | }; |
435 | 442 | ||
436 | 443 | ||
@@ -1010,7 +1017,7 @@ static void tx_set_rate(struct mv643xx_eth_private *mp, int rate, int burst) | |||
1010 | int mtu; | 1017 | int mtu; |
1011 | int bucket_size; | 1018 | int bucket_size; |
1012 | 1019 | ||
1013 | token_rate = ((rate / 1000) * 64) / (mp->shared->t_clk / 1000); | 1020 | token_rate = ((rate / 1000) * 64) / (mp->t_clk / 1000); |
1014 | if (token_rate > 1023) | 1021 | if (token_rate > 1023) |
1015 | token_rate = 1023; | 1022 | token_rate = 1023; |
1016 | 1023 | ||
@@ -1042,7 +1049,7 @@ static void txq_set_rate(struct tx_queue *txq, int rate, int burst) | |||
1042 | int token_rate; | 1049 | int token_rate; |
1043 | int bucket_size; | 1050 | int bucket_size; |
1044 | 1051 | ||
1045 | token_rate = ((rate / 1000) * 64) / (mp->shared->t_clk / 1000); | 1052 | token_rate = ((rate / 1000) * 64) / (mp->t_clk / 1000); |
1046 | if (token_rate > 1023) | 1053 | if (token_rate > 1023) |
1047 | token_rate = 1023; | 1054 | token_rate = 1023; |
1048 | 1055 | ||
@@ -1309,7 +1316,7 @@ static unsigned int get_rx_coal(struct mv643xx_eth_private *mp) | |||
1309 | temp = (val & 0x003fff00) >> 8; | 1316 | temp = (val & 0x003fff00) >> 8; |
1310 | 1317 | ||
1311 | temp *= 64000000; | 1318 | temp *= 64000000; |
1312 | do_div(temp, mp->shared->t_clk); | 1319 | do_div(temp, mp->t_clk); |
1313 | 1320 | ||
1314 | return (unsigned int)temp; | 1321 | return (unsigned int)temp; |
1315 | } | 1322 | } |
@@ -1319,7 +1326,7 @@ static void set_rx_coal(struct mv643xx_eth_private *mp, unsigned int usec) | |||
1319 | u64 temp; | 1326 | u64 temp; |
1320 | u32 val; | 1327 | u32 val; |
1321 | 1328 | ||
1322 | temp = (u64)usec * mp->shared->t_clk; | 1329 | temp = (u64)usec * mp->t_clk; |
1323 | temp += 31999999; | 1330 | temp += 31999999; |
1324 | do_div(temp, 64000000); | 1331 | do_div(temp, 64000000); |
1325 | 1332 | ||
@@ -1345,7 +1352,7 @@ static unsigned int get_tx_coal(struct mv643xx_eth_private *mp) | |||
1345 | 1352 | ||
1346 | temp = (rdlp(mp, TX_FIFO_URGENT_THRESHOLD) & 0x3fff0) >> 4; | 1353 | temp = (rdlp(mp, TX_FIFO_URGENT_THRESHOLD) & 0x3fff0) >> 4; |
1347 | temp *= 64000000; | 1354 | temp *= 64000000; |
1348 | do_div(temp, mp->shared->t_clk); | 1355 | do_div(temp, mp->t_clk); |
1349 | 1356 | ||
1350 | return (unsigned int)temp; | 1357 | return (unsigned int)temp; |
1351 | } | 1358 | } |
@@ -1354,7 +1361,7 @@ static void set_tx_coal(struct mv643xx_eth_private *mp, unsigned int usec) | |||
1354 | { | 1361 | { |
1355 | u64 temp; | 1362 | u64 temp; |
1356 | 1363 | ||
1357 | temp = (u64)usec * mp->shared->t_clk; | 1364 | temp = (u64)usec * mp->t_clk; |
1358 | temp += 31999999; | 1365 | temp += 31999999; |
1359 | do_div(temp, 64000000); | 1366 | do_div(temp, 64000000); |
1360 | 1367 | ||
@@ -2662,10 +2669,6 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) | |||
2662 | if (dram) | 2669 | if (dram) |
2663 | mv643xx_eth_conf_mbus_windows(msp, dram); | 2670 | mv643xx_eth_conf_mbus_windows(msp, dram); |
2664 | 2671 | ||
2665 | /* | ||
2666 | * Detect hardware parameters. | ||
2667 | */ | ||
2668 | msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000; | ||
2669 | msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ? | 2672 | msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ? |
2670 | pd->tx_csum_limit : 9 * 1024; | 2673 | pd->tx_csum_limit : 9 * 1024; |
2671 | infer_hw_params(msp); | 2674 | infer_hw_params(msp); |
@@ -2890,6 +2893,18 @@ static int mv643xx_eth_probe(struct platform_device *pdev) | |||
2890 | 2893 | ||
2891 | mp->dev = dev; | 2894 | mp->dev = dev; |
2892 | 2895 | ||
2896 | /* | ||
2897 | * Get the clk rate, if there is one, otherwise use the default. | ||
2898 | */ | ||
2899 | mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0")); | ||
2900 | if (!IS_ERR(mp->clk)) { | ||
2901 | clk_prepare_enable(mp->clk); | ||
2902 | mp->t_clk = clk_get_rate(mp->clk); | ||
2903 | } else { | ||
2904 | mp->t_clk = 133000000; | ||
2905 | printk(KERN_WARNING "Unable to get clock"); | ||
2906 | } | ||
2907 | |||
2893 | set_params(mp, pd); | 2908 | set_params(mp, pd); |
2894 | netif_set_real_num_tx_queues(dev, mp->txq_count); | 2909 | netif_set_real_num_tx_queues(dev, mp->txq_count); |
2895 | netif_set_real_num_rx_queues(dev, mp->rxq_count); | 2910 | netif_set_real_num_rx_queues(dev, mp->rxq_count); |
@@ -2978,6 +2993,11 @@ static int mv643xx_eth_remove(struct platform_device *pdev) | |||
2978 | if (mp->phy != NULL) | 2993 | if (mp->phy != NULL) |
2979 | phy_detach(mp->phy); | 2994 | phy_detach(mp->phy); |
2980 | cancel_work_sync(&mp->tx_timeout_task); | 2995 | cancel_work_sync(&mp->tx_timeout_task); |
2996 | |||
2997 | if (!IS_ERR(mp->clk)) { | ||
2998 | clk_disable_unprepare(mp->clk); | ||
2999 | clk_put(mp->clk); | ||
3000 | } | ||
2981 | free_netdev(mp->dev); | 3001 | free_netdev(mp->dev); |
2982 | 3002 | ||
2983 | platform_set_drvdata(pdev, NULL); | 3003 | platform_set_drvdata(pdev, NULL); |
diff --git a/include/linux/mv643xx_eth.h b/include/linux/mv643xx_eth.h index 30b0c4e78f91..51bf8ada6dc0 100644 --- a/include/linux/mv643xx_eth.h +++ b/include/linux/mv643xx_eth.h | |||
@@ -18,7 +18,6 @@ | |||
18 | struct mv643xx_eth_shared_platform_data { | 18 | struct mv643xx_eth_shared_platform_data { |
19 | struct mbus_dram_target_info *dram; | 19 | struct mbus_dram_target_info *dram; |
20 | struct platform_device *shared_smi; | 20 | struct platform_device *shared_smi; |
21 | unsigned int t_clk; | ||
22 | /* | 21 | /* |
23 | * Max packet size for Tx IP/Layer 4 checksum, when set to 0, default | 22 | * Max packet size for Tx IP/Layer 4 checksum, when set to 0, default |
24 | * limit of 9KiB will be used. | 23 | * limit of 9KiB will be used. |