diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2013-02-14 19:33:38 -0500 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2013-03-15 08:33:39 -0400 |
commit | 63d573835f835aab4c44d0e0342cf5976fb14b35 (patch) | |
tree | d5998a6c0cb914d85c246b0464b2b7e7db959d2a /drivers/pinctrl/sh-pfc/core.c | |
parent | 247127f90ba1fcc234008e00e937537a89eef9ca (diff) |
sh-pfc: Add support for sparse pin numbers
The PFC driver assumes that the value of the GPIO_PORTxxx enumeration
names are equal to the port number. This isn't true when the port number
space is sparse, as with the SH73A0.
Fix the issue by adding support for pin numbers ranges specified through
SoC data. When no range is specified the driver considers that the PFC
implements a single contiguous range for all pins.
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 | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c index 667db99fb510..798248261f30 100644 --- a/drivers/pinctrl/sh-pfc/core.c +++ b/drivers/pinctrl/sh-pfc/core.c | |||
@@ -80,7 +80,24 @@ static void __iomem *sh_pfc_phys_to_virt(struct sh_pfc *pfc, | |||
80 | 80 | ||
81 | struct sh_pfc_pin *sh_pfc_get_pin(struct sh_pfc *pfc, unsigned int pin) | 81 | struct sh_pfc_pin *sh_pfc_get_pin(struct sh_pfc *pfc, unsigned int pin) |
82 | { | 82 | { |
83 | return &pfc->info->pins[pin]; | 83 | unsigned int offset; |
84 | unsigned int i; | ||
85 | |||
86 | if (pfc->info->ranges == NULL) | ||
87 | return &pfc->info->pins[pin]; | ||
88 | |||
89 | for (i = 0, offset = 0; i < pfc->info->nr_ranges; ++i) { | ||
90 | const struct pinmux_range *range = &pfc->info->ranges[i]; | ||
91 | |||
92 | if (pin <= range->end) | ||
93 | return pin >= range->begin | ||
94 | ? &pfc->info->pins[offset + pin - range->begin] | ||
95 | : NULL; | ||
96 | |||
97 | offset += range->end - range->begin + 1; | ||
98 | } | ||
99 | |||
100 | return NULL; | ||
84 | } | 101 | } |
85 | 102 | ||
86 | static int sh_pfc_enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r) | 103 | static int sh_pfc_enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r) |