Commit 0411f0d1 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branch 'pm-cpufreq'

* pm-cpufreq:
  cpufreq: intel_pstate: Simplify intel_pstate_cpu_init()
  cpufreq: qcom: Add support for krait based socs
  cpufreq: imx6q-cpufreq: Improve the logic of -EPROBE_DEFER handling
  cpufreq: Use scnprintf() for avoiding potential buffer overflow
  Documentation: intel_pstate: update links for references
  cpufreq: intel_pstate: Consolidate policy verification
  cpufreq: dt: Allow platform specific intermediate callbacks
  cpufreq: imx-cpufreq-dt: Correct i.MX8MP's market segment fuse location
  cpufreq: imx6q: read OCOTP through nvmem for imx6q
  cpufreq: imx6q: fix error handling
  cpufreq: imx-cpufreq-dt: Add "cpu-supply" property check
  cpufreq: ti-cpufreq: Add support for OPP_PLUS
  cpufreq: imx6q: Fixes unwanted cpu overclocking on i.MX6ULL
parents be4f6540 5ac54113
...@@ -734,10 +734,10 @@ References ...@@ -734,10 +734,10 @@ References
========== ==========
.. [1] Kristen Accardi, *Balancing Power and Performance in the Linux Kernel*, .. [1] Kristen Accardi, *Balancing Power and Performance in the Linux Kernel*,
http://events.linuxfoundation.org/sites/events/files/slides/LinuxConEurope_2015.pdf https://events.static.linuxfound.org/sites/events/files/slides/LinuxConEurope_2015.pdf
.. [2] *Intel® 64 and IA-32 Architectures Software Developers Manual Volume 3: System Programming Guide*, .. [2] *Intel® 64 and IA-32 Architectures Software Developers Manual Volume 3: System Programming Guide*,
http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-system-programming-manual-325384.html https://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-system-programming-manual-325384.html
.. [3] *Advanced Configuration and Power Interface Specification*, .. [3] *Advanced Configuration and Power Interface Specification*,
https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
...@@ -19,7 +19,8 @@ In 'cpu' nodes: ...@@ -19,7 +19,8 @@ In 'cpu' nodes:
In 'operating-points-v2' table: In 'operating-points-v2' table:
- compatible: Should be - compatible: Should be
- 'operating-points-v2-kryo-cpu' for apq8096 and msm8996. - 'operating-points-v2-kryo-cpu' for apq8096, msm8996, msm8974,
apq8064, ipq8064, msm8960 and ipq8074.
Optional properties: Optional properties:
-------------------- --------------------
......
...@@ -128,7 +128,7 @@ config ARM_OMAP2PLUS_CPUFREQ ...@@ -128,7 +128,7 @@ config ARM_OMAP2PLUS_CPUFREQ
config ARM_QCOM_CPUFREQ_NVMEM config ARM_QCOM_CPUFREQ_NVMEM
tristate "Qualcomm nvmem based CPUFreq" tristate "Qualcomm nvmem based CPUFreq"
depends on ARM64 depends on ARCH_QCOM
depends on QCOM_QFPROM depends on QCOM_QFPROM
depends on QCOM_SMEM depends on QCOM_SMEM
select PM_OPP select PM_OPP
......
...@@ -141,6 +141,11 @@ static const struct of_device_id blacklist[] __initconst = { ...@@ -141,6 +141,11 @@ static const struct of_device_id blacklist[] __initconst = {
{ .compatible = "ti,dra7", }, { .compatible = "ti,dra7", },
{ .compatible = "ti,omap3", }, { .compatible = "ti,omap3", },
{ .compatible = "qcom,ipq8064", },
{ .compatible = "qcom,apq8064", },
{ .compatible = "qcom,msm8974", },
{ .compatible = "qcom,msm8960", },
{ } { }
}; };
......
...@@ -363,6 +363,10 @@ static int dt_cpufreq_probe(struct platform_device *pdev) ...@@ -363,6 +363,10 @@ static int dt_cpufreq_probe(struct platform_device *pdev)
dt_cpufreq_driver.resume = data->resume; dt_cpufreq_driver.resume = data->resume;
if (data->suspend) if (data->suspend)
dt_cpufreq_driver.suspend = data->suspend; dt_cpufreq_driver.suspend = data->suspend;
if (data->get_intermediate) {
dt_cpufreq_driver.target_intermediate = data->target_intermediate;
dt_cpufreq_driver.get_intermediate = data->get_intermediate;
}
} }
ret = cpufreq_register_driver(&dt_cpufreq_driver); ret = cpufreq_register_driver(&dt_cpufreq_driver);
......
...@@ -14,6 +14,10 @@ struct cpufreq_policy; ...@@ -14,6 +14,10 @@ struct cpufreq_policy;
struct cpufreq_dt_platform_data { struct cpufreq_dt_platform_data {
bool have_governor_per_policy; bool have_governor_per_policy;
unsigned int (*get_intermediate)(struct cpufreq_policy *policy,
unsigned int index);
int (*target_intermediate)(struct cpufreq_policy *policy,
unsigned int index);
int (*suspend)(struct cpufreq_policy *policy); int (*suspend)(struct cpufreq_policy *policy);
int (*resume)(struct cpufreq_policy *policy); int (*resume)(struct cpufreq_policy *policy);
}; };
......
...@@ -90,35 +90,35 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) ...@@ -90,35 +90,35 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
if (policy->fast_switch_enabled) if (policy->fast_switch_enabled)
return 0; return 0;
len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n"); len += scnprintf(buf + len, PAGE_SIZE - len, " From : To\n");
len += snprintf(buf + len, PAGE_SIZE - len, " : "); len += scnprintf(buf + len, PAGE_SIZE - len, " : ");
for (i = 0; i < stats->state_num; i++) { for (i = 0; i < stats->state_num; i++) {
if (len >= PAGE_SIZE) if (len >= PAGE_SIZE)
break; break;
len += snprintf(buf + len, PAGE_SIZE - len, "%9u ", len += scnprintf(buf + len, PAGE_SIZE - len, "%9u ",
stats->freq_table[i]); stats->freq_table[i]);
} }
if (len >= PAGE_SIZE) if (len >= PAGE_SIZE)
return PAGE_SIZE; return PAGE_SIZE;
len += snprintf(buf + len, PAGE_SIZE - len, "\n"); len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
for (i = 0; i < stats->state_num; i++) { for (i = 0; i < stats->state_num; i++) {
if (len >= PAGE_SIZE) if (len >= PAGE_SIZE)
break; break;
len += snprintf(buf + len, PAGE_SIZE - len, "%9u: ", len += scnprintf(buf + len, PAGE_SIZE - len, "%9u: ",
stats->freq_table[i]); stats->freq_table[i]);
for (j = 0; j < stats->state_num; j++) { for (j = 0; j < stats->state_num; j++) {
if (len >= PAGE_SIZE) if (len >= PAGE_SIZE)
break; break;
len += snprintf(buf + len, PAGE_SIZE - len, "%9u ", len += scnprintf(buf + len, PAGE_SIZE - len, "%9u ",
stats->trans_table[i*stats->max_state+j]); stats->trans_table[i*stats->max_state+j]);
} }
if (len >= PAGE_SIZE) if (len >= PAGE_SIZE)
break; break;
len += snprintf(buf + len, PAGE_SIZE - len, "\n"); len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
} }
if (len >= PAGE_SIZE) { if (len >= PAGE_SIZE) {
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#define IMX8MN_OCOTP_CFG3_SPEED_GRADE_MASK (0xf << 8) #define IMX8MN_OCOTP_CFG3_SPEED_GRADE_MASK (0xf << 8)
#define OCOTP_CFG3_MKT_SEGMENT_SHIFT 6 #define OCOTP_CFG3_MKT_SEGMENT_SHIFT 6
#define OCOTP_CFG3_MKT_SEGMENT_MASK (0x3 << 6) #define OCOTP_CFG3_MKT_SEGMENT_MASK (0x3 << 6)
#define IMX8MP_OCOTP_CFG3_MKT_SEGMENT_SHIFT 5
#define IMX8MP_OCOTP_CFG3_MKT_SEGMENT_MASK (0x3 << 5)
/* cpufreq-dt device registered by imx-cpufreq-dt */ /* cpufreq-dt device registered by imx-cpufreq-dt */
static struct platform_device *cpufreq_dt_pdev; static struct platform_device *cpufreq_dt_pdev;
...@@ -31,6 +33,9 @@ static int imx_cpufreq_dt_probe(struct platform_device *pdev) ...@@ -31,6 +33,9 @@ static int imx_cpufreq_dt_probe(struct platform_device *pdev)
int speed_grade, mkt_segment; int speed_grade, mkt_segment;
int ret; int ret;
if (!of_find_property(cpu_dev->of_node, "cpu-supply", NULL))
return -ENODEV;
ret = nvmem_cell_read_u32(cpu_dev, "speed_grade", &cell_value); ret = nvmem_cell_read_u32(cpu_dev, "speed_grade", &cell_value);
if (ret) if (ret)
return ret; return ret;
...@@ -42,7 +47,13 @@ static int imx_cpufreq_dt_probe(struct platform_device *pdev) ...@@ -42,7 +47,13 @@ static int imx_cpufreq_dt_probe(struct platform_device *pdev)
else else
speed_grade = (cell_value & OCOTP_CFG3_SPEED_GRADE_MASK) speed_grade = (cell_value & OCOTP_CFG3_SPEED_GRADE_MASK)
>> OCOTP_CFG3_SPEED_GRADE_SHIFT; >> OCOTP_CFG3_SPEED_GRADE_SHIFT;
mkt_segment = (cell_value & OCOTP_CFG3_MKT_SEGMENT_MASK) >> OCOTP_CFG3_MKT_SEGMENT_SHIFT;
if (of_machine_is_compatible("fsl,imx8mp"))
mkt_segment = (cell_value & IMX8MP_OCOTP_CFG3_MKT_SEGMENT_MASK)
>> IMX8MP_OCOTP_CFG3_MKT_SEGMENT_SHIFT;
else
mkt_segment = (cell_value & OCOTP_CFG3_MKT_SEGMENT_MASK)
>> OCOTP_CFG3_MKT_SEGMENT_SHIFT;
/* /*
* Early samples without fuses written report "0 0" which may NOT * Early samples without fuses written report "0 0" which may NOT
......
...@@ -216,20 +216,27 @@ static struct cpufreq_driver imx6q_cpufreq_driver = { ...@@ -216,20 +216,27 @@ static struct cpufreq_driver imx6q_cpufreq_driver = {
#define OCOTP_CFG3_SPEED_996MHZ 0x2 #define OCOTP_CFG3_SPEED_996MHZ 0x2
#define OCOTP_CFG3_SPEED_852MHZ 0x1 #define OCOTP_CFG3_SPEED_852MHZ 0x1
static void imx6q_opp_check_speed_grading(struct device *dev) static int imx6q_opp_check_speed_grading(struct device *dev)
{ {
struct device_node *np; struct device_node *np;
void __iomem *base; void __iomem *base;
u32 val; u32 val;
int ret;
if (of_find_property(dev->of_node, "nvmem-cells", NULL)) {
ret = nvmem_cell_read_u32(dev, "speed_grade", &val);
if (ret)
return ret;
} else {
np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ocotp"); np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ocotp");
if (!np) if (!np)
return; return -ENOENT;
base = of_iomap(np, 0); base = of_iomap(np, 0);
of_node_put(np);
if (!base) { if (!base) {
dev_err(dev, "failed to map ocotp\n"); dev_err(dev, "failed to map ocotp\n");
goto put_node; return -EFAULT;
} }
/* /*
...@@ -241,6 +248,9 @@ static void imx6q_opp_check_speed_grading(struct device *dev) ...@@ -241,6 +248,9 @@ static void imx6q_opp_check_speed_grading(struct device *dev)
* We need to set the max speed of ARM according to fuse map. * We need to set the max speed of ARM according to fuse map.
*/ */
val = readl_relaxed(base + OCOTP_CFG3); val = readl_relaxed(base + OCOTP_CFG3);
iounmap(base);
}
val >>= OCOTP_CFG3_SPEED_SHIFT; val >>= OCOTP_CFG3_SPEED_SHIFT;
val &= 0x3; val &= 0x3;
...@@ -257,9 +267,8 @@ static void imx6q_opp_check_speed_grading(struct device *dev) ...@@ -257,9 +267,8 @@ static void imx6q_opp_check_speed_grading(struct device *dev)
if (dev_pm_opp_disable(dev, 1200000000)) if (dev_pm_opp_disable(dev, 1200000000))
dev_warn(dev, "failed to disable 1.2GHz OPP\n"); dev_warn(dev, "failed to disable 1.2GHz OPP\n");
} }
iounmap(base);
put_node: return 0;
of_node_put(np);
} }
#define OCOTP_CFG3_6UL_SPEED_696MHZ 0x2 #define OCOTP_CFG3_6UL_SPEED_696MHZ 0x2
...@@ -280,6 +289,9 @@ static int imx6ul_opp_check_speed_grading(struct device *dev) ...@@ -280,6 +289,9 @@ static int imx6ul_opp_check_speed_grading(struct device *dev)
void __iomem *base; void __iomem *base;
np = of_find_compatible_node(NULL, NULL, "fsl,imx6ul-ocotp"); np = of_find_compatible_node(NULL, NULL, "fsl,imx6ul-ocotp");
if (!np)
np = of_find_compatible_node(NULL, NULL,
"fsl,imx6ull-ocotp");
if (!np) if (!np)
return -ENOENT; return -ENOENT;
...@@ -378,23 +390,22 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) ...@@ -378,23 +390,22 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
goto put_reg; goto put_reg;
} }
/* Because we have added the OPPs here, we must free them */
free_opp = true;
if (of_machine_is_compatible("fsl,imx6ul") || if (of_machine_is_compatible("fsl,imx6ul") ||
of_machine_is_compatible("fsl,imx6ull")) { of_machine_is_compatible("fsl,imx6ull")) {
ret = imx6ul_opp_check_speed_grading(cpu_dev); ret = imx6ul_opp_check_speed_grading(cpu_dev);
} else {
ret = imx6q_opp_check_speed_grading(cpu_dev);
}
if (ret) { if (ret) {
if (ret == -EPROBE_DEFER) if (ret != -EPROBE_DEFER)
goto put_node;
dev_err(cpu_dev, "failed to read ocotp: %d\n", dev_err(cpu_dev, "failed to read ocotp: %d\n",
ret); ret);
goto put_node; goto out_free_opp;
}
} else {
imx6q_opp_check_speed_grading(cpu_dev);
} }
/* Because we have added the OPPs here, we must free them */
free_opp = true;
num = dev_pm_opp_get_opp_count(cpu_dev); num = dev_pm_opp_get_opp_count(cpu_dev);
if (num < 0) { if (num < 0) {
ret = num; ret = num;
......
...@@ -2155,15 +2155,19 @@ static void intel_pstate_adjust_policy_max(struct cpudata *cpu, ...@@ -2155,15 +2155,19 @@ static void intel_pstate_adjust_policy_max(struct cpudata *cpu,
} }
} }
static int intel_pstate_verify_policy(struct cpufreq_policy_data *policy) static void intel_pstate_verify_cpu_policy(struct cpudata *cpu,
struct cpufreq_policy_data *policy)
{ {
struct cpudata *cpu = all_cpu_data[policy->cpu];
update_turbo_state(); update_turbo_state();
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
intel_pstate_get_max_freq(cpu)); intel_pstate_get_max_freq(cpu));
intel_pstate_adjust_policy_max(cpu, policy); intel_pstate_adjust_policy_max(cpu, policy);
}
static int intel_pstate_verify_policy(struct cpufreq_policy_data *policy)
{
intel_pstate_verify_cpu_policy(all_cpu_data[policy->cpu], policy);
return 0; return 0;
} }
...@@ -2243,9 +2247,10 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) ...@@ -2243,9 +2247,10 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
if (ret) if (ret)
return ret; return ret;
if (IS_ENABLED(CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE)) /*
policy->policy = CPUFREQ_POLICY_PERFORMANCE; * Set the policy to powersave to provide a valid fallback value in case
else * the default cpufreq governor is neither powersave nor performance.
*/
policy->policy = CPUFREQ_POLICY_POWERSAVE; policy->policy = CPUFREQ_POLICY_POWERSAVE;
return 0; return 0;
...@@ -2268,12 +2273,7 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy_data *policy) ...@@ -2268,12 +2273,7 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy_data *policy)
{ {
struct cpudata *cpu = all_cpu_data[policy->cpu]; struct cpudata *cpu = all_cpu_data[policy->cpu];
update_turbo_state(); intel_pstate_verify_cpu_policy(cpu, policy);
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
intel_pstate_get_max_freq(cpu));
intel_pstate_adjust_policy_max(cpu, policy);
intel_pstate_update_perf_limits(cpu, policy->min, policy->max); intel_pstate_update_perf_limits(cpu, policy->min, policy->max);
return 0; return 0;
......
...@@ -49,12 +49,14 @@ struct qcom_cpufreq_drv; ...@@ -49,12 +49,14 @@ struct qcom_cpufreq_drv;
struct qcom_cpufreq_match_data { struct qcom_cpufreq_match_data {
int (*get_version)(struct device *cpu_dev, int (*get_version)(struct device *cpu_dev,
struct nvmem_cell *speedbin_nvmem, struct nvmem_cell *speedbin_nvmem,
char **pvs_name,
struct qcom_cpufreq_drv *drv); struct qcom_cpufreq_drv *drv);
const char **genpd_names; const char **genpd_names;
}; };
struct qcom_cpufreq_drv { struct qcom_cpufreq_drv {
struct opp_table **opp_tables; struct opp_table **names_opp_tables;
struct opp_table **hw_opp_tables;
struct opp_table **genpd_opp_tables; struct opp_table **genpd_opp_tables;
u32 versions; u32 versions;
const struct qcom_cpufreq_match_data *data; const struct qcom_cpufreq_match_data *data;
...@@ -62,6 +64,84 @@ struct qcom_cpufreq_drv { ...@@ -62,6 +64,84 @@ struct qcom_cpufreq_drv {
static struct platform_device *cpufreq_dt_pdev, *cpufreq_pdev; static struct platform_device *cpufreq_dt_pdev, *cpufreq_pdev;
static void get_krait_bin_format_a(struct device *cpu_dev,
int *speed, int *pvs, int *pvs_ver,
struct nvmem_cell *pvs_nvmem, u8 *buf)
{
u32 pte_efuse;
pte_efuse = *((u32 *)buf);
*speed = pte_efuse & 0xf;
if (*speed == 0xf)
*speed = (pte_efuse >> 4) & 0xf;
if (*speed == 0xf) {
*speed = 0;
dev_warn(cpu_dev, "Speed bin: Defaulting to %d\n", *speed);
} else {
dev_dbg(cpu_dev, "Speed bin: %d\n", *speed);
}
*pvs = (pte_efuse >> 10) & 0x7;
if (*pvs == 0x7)
*pvs = (pte_efuse >> 13) & 0x7;
if (*pvs == 0x7) {
*pvs = 0;
dev_warn(cpu_dev, "PVS bin: Defaulting to %d\n", *pvs);
} else {
dev_dbg(cpu_dev, "PVS bin: %d\n", *pvs);
}
}
static void get_krait_bin_format_b(struct device *cpu_dev,
int *speed, int *pvs, int *pvs_ver,
struct nvmem_cell *pvs_nvmem, u8 *buf)
{
u32 pte_efuse, redundant_sel;
pte_efuse = *((u32 *)buf);
redundant_sel = (pte_efuse >> 24) & 0x7;
*pvs_ver = (pte_efuse >> 4) & 0x3;
switch (redundant_sel) {
case 1:
*pvs = ((pte_efuse >> 28) & 0x8) | ((pte_efuse >> 6) & 0x7);
*speed = (pte_efuse >> 27) & 0xf;
break;
case 2:
*pvs = (pte_efuse >> 27) & 0xf;
*speed = pte_efuse & 0x7;
break;
default:
/* 4 bits of PVS are in efuse register bits 31, 8-6. */
*pvs = ((pte_efuse >> 28) & 0x8) | ((pte_efuse >> 6) & 0x7);
*speed = pte_efuse & 0x7;
}
/* Check SPEED_BIN_BLOW_STATUS */
if (pte_efuse & BIT(3)) {
dev_dbg(cpu_dev, "Speed bin: %d\n", *speed);
} else {
dev_warn(cpu_dev, "Speed bin not set. Defaulting to 0!\n");
*speed = 0;
}
/* Check PVS_BLOW_STATUS */
pte_efuse = *(((u32 *)buf) + 4);
pte_efuse &= BIT(21);
if (pte_efuse) {
dev_dbg(cpu_dev, "PVS bin: %d\n", *pvs);
} else {
dev_warn(cpu_dev, "PVS bin not set. Defaulting to 0!\n");
*pvs = 0;
}
dev_dbg(cpu_dev, "PVS version: %d\n", *pvs_ver);
}
static enum _msm8996_version qcom_cpufreq_get_msm_id(void) static enum _msm8996_version qcom_cpufreq_get_msm_id(void)
{ {
size_t len; size_t len;
...@@ -93,11 +173,13 @@ static enum _msm8996_version qcom_cpufreq_get_msm_id(void) ...@@ -93,11 +173,13 @@ static enum _msm8996_version qcom_cpufreq_get_msm_id(void)
static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev, static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
struct nvmem_cell *speedbin_nvmem, struct nvmem_cell *speedbin_nvmem,
char **pvs_name,
struct qcom_cpufreq_drv *drv) struct qcom_cpufreq_drv *drv)
{ {
size_t len; size_t len;
u8 *speedbin; u8 *speedbin;
enum _msm8996_version msm8996_version; enum _msm8996_version msm8996_version;
*pvs_name = NULL;
msm8996_version = qcom_cpufreq_get_msm_id(); msm8996_version = qcom_cpufreq_get_msm_id();
if (NUM_OF_MSM8996_VERSIONS == msm8996_version) { if (NUM_OF_MSM8996_VERSIONS == msm8996_version) {
...@@ -125,10 +207,51 @@ static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev, ...@@ -125,10 +207,51 @@ static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
return 0; return 0;
} }
static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
struct nvmem_cell *speedbin_nvmem,
char **pvs_name,
struct qcom_cpufreq_drv *drv)
{
int speed = 0, pvs = 0, pvs_ver = 0;
u8 *speedbin;
size_t len;
speedbin = nvmem_cell_read(speedbin_nvmem, &len);
if (IS_ERR(speedbin))
return PTR_ERR(speedbin);
switch (len) {
case 4:
get_krait_bin_format_a(cpu_dev, &speed, &pvs, &pvs_ver,
speedbin_nvmem, speedbin);
break;
case 8:
get_krait_bin_format_b(cpu_dev, &speed, &pvs, &pvs_ver,
speedbin_nvmem, speedbin);
break;
default:
dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n");
return -ENODEV;
}
snprintf(*pvs_name, sizeof("speedXX-pvsXX-vXX"), "speed%d-pvs%d-v%d",
speed, pvs, pvs_ver);
drv->versions = (1 << speed);
kfree(speedbin);
return 0;
}
static const struct qcom_cpufreq_match_data match_data_kryo = { static const struct qcom_cpufreq_match_data match_data_kryo = {
.get_version = qcom_cpufreq_kryo_name_version, .get_version = qcom_cpufreq_kryo_name_version,
}; };
static const struct qcom_cpufreq_match_data match_data_krait = {
.get_version = qcom_cpufreq_krait_name_version,
};
static const char *qcs404_genpd_names[] = { "cpr", NULL }; static const char *qcs404_genpd_names[] = { "cpr", NULL };
static const struct qcom_cpufreq_match_data match_data_qcs404 = { static const struct qcom_cpufreq_match_data match_data_qcs404 = {
...@@ -141,6 +264,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) ...@@ -141,6 +264,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
struct nvmem_cell *speedbin_nvmem; struct nvmem_cell *speedbin_nvmem;
struct device_node *np; struct device_node *np;
struct device *cpu_dev; struct device *cpu_dev;
char *pvs_name = "speedXX-pvsXX-vXX";
unsigned cpu; unsigned cpu;
const struct of_device_id *match; const struct of_device_id *match;
int ret; int ret;
...@@ -153,7 +277,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) ...@@ -153,7 +277,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
if (!np) if (!np)
return -ENOENT; return -ENOENT;
ret = of_device_is_compatible(np, "operating-points-v2-kryo-cpu"); ret = of_device_is_compatible(np, "operating-points-v2-qcom-cpu");
if (!ret) { if (!ret) {
of_node_put(np); of_node_put(np);
return -ENOENT; return -ENOENT;
...@@ -181,7 +305,8 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) ...@@ -181,7 +305,8 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
goto free_drv; goto free_drv;
} }
ret = drv->data->get_version(cpu_dev, speedbin_nvmem, drv); ret = drv->data->get_version(cpu_dev,
speedbin_nvmem, &pvs_name, drv);
if (ret) { if (ret) {
nvmem_cell_put(speedbin_nvmem); nvmem_cell_put(speedbin_nvmem);
goto free_drv; goto free_drv;
...@@ -190,12 +315,20 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) ...@@ -190,12 +315,20 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
} }
of_node_put(np); of_node_put(np);
drv->opp_tables = kcalloc(num_possible_cpus(), sizeof(*drv->opp_tables), drv->names_opp_tables = kcalloc(num_possible_cpus(),
sizeof(*drv->names_opp_tables),
GFP_KERNEL); GFP_KERNEL);
if (!drv->opp_tables) { if (!drv->names_opp_tables) {
ret = -ENOMEM; ret = -ENOMEM;
goto free_drv; goto free_drv;
} }
drv->hw_opp_tables = kcalloc(num_possible_cpus(),
sizeof(*drv->hw_opp_tables),
GFP_KERNEL);
if (!drv->hw_opp_tables) {
ret = -ENOMEM;
goto free_opp_names;
}
drv->genpd_opp_tables = kcalloc(num_possible_cpus(), drv->genpd_opp_tables = kcalloc(num_possible_cpus(),
sizeof(*drv->genpd_opp_tables), sizeof(*drv->genpd_opp_tables),
...@@ -213,11 +346,23 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) ...@@ -213,11 +346,23 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
} }
if (drv->data->get_version) { if (drv->data->get_version) {
drv->opp_tables[cpu] =
dev_pm_opp_set_supported_hw(cpu_dev, if (pvs_name) {
&drv->versions, 1); drv->names_opp_tables[cpu] = dev_pm_opp_set_prop_name(
if (IS_ERR(drv->opp_tables[cpu])) { cpu_dev,
ret = PTR_ERR(drv->opp_tables[cpu]); pvs_name);
if (IS_ERR(drv->names_opp_tables[cpu])) {
ret = PTR_ERR(drv->names_opp_tables[cpu]);
dev_err(cpu_dev, "Failed to add OPP name %s\n",
pvs_name);
goto free_opp;
}
}
drv->hw_opp_tables[cpu] = dev_pm_opp_set_supported_hw(
cpu_dev, &drv->versions, 1);
if (IS_ERR(drv->hw_opp_tables[cpu])) {
ret = PTR_ERR(drv->hw_opp_tables[cpu]);
dev_err(cpu_dev, dev_err(cpu_dev,
"Failed to set supported hardware\n"); "Failed to set supported hardware\n");
goto free_genpd_opp; goto free_genpd_opp;
...@@ -259,11 +404,18 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) ...@@ -259,11 +404,18 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
kfree(drv->genpd_opp_tables); kfree(drv->genpd_opp_tables);
free_opp: free_opp:
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
if (IS_ERR_OR_NULL(drv->opp_tables[cpu])) if (IS_ERR_OR_NULL(drv->names_opp_tables[cpu]))
break;
dev_pm_opp_put_prop_name(drv->names_opp_tables[cpu]);
}
for_each_possible_cpu(cpu) {
if (IS_ERR_OR_NULL(drv->hw_opp_tables[cpu]))
break; break;
dev_pm_opp_put_supported_hw(drv->opp_tables[cpu]); dev_pm_opp_put_supported_hw(drv->hw_opp_tables[cpu]);
} }
kfree(drv->opp_tables); kfree(drv->hw_opp_tables);
free_opp_names:
kfree(drv->names_opp_tables);
free_drv: free_drv:
kfree(drv); kfree(drv);
...@@ -278,13 +430,16 @@ static int qcom_cpufreq_remove(struct platform_device *pdev) ...@@ -278,13 +430,16 @@ static int qcom_cpufreq_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) {
if (drv->opp_tables[cpu]) if (drv->names_opp_tables[cpu])
dev_pm_opp_put_supported_hw(drv->opp_tables[cpu]); dev_pm_opp_put_supported_hw(drv->names_opp_tables[cpu]);
if (drv->hw_opp_tables[cpu])
dev_pm_opp_put_supported_hw(drv->hw_opp_tables[cpu]);
if (drv->genpd_opp_tables[cpu]) if (drv->genpd_opp_tables[cpu])
dev_pm_opp_detach_genpd(drv->genpd_opp_tables[cpu]); dev_pm_opp_detach_genpd(drv->genpd_opp_tables[cpu]);
} }
kfree(drv->opp_tables); kfree(drv->names_opp_tables);
kfree(drv->hw_opp_tables);
kfree(drv->genpd_opp_tables); kfree(drv->genpd_opp_tables);
kfree(drv); kfree(drv);
...@@ -303,6 +458,10 @@ static const struct of_device_id qcom_cpufreq_match_list[] __initconst = { ...@@ -303,6 +458,10 @@ static const struct of_device_id qcom_cpufreq_match_list[] __initconst = {
{ .compatible = "qcom,apq8096", .data = &match_data_kryo }, { .compatible = "qcom,apq8096", .data = &match_data_kryo },
{ .compatible = "qcom,msm8996", .data = &match_data_kryo }, { .compatible = "qcom,msm8996", .data = &match_data_kryo },
{ .compatible = "qcom,qcs404", .data = &match_data_qcs404 }, { .compatible = "qcom,qcs404", .data = &match_data_qcs404 },
{ .compatible = "qcom,ipq8064", .data = &match_data_krait },
{ .compatible = "qcom,apq8064", .data = &match_data_krait },
{ .compatible = "qcom,msm8974", .data = &match_data_krait },
{ .compatible = "qcom,msm8960", .data = &match_data_krait },
{}, {},
}; };
......
...@@ -25,11 +25,14 @@ ...@@ -25,11 +25,14 @@
#define DRA7_EFUSE_HAS_OD_MPU_OPP 11 #define DRA7_EFUSE_HAS_OD_MPU_OPP 11
#define DRA7_EFUSE_HAS_HIGH_MPU_OPP 15 #define DRA7_EFUSE_HAS_HIGH_MPU_OPP 15
#define DRA76_EFUSE_HAS_PLUS_MPU_OPP 18
#define DRA7_EFUSE_HAS_ALL_MPU_OPP 23 #define DRA7_EFUSE_HAS_ALL_MPU_OPP 23
#define DRA76_EFUSE_HAS_ALL_MPU_OPP 24
#define DRA7_EFUSE_NOM_MPU_OPP BIT(0) #define DRA7_EFUSE_NOM_MPU_OPP BIT(0)
#define DRA7_EFUSE_OD_MPU_OPP BIT(1) #define DRA7_EFUSE_OD_MPU_OPP BIT(1)
#define DRA7_EFUSE_HIGH_MPU_OPP BIT(2) #define DRA7_EFUSE_HIGH_MPU_OPP BIT(2)
#define DRA76_EFUSE_PLUS_MPU_OPP BIT(3)
#define OMAP3_CONTROL_DEVICE_STATUS 0x4800244C #define OMAP3_CONTROL_DEVICE_STATUS 0x4800244C
#define OMAP3_CONTROL_IDCODE 0x4830A204 #define OMAP3_CONTROL_IDCODE 0x4830A204
...@@ -80,6 +83,10 @@ static unsigned long dra7_efuse_xlate(struct ti_cpufreq_data *opp_data, ...@@ -80,6 +83,10 @@ static unsigned long dra7_efuse_xlate(struct ti_cpufreq_data *opp_data,
*/ */
switch (efuse) { switch (efuse) {
case DRA76_EFUSE_HAS_PLUS_MPU_OPP:
case DRA76_EFUSE_HAS_ALL_MPU_OPP:
calculated_efuse |= DRA76_EFUSE_PLUS_MPU_OPP;
/* Fall through */
case DRA7_EFUSE_HAS_ALL_MPU_OPP: case DRA7_EFUSE_HAS_ALL_MPU_OPP:
case DRA7_EFUSE_HAS_HIGH_MPU_OPP: case DRA7_EFUSE_HAS_HIGH_MPU_OPP:
calculated_efuse |= DRA7_EFUSE_HIGH_MPU_OPP; calculated_efuse |= DRA7_EFUSE_HIGH_MPU_OPP;
......
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