Browse Source

GPIO:Starfive-jh7110: Add macro definition

Add macro definition of GPIO

Signed-off-by: yanhong.wang <yanhong.wang@starfivetech.com>
yanhong.wang 2 years ago
parent
commit
cafd9e471a
1 changed files with 21 additions and 0 deletions
  1. 21 0
      arch/riscv/include/asm/arch-jh7110/gpio.h

+ 21 - 0
arch/riscv/include/asm/arch-jh7110/gpio.h

@@ -46,6 +46,27 @@ struct starfive_gpio_platdata {
 	void		*base;
 };
 
+#define SYS_IOMUX_DOEN(gpio, oen) \
+	clrsetbits_le32(SYS_IOMUX_BASE+GPIO_OFFSET(gpio), \
+		GPIO_DOEN_MASK <<  GPIO_SHIFT(gpio), \
+		(oen) << GPIO_SHIFT(gpio))
+
+#define SYS_IOMUX_DOUT(gpio, gpo) \
+	clrsetbits_le32(SYS_IOMUX_BASE + GPIO_DOUT + GPIO_OFFSET(gpio),\
+		GPIO_DOUT_MASK << GPIO_SHIFT(gpio),\
+		((gpo) & GPIO_DOUT_MASK) << GPIO_SHIFT(gpio))
+
+#define SYS_IOMUX_DIN(gpio, gpi)\
+	clrsetbits_le32(SYS_IOMUX_BASE + GPIO_DIN + GPIO_OFFSET(gpi),\
+		GPIO_DIN_MASK << GPIO_SHIFT(gpi),\
+		((gpio+2) & GPIO_DIN_MASK) << GPIO_SHIFT(gpi))
+
+#define SYS_IOMUX_COMPLEX(gpio, gpi, gpo, oen) do {\
+		SYS_IOMUX_DOEN(gpio, oen);\
+		SYS_IOMUX_DOUT(gpio, gpo);\
+		SYS_IOMUX_DIN(gpio, gpi); \
+	} while (0)
+
 #ifdef __cplusplus
 }
 #endif