Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gerhard Sittig and committed by
Anatolij Gustschin
7b19f3bc 5ac22504

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