diff mbox

[U-Boot,1/6] sunxi: Add sunxi_gpio_get_val function

Message ID 1412348759-4599-2-git-send-email-hdegoede@redhat.com
State Superseded
Delegated to: Ian Campbell
Headers show

Commit Message

Hans de Goede Oct. 3, 2014, 3:05 p.m. UTC
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(+)

Comments

Ian Campbell Oct. 4, 2014, 8:14 a.m. UTC | #1
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.
Hans de Goede Oct. 5, 2014, 2:42 p.m. UTC | #2
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 mbox

Patch

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)