diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2012-11-29 07:24:07 -0500 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2013-03-15 08:33:38 -0400 |
commit | a373ed0aa229f06e7d699797669b664ef39d97c1 (patch) | |
tree | 0fe20a0492d3bd6953fc706eaa97bc28d7e14ff9 /drivers/pinctrl/sh-pfc/core.c | |
parent | 24d6b36e91b0503cd1c88b34fa793c0c65fa767d (diff) |
sh-pfc: Split pins and functions definition tables
Split the GPIOs table into a pins table for real GPIOs and a functions
table for function GPIOs.
Only register pins with the pinctrl core. The function GPIOs remain
accessible as GPIOs.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/sh-pfc/core.c')
-rw-r--r-- | drivers/pinctrl/sh-pfc/core.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c index bed2d23e2464..9dee3b911283 100644 --- a/drivers/pinctrl/sh-pfc/core.c +++ b/drivers/pinctrl/sh-pfc/core.c | |||
@@ -92,13 +92,14 @@ static int sh_pfc_enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r) | |||
92 | static bool sh_pfc_gpio_is_pin(struct sh_pfc *pfc, unsigned int gpio) | 92 | static bool sh_pfc_gpio_is_pin(struct sh_pfc *pfc, unsigned int gpio) |
93 | { | 93 | { |
94 | return (gpio < pfc->info->nr_pins) && | 94 | return (gpio < pfc->info->nr_pins) && |
95 | (pfc->info->gpios[gpio].enum_id != 0); | 95 | (pfc->info->pins[gpio].enum_id != 0); |
96 | } | 96 | } |
97 | 97 | ||
98 | bool sh_pfc_gpio_is_function(struct sh_pfc *pfc, unsigned int gpio) | 98 | bool sh_pfc_gpio_is_function(struct sh_pfc *pfc, unsigned int gpio) |
99 | { | 99 | { |
100 | return (gpio >= pfc->info->nr_pins) && (gpio < pfc->info->nr_gpios) && | 100 | return (gpio >= pfc->info->nr_pins) && |
101 | (pfc->info->gpios[gpio].enum_id != 0); | 101 | (gpio < pfc->info->nr_pins + pfc->info->nr_func_gpios) && |
102 | (pfc->info->func_gpios[gpio - pfc->info->nr_pins].enum_id != 0); | ||
102 | } | 103 | } |
103 | 104 | ||
104 | static unsigned long sh_pfc_read_raw_reg(void __iomem *mapped_reg, | 105 | static unsigned long sh_pfc_read_raw_reg(void __iomem *mapped_reg, |
@@ -234,7 +235,7 @@ static void sh_pfc_write_config_reg(struct sh_pfc *pfc, | |||
234 | 235 | ||
235 | static int sh_pfc_setup_data_reg(struct sh_pfc *pfc, unsigned gpio) | 236 | static int sh_pfc_setup_data_reg(struct sh_pfc *pfc, unsigned gpio) |
236 | { | 237 | { |
237 | struct pinmux_gpio *gpiop = &pfc->info->gpios[gpio]; | 238 | struct pinmux_pin *gpiop = &pfc->info->pins[gpio]; |
238 | struct pinmux_data_reg *data_reg; | 239 | struct pinmux_data_reg *data_reg; |
239 | int k, n; | 240 | int k, n; |
240 | 241 | ||
@@ -291,7 +292,7 @@ static void sh_pfc_setup_data_regs(struct sh_pfc *pfc) | |||
291 | int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio, | 292 | int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio, |
292 | struct pinmux_data_reg **drp, int *bitp) | 293 | struct pinmux_data_reg **drp, int *bitp) |
293 | { | 294 | { |
294 | struct pinmux_gpio *gpiop = &pfc->info->gpios[gpio]; | 295 | struct pinmux_pin *gpiop = &pfc->info->pins[gpio]; |
295 | int k, n; | 296 | int k, n; |
296 | 297 | ||
297 | if (!sh_pfc_gpio_is_pin(pfc, gpio)) | 298 | if (!sh_pfc_gpio_is_pin(pfc, gpio)) |
@@ -352,12 +353,16 @@ static int sh_pfc_get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id, | |||
352 | int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos, | 353 | int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos, |
353 | pinmux_enum_t *enum_idp) | 354 | pinmux_enum_t *enum_idp) |
354 | { | 355 | { |
355 | pinmux_enum_t enum_id = pfc->info->gpios[gpio].enum_id; | ||
356 | pinmux_enum_t *data = pfc->info->gpio_data; | 356 | pinmux_enum_t *data = pfc->info->gpio_data; |
357 | pinmux_enum_t enum_id; | ||
357 | int k; | 358 | int k; |
358 | 359 | ||
359 | if (!sh_pfc_gpio_is_pin(pfc, gpio) && | 360 | if (sh_pfc_gpio_is_pin(pfc, gpio)) { |
360 | !sh_pfc_gpio_is_function(pfc, gpio)) { | 361 | enum_id = pfc->info->pins[gpio].enum_id; |
362 | } else if (sh_pfc_gpio_is_function(pfc, gpio)) { | ||
363 | unsigned int offset = gpio - pfc->info->nr_pins; | ||
364 | enum_id = pfc->info->func_gpios[offset].enum_id; | ||
365 | } else { | ||
361 | pr_err("non data/mark enum_id for gpio %d\n", gpio); | 366 | pr_err("non data/mark enum_id for gpio %d\n", gpio); |
362 | return -1; | 367 | return -1; |
363 | } | 368 | } |