diff mbox series

[v6] cpufreq: qcom-nvmem: add support for IPQ8074

Message ID 20231013172033.3549476-1-robimarko@gmail.com
State New
Headers show
Series [v6] cpufreq: qcom-nvmem: add support for IPQ8074 | expand

Commit Message

Robert Marko Oct. 13, 2023, 5:20 p.m. UTC
IPQ8074 comes in 3 families:
* IPQ8070A/IPQ8071A (Acorn) up to 1.4GHz
* IPQ8172/IPQ8173/IPQ8174 (Oak) up to 1.4GHz
* IPQ8072A/IPQ8074A/IPQ8076A/IPQ8078A (Hawkeye) up to 2.2GHz

So, in order to be able to share one OPP table lets add support for IPQ8074
family based of SMEM SoC ID-s as speedbin fuse is always 0 on IPQ8074.

IPQ8074 compatible is blacklisted from DT platdev as the cpufreq device
will get created by NVMEM CPUFreq driver.

Signed-off-by: Robert Marko <robimarko@gmail.com>
Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
Changes in v6:
* Split IPQ8074 from the IPQ8064 as IPQ8064 has additional dependencies.

Changes in v4:
* Add support for IPQ8174 (Oak) family

Changes in v3:
* Use enum for SoC versions

Changes in v2:
* Print an error if SMEM ID is not part of the IPQ8074 family
and restrict the speed to Acorn variant (1.4GHz)

 drivers/cpufreq/cpufreq-dt-platdev.c |  1 +
 drivers/cpufreq/qcom-cpufreq-nvmem.c | 48 ++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

Comments

Robert Marko Oct. 13, 2023, 5:25 p.m. UTC | #1
On Fri, 13 Oct 2023 at 19:20, Robert Marko <robimarko@gmail.com> wrote:
>
> IPQ8074 comes in 3 families:
> * IPQ8070A/IPQ8071A (Acorn) up to 1.4GHz
> * IPQ8172/IPQ8173/IPQ8174 (Oak) up to 1.4GHz
> * IPQ8072A/IPQ8074A/IPQ8076A/IPQ8078A (Hawkeye) up to 2.2GHz
>
> So, in order to be able to share one OPP table lets add support for IPQ8074
> family based of SMEM SoC ID-s as speedbin fuse is always 0 on IPQ8074.
>
> IPQ8074 compatible is blacklisted from DT platdev as the cpufreq device
> will get created by NVMEM CPUFreq driver.
>
> Signed-off-by: Robert Marko <robimarko@gmail.com>
> Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> ---
> Changes in v6:
> * Split IPQ8074 from the IPQ8064 as IPQ8064 has additional dependencies.

I discussed this with Christian and we decided to split out IPQ8074 as
it is much simpler
than IPQ8064 and has no additional dependencies so it makes sense split it out.

Regards,
Robert
>
> Changes in v4:
> * Add support for IPQ8174 (Oak) family
>
> Changes in v3:
> * Use enum for SoC versions
>
> Changes in v2:
> * Print an error if SMEM ID is not part of the IPQ8074 family
> and restrict the speed to Acorn variant (1.4GHz)
>
>  drivers/cpufreq/cpufreq-dt-platdev.c |  1 +
>  drivers/cpufreq/qcom-cpufreq-nvmem.c | 48 ++++++++++++++++++++++++++++
>  2 files changed, 49 insertions(+)
>
> diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
> index 0b3776f558db..675da7f36846 100644
> --- a/drivers/cpufreq/cpufreq-dt-platdev.c
> +++ b/drivers/cpufreq/cpufreq-dt-platdev.c
> @@ -181,6 +181,7 @@ static const struct of_device_id blocklist[] __initconst = {
>         { .compatible = "ti,am62p5", },
>
>         { .compatible = "qcom,ipq8064", },
> +       { .compatible = "qcom,ipq8074", },
>         { .compatible = "qcom,apq8064", },
>         { .compatible = "qcom,msm8974", },
>         { .compatible = "qcom,msm8960", },
> diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c
> index 84d7033e5efe..3fa12648ceb6 100644
> --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
> +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
> @@ -30,6 +30,11 @@
>
>  #include <dt-bindings/arm/qcom,ids.h>
>
> +enum ipq8074_versions {
> +       IPQ8074_HAWKEYE_VERSION = 0,
> +       IPQ8074_ACORN_VERSION,
> +};
> +
>  struct qcom_cpufreq_drv;
>
>  struct qcom_cpufreq_match_data {
> @@ -203,6 +208,44 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
>         return ret;
>  }
>
> +static int qcom_cpufreq_ipq8074_name_version(struct device *cpu_dev,
> +                                            struct nvmem_cell *speedbin_nvmem,
> +                                            char **pvs_name,
> +                                            struct qcom_cpufreq_drv *drv)
> +{
> +       u32 msm_id;
> +       int ret;
> +       *pvs_name = NULL;
> +
> +       ret = qcom_smem_get_soc_id(&msm_id);
> +       if (ret)
> +               return ret;
> +
> +       switch (msm_id) {
> +       case QCOM_ID_IPQ8070A:
> +       case QCOM_ID_IPQ8071A:
> +       case QCOM_ID_IPQ8172:
> +       case QCOM_ID_IPQ8173:
> +       case QCOM_ID_IPQ8174:
> +               drv->versions = BIT(IPQ8074_ACORN_VERSION);
> +               break;
> +       case QCOM_ID_IPQ8072A:
> +       case QCOM_ID_IPQ8074A:
> +       case QCOM_ID_IPQ8076A:
> +       case QCOM_ID_IPQ8078A:
> +               drv->versions = BIT(IPQ8074_HAWKEYE_VERSION);
> +               break;
> +       default:
> +               dev_err(cpu_dev,
> +                       "SoC ID %u is not part of IPQ8074 family, limiting to 1.4GHz!\n",
> +                       msm_id);
> +               drv->versions = BIT(IPQ8074_ACORN_VERSION);
> +               break;
> +       }
> +
> +       return 0;
> +}
> +
>  static const struct qcom_cpufreq_match_data match_data_kryo = {
>         .get_version = qcom_cpufreq_kryo_name_version,
>  };
> @@ -217,6 +260,10 @@ static const struct qcom_cpufreq_match_data match_data_qcs404 = {
>         .genpd_names = qcs404_genpd_names,
>  };
>
> +static const struct qcom_cpufreq_match_data match_data_ipq8074 = {
> +       .get_version = qcom_cpufreq_ipq8074_name_version,
> +};
> +
>  static int qcom_cpufreq_probe(struct platform_device *pdev)
>  {
>         struct qcom_cpufreq_drv *drv;
> @@ -360,6 +407,7 @@ static const struct of_device_id qcom_cpufreq_match_list[] __initconst = {
>         { .compatible = "qcom,msm8996", .data = &match_data_kryo },
>         { .compatible = "qcom,qcs404", .data = &match_data_qcs404 },
>         { .compatible = "qcom,ipq8064", .data = &match_data_krait },
> +       { .compatible = "qcom,ipq8074", .data = &match_data_ipq8074 },
>         { .compatible = "qcom,apq8064", .data = &match_data_krait },
>         { .compatible = "qcom,msm8974", .data = &match_data_krait },
>         { .compatible = "qcom,msm8960", .data = &match_data_krait },
> --
> 2.41.0
>
Robert Marko Oct. 16, 2023, 8:29 a.m. UTC | #2
On Mon, 16 Oct 2023 at 10:22, Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 16-10-23, 09:02, Viresh Kumar wrote:
> > On 13-10-23, 19:20, Robert Marko wrote:
> > > IPQ8074 comes in 3 families:
> > > * IPQ8070A/IPQ8071A (Acorn) up to 1.4GHz
> > > * IPQ8172/IPQ8173/IPQ8174 (Oak) up to 1.4GHz
> > > * IPQ8072A/IPQ8074A/IPQ8076A/IPQ8078A (Hawkeye) up to 2.2GHz
> > >
> > > So, in order to be able to share one OPP table lets add support for IPQ8074
> > > family based of SMEM SoC ID-s as speedbin fuse is always 0 on IPQ8074.
> > >
> > > IPQ8074 compatible is blacklisted from DT platdev as the cpufreq device
> > > will get created by NVMEM CPUFreq driver.
> > >
> > > Signed-off-by: Robert Marko <robimarko@gmail.com>
> > > Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> > > ---
> > > Changes in v6:
> > > * Split IPQ8074 from the IPQ8064 as IPQ8064 has additional dependencies.
> >
> > Applied. Thanks.
>
> And it failed to build, please fix it. Dropped from my tree now.

I am looking at the error and it should not happen as the ID-s have
been in linux-next for a month now:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/include/dt-bindings/arm/qcom,ids.h?h=next-20231016&id=b8c889bef9797a58b8b5aad23875cc4d04b3efd3

They are also part of Bjorns 6.7 driver PR:
https://lore.kernel.org/all/20231015204014.855672-1-andersson@kernel.org/T/

Regards,
Robert

>
> --
> viresh
Robert Marko Oct. 16, 2023, 8:43 a.m. UTC | #3
On Mon, 16 Oct 2023 at 10:36, Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>
> On Mon, 16 Oct 2023 at 11:29, Robert Marko <robimarko@gmail.com> wrote:
> >
> > On Mon, 16 Oct 2023 at 10:22, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > >
> > > On 16-10-23, 09:02, Viresh Kumar wrote:
> > > > On 13-10-23, 19:20, Robert Marko wrote:
> > > > > IPQ8074 comes in 3 families:
> > > > > * IPQ8070A/IPQ8071A (Acorn) up to 1.4GHz
> > > > > * IPQ8172/IPQ8173/IPQ8174 (Oak) up to 1.4GHz
> > > > > * IPQ8072A/IPQ8074A/IPQ8076A/IPQ8078A (Hawkeye) up to 2.2GHz
> > > > >
> > > > > So, in order to be able to share one OPP table lets add support for IPQ8074
> > > > > family based of SMEM SoC ID-s as speedbin fuse is always 0 on IPQ8074.
> > > > >
> > > > > IPQ8074 compatible is blacklisted from DT platdev as the cpufreq device
> > > > > will get created by NVMEM CPUFreq driver.
> > > > >
> > > > > Signed-off-by: Robert Marko <robimarko@gmail.com>
> > > > > Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> > > > > ---
> > > > > Changes in v6:
> > > > > * Split IPQ8074 from the IPQ8064 as IPQ8064 has additional dependencies.
> > > >
> > > > Applied. Thanks.
> > >
> > > And it failed to build, please fix it. Dropped from my tree now.
> >
> > I am looking at the error and it should not happen as the ID-s have
> > been in linux-next for a month now:
> > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/include/dt-bindings/arm/qcom,ids.h?h=next-20231016&id=b8c889bef9797a58b8b5aad23875cc4d04b3efd3
> >
> > They are also part of Bjorns 6.7 driver PR:
> > https://lore.kernel.org/all/20231015204014.855672-1-andersson@kernel.org/T/
>
> But Bjorn's tree isn't a part of the cpufreq tree. In such cases it is
> typical to ask first maintainer to create an immutable branch / tag,
> which can later be also merged into another tree without going into
> troubles of merging the whole tree of the irrelevant subsystem.

Ok, I understand now, the thing is that the ID-s were added for
socinfo initially but recently
I finally had somebody with access to the Oak HW so I added them to
cpufreq as well.

What can I do to help this get resolved?

Regards,
Robert
>
>
> --
> With best wishes
> Dmitry
diff mbox series

Patch

diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
index 0b3776f558db..675da7f36846 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -181,6 +181,7 @@  static const struct of_device_id blocklist[] __initconst = {
 	{ .compatible = "ti,am62p5", },
 
 	{ .compatible = "qcom,ipq8064", },
+	{ .compatible = "qcom,ipq8074", },
 	{ .compatible = "qcom,apq8064", },
 	{ .compatible = "qcom,msm8974", },
 	{ .compatible = "qcom,msm8960", },
diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c
index 84d7033e5efe..3fa12648ceb6 100644
--- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
+++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
@@ -30,6 +30,11 @@ 
 
 #include <dt-bindings/arm/qcom,ids.h>
 
+enum ipq8074_versions {
+	IPQ8074_HAWKEYE_VERSION = 0,
+	IPQ8074_ACORN_VERSION,
+};
+
 struct qcom_cpufreq_drv;
 
 struct qcom_cpufreq_match_data {
@@ -203,6 +208,44 @@  static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
 	return ret;
 }
 
+static int qcom_cpufreq_ipq8074_name_version(struct device *cpu_dev,
+					     struct nvmem_cell *speedbin_nvmem,
+					     char **pvs_name,
+					     struct qcom_cpufreq_drv *drv)
+{
+	u32 msm_id;
+	int ret;
+	*pvs_name = NULL;
+
+	ret = qcom_smem_get_soc_id(&msm_id);
+	if (ret)
+		return ret;
+
+	switch (msm_id) {
+	case QCOM_ID_IPQ8070A:
+	case QCOM_ID_IPQ8071A:
+	case QCOM_ID_IPQ8172:
+	case QCOM_ID_IPQ8173:
+	case QCOM_ID_IPQ8174:
+		drv->versions = BIT(IPQ8074_ACORN_VERSION);
+		break;
+	case QCOM_ID_IPQ8072A:
+	case QCOM_ID_IPQ8074A:
+	case QCOM_ID_IPQ8076A:
+	case QCOM_ID_IPQ8078A:
+		drv->versions = BIT(IPQ8074_HAWKEYE_VERSION);
+		break;
+	default:
+		dev_err(cpu_dev,
+			"SoC ID %u is not part of IPQ8074 family, limiting to 1.4GHz!\n",
+			msm_id);
+		drv->versions = BIT(IPQ8074_ACORN_VERSION);
+		break;
+	}
+
+	return 0;
+}
+
 static const struct qcom_cpufreq_match_data match_data_kryo = {
 	.get_version = qcom_cpufreq_kryo_name_version,
 };
@@ -217,6 +260,10 @@  static const struct qcom_cpufreq_match_data match_data_qcs404 = {
 	.genpd_names = qcs404_genpd_names,
 };
 
+static const struct qcom_cpufreq_match_data match_data_ipq8074 = {
+	.get_version = qcom_cpufreq_ipq8074_name_version,
+};
+
 static int qcom_cpufreq_probe(struct platform_device *pdev)
 {
 	struct qcom_cpufreq_drv *drv;
@@ -360,6 +407,7 @@  static const struct of_device_id qcom_cpufreq_match_list[] __initconst = {
 	{ .compatible = "qcom,msm8996", .data = &match_data_kryo },
 	{ .compatible = "qcom,qcs404", .data = &match_data_qcs404 },
 	{ .compatible = "qcom,ipq8064", .data = &match_data_krait },
+	{ .compatible = "qcom,ipq8074", .data = &match_data_ipq8074 },
 	{ .compatible = "qcom,apq8064", .data = &match_data_krait },
 	{ .compatible = "qcom,msm8974", .data = &match_data_krait },
 	{ .compatible = "qcom,msm8960", .data = &match_data_krait },