Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69edbba0 authored by Magnus Damm's avatar Magnus Damm Committed by Paul Mundt
Browse files

sh: use gpiolib



This patch updates the SuperH gpio code to make use of gpiolib. The
gpiolib callbacks get() and set() are lockless, but we use our own
spinlock for the other operations to make sure hardware register
bitfield accesses stay atomic.

Signed-off-by: default avatarMagnus Damm <damm@igel.co.jp>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 3292094e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -126,6 +126,13 @@ config ARCH_HAS_ILOG2_U64
config ARCH_NO_VIRT_TO_BUS
	def_bool y

config ARCH_WANT_OPTIONAL_GPIOLIB
	def_bool y
	depends on !ARCH_REQUIRE_GPIOLIB

config ARCH_REQUIRE_GPIOLIB
	def_bool n

config IO_TRAPPED
	bool

+2 −2
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ config SH_SH7785LCR_29BIT_PHYSMAPS
config SH_MIGOR
	bool "Migo-R"
	depends on CPU_SUBTYPE_SH7722
	select GENERIC_GPIO
	select ARCH_REQUIRE_GPIOLIB
	help
	  Select Migo-R if configuring for the SH7722 Migo-R platform
          by Renesas System Solutions Asia Pte. Ltd.
@@ -173,7 +173,7 @@ config SH_MIGOR
config SH_AP325RXA
	bool "AP-325RXA"
	depends on CPU_SUBTYPE_SH7723
	select GENERIC_GPIO
	select ARCH_REQUIRE_GPIOLIB
	help
	  Renesas "AP-325RXA" support.
	  Compatible with ALGO SYSTEM CO.,LTD. "AP-320A"
+35 −26
Original line number Diff line number Diff line
@@ -19,6 +19,40 @@
#include <cpu/gpio.h>
#endif

#define ARCH_NR_GPIOS 512
#include <asm-generic/gpio.h>

#ifdef CONFIG_GPIOLIB

static inline int gpio_get_value(unsigned gpio)
{
	return __gpio_get_value(gpio);
}

static inline void gpio_set_value(unsigned gpio, int value)
{
	__gpio_set_value(gpio, value);
}

static inline int gpio_cansleep(unsigned gpio)
{
	return __gpio_cansleep(gpio);
}

static inline int gpio_to_irq(unsigned gpio)
{
	WARN_ON(1);
	return -ENOSYS;
}

static inline int irq_to_gpio(unsigned int irq)
{
	WARN_ON(1);
	return -EINVAL;
}

#endif /* CONFIG_GPIOLIB */

typedef unsigned short pinmux_enum_t;
typedef unsigned short pinmux_flag_t;

@@ -94,34 +128,9 @@ struct pinmux_info {
	unsigned int gpio_data_size;

	unsigned long *gpio_in_use;
	struct gpio_chip chip;
};

int register_pinmux(struct pinmux_info *pip);

int __gpio_request(unsigned gpio);
static inline int gpio_request(unsigned gpio, const char *label)
{
	return __gpio_request(gpio);
}
void gpio_free(unsigned gpio);
int gpio_direction_input(unsigned gpio);
int gpio_direction_output(unsigned gpio, int value);
int gpio_get_value(unsigned gpio);
void gpio_set_value(unsigned gpio, int value);

/* IRQ modes are unspported */
static inline int gpio_to_irq(unsigned gpio)
{
	WARN_ON(1);
	return -EINVAL;
}

static inline int irq_to_gpio(unsigned irq)
{
	WARN_ON(1);
	return -EINVAL;
}

#include <asm-generic/gpio.h>

#endif /* __ASM_SH_GPIO_H */
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
obj-$(CONFIG_STACKTRACE)	+= stacktrace.o
obj-$(CONFIG_IO_TRAPPED)	+= io_trapped.o
obj-$(CONFIG_KPROBES)		+= kprobes.o
obj-$(CONFIG_GENERIC_GPIO)	+= gpio.o
obj-$(CONFIG_ARCH_REQUIRE_GPIOLIB)	+= gpio.o
obj-$(CONFIG_DYNAMIC_FTRACE)	+= ftrace.o
obj-$(CONFIG_DUMP_CODE)		+= disassemble.o

+1 −1
Original line number Diff line number Diff line
@@ -15,6 +15,6 @@ obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
obj-$(CONFIG_CRASH_DUMP)	+= crash_dump.o
obj-$(CONFIG_STACKTRACE)	+= stacktrace.o
obj-$(CONFIG_IO_TRAPPED)	+= io_trapped.o
obj-$(CONFIG_GENERIC_GPIO)	+= gpio.o
obj-$(CONFIG_ARCH_REQUIRE_GPIOLIB)	+= gpio.o

EXTRA_CFLAGS += -Werror
Loading