* [PATCH 1/3] ARM: PXA: use generic gpio prototypes
@ 2015-08-06 11:23 Sascha Hauer
2015-08-06 11:23 ` [PATCH 2/3] gpio: Drop asm-generic/gpio.h Sascha Hauer
2015-08-06 11:23 ` [PATCH 3/3] ARM: boards: include gpio.h instead of mach/gpio.h Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2015-08-06 11:23 UTC (permalink / raw)
To: Barebox List
PXA is the only architecture that uses its own prototypes for
the gpio functions because it uses static inline variants of
these functions. For the sake of streamlining with other architectures
move them to a C file and use the generic gpio prototypes.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-pxa/gpio.c | 32 ++++++++++++++++++++++++++++++++
arch/arm/mach-pxa/include/mach/gpio.h | 1 +
arch/arm/mach-pxa/include/plat/gpio.h | 32 --------------------------------
3 files changed, 33 insertions(+), 32 deletions(-)
diff --git a/arch/arm/mach-pxa/gpio.c b/arch/arm/mach-pxa/gpio.c
index 4e98493..7dd6ac0 100644
--- a/arch/arm/mach-pxa/gpio.c
+++ b/arch/arm/mach-pxa/gpio.c
@@ -66,3 +66,35 @@ int __init pxa_init_gpio(int start, int end)
return 0;
}
+
+int gpio_get_value(unsigned gpio)
+{
+ return GPLR(gpio) & GPIO_bit(gpio);
+}
+
+void gpio_set_value(unsigned gpio, int value)
+{
+ if (value)
+ GPSR(gpio) = GPIO_bit(gpio);
+ else
+ GPCR(gpio) = GPIO_bit(gpio);
+}
+
+int gpio_direction_input(unsigned gpio)
+{
+ if (__gpio_is_inverted(gpio))
+ GPDR(gpio) |= GPIO_bit(gpio);
+ else
+ GPDR(gpio) &= ~GPIO_bit(gpio);
+ return 0;
+}
+
+int gpio_direction_output(unsigned gpio, int value)
+{
+ gpio_set_value(gpio, value);
+ if (__gpio_is_inverted(gpio))
+ GPDR(gpio) &= ~GPIO_bit(gpio);
+ else
+ GPDR(gpio) |= GPIO_bit(gpio);
+ return 0;
+}
diff --git a/arch/arm/mach-pxa/include/mach/gpio.h b/arch/arm/mach-pxa/include/mach/gpio.h
index e6724e1..950bb1a 100644
--- a/arch/arm/mach-pxa/include/mach/gpio.h
+++ b/arch/arm/mach-pxa/include/mach/gpio.h
@@ -20,6 +20,7 @@
#ifndef __ASM_ARCH_PXA_GPIO_H
#define __ASM_ARCH_PXA_GPIO_H
+#include <asm-generic/gpio.h>
#include <mach/hardware.h>
#define GPIO_REGS_VIRT (0x40E00000)
diff --git a/arch/arm/mach-pxa/include/plat/gpio.h b/arch/arm/mach-pxa/include/plat/gpio.h
index 4c7b526..35f9071 100644
--- a/arch/arm/mach-pxa/include/plat/gpio.h
+++ b/arch/arm/mach-pxa/include/plat/gpio.h
@@ -31,38 +31,6 @@
#define GFER_OFFSET 0x3C
#define GEDR_OFFSET 0x48
-static inline int gpio_get_value(unsigned gpio)
-{
- return GPLR(gpio) & GPIO_bit(gpio);
-}
-
-static inline void gpio_set_value(unsigned gpio, int value)
-{
- if (value)
- GPSR(gpio) = GPIO_bit(gpio);
- else
- GPCR(gpio) = GPIO_bit(gpio);
-}
-
-static inline int gpio_direction_input(unsigned gpio)
-{
- if (__gpio_is_inverted(gpio))
- GPDR(gpio) |= GPIO_bit(gpio);
- else
- GPDR(gpio) &= ~GPIO_bit(gpio);
- return 0;
-}
-
-static inline int gpio_direction_output(unsigned gpio, int value)
-{
- gpio_set_value(gpio, value);
- if (__gpio_is_inverted(gpio))
- GPDR(gpio) &= ~GPIO_bit(gpio);
- else
- GPDR(gpio) |= GPIO_bit(gpio);
- return 0;
-}
-
/* NOTE: some PXAs have fewer on-chip GPIOs (like PXA255, with 85).
* Those cases currently cause holes in the GPIO number space, the
* actual number of the last GPIO is recorded by 'pxa_last_gpio'.
--
2.4.6
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/3] gpio: Drop asm-generic/gpio.h
2015-08-06 11:23 [PATCH 1/3] ARM: PXA: use generic gpio prototypes Sascha Hauer
@ 2015-08-06 11:23 ` Sascha Hauer
2015-08-06 11:23 ` [PATCH 3/3] ARM: boards: include gpio.h instead of mach/gpio.h Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2015-08-06 11:23 UTC (permalink / raw)
To: Barebox List
Since we no longer have custom gpio function prototypes we can
drop the prototypes from asm-generic/gpio.h can add them to
include/gpio.h instead. While at it add static inline dummy wrappers
for !CONFIG_GENERIC_GPIO so that code using gpios can compile without
gpio support.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/include/asm/gpio.h | 10 ----------
arch/arm/mach-at91/include/mach/gpio.h | 2 --
arch/arm/mach-ep93xx/include/mach/gpio.h | 1 -
arch/arm/mach-mxs/include/mach/gpio.h | 21 ---------------------
arch/arm/mach-pxa/include/mach/gpio.h | 1 -
arch/arm/mach-samsung/include/mach/gpio.h | 18 ------------------
arch/mips/include/asm/gpio.h | 6 ------
arch/ppc/mach-mpc85xx/include/mach/gpio.h | 2 --
include/asm-generic/gpio.h | 9 ---------
include/gpio.h | 24 +++++++++++++++++++++++-
10 files changed, 23 insertions(+), 71 deletions(-)
delete mode 100644 arch/arm/include/asm/gpio.h
delete mode 100644 arch/arm/mach-ep93xx/include/mach/gpio.h
delete mode 100644 arch/arm/mach-mxs/include/mach/gpio.h
delete mode 100644 arch/arm/mach-samsung/include/mach/gpio.h
delete mode 100644 arch/mips/include/asm/gpio.h
delete mode 100644 include/asm-generic/gpio.h
diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h
deleted file mode 100644
index b3c1efe..0000000
--- a/arch/arm/include/asm/gpio.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _ARCH_ARM_GPIO_H
-#define _ARCH_ARM_GPIO_H
-
-#ifndef CONFIG_GPIOLIB
-#include <mach/gpio.h>
-#else
-#include <asm-generic/gpio.h>
-#endif
-
-#endif /* _ARCH_ARM_GPIO_H */
diff --git a/arch/arm/mach-at91/include/mach/gpio.h b/arch/arm/mach-at91/include/mach/gpio.h
index 4e9d686..bdc0cb6 100644
--- a/arch/arm/mach-at91/include/mach/gpio.h
+++ b/arch/arm/mach-at91/include/mach/gpio.h
@@ -7,8 +7,6 @@
#ifndef __AT91_GPIO_H__
#define __AT91_GPIO_H__
-#include <asm-generic/gpio.h>
-
#define MAX_NB_GPIO_PER_BANK 32
static inline unsigned pin_to_bank(unsigned pin)
diff --git a/arch/arm/mach-ep93xx/include/mach/gpio.h b/arch/arm/mach-ep93xx/include/mach/gpio.h
deleted file mode 100644
index 306ab4c..0000000
--- a/arch/arm/mach-ep93xx/include/mach/gpio.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/gpio.h>
diff --git a/arch/arm/mach-mxs/include/mach/gpio.h b/arch/arm/mach-mxs/include/mach/gpio.h
deleted file mode 100644
index 8643c98..0000000
--- a/arch/arm/mach-mxs/include/mach/gpio.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * (C) Copyright 2010 Juergen Beisert - Pengutronix
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#ifndef __ASM_MACH_GPIO_H
-#define __ASM_MACH_GPIO_H
-
-#include <asm-generic/gpio.h>
-
-#endif /* __ASM_MACH_GPIO_H */
diff --git a/arch/arm/mach-pxa/include/mach/gpio.h b/arch/arm/mach-pxa/include/mach/gpio.h
index 950bb1a..e6724e1 100644
--- a/arch/arm/mach-pxa/include/mach/gpio.h
+++ b/arch/arm/mach-pxa/include/mach/gpio.h
@@ -20,7 +20,6 @@
#ifndef __ASM_ARCH_PXA_GPIO_H
#define __ASM_ARCH_PXA_GPIO_H
-#include <asm-generic/gpio.h>
#include <mach/hardware.h>
#define GPIO_REGS_VIRT (0x40E00000)
diff --git a/arch/arm/mach-samsung/include/mach/gpio.h b/arch/arm/mach-samsung/include/mach/gpio.h
deleted file mode 100644
index 3920667..0000000
--- a/arch/arm/mach-samsung/include/mach/gpio.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#ifndef __ASM_MACH_GPIO_H
-#define __ASM_MACH_GPIO_H
-
-#include <asm-generic/gpio.h>
-
-#endif /* __ASM_MACH_GPIO_H */
diff --git a/arch/mips/include/asm/gpio.h b/arch/mips/include/asm/gpio.h
deleted file mode 100644
index 41a9589..0000000
--- a/arch/mips/include/asm/gpio.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ARCH_MIPS_GPIO_H
-#define _ARCH_MIPS_GPIO_H
-
-#include <asm-generic/gpio.h>
-
-#endif /* _ARCH_MIPS_GPIO_H */
diff --git a/arch/ppc/mach-mpc85xx/include/mach/gpio.h b/arch/ppc/mach-mpc85xx/include/mach/gpio.h
index 61f6349..b41ecc5 100644
--- a/arch/ppc/mach-mpc85xx/include/mach/gpio.h
+++ b/arch/ppc/mach-mpc85xx/include/mach/gpio.h
@@ -10,8 +10,6 @@
#ifndef _MACH_PPC_GPIO_H
#define _MACH_PPC_GPIO_H
-#include <asm-generic/gpio.h>
-
extern void fsl_enable_gpiout(void);
#endif /* _MACH_PPC_GPIO_H */
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
deleted file mode 100644
index 7674970..0000000
--- a/include/asm-generic/gpio.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __ASM_GENERIC_GPIO_H
-#define __ASM_GENERIC_GPIO_H
-
-void gpio_set_value(unsigned gpio, int value);
-int gpio_get_value(unsigned gpio);
-int gpio_direction_output(unsigned gpio, int value);
-int gpio_direction_input(unsigned gpio);
-
-#endif /* __ASM_GENERIC_GPIO_H */
diff --git a/include/gpio.h b/include/gpio.h
index f116ea6..2fb320e 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -1,7 +1,29 @@
#ifndef __GPIO_H
#define __GPIO_H
-#include <asm/gpio.h>
+#ifdef CONFIG_GENERIC_GPIO
+void gpio_set_value(unsigned gpio, int value);
+int gpio_get_value(unsigned gpio);
+int gpio_direction_output(unsigned gpio, int value);
+int gpio_direction_input(unsigned gpio);
+#else
+static inline void gpio_set_value(unsigned gpio, int value)
+{
+}
+static inline int gpio_get_value(unsigned gpio)
+{
+ return 0;
+}
+static inline int gpio_direction_output(unsigned gpio, int value);
+{
+ return -EINVAL;
+}
+
+static inline int gpio_direction_input(unsigned gpio)
+{
+ return -EINVAL;
+}
+#endif
#define ARCH_NR_GPIOS 256
--
2.4.6
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 3/3] ARM: boards: include gpio.h instead of mach/gpio.h
2015-08-06 11:23 [PATCH 1/3] ARM: PXA: use generic gpio prototypes Sascha Hauer
2015-08-06 11:23 ` [PATCH 2/3] gpio: Drop asm-generic/gpio.h Sascha Hauer
@ 2015-08-06 11:23 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2015-08-06 11:23 UTC (permalink / raw)
To: Barebox List
For getting the gpio functions include/gpio.h is the correct
header file.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/boards/phytec-phycore-pxa270/board.c | 2 +-
arch/arm/mach-samsung/gpio-s3c24x0.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boards/phytec-phycore-pxa270/board.c b/arch/arm/boards/phytec-phycore-pxa270/board.c
index 833c4c8..1424c9c 100644
--- a/arch/arm/boards/phytec-phycore-pxa270/board.c
+++ b/arch/arm/boards/phytec-phycore-pxa270/board.c
@@ -26,7 +26,7 @@
#include <partition.h>
#include <linux/sizes.h>
-#include <plat/gpio.h>
+#include <gpio.h>
#include <mach/mfp-pxa27x.h>
#include <mach/pxa-regs.h>
#include <mach/pxafb.h>
diff --git a/arch/arm/mach-samsung/gpio-s3c24x0.c b/arch/arm/mach-samsung/gpio-s3c24x0.c
index f62588f..58ca284 100644
--- a/arch/arm/mach-samsung/gpio-s3c24x0.c
+++ b/arch/arm/mach-samsung/gpio-s3c24x0.c
@@ -15,7 +15,7 @@
#include <errno.h>
#include <io.h>
#include <mach/s3c-iomap.h>
-#include <mach/gpio.h>
+#include <gpio.h>
#include <mach/s3c24xx-gpio.h>
#include <mach/iomux.h>
--
2.4.6
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-06 11:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-06 11:23 [PATCH 1/3] ARM: PXA: use generic gpio prototypes Sascha Hauer
2015-08-06 11:23 ` [PATCH 2/3] gpio: Drop asm-generic/gpio.h Sascha Hauer
2015-08-06 11:23 ` [PATCH 3/3] ARM: boards: include gpio.h instead of mach/gpio.h Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox