summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Chen <chenjh@rock-chips.com>2021-11-03 04:31:27 +0300
committerJianhong Chen <chenjh@rock-chips.com>2021-11-03 05:04:49 +0300
commit83cfcb32f9771681fb123214d36eb7b79a825c82 (patch)
treecdf5d3173b5c544c8f89815beda45c158f149f9a
parent5e1b21ba53ede39404909b0cb91b4a91a2350151 (diff)
downloadu-boot-83cfcb32f9771681fb123214d36eb7b79a825c82.tar.xz
dm: sysreset: do optimise
1. use more generic way for psci/syscon-reboot sysreset, fixes compile error: ...... drivers/built-in.o: In function `sysreset_walk': drivers/sysreset/sysreset-uclass.c:49: undefined reference to `_u_boot_list_2_driver_2_psci_sysreset' drivers/built-in.o: In function `reboot': drivers/sysreset/sysreset-uclass.c:102: undefined reference to `_u_boot_list_2_driver_2_sysreset_syscon_reboot' ...... 2. use psci/syscon-reboot sysreset only in U-Boot proper, excluding SPL/TPL/USBPLUG. Signed-off-by: Joseph Chen <chenjh@rock-chips.com> Change-Id: I6908e7e2d7e5143643be3f0cab90cd6009cde254
-rw-r--r--drivers/sysreset/Kconfig6
-rw-r--r--drivers/sysreset/Makefile6
-rw-r--r--drivers/sysreset/sysreset-uclass.c52
-rw-r--r--drivers/sysreset/sysreset_psci.c3
4 files changed, 31 insertions, 36 deletions
diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig
index e272a9990f..dd7928f8fa 100644
--- a/drivers/sysreset/Kconfig
+++ b/drivers/sysreset/Kconfig
@@ -50,6 +50,12 @@ config SYSRESET_SYSCON
help
Reboot support for generic SYSCON mapped register reset.
+config SYSRESET_SYSCON_REBOOT
+ bool "Enable support for syscon reboot mode driver"
+ default y if ARCH_ROCKCHIP
+ help
+ Reboot mode command, like: reboot bootloader, etc.
+
config SYSRESET_WATCHDOG
bool "Enable support for watchdog reboot driver"
select WDT
diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile
index 0aa37f6b30..f033560d62 100644
--- a/drivers/sysreset/Makefile
+++ b/drivers/sysreset/Makefile
@@ -6,9 +6,9 @@
obj-$(CONFIG_$(SPL_TPL_)SYSRESET) += sysreset-uclass.o
-ifndef CONFIG_SPL_BUILD
-obj-$(CONFIG_SYSRESET) += sysreset-syscon-reboot.o
-obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o
+ifndef CONFIG_SUPPORT_USBPLUG
+obj-$(CONFIG_$(SPL_TPL_)SYSRESET_SYSCON_REBOOT) += sysreset-syscon-reboot.o
+obj-$(CONFIG_$(SPL_TPL_)SYSRESET_PSCI) += sysreset_psci.o
endif
obj-$(CONFIG_SYSRESET_SYSCON) += sysreset_syscon.o
diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
index 6c3bb8fedb..63fd53204f 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -30,20 +30,6 @@ int sysreset_walk(enum sysreset_t type)
struct udevice *dev;
int ret = -ENOSYS;
- /*
- * Use psci sysreset as primary for rockchip platforms,
- * "rockchip_reset" is applied if PSCI is disabled.
- */
-#if !defined(CONFIG_SPL_BUILD) && \
- defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_SYSRESET_PSCI)
- ret = uclass_get_device_by_driver(UCLASS_SYSRESET,
- DM_GET_DRIVER(psci_sysreset), &dev);
- if (!ret)
- sysreset_request(dev, type);
- else
- printf("WARN: PSCI sysreset is disabled\n");
-#endif
-
while (ret != -EINPROGRESS && type < SYSRESET_COUNT) {
for (uclass_first_device(UCLASS_SYSRESET, &dev);
dev;
@@ -58,6 +44,25 @@ int sysreset_walk(enum sysreset_t type)
return ret;
}
+static void sysreset_walk_reboot_mode(const char *mode)
+{
+ struct sysreset_ops *ops;
+ struct udevice *dev;
+
+ if (!mode)
+ return;
+
+ for (uclass_first_device(UCLASS_SYSRESET, &dev);
+ dev;
+ uclass_next_device(&dev)) {
+ ops = sysreset_get_ops(dev);
+ if (ops && ops->request_by_mode) {
+ ops->request_by_mode(dev, mode);
+ break;
+ }
+ }
+}
+
void sysreset_walk_halt(enum sysreset_t type)
{
int ret;
@@ -83,24 +88,7 @@ void reset_cpu(ulong addr)
void reboot(const char *mode)
{
-#ifndef CONFIG_SPL_BUILD
- struct sysreset_ops *ops;
- struct udevice *dev;
- int ret;
-
- if (!mode)
- goto finish;
-
- ret = uclass_get_device_by_driver(UCLASS_SYSRESET,
- DM_GET_DRIVER(sysreset_syscon_reboot),
- &dev);
- if (!ret) {
- ops = sysreset_get_ops(dev);
- if (ops && ops->request_by_mode)
- ops->request_by_mode(dev, mode);
- }
-finish:
-#endif
+ sysreset_walk_reboot_mode(mode);
flushc();
sysreset_walk_halt(SYSRESET_COLD);
}
diff --git a/drivers/sysreset/sysreset_psci.c b/drivers/sysreset/sysreset_psci.c
index 4656d273c1..42a56e023b 100644
--- a/drivers/sysreset/sysreset_psci.c
+++ b/drivers/sysreset/sysreset_psci.c
@@ -35,7 +35,8 @@ static struct sysreset_ops psci_sysreset_ops = {
.request = psci_sysreset_request,
};
-U_BOOT_DRIVER(psci_sysreset) = {
+/* Add an 'a_' prefix so it comes the first sysreset path. */
+U_BOOT_DRIVER(a_psci_sysreset) = {
.name = "psci-sysreset",
.id = UCLASS_SYSRESET,
.ops = &psci_sysreset_ops,