summaryrefslogtreecommitdiff
path: root/drivers/gpio/imx_rgpio2p.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-05-23 09:25:39 -0400
committerTom Rini <trini@konsulko.com>2022-05-23 09:25:39 -0400
commit004d30c786056d443d40428c4b1c11e2f8f0bc32 (patch)
treea6c7d28590d20c5f88f292804bcb22ebfa36d942 /drivers/gpio/imx_rgpio2p.c
parent6f00b97d7e5760d92566317dde6c4b9224790827 (diff)
parent4d573d5c98234cad328de77c773c3c3d79258255 (diff)
Merge tag 'u-boot-imx-20220523' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
u-boot-imx-20220523 ------------------- CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/12087 Additionally to u-boot-imx20200520: - DH MX8MP - i.MX GPIO: reading GPIO when direction is output - Menlo i.MX53: switch to DM And from u-boot-imx20200520: - fix Verdin hang - add pca9450 regulator - conversion to DM_SERIAL - NAND block handling - fix crypto - enable cache on some boards - add ACC board (MX6)
Diffstat (limited to 'drivers/gpio/imx_rgpio2p.c')
-rw-r--r--drivers/gpio/imx_rgpio2p.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c
index 0e2874ca95c..175e460aff5 100644
--- a/drivers/gpio/imx_rgpio2p.c
+++ b/drivers/gpio/imx_rgpio2p.c
@@ -39,6 +39,14 @@ static int imx_rgpio2p_is_output(struct gpio_regs *regs, int offset)
return val & (1 << offset) ? 1 : 0;
}
+static int imx_rgpio2p_bank_get_direction(struct gpio_regs *regs, int offset)
+{
+ if ((readl(&regs->gpio_pddr) >> offset) & 0x01)
+ return IMX_RGPIO2P_DIRECTION_OUT;
+
+ return IMX_RGPIO2P_DIRECTION_IN;
+}
+
static void imx_rgpio2p_bank_direction(struct gpio_regs *regs, int offset,
enum imx_rgpio2p_direction direction)
{
@@ -67,7 +75,11 @@ static void imx_rgpio2p_bank_set_value(struct gpio_regs *regs, int offset,
static int imx_rgpio2p_bank_get_value(struct gpio_regs *regs, int offset)
{
- return (readl(&regs->gpio_pdir) >> offset) & 0x01;
+ if (imx_rgpio2p_bank_get_direction(regs, offset) ==
+ IMX_RGPIO2P_DIRECTION_IN)
+ return (readl(&regs->gpio_pdir) >> offset) & 0x01;
+
+ return (readl(&regs->gpio_pdor) >> offset) & 0x01;
}
static int imx_rgpio2p_direction_input(struct udevice *dev, unsigned offset)