Commit 7f6ee0a5 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Linus Walleij
Browse files

pinctrl: uniphier: clean up GPIO port muxing



There are a bunch of GPIO muxing data, but most of them are actually
unneeded because GPIO-to-pin mapping can be specified by "gpio-ranges"
DT properties.

Tables that contain a set of GPIO pins are still needed for the named
mapping by "gpio-ranges-group-names".  This is a much cleaner way for
UniPhier SoC family where GPIO numbers are not straight mapped to pin
numbers.

Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent e3829d15
Loading
Loading
Loading
Loading
+18 −21
Original line number Diff line number Diff line
@@ -651,30 +651,27 @@ static int uniphier_pmx_gpio_request_enable(struct pinctrl_dev *pctldev,
					    unsigned offset)
{
	struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev);
	const struct uniphier_pinctrl_group *groups = priv->socdata->groups;
	int groups_count = priv->socdata->groups_count;
	enum uniphier_pinmux_gpio_range_type range_type;
	int i, j;
	unsigned int gpio_offset;
	int muxval, i;

	if (strstr(range->name, "irq"))
		range_type = UNIPHIER_PINMUX_GPIO_RANGE_IRQ;
	else
		range_type = UNIPHIER_PINMUX_GPIO_RANGE_PORT;
	if (range->pins) {
		for (i = 0; i < range->npins; i++)
			if (range->pins[i] == offset)
				break;

	for (i = 0; i < groups_count; i++) {
		if (groups[i].range_type != range_type)
			continue;
		if (WARN_ON(i == range->npins))
			return -EINVAL;

		for (j = 0; j < groups[i].num_pins; j++)
			if (groups[i].pins[j] == offset)
				goto found;
		gpio_offset = i;
	} else {
		gpio_offset = offset - range->pin_base;
	}

	dev_err(pctldev->dev, "pin %u does not support GPIO\n", offset);
	return -EINVAL;
	gpio_offset += range->id;

	muxval = priv->socdata->get_gpio_muxval(offset, gpio_offset);

found:
	return uniphier_pmx_set_one_mux(pctldev, offset, groups[i].muxvals[j]);
	return uniphier_pmx_set_one_mux(pctldev, offset, muxval);
}

static const struct pinmux_ops uniphier_pmxops = {
+28 −347

File changed.

Preview size limit exceeded, changes collapsed.

+22 −334

File changed.

Preview size limit exceeded, changes collapsed.

+37 −235

File changed.

Preview size limit exceeded, changes collapsed.

+18 −367

File changed.

Preview size limit exceeded, changes collapsed.

Loading