Skip to content

Commit cef0691

Browse files
committed
Merge tag 'gpio-fixes-for-v5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fixes from Bartosz Golaszewski: - fix a probe failure for Tegra241 GPIO controller in gpio-tegra186 - revert changes that caused a regression in the sysfs user-space interface - correct the debounce time conversion in GPIO ACPI - statify a struct in gpio-sim and fix a typo - update registers in correct order (hardware quirk) in gpio-ts4900 * tag 'gpio-fixes-for-v5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpio: sim: fix a typo gpio: ts4900: Do not set DAT and OE together gpio: sim: Declare gpio_sim_hog_config_item_ops static gpiolib: acpi: Convert ACPI value of debounce to microseconds gpio: Revert regression in sysfs-gpio (gpiolib.c) gpio: tegra186: Add IRQ per bank for Tegra241
2 parents 9c67494 + 55d01c9 commit cef0691

File tree

5 files changed

+37
-19
lines changed

5 files changed

+37
-19
lines changed

drivers/gpio/gpio-sim.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ struct gpio_sim_bank {
547547
*
548548
* So we need to store the pointer to the parent struct here. We can
549549
* dereference it anywhere we need with no checks and no locking as
550-
* it's guaranteed to survive the childred and protected by configfs
550+
* it's guaranteed to survive the children and protected by configfs
551551
* locks.
552552
*
553553
* Same for other structures.
@@ -1322,7 +1322,7 @@ static void gpio_sim_hog_config_item_release(struct config_item *item)
13221322
kfree(hog);
13231323
}
13241324

1325-
struct configfs_item_operations gpio_sim_hog_config_item_ops = {
1325+
static struct configfs_item_operations gpio_sim_hog_config_item_ops = {
13261326
.release = gpio_sim_hog_config_item_release,
13271327
};
13281328

drivers/gpio/gpio-tegra186.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,7 @@ static const struct tegra_gpio_soc tegra241_main_soc = {
10751075
.ports = tegra241_main_ports,
10761076
.name = "tegra241-gpio",
10771077
.instance = 0,
1078+
.num_irqs_per_bank = 8,
10781079
};
10791080

10801081
#define TEGRA241_AON_GPIO_PORT(_name, _bank, _port, _pins) \
@@ -1095,6 +1096,7 @@ static const struct tegra_gpio_soc tegra241_aon_soc = {
10951096
.ports = tegra241_aon_ports,
10961097
.name = "tegra241-gpio-aon",
10971098
.instance = 1,
1099+
.num_irqs_per_bank = 8,
10981100
};
10991101

11001102
static const struct of_device_id tegra186_gpio_of_match[] = {

drivers/gpio/gpio-ts4900.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Digital I/O driver for Technologic Systems I2C FPGA Core
33
*
4-
* Copyright (C) 2015 Technologic Systems
4+
* Copyright (C) 2015, 2018 Technologic Systems
55
* Copyright (C) 2016 Savoir-Faire Linux
66
*
77
* This program is free software; you can redistribute it and/or
@@ -55,19 +55,33 @@ static int ts4900_gpio_direction_input(struct gpio_chip *chip,
5555
{
5656
struct ts4900_gpio_priv *priv = gpiochip_get_data(chip);
5757

58-
/*
59-
* This will clear the output enable bit, the other bits are
60-
* dontcare when this is cleared
58+
/* Only clear the OE bit here, requires a RMW. Prevents potential issue
59+
* with OE and data getting to the physical pin at different times.
6160
*/
62-
return regmap_write(priv->regmap, offset, 0);
61+
return regmap_update_bits(priv->regmap, offset, TS4900_GPIO_OE, 0);
6362
}
6463

6564
static int ts4900_gpio_direction_output(struct gpio_chip *chip,
6665
unsigned int offset, int value)
6766
{
6867
struct ts4900_gpio_priv *priv = gpiochip_get_data(chip);
68+
unsigned int reg;
6969
int ret;
7070

71+
/* If changing from an input to an output, we need to first set the
72+
* proper data bit to what is requested and then set OE bit. This
73+
* prevents a glitch that can occur on the IO line
74+
*/
75+
regmap_read(priv->regmap, offset, &reg);
76+
if (!(reg & TS4900_GPIO_OE)) {
77+
if (value)
78+
reg = TS4900_GPIO_OUT;
79+
else
80+
reg &= ~TS4900_GPIO_OUT;
81+
82+
regmap_write(priv->regmap, offset, reg);
83+
}
84+
7185
if (value)
7286
ret = regmap_write(priv->regmap, offset, TS4900_GPIO_OE |
7387
TS4900_GPIO_OUT);

drivers/gpio/gpiolib-acpi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
307307
if (IS_ERR(desc))
308308
return desc;
309309

310-
ret = gpio_set_debounce_timeout(desc, agpio->debounce_timeout);
310+
/* ACPI uses hundredths of milliseconds units */
311+
ret = gpio_set_debounce_timeout(desc, agpio->debounce_timeout * 10);
311312
if (ret)
312313
dev_warn(chip->parent,
313314
"Failed to set debounce-timeout for pin 0x%04X, err %d\n",
@@ -1035,7 +1036,8 @@ int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int ind
10351036
if (ret < 0)
10361037
return ret;
10371038

1038-
ret = gpio_set_debounce_timeout(desc, info.debounce);
1039+
/* ACPI uses hundredths of milliseconds units */
1040+
ret = gpio_set_debounce_timeout(desc, info.debounce * 10);
10391041
if (ret)
10401042
return ret;
10411043

drivers/gpio/gpiolib.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,11 +1701,6 @@ static inline void gpiochip_irqchip_free_valid_mask(struct gpio_chip *gc)
17011701
*/
17021702
int gpiochip_generic_request(struct gpio_chip *gc, unsigned int offset)
17031703
{
1704-
#ifdef CONFIG_PINCTRL
1705-
if (list_empty(&gc->gpiodev->pin_ranges))
1706-
return 0;
1707-
#endif
1708-
17091704
return pinctrl_gpio_request(gc->gpiodev->base + offset);
17101705
}
17111706
EXPORT_SYMBOL_GPL(gpiochip_generic_request);
@@ -1717,11 +1712,6 @@ EXPORT_SYMBOL_GPL(gpiochip_generic_request);
17171712
*/
17181713
void gpiochip_generic_free(struct gpio_chip *gc, unsigned int offset)
17191714
{
1720-
#ifdef CONFIG_PINCTRL
1721-
if (list_empty(&gc->gpiodev->pin_ranges))
1722-
return;
1723-
#endif
1724-
17251715
pinctrl_gpio_free(gc->gpiodev->base + offset);
17261716
}
17271717
EXPORT_SYMBOL_GPL(gpiochip_generic_free);
@@ -2227,6 +2217,16 @@ static int gpio_set_bias(struct gpio_desc *desc)
22272217
return gpio_set_config_with_argument_optional(desc, bias, arg);
22282218
}
22292219

2220+
/**
2221+
* gpio_set_debounce_timeout() - Set debounce timeout
2222+
* @desc: GPIO descriptor to set the debounce timeout
2223+
* @debounce: Debounce timeout in microseconds
2224+
*
2225+
* The function calls the certain GPIO driver to set debounce timeout
2226+
* in the hardware.
2227+
*
2228+
* Returns 0 on success, or negative error code otherwise.
2229+
*/
22302230
int gpio_set_debounce_timeout(struct gpio_desc *desc, unsigned int debounce)
22312231
{
22322232
return gpio_set_config_with_argument_optional(desc,

0 commit comments

Comments
 (0)