* [PATCH v5 0/2] Add DS4520 GPIO Expander Support @ 2023-07-27 9:54 Okan Sahin 2023-07-27 9:54 ` [PATCH v5 1/2] dt-bindings: gpio: ds4520: Add ADI DS4520 Okan Sahin 2023-07-27 9:54 ` [PATCH v5 2/2] gpio: ds4520: Add ADI DS4520 GPIO Expander Support Okan Sahin 0 siblings, 2 replies; 9+ messages in thread From: Okan Sahin @ 2023-07-27 9:54 UTC (permalink / raw) To: okan.sahin Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, linux-gpio, devicetree, linux-kernel GPIO expander driver and bindings for DS4520. The patches are required to be applied in sequence. Changes in v5: * Patch 1: "dt-bindings: gpio: ds4520: Add ADI DS4520" * No change * Patch 2: "gpio: ds4520: Add ADI DS4520 GPIO Expander Support" * Remove unnecessary new lines. * Use probe(..) instead of probe_new(..) Changes in v4: * Patch 1: "dt-bindings: gpio: ds4520: Add ADI DS4520" * No change * Patch 2: "gpio: ds4520: Add ADI DS4520 GPIO Expander Support" * Add, remove unnecessary new lines. Changes in v3: * Patch 1: "dt-bindings: gpio: ds4520: Add ADI DS4520" * Add ngpios property. * Patch 2: "gpio: ds4520: Add ADI DS4520 GPIO Expander Support" * Add namespace for MACROS * Read ngpios from dt * Add missing header file Changes in v2: * Patch 1: "dt-bindings: gpio: ds4520: Add ADI DS4520" * Drop label for gpio node * Use consistent quotes * Fix filename matching compatible. * Patch 2: "gpio: ds4520: Add ADI DS4520 GPIO Expander Support" * Use regmap_gpio framework * Fix typo in Kconfig * Fix commit message Okan Sahin (2): dt-bindings: gpio: ds4520: Add ADI DS4520 gpio: ds4520: Add ADI DS4520 GPIO Expander Support .../bindings/gpio/adi,ds4520-gpio.yaml | 51 ++++++++++++ drivers/gpio/Kconfig | 11 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-ds4520.c | 80 +++++++++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml create mode 100644 drivers/gpio/gpio-ds4520.c -- 2.30.2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v5 1/2] dt-bindings: gpio: ds4520: Add ADI DS4520 2023-07-27 9:54 [PATCH v5 0/2] Add DS4520 GPIO Expander Support Okan Sahin @ 2023-07-27 9:54 ` Okan Sahin 2023-07-29 13:57 ` Bartosz Golaszewski 2023-07-27 9:54 ` [PATCH v5 2/2] gpio: ds4520: Add ADI DS4520 GPIO Expander Support Okan Sahin 1 sibling, 1 reply; 9+ messages in thread From: Okan Sahin @ 2023-07-27 9:54 UTC (permalink / raw) To: okan.sahin Cc: Krzysztof Kozlowski, Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, linux-gpio, devicetree, linux-kernel Add ADI DS4520 devicetree document. Signed-off-by: Okan Sahin <okan.sahin@analog.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> --- .../bindings/gpio/adi,ds4520-gpio.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml diff --git a/Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml b/Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml new file mode 100644 index 000000000000..25b3198c4d3e --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/adi,ds4520-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: DS4520 I2C GPIO expander + +maintainers: + - Okan Sahin <okan.sahin@analog.com> + +properties: + compatible: + enum: + - adi,ds4520-gpio + + reg: + maxItems: 1 + + gpio-controller: true + + "#gpio-cells": + const: 2 + + ngpios: + minimum: 1 + maximum: 9 + +required: + - compatible + - reg + - gpio-controller + - "#gpio-cells" + - ngpios + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + gpio@50 { + compatible = "adi,ds4520-gpio"; + reg = <0x50>; + ngpios = <9>; + gpio-controller; + #gpio-cells = <2>; + }; + }; -- 2.30.2 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v5 1/2] dt-bindings: gpio: ds4520: Add ADI DS4520 2023-07-27 9:54 ` [PATCH v5 1/2] dt-bindings: gpio: ds4520: Add ADI DS4520 Okan Sahin @ 2023-07-29 13:57 ` Bartosz Golaszewski 2023-08-21 10:09 ` Sahin, Okan 0 siblings, 1 reply; 9+ messages in thread From: Bartosz Golaszewski @ 2023-07-29 13:57 UTC (permalink / raw) To: Okan Sahin Cc: Krzysztof Kozlowski, Linus Walleij, Rob Herring, Krzysztof Kozlowski, linux-gpio, devicetree, linux-kernel On Thu, Jul 27, 2023 at 11:55 AM Okan Sahin <okan.sahin@analog.com> wrote: > > Add ADI DS4520 devicetree document. > > Signed-off-by: Okan Sahin <okan.sahin@analog.com> > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org> > --- > .../bindings/gpio/adi,ds4520-gpio.yaml | 51 +++++++++++++++++++ > 1 file changed, 51 insertions(+) > create mode 100644 Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml > > diff --git a/Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml b/Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml > new file mode 100644 > index 000000000000..25b3198c4d3e > --- /dev/null > +++ b/Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml > @@ -0,0 +1,51 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/gpio/adi,ds4520-gpio.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: DS4520 I2C GPIO expander > + > +maintainers: > + - Okan Sahin <okan.sahin@analog.com> > + > +properties: > + compatible: > + enum: > + - adi,ds4520-gpio > + > + reg: > + maxItems: 1 > + > + gpio-controller: true > + > + "#gpio-cells": > + const: 2 > + > + ngpios: > + minimum: 1 > + maximum: 9 > + > +required: > + - compatible > + - reg > + - gpio-controller > + - "#gpio-cells" > + - ngpios > + > +additionalProperties: false > + > +examples: > + - | > + i2c { > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio@50 { > + compatible = "adi,ds4520-gpio"; > + reg = <0x50>; > + ngpios = <9>; > + gpio-controller; > + #gpio-cells = <2>; > + }; > + }; > -- > 2.30.2 > Applied this and the driver, thanks! Bart ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v5 1/2] dt-bindings: gpio: ds4520: Add ADI DS4520 2023-07-29 13:57 ` Bartosz Golaszewski @ 2023-08-21 10:09 ` Sahin, Okan 2023-08-21 12:27 ` Bartosz Golaszewski 0 siblings, 1 reply; 9+ messages in thread From: Sahin, Okan @ 2023-08-21 10:09 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Krzysztof Kozlowski, Linus Walleij, Rob Herring, Krzysztof Kozlowski, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org >On Thu, Jul 27, 2023 at 11:55 AM Okan Sahin <okan.sahin@analog.com> wrote: >> >> Add ADI DS4520 devicetree document. >> >> Signed-off-by: Okan Sahin <okan.sahin@analog.com> >> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> >> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> >> --- >> .../bindings/gpio/adi,ds4520-gpio.yaml | 51 +++++++++++++++++++ >> 1 file changed, 51 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/gpio/adi,ds4520- >gpio.yaml >> >> diff --git a/Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml >b/Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml >> new file mode 100644 >> index 000000000000..25b3198c4d3e >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml >> @@ -0,0 +1,51 @@ >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) >> +%YAML 1.2 >> +--- >> +$id: ... >> > >Applied this and the driver, thanks! > >Bart Hi Bart, When will it be released? I could not find your tree that's why I am asking it. Regards, Okan Sahin ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 1/2] dt-bindings: gpio: ds4520: Add ADI DS4520 2023-08-21 10:09 ` Sahin, Okan @ 2023-08-21 12:27 ` Bartosz Golaszewski 0 siblings, 0 replies; 9+ messages in thread From: Bartosz Golaszewski @ 2023-08-21 12:27 UTC (permalink / raw) To: Sahin, Okan Cc: Krzysztof Kozlowski, Linus Walleij, Rob Herring, Krzysztof Kozlowski, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org On Mon, Aug 21, 2023 at 12:09 PM Sahin, Okan <Okan.Sahin@analog.com> wrote: > > > >On Thu, Jul 27, 2023 at 11:55 AM Okan Sahin <okan.sahin@analog.com> wrote: > >> > >> Add ADI DS4520 devicetree document. > >> > >> Signed-off-by: Okan Sahin <okan.sahin@analog.com> > >> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> > >> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> > >> --- > >> .../bindings/gpio/adi,ds4520-gpio.yaml | 51 +++++++++++++++++++ > >> 1 file changed, 51 insertions(+) > >> create mode 100644 Documentation/devicetree/bindings/gpio/adi,ds4520- > >gpio.yaml > >> > >> diff --git a/Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml > >b/Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml > >> new file mode 100644 > >> index 000000000000..25b3198c4d3e > >> --- /dev/null > >> +++ b/Documentation/devicetree/bindings/gpio/adi,ds4520-gpio.yaml > >> @@ -0,0 +1,51 @@ > >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > >> +%YAML 1.2 > >> +--- > >> +$id: > > ... > > >> > > > >Applied this and the driver, thanks! > > > >Bart > > Hi Bart, > > When will it be released? I could not find your tree that's why I am asking it. > > Regards, > Okan Sahin It will be released in v6.6 in around 3 months (see Documentation/process). My tree is listed in the MAINTAINERS file. Bart ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v5 2/2] gpio: ds4520: Add ADI DS4520 GPIO Expander Support 2023-07-27 9:54 [PATCH v5 0/2] Add DS4520 GPIO Expander Support Okan Sahin 2023-07-27 9:54 ` [PATCH v5 1/2] dt-bindings: gpio: ds4520: Add ADI DS4520 Okan Sahin @ 2023-07-27 9:54 ` Okan Sahin 2023-08-07 13:08 ` Linus Walleij 1 sibling, 1 reply; 9+ messages in thread From: Okan Sahin @ 2023-07-27 9:54 UTC (permalink / raw) To: okan.sahin Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, linux-gpio, devicetree, linux-kernel The DS4520 is a 9-bit nonvolatile (NV) I/O expander. It offers users a digitally programmable alternative to hardware jumpers and mechanical switches that are being used to control digital logic node. Signed-off-by: Okan Sahin <okan.sahin@analog.com> --- drivers/gpio/Kconfig | 11 ++++++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-ds4520.c | 80 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 drivers/gpio/gpio-ds4520.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 13be729710f2..5f89e46d6411 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -1000,6 +1000,17 @@ config GPIO_ADNP enough to represent all pins, but the driver will assume a register layout for 64 pins (8 registers). +config GPIO_DS4520 + tristate "DS4520 I2C GPIO expander" + select REGMAP_I2C + select GPIO_REGMAP + help + GPIO driver for ADI DS4520 I2C-based GPIO expander. + Say yes here to enable the GPIO driver for the ADI DS4520 chip. + + To compile this driver as a module, choose M here: the module will + be called gpio-ds4520. + config GPIO_GW_PLD tristate "Gateworks PLD GPIO Expander" depends on OF_GPIO diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index c048ba003367..6f8656d5d617 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -52,6 +52,7 @@ obj-$(CONFIG_GPIO_DA9052) += gpio-da9052.o obj-$(CONFIG_GPIO_DA9055) += gpio-da9055.o obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o obj-$(CONFIG_GPIO_DLN2) += gpio-dln2.o +obj-$(CONFIG_GPIO_DS4520) += gpio-ds4520.o obj-$(CONFIG_GPIO_DWAPB) += gpio-dwapb.o obj-$(CONFIG_GPIO_EIC_SPRD) += gpio-eic-sprd.o obj-$(CONFIG_GPIO_EM) += gpio-em.o diff --git a/drivers/gpio/gpio-ds4520.c b/drivers/gpio/gpio-ds4520.c new file mode 100644 index 000000000000..1903deaef3e9 --- /dev/null +++ b/drivers/gpio/gpio-ds4520.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2023 Analog Devices, Inc. + * Driver for the DS4520 I/O Expander + */ + +#include <linux/device.h> +#include <linux/gpio/driver.h> +#include <linux/gpio/regmap.h> +#include <linux/i2c.h> +#include <linux/property.h> +#include <linux/regmap.h> + +#define DS4520_PULLUP0 0xF0 +#define DS4520_IO_CONTROL0 0xF2 +#define DS4520_IO_STATUS0 0xF8 + +static const struct regmap_config ds4520_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static int ds4520_gpio_probe(struct i2c_client *client) +{ + struct gpio_regmap_config config = { }; + struct device *dev = &client->dev; + struct regmap *regmap; + u32 ngpio; + u32 base; + int ret; + + ret = device_property_read_u32(dev, "reg", &base); + if (ret) + return dev_err_probe(dev, ret, "Missing 'reg' property.\n"); + + ret = device_property_read_u32(dev, "ngpios", &ngpio); + if (ret) + return dev_err_probe(dev, ret, "Missing 'ngpios' property.\n"); + + regmap = devm_regmap_init_i2c(client, &ds4520_regmap_config); + if (IS_ERR(regmap)) + return dev_err_probe(dev, PTR_ERR(regmap), + "Failed to allocate register map\n"); + + config.regmap = regmap; + config.parent = dev; + config.ngpio = ngpio; + + config.reg_dat_base = base + DS4520_IO_STATUS0; + config.reg_set_base = base + DS4520_PULLUP0; + config.reg_dir_out_base = base + DS4520_IO_CONTROL0; + + return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &config)); +} + +static const struct of_device_id ds4520_gpio_of_match_table[] = { + { .compatible = "adi,ds4520-gpio" }, + { } +}; +MODULE_DEVICE_TABLE(of, ds4520_gpio_of_match_table); + +static const struct i2c_device_id ds4520_gpio_id_table[] = { + { "ds4520-gpio" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, ds4520_gpio_id_table); + +static struct i2c_driver ds4520_gpio_driver = { + .driver = { + .name = "ds4520-gpio", + .of_match_table = ds4520_gpio_of_match_table, + }, + .probe = ds4520_gpio_probe, + .id_table = ds4520_gpio_id_table, +}; +module_i2c_driver(ds4520_gpio_driver); + +MODULE_DESCRIPTION("DS4520 I/O Expander"); +MODULE_AUTHOR("Okan Sahin <okan.sahin@analog.com>"); +MODULE_LICENSE("GPL"); -- 2.30.2 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v5 2/2] gpio: ds4520: Add ADI DS4520 GPIO Expander Support 2023-07-27 9:54 ` [PATCH v5 2/2] gpio: ds4520: Add ADI DS4520 GPIO Expander Support Okan Sahin @ 2023-08-07 13:08 ` Linus Walleij 2023-08-09 7:17 ` Michael Walle 0 siblings, 1 reply; 9+ messages in thread From: Linus Walleij @ 2023-08-07 13:08 UTC (permalink / raw) To: Okan Sahin Cc: Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, linux-gpio, devicetree, linux-kernel On Thu, Jul 27, 2023 at 11:55 AM Okan Sahin <okan.sahin@analog.com> wrote: > The DS4520 is a 9-bit nonvolatile (NV) I/O expander. > It offers users a digitally programmable alternative > to hardware jumpers and mechanical switches that are > being used to control digital logic node. > > Signed-off-by: Okan Sahin <okan.sahin@analog.com> Too late to add review tags but just pointing out what a beauty this driver is when using regmap GPIO. Total success! Yours, Linus Walleij ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 2/2] gpio: ds4520: Add ADI DS4520 GPIO Expander Support 2023-08-07 13:08 ` Linus Walleij @ 2023-08-09 7:17 ` Michael Walle 2023-08-10 8:45 ` Linus Walleij 0 siblings, 1 reply; 9+ messages in thread From: Michael Walle @ 2023-08-09 7:17 UTC (permalink / raw) To: linus.walleij Cc: brgl, devicetree, krzysztof.kozlowski+dt, linux-gpio, linux-kernel, okan.sahin, robh+dt, Michael Walle Hi, > On Thu, Jul 27, 2023 at 11:55=E2=80=AFAM Okan Sahin <okan.sahin@analog.com>= > wrote: > >> The DS4520 is a 9-bit nonvolatile (NV) I/O expander. >> It offers users a digitally programmable alternative >> to hardware jumpers and mechanical switches that are >> being used to control digital logic node. >> >> Signed-off-by: Okan Sahin <okan.sahin@analog.com> > > Too late to add review tags but just pointing out what a beauty > this driver is when using regmap GPIO. Total success! Mh somehow I'm always missing consumers of regmap GPIO. Linus, Bartosz, what do you think about the patch below? diff --git a/MAINTAINERS b/MAINTAINERS index 20a0f7411efd..907f39825733 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8868,6 +8868,7 @@ R: Michael Walle <michael@walle.cc> S: Maintained F: drivers/gpio/gpio-regmap.c F: include/linux/gpio/regmap.h +K: (devm_)?gpio_regmap_(un)?register GPIO SUBSYSTEM M: Linus Walleij <linus.walleij@linaro.org> -michael ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v5 2/2] gpio: ds4520: Add ADI DS4520 GPIO Expander Support 2023-08-09 7:17 ` Michael Walle @ 2023-08-10 8:45 ` Linus Walleij 0 siblings, 0 replies; 9+ messages in thread From: Linus Walleij @ 2023-08-10 8:45 UTC (permalink / raw) To: Michael Walle Cc: brgl, devicetree, krzysztof.kozlowski+dt, linux-gpio, linux-kernel, okan.sahin, robh+dt On Wed, Aug 9, 2023 at 9:19 AM Michael Walle <mwalle@kernel.org> wrote: > > On Thu, Jul 27, 2023 at 11:55=E2=80=AFAM Okan Sahin <okan.sahin@analog.com>= > > wrote: > > > >> The DS4520 is a 9-bit nonvolatile (NV) I/O expander. > >> It offers users a digitally programmable alternative > >> to hardware jumpers and mechanical switches that are > >> being used to control digital logic node. > >> > >> Signed-off-by: Okan Sahin <okan.sahin@analog.com> > > > > Too late to add review tags but just pointing out what a beauty > > this driver is when using regmap GPIO. Total success! > > Mh somehow I'm always missing consumers of regmap GPIO. > > Linus, Bartosz, what do you think about the patch below? (...) > +K: (devm_)?gpio_regmap_(un)?register I never saw that globbing trick before, but makes perfect sense so: Acked-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-08-21 12:28 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-07-27 9:54 [PATCH v5 0/2] Add DS4520 GPIO Expander Support Okan Sahin 2023-07-27 9:54 ` [PATCH v5 1/2] dt-bindings: gpio: ds4520: Add ADI DS4520 Okan Sahin 2023-07-29 13:57 ` Bartosz Golaszewski 2023-08-21 10:09 ` Sahin, Okan 2023-08-21 12:27 ` Bartosz Golaszewski 2023-07-27 9:54 ` [PATCH v5 2/2] gpio: ds4520: Add ADI DS4520 GPIO Expander Support Okan Sahin 2023-08-07 13:08 ` Linus Walleij 2023-08-09 7:17 ` Michael Walle 2023-08-10 8:45 ` Linus Walleij
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).