summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamin Guo <samin.guo@starfivetech.com>2023-06-07 13:22:21 +0300
committerWilliam Qiu <william.qiu@starfivetech.com>2023-07-26 13:35:38 +0300
commit3566baaf467887df9c71a5185dc3f1808b5c923d (patch)
tree7b15f94ddbe937b67c07705038d7dce669461eaf
parentf9516d9db115e5067079f823d2c4ad9938bd174e (diff)
downloadu-boot-3566baaf467887df9c71a5185dc3f1808b5c923d.tar.xz
gpio: starfive: Add SET_DS/SET_PULL/SET_SLEW support
SET_DS/SET_PULL/SET_SLEW can configure the properties of the GPIO Signed-off-by: Samin Guo <samin.guo@starfivetech.com>
-rw-r--r--arch/riscv/include/asm/arch-jh7110/gpio.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/arch/riscv/include/asm/arch-jh7110/gpio.h b/arch/riscv/include/asm/arch-jh7110/gpio.h
index 60e887c289..68a9bdc9ed 100644
--- a/arch/riscv/include/asm/arch-jh7110/gpio.h
+++ b/arch/riscv/include/asm/arch-jh7110/gpio.h
@@ -20,6 +20,14 @@ extern "C" {
#define GPIO_DOEN_MASK 0x3f
#define GPIO_DOUT_MASK 0x7f
#define GPIO_DIN_MASK 0x7f
+#define GPIO_DS_MASK 0x06
+#define GPIO_DS_SHIFT 1
+#define GPIO_SLEW_MASK BIT(5)
+#define GPIO_SLEW_SHIFT 5
+#define GPIO_PULL_MASK 0x18
+#define GPIO_PULL_SHIFT 3
+#define GPIO_PULL_UP 1
+#define GPIO_PULL_DOWN 2
#define NR_GPIOS 64
@@ -38,8 +46,10 @@ enum gpio_state {
#define GPIO_DOUT 0x40
#define GPIO_DIN 0x80
#define GPIO_EN 0xdc
-#define GPIO_LOW_IE 0x100
+#define GPIO_LOW_IE 0x100
#define GPIO_HIGH_IE 0x104
+#define GPIO_CONFIG 0x120
+
/* Details about a GPIO bank */
struct starfive_gpio_platdata {
@@ -61,6 +71,18 @@ struct starfive_gpio_platdata {
GPIO_DIN_MASK << GPIO_SHIFT(gpi),\
((gpio+2) & GPIO_DIN_MASK) << GPIO_SHIFT(gpi))
+#define SYS_IOMUX_SET_DS(gpio, ds) \
+ clrsetbits_le32(SYS_IOMUX_BASE + GPIO_CONFIG + gpio * 4, \
+ GPIO_DS_MASK, (ds) << GPIO_DS_SHIFT)
+
+#define SYS_IOMUX_SET_SLEW(gpio, slew) \
+ clrsetbits_le32(SYS_IOMUX_BASE + GPIO_CONFIG + gpio * 4, \
+ GPIO_SLEW_MASK, (slew) << GPIO_SLEW_SHIFT)
+
+#define SYS_IOMUX_SET_PULL(gpio, pull) \
+ clrsetbits_le32(SYS_IOMUX_BASE + GPIO_CONFIG + gpio * 4, \
+ GPIO_PULL_MASK, (pull) << GPIO_PULL_SHIFT)
+
#define SYS_IOMUX_COMPLEX(gpio, gpi, gpo, oen) do {\
SYS_IOMUX_DOEN(gpio, oen);\
SYS_IOMUX_DOUT(gpio, gpo);\