Message ID | 1412348759-4599-2-git-send-email-hdegoede@redhat.com |
---|---|
State | Superseded |
Delegated to: | Ian Campbell |
Headers | show |
On Fri, 2014-10-03 at 17:05 +0200, Hans de Goede wrote:
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/gpio/sunxi_gpio.c already has sunxi_gpio_input exported via the
standard gpio_get_value name.
Ian.
Hi Ian, Thanks for the reviews! On 10/04/2014 10:14 AM, Ian Campbell wrote: > On Fri, 2014-10-03 at 17:05 +0200, Hans de Goede wrote: >> Signed-off-by: Hans de Goede <hdegoede@redhat.com> > > drivers/gpio/sunxi_gpio.c already has sunxi_gpio_input exported via the > standard gpio_get_value name. Oops, I actually already checked if we did not have such a function, as I thought that we should have one, but I could not find it. Ah well. I'll drop this from the v2 of the series. Regards, Hans
diff --git a/arch/arm/cpu/armv7/sunxi/pinmux.c b/arch/arm/cpu/armv7/sunxi/pinmux.c index 1f2843f..a3e5bfc 100644 --- a/arch/arm/cpu/armv7/sunxi/pinmux.c +++ b/arch/arm/cpu/armv7/sunxi/pinmux.c @@ -59,3 +59,16 @@ int sunxi_gpio_set_pull(u32 pin, u32 val) return 0; } + +int sunxi_gpio_get_val(u32 pin) +{ + u32 dat; + u32 bank = GPIO_BANK(pin); + u32 offset = GPIO_NUM(pin); + struct sunxi_gpio *pio = BANK_TO_GPIO(bank); + + dat = readl(&pio->dat); + dat >>= offset; + + return dat & 0x1; +} diff --git a/arch/arm/include/asm/arch-sunxi/gpio.h b/arch/arm/include/asm/arch-sunxi/gpio.h index f7f3d8c..c049d39 100644 --- a/arch/arm/include/asm/arch-sunxi/gpio.h +++ b/arch/arm/include/asm/arch-sunxi/gpio.h @@ -143,6 +143,7 @@ int sunxi_gpio_set_cfgpin(u32 pin, u32 val); int sunxi_gpio_get_cfgpin(u32 pin); int sunxi_gpio_set_drv(u32 pin, u32 val); int sunxi_gpio_set_pull(u32 pin, u32 val); +int sunxi_gpio_get_val(u32 pin); int sunxi_name_to_gpio(const char *name); #define name_to_gpio(name) sunxi_name_to_gpio(name)
Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- arch/arm/cpu/armv7/sunxi/pinmux.c | 13 +++++++++++++ arch/arm/include/asm/arch-sunxi/gpio.h | 1 + 2 files changed, 14 insertions(+)