ipq40xx: update SCM SDI patches with pending upstream
authorRobert Marko <robimarko@gmail.com>
Sun, 13 Aug 2023 16:20:08 +0000 (18:20 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Tue, 15 Aug 2023 14:38:49 +0000 (16:38 +0200)
SCM SDI disable support is pending upstream, so lets use that instead.

Since the board check needs to be split out, export it with a header so
it applies with git-am.

Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/ipq40xx/patches-5.15/420-firmware-qcom-scm-Add-SDI-disable-support.patch [new file with mode: 0644]
target/linux/ipq40xx/patches-5.15/420-firmware-qcom-scm-disable-SDI.patch [deleted file]
target/linux/ipq40xx/patches-5.15/421-firmware-qcom-scm-disable-SDI-on-Google-WiFi.patch [new file with mode: 0644]
target/linux/ipq40xx/patches-5.15/910-Revert-firmware-qcom_scm-Clear-download-bit-during-r.patch

diff --git a/target/linux/ipq40xx/patches-5.15/420-firmware-qcom-scm-Add-SDI-disable-support.patch b/target/linux/ipq40xx/patches-5.15/420-firmware-qcom-scm-Add-SDI-disable-support.patch
new file mode 100644 (file)
index 0000000..e4ee745
--- /dev/null
@@ -0,0 +1,60 @@
+From b514bc3c0a5a57bc83843dc66c72788b9c9435ac Mon Sep 17 00:00:00 2001
+From: Robert Marko <robimarko@gmail.com>
+Date: Thu, 18 May 2023 16:02:23 +0200
+Subject: [PATCH 1/3] firmware: qcom: scm: Add SDI disable support
+
+Some SoC-s like IPQ5018 require SDI(Secure Debug Image) to be disabled
+before trying to reboot, otherwise board will just hang after reboot has
+been issued via PSCI.
+
+So, provide a call to SCM that allows disabling it.
+
+Signed-off-by: Robert Marko <robimarko@gmail.com>
+Acked-by: Mukesh Ojha <quic_mojha@quicinc.com>
+---
+ drivers/firmware/qcom_scm.c | 23 +++++++++++++++++++++++
+ drivers/firmware/qcom_scm.h |  1 +
+ 2 files changed, 24 insertions(+)
+
+--- a/drivers/firmware/qcom_scm.c
++++ b/drivers/firmware/qcom_scm.c
+@@ -389,6 +389,29 @@ int qcom_scm_set_remote_state(u32 state,
+ }
+ EXPORT_SYMBOL(qcom_scm_set_remote_state);
++static int qcom_scm_disable_sdi(void)
++{
++      int ret;
++      struct qcom_scm_desc desc = {
++              .svc = QCOM_SCM_SVC_BOOT,
++              .cmd = QCOM_SCM_BOOT_SDI_CONFIG,
++              .args[0] = 1, /* Disable watchdog debug */
++              .args[1] = 0, /* Disable SDI */
++              .arginfo = QCOM_SCM_ARGS(2),
++              .owner = ARM_SMCCC_OWNER_SIP,
++      };
++      struct qcom_scm_res res;
++
++      ret = qcom_scm_clk_enable();
++      if (ret)
++              return ret;
++      ret = qcom_scm_call(__scm->dev, &desc, &res);
++
++      qcom_scm_clk_disable();
++
++      return ret ? : res.result[0];
++}
++
+ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
+ {
+       struct qcom_scm_desc desc = {
+--- a/drivers/firmware/qcom_scm.h
++++ b/drivers/firmware/qcom_scm.h
+@@ -77,6 +77,7 @@ extern int scm_legacy_call(struct device
+ #define QCOM_SCM_SVC_BOOT             0x01
+ #define QCOM_SCM_BOOT_SET_ADDR                0x01
+ #define QCOM_SCM_BOOT_TERMINATE_PC    0x02
++#define QCOM_SCM_BOOT_SDI_CONFIG      0x09
+ #define QCOM_SCM_BOOT_SET_DLOAD_MODE  0x10
+ #define QCOM_SCM_BOOT_SET_REMOTE_STATE        0x0a
+ #define QCOM_SCM_FLUSH_FLAG_MASK      0x3
diff --git a/target/linux/ipq40xx/patches-5.15/420-firmware-qcom-scm-disable-SDI.patch b/target/linux/ipq40xx/patches-5.15/420-firmware-qcom-scm-disable-SDI.patch
deleted file mode 100644 (file)
index a007410..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/drivers/firmware/qcom_scm.c
-+++ b/drivers/firmware/qcom_scm.c
-@@ -404,6 +404,20 @@ static int __qcom_scm_set_dload_mode(str
-       return qcom_scm_call_atomic(__scm->dev, &desc, NULL);
- }
-+static int __qcom_scm_disable_sdi(struct device *dev)
-+{
-+      struct qcom_scm_desc desc = {
-+              .svc = QCOM_SCM_SVC_BOOT,
-+              .cmd = QCOM_SCM_BOOT_CONFIG_SDI,
-+              .arginfo = QCOM_SCM_ARGS(2),
-+              .args[0] = 1  /* 1: disable watchdog debug */,
-+              .args[1] = 0  /* 0: disable SDI */,
-+              .owner = ARM_SMCCC_OWNER_SIP,
-+      };
-+
-+      return qcom_scm_call(__scm->dev, &desc, NULL);
-+}
-+
- static void qcom_scm_set_download_mode(bool enable)
- {
-       bool avail;
-@@ -1314,6 +1328,13 @@ static int qcom_scm_probe(struct platfor
-       if (download_mode)
-               qcom_scm_set_download_mode(true);
-+      /*
-+       * Factory firmware leaves SDI (a debug interface), which prevents
-+       * clean reboot.
-+       */
-+      if (of_machine_is_compatible("google,wifi"))
-+              __qcom_scm_disable_sdi(__scm->dev);
-+
-       return 0;
- }
---- a/drivers/firmware/qcom_scm.h
-+++ b/drivers/firmware/qcom_scm.h
-@@ -77,6 +77,7 @@ extern int scm_legacy_call(struct device
- #define QCOM_SCM_SVC_BOOT             0x01
- #define QCOM_SCM_BOOT_SET_ADDR                0x01
- #define QCOM_SCM_BOOT_TERMINATE_PC    0x02
-+#define QCOM_SCM_BOOT_CONFIG_SDI      0x09
- #define QCOM_SCM_BOOT_SET_DLOAD_MODE  0x10
- #define QCOM_SCM_BOOT_SET_REMOTE_STATE        0x0a
- #define QCOM_SCM_FLUSH_FLAG_MASK      0x3
diff --git a/target/linux/ipq40xx/patches-5.15/421-firmware-qcom-scm-disable-SDI-on-Google-WiFi.patch b/target/linux/ipq40xx/patches-5.15/421-firmware-qcom-scm-disable-SDI-on-Google-WiFi.patch
new file mode 100644 (file)
index 0000000..98f0293
--- /dev/null
@@ -0,0 +1,34 @@
+From a658ad57c2b9d46eb5395c7bb8cf83b8e0f289e7 Mon Sep 17 00:00:00 2001
+From: Brian Norris <computersforpeace@gmail.com>
+Date: Fri, 28 Jul 2023 12:02:19 +0200
+Subject: [PATCH 2/3] firmware: qcom: scm: disable SDI on Google WiFi
+
+Google WiFi seems to have SDI (Secure Debug Image) enabled by default which
+prevents normal reboot from working causing the board to just hang after
+reboot is called.
+
+So lets disable SDI during SCM probe on Google WiFi boards in order to
+avoid a state where WDT will kick in and then the board will just hang
+in the debug mode.
+
+Signed-off-by: Brian Norris <computersforpeace@gmail.com>
+---
+ drivers/firmware/qcom_scm.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/drivers/firmware/qcom_scm.c
++++ b/drivers/firmware/qcom_scm.c
+@@ -1337,6 +1337,13 @@ static int qcom_scm_probe(struct platfor
+       if (download_mode)
+               qcom_scm_set_download_mode(true);
++      /*
++       * Factory firmware leaves SDI (a debug interface), which prevents
++       * clean reboot.
++       */
++      if (of_machine_is_compatible("google,wifi"))
++              qcom_scm_disable_sdi();
++
+       return 0;
+ }
index e24895deeca20994d2c325ca5b5fd1afcd02279a..b5b89b26f1deabd08156781269619b977849213c 100644 (file)
@@ -1,6 +1,6 @@
-From c87df89a82c17411cd6b98e5afaa1203ee9508dc Mon Sep 17 00:00:00 2001
+From c668fd2c4d9ad4a510fd214a2da83bd9b67a2508 Mon Sep 17 00:00:00 2001
 From: Robert Marko <robimarko@gmail.com>
-Date: Thu, 18 May 2023 12:16:02 +0200
+Date: Sun, 13 Aug 2023 18:13:08 +0200
 Subject: [PATCH] Revert "firmware: qcom_scm: Clear download bit during reboot"
 
 This reverts commit a3ea89b5978dbcd0fa55f675c5a1e04611093709.
@@ -15,7 +15,7 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
 
 --- a/drivers/firmware/qcom_scm.c
 +++ b/drivers/firmware/qcom_scm.c
-@@ -1352,7 +1352,8 @@ static int qcom_scm_probe(struct platfor
+@@ -1361,7 +1361,8 @@ static int qcom_scm_probe(struct platfor
  static void qcom_scm_shutdown(struct platform_device *pdev)
  {
        /* Clean shutdown, disable download mode to allow normal restart */