| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. |
|---|
| 3 | 4 | * http://www.samsung.com |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * CPU frequency scaling for S5PC110/S5PV210 |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 9 | | - * published by the Free Software Foundation. |
|---|
| 10 | 7 | */ |
|---|
| 11 | 8 | |
|---|
| 12 | 9 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 481 | 478 | arm_volt, arm_volt_max); |
|---|
| 482 | 479 | } |
|---|
| 483 | 480 | |
|---|
| 484 | | - printk(KERN_DEBUG "Perf changed[L%d]\n", index); |
|---|
| 481 | + pr_debug("Perf changed[L%d]\n", index); |
|---|
| 485 | 482 | |
|---|
| 486 | 483 | exit: |
|---|
| 487 | 484 | mutex_unlock(&set_freq_lock); |
|---|
| .. | .. |
|---|
| 544 | 541 | s5pv210_dram_conf[1].freq = clk_get_rate(dmc1_clk); |
|---|
| 545 | 542 | |
|---|
| 546 | 543 | policy->suspend_freq = SLEEP_FREQ; |
|---|
| 547 | | - return cpufreq_generic_init(policy, s5pv210_freq_table, 40000); |
|---|
| 544 | + cpufreq_generic_init(policy, s5pv210_freq_table, 40000); |
|---|
| 545 | + return 0; |
|---|
| 548 | 546 | |
|---|
| 549 | 547 | out_dmc1: |
|---|
| 550 | 548 | clk_put(dmc0_clk); |
|---|
| .. | .. |
|---|
| 557 | 555 | unsigned long event, void *ptr) |
|---|
| 558 | 556 | { |
|---|
| 559 | 557 | int ret; |
|---|
| 558 | + struct cpufreq_policy *policy; |
|---|
| 560 | 559 | |
|---|
| 561 | | - ret = cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ, 0); |
|---|
| 560 | + policy = cpufreq_cpu_get(0); |
|---|
| 561 | + if (!policy) { |
|---|
| 562 | + pr_debug("cpufreq: get no policy for cpu0\n"); |
|---|
| 563 | + return NOTIFY_BAD; |
|---|
| 564 | + } |
|---|
| 565 | + |
|---|
| 566 | + ret = cpufreq_driver_target(policy, SLEEP_FREQ, 0); |
|---|
| 567 | + cpufreq_cpu_put(policy); |
|---|
| 568 | + |
|---|
| 562 | 569 | if (ret < 0) |
|---|
| 563 | 570 | return NOTIFY_BAD; |
|---|
| 564 | 571 | |
|---|
| .. | .. |
|---|
| 583 | 590 | |
|---|
| 584 | 591 | static int s5pv210_cpufreq_probe(struct platform_device *pdev) |
|---|
| 585 | 592 | { |
|---|
| 593 | + struct device *dev = &pdev->dev; |
|---|
| 586 | 594 | struct device_node *np; |
|---|
| 587 | | - int id; |
|---|
| 595 | + int id, result = 0; |
|---|
| 588 | 596 | |
|---|
| 589 | 597 | /* |
|---|
| 590 | 598 | * HACK: This is a temporary workaround to get access to clock |
|---|
| .. | .. |
|---|
| 594 | 602 | * this whole driver as soon as S5PV210 gets migrated to use |
|---|
| 595 | 603 | * cpufreq-dt driver. |
|---|
| 596 | 604 | */ |
|---|
| 605 | + arm_regulator = regulator_get(NULL, "vddarm"); |
|---|
| 606 | + if (IS_ERR(arm_regulator)) |
|---|
| 607 | + return dev_err_probe(dev, PTR_ERR(arm_regulator), |
|---|
| 608 | + "failed to get regulator vddarm\n"); |
|---|
| 609 | + |
|---|
| 610 | + int_regulator = regulator_get(NULL, "vddint"); |
|---|
| 611 | + if (IS_ERR(int_regulator)) { |
|---|
| 612 | + result = dev_err_probe(dev, PTR_ERR(int_regulator), |
|---|
| 613 | + "failed to get regulator vddint\n"); |
|---|
| 614 | + goto err_int_regulator; |
|---|
| 615 | + } |
|---|
| 616 | + |
|---|
| 597 | 617 | np = of_find_compatible_node(NULL, NULL, "samsung,s5pv210-clock"); |
|---|
| 598 | 618 | if (!np) { |
|---|
| 599 | | - pr_err("%s: failed to find clock controller DT node\n", |
|---|
| 600 | | - __func__); |
|---|
| 601 | | - return -ENODEV; |
|---|
| 619 | + dev_err(dev, "failed to find clock controller DT node\n"); |
|---|
| 620 | + result = -ENODEV; |
|---|
| 621 | + goto err_clock; |
|---|
| 602 | 622 | } |
|---|
| 603 | 623 | |
|---|
| 604 | 624 | clk_base = of_iomap(np, 0); |
|---|
| 605 | 625 | of_node_put(np); |
|---|
| 606 | 626 | if (!clk_base) { |
|---|
| 607 | | - pr_err("%s: failed to map clock registers\n", __func__); |
|---|
| 608 | | - return -EFAULT; |
|---|
| 627 | + dev_err(dev, "failed to map clock registers\n"); |
|---|
| 628 | + result = -EFAULT; |
|---|
| 629 | + goto err_clock; |
|---|
| 609 | 630 | } |
|---|
| 610 | 631 | |
|---|
| 611 | 632 | for_each_compatible_node(np, NULL, "samsung,s5pv210-dmc") { |
|---|
| 612 | 633 | id = of_alias_get_id(np, "dmc"); |
|---|
| 613 | 634 | if (id < 0 || id >= ARRAY_SIZE(dmc_base)) { |
|---|
| 614 | | - pr_err("%s: failed to get alias of dmc node '%s'\n", |
|---|
| 615 | | - __func__, np->name); |
|---|
| 635 | + dev_err(dev, "failed to get alias of dmc node '%pOFn'\n", np); |
|---|
| 616 | 636 | of_node_put(np); |
|---|
| 617 | | - return id; |
|---|
| 637 | + result = id; |
|---|
| 638 | + goto err_clk_base; |
|---|
| 618 | 639 | } |
|---|
| 619 | 640 | |
|---|
| 620 | 641 | dmc_base[id] = of_iomap(np, 0); |
|---|
| 621 | 642 | if (!dmc_base[id]) { |
|---|
| 622 | | - pr_err("%s: failed to map dmc%d registers\n", |
|---|
| 623 | | - __func__, id); |
|---|
| 643 | + dev_err(dev, "failed to map dmc%d registers\n", id); |
|---|
| 624 | 644 | of_node_put(np); |
|---|
| 625 | | - return -EFAULT; |
|---|
| 645 | + result = -EFAULT; |
|---|
| 646 | + goto err_dmc; |
|---|
| 626 | 647 | } |
|---|
| 627 | 648 | } |
|---|
| 628 | 649 | |
|---|
| 629 | 650 | for (id = 0; id < ARRAY_SIZE(dmc_base); ++id) { |
|---|
| 630 | 651 | if (!dmc_base[id]) { |
|---|
| 631 | | - pr_err("%s: failed to find dmc%d node\n", __func__, id); |
|---|
| 632 | | - return -ENODEV; |
|---|
| 652 | + dev_err(dev, "failed to find dmc%d node\n", id); |
|---|
| 653 | + result = -ENODEV; |
|---|
| 654 | + goto err_dmc; |
|---|
| 633 | 655 | } |
|---|
| 634 | | - } |
|---|
| 635 | | - |
|---|
| 636 | | - arm_regulator = regulator_get(NULL, "vddarm"); |
|---|
| 637 | | - if (IS_ERR(arm_regulator)) { |
|---|
| 638 | | - pr_err("failed to get regulator vddarm\n"); |
|---|
| 639 | | - return PTR_ERR(arm_regulator); |
|---|
| 640 | | - } |
|---|
| 641 | | - |
|---|
| 642 | | - int_regulator = regulator_get(NULL, "vddint"); |
|---|
| 643 | | - if (IS_ERR(int_regulator)) { |
|---|
| 644 | | - pr_err("failed to get regulator vddint\n"); |
|---|
| 645 | | - regulator_put(arm_regulator); |
|---|
| 646 | | - return PTR_ERR(int_regulator); |
|---|
| 647 | 656 | } |
|---|
| 648 | 657 | |
|---|
| 649 | 658 | register_reboot_notifier(&s5pv210_cpufreq_reboot_notifier); |
|---|
| 650 | 659 | |
|---|
| 651 | 660 | return cpufreq_register_driver(&s5pv210_driver); |
|---|
| 661 | + |
|---|
| 662 | +err_dmc: |
|---|
| 663 | + for (id = 0; id < ARRAY_SIZE(dmc_base); ++id) |
|---|
| 664 | + if (dmc_base[id]) { |
|---|
| 665 | + iounmap(dmc_base[id]); |
|---|
| 666 | + dmc_base[id] = NULL; |
|---|
| 667 | + } |
|---|
| 668 | + |
|---|
| 669 | +err_clk_base: |
|---|
| 670 | + iounmap(clk_base); |
|---|
| 671 | + |
|---|
| 672 | +err_clock: |
|---|
| 673 | + regulator_put(int_regulator); |
|---|
| 674 | + |
|---|
| 675 | +err_int_regulator: |
|---|
| 676 | + regulator_put(arm_regulator); |
|---|
| 677 | + |
|---|
| 678 | + return result; |
|---|
| 652 | 679 | } |
|---|
| 653 | 680 | |
|---|
| 654 | 681 | static struct platform_driver s5pv210_cpufreq_platdrv = { |
|---|