Merge patch series "pinctrl: intel: use new GPIO line value setter callbacks"
Bartosz Golaszewski <brgl@bgdev.pl> says:
Commit 98ce1eb1fd ("gpiolib: introduce gpio_chip setters that return
values") added new line setter callbacks to struct gpio_chip. They allow
to indicate failures to callers. We're in the process of converting all
GPIO controllers to using them before removing the old ones. This series
converts all GPIO chips in intel pin control drivers.
Link: https://lore.kernel.org/r/20250610-gpiochip-set-rv-pinctrl-intel-v1-0-d7a773ff864e@linaro.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
@@ -1045,7 +1045,7 @@ static int byt_gpio_get(struct gpio_chip *chip, unsigned int offset)
|
||||
return !!(val & BYT_LEVEL);
|
||||
}
|
||||
|
||||
static void byt_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
static int byt_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
{
|
||||
struct intel_pinctrl *vg = gpiochip_get_data(chip);
|
||||
void __iomem *reg;
|
||||
@@ -1053,7 +1053,7 @@ static void byt_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
|
||||
reg = byt_gpio_reg(vg, offset, BYT_VAL_REG);
|
||||
if (!reg)
|
||||
return;
|
||||
return -EINVAL;
|
||||
|
||||
guard(raw_spinlock_irqsave)(&byt_lock);
|
||||
|
||||
@@ -1062,6 +1062,8 @@ static void byt_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
writel(old_val | BYT_LEVEL, reg);
|
||||
else
|
||||
writel(old_val & ~BYT_LEVEL, reg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int byt_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
|
||||
@@ -1229,7 +1231,7 @@ static const struct gpio_chip byt_gpio_chip = {
|
||||
.direction_input = byt_gpio_direction_input,
|
||||
.direction_output = byt_gpio_direction_output,
|
||||
.get = byt_gpio_get,
|
||||
.set = byt_gpio_set,
|
||||
.set_rv = byt_gpio_set,
|
||||
.set_config = gpiochip_generic_config,
|
||||
.dbg_show = byt_gpio_dbg_show,
|
||||
};
|
||||
|
||||
@@ -1112,7 +1112,7 @@ static int chv_gpio_get(struct gpio_chip *chip, unsigned int offset)
|
||||
return !!(ctrl0 & CHV_PADCTRL0_GPIORXSTATE);
|
||||
}
|
||||
|
||||
static void chv_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
static int chv_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
{
|
||||
struct intel_pinctrl *pctrl = gpiochip_get_data(chip);
|
||||
u32 ctrl0;
|
||||
@@ -1127,6 +1127,8 @@ static void chv_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
ctrl0 &= ~CHV_PADCTRL0_GPIOTXSTATE;
|
||||
|
||||
chv_writel(pctrl, offset, CHV_PADCTRL0, ctrl0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int chv_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
|
||||
@@ -1166,7 +1168,7 @@ static const struct gpio_chip chv_gpio_chip = {
|
||||
.direction_input = chv_gpio_direction_input,
|
||||
.direction_output = chv_gpio_direction_output,
|
||||
.get = chv_gpio_get,
|
||||
.set = chv_gpio_set,
|
||||
.set_rv = chv_gpio_set,
|
||||
};
|
||||
|
||||
static void chv_gpio_irq_ack(struct irq_data *d)
|
||||
|
||||
@@ -1033,8 +1033,8 @@ static int intel_gpio_get(struct gpio_chip *chip, unsigned int offset)
|
||||
return !!(padcfg0 & PADCFG0_GPIORXSTATE);
|
||||
}
|
||||
|
||||
static void intel_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
static int intel_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
struct intel_pinctrl *pctrl = gpiochip_get_data(chip);
|
||||
void __iomem *reg;
|
||||
@@ -1043,11 +1043,11 @@ static void intel_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
|
||||
pin = intel_gpio_to_pin(pctrl, offset, NULL, NULL);
|
||||
if (pin < 0)
|
||||
return;
|
||||
return -EINVAL;
|
||||
|
||||
reg = intel_get_padcfg(pctrl, pin, PADCFG0);
|
||||
if (!reg)
|
||||
return;
|
||||
return -EINVAL;
|
||||
|
||||
guard(raw_spinlock_irqsave)(&pctrl->lock);
|
||||
|
||||
@@ -1057,6 +1057,8 @@ static void intel_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
else
|
||||
padcfg0 &= ~PADCFG0_GPIOTXSTATE;
|
||||
writel(padcfg0, reg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intel_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
|
||||
@@ -1094,7 +1096,12 @@ static int intel_gpio_direction_input(struct gpio_chip *chip, unsigned int offse
|
||||
static int intel_gpio_direction_output(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
intel_gpio_set(chip, offset, value);
|
||||
int ret;
|
||||
|
||||
ret = intel_gpio_set(chip, offset, value);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return pinctrl_gpio_direction_output(chip, offset);
|
||||
}
|
||||
|
||||
@@ -1106,7 +1113,7 @@ static const struct gpio_chip intel_gpio_chip = {
|
||||
.direction_input = intel_gpio_direction_input,
|
||||
.direction_output = intel_gpio_direction_output,
|
||||
.get = intel_gpio_get,
|
||||
.set = intel_gpio_set,
|
||||
.set_rv = intel_gpio_set,
|
||||
.set_config = gpiochip_generic_config,
|
||||
};
|
||||
|
||||
|
||||
@@ -503,7 +503,7 @@ static int lp_gpio_get(struct gpio_chip *chip, unsigned int offset)
|
||||
return !!(ioread32(reg) & IN_LVL_BIT);
|
||||
}
|
||||
|
||||
static void lp_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
static int lp_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
{
|
||||
struct intel_pinctrl *lg = gpiochip_get_data(chip);
|
||||
void __iomem *reg = lp_gpio_reg(chip, offset, LP_CONFIG1);
|
||||
@@ -514,6 +514,8 @@ static void lp_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
iowrite32(ioread32(reg) | OUT_LVL_BIT, reg);
|
||||
else
|
||||
iowrite32(ioread32(reg) & ~OUT_LVL_BIT, reg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lp_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
|
||||
@@ -775,7 +777,7 @@ static int lp_gpio_probe(struct platform_device *pdev)
|
||||
gc->direction_input = lp_gpio_direction_input;
|
||||
gc->direction_output = lp_gpio_direction_output;
|
||||
gc->get = lp_gpio_get;
|
||||
gc->set = lp_gpio_set;
|
||||
gc->set_rv = lp_gpio_set;
|
||||
gc->set_config = gpiochip_generic_config;
|
||||
gc->get_direction = lp_gpio_get_direction;
|
||||
gc->base = -1;
|
||||
|
||||
Reference in New Issue
Block a user