Skip to content

Commit 078d2f2

Browse files
Shuosheng Huangvireshk
authored andcommitted
cpufreq: sun50i: add a100 cpufreq support
Let's add cpufreq nvmem based for allwinner a100 soc. It's similar to h6, let us use efuse_xlate to extract the differentiated part. Signed-off-by: Shuosheng Huang <[email protected]> [[email protected]: add A100 to opp_match_list] Signed-off-by: Cody Eksal <[email protected]> Reviewed-by: Andre Przywara <[email protected]> Tested-by: Andre Przywara <[email protected]> Tested-by: Parthiban Nallathambi <[email protected]> Acked-by: Chen-Yu Tsai <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent 172bf5e commit 078d2f2

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

drivers/cpufreq/cpufreq-dt-platdev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static const struct of_device_id allowlist[] __initconst = {
103103
* platforms using "operating-points-v2" property.
104104
*/
105105
static const struct of_device_id blocklist[] __initconst = {
106+
{ .compatible = "allwinner,sun50i-a100" },
106107
{ .compatible = "allwinner,sun50i-h6", },
107108
{ .compatible = "allwinner,sun50i-h616", },
108109
{ .compatible = "allwinner,sun50i-h618", },

drivers/cpufreq/sun50i-cpufreq-nvmem.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#define NVMEM_MASK 0x7
2323
#define NVMEM_SHIFT 5
2424

25+
#define SUN50I_A100_NVMEM_MASK 0xf
26+
#define SUN50I_A100_NVMEM_SHIFT 12
27+
2528
static struct platform_device *cpufreq_dt_pdev, *sun50i_cpufreq_pdev;
2629

2730
struct sunxi_cpufreq_data {
@@ -45,6 +48,23 @@ static u32 sun50i_h6_efuse_xlate(u32 speedbin)
4548
return 0;
4649
}
4750

51+
static u32 sun50i_a100_efuse_xlate(u32 speedbin)
52+
{
53+
u32 efuse_value;
54+
55+
efuse_value = (speedbin >> SUN50I_A100_NVMEM_SHIFT) &
56+
SUN50I_A100_NVMEM_MASK;
57+
58+
switch (efuse_value) {
59+
case 0b100:
60+
return 2;
61+
case 0b010:
62+
return 1;
63+
default:
64+
return 0;
65+
}
66+
}
67+
4868
static int get_soc_id_revision(void)
4969
{
5070
#ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY
@@ -108,6 +128,10 @@ static struct sunxi_cpufreq_data sun50i_h6_cpufreq_data = {
108128
.efuse_xlate = sun50i_h6_efuse_xlate,
109129
};
110130

131+
static struct sunxi_cpufreq_data sun50i_a100_cpufreq_data = {
132+
.efuse_xlate = sun50i_a100_efuse_xlate,
133+
};
134+
111135
static struct sunxi_cpufreq_data sun50i_h616_cpufreq_data = {
112136
.efuse_xlate = sun50i_h616_efuse_xlate,
113137
};
@@ -116,6 +140,9 @@ static const struct of_device_id cpu_opp_match_list[] = {
116140
{ .compatible = "allwinner,sun50i-h6-operating-points",
117141
.data = &sun50i_h6_cpufreq_data,
118142
},
143+
{ .compatible = "allwinner,sun50i-a100-operating-points",
144+
.data = &sun50i_a100_cpufreq_data,
145+
},
119146
{ .compatible = "allwinner,sun50i-h616-operating-points",
120147
.data = &sun50i_h616_cpufreq_data,
121148
},
@@ -291,6 +318,7 @@ static struct platform_driver sun50i_cpufreq_driver = {
291318

292319
static const struct of_device_id sun50i_cpufreq_match_list[] = {
293320
{ .compatible = "allwinner,sun50i-h6" },
321+
{ .compatible = "allwinner,sun50i-a100" },
294322
{ .compatible = "allwinner,sun50i-h616" },
295323
{ .compatible = "allwinner,sun50i-h618" },
296324
{ .compatible = "allwinner,sun50i-h700" },

0 commit comments

Comments
 (0)