Initial commit
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
From 5001f2e1a325b68dbf225bd17f69a4d3d975cca5 Mon Sep 17 00:00:00 2001
|
||||
From: John Crispin <john@phrozen.org>
|
||||
Date: Thu, 9 Mar 2017 09:31:44 +0100
|
||||
Subject: [PATCH 61/69] mtd: "rootfs" conflicts with OpenWrt auto mounting
|
||||
|
||||
Signed-off-by: John Crispin <john@phrozen.org>
|
||||
---
|
||||
drivers/mtd/mtdpart.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -57,7 +57,11 @@ static struct mtd_info *allocate_partiti
|
||||
|
||||
/* allocate the partition structure */
|
||||
child = kzalloc(sizeof(*child), GFP_KERNEL);
|
||||
- name = kstrdup(part->name, GFP_KERNEL);
|
||||
+ /* "rootfs" conflicts with OpenWrt auto mounting */
|
||||
+ if (mtd_type_is_nand(parent) && !strcmp(part->name, "rootfs"))
|
||||
+ name = "ubi";
|
||||
+ else
|
||||
+ name = kstrdup(part->name, GFP_KERNEL);
|
||||
if (!name || !child) {
|
||||
printk(KERN_ERR"memory allocation error while creating partitions for \"%s\"\n",
|
||||
parent->name);
|
||||
@@ -0,0 +1,69 @@
|
||||
From bef5018abb7cf94efafdc05087b4c998891ae4ec Mon Sep 17 00:00:00 2001
|
||||
From: Ansuel Smith <ansuelsmth@gmail.com>
|
||||
Date: Mon, 17 Jan 2022 23:39:34 +0100
|
||||
Subject: [PATCH v3 10/18] ARM: dts: qcom: add saw for l2 cache and kraitcc for
|
||||
ipq8064
|
||||
|
||||
Add saw compatible for l2 cache and kraitcc node for ipq8064 dtsi.
|
||||
Also declare clock-output-names for acc0 and acc1 and qsb fixed clock
|
||||
for the secondary mux.
|
||||
|
||||
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
|
||||
Tested-by: Jonathan McDowell <noodles@earth.li>
|
||||
---
|
||||
arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi | 34 +++++++++++++++++++++++++++--
|
||||
1 file changed, 32 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
@@ -302,6 +302,12 @@
|
||||
};
|
||||
|
||||
clocks {
|
||||
+ qsb: qsb {
|
||||
+ compatible = "fixed-clock";
|
||||
+ clock-frequency = <225000000>;
|
||||
+ #clock-cells = <0>;
|
||||
+ };
|
||||
+
|
||||
cxo_board: cxo_board {
|
||||
compatible = "fixed-clock";
|
||||
#clock-cells = <0>;
|
||||
@@ -587,7 +593,7 @@
|
||||
};
|
||||
|
||||
saw0: regulator@2089000 {
|
||||
- compatible = "qcom,saw2";
|
||||
+ compatible = "qcom,saw2", "qcom,apq8064-saw2-v1.1-cpu", "syscon";
|
||||
reg = <0x02089000 0x1000>, <0x02009000 0x1000>;
|
||||
regulator;
|
||||
};
|
||||
@@ -602,11 +608,27 @@
|
||||
};
|
||||
|
||||
saw1: regulator@2099000 {
|
||||
- compatible = "qcom,saw2";
|
||||
+ compatible = "qcom,saw2", "qcom,apq8064-saw2-v1.1-cpu", "syscon";
|
||||
reg = <0x02099000 0x1000>, <0x02009000 0x1000>;
|
||||
regulator;
|
||||
};
|
||||
|
||||
+ saw_l2: regulator@02012000 {
|
||||
+ compatible = "qcom,saw2", "syscon";
|
||||
+ reg = <0x02012000 0x1000>;
|
||||
+ regulator;
|
||||
+ };
|
||||
+
|
||||
+ kraitcc: clock-controller {
|
||||
+ compatible = "qcom,krait-cc-v1";
|
||||
+ clocks = <&gcc PLL9>, <&gcc PLL10>, <&gcc PLL12>,
|
||||
+ <&acc0>, <&acc1>, <&l2cc>, <&qsb>, <&pxo_board>;
|
||||
+ clock-names = "hfpll0", "hfpll1", "hfpll_l2",
|
||||
+ "acpu0_aux", "acpu1_aux", "acpu_l2_aux",
|
||||
+ "qsb", "pxo";
|
||||
+ #clock-cells = <1>;
|
||||
+ };
|
||||
+
|
||||
nss_common: syscon@3000000 {
|
||||
compatible = "syscon";
|
||||
reg = <0x03000000 0x0000FFFF>;
|
||||
@@ -0,0 +1,268 @@
|
||||
From 076ebb6e1799c4c7a1d2e07510d88b9e9b57b551 Mon Sep 17 00:00:00 2001
|
||||
From: Ansuel Smith <ansuelsmth@gmail.com>
|
||||
Date: Tue, 18 Jan 2022 00:03:47 +0100
|
||||
Subject: [PATCH v3 13/18] ARM: dts: qcom: add opp table for cpu and l2 for
|
||||
ipq8064
|
||||
|
||||
Add opp table for cpu and l2 cache. While the current cpufreq is
|
||||
the generic one that doesn't scale the L2 cache, we add the l2
|
||||
cache opp anyway for the sake of completeness. This will be handy in the
|
||||
future when a dedicated cpufreq driver is introduced for krait cores
|
||||
that will correctly scale l2 cache with the core freq.
|
||||
|
||||
Opp-level is set based on the logic of
|
||||
0: idle level
|
||||
1: normal level
|
||||
2: turbo level
|
||||
|
||||
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
|
||||
Tested-by: Jonathan McDowell <noodles@earth.li>
|
||||
---
|
||||
arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi | 99 +++++++++++++++++++++++++++++
|
||||
1 file changed, 99 insertions(+)
|
||||
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
@@ -49,6 +49,105 @@
|
||||
};
|
||||
};
|
||||
|
||||
+ opp_table_l2: opp_table_l2 {
|
||||
+ compatible = "operating-points-v2";
|
||||
+
|
||||
+ opp-384000000 {
|
||||
+ opp-hz = /bits/ 64 <384000000>;
|
||||
+ opp-microvolt = <1100000>;
|
||||
+ clock-latency-ns = <100000>;
|
||||
+ opp-level = <0>;
|
||||
+ };
|
||||
+
|
||||
+ opp-1000000000 {
|
||||
+ opp-hz = /bits/ 64 <1000000000>;
|
||||
+ opp-microvolt = <1100000>;
|
||||
+ clock-latency-ns = <100000>;
|
||||
+ opp-level = <1>;
|
||||
+ };
|
||||
+
|
||||
+ opp-1200000000 {
|
||||
+ opp-hz = /bits/ 64 <1200000000>;
|
||||
+ opp-microvolt = <1150000>;
|
||||
+ clock-latency-ns = <100000>;
|
||||
+ opp-level = <2>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ opp_table0: opp_table0 {
|
||||
+ compatible = "operating-points-v2-kryo-cpu";
|
||||
+ nvmem-cells = <&speedbin_efuse>;
|
||||
+
|
||||
+ /*
|
||||
+ * Voltage thresholds are <target min max>
|
||||
+ */
|
||||
+ opp-384000000 {
|
||||
+ opp-hz = /bits/ 64 <384000000>;
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1000000 950000 1050000>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <925000 878750 971250>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <875000 831250 918750>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = <800000 760000 840000>;
|
||||
+ opp-supported-hw = <0x1>;
|
||||
+ clock-latency-ns = <100000>;
|
||||
+ opp-level = <0>;
|
||||
+ };
|
||||
+
|
||||
+ opp-600000000 {
|
||||
+ opp-hz = /bits/ 64 <600000000>;
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1050000 997500 1102500>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <975000 926250 1023750>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <925000 878750 971250>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = <850000 807500 892500>;
|
||||
+ opp-supported-hw = <0x1>;
|
||||
+ clock-latency-ns = <100000>;
|
||||
+ opp-level = <1>;
|
||||
+ };
|
||||
+
|
||||
+ opp-800000000 {
|
||||
+ opp-hz = /bits/ 64 <800000000>;
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1100000 1045000 1155000>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <1025000 973750 1076250>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <995000 945250 1044750>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = <900000 855000 945000>;
|
||||
+ opp-supported-hw = <0x1>;
|
||||
+ clock-latency-ns = <100000>;
|
||||
+ opp-level = <1>;
|
||||
+ };
|
||||
+
|
||||
+ opp-1000000000 {
|
||||
+ opp-hz = /bits/ 64 <1000000000>;
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1150000 1092500 1207500>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <1075000 1021250 1128750>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <1025000 973750 1076250>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = <950000 902500 997500>;
|
||||
+ opp-supported-hw = <0x1>;
|
||||
+ clock-latency-ns = <100000>;
|
||||
+ opp-level = <1>;
|
||||
+ };
|
||||
+
|
||||
+ opp-1200000000 {
|
||||
+ opp-hz = /bits/ 64 <1200000000>;
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1200000 1140000 1260000>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <1125000 1068750 1181250>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <1075000 1021250 1128750>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = <1000000 950000 1050000>;
|
||||
+ opp-supported-hw = <0x1>;
|
||||
+ clock-latency-ns = <100000>;
|
||||
+ opp-level = <2>;
|
||||
+ };
|
||||
+
|
||||
+ opp-1400000000 {
|
||||
+ opp-hz = /bits/ 64 <1400000000>;
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1250000 1187500 1312500>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <1175000 1116250 1233750>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <1125000 1068750 1181250>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = <1050000 997500 1102500>;
|
||||
+ opp-supported-hw = <0x1>;
|
||||
+ clock-latency-ns = <100000>;
|
||||
+ opp-level = <2>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
thermal-zones {
|
||||
sensor0-thermal {
|
||||
polling-delay-passive = <0>;
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8065.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8065.dtsi
|
||||
@@ -6,3 +6,92 @@
|
||||
model = "Qualcomm Technologies, Inc. IPQ8065";
|
||||
compatible = "qcom,ipq8065", "qcom,ipq8064";
|
||||
};
|
||||
+
|
||||
+&opp_table_l2 {
|
||||
+ /delete-node/opp-1200000000;
|
||||
+
|
||||
+ opp-1400000000 {
|
||||
+ opp-hz = /bits/ 64 <1400000000>;
|
||||
+ opp-microvolt = <1150000>;
|
||||
+ clock-latency-ns = <100000>;
|
||||
+ opp-level = <2>;
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&opp_table0 {
|
||||
+ /*
|
||||
+ * On ipq8065 1.2 ghz freq is not present
|
||||
+ * Remove it to make cpufreq work and not
|
||||
+ * complain for missing definition
|
||||
+ */
|
||||
+
|
||||
+ /delete-node/opp-1200000000;
|
||||
+
|
||||
+ /*
|
||||
+ * Voltage thresholds are <target min max>
|
||||
+ */
|
||||
+ opp-384000000 {
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <975000 926250 1023750>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <950000 902500 997500>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <925000 878750 971250>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = <900000 855000 945000>;
|
||||
+ opp-microvolt-speed0-pvs4-v0 = <875000 831250 918750>;
|
||||
+ opp-microvolt-speed0-pvs5-v0 = <825000 783750 866250>;
|
||||
+ opp-microvolt-speed0-pvs6-v0 = <775000 736250 813750>;
|
||||
+ };
|
||||
+
|
||||
+ opp-600000000 {
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1000000 950000 1050000>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <975000 926250 1023750>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <950000 902500 997500>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = <925000 878750 971250>;
|
||||
+ opp-microvolt-speed0-pvs4-v0 = <900000 855000 945000>;
|
||||
+ opp-microvolt-speed0-pvs5-v0 = <850000 807500 892500>;
|
||||
+ opp-microvolt-speed0-pvs6-v0 = <800000 760000 840000>;
|
||||
+ };
|
||||
+
|
||||
+ opp-800000000 {
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1050000 997500 1102500>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <1025000 973750 1076250>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <1000000 950000 1050000>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = <975000 926250 1023750>;
|
||||
+ opp-microvolt-speed0-pvs4-v0 = <950000 902500 997500>;
|
||||
+ opp-microvolt-speed0-pvs5-v0 = <900000 855000 945000>;
|
||||
+ opp-microvolt-speed0-pvs6-v0 = <850000 807500 892500>;
|
||||
+ };
|
||||
+
|
||||
+ opp-1000000000 {
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1100000 1045000 1155000>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <1075000 1021250 1128750>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <1050000 997500 1102500>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = <1025000 973750 1076250>;
|
||||
+ opp-microvolt-speed0-pvs4-v0 = <1000000 950000 1050000>;
|
||||
+ opp-microvolt-speed0-pvs5-v0 = <950000 902500 997500>;
|
||||
+ opp-microvolt-speed0-pvs6-v0 = <900000 855000 945000>;
|
||||
+ };
|
||||
+
|
||||
+ opp-1400000000 {
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1175000 1116250 1233750>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <1150000 1092500 1207500>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <1125000 1068750 1181250>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = <1100000 1045000 1155000>;
|
||||
+ opp-microvolt-speed0-pvs4-v0 = <1075000 1021250 1128750>;
|
||||
+ opp-microvolt-speed0-pvs5-v0 = <1025000 973750 1076250>;
|
||||
+ opp-microvolt-speed0-pvs6-v0 = <975000 926250 1023750>;
|
||||
+ opp-level = <1>;
|
||||
+ };
|
||||
+
|
||||
+ opp-1725000000 {
|
||||
+ opp-hz = /bits/ 64 <1725000000>;
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1262500 1199375 1325625>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <1225000 1163750 1286250>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <1200000 1140000 1260000>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = <1175000 1116250 1233750>;
|
||||
+ opp-microvolt-speed0-pvs4-v0 = <1150000 1092500 1207500>;
|
||||
+ opp-microvolt-speed0-pvs5-v0 = <1100000 1045000 1155000>;
|
||||
+ opp-microvolt-speed0-pvs6-v0 = <1050000 997500 1102500>;
|
||||
+ opp-supported-hw = <0x1>;
|
||||
+ clock-latency-ns = <100000>;
|
||||
+ opp-level = <2>;
|
||||
+ };
|
||||
+};
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8062.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8062.dtsi
|
||||
@@ -6,3 +6,39 @@
|
||||
model = "Qualcomm Technologies, Inc. IPQ8062";
|
||||
compatible = "qcom,ipq8062", "qcom,ipq8064";
|
||||
};
|
||||
+
|
||||
+&opp_table0 {
|
||||
+ /delete-node/opp-1200000000;
|
||||
+ /delete-node/opp-1400000000;
|
||||
+
|
||||
+ /*
|
||||
+ * Voltage thresholds are <target min max>
|
||||
+ */
|
||||
+ opp-384000000 {
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1000000 950000 1050000>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = < 925000 878750 971250>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = < 875000 831250 918750>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = < 800000 760000 840000>;
|
||||
+ };
|
||||
+
|
||||
+ opp-600000000 {
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1050000 997500 1102500>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = < 975000 926250 1023750>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = < 925000 878750 971250>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = < 850000 807500 892500>;
|
||||
+ };
|
||||
+
|
||||
+ opp-800000000 {
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1100000 1045000 1155000>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <1025000 973750 1076250>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = < 995000 945250 1044750>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = < 900000 855000 945000>;
|
||||
+ };
|
||||
+
|
||||
+ opp-1000000000 {
|
||||
+ opp-microvolt-speed0-pvs0-v0 = <1150000 1092500 1207500>;
|
||||
+ opp-microvolt-speed0-pvs1-v0 = <1075000 1021250 1128750>;
|
||||
+ opp-microvolt-speed0-pvs2-v0 = <1025000 973750 1076250>;
|
||||
+ opp-microvolt-speed0-pvs3-v0 = < 950000 902500 997500>;
|
||||
+ };
|
||||
+};
|
||||
@@ -0,0 +1,154 @@
|
||||
From 211fc0c0a63c99b68663a27182e643316c2d8cbe Mon Sep 17 00:00:00 2001
|
||||
From: Ansuel Smith <ansuelsmth@gmail.com>
|
||||
Date: Tue, 18 Jan 2022 00:07:57 +0100
|
||||
Subject: [PATCH v3 15/18] ARM: dts: qcom: add multiple missing binding for cpu
|
||||
and l2 for ipq8064
|
||||
|
||||
Add multiple binding for cpu node, l2 node and add idle-states
|
||||
definition for ipq8064 dtsi.
|
||||
|
||||
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
|
||||
Tested-by: Jonathan McDowell <noodles@earth.li>
|
||||
---
|
||||
arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi | 36 +++++++++++++++++++++++++++++
|
||||
1 file changed, 36 insertions(+)
|
||||
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
@@ -30,6 +30,15 @@
|
||||
next-level-cache = <&L2>;
|
||||
qcom,acc = <&acc0>;
|
||||
qcom,saw = <&saw0>;
|
||||
+ clocks = <&kraitcc 0>, <&kraitcc 4>;
|
||||
+ clock-names = "cpu", "l2";
|
||||
+ clock-latency = <100000>;
|
||||
+ operating-points-v2 = <&opp_table0>;
|
||||
+ voltage-tolerance = <5>;
|
||||
+ cooling-min-state = <0>;
|
||||
+ cooling-max-state = <10>;
|
||||
+ #cooling-cells = <2>;
|
||||
+ cpu-idle-states = <&CPU_SPC>;
|
||||
};
|
||||
|
||||
cpu1: cpu@1 {
|
||||
@@ -40,12 +49,36 @@
|
||||
next-level-cache = <&L2>;
|
||||
qcom,acc = <&acc1>;
|
||||
qcom,saw = <&saw1>;
|
||||
+ clocks = <&kraitcc 1>, <&kraitcc 4>;
|
||||
+ clock-names = "cpu", "l2";
|
||||
+ clock-latency = <100000>;
|
||||
+ operating-points-v2 = <&opp_table0>;
|
||||
+ voltage-tolerance = <5>;
|
||||
+ cooling-min-state = <0>;
|
||||
+ cooling-max-state = <10>;
|
||||
+ #cooling-cells = <2>;
|
||||
+ cpu-idle-states = <&CPU_SPC>;
|
||||
+ };
|
||||
+
|
||||
+ idle-states {
|
||||
+ CPU_SPC: spc {
|
||||
+ compatible = "qcom,idle-state-spc";
|
||||
+ status = "disabled";
|
||||
+ entry-latency-us = <400>;
|
||||
+ exit-latency-us = <900>;
|
||||
+ min-residency-us = <3000>;
|
||||
+ };
|
||||
};
|
||||
|
||||
L2: l2-cache {
|
||||
compatible = "cache";
|
||||
cache-level = <2>;
|
||||
cache-unified;
|
||||
+ qcom,saw = <&saw_l2>;
|
||||
+
|
||||
+ clocks = <&kraitcc 4>;
|
||||
+ clock-names = "l2";
|
||||
+ operating-points-v2 = <&opp_table_l2>;
|
||||
};
|
||||
};
|
||||
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8064-smb208.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8064-smb208.dtsi
|
||||
@@ -2,6 +2,18 @@
|
||||
|
||||
#include "qcom-ipq8064.dtsi"
|
||||
|
||||
+&cpu0 {
|
||||
+ cpu-supply = <&smb208_s2a>;
|
||||
+};
|
||||
+
|
||||
+&cpu1 {
|
||||
+ cpu-supply = <&smb208_s2b>;
|
||||
+};
|
||||
+
|
||||
+&L2 {
|
||||
+ l2-supply = <&smb208_s1a>;
|
||||
+};
|
||||
+
|
||||
&rpm {
|
||||
smb208_regulators: regulators {
|
||||
compatible = "qcom,rpm-smb208-regulators";
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8064-v2.0-smb208.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8064-v2.0-smb208.dtsi
|
||||
@@ -2,6 +2,18 @@
|
||||
|
||||
#include "qcom-ipq8064-v2.0.dtsi"
|
||||
|
||||
+&cpu0 {
|
||||
+ cpu-supply = <&smb208_s2a>;
|
||||
+};
|
||||
+
|
||||
+&cpu1 {
|
||||
+ cpu-supply = <&smb208_s2b>;
|
||||
+};
|
||||
+
|
||||
+&L2 {
|
||||
+ l2-supply = <&smb208_s1a>;
|
||||
+};
|
||||
+
|
||||
&rpm {
|
||||
smb208_regulators: regulators {
|
||||
compatible = "qcom,rpm-smb208-regulators";
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8062-smb208.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8062-smb208.dtsi
|
||||
@@ -2,6 +2,18 @@
|
||||
|
||||
#include "qcom-ipq8062.dtsi"
|
||||
|
||||
+&cpu0 {
|
||||
+ cpu-supply = <&smb208_s2a>;
|
||||
+};
|
||||
+
|
||||
+&cpu1 {
|
||||
+ cpu-supply = <&smb208_s2b>;
|
||||
+};
|
||||
+
|
||||
+&L2 {
|
||||
+ l2-supply = <&smb208_s1a>;
|
||||
+};
|
||||
+
|
||||
&rpm {
|
||||
smb208_regulators: regulators {
|
||||
compatible = "qcom,rpm-smb208-regulators";
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8065-smb208.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8065-smb208.dtsi
|
||||
@@ -2,6 +2,18 @@
|
||||
|
||||
#include "qcom-ipq8065.dtsi"
|
||||
|
||||
+&cpu0 {
|
||||
+ cpu-supply = <&smb208_s2a>;
|
||||
+};
|
||||
+
|
||||
+&cpu1 {
|
||||
+ cpu-supply = <&smb208_s2b>;
|
||||
+};
|
||||
+
|
||||
+&L2 {
|
||||
+ l2-supply = <&smb208_s1a>;
|
||||
+};
|
||||
+
|
||||
&rpm {
|
||||
smb208_regulators: regulators {
|
||||
compatible = "qcom,rpm-smb208-regulators";
|
||||
@@ -0,0 +1,29 @@
|
||||
From 6c94e0184e56f9e9f1f5d5f54b20758433e498d2 Mon Sep 17 00:00:00 2001
|
||||
From: Christian 'Ansuel' Marangi <ansuelsmth@gmail.com>
|
||||
Date: Wed, 15 Jun 2022 16:47:09 +0200
|
||||
Subject: [PATCH 1/2] ARM: dts: qcom: fix wrong nad_pins definition for ipq806x
|
||||
|
||||
Fix wrong nand_pings definition for bias-disable pins.
|
||||
|
||||
Signed-off-by: Christian 'Ansuel' Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi | 7 ++-----
|
||||
1 file changed, 2 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
@@ -600,12 +600,9 @@
|
||||
};
|
||||
|
||||
nand_pins: nand_pins {
|
||||
- mux {
|
||||
+ disable {
|
||||
pins = "gpio34", "gpio35", "gpio36",
|
||||
- "gpio37", "gpio38", "gpio39",
|
||||
- "gpio40", "gpio41", "gpio42",
|
||||
- "gpio43", "gpio44", "gpio45",
|
||||
- "gpio46", "gpio47";
|
||||
+ "gpio37", "gpio38";
|
||||
function = "nand";
|
||||
drive-strength = <10>;
|
||||
bias-disable;
|
||||
@@ -0,0 +1,304 @@
|
||||
From 504188183408fac0f61b59f5ed8ea1773fe43669 Mon Sep 17 00:00:00 2001
|
||||
From: Christian 'Ansuel' Marangi <ansuelsmth@gmail.com>
|
||||
Date: Wed, 15 Jun 2022 16:59:30 +0200
|
||||
Subject: [PATCH 2/2] ARM: dts: qcom: add MDIO dedicated controller node for
|
||||
ipq806x
|
||||
|
||||
Add MDIO dedicated controller attached to gmac0 and fix rb3011 dts to
|
||||
correctly use the new tag.
|
||||
|
||||
Signed-off-by: Christian 'Ansuel' Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
arch/arm/boot/dts/qcom/qcom-ipq8064-rb3011.dts | 134 +++++++++++-----------
|
||||
arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi | 14 +++
|
||||
2 files changed, 81 insertions(+), 67 deletions(-)
|
||||
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8064-rb3011.dts
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8064-rb3011.dts
|
||||
@@ -25,131 +25,6 @@
|
||||
device_type = "memory";
|
||||
};
|
||||
|
||||
- mdio0: mdio-0 {
|
||||
- status = "okay";
|
||||
- compatible = "virtual,mdio-gpio";
|
||||
- gpios = <&qcom_pinmux 1 GPIO_ACTIVE_HIGH>,
|
||||
- <&qcom_pinmux 0 GPIO_ACTIVE_HIGH>;
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
-
|
||||
- pinctrl-0 = <&mdio0_pins>;
|
||||
- pinctrl-names = "default";
|
||||
-
|
||||
- switch0: switch@10 {
|
||||
- compatible = "qca,qca8337";
|
||||
-
|
||||
- dsa,member = <0 0>;
|
||||
-
|
||||
- pinctrl-0 = <&sw0_reset_pin>;
|
||||
- pinctrl-names = "default";
|
||||
-
|
||||
- reset-gpios = <&qcom_pinmux 16 GPIO_ACTIVE_LOW>;
|
||||
- reg = <0x10>;
|
||||
-
|
||||
- ports {
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
-
|
||||
- switch0cpu: port@0 {
|
||||
- reg = <0>;
|
||||
- label = "cpu";
|
||||
- ethernet = <&gmac0>;
|
||||
- phy-mode = "rgmii-id";
|
||||
- fixed-link {
|
||||
- speed = <1000>;
|
||||
- full-duplex;
|
||||
- };
|
||||
- };
|
||||
-
|
||||
- port@1 {
|
||||
- reg = <1>;
|
||||
- label = "sw1";
|
||||
-
|
||||
- leds {
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
-
|
||||
- led@0 {
|
||||
- reg = <0>;
|
||||
- color = <LED_COLOR_ID_GREEN>;
|
||||
- function = LED_FUNCTION_LAN;
|
||||
- default-state = "keep";
|
||||
- };
|
||||
- };
|
||||
- };
|
||||
-
|
||||
- port@2 {
|
||||
- reg = <2>;
|
||||
- label = "sw2";
|
||||
-
|
||||
- leds {
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
-
|
||||
- led@0 {
|
||||
- reg = <0>;
|
||||
- color = <LED_COLOR_ID_GREEN>;
|
||||
- function = LED_FUNCTION_LAN;
|
||||
- default-state = "keep";
|
||||
- };
|
||||
- };
|
||||
- };
|
||||
-
|
||||
- port@3 {
|
||||
- reg = <3>;
|
||||
- label = "sw3";
|
||||
-
|
||||
- leds {
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
-
|
||||
- led@0 {
|
||||
- reg = <0>;
|
||||
- color = <LED_COLOR_ID_GREEN>;
|
||||
- function = LED_FUNCTION_LAN;
|
||||
- default-state = "keep";
|
||||
- };
|
||||
- };
|
||||
- };
|
||||
-
|
||||
- port@4 {
|
||||
- reg = <4>;
|
||||
- label = "sw4";
|
||||
-
|
||||
- leds {
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
-
|
||||
- led@0 {
|
||||
- reg = <0>;
|
||||
- color = <LED_COLOR_ID_GREEN>;
|
||||
- function = LED_FUNCTION_LAN;
|
||||
- default-state = "keep";
|
||||
- };
|
||||
- };
|
||||
- };
|
||||
-
|
||||
- port@5 {
|
||||
- reg = <5>;
|
||||
- label = "sw5";
|
||||
-
|
||||
- leds {
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
-
|
||||
- led@0 {
|
||||
- reg = <0>;
|
||||
- color = <LED_COLOR_ID_GREEN>;
|
||||
- function = LED_FUNCTION_LAN;
|
||||
- default-state = "keep";
|
||||
- };
|
||||
- };
|
||||
- };
|
||||
- };
|
||||
- };
|
||||
- };
|
||||
-
|
||||
mdio1: mdio-1 {
|
||||
status = "okay";
|
||||
compatible = "virtual,mdio-gpio";
|
||||
@@ -337,6 +212,131 @@
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
+&mdio0 {
|
||||
+ status = "okay";
|
||||
+ compatible = "virtual,mdio-gpio";
|
||||
+ gpios = <&qcom_pinmux 1 GPIO_ACTIVE_HIGH>,
|
||||
+ <&qcom_pinmux 0 GPIO_ACTIVE_HIGH>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ pinctrl-0 = <&mdio0_pins>;
|
||||
+ pinctrl-names = "default";
|
||||
+
|
||||
+ switch0: switch@10 {
|
||||
+ compatible = "qca,qca8337";
|
||||
+
|
||||
+ dsa,member = <0 0>;
|
||||
+
|
||||
+ pinctrl-0 = <&sw0_reset_pin>;
|
||||
+ pinctrl-names = "default";
|
||||
+
|
||||
+ reset-gpios = <&qcom_pinmux 16 GPIO_ACTIVE_LOW>;
|
||||
+ reg = <0x10>;
|
||||
+
|
||||
+ ports {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ switch0cpu: port@0 {
|
||||
+ reg = <0>;
|
||||
+ label = "cpu";
|
||||
+ ethernet = <&gmac0>;
|
||||
+ phy-mode = "rgmii-id";
|
||||
+ fixed-link {
|
||||
+ speed = <1000>;
|
||||
+ full-duplex;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ port@1 {
|
||||
+ reg = <1>;
|
||||
+ label = "sw1";
|
||||
+
|
||||
+ leds {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ led@0 {
|
||||
+ reg = <0>;
|
||||
+ color = <LED_COLOR_ID_GREEN>;
|
||||
+ function = LED_FUNCTION_LAN;
|
||||
+ default-state = "keep";
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ port@2 {
|
||||
+ reg = <2>;
|
||||
+ label = "sw2";
|
||||
+
|
||||
+ leds {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ led@0 {
|
||||
+ reg = <0>;
|
||||
+ color = <LED_COLOR_ID_GREEN>;
|
||||
+ function = LED_FUNCTION_LAN;
|
||||
+ default-state = "keep";
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ port@3 {
|
||||
+ reg = <3>;
|
||||
+ label = "sw3";
|
||||
+
|
||||
+ leds {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ led@0 {
|
||||
+ reg = <0>;
|
||||
+ color = <LED_COLOR_ID_GREEN>;
|
||||
+ function = LED_FUNCTION_LAN;
|
||||
+ default-state = "keep";
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ port@4 {
|
||||
+ reg = <4>;
|
||||
+ label = "sw4";
|
||||
+
|
||||
+ leds {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ led@0 {
|
||||
+ reg = <0>;
|
||||
+ color = <LED_COLOR_ID_GREEN>;
|
||||
+ function = LED_FUNCTION_LAN;
|
||||
+ default-state = "keep";
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ port@5 {
|
||||
+ reg = <5>;
|
||||
+ label = "sw5";
|
||||
+
|
||||
+ leds {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ led@0 {
|
||||
+ reg = <0>;
|
||||
+ color = <LED_COLOR_ID_GREEN>;
|
||||
+ function = LED_FUNCTION_LAN;
|
||||
+ default-state = "keep";
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
&gmac0 {
|
||||
status = "okay";
|
||||
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
@@ -1429,6 +1429,20 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ mdio0: mdio@37000000 {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ compatible = "qcom,ipq8064-mdio", "syscon";
|
||||
+ reg = <0x37000000 0x200000>;
|
||||
+ resets = <&gcc GMAC_CORE1_RESET>;
|
||||
+ reset-names = "stmmaceth";
|
||||
+ clocks = <&gcc GMAC_CORE1_CLK>;
|
||||
+ clock-names = "stmmaceth";
|
||||
+
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
gmac0: ethernet@37000000 {
|
||||
device_type = "network";
|
||||
compatible = "qcom,ipq806x-gmac", "snps,dwmac";
|
||||
@@ -0,0 +1,235 @@
|
||||
From b044ae89862132a86fb511648e9c52ea3cdf8c30 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Wed, 5 Aug 2020 14:19:23 +0200
|
||||
Subject: [PATCH 1/4] devfreq: qcom: Add L2 Krait Cache devfreq scaling driver
|
||||
|
||||
Qcom L2 Krait CPUs use the generic cpufreq-dt driver and doesn't actually
|
||||
scale the Cache frequency when the CPU frequency is changed. This
|
||||
devfreq driver register with the cpu notifier and scale the Cache
|
||||
based on the max Freq across all core as the CPU cache is shared across
|
||||
all of them. If provided this also scale the voltage of the regulator
|
||||
attached to the CPU cache. The scaling logic is based on the CPU freq
|
||||
and the 3 scaling interval are set by the device dts.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
drivers/devfreq/Kconfig | 11 ++
|
||||
drivers/devfreq/Makefile | 1 +
|
||||
drivers/devfreq/krait-cache-devfreq.c | 188 ++++++++++++++++++++++++++
|
||||
3 files changed, 200 insertions(+)
|
||||
create mode 100644 drivers/devfreq/krait-cache-devfreq.c
|
||||
|
||||
--- a/drivers/devfreq/Kconfig
|
||||
+++ b/drivers/devfreq/Kconfig
|
||||
@@ -150,6 +150,17 @@ config ARM_SUN8I_A33_MBUS_DEVFREQ
|
||||
This adds the DEVFREQ driver for the MBUS controller in some
|
||||
Allwinner sun8i (A33 through H3) and sun50i (A64 and H5) SoCs.
|
||||
|
||||
+config ARM_KRAIT_CACHE_DEVFREQ
|
||||
+ tristate "Scaling support for Krait CPU Cache Devfreq"
|
||||
+ depends on ARCH_QCOM || COMPILE_TEST
|
||||
+ select DEVFREQ_GOV_PASSIVE
|
||||
+ help
|
||||
+ This adds the DEVFREQ driver for the Krait CPU L2 Cache shared by all cores.
|
||||
+
|
||||
+ The driver register with the cpufreq notifier and find the right frequency
|
||||
+ based on the max frequency across all core and the range set in the device
|
||||
+ dts. If provided this scale also the regulator attached to the l2 cache.
|
||||
+
|
||||
source "drivers/devfreq/event/Kconfig"
|
||||
|
||||
endif # PM_DEVFREQ
|
||||
--- a/drivers/devfreq/Makefile
|
||||
+++ b/drivers/devfreq/Makefile
|
||||
@@ -15,6 +15,7 @@ obj-$(CONFIG_ARM_MEDIATEK_CCI_DEVFREQ) +
|
||||
obj-$(CONFIG_ARM_RK3399_DMC_DEVFREQ) += rk3399_dmc.o
|
||||
obj-$(CONFIG_ARM_SUN8I_A33_MBUS_DEVFREQ) += sun8i-a33-mbus.o
|
||||
obj-$(CONFIG_ARM_TEGRA_DEVFREQ) += tegra30-devfreq.o
|
||||
+obj-$(CONFIG_ARM_KRAIT_CACHE_DEVFREQ) += krait-cache-devfreq.o
|
||||
|
||||
# DEVFREQ Event Drivers
|
||||
obj-$(CONFIG_PM_DEVFREQ_EVENT) += event/
|
||||
--- /dev/null
|
||||
+++ b/drivers/devfreq/krait-cache-devfreq.c
|
||||
@@ -0,0 +1,181 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/cpufreq.h>
|
||||
+#include <linux/devfreq.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/clk.h>
|
||||
+#include <linux/slab.h>
|
||||
+#include <linux/regulator/consumer.h>
|
||||
+#include <linux/pm_opp.h>
|
||||
+
|
||||
+#include "governor.h"
|
||||
+
|
||||
+struct krait_cache_data {
|
||||
+ struct clk *clk;
|
||||
+ unsigned long idle_freq;
|
||||
+ int token;
|
||||
+};
|
||||
+
|
||||
+static int krait_cache_config_clk(struct device *dev, struct opp_table *opp_table,
|
||||
+ struct dev_pm_opp *old_opp, struct dev_pm_opp *opp,
|
||||
+ void *data, bool scaling_down)
|
||||
+{
|
||||
+ struct krait_cache_data *kdata;
|
||||
+ unsigned long old_freq, freq;
|
||||
+ unsigned long idle_freq;
|
||||
+ struct clk *clk;
|
||||
+ int ret;
|
||||
+
|
||||
+ kdata = dev_get_drvdata(dev);
|
||||
+ idle_freq = kdata->idle_freq;
|
||||
+ clk = kdata->clk;
|
||||
+
|
||||
+ old_freq = dev_pm_opp_get_freq(old_opp);
|
||||
+ freq = dev_pm_opp_get_freq(opp);
|
||||
+
|
||||
+ /*
|
||||
+ * Set to idle bin if switching from normal to high bin
|
||||
+ * or vice versa. It has been notice that a bug is triggered
|
||||
+ * in cache scaling when more than one bin is scaled, to fix
|
||||
+ * this we first need to transition to the base rate and then
|
||||
+ * to target rate
|
||||
+ */
|
||||
+ if (likely(freq != idle_freq && old_freq != idle_freq)) {
|
||||
+ ret = clk_set_rate(clk, idle_freq);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ return clk_set_rate(clk, freq);
|
||||
+};
|
||||
+
|
||||
+static int krait_cache_get_cur_freq(struct device *dev, unsigned long *freq)
|
||||
+{
|
||||
+ struct krait_cache_data *data = dev_get_drvdata(dev);
|
||||
+
|
||||
+ *freq = clk_get_rate(data->clk);
|
||||
+
|
||||
+ return 0;
|
||||
+};
|
||||
+
|
||||
+static int krait_cache_target(struct device *dev, unsigned long *freq,
|
||||
+ u32 flags)
|
||||
+{
|
||||
+ struct dev_pm_opp *opp;
|
||||
+
|
||||
+ opp = dev_pm_opp_find_freq_ceil(dev, freq);
|
||||
+ if (unlikely(IS_ERR(opp)))
|
||||
+ return PTR_ERR(opp);
|
||||
+
|
||||
+ dev_pm_opp_put(opp);
|
||||
+
|
||||
+ return dev_pm_opp_set_rate(dev, *freq);
|
||||
+};
|
||||
+
|
||||
+static int krait_cache_get_dev_status(struct device *dev,
|
||||
+ struct devfreq_dev_status *stat)
|
||||
+{
|
||||
+ struct krait_cache_data *data = dev_get_drvdata(dev);
|
||||
+
|
||||
+ stat->busy_time = 0;
|
||||
+ stat->total_time = 0;
|
||||
+ stat->current_frequency = clk_get_rate(data->clk);
|
||||
+
|
||||
+ return 0;
|
||||
+};
|
||||
+
|
||||
+static struct devfreq_dev_profile krait_cache_devfreq_profile = {
|
||||
+ .target = krait_cache_target,
|
||||
+ .get_dev_status = krait_cache_get_dev_status,
|
||||
+ .get_cur_freq = krait_cache_get_cur_freq
|
||||
+};
|
||||
+
|
||||
+static struct devfreq_passive_data devfreq_gov_data = {
|
||||
+ .parent_type = CPUFREQ_PARENT_DEV,
|
||||
+};
|
||||
+
|
||||
+static int krait_cache_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct dev_pm_opp_config config = { };
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct krait_cache_data *data;
|
||||
+ struct devfreq *devfreq;
|
||||
+ struct dev_pm_opp *opp;
|
||||
+ struct clk *clk;
|
||||
+ int ret, token;
|
||||
+
|
||||
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
|
||||
+ if (!data)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ clk = devm_clk_get(dev, "l2");
|
||||
+ if (IS_ERR(clk))
|
||||
+ return PTR_ERR(clk);
|
||||
+
|
||||
+ config.regulator_names = (const char *[]){ "l2", NULL };
|
||||
+ config.clk_names = (const char *[]){ "l2", NULL };
|
||||
+ config.config_clks = krait_cache_config_clk;
|
||||
+
|
||||
+ token = dev_pm_opp_set_config(dev, &config);
|
||||
+ if (token < 0)
|
||||
+ return token;
|
||||
+
|
||||
+ ret = devm_pm_opp_of_add_table(dev);
|
||||
+ if (ret)
|
||||
+ goto free_opp;
|
||||
+
|
||||
+ opp = dev_pm_opp_find_freq_ceil(dev, &data->idle_freq);
|
||||
+ if (IS_ERR(opp)) {
|
||||
+ ret = PTR_ERR(opp);
|
||||
+ goto free_opp;
|
||||
+ }
|
||||
+ dev_pm_opp_put(opp);
|
||||
+
|
||||
+ data->token = token;
|
||||
+ data->clk = clk;
|
||||
+ dev_set_drvdata(dev, data);
|
||||
+ devfreq = devm_devfreq_add_device(dev, &krait_cache_devfreq_profile,
|
||||
+ DEVFREQ_GOV_PASSIVE, &devfreq_gov_data);
|
||||
+ if (IS_ERR(devfreq)) {
|
||||
+ ret = PTR_ERR(devfreq);
|
||||
+ goto free_opp;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+free_opp:
|
||||
+ dev_pm_opp_clear_config(token);
|
||||
+ return ret;
|
||||
+};
|
||||
+
|
||||
+static int krait_cache_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct krait_cache_data *data = dev_get_drvdata(&pdev->dev);
|
||||
+
|
||||
+ dev_pm_opp_clear_config(data->token);
|
||||
+
|
||||
+ return 0;
|
||||
+};
|
||||
+
|
||||
+static const struct of_device_id krait_cache_match_table[] = {
|
||||
+ { .compatible = "qcom,krait-cache" },
|
||||
+ {}
|
||||
+};
|
||||
+
|
||||
+static struct platform_driver krait_cache_driver = {
|
||||
+ .probe = krait_cache_probe,
|
||||
+ .remove = krait_cache_remove,
|
||||
+ .driver = {
|
||||
+ .name = "krait-cache-scaling",
|
||||
+ .of_match_table = krait_cache_match_table,
|
||||
+ },
|
||||
+};
|
||||
+module_platform_driver(krait_cache_driver);
|
||||
+
|
||||
+MODULE_DESCRIPTION("Krait CPU Cache Scaling driver");
|
||||
+MODULE_AUTHOR("Christian Marangi <ansuelsmth@gmail.com>");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
@@ -0,0 +1,52 @@
|
||||
From ef124ad0ff8abfbf4ebe3fe6d7dcef4541dec13a Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Thu, 16 Jun 2022 18:39:21 +0200
|
||||
Subject: [PATCH] ARM: dts: qcom: add krait-cache compatible for ipq806x dtsi
|
||||
|
||||
Add qcom,krait-cache compatible to enable cache devfreq driver for
|
||||
ipq806x SoC and move the L2 node to the soc node to make the devfreq
|
||||
driver correctly probe.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi | 22 +++++++++++-----------
|
||||
1 file changed, 11 insertions(+), 11 deletions(-)
|
||||
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
@@ -69,17 +69,6 @@
|
||||
min-residency-us = <3000>;
|
||||
};
|
||||
};
|
||||
-
|
||||
- L2: l2-cache {
|
||||
- compatible = "cache";
|
||||
- cache-level = <2>;
|
||||
- cache-unified;
|
||||
- qcom,saw = <&saw_l2>;
|
||||
-
|
||||
- clocks = <&kraitcc 4>;
|
||||
- clock-names = "l2";
|
||||
- operating-points-v2 = <&opp_table_l2>;
|
||||
- };
|
||||
};
|
||||
|
||||
opp_table_l2: opp_table_l2 {
|
||||
@@ -1392,6 +1381,17 @@
|
||||
#reset-cells = <1>;
|
||||
};
|
||||
|
||||
+ L2: l2-cache {
|
||||
+ compatible = "cache", "qcom,krait-cache";
|
||||
+ cache-level = <2>;
|
||||
+ cache-unified;
|
||||
+ qcom,saw = <&saw_l2>;
|
||||
+
|
||||
+ clocks = <&kraitcc 4>;
|
||||
+ clock-names = "l2";
|
||||
+ operating-points-v2 = <&opp_table_l2>;
|
||||
+ };
|
||||
+
|
||||
lpass@28100000 {
|
||||
compatible = "qcom,lpass-cpu";
|
||||
status = "disabled";
|
||||
@@ -0,0 +1,203 @@
|
||||
From 13f075999935bb696dbab63243923179f06fa05e Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Thu, 16 Jun 2022 19:56:08 +0200
|
||||
Subject: [PATCH 3/4] devfreq: add ipq806x fabric scaling driver
|
||||
|
||||
Add ipq806x fabric scaling driver using the devfreq passive governor.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
drivers/devfreq/Kconfig | 11 ++
|
||||
drivers/devfreq/Makefile | 1 +
|
||||
drivers/devfreq/ipq806x-fab-devfreq.c | 155 ++++++++++++++++++++++++++
|
||||
3 files changed, 167 insertions(+)
|
||||
create mode 100644 drivers/devfreq/ipq806x-fab-devfreq.c
|
||||
|
||||
--- a/drivers/devfreq/Kconfig
|
||||
+++ b/drivers/devfreq/Kconfig
|
||||
@@ -161,6 +161,17 @@ config ARM_KRAIT_CACHE_DEVFREQ
|
||||
based on the max frequency across all core and the range set in the device
|
||||
dts. If provided this scale also the regulator attached to the l2 cache.
|
||||
|
||||
+config ARM_IPQ806X_FAB_DEVFREQ
|
||||
+ tristate "Scaling support for ipq806x Soc Fabric"
|
||||
+ depends on ARCH_QCOM || COMPILE_TEST
|
||||
+ select DEVFREQ_GOV_PASSIVE
|
||||
+ help
|
||||
+ This adds the DEVFREQ driver for the ipq806x Soc Fabric.
|
||||
+
|
||||
+ The driver register with the cpufreq notifier and find the right frequency
|
||||
+ based on the max frequency across all core and the range set in the device
|
||||
+ dts.
|
||||
+
|
||||
source "drivers/devfreq/event/Kconfig"
|
||||
|
||||
endif # PM_DEVFREQ
|
||||
--- a/drivers/devfreq/Makefile
|
||||
+++ b/drivers/devfreq/Makefile
|
||||
@@ -16,6 +16,7 @@ obj-$(CONFIG_ARM_RK3399_DMC_DEVFREQ) +=
|
||||
obj-$(CONFIG_ARM_SUN8I_A33_MBUS_DEVFREQ) += sun8i-a33-mbus.o
|
||||
obj-$(CONFIG_ARM_TEGRA_DEVFREQ) += tegra30-devfreq.o
|
||||
obj-$(CONFIG_ARM_KRAIT_CACHE_DEVFREQ) += krait-cache-devfreq.o
|
||||
+obj-$(CONFIG_ARM_IPQ806X_FAB_DEVFREQ) += ipq806x-fab-devfreq.o
|
||||
|
||||
# DEVFREQ Event Drivers
|
||||
obj-$(CONFIG_PM_DEVFREQ_EVENT) += event/
|
||||
--- /dev/null
|
||||
+++ b/drivers/devfreq/ipq806x-fab-devfreq.c
|
||||
@@ -0,0 +1,155 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/cpufreq.h>
|
||||
+#include <linux/devfreq.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/clk.h>
|
||||
+#include <linux/slab.h>
|
||||
+#include <linux/pm_opp.h>
|
||||
+
|
||||
+#include "governor.h"
|
||||
+
|
||||
+struct ipq806x_fab_data {
|
||||
+ struct clk *fab_clk;
|
||||
+ struct clk *ddr_clk;
|
||||
+};
|
||||
+
|
||||
+static int ipq806x_fab_get_cur_freq(struct device *dev, unsigned long *freq)
|
||||
+{
|
||||
+ struct ipq806x_fab_data *data = dev_get_drvdata(dev);
|
||||
+
|
||||
+ *freq = clk_get_rate(data->fab_clk);
|
||||
+
|
||||
+ return 0;
|
||||
+};
|
||||
+
|
||||
+static int ipq806x_fab_target(struct device *dev, unsigned long *freq,
|
||||
+ u32 flags)
|
||||
+{
|
||||
+ struct ipq806x_fab_data *data = dev_get_drvdata(dev);
|
||||
+ struct dev_pm_opp *opp;
|
||||
+ int ret;
|
||||
+
|
||||
+ opp = dev_pm_opp_find_freq_ceil(dev, freq);
|
||||
+ if (unlikely(IS_ERR(opp)))
|
||||
+ return PTR_ERR(opp);
|
||||
+
|
||||
+ dev_pm_opp_put(opp);
|
||||
+
|
||||
+ ret = clk_set_rate(data->fab_clk, *freq);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ return clk_set_rate(data->ddr_clk, *freq);
|
||||
+};
|
||||
+
|
||||
+static int ipq806x_fab_get_dev_status(struct device *dev,
|
||||
+ struct devfreq_dev_status *stat)
|
||||
+{
|
||||
+ struct ipq806x_fab_data *data = dev_get_drvdata(dev);
|
||||
+
|
||||
+ stat->busy_time = 0;
|
||||
+ stat->total_time = 0;
|
||||
+ stat->current_frequency = clk_get_rate(data->fab_clk);
|
||||
+
|
||||
+ return 0;
|
||||
+};
|
||||
+
|
||||
+static struct devfreq_dev_profile ipq806x_fab_devfreq_profile = {
|
||||
+ .target = ipq806x_fab_target,
|
||||
+ .get_dev_status = ipq806x_fab_get_dev_status,
|
||||
+ .get_cur_freq = ipq806x_fab_get_cur_freq
|
||||
+};
|
||||
+
|
||||
+static struct devfreq_passive_data devfreq_gov_data = {
|
||||
+ .parent_type = CPUFREQ_PARENT_DEV,
|
||||
+};
|
||||
+
|
||||
+static int ipq806x_fab_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct ipq806x_fab_data *data;
|
||||
+ struct devfreq *devfreq;
|
||||
+ struct clk *clk;
|
||||
+ int ret;
|
||||
+
|
||||
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
|
||||
+ if (!data)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ clk = devm_clk_get(dev, "apps-fab-clk");
|
||||
+ if (IS_ERR(clk)) {
|
||||
+ dev_err_probe(dev, PTR_ERR(clk), "failed to get apps fab clk\n");
|
||||
+ return PTR_ERR(clk);
|
||||
+ }
|
||||
+
|
||||
+ clk_prepare_enable(clk);
|
||||
+ data->fab_clk = clk;
|
||||
+
|
||||
+ clk = devm_clk_get(dev, "ddr-fab-clk");
|
||||
+ if (IS_ERR(clk)) {
|
||||
+ dev_err_probe(dev, PTR_ERR(clk), "failed to get ddr fab clk\n");
|
||||
+ goto err_ddr;
|
||||
+ }
|
||||
+
|
||||
+ clk_prepare_enable(clk);
|
||||
+ data->ddr_clk = clk;
|
||||
+
|
||||
+ ret = dev_pm_opp_of_add_table(dev);
|
||||
+ if (ret) {
|
||||
+ dev_err(dev, "failed to parse fab freq thresholds\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ dev_set_drvdata(dev, data);
|
||||
+
|
||||
+ devfreq = devm_devfreq_add_device(&pdev->dev, &ipq806x_fab_devfreq_profile,
|
||||
+ DEVFREQ_GOV_PASSIVE, &devfreq_gov_data);
|
||||
+ if (IS_ERR(devfreq))
|
||||
+ dev_pm_opp_remove_table(dev);
|
||||
+
|
||||
+ return PTR_ERR_OR_ZERO(devfreq);
|
||||
+
|
||||
+err_ddr:
|
||||
+ clk_unprepare(data->fab_clk);
|
||||
+ clk_put(data->fab_clk);
|
||||
+ return PTR_ERR(clk);
|
||||
+};
|
||||
+
|
||||
+static int ipq806x_fab_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct ipq806x_fab_data *data = dev_get_drvdata(&pdev->dev);
|
||||
+
|
||||
+ clk_unprepare(data->fab_clk);
|
||||
+ clk_put(data->fab_clk);
|
||||
+
|
||||
+ clk_unprepare(data->ddr_clk);
|
||||
+ clk_put(data->ddr_clk);
|
||||
+
|
||||
+ dev_pm_opp_remove_table(&pdev->dev);
|
||||
+
|
||||
+ return 0;
|
||||
+};
|
||||
+
|
||||
+static const struct of_device_id ipq806x_fab_match_table[] = {
|
||||
+ { .compatible = "qcom,fab-scaling" },
|
||||
+ {}
|
||||
+};
|
||||
+
|
||||
+static struct platform_driver ipq806x_fab_driver = {
|
||||
+ .probe = ipq806x_fab_probe,
|
||||
+ .remove = ipq806x_fab_remove,
|
||||
+ .driver = {
|
||||
+ .name = "ipq806x-fab-scaling",
|
||||
+ .of_match_table = ipq806x_fab_match_table,
|
||||
+ },
|
||||
+};
|
||||
+module_platform_driver(ipq806x_fab_driver);
|
||||
+
|
||||
+MODULE_DESCRIPTION("ipq806x Fab Scaling driver");
|
||||
+MODULE_AUTHOR("Christian Marangi <ansuelsmth@gmail.com>");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
@@ -0,0 +1,48 @@
|
||||
From c3573f0907dadb0a6e9933aae2a46a489abcbd48 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Thu, 16 Jun 2022 20:03:05 +0200
|
||||
Subject: [PATCH 4/4] ARM: dts: qcom: add fab scaling node for ipq806x
|
||||
|
||||
Add fabric scaling node for ipq806x to correctly scale apps and ddr
|
||||
fabric clk.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi | 19 +++++++++++++++++++
|
||||
1 file changed, 19 insertions(+)
|
||||
|
||||
--- a/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
+++ b/arch/arm/boot/dts/qcom/qcom-ipq8064.dtsi
|
||||
@@ -170,6 +170,18 @@
|
||||
};
|
||||
};
|
||||
|
||||
+ opp_table_fab: opp_table_fab {
|
||||
+ compatible = "operating-points-v2";
|
||||
+
|
||||
+ opp-533000000 {
|
||||
+ opp-hz = /bits/ 64 <533000000>;
|
||||
+ };
|
||||
+
|
||||
+ opp-400000000 {
|
||||
+ opp-hz = /bits/ 64 <400000000>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
thermal-zones {
|
||||
sensor0-thermal {
|
||||
polling-delay-passive = <0>;
|
||||
@@ -1392,6 +1404,13 @@
|
||||
operating-points-v2 = <&opp_table_l2>;
|
||||
};
|
||||
|
||||
+ fab-scaling {
|
||||
+ compatible = "qcom,fab-scaling";
|
||||
+ clocks = <&rpmcc RPM_APPS_FABRIC_A_CLK>, <&rpmcc RPM_EBI1_A_CLK>;
|
||||
+ clock-names = "apps-fab-clk", "ddr-fab-clk";
|
||||
+ operating-points-v2 = <&opp_table_fab>;
|
||||
+ };
|
||||
+
|
||||
lpass@28100000 {
|
||||
compatible = "qcom,lpass-cpu";
|
||||
status = "disabled";
|
||||
@@ -0,0 +1,47 @@
|
||||
From 666c1b745e93ccddde841d5057c33f97b29a316a Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Thu, 15 Sep 2022 02:19:28 +0200
|
||||
Subject: [PATCH 3/9] clk: qcom: krait-cc: handle qsb clock defined in DTS
|
||||
|
||||
qsb fixed clk may be defined in DTS and correctly passed in the clocks
|
||||
list. Add related code to handle this and modify the logic to
|
||||
dynamically read qsb clock frequency.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
drivers/clk/qcom/krait-cc.c | 14 +++++++++++---
|
||||
1 file changed, 11 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/clk/qcom/krait-cc.c
|
||||
+++ b/drivers/clk/qcom/krait-cc.c
|
||||
@@ -348,7 +348,7 @@ static int krait_cc_probe(struct platfor
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
const struct of_device_id *id;
|
||||
- unsigned long cur_rate, aux_rate;
|
||||
+ unsigned long cur_rate, aux_rate, qsb_rate;
|
||||
int cpu;
|
||||
struct clk_hw *mux, *l2_pri_mux;
|
||||
struct clk *clk, **clks;
|
||||
@@ -357,11 +357,19 @@ static int krait_cc_probe(struct platfor
|
||||
if (!id)
|
||||
return -ENODEV;
|
||||
|
||||
- /* Rate is 1 because 0 causes problems for __clk_mux_determine_rate */
|
||||
- clk = clk_register_fixed_rate(dev, "qsb", NULL, 0, 1);
|
||||
+ /*
|
||||
+ * Per Documentation qsb should be provided from DTS.
|
||||
+ * To address old implementation, register the fixed clock anyway.
|
||||
+ * Rate is 1 because 0 causes problems for __clk_mux_determine_rate
|
||||
+ */
|
||||
+ clk = clk_get(dev, "qsb");
|
||||
+ if (IS_ERR(clk))
|
||||
+ clk = clk_register_fixed_rate(dev, "qsb", NULL, 0, 1);
|
||||
if (IS_ERR(clk))
|
||||
return PTR_ERR(clk);
|
||||
|
||||
+ qsb_rate = clk_get_rate(clk);
|
||||
+
|
||||
if (!id->data) {
|
||||
clk = clk_register_fixed_factor(dev, "acpu_aux",
|
||||
"gpll0_vote", 0, 1, 2);
|
||||
@@ -0,0 +1,36 @@
|
||||
From fca6f185a9d9ef0892a719bc6da955b22d326ec7 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Thu, 15 Sep 2022 02:24:33 +0200
|
||||
Subject: [PATCH 4/9] clk: qcom: krait-cc: register REAL qsb fixed clock
|
||||
|
||||
With some tools it was discovered the real frequency of the qsb fixed
|
||||
clock. While not 100% correct it's still better than using 1 as a dummy
|
||||
frequency.
|
||||
Correctly register the qsb fixed clock with the frequency of 225 MHz
|
||||
instead of 1.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
drivers/clk/qcom/krait-cc.c | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/clk/qcom/krait-cc.c
|
||||
+++ b/drivers/clk/qcom/krait-cc.c
|
||||
@@ -25,6 +25,8 @@ enum {
|
||||
clks_max,
|
||||
};
|
||||
|
||||
+#define QSB_RATE 2250000000
|
||||
+
|
||||
static unsigned int sec_mux_map[] = {
|
||||
2,
|
||||
0,
|
||||
@@ -364,7 +366,7 @@ static int krait_cc_probe(struct platfor
|
||||
*/
|
||||
clk = clk_get(dev, "qsb");
|
||||
if (IS_ERR(clk))
|
||||
- clk = clk_register_fixed_rate(dev, "qsb", NULL, 0, 1);
|
||||
+ clk = clk_register_fixed_rate(dev, "qsb", NULL, 0, QSB_RATE);
|
||||
if (IS_ERR(clk))
|
||||
return PTR_ERR(clk);
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
From 2399d181557d94ae9a2686926cd25768f132e4b4 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Fri, 18 Mar 2022 16:12:14 +0100
|
||||
Subject: [PATCH 7/9] clk: qcom: krait-cc: drop pr_info and use dev_info
|
||||
|
||||
Replace pr_info() with dev_info() to provide better diagnostics.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
drivers/clk/qcom/krait-cc.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/clk/qcom/krait-cc.c
|
||||
+++ b/drivers/clk/qcom/krait-cc.c
|
||||
@@ -423,25 +423,25 @@ static int krait_cc_probe(struct platfor
|
||||
cur_rate = clk_get_rate(clks[l2_mux]);
|
||||
aux_rate = 384000000;
|
||||
if (cur_rate < aux_rate) {
|
||||
- pr_info("L2 @ Undefined rate. Forcing new rate.\n");
|
||||
+ dev_info(dev, "L2 @ Undefined rate. Forcing new rate.\n");
|
||||
cur_rate = aux_rate;
|
||||
}
|
||||
clk_set_rate(clks[l2_mux], aux_rate);
|
||||
clk_set_rate(clks[l2_mux], 2);
|
||||
clk_set_rate(clks[l2_mux], cur_rate);
|
||||
- pr_info("L2 @ %lu KHz\n", clk_get_rate(clks[l2_mux]) / 1000);
|
||||
+ dev_info(dev, "L2 @ %lu KHz\n", clk_get_rate(clks[l2_mux]) / 1000);
|
||||
for_each_possible_cpu(cpu) {
|
||||
clk = clks[cpu];
|
||||
cur_rate = clk_get_rate(clk);
|
||||
if (cur_rate < aux_rate) {
|
||||
- pr_info("CPU%d @ Undefined rate. Forcing new rate.\n", cpu);
|
||||
+ dev_info(dev, "CPU%d @ Undefined rate. Forcing new rate.\n", cpu);
|
||||
cur_rate = aux_rate;
|
||||
}
|
||||
|
||||
clk_set_rate(clk, aux_rate);
|
||||
clk_set_rate(clk, 2);
|
||||
clk_set_rate(clk, cur_rate);
|
||||
- pr_info("CPU%d @ %lu KHz\n", cpu, clk_get_rate(clk) / 1000);
|
||||
+ dev_info(dev, "CPU%d @ %lu KHz\n", cpu, clk_get_rate(clk) / 1000);
|
||||
}
|
||||
|
||||
of_clk_add_provider(dev->of_node, krait_of_get, clks);
|
||||
@@ -0,0 +1,88 @@
|
||||
From 6a77cf3f5f95ec0058e1b4d1ada018748cb0b83b Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Thu, 15 Sep 2022 03:33:13 +0200
|
||||
Subject: [PATCH 9/9] clk: qcom: krait-cc: rework mux reset logic and reset
|
||||
hfpll
|
||||
|
||||
Rework and clean mux reset logic.
|
||||
Compact it to a for loop to handle both CPU and L2 in one place.
|
||||
Move hardcoded aux_rate to define and add a new hfpll_rate value to
|
||||
reset hfpll settings.
|
||||
Change logic to now reset the hfpll to the lowest value of 600 Mhz and
|
||||
then restoring the previous frequency. This permits to reset the hfpll if
|
||||
the primary mux was set to source out of the secondary mux.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
drivers/clk/qcom/krait-cc.c | 50 +++++++++++++++++--------------------
|
||||
1 file changed, 23 insertions(+), 27 deletions(-)
|
||||
|
||||
--- a/drivers/clk/qcom/krait-cc.c
|
||||
+++ b/drivers/clk/qcom/krait-cc.c
|
||||
@@ -25,7 +25,9 @@ enum {
|
||||
clks_max,
|
||||
};
|
||||
|
||||
-#define QSB_RATE 2250000000
|
||||
+#define QSB_RATE 225000000
|
||||
+#define AUX_RATE 384000000
|
||||
+#define HFPLL_RATE 600000000
|
||||
|
||||
static unsigned int sec_mux_map[] = {
|
||||
2,
|
||||
@@ -350,7 +352,7 @@ static int krait_cc_probe(struct platfor
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
const struct of_device_id *id;
|
||||
- unsigned long cur_rate, aux_rate, qsb_rate;
|
||||
+ unsigned long cur_rate, qsb_rate;
|
||||
int cpu;
|
||||
struct clk_hw *mux, *l2_pri_mux;
|
||||
struct clk *clk, **clks;
|
||||
@@ -420,28 +422,29 @@ static int krait_cc_probe(struct platfor
|
||||
* two different rates to force a HFPLL reinit under all
|
||||
* circumstances.
|
||||
*/
|
||||
- cur_rate = clk_get_rate(clks[l2_mux]);
|
||||
- aux_rate = 384000000;
|
||||
- if (cur_rate < aux_rate) {
|
||||
- dev_info(dev, "L2 @ Undefined rate. Forcing new rate.\n");
|
||||
- cur_rate = aux_rate;
|
||||
- }
|
||||
- clk_set_rate(clks[l2_mux], aux_rate);
|
||||
- clk_set_rate(clks[l2_mux], 2);
|
||||
- clk_set_rate(clks[l2_mux], cur_rate);
|
||||
- dev_info(dev, "L2 @ %lu KHz\n", clk_get_rate(clks[l2_mux]) / 1000);
|
||||
- for_each_possible_cpu(cpu) {
|
||||
+ for (cpu = 0; cpu < 5; cpu++) {
|
||||
+ const char *l2_s = "L2";
|
||||
+ char cpu_s[5];
|
||||
+
|
||||
clk = clks[cpu];
|
||||
+ if (!clk)
|
||||
+ continue;
|
||||
+
|
||||
+ if (cpu < 4)
|
||||
+ snprintf(cpu_s, 5, "CPU%d", cpu);
|
||||
+
|
||||
cur_rate = clk_get_rate(clk);
|
||||
- if (cur_rate < aux_rate) {
|
||||
- dev_info(dev, "CPU%d @ Undefined rate. Forcing new rate.\n", cpu);
|
||||
- cur_rate = aux_rate;
|
||||
+ if (cur_rate < AUX_RATE) {
|
||||
+ dev_info(dev, "%s @ Undefined rate. Forcing new rate.\n",
|
||||
+ cpu < 4 ? cpu_s : l2_s);
|
||||
+ cur_rate = AUX_RATE;
|
||||
}
|
||||
|
||||
- clk_set_rate(clk, aux_rate);
|
||||
- clk_set_rate(clk, 2);
|
||||
+ clk_set_rate(clk, AUX_RATE);
|
||||
+ clk_set_rate(clk, HFPLL_RATE);
|
||||
clk_set_rate(clk, cur_rate);
|
||||
- dev_info(dev, "CPU%d @ %lu KHz\n", cpu, clk_get_rate(clk) / 1000);
|
||||
+ dev_info(dev, "%s @ %lu KHz\n", cpu < 4 ? cpu_s : l2_s,
|
||||
+ clk_get_rate(clk) / 1000);
|
||||
}
|
||||
|
||||
of_clk_add_provider(dev->of_node, krait_of_get, clks);
|
||||
@@ -0,0 +1,155 @@
|
||||
From 908c361b3c3a139eb3e6a798cb620a6da7514d5c Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Fri, 23 Sep 2022 19:05:39 +0200
|
||||
Subject: [PATCH 2/4] clk: qcom: clk-krait: generilize div functions
|
||||
|
||||
Generilize div functions and remove hardcode to a divisor of 2.
|
||||
This is just a cleanup and permit to make it more clear the settings of
|
||||
the devisor when used by the krait-cc driver.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
drivers/clk/qcom/clk-krait.c | 57 ++++++++++++++++++++----------------
|
||||
drivers/clk/qcom/clk-krait.h | 11 ++++---
|
||||
drivers/clk/qcom/krait-cc.c | 7 +++--
|
||||
3 files changed, 42 insertions(+), 33 deletions(-)
|
||||
|
||||
--- a/drivers/clk/qcom/clk-krait.c
|
||||
+++ b/drivers/clk/qcom/clk-krait.c
|
||||
@@ -97,53 +97,57 @@ const struct clk_ops krait_mux_clk_ops =
|
||||
EXPORT_SYMBOL_GPL(krait_mux_clk_ops);
|
||||
|
||||
/* The divider can divide by 2, 4, 6 and 8. But we only really need div-2. */
|
||||
-static int krait_div2_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
|
||||
+static int krait_div_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
|
||||
{
|
||||
- req->best_parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw), req->rate * 2);
|
||||
- req->rate = DIV_ROUND_UP(req->best_parent_rate, 2);
|
||||
+ struct krait_div_clk *d = to_krait_div_clk(hw);
|
||||
+
|
||||
+ req->best_parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw),
|
||||
+ req->rate * d->divisor);
|
||||
+ req->rate = DIV_ROUND_UP(req->best_parent_rate, d->divisor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int krait_div2_set_rate(struct clk_hw *hw, unsigned long rate,
|
||||
+static int krait_div_set_rate(struct clk_hw *hw, unsigned long rate,
|
||||
unsigned long parent_rate)
|
||||
{
|
||||
- struct krait_div2_clk *d = to_krait_div2_clk(hw);
|
||||
+ struct krait_div_clk *d = to_krait_div_clk(hw);
|
||||
+ u8 div_val = krait_div_to_val(d->divisor);
|
||||
unsigned long flags;
|
||||
- u32 val;
|
||||
- u32 mask = BIT(d->width) - 1;
|
||||
-
|
||||
- if (d->lpl)
|
||||
- mask = mask << (d->shift + LPL_SHIFT) | mask << d->shift;
|
||||
- else
|
||||
- mask <<= d->shift;
|
||||
+ u32 regval;
|
||||
|
||||
spin_lock_irqsave(&krait_clock_reg_lock, flags);
|
||||
- val = krait_get_l2_indirect_reg(d->offset);
|
||||
- val &= ~mask;
|
||||
- krait_set_l2_indirect_reg(d->offset, val);
|
||||
+ regval = krait_get_l2_indirect_reg(d->offset);
|
||||
+
|
||||
+ regval &= ~(d->mask << d->shift);
|
||||
+ regval |= (div_val & d->mask) << d->shift;
|
||||
+
|
||||
+ if (d->lpl) {
|
||||
+ regval &= ~(d->mask << (d->shift + LPL_SHIFT));
|
||||
+ regval |= (div_val & d->mask) << (d->shift + LPL_SHIFT);
|
||||
+ }
|
||||
+
|
||||
+ krait_set_l2_indirect_reg(d->offset, regval);
|
||||
spin_unlock_irqrestore(&krait_clock_reg_lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
-krait_div2_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
|
||||
+krait_div_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
|
||||
{
|
||||
- struct krait_div2_clk *d = to_krait_div2_clk(hw);
|
||||
- u32 mask = BIT(d->width) - 1;
|
||||
+ struct krait_div_clk *d = to_krait_div_clk(hw);
|
||||
u32 div;
|
||||
|
||||
div = krait_get_l2_indirect_reg(d->offset);
|
||||
div >>= d->shift;
|
||||
- div &= mask;
|
||||
- div = (div + 1) * 2;
|
||||
+ div &= d->mask;
|
||||
|
||||
- return DIV_ROUND_UP(parent_rate, div);
|
||||
+ return DIV_ROUND_UP(parent_rate, krait_val_to_div(div));
|
||||
}
|
||||
|
||||
-const struct clk_ops krait_div2_clk_ops = {
|
||||
- .determine_rate = krait_div2_determine_rate,
|
||||
- .set_rate = krait_div2_set_rate,
|
||||
- .recalc_rate = krait_div2_recalc_rate,
|
||||
+const struct clk_ops krait_div_clk_ops = {
|
||||
+ .determine_rate = krait_div_determine_rate,
|
||||
+ .set_rate = krait_div_set_rate,
|
||||
+ .recalc_rate = krait_div_recalc_rate,
|
||||
};
|
||||
-EXPORT_SYMBOL_GPL(krait_div2_clk_ops);
|
||||
+EXPORT_SYMBOL_GPL(krait_div_clk_ops);
|
||||
--- a/drivers/clk/qcom/clk-krait.h
|
||||
+++ b/drivers/clk/qcom/clk-krait.h
|
||||
@@ -25,17 +25,20 @@ struct krait_mux_clk {
|
||||
|
||||
extern const struct clk_ops krait_mux_clk_ops;
|
||||
|
||||
-struct krait_div2_clk {
|
||||
+struct krait_div_clk {
|
||||
u32 offset;
|
||||
- u8 width;
|
||||
+ u32 mask;
|
||||
+ u8 divisor;
|
||||
u32 shift;
|
||||
bool lpl;
|
||||
|
||||
struct clk_hw hw;
|
||||
};
|
||||
|
||||
-#define to_krait_div2_clk(_hw) container_of(_hw, struct krait_div2_clk, hw)
|
||||
+#define to_krait_div_clk(_hw) container_of(_hw, struct krait_div_clk, hw)
|
||||
+#define krait_div_to_val(_div) ((_div) / 2) - 1
|
||||
+#define krait_val_to_div(_val) ((_val) + 1) * 2
|
||||
|
||||
-extern const struct clk_ops krait_div2_clk_ops;
|
||||
+extern const struct clk_ops krait_div_clk_ops;
|
||||
|
||||
#endif
|
||||
--- a/drivers/clk/qcom/krait-cc.c
|
||||
+++ b/drivers/clk/qcom/krait-cc.c
|
||||
@@ -86,11 +86,11 @@ static int krait_notifier_register(struc
|
||||
static struct clk_hw *
|
||||
krait_add_div(struct device *dev, int id, const char *s, unsigned int offset)
|
||||
{
|
||||
- struct krait_div2_clk *div;
|
||||
+ struct krait_div_clk *div;
|
||||
static struct clk_parent_data p_data[1];
|
||||
struct clk_init_data init = {
|
||||
.num_parents = ARRAY_SIZE(p_data),
|
||||
- .ops = &krait_div2_clk_ops,
|
||||
+ .ops = &krait_div_clk_ops,
|
||||
.flags = CLK_SET_RATE_PARENT,
|
||||
};
|
||||
struct clk_hw *clk;
|
||||
@@ -101,7 +101,8 @@ krait_add_div(struct device *dev, int id
|
||||
if (!div)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
- div->width = 2;
|
||||
+ div->mask = 0x3;
|
||||
+ div->divisor = 2;
|
||||
div->shift = 6;
|
||||
div->lpl = id >= 0;
|
||||
div->offset = offset;
|
||||
@@ -0,0 +1,31 @@
|
||||
From ac84ac819a2e8fd3d87122b452c502a386c54437 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Tue, 5 Jul 2022 18:30:18 +0200
|
||||
Subject: [PATCH v2 4/4] clk: qcom: gcc-ipq806x: remove cc_register_board for
|
||||
pxo and cxo
|
||||
|
||||
Now that these clock are defined as fixed clk in dts, we can drop the
|
||||
register_board_clk for cxo_board and pxo_board in gcc_ipq806x_probe.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
drivers/clk/qcom/gcc-ipq806x.c | 8 --------
|
||||
1 file changed, 8 deletions(-)
|
||||
|
||||
--- a/drivers/clk/qcom/gcc-ipq806x.c
|
||||
+++ b/drivers/clk/qcom/gcc-ipq806x.c
|
||||
@@ -3386,14 +3386,6 @@ static int gcc_ipq806x_probe(struct plat
|
||||
struct regmap *regmap;
|
||||
int ret;
|
||||
|
||||
- ret = qcom_cc_register_board_clk(dev, "cxo_board", "cxo", 25000000);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
-
|
||||
- ret = qcom_cc_register_board_clk(dev, "pxo_board", "pxo", 25000000);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
-
|
||||
if (of_machine_is_compatible("qcom,ipq8065")) {
|
||||
ubi32_core1_src_clk.freq_tbl = clk_tbl_nss_ipq8065;
|
||||
ubi32_core2_src_clk.freq_tbl = clk_tbl_nss_ipq8065;
|
||||
@@ -0,0 +1,118 @@
|
||||
From: Christian Lamparter <chunkeey@googlemail.com>
|
||||
Subject: SoC: add qualcomm syscon
|
||||
--- a/drivers/soc/qcom/Makefile
|
||||
+++ b/drivers/soc/qcom/Makefile
|
||||
@@ -26,6 +26,7 @@ obj-$(CONFIG_QCOM_SOCINFO) += socinfo.o
|
||||
obj-$(CONFIG_QCOM_SPM) += spm.o
|
||||
obj-$(CONFIG_QCOM_STATS) += qcom_stats.o
|
||||
obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o
|
||||
+obj-$(CONFIG_QCOM_TCSR) += qcom_tcsr.o
|
||||
obj-$(CONFIG_QCOM_APR) += apr.o
|
||||
obj-$(CONFIG_QCOM_LLCC) += llcc-qcom.o
|
||||
obj-$(CONFIG_QCOM_KRYO_L2_ACCESSORS) += kryo-l2-accessors.o
|
||||
--- a/drivers/soc/qcom/Kconfig
|
||||
+++ b/drivers/soc/qcom/Kconfig
|
||||
@@ -252,6 +252,13 @@ config QCOM_STATS
|
||||
various SoC level low power modes statistics and export to debugfs
|
||||
interface.
|
||||
|
||||
+config QCOM_TCSR
|
||||
+ tristate "QCOM Top Control and Status Registers"
|
||||
+ depends on ARCH_QCOM
|
||||
+ help
|
||||
+ Say y here to enable TCSR support. The TCSR provides control
|
||||
+ functions for various peripherals.
|
||||
+
|
||||
config QCOM_WCNSS_CTRL
|
||||
tristate "Qualcomm WCNSS control driver"
|
||||
depends on ARCH_QCOM || COMPILE_TEST
|
||||
--- /dev/null
|
||||
+++ b/drivers/soc/qcom/qcom_tcsr.c
|
||||
@@ -0,0 +1,61 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2014, The Linux foundation. All rights reserved.
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License rev 2 and
|
||||
+ * only rev 2 as published by the free Software foundation.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or fITNESS fOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/clk.h>
|
||||
+#include <linux/err.h>
|
||||
+#include <linux/io.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_platform.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+
|
||||
+#define TCSR_USB_PORT_SEL 0xb0
|
||||
+
|
||||
+static int tcsr_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ const struct device_node *node = pdev->dev.of_node;
|
||||
+ void __iomem *base;
|
||||
+ u32 val;
|
||||
+
|
||||
+ base = devm_platform_ioremap_resource(pdev, 0);
|
||||
+ if (IS_ERR(base))
|
||||
+ return PTR_ERR(base);
|
||||
+
|
||||
+ if (!of_property_read_u32(node, "qcom,usb-ctrl-select", &val)) {
|
||||
+ dev_err(&pdev->dev, "setting usb port select = %d\n", val);
|
||||
+ writel(val, base + TCSR_USB_PORT_SEL);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id tcsr_dt_match[] = {
|
||||
+ { .compatible = "qcom,tcsr", },
|
||||
+ { },
|
||||
+};
|
||||
+
|
||||
+MODULE_DEVICE_TABLE(of, tcsr_dt_match);
|
||||
+
|
||||
+static struct platform_driver tcsr_driver = {
|
||||
+ .driver = {
|
||||
+ .name = "tcsr",
|
||||
+ .of_match_table = tcsr_dt_match,
|
||||
+ },
|
||||
+ .probe = tcsr_probe,
|
||||
+};
|
||||
+
|
||||
+module_platform_driver(tcsr_driver);
|
||||
+
|
||||
+MODULE_AUTHOR("Andy Gross <agross@codeaurora.org>");
|
||||
+MODULE_DESCRIPTION("QCOM TCSR driver");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
--- /dev/null
|
||||
+++ b/include/dt-bindings/soc/qcom,tcsr.h
|
||||
@@ -0,0 +1,23 @@
|
||||
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License version 2 and
|
||||
+ * only version 2 as published by the Free Software Foundation.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ */
|
||||
+#ifndef __DT_BINDINGS_QCOM_TCSR_H
|
||||
+#define __DT_BINDINGS_QCOM_TCSR_H
|
||||
+
|
||||
+#define TCSR_USB_SELECT_USB3_P0 0x1
|
||||
+#define TCSR_USB_SELECT_USB3_P1 0x2
|
||||
+#define TCSR_USB_SELECT_USB3_DUAL 0x3
|
||||
+
|
||||
+/* TCSR A/B REG */
|
||||
+#define IPQ806X_TCSR_REG_A_ADM_CRCI_MUX_SEL 0
|
||||
+#define IPQ806X_TCSR_REG_B_ADM_CRCI_MUX_SEL 1
|
||||
+
|
||||
+#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
--- a/arch/arm/Kconfig
|
||||
+++ b/arch/arm/Kconfig
|
||||
@@ -1568,6 +1568,14 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEN
|
||||
|
||||
endchoice
|
||||
|
||||
+config CMDLINE_OVERRIDE
|
||||
+ bool "Use alternative cmdline from device tree"
|
||||
+ help
|
||||
+ Some bootloaders may have uneditable bootargs. While CMDLINE_FORCE can
|
||||
+ be used, this is not a good option for kernels that are shared across
|
||||
+ devices. This setting enables using "chosen/cmdline-override" as the
|
||||
+ cmdline if it exists in the device tree.
|
||||
+
|
||||
config CMDLINE
|
||||
string "Default kernel command string"
|
||||
default ""
|
||||
--- a/drivers/of/fdt.c
|
||||
+++ b/drivers/of/fdt.c
|
||||
@@ -1190,6 +1190,17 @@ int __init early_init_dt_scan_chosen(cha
|
||||
if (p != NULL && l > 0)
|
||||
strlcat(cmdline, p, min_t(int, strlen(cmdline) + (int)l, COMMAND_LINE_SIZE));
|
||||
|
||||
+ /* CONFIG_CMDLINE_OVERRIDE is used to fallback to a different
|
||||
+ * device tree option of chosen/bootargs-override. This is
|
||||
+ * helpful on boards where u-boot sets bootargs, and is unable
|
||||
+ * to be modified.
|
||||
+ */
|
||||
+#ifdef CONFIG_CMDLINE_OVERRIDE
|
||||
+ p = of_get_flat_dt_prop(node, "bootargs-override", &l);
|
||||
+ if (p != NULL && l > 0)
|
||||
+ strlcpy(cmdline, p, min((int)l, COMMAND_LINE_SIZE));
|
||||
+#endif
|
||||
+
|
||||
handle_cmdline:
|
||||
/*
|
||||
* CONFIG_CMDLINE is meant to be a default in case nothing else
|
||||
@@ -0,0 +1,75 @@
|
||||
From 2f86b9b71a11f86e3d850214ab781ebb17d7260e Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Fri, 19 Jan 2024 19:48:30 +0100
|
||||
Subject: [PATCH v2 1/2] ARM: decompressor: support memory start validation for
|
||||
appended DTB
|
||||
|
||||
There is currently a problem with a very specific sets of kernel config
|
||||
and AUTO_ZRELADDR.
|
||||
|
||||
For the most common case AUTO_ZRELADDR check the PC register and
|
||||
calculate the start of the physical memory. Then fdt_check_mem_start is
|
||||
called to make sure the detected value makes sense by comparing it with
|
||||
what is present in DTB in the memory nodes and if additional fixup are
|
||||
required with the use of linux,usable-memory-range in the chosen node to
|
||||
hardcode usable memory range in case some reserved space needs to be
|
||||
addressed. With the help of this function the right address is
|
||||
calculated and the kernel correctly decompress and loads.
|
||||
|
||||
Things starts to become problematic when in the mix,
|
||||
CONFIG_ARM_APPENDED_DTB is used. This is a particular kernel config is
|
||||
used when legacy systems doesn't support passing a DTB directly and a
|
||||
DTB is appended at the end of the image.
|
||||
|
||||
In such case, fdt_check_mem_start is skipped in AUTO_ZRELADDR iteration
|
||||
as the appended DTB can be augumented later with ATAGS passed from the
|
||||
bootloader (if CONFIG_ARM_ATAG_DTB_COMPAT is enabled).
|
||||
|
||||
The main problem and what this patch address is the fact that
|
||||
fdt_check_mem_start is never called later when the appended DTB is
|
||||
augumented, hence any fixup and validation is not done making AUTO_ZRELADDR
|
||||
detection inconsistent and most of the time wrong.
|
||||
|
||||
Add support in head.S for this by checking if AUTO_ZRELADDR is enabled
|
||||
and calling fdt_check_mem_start with the appended DTB and the augumented
|
||||
values permitting legacy device to provide info in DTB instead of
|
||||
disabling AUTO_ZRELADDR and hardcoding the physical address offsets.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
|
||||
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
---
|
||||
arch/arm/boot/compressed/head.S | 22 ++++++++++++++++++++++
|
||||
1 file changed, 22 insertions(+)
|
||||
|
||||
--- a/arch/arm/boot/compressed/head.S
|
||||
+++ b/arch/arm/boot/compressed/head.S
|
||||
@@ -443,6 +443,28 @@ restart: adr r0, LC1
|
||||
add r6, r6, r5
|
||||
add r10, r10, r5
|
||||
add sp, sp, r5
|
||||
+
|
||||
+#ifdef CONFIG_AUTO_ZRELADDR
|
||||
+ /*
|
||||
+ * Validate calculated start of physical memory with appended DTB.
|
||||
+ * In the first iteration for physical memory start calculation,
|
||||
+ * we skipped validating it as it could have been augumented by
|
||||
+ * ATAGS stored at an offset from the same start of physical memory.
|
||||
+ *
|
||||
+ * We now have parsed them and augumented the appended DTB if asked
|
||||
+ * so we can finally validate the start of physical memory.
|
||||
+ *
|
||||
+ * This is needed to apply additional fixup with
|
||||
+ * linux,usable-memory-range or to make sure AUTO_ZRELADDR detected
|
||||
+ * the correct value.
|
||||
+ */
|
||||
+ sub r0, r4, #TEXT_OFFSET @ revert to base address
|
||||
+ mov r1, r8 @ use appended DTB
|
||||
+ bl fdt_check_mem_start
|
||||
+
|
||||
+ /* Determine final kernel image address. */
|
||||
+ add r4, r0, #TEXT_OFFSET
|
||||
+#endif
|
||||
dtb_check_done:
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
From 781d7cd4c3364e9d38fa12a342c5ad4c7e33a5ba Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Fri, 19 Jan 2024 20:33:10 +0100
|
||||
Subject: [PATCH v2 2/2] ARM: decompressor: add option to ignore MEM ATAGs
|
||||
|
||||
Some bootloaders can pass broken MEM ATAGs that provide hardcoded
|
||||
information about mounted RAM size and physical location.
|
||||
Example booloader provide RAM of size 1.7Gb but actual mounted RAM
|
||||
size is 512Mb causing kernel panic.
|
||||
|
||||
Add option CONFIG_ARM_ATAG_DTB_COMPAT_IGNORE_MEM to ignore these ATAG
|
||||
and not augument appended DTB memory node.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Acked-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
---
|
||||
arch/arm/Kconfig | 12 ++++++++++++
|
||||
arch/arm/boot/compressed/atags_to_fdt.c | 4 ++++
|
||||
2 files changed, 16 insertions(+)
|
||||
|
||||
--- a/arch/arm/Kconfig
|
||||
+++ b/arch/arm/Kconfig
|
||||
@@ -1549,6 +1549,18 @@ config ARM_ATAG_DTB_COMPAT
|
||||
bootloaders, this option allows zImage to extract the information
|
||||
from the ATAG list and store it at run time into the appended DTB.
|
||||
|
||||
+config ARM_ATAG_DTB_COMPAT_IGNORE_MEM
|
||||
+ bool "Ignore MEM ATAG information from bootloader"
|
||||
+ depends on ARM_ATAG_DTB_COMPAT
|
||||
+ help
|
||||
+ Some bootloaders can pass broken MEM ATAGs that provide hardcoded
|
||||
+ information about mounted RAM size and physical location.
|
||||
+ Example booloader provide RAM of size 1.7Gb but actual mounted RAM
|
||||
+ size is 512Mb causing kernel panic.
|
||||
+
|
||||
+ Enable this option if MEM ATAGs should be ignored and the memory
|
||||
+ node in the appended DTB should NOT be augumented.
|
||||
+
|
||||
choice
|
||||
prompt "Kernel command line type" if ARM_ATAG_DTB_COMPAT
|
||||
default ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER
|
||||
--- a/arch/arm/boot/compressed/atags_to_fdt.c
|
||||
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
|
||||
@@ -170,6 +170,10 @@ int atags_to_fdt(void *atag_list, void *
|
||||
setprop_string(fdt, "/chosen", "bootargs",
|
||||
atag->u.cmdline.cmdline);
|
||||
} else if (atag->hdr.tag == ATAG_MEM) {
|
||||
+ /* Bootloader MEM ATAG are broken and should be ignored */
|
||||
+ if (IS_ENABLED(CONFIG_ARM_ATAG_DTB_COMPAT_IGNORE_MEM))
|
||||
+ continue;
|
||||
+
|
||||
if (memcount >= sizeof(mem_reg_property)/4)
|
||||
continue;
|
||||
if (!atag->u.mem.size)
|
||||
@@ -0,0 +1,197 @@
|
||||
From 13bb6d8dd9138927950a520a288401db82871dc9 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Sun, 21 Jan 2024 23:36:57 +0100
|
||||
Subject: [PATCH] ARM: decompressor: support for ATAGs rootblock parsing
|
||||
|
||||
The command-line arguments provided by the boot loader will be
|
||||
appended to a new device tree property: bootloader-args.
|
||||
|
||||
If there is a property "append-rootblock" in DT under /chosen
|
||||
and a root= option in bootloaders command line it will be parsed
|
||||
and added to DT bootargs with the form: <append-rootblock>XX.
|
||||
|
||||
This is usefull in dual boot systems, to get the current root partition
|
||||
without afecting the rest of the system.
|
||||
|
||||
Signed-off-by: Adrian Panella <ianchi74@outlook.com>
|
||||
[ reworked to a cleaner patch ]
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
arch/arm/Kconfig | 10 +++
|
||||
arch/arm/boot/compressed/atags_to_fdt.c | 102 ++++++++++++++++++++++--
|
||||
init/main.c | 12 +++
|
||||
3 files changed, 117 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/arch/arm/Kconfig
|
||||
+++ b/arch/arm/Kconfig
|
||||
@@ -1578,6 +1578,16 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEN
|
||||
The command-line arguments provided by the boot loader will be
|
||||
appended to the the device tree bootargs property.
|
||||
|
||||
+config ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE
|
||||
+ bool "Append rootblock parsing bootloader's kernel arguments"
|
||||
+ help
|
||||
+ The command-line arguments provided by the boot loader will be
|
||||
+ appended to a new device tree property: bootloader-args.
|
||||
+
|
||||
+ If there is a property "append-rootblock" in DT under /chosen
|
||||
+ and a root= option in bootloaders command line it will be parsed
|
||||
+ and added to DT bootargs with the form: <append-rootblock>XX.
|
||||
+
|
||||
endchoice
|
||||
|
||||
config CMDLINE_OVERRIDE
|
||||
--- a/arch/arm/boot/compressed/atags_to_fdt.c
|
||||
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
|
||||
@@ -4,7 +4,8 @@
|
||||
#include <libfdt.h>
|
||||
#include "misc.h"
|
||||
|
||||
-#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND)
|
||||
+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND) || \
|
||||
+ defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE)
|
||||
#define do_extend_cmdline 1
|
||||
#else
|
||||
#define do_extend_cmdline 0
|
||||
@@ -70,6 +71,83 @@ static uint32_t get_cell_size(const void
|
||||
return cell_size;
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * taken from arch/x86/boot/string.c
|
||||
+ * local_strstr - Find the first substring in a %NUL terminated string
|
||||
+ * @s1: The string to be searched
|
||||
+ * @s2: The string to search for
|
||||
+ */
|
||||
+static char *local_strstr(const char *s1, const char *s2)
|
||||
+{
|
||||
+ size_t l1, l2;
|
||||
+
|
||||
+ l2 = strlen(s2);
|
||||
+ if (!l2)
|
||||
+ return (char *)s1;
|
||||
+ l1 = strlen(s1);
|
||||
+ while (l1 >= l2) {
|
||||
+ l1--;
|
||||
+ if (!memcmp(s1, s2, l2))
|
||||
+ return (char *)s1;
|
||||
+ s1++;
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static char *append_rootblock(char *dest, const char *str, int len, void *fdt)
|
||||
+{
|
||||
+ char *ptr, *end, *tmp;
|
||||
+ const char *root="root=";
|
||||
+ const char *find_rootblock;
|
||||
+ int i, l;
|
||||
+ const char *rootblock;
|
||||
+
|
||||
+ find_rootblock = getprop(fdt, "/chosen", "find-rootblock", &l);
|
||||
+ if (!find_rootblock)
|
||||
+ find_rootblock = root;
|
||||
+
|
||||
+ /* ARM doesn't have __HAVE_ARCH_STRSTR, so it was copied from x86 */
|
||||
+ ptr = local_strstr(str, find_rootblock);
|
||||
+ if (!ptr)
|
||||
+ return dest;
|
||||
+
|
||||
+ end = strchr(ptr, ' ');
|
||||
+ end = end ? (end - 1) : (strchr(ptr, 0) - 1);
|
||||
+
|
||||
+ /* Some boards ubi.mtd=XX,ZZZZ, so let's check for '," too. */
|
||||
+ tmp = strchr(ptr, ',');
|
||||
+ if (tmp)
|
||||
+ end = end < tmp ? end : tmp - 1;
|
||||
+
|
||||
+ /*
|
||||
+ * find partition number
|
||||
+ * (assumes format root=/dev/mtdXX | /dev/mtdblockXX | yy:XX | ubi.mtd=XX,ZZZZ )
|
||||
+ */
|
||||
+ for (i = 0; end >= ptr && *end >= '0' && *end <= '9'; end--, i++);
|
||||
+
|
||||
+ ptr = end + 1;
|
||||
+
|
||||
+ /* if append-rootblock property is set use it to append to command line */
|
||||
+ rootblock = getprop(fdt, "/chosen", "append-rootblock", &l);
|
||||
+ if (rootblock != NULL) {
|
||||
+ if (*dest != ' ') {
|
||||
+ *dest = ' ';
|
||||
+ dest++;
|
||||
+ len++;
|
||||
+ }
|
||||
+
|
||||
+ if (len + l + i <= COMMAND_LINE_SIZE) {
|
||||
+ memcpy(dest, rootblock, l);
|
||||
+ dest += l - 1;
|
||||
+
|
||||
+ memcpy(dest, ptr, i);
|
||||
+ dest += i;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return dest;
|
||||
+}
|
||||
+
|
||||
static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)
|
||||
{
|
||||
char cmdline[COMMAND_LINE_SIZE];
|
||||
@@ -87,13 +165,23 @@ static void merge_fdt_bootargs(void *fdt
|
||||
ptr += len - 1;
|
||||
}
|
||||
|
||||
- /* and append the ATAG_CMDLINE */
|
||||
if (fdt_cmdline) {
|
||||
- len = strlen(fdt_cmdline);
|
||||
- if (ptr - cmdline + len + 2 < COMMAND_LINE_SIZE) {
|
||||
- *ptr++ = ' ';
|
||||
- memcpy(ptr, fdt_cmdline, len);
|
||||
- ptr += len;
|
||||
+ if (IS_ENABLED(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE)) {
|
||||
+ /*
|
||||
+ * save original bootloader args
|
||||
+ * and append ubi.mtd with root partition number
|
||||
+ * to current cmdline
|
||||
+ */
|
||||
+ setprop_string(fdt, "/chosen", "bootloader-args", fdt_cmdline);
|
||||
+ ptr = append_rootblock(ptr, fdt_cmdline, len, fdt);
|
||||
+ } else {
|
||||
+ /* and append the ATAG_CMDLINE */
|
||||
+ len = strlen(fdt_cmdline);
|
||||
+ if (ptr - cmdline + len + 2 < COMMAND_LINE_SIZE) {
|
||||
+ *ptr++ = ' ';
|
||||
+ memcpy(ptr, fdt_cmdline, len);
|
||||
+ ptr += len;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
*ptr = '\0';
|
||||
--- a/init/main.c
|
||||
+++ b/init/main.c
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <linux/initrd.h>
|
||||
#include <linux/memblock.h>
|
||||
#include <linux/acpi.h>
|
||||
+#include <linux/of.h>
|
||||
#include <linux/bootconfig.h>
|
||||
#include <linux/console.h>
|
||||
#include <linux/nmi.h>
|
||||
@@ -931,6 +932,17 @@ void start_kernel(void)
|
||||
pr_notice("Kernel command line: %s\n", saved_command_line);
|
||||
/* parameters may set static keys */
|
||||
jump_label_init();
|
||||
+
|
||||
+ /* Show bootloader's original command line for reference */
|
||||
+ if (IS_ENABLED(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) && of_chosen) {
|
||||
+ const char *prop = of_get_property(of_chosen, "bootloader-args", NULL);
|
||||
+
|
||||
+ if(prop)
|
||||
+ pr_notice("Bootloader command line (ignored): %s\n", prop);
|
||||
+ else
|
||||
+ pr_notice("Bootloader command line not present\n");
|
||||
+ }
|
||||
+
|
||||
parse_early_param();
|
||||
after_dashes = parse_args("Booting kernel",
|
||||
static_command_line, __start___param,
|
||||
Reference in New Issue
Block a user