diff options
author | Gerhard Sittig <gsi@denx.de> | 2013-11-30 17:51:35 -0500 |
---|---|---|
committer | Anatolij Gustschin <agust@denx.de> | 2014-01-12 12:53:05 -0500 |
commit | 7b19f3bcefd0eba677e5cb3e5c88de38cd5c95c8 (patch) | |
tree | 5b4b2bdebda9724aac9505cc3f3f5d2bd0d3b66a /drivers/net | |
parent | 5ac22504f928db34a3a75ab67bf1eef82b91ef0b (diff) |
net: can: mscan: remove non-CCF code for MPC512x
transition to the common clock framework has completed and the PPC_CLOCK
is no longer available for the MPC512x platform, remove the now obsolete
code path of the mpc5xxx mscan driver which accessed clock control module
registers directly
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org
Signed-off-by: Gerhard Sittig <gsi@denx.de>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/can/mscan/mpc5xxx_can.c | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c index f48f1297ff30..6b0c9958d824 100644 --- a/drivers/net/can/mscan/mpc5xxx_can.c +++ b/drivers/net/can/mscan/mpc5xxx_can.c | |||
@@ -109,9 +109,6 @@ static u32 mpc52xx_can_get_clock(struct platform_device *ofdev, | |||
109 | #endif /* CONFIG_PPC_MPC52xx */ | 109 | #endif /* CONFIG_PPC_MPC52xx */ |
110 | 110 | ||
111 | #ifdef CONFIG_PPC_MPC512x | 111 | #ifdef CONFIG_PPC_MPC512x |
112 | |||
113 | #if IS_ENABLED(CONFIG_COMMON_CLK) | ||
114 | |||
115 | static u32 mpc512x_can_get_clock(struct platform_device *ofdev, | 112 | static u32 mpc512x_can_get_clock(struct platform_device *ofdev, |
116 | const char *clock_source, int *mscan_clksrc) | 113 | const char *clock_source, int *mscan_clksrc) |
117 | { | 114 | { |
@@ -277,144 +274,6 @@ static void mpc512x_can_put_clock(struct platform_device *ofdev) | |||
277 | if (priv->clk_ipg) | 274 | if (priv->clk_ipg) |
278 | clk_disable_unprepare(priv->clk_ipg); | 275 | clk_disable_unprepare(priv->clk_ipg); |
279 | } | 276 | } |
280 | |||
281 | #else /* COMMON_CLK */ | ||
282 | |||
283 | struct mpc512x_clockctl { | ||
284 | u32 spmr; /* System PLL Mode Reg */ | ||
285 | u32 sccr[2]; /* System Clk Ctrl Reg 1 & 2 */ | ||
286 | u32 scfr1; /* System Clk Freq Reg 1 */ | ||
287 | u32 scfr2; /* System Clk Freq Reg 2 */ | ||
288 | u32 reserved; | ||
289 | u32 bcr; /* Bread Crumb Reg */ | ||
290 | u32 pccr[12]; /* PSC Clk Ctrl Reg 0-11 */ | ||
291 | u32 spccr; /* SPDIF Clk Ctrl Reg */ | ||
292 | u32 cccr; /* CFM Clk Ctrl Reg */ | ||
293 | u32 dccr; /* DIU Clk Cnfg Reg */ | ||
294 | u32 mccr[4]; /* MSCAN Clk Ctrl Reg 1-3 */ | ||
295 | }; | ||
296 | |||
297 | static struct of_device_id mpc512x_clock_ids[] = { | ||
298 | { .compatible = "fsl,mpc5121-clock", }, | ||
299 | {} | ||
300 | }; | ||
301 | |||
302 | static u32 mpc512x_can_get_clock(struct platform_device *ofdev, | ||
303 | const char *clock_name, int *mscan_clksrc) | ||
304 | { | ||
305 | struct mpc512x_clockctl __iomem *clockctl; | ||
306 | struct device_node *np_clock; | ||
307 | struct clk *sys_clk, *ref_clk; | ||
308 | int plen, clockidx, clocksrc = -1; | ||
309 | u32 sys_freq, val, clockdiv = 1, freq = 0; | ||
310 | const u32 *pval; | ||
311 | |||
312 | np_clock = of_find_matching_node(NULL, mpc512x_clock_ids); | ||
313 | if (!np_clock) { | ||
314 | dev_err(&ofdev->dev, "couldn't find clock node\n"); | ||
315 | return 0; | ||
316 | } | ||
317 | clockctl = of_iomap(np_clock, 0); | ||
318 | if (!clockctl) { | ||
319 | dev_err(&ofdev->dev, "couldn't map clock registers\n"); | ||
320 | goto exit_put; | ||
321 | } | ||
322 | |||
323 | /* Determine the MSCAN device index from the peripheral's | ||
324 | * physical address. Register address offsets against the | ||
325 | * IMMR base are: 0x1300, 0x1380, 0x2300, 0x2380 | ||
326 | */ | ||
327 | pval = of_get_property(ofdev->dev.of_node, "reg", &plen); | ||
328 | BUG_ON(!pval || plen < sizeof(*pval)); | ||
329 | clockidx = (*pval & 0x80) ? 1 : 0; | ||
330 | if (*pval & 0x2000) | ||
331 | clockidx += 2; | ||
332 | |||
333 | /* | ||
334 | * Clock source and divider selection: 3 different clock sources | ||
335 | * can be selected: "ip", "ref" or "sys". For the latter two, a | ||
336 | * clock divider can be defined as well. If the clock source is | ||
337 | * not specified by the device tree, we first try to find an | ||
338 | * optimal CAN source clock based on the system clock. If that | ||
339 | * is not posslible, the reference clock will be used. | ||
340 | */ | ||
341 | if (clock_name && !strcmp(clock_name, "ip")) { | ||
342 | *mscan_clksrc = MSCAN_CLKSRC_IPS; | ||
343 | freq = mpc5xxx_get_bus_frequency(ofdev->dev.of_node); | ||
344 | } else { | ||
345 | *mscan_clksrc = MSCAN_CLKSRC_BUS; | ||
346 | |||
347 | pval = of_get_property(ofdev->dev.of_node, | ||
348 | "fsl,mscan-clock-divider", &plen); | ||
349 | if (pval && plen == sizeof(*pval)) | ||
350 | clockdiv = *pval; | ||
351 | if (!clockdiv) | ||
352 | clockdiv = 1; | ||
353 | |||
354 | if (!clock_name || !strcmp(clock_name, "sys")) { | ||
355 | sys_clk = devm_clk_get(&ofdev->dev, "sys_clk"); | ||
356 | if (IS_ERR(sys_clk)) { | ||
357 | dev_err(&ofdev->dev, "couldn't get sys_clk\n"); | ||
358 | goto exit_unmap; | ||
359 | } | ||
360 | /* Get and round up/down sys clock rate */ | ||
361 | sys_freq = 1000000 * | ||
362 | ((clk_get_rate(sys_clk) + 499999) / 1000000); | ||
363 | |||
364 | if (!clock_name) { | ||
365 | /* A multiple of 16 MHz would be optimal */ | ||
366 | if ((sys_freq % 16000000) == 0) { | ||
367 | clocksrc = 0; | ||
368 | clockdiv = sys_freq / 16000000; | ||
369 | freq = sys_freq / clockdiv; | ||
370 | } | ||
371 | } else { | ||
372 | clocksrc = 0; | ||
373 | freq = sys_freq / clockdiv; | ||
374 | } | ||
375 | } | ||
376 | |||
377 | if (clocksrc < 0) { | ||
378 | ref_clk = devm_clk_get(&ofdev->dev, "ref_clk"); | ||
379 | if (IS_ERR(ref_clk)) { | ||
380 | dev_err(&ofdev->dev, "couldn't get ref_clk\n"); | ||
381 | goto exit_unmap; | ||
382 | } | ||
383 | clocksrc = 1; | ||
384 | freq = clk_get_rate(ref_clk) / clockdiv; | ||
385 | } | ||
386 | } | ||
387 | |||
388 | /* Disable clock */ | ||
389 | out_be32(&clockctl->mccr[clockidx], 0x0); | ||
390 | if (clocksrc >= 0) { | ||
391 | /* Set source and divider */ | ||
392 | val = (clocksrc << 14) | ((clockdiv - 1) << 17); | ||
393 | out_be32(&clockctl->mccr[clockidx], val); | ||
394 | /* Enable clock */ | ||
395 | out_be32(&clockctl->mccr[clockidx], val | 0x10000); | ||
396 | } | ||
397 | |||
398 | /* Enable MSCAN clock domain */ | ||
399 | val = in_be32(&clockctl->sccr[1]); | ||
400 | if (!(val & (1 << 25))) | ||
401 | out_be32(&clockctl->sccr[1], val | (1 << 25)); | ||
402 | |||
403 | dev_dbg(&ofdev->dev, "using '%s' with frequency divider %d\n", | ||
404 | *mscan_clksrc == MSCAN_CLKSRC_IPS ? "ips_clk" : | ||
405 | clocksrc == 1 ? "ref_clk" : "sys_clk", clockdiv); | ||
406 | |||
407 | exit_unmap: | ||
408 | iounmap(clockctl); | ||
409 | exit_put: | ||
410 | of_node_put(np_clock); | ||
411 | return freq; | ||
412 | } | ||
413 | |||
414 | #define mpc512x_can_put_clock NULL | ||
415 | |||
416 | #endif /* COMMON_CLK */ | ||
417 | |||
418 | #else /* !CONFIG_PPC_MPC512x */ | 277 | #else /* !CONFIG_PPC_MPC512x */ |
419 | static u32 mpc512x_can_get_clock(struct platform_device *ofdev, | 278 | static u32 mpc512x_can_get_clock(struct platform_device *ofdev, |
420 | const char *clock_name, int *mscan_clksrc) | 279 | const char *clock_name, int *mscan_clksrc) |