* [PATCH v2 11/29] sh-pfc: Initialize pinmux_gpio flags statically
@ 2013-01-09 0:52 Laurent Pinchart
0 siblings, 0 replies; only message in thread
From: Laurent Pinchart @ 2013-01-09 0:52 UTC (permalink / raw)
To: linux-sh
All function GPIO entries are initialized with the GPIO_FN macro that
expands to the PINMUX_GPIO macro, used to initialize real GPIOs. Create
a PINMUX_GPIO_FN macro that duplicates PINMUX_GPIO and sets flags to
PINMUX_TYPE_FUNCTION and use it in GPIO_FN, and make PINMUX_GPIO set
flags to PINMUX_TYPE_GPIO.
This removes the need to initialize GPIO flags at runtime and thus
simplifies the code, preparing for the GPIO and functions split.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/pinctrl/sh-pfc/pinctrl.c | 19 ++-----------------
drivers/pinctrl/sh-pfc/sh_pfc.h | 16 +++++++++++++---
2 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index 33ac4f7..8a13dff 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -325,22 +325,6 @@ static struct pinctrl_desc sh_pfc_pinctrl_desc = {
.confops = &sh_pfc_pinconf_ops,
};
-static void sh_pfc_map_one_gpio(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx,
- struct pinmux_gpio *gpio, unsigned offset)
-{
- struct pinmux_data_reg *dummy;
- int bit;
-
- gpio->flags &= ~PINMUX_FLAG_TYPE;
-
- if (sh_pfc_get_data_reg(pfc, offset, &dummy, &bit) = 0)
- gpio->flags |= PINMUX_TYPE_GPIO;
- else {
- gpio->flags |= PINMUX_TYPE_FUNCTION;
- pmx->nr_functions++;
- }
-}
-
/* pinmux ranges -> pinctrl pin descs */
static int sh_pfc_map_gpios(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
{
@@ -366,7 +350,8 @@ static int sh_pfc_map_gpios(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
if (unlikely(!gpio->enum_id))
continue;
- sh_pfc_map_one_gpio(pfc, pmx, gpio, i);
+ if ((gpio->flags & PINMUX_FLAG_TYPE) = PINMUX_TYPE_FUNCTION)
+ pmx->nr_functions++;
}
sh_pfc_pinctrl_desc.pins = pmx->pads;
diff --git a/drivers/pinctrl/sh-pfc/sh_pfc.h b/drivers/pinctrl/sh-pfc/sh_pfc.h
index 2627a89..e150395 100644
--- a/drivers/pinctrl/sh-pfc/sh_pfc.h
+++ b/drivers/pinctrl/sh-pfc/sh_pfc.h
@@ -41,8 +41,18 @@ struct pinmux_gpio {
const char *name;
};
-#define PINMUX_GPIO(gpio, data_or_mark) \
- [gpio] = { .name = __stringify(gpio), .enum_id = data_or_mark, .flags = PINMUX_TYPE_NONE }
+#define PINMUX_GPIO(gpio, data_or_mark) \
+ [gpio] = { \
+ .name = __stringify(gpio), \
+ .enum_id = data_or_mark, \
+ .flags = PINMUX_TYPE_GPIO \
+ }
+#define PINMUX_GPIO_FN(gpio, data_or_mark) \
+ [gpio] = { \
+ .name = __stringify(gpio), \
+ .enum_id = data_or_mark, \
+ .flags = PINMUX_TYPE_FUNCTION \
+ }
#define PINMUX_DATA(data_or_mark, ids...) data_or_mark, ids, 0
@@ -135,7 +145,7 @@ enum { GPIO_CFG_DRYRUN, GPIO_CFG_REQ, GPIO_CFG_FREE };
#define _GPIO_PORT(pfx, sfx) PINMUX_GPIO(GPIO_PORT##pfx, PORT##pfx##_DATA)
#define PORT_ALL(str) CPU_ALL_PORT(_PORT_ALL, PORT, str)
#define GPIO_PORT_ALL() CPU_ALL_PORT(_GPIO_PORT, , unused)
-#define GPIO_FN(str) PINMUX_GPIO(GPIO_FN_##str, str##_MARK)
+#define GPIO_FN(str) PINMUX_GPIO_FN(GPIO_FN_##str, str##_MARK)
/* helper macro for pinmux_enum_t */
#define PORT_DATA_I(nr) \
--
1.7.8.6
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-01-09 0:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-09 0:52 [PATCH v2 11/29] sh-pfc: Initialize pinmux_gpio flags statically Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).