Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45dcb54f authored by David Lechner's avatar David Lechner Committed by Linus Walleij
Browse files

pinctrl: pinctrl-single: Fix pcs_request_gpio() when bits_per_mux != 0



This fixes pcs_request_gpio() in the pinctrl-single driver when
bits_per_mux != 0. It appears this was overlooked when the multiple
pins per register feature was added.

Fixes: 4e7e8017 ("pinctrl: pinctrl-single: enhance to configure multiple pins of different modules")
Signed-off-by: default avatarDavid Lechner <david@lechnology.com>
Acked-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 864670d5
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -391,9 +391,25 @@ static int pcs_request_gpio(struct pinctrl_dev *pctldev,
			|| pin < frange->offset)
			continue;
		mux_bytes = pcs->width / BITS_PER_BYTE;
		data = pcs->read(pcs->base + pin * mux_bytes) & ~pcs->fmask;

		if (pcs->bits_per_mux) {
			int byte_num, offset, pin_shift;

			byte_num = (pcs->bits_per_pin * pin) / BITS_PER_BYTE;
			offset = (byte_num / mux_bytes) * mux_bytes;
			pin_shift = pin % (pcs->width / pcs->bits_per_pin) *
				    pcs->bits_per_pin;

			data = pcs->read(pcs->base + offset);
			data &= ~(pcs->fmask << pin_shift);
			data |= frange->gpiofunc << pin_shift;
			pcs->write(data, pcs->base + offset);
		} else {
			data = pcs->read(pcs->base + pin * mux_bytes);
			data &= ~pcs->fmask;
			data |= frange->gpiofunc;
			pcs->write(data, pcs->base + pin * mux_bytes);
		}
		break;
	}
	return 0;