Commit 4f60aa29 authored by Leonard Crestez's avatar Leonard Crestez Committed by Angus Ainslie (Purism)

cpufreq: Add imx-cpufreq-dt driver

Right now in upstream imx8m cpufreq support just lists a common subset
of OPPs because the higher ones should only be attempted after checking
speed grading in fuses.

Add a small driver which checks speed grading from nvmem cells before
registering cpufreq-dt.

This driver allows unlocking all frequencies for imx8mm and imx8mq and
could be applied to other chips like imx7d
Signed-off-by: default avatarLeonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent 850eb396
......@@ -19,6 +19,12 @@
#define OCOTP_CFG3_MKT_SEGMENT_SHIFT 6
#define OCOTP_CFG3_MKT_SEGMENT_MASK (0x3 << 6)
static const struct of_device_id imx_cpufreq_dt_match_list[] = {
{ .compatible = "fsl,imx8mm" },
{ .compatible = "fsl,imx8mq" },
{}
};
/* cpufreq-dt device registered by imx-cpufreq-dt */
static struct platform_device *cpufreq_dt_pdev;
static struct opp_table *cpufreq_opp_table;
......@@ -26,10 +32,18 @@ static struct opp_table *cpufreq_opp_table;
static int imx_cpufreq_dt_probe(struct platform_device *pdev)
{
struct device *cpu_dev = get_cpu_device(0);
struct device_node *np;
const struct of_device_id *match;
u32 cell_value, supported_hw[2];
int speed_grade, mkt_segment;
int ret;
np = of_find_node_by_path("/");
match = of_match_node(imx_cpufreq_dt_match_list, np);
of_node_put(np);
if (!match)
return -ENODEV;
ret = nvmem_cell_read_u32(cpu_dev, "speed_grade", &cell_value);
if (ret)
return ret;
......
......@@ -181,6 +181,9 @@ static int __init imx8_soc_init(void)
goto free_rev;
}
if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT))
platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT))
platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
......
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