aboutsummaryrefslogtreecommitdiff
path: root/plat/qti
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2019-02-20 17:33:23 -0800
committerJulius Werner <jwerner@chromium.org>2020-08-25 17:36:13 -0700
commit522a22771f0e40866a7361b2f8e416b8cb716a1c (patch)
tree234235d3ccb10823a4eb451514645da313d95719 /plat/qti
parentf40008a4be26dc43cbf50f68c4f20803ea735807 (diff)
downloadtrusted-firmware-a-522a22771f0e40866a7361b2f8e416b8cb716a1c.tar.gz
qti/sc7180: Do shutdown handling outside qtiseclib
With an open source SPMI driver we can now remove qtiseclib involvement in reset and shutdown handling by setting the required registers directly. Change-Id: I6bf1db15734048df583daa2a4ee98701c6ece621 Signed-off-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'plat/qti')
-rw-r--r--plat/qti/common/inc/qti_plat.h3
-rw-r--r--plat/qti/common/src/pm8998.c43
-rw-r--r--plat/qti/common/src/qti_pm.c17
-rw-r--r--plat/qti/qtiseclib/inc/qtiseclib_interface.h4
-rw-r--r--plat/qti/qtiseclib/src/qtiseclib_interface_stub.c12
-rw-r--r--plat/qti/sc7180/inc/platform_def.h6
-rw-r--r--plat/qti/sc7180/platform.mk2
7 files changed, 69 insertions, 18 deletions
diff --git a/plat/qti/common/inc/qti_plat.h b/plat/qti/common/inc/qti_plat.h
index 0e867be793..4d9d3204a1 100644
--- a/plat/qti/common/inc/qti_plat.h
+++ b/plat/qti/common/inc/qti_plat.h
@@ -50,4 +50,7 @@ unsigned int plat_qti_my_cluster_pos(void);
void gic_set_spi_routing(unsigned int id, unsigned int irm, u_register_t mpidr);
+void qti_pmic_prepare_reset(void);
+void qti_pmic_prepare_shutdown(void);
+
#endif /* QTI_PLAT_H */
diff --git a/plat/qti/common/src/pm8998.c b/plat/qti/common/src/pm8998.c
new file mode 100644
index 0000000000..b189a8b86b
--- /dev/null
+++ b/plat/qti/common/src/pm8998.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2020, Google LLC. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <drivers/delay_timer.h>
+
+#include <qti_plat.h>
+#include <spmi_arb.h>
+
+/*
+ * This driver implements PON support for PM8998-compatible PMICs. This can
+ * include other part numbers like PM6150.
+ */
+
+#define PON_PS_HOLD_RESET_CTL 0x85a
+#define RESET_TYPE_WARM_RESET 1
+#define RESET_TYPE_SHUTDOWN 4
+
+#define PON_PS_HOLD_RESET_CTL2 0x85b
+#define S2_RESET_EN BIT(7)
+
+static void configure_ps_hold(uint32_t reset_type)
+{
+ /* QTI recommends disabling reset for 10 cycles before reconfiguring. */
+ spmi_arb_write8(PON_PS_HOLD_RESET_CTL2, 0);
+ mdelay(1);
+
+ spmi_arb_write8(PON_PS_HOLD_RESET_CTL, reset_type);
+ spmi_arb_write8(PON_PS_HOLD_RESET_CTL2, S2_RESET_EN);
+ mdelay(1);
+}
+
+void qti_pmic_prepare_reset(void)
+{
+ configure_ps_hold(RESET_TYPE_WARM_RESET);
+}
+
+void qti_pmic_prepare_shutdown(void)
+{
+ configure_ps_hold(RESET_TYPE_SHUTDOWN);
+}
diff --git a/plat/qti/common/src/qti_pm.c b/plat/qti/common/src/qti_pm.c
index 4a5877c5b0..5f1b7aa1dc 100644
--- a/plat/qti/common/src/qti_pm.c
+++ b/plat/qti/common/src/qti_pm.c
@@ -9,6 +9,8 @@
#include <arch_helpers.h>
#include <bl31/bl31.h>
#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
#include <lib/psci/psci.h>
#include <platform.h>
@@ -204,14 +206,25 @@ __dead2 void qti_domain_power_down_wfi(const psci_power_state_t *target_state)
/* We should never reach here */
}
+static __dead2 void assert_ps_hold(void)
+{
+ mmio_write_32(QTI_PS_HOLD_REG, 0);
+ mdelay(1000);
+
+ /* Should be dead before reaching this. */
+ panic();
+}
+
__dead2 void qti_system_off(void)
{
- qtiseclib_psci_system_off();
+ qti_pmic_prepare_shutdown();
+ assert_ps_hold();
}
__dead2 void qti_system_reset(void)
{
- qtiseclib_psci_system_reset();
+ qti_pmic_prepare_reset();
+ assert_ps_hold();
}
void qti_get_sys_suspend_power_state(psci_power_state_t *req_state)
diff --git a/plat/qti/qtiseclib/inc/qtiseclib_interface.h b/plat/qti/qtiseclib/inc/qtiseclib_interface.h
index 357bb6a2d6..315bd6bc77 100644
--- a/plat/qti/qtiseclib/inc/qtiseclib_interface.h
+++ b/plat/qti/qtiseclib/inc/qtiseclib_interface.h
@@ -78,10 +78,6 @@ void qtiseclib_psci_cpu_standby(uint8_t pwr_state);
void qtiseclib_psci_node_power_off(const uint8_t *states);
void qtiseclib_psci_node_suspend(const uint8_t *states);
void qtiseclib_psci_node_suspend_finish(const uint8_t *states);
-__attribute__ ((noreturn))
-void qtiseclib_psci_system_off(void);
-__attribute__ ((noreturn))
-void qtiseclib_psci_system_reset(void);
void qtiseclib_disable_cluster_coherency(uint8_t state);
#endif /* QTISECLIB_INTERFACE_H */
diff --git a/plat/qti/qtiseclib/src/qtiseclib_interface_stub.c b/plat/qti/qtiseclib/src/qtiseclib_interface_stub.c
index 70485fe908..9c93d51daf 100644
--- a/plat/qti/qtiseclib/src/qtiseclib_interface_stub.c
+++ b/plat/qti/qtiseclib/src/qtiseclib_interface_stub.c
@@ -108,18 +108,6 @@ void qtiseclib_psci_node_suspend_finish(const uint8_t *states)
{
}
-void qtiseclib_psci_system_off(void)
-{
- while (1) {
- };
-}
-
-void qtiseclib_psci_system_reset(void)
-{
- while (1) {
- };
-}
-
void qtiseclib_disable_cluster_coherency(uint8_t state)
{
}
diff --git a/plat/qti/sc7180/inc/platform_def.h b/plat/qti/sc7180/inc/platform_def.h
index d95b365dc4..17e1310b08 100644
--- a/plat/qti/sc7180/inc/platform_def.h
+++ b/plat/qti/sc7180/inc/platform_def.h
@@ -173,4 +173,10 @@
*/
#define BL31_LIMIT (BL31_BASE + BL31_SIZE)
+/*----------------------------------------------------------------------------*/
+/* AOSS registers */
+/*----------------------------------------------------------------------------*/
+#define QTI_PS_HOLD_REG 0x0C264000
+/*----------------------------------------------------------------------------*/
+
#endif /* PLATFORM_DEF_H */
diff --git a/plat/qti/sc7180/platform.mk b/plat/qti/sc7180/platform.mk
index 562fe7cd8e..ec560d0368 100644
--- a/plat/qti/sc7180/platform.mk
+++ b/plat/qti/sc7180/platform.mk
@@ -51,6 +51,7 @@ QTI_BL31_SOURCES := $(QTI_PLAT_PATH)/common/src/$(ARCH)/qti_helpers.S \
$(QTI_PLAT_PATH)/common/src/$(ARCH)/qti_kryo4_silver.S \
$(QTI_PLAT_PATH)/common/src/$(ARCH)/qti_kryo4_gold.S \
$(QTI_PLAT_PATH)/common/src/$(ARCH)/qti_uart_console.S \
+ $(QTI_PLAT_PATH)/common/src/pm8998.c \
$(QTI_PLAT_PATH)/common/src/qti_stack_protector.c \
$(QTI_PLAT_PATH)/common/src/qti_common.c \
$(QTI_PLAT_PATH)/common/src/qti_bl31_setup.c \
@@ -60,6 +61,7 @@ QTI_BL31_SOURCES := $(QTI_PLAT_PATH)/common/src/$(ARCH)/qti_helpers.S \
$(QTI_PLAT_PATH)/common/src/qti_topology.c \
$(QTI_PLAT_PATH)/common/src/qti_pm.c \
$(QTI_PLAT_PATH)/common/src/qti_rng.c \
+ $(QTI_PLAT_PATH)/common/src/spmi_arb.c \
$(QTI_PLAT_PATH)/qtiseclib/src/qtiseclib_cb_interface.c \