Commit 0c181b1d authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pm-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management updates from Rafael Wysocki:
 "These are mostly cpufreq updates, including a significant intel-pstate
  driver update and several amd-pstate improvements plus some updates of
  ARM cpufreq drivers, general fixes and cleanups.

  Also included are changes related to system sleep, power capping
  updates adding support for a new platform and a new hardware feature
  (among other things), a Samsung exynos-asv driver update allowing it
  to change its Energy Model after adjusting voltage, minor cpuidle and
  devfreq updates and a small documentation cleanup.

  Specifics:

   - Rework the handling of disabled turbo in the intel_pstate driver
     and make it update the maximum CPU frequency consistently
     regardless of the reason on top of a number of cleanups (Rafael
     Wysocki)

   - Add missing checks for NULL .exit() cpufreq driver callback to the
     cpufreq core (Viresh Kumar)

   - Prevent pulicy->max from going above the frequency QoS maximum
     value when cpufreq_frequency_table_verify() is used (Xuewen Yan)

   - Prevent a negative CPU number or frequency value from being printed
     if they are really large (Joshua Yeong)

   - Update MAINTAINERS entry for amd-pstate to add two new
     submaintainers and a designated reviewer (Huang Rui)

   - Clean up the amd-pstate driver and update its documentation
     (Gautham Shenoy)

   - Fix the highest frequency issue in the amd-pstate driver which
     limits performance (Perry Yuan)

   - Enable CPPC v2 for certain processors in the family 17H, as
     requested by TR40 processor users who expect improved performance
     and lower system temperature (Perry Yuan)

   - Change latency and delay values to be read from platform firmware
     firstly for more accurate timing (Perry Yuan)

   - A new quirk is introduced for supporting amd-pstate on legacy
     processors which either lack CPPC capability, or only only have
     CPPC v2 capability (Perry Yuan)

   - Sun50i cpufreq: Add support for opp_supported_hw, H616 platform and
     general cleanups (Andre Przywara, Martin Botka, Brandon Cheo Fusi,
     Dan Carpenter, Viresh Kumar)

   - CPPC cpufreq: Fix possible null pointer dereference (Aleksandr
     Mishin)

   - Eliminate uses of of_node_put() from cpufreq (Javier Carrasco,
     Shivani Gupta)

   - brcmstb-avs: ISO C90 forbids mixed declarations (Portia Stephens)

   - mediatek cpufreq: Add support for MT7988A (Sam Shih)

   - cpufreq-qcom-hw: Add SM4450 compatibles in DT bindings (Tengfei
     Fan)

   - Fix struct cpudata::epp_cached kernel-doc in the intel_pstate
     cpufreq driver (Jeff Johnson)

   - Fix kerneldoc description of ladder_do_selection() (Jeff Johnson)

   - Convert the cpuidle kirkwood driver to platform remove callback
     returning void (Yangtao Li)

   - Replace deprecated strncpy() with strscpy() in the hibernation core
     code (Justin Stitt)

   - Use %ps to simplify debug output in the core system-wide suspend
     and resume code (Len Brown)

   - Remove unnecessary else from device_init_wakeup() and make
     device_wakeup_disable() return void (Dhruva Gole)

   - Enable PMU support in the Intel TPMI RAPL driver (Zhang Rui)

   - Add support for ArrowLake-H platform to the Intel RAPL driver
     (Zhang Rui)

   - Avoid explicit cpumask allocation on stack in DTPM (Dawei Li)

   - Make the Samsung exynos-asv driver update the Energy Model after
     adjusting voltage on top of some preliminary changes of the OPP and
     Enery Model generic code (Lukasz Luba)

   - Remove a reference to a function that has been dropped from the
     power management documentation (Bjorn Helgaas)

   - Convert the platfrom remove callback to .remove_new for the
     exyno-nocp, exynos-ppmu, mtk-cci-devfreq, sun8i-a33-mbus, and
     rk3399_dmc devfreq drivers (Uwe Kleine-König)

   - Use DEFINE_SIMPLE_PM_OPS for exyno-bus.c driver (Anand Moon)"

* tag 'pm-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (68 commits)
  PM / devfreq: exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  PM / devfreq: rk3399_dmc: Convert to platform remove callback returning void
  PM / devfreq: sun8i-a33-mbus: Convert to platform remove callback returning void
  PM / devfreq: mtk-cci: Convert to platform remove callback returning void
  PM / devfreq: exynos-ppmu: Convert to platform remove callback returning void
  PM / devfreq: exynos-nocp: Convert to platform remove callback returning void
  cpufreq: amd-pstate: fix the highest frequency issue which limits performance
  cpufreq: intel_pstate: fix struct cpudata::epp_cached kernel-doc
  cpuidle: ladder: fix ladder_do_selection() kernel-doc
  powercap: intel_rapl_tpmi: Enable PMU support
  powercap: intel_rapl: Introduce APIs for PMU support
  PM: hibernate: replace deprecated strncpy() with strscpy()
  cpufreq: Fix up printing large CPU numbers and frequency values
  MAINTAINERS: cpufreq: amd-pstate: Add co-maintainers and reviewer
  cpufreq: amd-pstate: remove unused variable lowest_nonlinear_freq
  cpufreq: amd-pstate: fix code format problems
  cpufreq: amd-pstate: Add quirk for the pstate CPPC capabilities missing
  cppc_acpi: print error message if CPPC is unsupported
  cpufreq: amd-pstate: get transition delay and latency value from ACPI tables
  cpufreq: amd-pstate: Bail out if min/max/nominal_freq is 0
  ...
parents f952b6c8 de1c2722
...@@ -38,6 +38,7 @@ properties: ...@@ -38,6 +38,7 @@ properties:
- qcom,sc7280-cpufreq-epss - qcom,sc7280-cpufreq-epss
- qcom,sc8280xp-cpufreq-epss - qcom,sc8280xp-cpufreq-epss
- qcom,sdx75-cpufreq-epss - qcom,sdx75-cpufreq-epss
- qcom,sm4450-cpufreq-epss
- qcom,sm6375-cpufreq-epss - qcom,sm6375-cpufreq-epss
- qcom,sm8250-cpufreq-epss - qcom,sm8250-cpufreq-epss
- qcom,sm8350-cpufreq-epss - qcom,sm8350-cpufreq-epss
...@@ -133,6 +134,7 @@ allOf: ...@@ -133,6 +134,7 @@ allOf:
- qcom,sc8280xp-cpufreq-epss - qcom,sc8280xp-cpufreq-epss
- qcom,sdm670-cpufreq-hw - qcom,sdm670-cpufreq-hw
- qcom,sdm845-cpufreq-hw - qcom,sdm845-cpufreq-hw
- qcom,sm4450-cpufreq-epss
- qcom,sm6115-cpufreq-hw - qcom,sm6115-cpufreq-hw
- qcom,sm6350-cpufreq-hw - qcom,sm6350-cpufreq-hw
- qcom,sm6375-cpufreq-epss - qcom,sm6375-cpufreq-epss
......
...@@ -13,25 +13,25 @@ maintainers: ...@@ -13,25 +13,25 @@ maintainers:
description: | description: |
For some SoCs, the CPU frequency subset and voltage value of each For some SoCs, the CPU frequency subset and voltage value of each
OPP varies based on the silicon variant in use. Allwinner Process OPP varies based on the silicon variant in use. Allwinner Process
Voltage Scaling Tables defines the voltage and frequency value based Voltage Scaling Tables define the voltage and frequency values based
on the speedbin blown in the efuse combination. The on the speedbin blown in the efuse combination.
sun50i-cpufreq-nvmem driver reads the efuse value from the SoC to
provide the OPP framework with required information.
allOf: allOf:
- $ref: opp-v2-base.yaml# - $ref: opp-v2-base.yaml#
properties: properties:
compatible: compatible:
const: allwinner,sun50i-h6-operating-points enum:
- allwinner,sun50i-h6-operating-points
- allwinner,sun50i-h616-operating-points
nvmem-cells: nvmem-cells:
description: | description: |
A phandle pointing to a nvmem-cells node representing the efuse A phandle pointing to a nvmem-cells node representing the efuse
registers that has information about the speedbin that is used register that has information about the speedbin that is used
to select the right frequency/voltage value pair. Please refer to select the right frequency/voltage value pair. Please refer
the for nvmem-cells bindings to the nvmem-cells bindings in
Documentation/devicetree/bindings/nvmem/nvmem.txt and also Documentation/devicetree/bindings/nvmem/nvmem.yaml and also the
examples below. examples below.
opp-shared: true opp-shared: true
...@@ -47,15 +47,18 @@ patternProperties: ...@@ -47,15 +47,18 @@ patternProperties:
properties: properties:
opp-hz: true opp-hz: true
clock-latency-ns: true clock-latency-ns: true
opp-microvolt: true
opp-supported-hw:
maxItems: 1
description:
A single 32 bit bitmap value, representing compatible HW, one
bit per speed bin index.
patternProperties: patternProperties:
"^opp-microvolt-speed[0-9]$": true "^opp-microvolt-speed[0-9]$": true
required: required:
- opp-hz - opp-hz
- opp-microvolt-speed0
- opp-microvolt-speed1
- opp-microvolt-speed2
unevaluatedProperties: false unevaluatedProperties: false
...@@ -77,58 +80,54 @@ examples: ...@@ -77,58 +80,54 @@ examples:
opp-microvolt-speed2 = <800000>; opp-microvolt-speed2 = <800000>;
}; };
opp-720000000 { opp-1080000000 {
clock-latency-ns = <244144>; /* 8 32k periods */ clock-latency-ns = <244144>; /* 8 32k periods */
opp-hz = /bits/ 64 <720000000>; opp-hz = /bits/ 64 <1080000000>;
opp-microvolt-speed0 = <880000>; opp-microvolt-speed0 = <1060000>;
opp-microvolt-speed1 = <820000>; opp-microvolt-speed1 = <880000>;
opp-microvolt-speed2 = <800000>; opp-microvolt-speed2 = <840000>;
}; };
opp-816000000 { opp-1488000000 {
clock-latency-ns = <244144>; /* 8 32k periods */ clock-latency-ns = <244144>; /* 8 32k periods */
opp-hz = /bits/ 64 <816000000>; opp-hz = /bits/ 64 <1488000000>;
opp-microvolt-speed0 = <880000>; opp-microvolt-speed0 = <1160000>;
opp-microvolt-speed1 = <820000>; opp-microvolt-speed1 = <1000000>;
opp-microvolt-speed2 = <800000>; opp-microvolt-speed2 = <960000>;
}; };
};
opp-888000000 { - |
clock-latency-ns = <244144>; /* 8 32k periods */ opp-table {
opp-hz = /bits/ 64 <888000000>; compatible = "allwinner,sun50i-h616-operating-points";
nvmem-cells = <&speedbin_efuse>;
opp-microvolt-speed0 = <940000>; opp-shared;
opp-microvolt-speed1 = <820000>;
opp-microvolt-speed2 = <800000>;
};
opp-1080000000 { opp-480000000 {
clock-latency-ns = <244144>; /* 8 32k periods */ clock-latency-ns = <244144>; /* 8 32k periods */
opp-hz = /bits/ 64 <1080000000>; opp-hz = /bits/ 64 <480000000>;
opp-microvolt-speed0 = <1060000>; opp-microvolt = <900000>;
opp-microvolt-speed1 = <880000>; opp-supported-hw = <0x1f>;
opp-microvolt-speed2 = <840000>;
}; };
opp-1320000000 { opp-792000000 {
clock-latency-ns = <244144>; /* 8 32k periods */ clock-latency-ns = <244144>; /* 8 32k periods */
opp-hz = /bits/ 64 <1320000000>; opp-hz = /bits/ 64 <792000000>;
opp-microvolt-speed0 = <1160000>; opp-microvolt-speed1 = <900000>;
opp-microvolt-speed1 = <940000>; opp-microvolt-speed4 = <940000>;
opp-microvolt-speed2 = <900000>; opp-supported-hw = <0x12>;
}; };
opp-1488000000 { opp-1512000000 {
clock-latency-ns = <244144>; /* 8 32k periods */ clock-latency-ns = <244144>; /* 8 32k periods */
opp-hz = /bits/ 64 <1488000000>; opp-hz = /bits/ 64 <1512000000>;
opp-microvolt-speed0 = <1160000>; opp-microvolt = <1100000>;
opp-microvolt-speed1 = <1000000>; opp-supported-hw = <0x0a>;
opp-microvolt-speed2 = <960000>;
}; };
}; };
......
...@@ -333,7 +333,7 @@ struct pci_dev. ...@@ -333,7 +333,7 @@ struct pci_dev.
The PCI subsystem's first task related to device power management is to The PCI subsystem's first task related to device power management is to
prepare the device for power management and initialize the fields of struct prepare the device for power management and initialize the fields of struct
pci_dev used for this purpose. This happens in two functions defined in pci_dev used for this purpose. This happens in two functions defined in
drivers/pci/pci.c, pci_pm_init() and platform_pci_wakeup_init(). drivers/pci/, pci_pm_init() and pci_acpi_setup().
The first of these functions checks if the device supports native PCI PM The first of these functions checks if the device supports native PCI PM
and if that's the case the offset of its power management capability structure and if that's the case the offset of its power management capability structure
......
...@@ -1062,6 +1062,9 @@ F: drivers/gpu/drm/amd/pm/ ...@@ -1062,6 +1062,9 @@ F: drivers/gpu/drm/amd/pm/
AMD PSTATE DRIVER AMD PSTATE DRIVER
M: Huang Rui <ray.huang@amd.com> M: Huang Rui <ray.huang@amd.com>
M: Gautham R. Shenoy <gautham.shenoy@amd.com>
M: Mario Limonciello <mario.limonciello@amd.com>
R: Perry Yuan <perry.yuan@amd.com>
L: linux-pm@vger.kernel.org L: linux-pm@vger.kernel.org
S: Supported S: Supported
F: Documentation/admin-guide/pm/amd-pstate.rst F: Documentation/admin-guide/pm/amd-pstate.rst
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
/dts-v1/; /dts-v1/;
#include "sun50i-h616.dtsi" #include "sun50i-h616.dtsi"
#include "sun50i-h616-cpu-opp.dtsi"
#include <dt-bindings/gpio/gpio.h> #include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/interrupt-controller/arm-gic.h>
...@@ -62,6 +63,10 @@ wifi_pwrseq: wifi-pwrseq { ...@@ -62,6 +63,10 @@ wifi_pwrseq: wifi-pwrseq {
}; };
}; };
&cpu0 {
cpu-supply = <&reg_dcdc2>;
};
&mmc0 { &mmc0 {
vmmc-supply = <&reg_dldo1>; vmmc-supply = <&reg_dldo1>;
/* Card detection pin is not connected */ /* Card detection pin is not connected */
......
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
// Copyright (C) 2023 Martin Botka <martin@somainline.org>
/ {
cpu_opp_table: opp-table-cpu {
compatible = "allwinner,sun50i-h616-operating-points";
nvmem-cells = <&cpu_speed_grade>;
opp-shared;
opp-480000000 {
opp-hz = /bits/ 64 <480000000>;
opp-microvolt = <900000>;
clock-latency-ns = <244144>; /* 8 32k periods */
opp-supported-hw = <0x1f>;
};
opp-600000000 {
opp-hz = /bits/ 64 <600000000>;
opp-microvolt = <900000>;
clock-latency-ns = <244144>; /* 8 32k periods */
opp-supported-hw = <0x12>;
};
opp-720000000 {
opp-hz = /bits/ 64 <720000000>;
opp-microvolt = <900000>;
clock-latency-ns = <244144>; /* 8 32k periods */
opp-supported-hw = <0x0d>;
};
opp-792000000 {
opp-hz = /bits/ 64 <792000000>;
opp-microvolt-speed1 = <900000>;
opp-microvolt-speed4 = <940000>;
clock-latency-ns = <244144>; /* 8 32k periods */
opp-supported-hw = <0x12>;
};
opp-936000000 {
opp-hz = /bits/ 64 <936000000>;
opp-microvolt = <900000>;
clock-latency-ns = <244144>; /* 8 32k periods */
opp-supported-hw = <0x0d>;
};
opp-1008000000 {
opp-hz = /bits/ 64 <1008000000>;
opp-microvolt-speed0 = <950000>;
opp-microvolt-speed1 = <940000>;
opp-microvolt-speed2 = <950000>;
opp-microvolt-speed3 = <950000>;
opp-microvolt-speed4 = <1020000>;
clock-latency-ns = <244144>; /* 8 32k periods */
opp-supported-hw = <0x1f>;
};
opp-1104000000 {
opp-hz = /bits/ 64 <1104000000>;
opp-microvolt-speed0 = <1000000>;
opp-microvolt-speed2 = <1000000>;
opp-microvolt-speed3 = <1000000>;
clock-latency-ns = <244144>; /* 8 32k periods */
opp-supported-hw = <0x0d>;
};
opp-1200000000 {
opp-hz = /bits/ 64 <1200000000>;
opp-microvolt-speed0 = <1050000>;
opp-microvolt-speed1 = <1020000>;
opp-microvolt-speed2 = <1050000>;
opp-microvolt-speed3 = <1050000>;
opp-microvolt-speed4 = <1100000>;
clock-latency-ns = <244144>; /* 8 32k periods */
opp-supported-hw = <0x1f>;
};
opp-1320000000 {
opp-hz = /bits/ 64 <1320000000>;
opp-microvolt = <1100000>;
clock-latency-ns = <244144>; /* 8 32k periods */
opp-supported-hw = <0x1d>;
};
opp-1416000000 {
opp-hz = /bits/ 64 <1416000000>;
opp-microvolt = <1100000>;
clock-latency-ns = <244144>; /* 8 32k periods */
opp-supported-hw = <0x0d>;
};
opp-1512000000 {
opp-hz = /bits/ 64 <1512000000>;
opp-microvolt-speed1 = <1100000>;
opp-microvolt-speed3 = <1100000>;
clock-latency-ns = <244144>; /* 8 32k periods */
opp-supported-hw = <0x0a>;
};
};
};
&cpu0 {
operating-points-v2 = <&cpu_opp_table>;
};
&cpu1 {
operating-points-v2 = <&cpu_opp_table>;
};
&cpu2 {
operating-points-v2 = <&cpu_opp_table>;
};
&cpu3 {
operating-points-v2 = <&cpu_opp_table>;
};
...@@ -6,12 +6,17 @@ ...@@ -6,12 +6,17 @@
/dts-v1/; /dts-v1/;
#include "sun50i-h616-orangepi-zero.dtsi" #include "sun50i-h616-orangepi-zero.dtsi"
#include "sun50i-h616-cpu-opp.dtsi"
/ { / {
model = "OrangePi Zero2"; model = "OrangePi Zero2";
compatible = "xunlong,orangepi-zero2", "allwinner,sun50i-h616"; compatible = "xunlong,orangepi-zero2", "allwinner,sun50i-h616";
}; };
&cpu0 {
cpu-supply = <&reg_dcdca>;
};
&emac0 { &emac0 {
allwinner,rx-delay-ps = <3100>; allwinner,rx-delay-ps = <3100>;
allwinner,tx-delay-ps = <700>; allwinner,tx-delay-ps = <700>;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
/dts-v1/; /dts-v1/;
#include "sun50i-h616.dtsi" #include "sun50i-h616.dtsi"
#include "sun50i-h616-cpu-opp.dtsi"
#include <dt-bindings/gpio/gpio.h> #include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/interrupt-controller/arm-gic.h>
...@@ -32,6 +33,10 @@ reg_vcc5v: vcc5v { ...@@ -32,6 +33,10 @@ reg_vcc5v: vcc5v {
}; };
}; };
&cpu0 {
cpu-supply = <&reg_dcdca>;
};
&ehci0 { &ehci0 {
status = "okay"; status = "okay";
}; };
......
...@@ -26,6 +26,7 @@ cpu0: cpu@0 { ...@@ -26,6 +26,7 @@ cpu0: cpu@0 {
reg = <0>; reg = <0>;
enable-method = "psci"; enable-method = "psci";
clocks = <&ccu CLK_CPUX>; clocks = <&ccu CLK_CPUX>;
#cooling-cells = <2>;
}; };
cpu1: cpu@1 { cpu1: cpu@1 {
...@@ -34,6 +35,7 @@ cpu1: cpu@1 { ...@@ -34,6 +35,7 @@ cpu1: cpu@1 {
reg = <1>; reg = <1>;
enable-method = "psci"; enable-method = "psci";
clocks = <&ccu CLK_CPUX>; clocks = <&ccu CLK_CPUX>;
#cooling-cells = <2>;
}; };
cpu2: cpu@2 { cpu2: cpu@2 {
...@@ -42,6 +44,7 @@ cpu2: cpu@2 { ...@@ -42,6 +44,7 @@ cpu2: cpu@2 {
reg = <2>; reg = <2>;
enable-method = "psci"; enable-method = "psci";
clocks = <&ccu CLK_CPUX>; clocks = <&ccu CLK_CPUX>;
#cooling-cells = <2>;
}; };
cpu3: cpu@3 { cpu3: cpu@3 {
...@@ -50,6 +53,7 @@ cpu3: cpu@3 { ...@@ -50,6 +53,7 @@ cpu3: cpu@3 {
reg = <3>; reg = <3>;
enable-method = "psci"; enable-method = "psci";
clocks = <&ccu CLK_CPUX>; clocks = <&ccu CLK_CPUX>;
#cooling-cells = <2>;
}; };
}; };
...@@ -156,6 +160,10 @@ sid: efuse@3006000 { ...@@ -156,6 +160,10 @@ sid: efuse@3006000 {
ths_calibration: thermal-sensor-calibration@14 { ths_calibration: thermal-sensor-calibration@14 {
reg = <0x14 0x8>; reg = <0x14 0x8>;
}; };
cpu_speed_grade: cpu-speed-grade@0 {
reg = <0x0 2>;
};
}; };
watchdog: watchdog@30090a0 { watchdog: watchdog@30090a0 {
......
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
*/ */
#include "sun50i-h616.dtsi" #include "sun50i-h616.dtsi"
#include "sun50i-h616-cpu-opp.dtsi"
&cpu0 {
cpu-supply = <&reg_dcdc2>;
};
&mmc2 { &mmc2 {
pinctrl-names = "default"; pinctrl-names = "default";
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
/dts-v1/; /dts-v1/;
#include "sun50i-h616.dtsi" #include "sun50i-h616.dtsi"
#include "sun50i-h616-cpu-opp.dtsi"
#include <dt-bindings/gpio/gpio.h> #include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/interrupt-controller/arm-gic.h>
...@@ -53,6 +54,10 @@ reg_vcc3v3: vcc3v3 { ...@@ -53,6 +54,10 @@ reg_vcc3v3: vcc3v3 {
}; };
}; };
&cpu0 {
cpu-supply = <&reg_dcdc2>;
};
&ehci1 { &ehci1 {
status = "okay"; status = "okay";
}; };
......
...@@ -6,12 +6,17 @@ ...@@ -6,12 +6,17 @@
/dts-v1/; /dts-v1/;
#include "sun50i-h616-orangepi-zero.dtsi" #include "sun50i-h616-orangepi-zero.dtsi"
#include "sun50i-h616-cpu-opp.dtsi"
/ { / {
model = "OrangePi Zero3"; model = "OrangePi Zero3";
compatible = "xunlong,orangepi-zero3", "allwinner,sun50i-h618"; compatible = "xunlong,orangepi-zero3", "allwinner,sun50i-h618";
}; };
&cpu0 {
cpu-supply = <&reg_dcdc2>;
};
&emac0 { &emac0 {
allwinner,tx-delay-ps = <700>; allwinner,tx-delay-ps = <700>;
phy-mode = "rgmii-rxid"; phy-mode = "rgmii-rxid";
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
/dts-v1/; /dts-v1/;
#include "sun50i-h616.dtsi" #include "sun50i-h616.dtsi"
#include "sun50i-h616-cpu-opp.dtsi"
#include <dt-bindings/gpio/gpio.h> #include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/interrupt-controller/arm-gic.h>
...@@ -51,6 +52,10 @@ wifi_pwrseq: pwrseq { ...@@ -51,6 +52,10 @@ wifi_pwrseq: pwrseq {
}; };
}; };
&cpu0 {
cpu-supply = <&reg_dcdc2>;
};
&ehci0 { &ehci0 {
status = "okay"; status = "okay";
}; };
......
...@@ -686,8 +686,10 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) ...@@ -686,8 +686,10 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
if (!osc_sb_cppc2_support_acked) { if (!osc_sb_cppc2_support_acked) {
pr_debug("CPPC v2 _OSC not acked\n"); pr_debug("CPPC v2 _OSC not acked\n");
if (!cpc_supported_by_cpu()) if (!cpc_supported_by_cpu()) {
pr_debug("CPPC is not supported by the CPU\n");
return -ENODEV; return -ENODEV;
}
} }
/* Parse the ACPI _CPC table for this CPU. */ /* Parse the ACPI _CPC table for this CPU. */
......
...@@ -208,7 +208,7 @@ static ktime_t initcall_debug_start(struct device *dev, void *cb) ...@@ -208,7 +208,7 @@ static ktime_t initcall_debug_start(struct device *dev, void *cb)
if (!pm_print_times_enabled) if (!pm_print_times_enabled)
return 0; return 0;
dev_info(dev, "calling %pS @ %i, parent: %s\n", cb, dev_info(dev, "calling %ps @ %i, parent: %s\n", cb,
task_pid_nr(current), task_pid_nr(current),
dev->parent ? dev_name(dev->parent) : "none"); dev->parent ? dev_name(dev->parent) : "none");
return ktime_get(); return ktime_get();
...@@ -223,7 +223,7 @@ static void initcall_debug_report(struct device *dev, ktime_t calltime, ...@@ -223,7 +223,7 @@ static void initcall_debug_report(struct device *dev, ktime_t calltime,
return; return;
rettime = ktime_get(); rettime = ktime_get();
dev_info(dev, "%pS returned %d after %Ld usecs\n", cb, error, dev_info(dev, "%ps returned %d after %Ld usecs\n", cb, error,
(unsigned long long)ktime_us_delta(rettime, calltime)); (unsigned long long)ktime_us_delta(rettime, calltime));
} }
...@@ -1927,7 +1927,7 @@ EXPORT_SYMBOL_GPL(dpm_suspend_start); ...@@ -1927,7 +1927,7 @@ EXPORT_SYMBOL_GPL(dpm_suspend_start);
void __suspend_report_result(const char *function, struct device *dev, void *fn, int ret) void __suspend_report_result(const char *function, struct device *dev, void *fn, int ret)
{ {
if (ret) if (ret)
dev_err(dev, "%s(): %pS returns %d\n", function, fn, ret); dev_err(dev, "%s(): %ps returns %d\n", function, fn, ret);
} }
EXPORT_SYMBOL_GPL(__suspend_report_result); EXPORT_SYMBOL_GPL(__suspend_report_result);
......
...@@ -451,16 +451,15 @@ static struct wakeup_source *device_wakeup_detach(struct device *dev) ...@@ -451,16 +451,15 @@ static struct wakeup_source *device_wakeup_detach(struct device *dev)
* Detach the @dev's wakeup source object from it, unregister this wakeup source * Detach the @dev's wakeup source object from it, unregister this wakeup source
* object and destroy it. * object and destroy it.
*/ */
int device_wakeup_disable(struct device *dev) void device_wakeup_disable(struct device *dev)
{ {
struct wakeup_source *ws; struct wakeup_source *ws;
if (!dev || !dev->power.can_wakeup) if (!dev || !dev->power.can_wakeup)
return -EINVAL; return;
ws = device_wakeup_detach(dev); ws = device_wakeup_detach(dev);
wakeup_source_unregister(ws); wakeup_source_unregister(ws);
return 0;
} }
EXPORT_SYMBOL_GPL(device_wakeup_disable); EXPORT_SYMBOL_GPL(device_wakeup_disable);
...@@ -502,7 +501,11 @@ EXPORT_SYMBOL_GPL(device_set_wakeup_capable); ...@@ -502,7 +501,11 @@ EXPORT_SYMBOL_GPL(device_set_wakeup_capable);
*/ */
int device_set_wakeup_enable(struct device *dev, bool enable) int device_set_wakeup_enable(struct device *dev, bool enable)
{ {
return enable ? device_wakeup_enable(dev) : device_wakeup_disable(dev); if (enable)
return device_wakeup_enable(dev);
device_wakeup_disable(dev);
return 0;
} }
EXPORT_SYMBOL_GPL(device_set_wakeup_enable); EXPORT_SYMBOL_GPL(device_set_wakeup_enable);
......
This diff is collapsed.
...@@ -481,9 +481,12 @@ static bool brcm_avs_is_firmware_loaded(struct private_data *priv) ...@@ -481,9 +481,12 @@ static bool brcm_avs_is_firmware_loaded(struct private_data *priv)
static unsigned int brcm_avs_cpufreq_get(unsigned int cpu) static unsigned int brcm_avs_cpufreq_get(unsigned int cpu)
{ {
struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
struct private_data *priv;
if (!policy) if (!policy)
return 0; return 0;
struct private_data *priv = policy->driver_data;
priv = policy->driver_data;
cpufreq_cpu_put(policy); cpufreq_cpu_put(policy);
......
...@@ -741,10 +741,15 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu) ...@@ -741,10 +741,15 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu)
{ {
struct cppc_perf_fb_ctrs fb_ctrs_t0 = {0}, fb_ctrs_t1 = {0}; struct cppc_perf_fb_ctrs fb_ctrs_t0 = {0}, fb_ctrs_t1 = {0};
struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
struct cppc_cpudata *cpu_data = policy->driver_data; struct cppc_cpudata *cpu_data;
u64 delivered_perf; u64 delivered_perf;
int ret; int ret;
if (!policy)
return -ENODEV;
cpu_data = policy->driver_data;
cpufreq_cpu_put(policy); cpufreq_cpu_put(policy);
ret = cppc_get_perf_ctrs(cpu, &fb_ctrs_t0); ret = cppc_get_perf_ctrs(cpu, &fb_ctrs_t0);
...@@ -822,10 +827,15 @@ static struct cpufreq_driver cppc_cpufreq_driver = { ...@@ -822,10 +827,15 @@ static struct cpufreq_driver cppc_cpufreq_driver = {
static unsigned int hisi_cppc_cpufreq_get_rate(unsigned int cpu) static unsigned int hisi_cppc_cpufreq_get_rate(unsigned int cpu)
{ {
struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
struct cppc_cpudata *cpu_data = policy->driver_data; struct cppc_cpudata *cpu_data;
u64 desired_perf; u64 desired_perf;
int ret; int ret;
if (!policy)
return -ENODEV;
cpu_data = policy->driver_data;
cpufreq_cpu_put(policy); cpufreq_cpu_put(policy);
ret = cppc_get_desired_perf(cpu, &desired_perf); ret = cppc_get_desired_perf(cpu, &desired_perf);
......
...@@ -104,6 +104,9 @@ static const struct of_device_id allowlist[] __initconst = { ...@@ -104,6 +104,9 @@ static const struct of_device_id allowlist[] __initconst = {
*/ */
static const struct of_device_id blocklist[] __initconst = { static const struct of_device_id blocklist[] __initconst = {
{ .compatible = "allwinner,sun50i-h6", }, { .compatible = "allwinner,sun50i-h6", },
{ .compatible = "allwinner,sun50i-h616", },
{ .compatible = "allwinner,sun50i-h618", },
{ .compatible = "allwinner,sun50i-h700", },
{ .compatible = "apple,arm-platform", }, { .compatible = "apple,arm-platform", },
...@@ -195,19 +198,18 @@ static const struct of_device_id blocklist[] __initconst = { ...@@ -195,19 +198,18 @@ static const struct of_device_id blocklist[] __initconst = {
static bool __init cpu0_node_has_opp_v2_prop(void) static bool __init cpu0_node_has_opp_v2_prop(void)
{ {
struct device_node *np = of_cpu_device_node_get(0); struct device_node *np __free(device_node) = of_cpu_device_node_get(0);
bool ret = false; bool ret = false;
if (of_property_present(np, "operating-points-v2")) if (of_property_present(np, "operating-points-v2"))
ret = true; ret = true;
of_node_put(np);
return ret; return ret;
} }
static int __init cpufreq_dt_platdev_init(void) static int __init cpufreq_dt_platdev_init(void)
{ {
struct device_node *np = of_find_node_by_path("/"); struct device_node *np __free(device_node) = of_find_node_by_path("/");
const struct of_device_id *match; const struct of_device_id *match;
const void *data = NULL; const void *data = NULL;
...@@ -223,11 +225,9 @@ static int __init cpufreq_dt_platdev_init(void) ...@@ -223,11 +225,9 @@ static int __init cpufreq_dt_platdev_init(void)
if (cpu0_node_has_opp_v2_prop() && !of_match_node(blocklist, np)) if (cpu0_node_has_opp_v2_prop() && !of_match_node(blocklist, np))
goto create_pdev; goto create_pdev;
of_node_put(np);
return -ENODEV; return -ENODEV;
create_pdev: create_pdev:
of_node_put(np);
return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt", return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt",
-1, data, -1, data,
sizeof(struct cpufreq_dt_platform_data))); sizeof(struct cpufreq_dt_platform_data)));
......
...@@ -68,12 +68,9 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index) ...@@ -68,12 +68,9 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
*/ */
static const char *find_supply_name(struct device *dev) static const char *find_supply_name(struct device *dev)
{ {
struct device_node *np; struct device_node *np __free(device_node) = of_node_get(dev->of_node);
struct property *pp; struct property *pp;
int cpu = dev->id; int cpu = dev->id;
const char *name = NULL;
np = of_node_get(dev->of_node);
/* This must be valid for sure */ /* This must be valid for sure */
if (WARN_ON(!np)) if (WARN_ON(!np))
...@@ -82,22 +79,16 @@ static const char *find_supply_name(struct device *dev) ...@@ -82,22 +79,16 @@ static const char *find_supply_name(struct device *dev)
/* Try "cpu0" for older DTs */ /* Try "cpu0" for older DTs */
if (!cpu) { if (!cpu) {
pp = of_find_property(np, "cpu0-supply", NULL); pp = of_find_property(np, "cpu0-supply", NULL);
if (pp) { if (pp)
name = "cpu0"; return "cpu0";
goto node_put;
}
} }
pp = of_find_property(np, "cpu-supply", NULL); pp = of_find_property(np, "cpu-supply", NULL);
if (pp) { if (pp)
name = "cpu"; return "cpu";
goto node_put;
}
dev_dbg(dev, "no regulator for cpu%d\n", cpu); dev_dbg(dev, "no regulator for cpu%d\n", cpu);
node_put: return NULL;
of_node_put(np);
return name;
} }
static int cpufreq_init(struct cpufreq_policy *policy) static int cpufreq_init(struct cpufreq_policy *policy)
......
...@@ -1679,10 +1679,13 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy) ...@@ -1679,10 +1679,13 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy)
*/ */
if (cpufreq_driver->offline) { if (cpufreq_driver->offline) {
cpufreq_driver->offline(policy); cpufreq_driver->offline(policy);
} else if (cpufreq_driver->exit) { return;
cpufreq_driver->exit(policy);
policy->freq_table = NULL;
} }
if (cpufreq_driver->exit)
cpufreq_driver->exit(policy);
policy->freq_table = NULL;
} }
static int cpufreq_offline(unsigned int cpu) static int cpufreq_offline(unsigned int cpu)
...@@ -1740,7 +1743,7 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) ...@@ -1740,7 +1743,7 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
} }
/* We did light-weight exit earlier, do full tear down now */ /* We did light-weight exit earlier, do full tear down now */
if (cpufreq_driver->offline) if (cpufreq_driver->offline && cpufreq_driver->exit)
cpufreq_driver->exit(policy); cpufreq_driver->exit(policy);
up_write(&policy->rwsem); up_write(&policy->rwsem);
......
...@@ -70,7 +70,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy, ...@@ -70,7 +70,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy,
struct cpufreq_frequency_table *table) struct cpufreq_frequency_table *table)
{ {
struct cpufreq_frequency_table *pos; struct cpufreq_frequency_table *pos;
unsigned int freq, next_larger = ~0; unsigned int freq, prev_smaller = 0;
bool found = false; bool found = false;
pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n",
...@@ -86,12 +86,12 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy, ...@@ -86,12 +86,12 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy,
break; break;
} }
if ((next_larger > freq) && (freq > policy->max)) if ((prev_smaller < freq) && (freq <= policy->max))
next_larger = freq; prev_smaller = freq;
} }
if (!found) { if (!found) {
policy->max = next_larger; policy->max = prev_smaller;
cpufreq_verify_within_cpu_limits(policy); cpufreq_verify_within_cpu_limits(policy);
} }
...@@ -194,7 +194,7 @@ int cpufreq_table_index_unsorted(struct cpufreq_policy *policy, ...@@ -194,7 +194,7 @@ int cpufreq_table_index_unsorted(struct cpufreq_policy *policy,
} }
if (optimal.driver_data > i) { if (optimal.driver_data > i) {
if (suboptimal.driver_data > i) { if (suboptimal.driver_data > i) {
WARN(1, "Invalid frequency table: %d\n", policy->cpu); WARN(1, "Invalid frequency table: %u\n", policy->cpu);
return 0; return 0;
} }
...@@ -254,7 +254,7 @@ static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf, ...@@ -254,7 +254,7 @@ static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf,
if (show_boost ^ (pos->flags & CPUFREQ_BOOST_FREQ)) if (show_boost ^ (pos->flags & CPUFREQ_BOOST_FREQ))
continue; continue;
count += sprintf(&buf[count], "%d ", pos->frequency); count += sprintf(&buf[count], "%u ", pos->frequency);
} }
count += sprintf(&buf[count], "\n"); count += sprintf(&buf[count], "\n");
......
This diff is collapsed.
...@@ -707,6 +707,15 @@ static const struct mtk_cpufreq_platform_data mt7623_platform_data = { ...@@ -707,6 +707,15 @@ static const struct mtk_cpufreq_platform_data mt7623_platform_data = {
.ccifreq_supported = false, .ccifreq_supported = false,
}; };
static const struct mtk_cpufreq_platform_data mt7988_platform_data = {
.min_volt_shift = 100000,
.max_volt_shift = 200000,
.proc_max_volt = 900000,
.sram_min_volt = 0,
.sram_max_volt = 1150000,
.ccifreq_supported = true,
};
static const struct mtk_cpufreq_platform_data mt8183_platform_data = { static const struct mtk_cpufreq_platform_data mt8183_platform_data = {
.min_volt_shift = 100000, .min_volt_shift = 100000,
.max_volt_shift = 200000, .max_volt_shift = 200000,
...@@ -740,6 +749,7 @@ static const struct of_device_id mtk_cpufreq_machines[] __initconst = { ...@@ -740,6 +749,7 @@ static const struct of_device_id mtk_cpufreq_machines[] __initconst = {
{ .compatible = "mediatek,mt2712", .data = &mt2701_platform_data }, { .compatible = "mediatek,mt2712", .data = &mt2701_platform_data },
{ .compatible = "mediatek,mt7622", .data = &mt7622_platform_data }, { .compatible = "mediatek,mt7622", .data = &mt7622_platform_data },
{ .compatible = "mediatek,mt7623", .data = &mt7623_platform_data }, { .compatible = "mediatek,mt7623", .data = &mt7623_platform_data },
{ .compatible = "mediatek,mt7988a", .data = &mt7988_platform_data },
{ .compatible = "mediatek,mt8167", .data = &mt8516_platform_data }, { .compatible = "mediatek,mt8167", .data = &mt8516_platform_data },
{ .compatible = "mediatek,mt817x", .data = &mt2701_platform_data }, { .compatible = "mediatek,mt817x", .data = &mt2701_platform_data },
{ .compatible = "mediatek,mt8173", .data = &mt2701_platform_data }, { .compatible = "mediatek,mt8173", .data = &mt2701_platform_data },
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/arm-smccc.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/nvmem-consumer.h> #include <linux/nvmem-consumer.h>
...@@ -18,26 +19,155 @@ ...@@ -18,26 +19,155 @@
#include <linux/pm_opp.h> #include <linux/pm_opp.h>
#include <linux/slab.h> #include <linux/slab.h>
#define MAX_NAME_LEN 7
#define NVMEM_MASK 0x7 #define NVMEM_MASK 0x7
#define NVMEM_SHIFT 5 #define NVMEM_SHIFT 5
static struct platform_device *cpufreq_dt_pdev, *sun50i_cpufreq_pdev; static struct platform_device *cpufreq_dt_pdev, *sun50i_cpufreq_pdev;
struct sunxi_cpufreq_data {
u32 (*efuse_xlate)(u32 speedbin);
};
static u32 sun50i_h6_efuse_xlate(u32 speedbin)
{
u32 efuse_value;
efuse_value = (speedbin >> NVMEM_SHIFT) & NVMEM_MASK;
/*
* We treat unexpected efuse values as if the SoC was from
* the slowest bin. Expected efuse values are 1-3, slowest
* to fastest.
*/
if (efuse_value >= 1 && efuse_value <= 3)
return efuse_value - 1;
else
return 0;
}
static int get_soc_id_revision(void)
{
#ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY
return arm_smccc_get_soc_id_revision();
#else
return SMCCC_RET_NOT_SUPPORTED;
#endif
}
/*
* Judging by the OPP tables in the vendor BSP, the quality order of the
* returned speedbin index is 4 -> 0/2 -> 3 -> 1, from worst to best.
* 0 and 2 seem identical from the OPP tables' point of view.
*/
static u32 sun50i_h616_efuse_xlate(u32 speedbin)
{
int ver_bits = get_soc_id_revision();
u32 value = 0;
switch (speedbin & 0xffff) {
case 0x2000:
value = 0;
break;
case 0x2400:
case 0x7400:
case 0x2c00:
case 0x7c00:
if (ver_bits != SMCCC_RET_NOT_SUPPORTED && ver_bits <= 1) {
/* ic version A/B */
value = 1;
} else {
/* ic version C and later version */
value = 2;
}
break;
case 0x5000:
case 0x5400:
case 0x6000:
value = 3;
break;
case 0x5c00:
value = 4;
break;
case 0x5d00:
value = 0;
break;
default:
pr_warn("sun50i-cpufreq-nvmem: unknown speed bin 0x%x, using default bin 0\n",
speedbin & 0xffff);
value = 0;
break;
}
return value;
}
static struct sunxi_cpufreq_data sun50i_h6_cpufreq_data = {
.efuse_xlate = sun50i_h6_efuse_xlate,
};
static struct sunxi_cpufreq_data sun50i_h616_cpufreq_data = {
.efuse_xlate = sun50i_h616_efuse_xlate,
};
static const struct of_device_id cpu_opp_match_list[] = {
{ .compatible = "allwinner,sun50i-h6-operating-points",
.data = &sun50i_h6_cpufreq_data,
},
{ .compatible = "allwinner,sun50i-h616-operating-points",
.data = &sun50i_h616_cpufreq_data,
},
{}
};
/**
* dt_has_supported_hw() - Check if any OPPs use opp-supported-hw
*
* If we ask the cpufreq framework to use the opp-supported-hw feature, it
* will ignore every OPP node without that DT property. If none of the OPPs
* have it, the driver will fail probing, due to the lack of OPPs.
*
* Returns true if we have at least one OPP with the opp-supported-hw property.
*/
static bool dt_has_supported_hw(void)
{
bool has_opp_supported_hw = false;
struct device_node *np, *opp;
struct device *cpu_dev;
cpu_dev = get_cpu_device(0);
if (!cpu_dev)
return false;
np = dev_pm_opp_of_get_opp_desc_node(cpu_dev);
if (!np)
return false;
for_each_child_of_node(np, opp) {
if (of_find_property(opp, "opp-supported-hw", NULL)) {
has_opp_supported_hw = true;
break;
}
}
of_node_put(np);
return has_opp_supported_hw;
}
/** /**
* sun50i_cpufreq_get_efuse() - Determine speed grade from efuse value * sun50i_cpufreq_get_efuse() - Determine speed grade from efuse value
* @versions: Set to the value parsed from efuse
* *
* Returns 0 if success. * Returns non-negative speed bin index on success, a negative error
* value otherwise.
*/ */
static int sun50i_cpufreq_get_efuse(u32 *versions) static int sun50i_cpufreq_get_efuse(void)
{ {
const struct sunxi_cpufreq_data *opp_data;
struct nvmem_cell *speedbin_nvmem; struct nvmem_cell *speedbin_nvmem;
const struct of_device_id *match;
struct device_node *np; struct device_node *np;
struct device *cpu_dev; struct device *cpu_dev;
u32 *speedbin, efuse_value; u32 *speedbin;
size_t len;
int ret; int ret;
cpu_dev = get_cpu_device(0); cpu_dev = get_cpu_device(0);
...@@ -48,12 +178,12 @@ static int sun50i_cpufreq_get_efuse(u32 *versions) ...@@ -48,12 +178,12 @@ static int sun50i_cpufreq_get_efuse(u32 *versions)
if (!np) if (!np)
return -ENOENT; return -ENOENT;
ret = of_device_is_compatible(np, match = of_match_node(cpu_opp_match_list, np);
"allwinner,sun50i-h6-operating-points"); if (!match) {
if (!ret) {
of_node_put(np); of_node_put(np);
return -ENOENT; return -ENOENT;
} }
opp_data = match->data;
speedbin_nvmem = of_nvmem_cell_get(np, NULL); speedbin_nvmem = of_nvmem_cell_get(np, NULL);
of_node_put(np); of_node_put(np);
...@@ -61,33 +191,25 @@ static int sun50i_cpufreq_get_efuse(u32 *versions) ...@@ -61,33 +191,25 @@ static int sun50i_cpufreq_get_efuse(u32 *versions)
return dev_err_probe(cpu_dev, PTR_ERR(speedbin_nvmem), return dev_err_probe(cpu_dev, PTR_ERR(speedbin_nvmem),
"Could not get nvmem cell\n"); "Could not get nvmem cell\n");
speedbin = nvmem_cell_read(speedbin_nvmem, &len); speedbin = nvmem_cell_read(speedbin_nvmem, NULL);
nvmem_cell_put(speedbin_nvmem); nvmem_cell_put(speedbin_nvmem);
if (IS_ERR(speedbin)) if (IS_ERR(speedbin))
return PTR_ERR(speedbin); return PTR_ERR(speedbin);
efuse_value = (*speedbin >> NVMEM_SHIFT) & NVMEM_MASK; ret = opp_data->efuse_xlate(*speedbin);
/*
* We treat unexpected efuse values as if the SoC was from
* the slowest bin. Expected efuse values are 1-3, slowest
* to fastest.
*/
if (efuse_value >= 1 && efuse_value <= 3)
*versions = efuse_value - 1;
else
*versions = 0;
kfree(speedbin); kfree(speedbin);
return 0;
return ret;
}; };
static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev) static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev)
{ {
int *opp_tokens; int *opp_tokens;
char name[MAX_NAME_LEN]; char name[] = "speedXXXXXXXXXXX"; /* Integers can take 11 chars max */
unsigned int cpu; unsigned int cpu, supported_hw;
u32 speed = 0; struct dev_pm_opp_config config = {};
int speed;
int ret; int ret;
opp_tokens = kcalloc(num_possible_cpus(), sizeof(*opp_tokens), opp_tokens = kcalloc(num_possible_cpus(), sizeof(*opp_tokens),
...@@ -95,13 +217,24 @@ static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev) ...@@ -95,13 +217,24 @@ static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev)
if (!opp_tokens) if (!opp_tokens)
return -ENOMEM; return -ENOMEM;
ret = sun50i_cpufreq_get_efuse(&speed); speed = sun50i_cpufreq_get_efuse();
if (ret) { if (speed < 0) {
kfree(opp_tokens); kfree(opp_tokens);
return ret; return speed;
} }
snprintf(name, MAX_NAME_LEN, "speed%d", speed); /*
* We need at least one OPP with the "opp-supported-hw" property,
* or else the upper layers will ignore every OPP and will bail out.
*/
if (dt_has_supported_hw()) {
supported_hw = 1U << speed;
config.supported_hw = &supported_hw;
config.supported_hw_count = 1;
}
snprintf(name, sizeof(name), "speed%d", speed);
config.prop_name = name;
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
struct device *cpu_dev = get_cpu_device(cpu); struct device *cpu_dev = get_cpu_device(cpu);
...@@ -111,12 +244,11 @@ static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev) ...@@ -111,12 +244,11 @@ static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev)
goto free_opp; goto free_opp;
} }
opp_tokens[cpu] = dev_pm_opp_set_prop_name(cpu_dev, name); ret = dev_pm_opp_set_config(cpu_dev, &config);
if (opp_tokens[cpu] < 0) { if (ret < 0)
ret = opp_tokens[cpu];
pr_err("Failed to set prop name\n");
goto free_opp; goto free_opp;
}
opp_tokens[cpu] = ret;
} }
cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1, cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1,
...@@ -131,7 +263,7 @@ static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev) ...@@ -131,7 +263,7 @@ static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev)
free_opp: free_opp:
for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
dev_pm_opp_put_prop_name(opp_tokens[cpu]); dev_pm_opp_clear_config(opp_tokens[cpu]);
kfree(opp_tokens); kfree(opp_tokens);
return ret; return ret;
...@@ -145,7 +277,7 @@ static void sun50i_cpufreq_nvmem_remove(struct platform_device *pdev) ...@@ -145,7 +277,7 @@ static void sun50i_cpufreq_nvmem_remove(struct platform_device *pdev)
platform_device_unregister(cpufreq_dt_pdev); platform_device_unregister(cpufreq_dt_pdev);
for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
dev_pm_opp_put_prop_name(opp_tokens[cpu]); dev_pm_opp_clear_config(opp_tokens[cpu]);
kfree(opp_tokens); kfree(opp_tokens);
} }
...@@ -160,6 +292,9 @@ static struct platform_driver sun50i_cpufreq_driver = { ...@@ -160,6 +292,9 @@ static struct platform_driver sun50i_cpufreq_driver = {
static const struct of_device_id sun50i_cpufreq_match_list[] = { static const struct of_device_id sun50i_cpufreq_match_list[] = {
{ .compatible = "allwinner,sun50i-h6" }, { .compatible = "allwinner,sun50i-h6" },
{ .compatible = "allwinner,sun50i-h616" },
{ .compatible = "allwinner,sun50i-h618" },
{ .compatible = "allwinner,sun50i-h700" },
{} {}
}; };
MODULE_DEVICE_TABLE(of, sun50i_cpufreq_match_list); MODULE_DEVICE_TABLE(of, sun50i_cpufreq_match_list);
......
...@@ -52,12 +52,15 @@ static int tegra124_cpu_switch_to_dfll(struct tegra124_cpufreq_priv *priv) ...@@ -52,12 +52,15 @@ static int tegra124_cpu_switch_to_dfll(struct tegra124_cpufreq_priv *priv)
static int tegra124_cpufreq_probe(struct platform_device *pdev) static int tegra124_cpufreq_probe(struct platform_device *pdev)
{ {
struct device_node *np __free(device_node) = of_cpu_device_node_get(0);
struct tegra124_cpufreq_priv *priv; struct tegra124_cpufreq_priv *priv;
struct device_node *np;
struct device *cpu_dev; struct device *cpu_dev;
struct platform_device_info cpufreq_dt_devinfo = {}; struct platform_device_info cpufreq_dt_devinfo = {};
int ret; int ret;
if (!np)
return -ENODEV;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
...@@ -66,15 +69,9 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev) ...@@ -66,15 +69,9 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)
if (!cpu_dev) if (!cpu_dev)
return -ENODEV; return -ENODEV;
np = of_cpu_device_node_get(0);
if (!np)
return -ENODEV;
priv->cpu_clk = of_clk_get_by_name(np, "cpu_g"); priv->cpu_clk = of_clk_get_by_name(np, "cpu_g");
if (IS_ERR(priv->cpu_clk)) { if (IS_ERR(priv->cpu_clk))
ret = PTR_ERR(priv->cpu_clk); return PTR_ERR(priv->cpu_clk);
goto out_put_np;
}
priv->dfll_clk = of_clk_get_by_name(np, "dfll"); priv->dfll_clk = of_clk_get_by_name(np, "dfll");
if (IS_ERR(priv->dfll_clk)) { if (IS_ERR(priv->dfll_clk)) {
...@@ -110,8 +107,6 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev) ...@@ -110,8 +107,6 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
of_node_put(np);
return 0; return 0;
out_put_pllp_clk: out_put_pllp_clk:
...@@ -122,8 +117,6 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev) ...@@ -122,8 +117,6 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)
clk_put(priv->dfll_clk); clk_put(priv->dfll_clk);
out_put_cpu_clk: out_put_cpu_clk:
clk_put(priv->cpu_clk); clk_put(priv->cpu_clk);
out_put_np:
of_node_put(np);
return ret; return ret;
} }
......
...@@ -347,12 +347,10 @@ static const struct of_device_id ti_cpufreq_of_match[] = { ...@@ -347,12 +347,10 @@ static const struct of_device_id ti_cpufreq_of_match[] = {
static const struct of_device_id *ti_cpufreq_match_node(void) static const struct of_device_id *ti_cpufreq_match_node(void)
{ {
struct device_node *np; struct device_node *np __free(device_node) = of_find_node_by_path("/");
const struct of_device_id *match; const struct of_device_id *match;
np = of_find_node_by_path("/");
match = of_match_node(ti_cpufreq_of_match, np); match = of_match_node(ti_cpufreq_of_match, np);
of_node_put(np);
return match; return match;
} }
......
...@@ -59,15 +59,14 @@ static int kirkwood_cpuidle_probe(struct platform_device *pdev) ...@@ -59,15 +59,14 @@ static int kirkwood_cpuidle_probe(struct platform_device *pdev)
return cpuidle_register(&kirkwood_idle_driver, NULL); return cpuidle_register(&kirkwood_idle_driver, NULL);
} }
static int kirkwood_cpuidle_remove(struct platform_device *pdev) static void kirkwood_cpuidle_remove(struct platform_device *pdev)
{ {
cpuidle_unregister(&kirkwood_idle_driver); cpuidle_unregister(&kirkwood_idle_driver);
return 0;
} }
static struct platform_driver kirkwood_cpuidle_driver = { static struct platform_driver kirkwood_cpuidle_driver = {
.probe = kirkwood_cpuidle_probe, .probe = kirkwood_cpuidle_probe,
.remove = kirkwood_cpuidle_remove, .remove_new = kirkwood_cpuidle_remove,
.driver = { .driver = {
.name = "kirkwood_cpuidle", .name = "kirkwood_cpuidle",
}, },
......
...@@ -44,6 +44,7 @@ static DEFINE_PER_CPU(struct ladder_device, ladder_devices); ...@@ -44,6 +44,7 @@ static DEFINE_PER_CPU(struct ladder_device, ladder_devices);
/** /**
* ladder_do_selection - prepares private data for a state change * ladder_do_selection - prepares private data for a state change
* @dev: the CPU
* @ldev: the ladder device * @ldev: the ladder device
* @old_idx: the current state index * @old_idx: the current state index
* @new_idx: the new target state index * @new_idx: the new target state index
......
...@@ -275,18 +275,16 @@ static int exynos_nocp_probe(struct platform_device *pdev) ...@@ -275,18 +275,16 @@ static int exynos_nocp_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int exynos_nocp_remove(struct platform_device *pdev) static void exynos_nocp_remove(struct platform_device *pdev)
{ {
struct exynos_nocp *nocp = platform_get_drvdata(pdev); struct exynos_nocp *nocp = platform_get_drvdata(pdev);
clk_disable_unprepare(nocp->clk); clk_disable_unprepare(nocp->clk);
return 0;
} }
static struct platform_driver exynos_nocp_driver = { static struct platform_driver exynos_nocp_driver = {
.probe = exynos_nocp_probe, .probe = exynos_nocp_probe,
.remove = exynos_nocp_remove, .remove_new = exynos_nocp_remove,
.driver = { .driver = {
.name = "exynos-nocp", .name = "exynos-nocp",
.of_match_table = exynos_nocp_id_match, .of_match_table = exynos_nocp_id_match,
......
...@@ -692,18 +692,16 @@ static int exynos_ppmu_probe(struct platform_device *pdev) ...@@ -692,18 +692,16 @@ static int exynos_ppmu_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int exynos_ppmu_remove(struct platform_device *pdev) static void exynos_ppmu_remove(struct platform_device *pdev)
{ {
struct exynos_ppmu *info = platform_get_drvdata(pdev); struct exynos_ppmu *info = platform_get_drvdata(pdev);
clk_disable_unprepare(info->ppmu.clk); clk_disable_unprepare(info->ppmu.clk);
return 0;
} }
static struct platform_driver exynos_ppmu_driver = { static struct platform_driver exynos_ppmu_driver = {
.probe = exynos_ppmu_probe, .probe = exynos_ppmu_probe,
.remove = exynos_ppmu_remove, .remove_new = exynos_ppmu_remove,
.driver = { .driver = {
.name = "exynos-ppmu", .name = "exynos-ppmu",
.of_match_table = exynos_ppmu_id_match, .of_match_table = exynos_ppmu_id_match,
......
...@@ -467,7 +467,6 @@ static void exynos_bus_shutdown(struct platform_device *pdev) ...@@ -467,7 +467,6 @@ static void exynos_bus_shutdown(struct platform_device *pdev)
devfreq_suspend_device(bus->devfreq); devfreq_suspend_device(bus->devfreq);
} }
#ifdef CONFIG_PM_SLEEP
static int exynos_bus_resume(struct device *dev) static int exynos_bus_resume(struct device *dev)
{ {
struct exynos_bus *bus = dev_get_drvdata(dev); struct exynos_bus *bus = dev_get_drvdata(dev);
...@@ -495,11 +494,9 @@ static int exynos_bus_suspend(struct device *dev) ...@@ -495,11 +494,9 @@ static int exynos_bus_suspend(struct device *dev)
return 0; return 0;
} }
#endif
static const struct dev_pm_ops exynos_bus_pm = { static DEFINE_SIMPLE_DEV_PM_OPS(exynos_bus_pm,
SET_SYSTEM_SLEEP_PM_OPS(exynos_bus_suspend, exynos_bus_resume) exynos_bus_suspend, exynos_bus_resume);
};
static const struct of_device_id exynos_bus_of_match[] = { static const struct of_device_id exynos_bus_of_match[] = {
{ .compatible = "samsung,exynos-bus", }, { .compatible = "samsung,exynos-bus", },
...@@ -512,7 +509,7 @@ static struct platform_driver exynos_bus_platdrv = { ...@@ -512,7 +509,7 @@ static struct platform_driver exynos_bus_platdrv = {
.shutdown = exynos_bus_shutdown, .shutdown = exynos_bus_shutdown,
.driver = { .driver = {
.name = "exynos-bus", .name = "exynos-bus",
.pm = &exynos_bus_pm, .pm = pm_sleep_ptr(&exynos_bus_pm),
.of_match_table = exynos_bus_of_match, .of_match_table = exynos_bus_of_match,
}, },
}; };
......
...@@ -392,7 +392,7 @@ static int mtk_ccifreq_probe(struct platform_device *pdev) ...@@ -392,7 +392,7 @@ static int mtk_ccifreq_probe(struct platform_device *pdev)
return ret; return ret;
} }
static int mtk_ccifreq_remove(struct platform_device *pdev) static void mtk_ccifreq_remove(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct mtk_ccifreq_drv *drv; struct mtk_ccifreq_drv *drv;
...@@ -405,8 +405,6 @@ static int mtk_ccifreq_remove(struct platform_device *pdev) ...@@ -405,8 +405,6 @@ static int mtk_ccifreq_remove(struct platform_device *pdev)
regulator_disable(drv->proc_reg); regulator_disable(drv->proc_reg);
if (drv->sram_reg) if (drv->sram_reg)
regulator_disable(drv->sram_reg); regulator_disable(drv->sram_reg);
return 0;
} }
static const struct mtk_ccifreq_platform_data mt8183_platform_data = { static const struct mtk_ccifreq_platform_data mt8183_platform_data = {
...@@ -432,7 +430,7 @@ MODULE_DEVICE_TABLE(of, mtk_ccifreq_machines); ...@@ -432,7 +430,7 @@ MODULE_DEVICE_TABLE(of, mtk_ccifreq_machines);
static struct platform_driver mtk_ccifreq_platdrv = { static struct platform_driver mtk_ccifreq_platdrv = {
.probe = mtk_ccifreq_probe, .probe = mtk_ccifreq_probe,
.remove = mtk_ccifreq_remove, .remove_new = mtk_ccifreq_remove,
.driver = { .driver = {
.name = "mtk-ccifreq", .name = "mtk-ccifreq",
.of_match_table = mtk_ccifreq_machines, .of_match_table = mtk_ccifreq_machines,
......
...@@ -459,13 +459,11 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev) ...@@ -459,13 +459,11 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
return ret; return ret;
} }
static int rk3399_dmcfreq_remove(struct platform_device *pdev) static void rk3399_dmcfreq_remove(struct platform_device *pdev)
{ {
struct rk3399_dmcfreq *dmcfreq = dev_get_drvdata(&pdev->dev); struct rk3399_dmcfreq *dmcfreq = dev_get_drvdata(&pdev->dev);
devfreq_event_disable_edev(dmcfreq->edev); devfreq_event_disable_edev(dmcfreq->edev);
return 0;
} }
static const struct of_device_id rk3399dmc_devfreq_of_match[] = { static const struct of_device_id rk3399dmc_devfreq_of_match[] = {
...@@ -476,7 +474,7 @@ MODULE_DEVICE_TABLE(of, rk3399dmc_devfreq_of_match); ...@@ -476,7 +474,7 @@ MODULE_DEVICE_TABLE(of, rk3399dmc_devfreq_of_match);
static struct platform_driver rk3399_dmcfreq_driver = { static struct platform_driver rk3399_dmcfreq_driver = {
.probe = rk3399_dmcfreq_probe, .probe = rk3399_dmcfreq_probe,
.remove = rk3399_dmcfreq_remove, .remove_new = rk3399_dmcfreq_remove,
.driver = { .driver = {
.name = "rk3399-dmc-freq", .name = "rk3399-dmc-freq",
.pm = &rk3399_dmcfreq_pm, .pm = &rk3399_dmcfreq_pm,
......
...@@ -458,7 +458,7 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev) ...@@ -458,7 +458,7 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev)
return dev_err_probe(dev, ret, err); return dev_err_probe(dev, ret, err);
} }
static int sun8i_a33_mbus_remove(struct platform_device *pdev) static void sun8i_a33_mbus_remove(struct platform_device *pdev)
{ {
struct sun8i_a33_mbus *priv = platform_get_drvdata(pdev); struct sun8i_a33_mbus *priv = platform_get_drvdata(pdev);
unsigned long initial_freq = priv->profile.initial_freq; unsigned long initial_freq = priv->profile.initial_freq;
...@@ -475,8 +475,6 @@ static int sun8i_a33_mbus_remove(struct platform_device *pdev) ...@@ -475,8 +475,6 @@ static int sun8i_a33_mbus_remove(struct platform_device *pdev)
clk_rate_exclusive_put(priv->clk_mbus); clk_rate_exclusive_put(priv->clk_mbus);
clk_rate_exclusive_put(priv->clk_dram); clk_rate_exclusive_put(priv->clk_dram);
clk_disable_unprepare(priv->clk_bus); clk_disable_unprepare(priv->clk_bus);
return 0;
} }
static const struct sun8i_a33_mbus_variant sun50i_a64_mbus = { static const struct sun8i_a33_mbus_variant sun50i_a64_mbus = {
...@@ -497,7 +495,7 @@ static SIMPLE_DEV_PM_OPS(sun8i_a33_mbus_pm_ops, ...@@ -497,7 +495,7 @@ static SIMPLE_DEV_PM_OPS(sun8i_a33_mbus_pm_ops,
static struct platform_driver sun8i_a33_mbus_driver = { static struct platform_driver sun8i_a33_mbus_driver = {
.probe = sun8i_a33_mbus_probe, .probe = sun8i_a33_mbus_probe,
.remove = sun8i_a33_mbus_remove, .remove_new = sun8i_a33_mbus_remove,
.driver = { .driver = {
.name = "sun8i-a33-mbus", .name = "sun8i-a33-mbus",
.of_match_table = sun8i_a33_mbus_of_match, .of_match_table = sun8i_a33_mbus_of_match,
......
...@@ -69,6 +69,7 @@ s32 arm_smccc_get_soc_id_revision(void) ...@@ -69,6 +69,7 @@ s32 arm_smccc_get_soc_id_revision(void)
{ {
return smccc_soc_id_revision; return smccc_soc_id_revision;
} }
EXPORT_SYMBOL_GPL(arm_smccc_get_soc_id_revision);
static int __init smccc_devices_init(void) static int __init smccc_devices_init(void)
{ {
......
...@@ -63,7 +63,7 @@ static int sdhci_pci_init_wakeup(struct sdhci_pci_chip *chip) ...@@ -63,7 +63,7 @@ static int sdhci_pci_init_wakeup(struct sdhci_pci_chip *chip)
if ((pm_flags & MMC_PM_KEEP_POWER) && (pm_flags & MMC_PM_WAKE_SDIO_IRQ)) if ((pm_flags & MMC_PM_KEEP_POWER) && (pm_flags & MMC_PM_WAKE_SDIO_IRQ))
return device_wakeup_enable(&chip->pdev->dev); return device_wakeup_enable(&chip->pdev->dev);
else if (!cap_cd_wake) else if (!cap_cd_wake)
return device_wakeup_disable(&chip->pdev->dev); device_wakeup_disable(&chip->pdev->dev);
return 0; return 0;
} }
......
...@@ -1494,20 +1494,26 @@ _get_dt_power(struct device *dev, unsigned long *uW, unsigned long *kHz) ...@@ -1494,20 +1494,26 @@ _get_dt_power(struct device *dev, unsigned long *uW, unsigned long *kHz)
return 0; return 0;
} }
/* /**
* Callback function provided to the Energy Model framework upon registration. * dev_pm_opp_calc_power() - Calculate power value for device with EM
* @dev : Device for which an Energy Model has to be registered
* @uW : New power value that is calculated
* @kHz : Frequency for which the new power is calculated
*
* This computes the power estimated by @dev at @kHz if it is the frequency * This computes the power estimated by @dev at @kHz if it is the frequency
* of an existing OPP, or at the frequency of the first OPP above @kHz otherwise * of an existing OPP, or at the frequency of the first OPP above @kHz otherwise
* (see dev_pm_opp_find_freq_ceil()). This function updates @kHz to the ceiled * (see dev_pm_opp_find_freq_ceil()). This function updates @kHz to the ceiled
* frequency and @uW to the associated power. The power is estimated as * frequency and @uW to the associated power. The power is estimated as
* P = C * V^2 * f with C being the device's capacitance and V and f * P = C * V^2 * f with C being the device's capacitance and V and f
* respectively the voltage and frequency of the OPP. * respectively the voltage and frequency of the OPP.
* It is also used as a callback function provided to the Energy Model
* framework upon registration.
* *
* Returns -EINVAL if the power calculation failed because of missing * Returns -EINVAL if the power calculation failed because of missing
* parameters, 0 otherwise. * parameters, 0 otherwise.
*/ */
static int __maybe_unused _get_power(struct device *dev, unsigned long *uW, int dev_pm_opp_calc_power(struct device *dev, unsigned long *uW,
unsigned long *kHz) unsigned long *kHz)
{ {
struct dev_pm_opp *opp; struct dev_pm_opp *opp;
struct device_node *np; struct device_node *np;
...@@ -1544,6 +1550,7 @@ static int __maybe_unused _get_power(struct device *dev, unsigned long *uW, ...@@ -1544,6 +1550,7 @@ static int __maybe_unused _get_power(struct device *dev, unsigned long *uW,
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(dev_pm_opp_calc_power);
static bool _of_has_opp_microwatt_property(struct device *dev) static bool _of_has_opp_microwatt_property(struct device *dev)
{ {
...@@ -1619,7 +1626,7 @@ int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus) ...@@ -1619,7 +1626,7 @@ int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus)
goto failed; goto failed;
} }
EM_SET_ACTIVE_POWER_CB(em_cb, _get_power); EM_SET_ACTIVE_POWER_CB(em_cb, dev_pm_opp_calc_power);
register_em: register_em:
ret = em_dev_register_perf_domain(dev, nr_opp, &em_cb, cpus, true); ret = em_dev_register_perf_domain(dev, nr_opp, &em_cb, cpus, true);
......
...@@ -43,13 +43,11 @@ static u64 set_pd_power_limit(struct dtpm *dtpm, u64 power_limit) ...@@ -43,13 +43,11 @@ static u64 set_pd_power_limit(struct dtpm *dtpm, u64 power_limit)
struct dtpm_cpu *dtpm_cpu = to_dtpm_cpu(dtpm); struct dtpm_cpu *dtpm_cpu = to_dtpm_cpu(dtpm);
struct em_perf_domain *pd = em_cpu_get(dtpm_cpu->cpu); struct em_perf_domain *pd = em_cpu_get(dtpm_cpu->cpu);
struct em_perf_state *table; struct em_perf_state *table;
struct cpumask cpus;
unsigned long freq; unsigned long freq;
u64 power; u64 power;
int i, nr_cpus; int i, nr_cpus;
cpumask_and(&cpus, cpu_online_mask, to_cpumask(pd->cpus)); nr_cpus = cpumask_weight_and(cpu_online_mask, to_cpumask(pd->cpus));
nr_cpus = cpumask_weight(&cpus);
rcu_read_lock(); rcu_read_lock();
table = em_perf_state_from_pd(pd); table = em_perf_state_from_pd(pd);
...@@ -123,11 +121,9 @@ static int update_pd_power_uw(struct dtpm *dtpm) ...@@ -123,11 +121,9 @@ static int update_pd_power_uw(struct dtpm *dtpm)
struct dtpm_cpu *dtpm_cpu = to_dtpm_cpu(dtpm); struct dtpm_cpu *dtpm_cpu = to_dtpm_cpu(dtpm);
struct em_perf_domain *em = em_cpu_get(dtpm_cpu->cpu); struct em_perf_domain *em = em_cpu_get(dtpm_cpu->cpu);
struct em_perf_state *table; struct em_perf_state *table;
struct cpumask cpus;
int nr_cpus; int nr_cpus;
cpumask_and(&cpus, cpu_online_mask, to_cpumask(em->cpus)); nr_cpus = cpumask_weight_and(cpu_online_mask, to_cpumask(em->cpus));
nr_cpus = cpumask_weight(&cpus);
rcu_read_lock(); rcu_read_lock();
table = em_perf_state_from_pd(em); table = em_perf_state_from_pd(em);
......
This diff is collapsed.
...@@ -302,6 +302,8 @@ static int intel_rapl_tpmi_probe(struct auxiliary_device *auxdev, ...@@ -302,6 +302,8 @@ static int intel_rapl_tpmi_probe(struct auxiliary_device *auxdev,
goto err; goto err;
} }
rapl_package_add_pmu(trp->rp);
auxiliary_set_drvdata(auxdev, trp); auxiliary_set_drvdata(auxdev, trp);
return 0; return 0;
...@@ -314,6 +316,7 @@ static void intel_rapl_tpmi_remove(struct auxiliary_device *auxdev) ...@@ -314,6 +316,7 @@ static void intel_rapl_tpmi_remove(struct auxiliary_device *auxdev)
{ {
struct tpmi_rapl_package *trp = auxiliary_get_drvdata(auxdev); struct tpmi_rapl_package *trp = auxiliary_get_drvdata(auxdev);
rapl_package_remove_pmu(trp->rp);
rapl_remove_package(trp->rp); rapl_remove_package(trp->rp);
trp_release(trp); trp_release(trp);
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/energy_model.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/pm_opp.h> #include <linux/pm_opp.h>
...@@ -97,9 +98,16 @@ static int exynos_asv_update_opps(struct exynos_asv *asv) ...@@ -97,9 +98,16 @@ static int exynos_asv_update_opps(struct exynos_asv *asv)
last_opp_table = opp_table; last_opp_table = opp_table;
ret = exynos_asv_update_cpu_opps(asv, cpu); ret = exynos_asv_update_cpu_opps(asv, cpu);
if (ret < 0) if (!ret) {
/*
* Update EM power values since OPP
* voltage values may have changed.
*/
em_dev_update_chip_binning(cpu);
} else {
dev_err(asv->dev, "Couldn't udate OPPs for cpu%d\n", dev_err(asv->dev, "Couldn't udate OPPs for cpu%d\n",
cpuid); cpuid);
}
} }
dev_pm_opp_put_opp_table(opp_table); dev_pm_opp_put_opp_table(opp_table);
......
...@@ -49,13 +49,17 @@ struct amd_aperf_mperf { ...@@ -49,13 +49,17 @@ struct amd_aperf_mperf {
* @lowest_perf: the absolute lowest performance level of the processor * @lowest_perf: the absolute lowest performance level of the processor
* @prefcore_ranking: the preferred core ranking, the higher value indicates a higher * @prefcore_ranking: the preferred core ranking, the higher value indicates a higher
* priority. * priority.
* @max_freq: the frequency that mapped to highest_perf * @min_limit_perf: Cached value of the performance corresponding to policy->min
* @min_freq: the frequency that mapped to lowest_perf * @max_limit_perf: Cached value of the performance corresponding to policy->max
* @nominal_freq: the frequency that mapped to nominal_perf * @min_limit_freq: Cached value of policy->min (in khz)
* @lowest_nonlinear_freq: the frequency that mapped to lowest_nonlinear_perf * @max_limit_freq: Cached value of policy->max (in khz)
* @max_freq: the frequency (in khz) that mapped to highest_perf
* @min_freq: the frequency (in khz) that mapped to lowest_perf
* @nominal_freq: the frequency (in khz) that mapped to nominal_perf
* @lowest_nonlinear_freq: the frequency (in khz) that mapped to lowest_nonlinear_perf
* @cur: Difference of Aperf/Mperf/tsc count between last and current sample * @cur: Difference of Aperf/Mperf/tsc count between last and current sample
* @prev: Last Aperf/Mperf/tsc count value read from register * @prev: Last Aperf/Mperf/tsc count value read from register
* @freq: current cpu frequency value * @freq: current cpu frequency value (in khz)
* @boost_supported: check whether the Processor or SBIOS supports boost mode * @boost_supported: check whether the Processor or SBIOS supports boost mode
* @hw_prefcore: check whether HW supports preferred core featue. * @hw_prefcore: check whether HW supports preferred core featue.
* Only when hw_prefcore and early prefcore param are true, * Only when hw_prefcore and early prefcore param are true,
...@@ -124,4 +128,10 @@ static const char * const amd_pstate_mode_string[] = { ...@@ -124,4 +128,10 @@ static const char * const amd_pstate_mode_string[] = {
[AMD_PSTATE_GUIDED] = "guided", [AMD_PSTATE_GUIDED] = "guided",
NULL, NULL,
}; };
struct quirk_entry {
u32 nominal_freq;
u32 lowest_freq;
};
#endif /* _LINUX_AMD_PSTATE_H */ #endif /* _LINUX_AMD_PSTATE_H */
...@@ -172,6 +172,7 @@ struct em_perf_table __rcu *em_table_alloc(struct em_perf_domain *pd); ...@@ -172,6 +172,7 @@ struct em_perf_table __rcu *em_table_alloc(struct em_perf_domain *pd);
void em_table_free(struct em_perf_table __rcu *table); void em_table_free(struct em_perf_table __rcu *table);
int em_dev_compute_costs(struct device *dev, struct em_perf_state *table, int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
int nr_states); int nr_states);
int em_dev_update_chip_binning(struct device *dev);
/** /**
* em_pd_get_efficient_state() - Get an efficient performance state from the EM * em_pd_get_efficient_state() - Get an efficient performance state from the EM
...@@ -386,6 +387,10 @@ int em_dev_compute_costs(struct device *dev, struct em_perf_state *table, ...@@ -386,6 +387,10 @@ int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
{ {
return -EINVAL; return -EINVAL;
} }
static inline int em_dev_update_chip_binning(struct device *dev)
{
return -EINVAL;
}
#endif #endif
#endif #endif
...@@ -158,6 +158,26 @@ struct rapl_if_priv { ...@@ -158,6 +158,26 @@ struct rapl_if_priv {
void *rpi; void *rpi;
}; };
#ifdef CONFIG_PERF_EVENTS
/**
* struct rapl_package_pmu_data: Per package data for PMU support
* @scale: Scale of 2^-32 Joules for each energy counter increase.
* @lock: Lock to protect n_active and active_list.
* @n_active: Number of active events.
* @active_list: List of active events.
* @timer_interval: Maximum timer expiration time before counter overflow.
* @hrtimer: Periodically update the counter to prevent overflow.
*/
struct rapl_package_pmu_data {
u64 scale[RAPL_DOMAIN_MAX];
raw_spinlock_t lock;
int n_active;
struct list_head active_list;
ktime_t timer_interval;
struct hrtimer hrtimer;
};
#endif
/* maximum rapl package domain name: package-%d-die-%d */ /* maximum rapl package domain name: package-%d-die-%d */
#define PACKAGE_DOMAIN_NAME_LENGTH 30 #define PACKAGE_DOMAIN_NAME_LENGTH 30
...@@ -176,6 +196,10 @@ struct rapl_package { ...@@ -176,6 +196,10 @@ struct rapl_package {
struct cpumask cpumask; struct cpumask cpumask;
char name[PACKAGE_DOMAIN_NAME_LENGTH]; char name[PACKAGE_DOMAIN_NAME_LENGTH];
struct rapl_if_priv *priv; struct rapl_if_priv *priv;
#ifdef CONFIG_PERF_EVENTS
bool has_pmu;
struct rapl_package_pmu_data pmu_data;
#endif
}; };
struct rapl_package *rapl_find_package_domain_cpuslocked(int id, struct rapl_if_priv *priv, struct rapl_package *rapl_find_package_domain_cpuslocked(int id, struct rapl_if_priv *priv,
...@@ -188,4 +212,12 @@ struct rapl_package *rapl_find_package_domain(int id, struct rapl_if_priv *priv, ...@@ -188,4 +212,12 @@ struct rapl_package *rapl_find_package_domain(int id, struct rapl_if_priv *priv,
struct rapl_package *rapl_add_package(int id, struct rapl_if_priv *priv, bool id_is_cpu); struct rapl_package *rapl_add_package(int id, struct rapl_if_priv *priv, bool id_is_cpu);
void rapl_remove_package(struct rapl_package *rp); void rapl_remove_package(struct rapl_package *rp);
#ifdef CONFIG_PERF_EVENTS
int rapl_package_add_pmu(struct rapl_package *rp);
void rapl_package_remove_pmu(struct rapl_package *rp);
#else
static inline int rapl_package_add_pmu(struct rapl_package *rp) { return 0; }
static inline void rapl_package_remove_pmu(struct rapl_package *rp) { }
#endif
#endif /* __INTEL_RAPL_H__ */ #endif /* __INTEL_RAPL_H__ */
...@@ -476,6 +476,8 @@ struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); ...@@ -476,6 +476,8 @@ struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp);
int of_get_required_opp_performance_state(struct device_node *np, int index); int of_get_required_opp_performance_state(struct device_node *np, int index);
int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table); int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table);
int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus); int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus);
int dev_pm_opp_calc_power(struct device *dev, unsigned long *uW,
unsigned long *kHz);
static inline void dev_pm_opp_of_unregister_em(struct device *dev) static inline void dev_pm_opp_of_unregister_em(struct device *dev)
{ {
em_dev_unregister_perf_domain(dev); em_dev_unregister_perf_domain(dev);
...@@ -539,6 +541,12 @@ static inline void dev_pm_opp_of_unregister_em(struct device *dev) ...@@ -539,6 +541,12 @@ static inline void dev_pm_opp_of_unregister_em(struct device *dev)
{ {
} }
static inline int dev_pm_opp_calc_power(struct device *dev, unsigned long *uW,
unsigned long *kHz)
{
return -EOPNOTSUPP;
}
static inline int of_get_required_opp_performance_state(struct device_node *np, int index) static inline int of_get_required_opp_performance_state(struct device_node *np, int index)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
...@@ -107,7 +107,7 @@ extern void wakeup_sources_read_unlock(int idx); ...@@ -107,7 +107,7 @@ extern void wakeup_sources_read_unlock(int idx);
extern struct wakeup_source *wakeup_sources_walk_start(void); extern struct wakeup_source *wakeup_sources_walk_start(void);
extern struct wakeup_source *wakeup_sources_walk_next(struct wakeup_source *ws); extern struct wakeup_source *wakeup_sources_walk_next(struct wakeup_source *ws);
extern int device_wakeup_enable(struct device *dev); extern int device_wakeup_enable(struct device *dev);
extern int device_wakeup_disable(struct device *dev); extern void device_wakeup_disable(struct device *dev);
extern void device_set_wakeup_capable(struct device *dev, bool capable); extern void device_set_wakeup_capable(struct device *dev, bool capable);
extern int device_set_wakeup_enable(struct device *dev, bool enable); extern int device_set_wakeup_enable(struct device *dev, bool enable);
extern void __pm_stay_awake(struct wakeup_source *ws); extern void __pm_stay_awake(struct wakeup_source *ws);
...@@ -154,10 +154,9 @@ static inline int device_wakeup_enable(struct device *dev) ...@@ -154,10 +154,9 @@ static inline int device_wakeup_enable(struct device *dev)
return 0; return 0;
} }
static inline int device_wakeup_disable(struct device *dev) static inline void device_wakeup_disable(struct device *dev)
{ {
dev->power.should_wakeup = false; dev->power.should_wakeup = false;
return 0;
} }
static inline int device_set_wakeup_enable(struct device *dev, bool enable) static inline int device_set_wakeup_enable(struct device *dev, bool enable)
...@@ -235,11 +234,10 @@ static inline int device_init_wakeup(struct device *dev, bool enable) ...@@ -235,11 +234,10 @@ static inline int device_init_wakeup(struct device *dev, bool enable)
if (enable) { if (enable) {
device_set_wakeup_capable(dev, true); device_set_wakeup_capable(dev, true);
return device_wakeup_enable(dev); return device_wakeup_enable(dev);
} else {
device_wakeup_disable(dev);
device_set_wakeup_capable(dev, false);
return 0;
} }
device_wakeup_disable(dev);
device_set_wakeup_capable(dev, false);
return 0;
} }
#endif /* _LINUX_PM_WAKEUP_H */ #endif /* _LINUX_PM_WAKEUP_H */
...@@ -674,23 +674,15 @@ void em_dev_unregister_perf_domain(struct device *dev) ...@@ -674,23 +674,15 @@ void em_dev_unregister_perf_domain(struct device *dev)
} }
EXPORT_SYMBOL_GPL(em_dev_unregister_perf_domain); EXPORT_SYMBOL_GPL(em_dev_unregister_perf_domain);
/* static struct em_perf_table __rcu *em_table_dup(struct em_perf_domain *pd)
* Adjustment of CPU performance values after boot, when all CPUs capacites
* are correctly calculated.
*/
static void em_adjust_new_capacity(struct device *dev,
struct em_perf_domain *pd,
u64 max_cap)
{ {
struct em_perf_table __rcu *em_table; struct em_perf_table __rcu *em_table;
struct em_perf_state *ps, *new_ps; struct em_perf_state *ps, *new_ps;
int ret, ps_size; int ps_size;
em_table = em_table_alloc(pd); em_table = em_table_alloc(pd);
if (!em_table) { if (!em_table)
dev_warn(dev, "EM: allocation failed\n"); return NULL;
return;
}
new_ps = em_table->state; new_ps = em_table->state;
...@@ -702,24 +694,52 @@ static void em_adjust_new_capacity(struct device *dev, ...@@ -702,24 +694,52 @@ static void em_adjust_new_capacity(struct device *dev,
rcu_read_unlock(); rcu_read_unlock();
em_init_performance(dev, pd, new_ps, pd->nr_perf_states); return em_table;
ret = em_compute_costs(dev, new_ps, NULL, pd->nr_perf_states, }
static int em_recalc_and_update(struct device *dev, struct em_perf_domain *pd,
struct em_perf_table __rcu *em_table)
{
int ret;
ret = em_compute_costs(dev, em_table->state, NULL, pd->nr_perf_states,
pd->flags); pd->flags);
if (ret) { if (ret)
dev_warn(dev, "EM: compute costs failed\n"); goto free_em_table;
return;
}
ret = em_dev_update_perf_domain(dev, em_table); ret = em_dev_update_perf_domain(dev, em_table);
if (ret) if (ret)
dev_warn(dev, "EM: update failed %d\n", ret); goto free_em_table;
/* /*
* This is one-time-update, so give up the ownership in this updater. * This is one-time-update, so give up the ownership in this updater.
* The EM framework has incremented the usage counter and from now * The EM framework has incremented the usage counter and from now
* will keep the reference (then free the memory when needed). * will keep the reference (then free the memory when needed).
*/ */
free_em_table:
em_table_free(em_table); em_table_free(em_table);
return ret;
}
/*
* Adjustment of CPU performance values after boot, when all CPUs capacites
* are correctly calculated.
*/
static void em_adjust_new_capacity(struct device *dev,
struct em_perf_domain *pd,
u64 max_cap)
{
struct em_perf_table __rcu *em_table;
em_table = em_table_dup(pd);
if (!em_table) {
dev_warn(dev, "EM: allocation failed\n");
return;
}
em_init_performance(dev, pd, em_table->state, pd->nr_perf_states);
em_recalc_and_update(dev, pd, em_table);
} }
static void em_check_capacity_update(void) static void em_check_capacity_update(void)
...@@ -788,3 +808,51 @@ static void em_update_workfn(struct work_struct *work) ...@@ -788,3 +808,51 @@ static void em_update_workfn(struct work_struct *work)
{ {
em_check_capacity_update(); em_check_capacity_update();
} }
/**
* em_dev_update_chip_binning() - Update Energy Model after the new voltage
* information is present in the OPPs.
* @dev : Device for which the Energy Model has to be updated.
*
* This function allows to update easily the EM with new values available in
* the OPP framework and DT. It can be used after the chip has been properly
* verified by device drivers and the voltages adjusted for the 'chip binning'.
*/
int em_dev_update_chip_binning(struct device *dev)
{
struct em_perf_table __rcu *em_table;
struct em_perf_domain *pd;
int i, ret;
if (IS_ERR_OR_NULL(dev))
return -EINVAL;
pd = em_pd_get(dev);
if (!pd) {
dev_warn(dev, "Couldn't find Energy Model\n");
return -EINVAL;
}
em_table = em_table_dup(pd);
if (!em_table) {
dev_warn(dev, "EM: allocation failed\n");
return -ENOMEM;
}
/* Update power values which might change due to new voltage in OPPs */
for (i = 0; i < pd->nr_perf_states; i++) {
unsigned long freq = em_table->state[i].frequency;
unsigned long power;
ret = dev_pm_opp_calc_power(dev, &power, &freq);
if (ret) {
em_table_free(em_table);
return ret;
}
em_table->state[i].power = power;
}
return em_recalc_and_update(dev, pd, em_table);
}
EXPORT_SYMBOL_GPL(em_dev_update_chip_binning);
...@@ -1361,7 +1361,7 @@ static int __init resume_setup(char *str) ...@@ -1361,7 +1361,7 @@ static int __init resume_setup(char *str)
if (noresume) if (noresume)
return 1; return 1;
strncpy(resume_file, str, 255); strscpy(resume_file, str);
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment