Skip to content

Commit

Permalink
Merge tag 'gpio-updates-for-v6.13-rc1' of git://git.kernel.org/pub/sc…
Browse files Browse the repository at this point in the history
…m/linux/kernel/git/brgl/linux

Pull gpio updates from Bartosz Golaszewski:
 "Three new drivers, support for some new models in existing ones and
  lots of various tweaks and improvements across the board (switching to
  using recommended APIs, code shrink and simplification, etc.).

  Also a new feature in the character device uAPI where we now notify
  the user-space about changes triggered by in-kernel users as well, not
  only when they were done by other user-space agents.

  Summary:

  GPIOLIB core:
   - use the new mem_is_zero() instead of memchr_inv(s, 0, n)
   - don't store debounce period twice needlessly
   - clean-up debugfs handling
   - remove leftover comments referring to no longer used spinlocks
   - unduplicate some operations like SRCU locks and initializing GPIO
     descriptors
   - constify the sysfs class struct
   - use lock guards in GPIO sysfs code
   - update GPIO uAPI internal flags all at once atomically for
     consistency with other places
   - modify the behavior of the sysfs interface by no longer exporting
     lines that are named inside the driver code or board files with the
     sysfs links bearing the line names as this has for many years been
     largely unused due to the prevalence of DT, ACPI and firmware nodes
     over board files and made the API inconsistent
   - for GPIO interrupt providers: free irqs that are still requested by
     users when removing the chip

  GPIO uAPI:
   - notify user-space about changes to GPIO lines' state (requested,
     released, reconfigured) triggered from the kernel as well (until
     now we'd only do this for changes triggered from user-space)
   - to that end: modify the internal workings of the notification
     mechanism by switching to an atomic notifier which allows us to
     send events from atomic context
   - also to that end store the debounce period in the GPIO descriptor
     struct and not in the character device context struct
   - while at it, also cover the corner-case of users introducing
     changes over sysfs while others watch them via the character device
   - don't report GPIO lines requested as interrupts as "used" to
     user-space as it can still request them as GPIOs

  New drivers:
   - GPIO part of the MFD Congatec Board Controller
   - PolarFire GPIO controller
   - GPIOs on FTDI FT2232H

  Driver improvements:
   - use generic device property accessors instead of OF-specific ones
     across many GPIO drivers (mpc8xxx, vf610, eic-sprd, davinci,
     ts4900, xilinx, mvebu)
   - use devres helpers to simplify error paths and either shrink or
     entirely remove the driver's remove() callback (grgpio, amdpt,
     menz127, max730x, ftgpio010, 74x164, ljca)
   - use helper variables to store the address of pdev->dev and avoid
     some line-breaks
   - use device_for_each_child_node_scoped() to avoid having to put the
     fwnode on breaks or errors (gpio-sim, gpio-dwapb, gpiolib-acpi)
   - use a scoped bitmap to simplify the code and drop goto labels in
     gpio-aggregator
   - drop unneeded Kconfig dependencies on OF_GPIO (grgpio, mveby,
     xilinx)
   - add support for new models to gpio-aspeed, gpio-rockchip and
     gpio-dwapb
   - clean-up ACPI handling and some other bits in gpio-xgene-sb
   - replace deprecated PCI functions in pcie-idio-24 and pci-idio-16
   - allow to build davinci and mvebu drivers with COMPILE_TEST=y
   - remove dead code in gpio-mb86s7x
   - switch back to using platform_driver::remove() (after the
     conversion to remove_new()) across the GPIO drivers
   - remove remaining uses of GPIOF_ACTIVE_LOW across the tree and drop
     this deprecated symbol
   - convert the gpio-altera driver to no longer pull in the deprecated
     legacy-of-mm-gpiochip.h header
   - use of_property_present() instead of of_property_read_bool() in
     gpiolib-of and gpio-rockchip
   - allow to build the tegra186 driver on Tegra234 platforms in Kconfig

  Late fixes:
   - add a missing return value check after devm_kasprintf() to
     gpio-grgpio

  DT bindings:
   - document the ngpios property of gpio-mmio
   - add support for a new aspeed model
   - fix the example for st,nomadik-gpio

  Other:
   - kernel doc and comments tweaks
   - fix typos in TODO
   - reorder headers alphabetically in some drivers
   - fix incorrect format specifiers in gpio tools"

* tag 'gpio-updates-for-v6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (98 commits)
  gpio: tegra186: Allow to enable driver on Tegra234
  gpio: grgpio: Add NULL check in grgpio_probe
  tools: gpio: Fix several incorrect format specifiers
  gpio: mpfs: add CoreGPIO support
  gpio: rockchip: support new version GPIO
  gpio: rockchip: change the GPIO version judgment logic
  gpio: rockchip: explan the format of the GPIO version ID
  gpiolib: cdev: use !mem_is_zero() instead of memchr_inv(s, 0, n)
  MAINTAINERS: add gpio driver to PolarFire entry
  gpio: Get rid of GPIOF_ACTIVE_LOW
  USB: gadget: pxa27x_udc: Avoid using GPIOF_ACTIVE_LOW
  pcmcia: soc_common: Avoid using GPIOF_ACTIVE_LOW
  leds: gpio: Avoid using GPIOF_ACTIVE_LOW
  Input: gpio_keys_polled - avoid using GPIOF_ACTIVE_LOW
  Input: gpio_keys - avoid using GPIOF_ACTIVE_LOW
  gpio: Use of_property_present() for non-boolean properties
  gpio: mpfs: add polarfire soc gpio support
  gpio: altera: Drop legacy-of-mm-gpiochip.h header
  gpio: pcie-idio-24: Replace deprecated PCI functions
  gpio: pci-idio-16: Replace deprecated PCI functions
  ...
  • Loading branch information
torvalds committed Nov 20, 2024
2 parents 7d75606 + bef29ca commit 131561f
Show file tree
Hide file tree
Showing 73 changed files with 3,246 additions and 1,065 deletions.
19 changes: 17 additions & 2 deletions Documentation/devicetree/bindings/gpio/aspeed,ast2400-gpio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ properties:
- aspeed,ast2400-gpio
- aspeed,ast2500-gpio
- aspeed,ast2600-gpio
- aspeed,ast2700-gpio

reg:
maxItems: 1
Expand All @@ -25,7 +26,7 @@ properties:

gpio-controller: true
gpio-line-names:
minItems: 36
minItems: 12
maxItems: 232

gpio-ranges: true
Expand All @@ -42,7 +43,7 @@ properties:
const: 2

ngpios:
minimum: 36
minimum: 12
maximum: 232

required:
Expand Down Expand Up @@ -93,6 +94,20 @@ allOf:
enum: [ 36, 208 ]
required:
- ngpios
- if:
properties:
compatible:
contains:
const: aspeed,ast2700-gpio
then:
properties:
gpio-line-names:
minItems: 12
maxItems: 216
ngpios:
enum: [ 12, 216 ]
required:
- ngpios

additionalProperties: false

Expand Down
13 changes: 12 additions & 1 deletion Documentation/devicetree/bindings/gpio/gpio-mmio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ properties:
description:
A list of registers in the controller. The width of each register is
determined by its size. All registers must have the same width. The number
of GPIOs is set by the width, with bit 0 corresponding to GPIO 0.
of GPIOs is set by the width, with bit 0 corresponding to GPIO 0, unless
the ngpios property further restricts the number of used lines.
items:
- description:
Register to READ the value of the GPIO lines. If GPIO line is high,
Expand Down Expand Up @@ -74,6 +75,15 @@ properties:

native-endian: true

ngpios:
minimum: 1
maximum: 63
description:
If this property is present the number of usable GPIO lines are restricted
to the first 0 .. ngpios lines. This is useful when the GPIO MMIO register
has 32 bits for GPIO but only the first 12 are actually connected to
real electronics, and then we set ngpios to 12.

no-output:
$ref: /schemas/types.yaml#/definitions/flag
description:
Expand Down Expand Up @@ -111,6 +121,7 @@ examples:
compatible = "brcm,bcm6345-gpio";
reg-names = "dirout", "dat";
reg = <0xfffe0406 2>, <0xfffe040a 2>;
ngpios = <15>;
native-endian;
gpio-controller;
#gpio-cells = <2>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ examples:
interrupts = <0 120 0x4>;
#gpio-cells = <2>;
gpio-controller;
#interrupt-cells = <2>;
interrupt-controller;
st,supports-sleepmode;
gpio-bank = <1>;
Expand Down
10 changes: 10 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -5741,6 +5741,15 @@ F: fs/configfs/
F: include/linux/configfs.h
F: samples/configfs/

CONGATEC BOARD CONTROLLER MFD DRIVER
M: Thomas Richard <[email protected]>
S: Maintained
F: drivers/gpio/gpio-cgbc.c
F: drivers/i2c/busses/i2c-cgbc.c
F: drivers/mfd/cgbc-core.c
F: drivers/watchdog/cgbc_wdt.c
F: include/linux/mfd/cgbc.h

CONSOLE SUBSYSTEM
M: Greg Kroah-Hartman <[email protected]>
S: Supported
Expand Down Expand Up @@ -19879,6 +19888,7 @@ F: arch/riscv/boot/dts/microchip/
F: drivers/char/hw_random/mpfs-rng.c
F: drivers/clk/microchip/clk-mpfs*.c
F: drivers/firmware/microchip/mpfs-auto-update.c
F: drivers/gpio/gpio-mpfs.c
F: drivers/i2c/busses/i2c-microchip-corei2c.c
F: drivers/mailbox/mailbox-mpfs.c
F: drivers/pci/controller/plda/pcie-microchip-host.c
Expand Down
41 changes: 29 additions & 12 deletions drivers/gpio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ config GPIO_SYSFS
ioctl() operations instead.

config GPIO_CDEV
bool
prompt "Character device (/dev/gpiochipN) support" if EXPERT
bool "Character device (/dev/gpiochipN) support" if EXPERT
default y
help
Say Y here to add the character device /dev/gpiochipN interface
Expand Down Expand Up @@ -149,9 +148,7 @@ config GPIO_74XX_MMIO

config GPIO_ALTERA
tristate "Altera GPIO"
depends on OF_GPIO
select GPIOLIB_IRQCHIP
select OF_GPIO_MM_GPIOCHIP
help
Say Y or M here to build support for the Altera PIO device.

Expand Down Expand Up @@ -243,7 +240,7 @@ config GPIO_CLPS711X
config GPIO_DAVINCI
tristate "TI Davinci/Keystone GPIO support"
default y if ARCH_DAVINCI
depends on (ARM || ARM64) && (ARCH_DAVINCI || ARCH_KEYSTONE || ARCH_K3)
depends on ((ARM || ARM64) && (ARCH_DAVINCI || ARCH_KEYSTONE || ARCH_K3)) || COMPILE_TEST
help
Say yes here to enable GPIO support for TI Davinci/Keystone SoCs.

Expand Down Expand Up @@ -341,7 +338,6 @@ config GPIO_GRANITERAPIDS

config GPIO_GRGPIO
tristate "Aeroflex Gaisler GRGPIO support"
depends on OF_GPIO
select GPIO_GENERIC
select IRQ_DOMAIN
help
Expand Down Expand Up @@ -487,8 +483,7 @@ config GPIO_MT7621

config GPIO_MVEBU
def_bool y
depends on PLAT_ORION || ARCH_MVEBU
depends on OF_GPIO
depends on PLAT_ORION || ARCH_MVEBU || COMPILE_TEST
select GENERIC_IRQ_CHIP
select REGMAP_MMIO

Expand Down Expand Up @@ -549,6 +544,12 @@ config GPIO_PL061
help
Say yes here to support the PrimeCell PL061 GPIO device.

config GPIO_POLARFIRE_SOC
bool "Microchip FPGA GPIO support"
select REGMAP_MMIO
help
Say yes here to support the GPIO controllers on Microchip FPGAs.

config GPIO_PXA
bool "PXA GPIO support"
depends on ARCH_PXA || ARCH_MMP || COMPILE_TEST
Expand Down Expand Up @@ -714,13 +715,13 @@ config GPIO_TEGRA

config GPIO_TEGRA186
tristate "NVIDIA Tegra186 GPIO support"
default ARCH_TEGRA_186_SOC || ARCH_TEGRA_194_SOC
depends on ARCH_TEGRA_186_SOC || ARCH_TEGRA_194_SOC || COMPILE_TEST
default ARCH_TEGRA_186_SOC || ARCH_TEGRA_194_SOC || ARCH_TEGRA_234_SOC
depends on ARCH_TEGRA_186_SOC || ARCH_TEGRA_194_SOC || ARCH_TEGRA_234_SOC || COMPILE_TEST
depends on OF_GPIO
select GPIOLIB_IRQCHIP
select IRQ_DOMAIN_HIERARCHY
help
Say yes here to support GPIO pins on NVIDIA Tegra186 SoCs.
Say yes here to support GPIO pins on NVIDIA Tegra186, 194 and 234 SoCs.

config GPIO_TS4800
tristate "TS-4800 DIO blocks and compatibles"
Expand Down Expand Up @@ -796,7 +797,6 @@ config GPIO_XGENE_SB
config GPIO_XILINX
tristate "Xilinx GPIO support"
select GPIOLIB_IRQCHIP
depends on OF_GPIO
help
Say yes here to support the Xilinx FPGA GPIO device.

Expand Down Expand Up @@ -1287,6 +1287,16 @@ config GPIO_BD9571MWV
This driver can also be built as a module. If so, the module
will be called gpio-bd9571mwv.

config GPIO_CGBC
tristate "Congatec Board Controller GPIO support"
depends on MFD_CGBC
help
Select this option to enable GPIO support for the Congatec Board
Controller.

This driver can also be built as a module. If so, the module will be
called gpio-cgbc.

config GPIO_CROS_EC
tristate "ChromeOS EC GPIO support"
depends on CROS_EC
Expand Down Expand Up @@ -1844,6 +1854,13 @@ config GPIO_VIPERBOARD
River Tech's viperboard.h for detailed meaning
of the module parameters.

config GPIO_MPSSE
tristate "FTDI MPSSE GPIO support"
select GPIOLIB_IRQCHIP
help
GPIO driver for FTDI's MPSSE interface. These can do input and
output. Each MPSSE provides 16 IO pins.

endmenu

menu "Virtual GPIO drivers"
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ obj-$(CONFIG_GPIO_BD9571MWV) += gpio-bd9571mwv.o
obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o
obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o
obj-$(CONFIG_GPIO_CADENCE) += gpio-cadence.o
obj-$(CONFIG_GPIO_CGBC) += gpio-cgbc.o
obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o
obj-$(CONFIG_GPIO_SNPS_CREG) += gpio-creg-snps.o
obj-$(CONFIG_GPIO_CROS_EC) += gpio-cros-ec.o
Expand Down Expand Up @@ -114,6 +115,7 @@ obj-$(CONFIG_GPIO_MOCKUP) += gpio-mockup.o
obj-$(CONFIG_GPIO_MOXTET) += gpio-moxtet.o
obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o
obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o
obj-$(CONFIG_GPIO_MPSSE) += gpio-mpsse.o
obj-$(CONFIG_GPIO_MSC313) += gpio-msc313.o
obj-$(CONFIG_GPIO_MT7621) += gpio-mt7621.o
obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o
Expand All @@ -133,6 +135,7 @@ obj-$(CONFIG_GPIO_PCI_IDIO_16) += gpio-pci-idio-16.o
obj-$(CONFIG_GPIO_PISOSR) += gpio-pisosr.o
obj-$(CONFIG_GPIO_PL061) += gpio-pl061.o
obj-$(CONFIG_GPIO_PMIC_EIC_SPRD) += gpio-pmic-eic-sprd.o
obj-$(CONFIG_GPIO_POLARFIRE_SOC) += gpio-mpfs.o
obj-$(CONFIG_GPIO_PXA) += gpio-pxa.o
obj-$(CONFIG_GPIO_RASPBERRYPI_EXP) += gpio-raspberrypi-exp.o
obj-$(CONFIG_GPIO_RC5T583) += gpio-rc5t583.o
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpio/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ Work items:

- Change all consumer drivers that #include <linux/of_gpio.h> to
#include <linux/gpio/consumer.h> and stop doing custom parsing of the
GPIO lines from the device tree. This can be tricky and often ivolves
changing boardfiles, etc.
GPIO lines from the device tree. This can be tricky and often involves
changing board files, etc.

- Pull semantics for legacy device tree (OF) GPIO lookups into
gpiolib-of.c: in some cases subsystems are doing custom flags and
Expand Down
21 changes: 6 additions & 15 deletions drivers/gpio/gpio-74x164.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,33 +143,24 @@ static int gen_74x164_probe(struct spi_device *spi)
chip->gpio_chip.parent = &spi->dev;
chip->gpio_chip.owner = THIS_MODULE;

mutex_init(&chip->lock);
ret = devm_mutex_init(&spi->dev, &chip->lock);
if (ret)
return ret;

ret = __gen_74x164_write_config(chip);
if (ret) {
dev_err(&spi->dev, "Failed writing: %d\n", ret);
goto exit_destroy;
}
if (ret)
return dev_err_probe(&spi->dev, ret, "Config write failed\n");

gpiod_set_value_cansleep(chip->gpiod_oe, 1);

ret = gpiochip_add_data(&chip->gpio_chip, chip);
if (!ret)
return 0;

exit_destroy:
mutex_destroy(&chip->lock);

return ret;
return devm_gpiochip_add_data(&spi->dev, &chip->gpio_chip, chip);
}

static void gen_74x164_remove(struct spi_device *spi)
{
struct gen_74x164_chip *chip = spi_get_drvdata(spi);

gpiod_set_value_cansleep(chip->gpiod_oe, 0);
gpiochip_remove(&chip->gpio_chip);
mutex_destroy(&chip->lock);
}

static const struct spi_device_id gen_74x164_spi_ids[] = {
Expand Down
16 changes: 7 additions & 9 deletions drivers/gpio/gpio-aggregator.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ static int aggr_parse(struct gpio_aggregator *aggr)
{
char *args = skip_spaces(aggr->args);
char *name, *offsets, *p;
unsigned long *bitmap;
unsigned int i, n = 0;
int error = 0;

bitmap = bitmap_alloc(AGGREGATOR_MAX_GPIOS, GFP_KERNEL);
unsigned long *bitmap __free(bitmap) =
bitmap_alloc(AGGREGATOR_MAX_GPIOS, GFP_KERNEL);
if (!bitmap)
return -ENOMEM;

Expand All @@ -82,7 +82,7 @@ static int aggr_parse(struct gpio_aggregator *aggr)
/* Named GPIO line */
error = aggr_add_gpio(aggr, name, U16_MAX, &n);
if (error)
goto free_bitmap;
return error;

name = offsets;
continue;
Expand All @@ -92,26 +92,24 @@ static int aggr_parse(struct gpio_aggregator *aggr)
error = bitmap_parselist(offsets, bitmap, AGGREGATOR_MAX_GPIOS);
if (error) {
pr_err("Cannot parse %s: %d\n", offsets, error);
goto free_bitmap;
return error;
}

for_each_set_bit(i, bitmap, AGGREGATOR_MAX_GPIOS) {
error = aggr_add_gpio(aggr, name, i, &n);
if (error)
goto free_bitmap;
return error;
}

args = next_arg(args, &name, &p);
}

if (!n) {
pr_err("No GPIOs specified\n");
error = -EINVAL;
return -EINVAL;
}

free_bitmap:
bitmap_free(bitmap);
return error;
return 0;
}

static ssize_t new_device_store(struct device_driver *driver, const char *buf,
Expand Down
Loading

0 comments on commit 131561f

Please sign in to comment.