* [PATCH 1/2] pinctrl: ocelot: fix gpio direction for pins after 31 @ 2019-06-20 18:30 Alexandre Belloni 2019-06-20 18:30 ` [PATCH 2/2] pinctrl: ocelot: fix pinmuxing " Alexandre Belloni 2019-06-25 13:41 ` [PATCH 1/2] pinctrl: ocelot: fix gpio direction " Linus Walleij 0 siblings, 2 replies; 4+ messages in thread From: Alexandre Belloni @ 2019-06-20 18:30 UTC (permalink / raw) To: Linus Walleij; +Cc: linux-gpio, linux-kernel, Alexandre Belloni The third argument passed to REG is not the correct one and ocelot_gpio_set_direction is not working for pins after 31. Fix that by passing the pin number instead of the modulo 32 value. Fixes: da801ab56ad8 pinctrl: ocelot: add MSCC Jaguar2 support Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> --- drivers/pinctrl/pinctrl-ocelot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c index 3b4ca52d2456..d2478db975bd 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -432,7 +432,7 @@ static int ocelot_gpio_set_direction(struct pinctrl_dev *pctldev, struct ocelot_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); unsigned int p = pin % 32; - regmap_update_bits(info->map, REG(OCELOT_GPIO_OE, info, p), BIT(p), + regmap_update_bits(info->map, REG(OCELOT_GPIO_OE, info, pin), BIT(p), input ? 0 : BIT(p)); return 0; -- 2.21.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] pinctrl: ocelot: fix pinmuxing for pins after 31 2019-06-20 18:30 [PATCH 1/2] pinctrl: ocelot: fix gpio direction for pins after 31 Alexandre Belloni @ 2019-06-20 18:30 ` Alexandre Belloni 2019-06-25 13:43 ` Linus Walleij 2019-06-25 13:41 ` [PATCH 1/2] pinctrl: ocelot: fix gpio direction " Linus Walleij 1 sibling, 1 reply; 4+ messages in thread From: Alexandre Belloni @ 2019-06-20 18:30 UTC (permalink / raw) To: Linus Walleij; +Cc: linux-gpio, linux-kernel, Alexandre Belloni The actual layout for OCELOT_GPIO_ALT[01] when there are more than 32 pins is interleaved, i.e. OCELOT_GPIO_ALT0[0], OCELOT_GPIO_ALT1[0], OCELOT_GPIO_ALT0[1], OCELOT_GPIO_ALT1[1]. Introduce a new REG_ALT macro to facilitate the register offset calculation and use it where necessary. Fixes: da801ab56ad8 pinctrl: ocelot: add MSCC Jaguar2 support Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> --- drivers/pinctrl/pinctrl-ocelot.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c index d2478db975bd..fb76fb2e9ea5 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -396,7 +396,7 @@ static int ocelot_pin_function_idx(struct ocelot_pinctrl *info, return -1; } -#define REG(r, info, p) ((r) * (info)->stride + (4 * ((p) / 32))) +#define REG_ALT(msb, info, p) (OCELOT_GPIO_ALT0 * (info)->stride + 4 * ((msb) + ((info)->stride * ((p) / 32)))) static int ocelot_pinmux_set_mux(struct pinctrl_dev *pctldev, unsigned int selector, unsigned int group) @@ -412,19 +412,21 @@ static int ocelot_pinmux_set_mux(struct pinctrl_dev *pctldev, /* * f is encoded on two bits. - * bit 0 of f goes in BIT(pin) of ALT0, bit 1 of f goes in BIT(pin) of - * ALT1 + * bit 0 of f goes in BIT(pin) of ALT[0], bit 1 of f goes in BIT(pin) of + * ALT[1] * This is racy because both registers can't be updated at the same time * but it doesn't matter much for now. */ - regmap_update_bits(info->map, REG(OCELOT_GPIO_ALT0, info, pin->pin), + regmap_update_bits(info->map, REG_ALT(0, info, pin->pin), BIT(p), f << p); - regmap_update_bits(info->map, REG(OCELOT_GPIO_ALT1, info, pin->pin), + regmap_update_bits(info->map, REG_ALT(1, info, pin->pin), BIT(p), f << (p - 1)); return 0; } +#define REG(r, info, p) ((r) * (info)->stride + (4 * ((p) / 32))) + static int ocelot_gpio_set_direction(struct pinctrl_dev *pctldev, struct pinctrl_gpio_range *range, unsigned int pin, bool input) @@ -445,9 +447,9 @@ static int ocelot_gpio_request_enable(struct pinctrl_dev *pctldev, struct ocelot_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); unsigned int p = offset % 32; - regmap_update_bits(info->map, REG(OCELOT_GPIO_ALT0, info, offset), + regmap_update_bits(info->map, REG_ALT(0, info, offset), BIT(p), 0); - regmap_update_bits(info->map, REG(OCELOT_GPIO_ALT1, info, offset), + regmap_update_bits(info->map, REG_ALT(1, info, offset), BIT(p), 0); return 0; -- 2.21.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] pinctrl: ocelot: fix pinmuxing for pins after 31 2019-06-20 18:30 ` [PATCH 2/2] pinctrl: ocelot: fix pinmuxing " Alexandre Belloni @ 2019-06-25 13:43 ` Linus Walleij 0 siblings, 0 replies; 4+ messages in thread From: Linus Walleij @ 2019-06-25 13:43 UTC (permalink / raw) To: Alexandre Belloni; +Cc: open list:GPIO SUBSYSTEM, linux-kernel@vger.kernel.org On Thu, Jun 20, 2019 at 8:30 PM Alexandre Belloni <alexandre.belloni@bootlin.com> wrote: > The actual layout for OCELOT_GPIO_ALT[01] when there are more than 32 pins > is interleaved, i.e. OCELOT_GPIO_ALT0[0], OCELOT_GPIO_ALT1[0], > OCELOT_GPIO_ALT0[1], OCELOT_GPIO_ALT1[1]. Introduce a new REG_ALT macro to > facilitate the register offset calculation and use it where necessary. > > Fixes: da801ab56ad8 pinctrl: ocelot: add MSCC Jaguar2 support > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Patch applied for fixes. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] pinctrl: ocelot: fix gpio direction for pins after 31 2019-06-20 18:30 [PATCH 1/2] pinctrl: ocelot: fix gpio direction for pins after 31 Alexandre Belloni 2019-06-20 18:30 ` [PATCH 2/2] pinctrl: ocelot: fix pinmuxing " Alexandre Belloni @ 2019-06-25 13:41 ` Linus Walleij 1 sibling, 0 replies; 4+ messages in thread From: Linus Walleij @ 2019-06-25 13:41 UTC (permalink / raw) To: Alexandre Belloni; +Cc: open list:GPIO SUBSYSTEM, linux-kernel@vger.kernel.org On Thu, Jun 20, 2019 at 8:30 PM Alexandre Belloni <alexandre.belloni@bootlin.com> wrote: > The third argument passed to REG is not the correct one and > ocelot_gpio_set_direction is not working for pins after 31. Fix that by > passing the pin number instead of the modulo 32 value. > > Fixes: da801ab56ad8 pinctrl: ocelot: add MSCC Jaguar2 support > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Patch applied. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-25 13:43 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-06-20 18:30 [PATCH 1/2] pinctrl: ocelot: fix gpio direction for pins after 31 Alexandre Belloni 2019-06-20 18:30 ` [PATCH 2/2] pinctrl: ocelot: fix pinmuxing " Alexandre Belloni 2019-06-25 13:43 ` Linus Walleij 2019-06-25 13:41 ` [PATCH 1/2] pinctrl: ocelot: fix gpio direction " Linus Walleij
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).