-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'cpufreq-arm-updates-6.14' of ssh://gitolite.kernel.org/pub…
…/scm/linux/kernel/git/vireshk/pm Merge ARM cpufreq updates for 6.14 from Viresh Kumar: "- Extended support for more SoCs in apple cpufreq driver (Hector Martin and Nick Chan). - Add new cpufreq driver for Airoha SoCs (Christian Marangi). - Fix using cpufreq-dt as module (Andreas Kemnade). - Minor fixes for Sparc, scmi, and Qcom drivers (Ethan Carter Edwards, Sibi Sankar and Manivannan Sadhasivam)." * tag 'cpufreq-arm-updates-6.14' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/vireshk/pm: cpufreq: airoha: Add EN7581 CPUFreq SMCCC driver cpufreq: sparc: change kzalloc to kcalloc cpufreq: qcom: Implement clk_ops::determine_rate() for qcom_cpufreq* clocks cpufreq: qcom: Fix qcom_cpufreq_hw_recalc_rate() to query LUT if LMh IRQ is not available cpufreq: apple-soc: Add Apple A7-A8X SoC cpufreq support cpufreq: apple-soc: Set fallback transition latency to APPLE_DVFS_TRANSITION_TIMEOUT cpufreq: apple-soc: Increase cluster switch timeout to 400us cpufreq: apple-soc: Use 32-bit read for status register cpufreq: apple-soc: Allow per-SoC configuration of APPLE_DVFS_CMD_PS1 cpufreq: apple-soc: Drop setting the PS2 field on M2+ dt-bindings: cpufreq: apple,cluster-cpufreq: Add A7-A11, T2 compatibles dt-bindings: cpufreq: Document support for Airoha EN7581 CPUFreq cpufreq: fix using cpufreq-dt as module cpufreq: scmi: Register for limit change notifications
- Loading branch information
Showing
12 changed files
with
344 additions
and
27 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
Documentation/devicetree/bindings/cpufreq/airoha,en7581-cpufreq.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | ||
%YAML 1.2 | ||
--- | ||
$id: http://devicetree.org/schemas/cpufreq/airoha,en7581-cpufreq.yaml# | ||
$schema: http://devicetree.org/meta-schemas/core.yaml# | ||
|
||
title: Airoha EN7581 CPUFreq | ||
|
||
maintainers: | ||
- Christian Marangi <ansuelsmth@gmail.com> | ||
|
||
description: | | ||
On newer Airoha SoC, CPU Frequency is scaled indirectly with SMC commands | ||
to ATF. | ||
A virtual clock is exposed. This virtual clock is a get-only clock and | ||
is used to expose the current global CPU clock. The frequency info comes | ||
by the output of the SMC command that reports the clock in MHz. | ||
The SMC sets the CPU clock by providing an index, this is modelled as | ||
performance states in a power domain. | ||
CPUs can't be individually scaled as the CPU frequency is shared across | ||
all CPUs and is global. | ||
properties: | ||
compatible: | ||
const: airoha,en7581-cpufreq | ||
|
||
'#clock-cells': | ||
const: 0 | ||
|
||
'#power-domain-cells': | ||
const: 0 | ||
|
||
operating-points-v2: true | ||
|
||
required: | ||
- compatible | ||
- '#clock-cells' | ||
- '#power-domain-cells' | ||
- operating-points-v2 | ||
|
||
additionalProperties: false | ||
|
||
examples: | ||
- | | ||
performance-domain { | ||
compatible = "airoha,en7581-cpufreq"; | ||
operating-points-v2 = <&cpu_smcc_opp_table>; | ||
#power-domain-cells = <0>; | ||
#clock-cells = <0>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include <linux/bitfield.h> | ||
#include <linux/cpufreq.h> | ||
#include <linux/module.h> | ||
#include <linux/platform_device.h> | ||
#include <linux/pm_domain.h> | ||
#include <linux/pm_runtime.h> | ||
#include <linux/slab.h> | ||
|
||
#include "cpufreq-dt.h" | ||
|
||
struct airoha_cpufreq_priv { | ||
int opp_token; | ||
struct dev_pm_domain_list *pd_list; | ||
struct platform_device *cpufreq_dt; | ||
}; | ||
|
||
static struct platform_device *cpufreq_pdev; | ||
|
||
/* NOP function to disable OPP from setting clock */ | ||
static int airoha_cpufreq_config_clks_nop(struct device *dev, | ||
struct opp_table *opp_table, | ||
struct dev_pm_opp *opp, | ||
void *data, bool scaling_down) | ||
{ | ||
return 0; | ||
} | ||
|
||
static const char * const airoha_cpufreq_clk_names[] = { "cpu", NULL }; | ||
static const char * const airoha_cpufreq_pd_names[] = { "perf" }; | ||
|
||
static int airoha_cpufreq_probe(struct platform_device *pdev) | ||
{ | ||
const struct dev_pm_domain_attach_data attach_data = { | ||
.pd_names = airoha_cpufreq_pd_names, | ||
.num_pd_names = ARRAY_SIZE(airoha_cpufreq_pd_names), | ||
.pd_flags = PD_FLAG_DEV_LINK_ON | PD_FLAG_REQUIRED_OPP, | ||
}; | ||
struct dev_pm_opp_config config = { | ||
.clk_names = airoha_cpufreq_clk_names, | ||
.config_clks = airoha_cpufreq_config_clks_nop, | ||
}; | ||
struct platform_device *cpufreq_dt; | ||
struct airoha_cpufreq_priv *priv; | ||
struct device *dev = &pdev->dev; | ||
struct device *cpu_dev; | ||
int ret; | ||
|
||
/* CPUs refer to the same OPP table */ | ||
cpu_dev = get_cpu_device(0); | ||
if (!cpu_dev) | ||
return -ENODEV; | ||
|
||
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); | ||
if (!priv) | ||
return -ENOMEM; | ||
|
||
/* Set OPP table conf with NOP config_clks */ | ||
priv->opp_token = dev_pm_opp_set_config(cpu_dev, &config); | ||
if (priv->opp_token < 0) | ||
return dev_err_probe(dev, priv->opp_token, "Failed to set OPP config\n"); | ||
|
||
/* Attach PM for OPP */ | ||
ret = dev_pm_domain_attach_list(cpu_dev, &attach_data, | ||
&priv->pd_list); | ||
if (ret) | ||
goto clear_opp_config; | ||
|
||
cpufreq_dt = platform_device_register_simple("cpufreq-dt", -1, NULL, 0); | ||
ret = PTR_ERR_OR_ZERO(cpufreq_dt); | ||
if (ret) { | ||
dev_err(dev, "failed to create cpufreq-dt device: %d\n", ret); | ||
goto detach_pm; | ||
} | ||
|
||
priv->cpufreq_dt = cpufreq_dt; | ||
platform_set_drvdata(pdev, priv); | ||
|
||
return 0; | ||
|
||
detach_pm: | ||
dev_pm_domain_detach_list(priv->pd_list); | ||
clear_opp_config: | ||
dev_pm_opp_clear_config(priv->opp_token); | ||
|
||
return ret; | ||
} | ||
|
||
static void airoha_cpufreq_remove(struct platform_device *pdev) | ||
{ | ||
struct airoha_cpufreq_priv *priv = platform_get_drvdata(pdev); | ||
|
||
platform_device_unregister(priv->cpufreq_dt); | ||
|
||
dev_pm_domain_detach_list(priv->pd_list); | ||
|
||
dev_pm_opp_clear_config(priv->opp_token); | ||
} | ||
|
||
static struct platform_driver airoha_cpufreq_driver = { | ||
.probe = airoha_cpufreq_probe, | ||
.remove = airoha_cpufreq_remove, | ||
.driver = { | ||
.name = "airoha-cpufreq", | ||
}, | ||
}; | ||
|
||
static const struct of_device_id airoha_cpufreq_match_list[] __initconst = { | ||
{ .compatible = "airoha,en7581" }, | ||
{}, | ||
}; | ||
MODULE_DEVICE_TABLE(of, airoha_cpufreq_match_list); | ||
|
||
static int __init airoha_cpufreq_init(void) | ||
{ | ||
struct device_node *np = of_find_node_by_path("/"); | ||
const struct of_device_id *match; | ||
int ret; | ||
|
||
if (!np) | ||
return -ENODEV; | ||
|
||
match = of_match_node(airoha_cpufreq_match_list, np); | ||
of_node_put(np); | ||
if (!match) | ||
return -ENODEV; | ||
|
||
ret = platform_driver_register(&airoha_cpufreq_driver); | ||
if (unlikely(ret < 0)) | ||
return ret; | ||
|
||
cpufreq_pdev = platform_device_register_data(NULL, "airoha-cpufreq", | ||
-1, match, sizeof(*match)); | ||
ret = PTR_ERR_OR_ZERO(cpufreq_pdev); | ||
if (ret) | ||
platform_driver_unregister(&airoha_cpufreq_driver); | ||
|
||
return ret; | ||
} | ||
module_init(airoha_cpufreq_init); | ||
|
||
static void __exit airoha_cpufreq_exit(void) | ||
{ | ||
platform_device_unregister(cpufreq_pdev); | ||
platform_driver_unregister(&airoha_cpufreq_driver); | ||
} | ||
module_exit(airoha_cpufreq_exit); | ||
|
||
MODULE_AUTHOR("Christian Marangi <ansuelsmth@gmail.com>"); | ||
MODULE_DESCRIPTION("CPUfreq driver for Airoha SoCs"); | ||
MODULE_LICENSE("GPL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.