diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-01-08 18:15:17 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-01-12 11:21:39 +0100 |
commit | 1f66cbe01759930c27497eec24d28adca6d6bc94 (patch) | |
tree | f9f9ff047f1762cc439718f572a4b94069501a66 /arch/riscv | |
parent | d621a996dfc1e356428f6ebdc4014275c3d5e23c (diff) | |
download | barebox-1f66cbe01759930c27497eec24d28adca6d6bc94.tar.gz barebox-1f66cbe01759930c27497eec24d28adca6d6bc94.tar.xz |
power: reset: add RISC-V/UC Berkely HTIF poweroff driver support
We already have a driver in board code and device tree passed by
emulator already has a node for it. Match against it and create a proper
driver.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220108171524.587144-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/riscv')
-rw-r--r-- | arch/riscv/boards/riscvemu/board.c | 15 | ||||
-rw-r--r-- | arch/riscv/configs/virt32_defconfig | 1 | ||||
-rw-r--r-- | arch/riscv/configs/virt64_defconfig | 1 | ||||
-rw-r--r-- | arch/riscv/include/asm/htif.h | 31 |
4 files changed, 33 insertions, 15 deletions
diff --git a/arch/riscv/boards/riscvemu/board.c b/arch/riscv/boards/riscvemu/board.c index 7dbf9afe4c..73d787a833 100644 --- a/arch/riscv/boards/riscvemu/board.c +++ b/arch/riscv/boards/riscvemu/board.c @@ -16,18 +16,6 @@ struct riscvemu_priv { }; -#define HTIF_BASE_ADDR IOMEM(0x40008000) -#define HTIF_TOHOST_LOW (HTIF_BASE_ADDR + 0) -#define HTIF_TOHOST_HIGH (HTIF_BASE_ADDR + 4) - -static void __noreturn riscvemu_poweroff(struct poweroff_handler *pwr) -{ - writel(1, HTIF_TOHOST_LOW); - writel(0, HTIF_TOHOST_HIGH); - - __builtin_unreachable(); -} - static void __noreturn riscvemu_restart(struct restart_handler *rst) { struct riscvemu_priv *priv = container_of(rst, struct riscvemu_priv, rst); @@ -46,9 +34,6 @@ static int riscvemu_probe(struct device_d *dev) struct riscvemu_priv *priv; u64 start; - if (of_find_compatible_node(NULL, NULL, "ucb,htif0")) - poweroff_handler_register_fn(riscvemu_poweroff); - of_chosen = of_find_node_by_path("/chosen"); if (of_property_read_u64(of_chosen, "riscv,kernel-start", &start)) diff --git a/arch/riscv/configs/virt32_defconfig b/arch/riscv/configs/virt32_defconfig index ea7d1de8be..bfea7771ef 100644 --- a/arch/riscv/configs/virt32_defconfig +++ b/arch/riscv/configs/virt32_defconfig @@ -109,6 +109,7 @@ CONFIG_BLK_DEV_NVME=y CONFIG_SYSCON_REBOOT_MODE=y CONFIG_POWER_RESET_SYSCON=y CONFIG_POWER_RESET_SYSCON_POWEROFF=y +CONFIG_POWER_RESET_HTIF_POWEROFF=y CONFIG_VIRTIO_MMIO=y CONFIG_FS_EXT4=y CONFIG_FS_TFTP=y diff --git a/arch/riscv/configs/virt64_defconfig b/arch/riscv/configs/virt64_defconfig index b1c7a6712a..2ddc174b8a 100644 --- a/arch/riscv/configs/virt64_defconfig +++ b/arch/riscv/configs/virt64_defconfig @@ -110,6 +110,7 @@ CONFIG_BLK_DEV_NVME=y CONFIG_SYSCON_REBOOT_MODE=y CONFIG_POWER_RESET_SYSCON=y CONFIG_POWER_RESET_SYSCON_POWEROFF=y +CONFIG_POWER_RESET_HTIF_POWEROFF=y CONFIG_VIRTIO_MMIO=y CONFIG_FS_EXT4=y CONFIG_FS_TFTP=y diff --git a/arch/riscv/include/asm/htif.h b/arch/riscv/include/asm/htif.h new file mode 100644 index 0000000000..7312f09d2e --- /dev/null +++ b/arch/riscv/include/asm/htif.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2021 Ahmad Fatoum, Pengutronix + */ + +#ifndef __ASM_HTIF_LL__ +#define __ASM_HTIF_LL__ + +#define HTIF_DEFAULT_BASE_ADDR 0x40008000 + +#define HTIF_DEV_SYSCALL 0 +#define HTIF_CMD_SYSCALL 0 + +#ifndef __ASSEMBLY__ + +#include <linux/types.h> +#include <io-64-nonatomic-lo-hi.h> + +static inline void __htif_tohost(void __iomem *htif, u8 device, u8 command, u64 arg) +{ + writeq(((u64)device << 56) | ((u64)command << 48) | arg, htif); +} + +static inline void htif_tohost(u8 device, u8 command, u64 arg) +{ + __htif_tohost(IOMEM(HTIF_DEFAULT_BASE_ADDR), device, command, arg); +} + +#endif + +#endif |