mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
UPSTREAM: pinctrl: rockchip: split out verification of mux settings
We need to avoid calling regmap functions from irq handlers, so the next
commit is going to move the call to rockchip_set_mux() into an
irq_bus_sync_unlock handler. But we can't return an error from there so
we still need to check the settings from rockchip_irq_set_type() and we
will use this new rockchip_verify_mux() function from there.
Signed-off-by: John Keeping <john@metanate.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David Wu <david.wu@rock-chips.com>
(cherry picked from git.kernel.org thierry.reding/linux-pwm.git for-next
commit 05709c3e88)
Signed-off-by: David Wu <david.wu@rock-chips.com>
Change-Id: I421f9c2faf835ca821c574602d6b4a66cdde9769
This commit is contained in:
@@ -694,6 +694,31 @@ static int rockchip_get_mux(struct rockchip_pin_bank *bank, int pin)
|
||||
return ((val >> bit) & mask);
|
||||
}
|
||||
|
||||
static int rockchip_verify_mux(struct rockchip_pin_bank *bank,
|
||||
int pin, int mux)
|
||||
{
|
||||
struct rockchip_pinctrl *info = bank->drvdata;
|
||||
int iomux_num = (pin / 8);
|
||||
|
||||
if (iomux_num > 3)
|
||||
return -EINVAL;
|
||||
|
||||
if (bank->iomux[iomux_num].type & IOMUX_UNROUTED) {
|
||||
dev_err(info->dev, "pin %d is unrouted\n", pin);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) {
|
||||
if (mux != RK_FUNC_GPIO) {
|
||||
dev_err(info->dev,
|
||||
"pin %d only supports a gpio mux\n", pin);
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set a new mux function for a pin.
|
||||
*
|
||||
@@ -717,23 +742,12 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux)
|
||||
u8 bit;
|
||||
u32 data, rmask;
|
||||
|
||||
if (iomux_num > 3)
|
||||
return -EINVAL;
|
||||
ret = rockchip_verify_mux(bank, pin, mux);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (bank->iomux[iomux_num].type & IOMUX_UNROUTED) {
|
||||
dev_err(info->dev, "pin %d is unrouted\n", pin);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) {
|
||||
if (mux != RK_FUNC_GPIO) {
|
||||
dev_err(info->dev,
|
||||
"pin %d only supports a gpio mux\n", pin);
|
||||
return -ENOTSUPP;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY)
|
||||
return 0;
|
||||
|
||||
dev_dbg(info->dev, "setting mux of GPIO%d-%d to %d\n",
|
||||
bank->bank_num, pin, mux);
|
||||
|
||||
Reference in New Issue
Block a user