* [PATCH 1/3] gpio: gpioinfo: use dev_name to get device name @ 2023-03-07 10:23 Ahmad Fatoum 2023-03-07 10:23 ` [PATCH 2/3] gpio: pca953x: sync DT compatibles with Linux Ahmad Fatoum ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: Ahmad Fatoum @ 2023-03-07 10:23 UTC (permalink / raw) To: barebox; +Cc: Ahmad Fatoum Otherwise, we don't correctly number devices with dynamic ID. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 2e7a39b47552..736279875856 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -716,7 +716,7 @@ static int do_gpiolib(int argc, char *argv[]) printf("\nGPIOs %u-%u, chip %s:\n", gi->chip->base, gi->chip->base + gi->chip->ngpio - 1, - gi->chip->dev->name); + dev_name(gi->chip->dev)); printf(" %-3s %-3s %-9s %-20s %-20s\n", "dir", "val", "requested", "name", "label"); } -- 2.30.2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] gpio: pca953x: sync DT compatibles with Linux 2023-03-07 10:23 [PATCH 1/3] gpio: gpioinfo: use dev_name to get device name Ahmad Fatoum @ 2023-03-07 10:23 ` Ahmad Fatoum 2023-03-07 10:23 ` [PATCH 3/3] gpio: pca953x: add optional support for regulator and reset GPIO Ahmad Fatoum 2023-03-09 10:51 ` [PATCH 1/3] gpio: gpioinfo: use dev_name to get device name Sascha Hauer 2 siblings, 0 replies; 4+ messages in thread From: Ahmad Fatoum @ 2023-03-07 10:23 UTC (permalink / raw) To: barebox; +Cc: Ahmad Fatoum There are a lot of pca953x compatible chips. Import the current list of compatibles from Linux. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- drivers/gpio/gpio-pca953x.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 4633d4f15d70..2a1822ef3bcc 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -37,6 +37,8 @@ #define PCA_GPIO_MASK 0x00FF #define PCA_INT 0x0100 +#define PCA_PCAL 0x0200 +#define PCA_LATCH_INT (PCA_PCAL | PCA_INT) #define PCA953X_TYPE 0x1000 #define PCA957X_TYPE 0x2000 @@ -468,7 +470,10 @@ static int pca953x_probe(struct device *dev) #define OF_957X(__nrgpio, __int) (void *)(__nrgpio | PCA957X_TYPE | __int) static const struct of_device_id pca953x_dt_ids[] = { + { .compatible = "nxp,pca6408", .data = OF_953X(8, PCA_INT), }, + { .compatible = "nxp,pca6416", .data = OF_953X(16, PCA_INT), }, { .compatible = "nxp,pca9505", .data = OF_953X(40, PCA_INT), }, + { .compatible = "nxp,pca9506", .data = OF_953X(40, PCA_INT), }, { .compatible = "nxp,pca9534", .data = OF_953X( 8, PCA_INT), }, { .compatible = "nxp,pca9535", .data = OF_953X(16, PCA_INT), }, { .compatible = "nxp,pca9536", .data = OF_953X( 4, 0), }, @@ -483,15 +488,29 @@ static const struct of_device_id pca953x_dt_ids[] = { { .compatible = "nxp,pca9575", .data = OF_957X(16, PCA_INT), }, { .compatible = "nxp,pca9698", .data = OF_953X(40, 0), }, + { .compatible = "nxp,pcal6408", .data = OF_953X(8, PCA_LATCH_INT), }, + { .compatible = "nxp,pcal6416", .data = OF_953X(16, PCA_LATCH_INT), }, + { .compatible = "nxp,pcal6524", .data = OF_953X(24, PCA_LATCH_INT), }, + { .compatible = "nxp,pcal9535", .data = OF_953X(16, PCA_LATCH_INT), }, + { .compatible = "nxp,pcal9554b", .data = OF_953X( 8, PCA_LATCH_INT), }, + { .compatible = "nxp,pcal9555a", .data = OF_953X(16, PCA_LATCH_INT), }, + { .compatible = "maxim,max7310", .data = OF_953X( 8, 0), }, { .compatible = "maxim,max7312", .data = OF_953X(16, PCA_INT), }, { .compatible = "maxim,max7313", .data = OF_953X(16, PCA_INT), }, { .compatible = "maxim,max7315", .data = OF_953X( 8, PCA_INT), }, + { .compatible = "maxim,max7318", .data = OF_953X(16, PCA_INT), }, { .compatible = "ti,pca6107", .data = OF_953X( 8, PCA_INT), }, + { .compatible = "ti,pca9536", .data = OF_953X( 4, 0), }, { .compatible = "ti,tca6408", .data = OF_953X( 8, PCA_INT), }, { .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), }, { .compatible = "ti,tca6424", .data = OF_953X(24, PCA_INT), }, + { .compatible = "ti,tca9539", .data = OF_953X(16, PCA_INT), }, + + { .compatible = "onnn,cat9554", .data = OF_953X( 8, PCA_INT), }, + { .compatible = "onnn,pca9654", .data = OF_953X( 8, PCA_INT), }, + { .compatible = "onnn,pca9655", .data = OF_953X(16, PCA_INT), }, { .compatible = "exar,xra1202", .data = OF_953X( 8, 0), }, { } -- 2.30.2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] gpio: pca953x: add optional support for regulator and reset GPIO 2023-03-07 10:23 [PATCH 1/3] gpio: gpioinfo: use dev_name to get device name Ahmad Fatoum 2023-03-07 10:23 ` [PATCH 2/3] gpio: pca953x: sync DT compatibles with Linux Ahmad Fatoum @ 2023-03-07 10:23 ` Ahmad Fatoum 2023-03-09 10:51 ` [PATCH 1/3] gpio: gpioinfo: use dev_name to get device name Sascha Hauer 2 siblings, 0 replies; 4+ messages in thread From: Ahmad Fatoum @ 2023-03-07 10:23 UTC (permalink / raw) To: barebox; +Cc: Ahmad Fatoum Traditionally, pca953x have a Power-On Reset mechanism that activates once supply voltage rises over threshold. Newer chips additionally feature a reset input. Add support for both. To not break existing boards, we will ignore failure to claim GPIO or regulator, even if it's just probe deferral. Boards wanting to make use of the newly parsed DT properties should enable deep probe. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- drivers/gpio/gpio-pca953x.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 2a1822ef3bcc..2fafa0325663 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -12,6 +12,8 @@ #include <common.h> #include <malloc.h> #include <driver.h> +#include <gpiod.h> +#include <regulator.h> #include <xfuncs.h> #include <errno.h> #include <i2c/i2c.h> @@ -414,7 +416,8 @@ static int pca953x_probe(struct device *dev) unsigned long driver_data; struct pca953x_platform_data *pdata; struct pca953x_chip *chip; - int ret; + struct regulator *reg; + int reset_gpio, ret; u32 invert = 0; chip = xzalloc(sizeof(struct pca953x_chip)); @@ -437,6 +440,20 @@ static int pca953x_probe(struct device *dev) chip->client = client; + reset_gpio = gpiod_get(dev, "reset", GPIOD_OUT_LOW); + if (!gpio_is_valid(reset_gpio) && reset_gpio != -ENOENT) + dev_warn(dev, "Failed to get 'reset' GPIO (ignored)\n"); + + reg = regulator_get(dev, "vcc"); + if (IS_ERR(reg)) { + dev_warn(dev, "Failed to get 'vcc' regulator (ignored).\n"); + reg = NULL; + } + + ret = regulator_enable(reg); + if (ret) + return dev_err_probe(dev, ret, "failed to enable register\n"); + chip->chip_type = driver_data & (PCA953X_TYPE | PCA957X_TYPE); /* initialize cached registers from their original values. -- 2.30.2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] gpio: gpioinfo: use dev_name to get device name 2023-03-07 10:23 [PATCH 1/3] gpio: gpioinfo: use dev_name to get device name Ahmad Fatoum 2023-03-07 10:23 ` [PATCH 2/3] gpio: pca953x: sync DT compatibles with Linux Ahmad Fatoum 2023-03-07 10:23 ` [PATCH 3/3] gpio: pca953x: add optional support for regulator and reset GPIO Ahmad Fatoum @ 2023-03-09 10:51 ` Sascha Hauer 2 siblings, 0 replies; 4+ messages in thread From: Sascha Hauer @ 2023-03-09 10:51 UTC (permalink / raw) To: Ahmad Fatoum; +Cc: barebox On Tue, Mar 07, 2023 at 11:23:18AM +0100, Ahmad Fatoum wrote: > Otherwise, we don't correctly number devices with dynamic ID. > > Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> > --- > drivers/gpio/gpiolib.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied, thanks Sascha > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index 2e7a39b47552..736279875856 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -716,7 +716,7 @@ static int do_gpiolib(int argc, char *argv[]) > printf("\nGPIOs %u-%u, chip %s:\n", > gi->chip->base, > gi->chip->base + gi->chip->ngpio - 1, > - gi->chip->dev->name); > + dev_name(gi->chip->dev)); > printf(" %-3s %-3s %-9s %-20s %-20s\n", "dir", "val", "requested", "name", "label"); > } > > -- > 2.30.2 > > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-09 10:52 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-03-07 10:23 [PATCH 1/3] gpio: gpioinfo: use dev_name to get device name Ahmad Fatoum 2023-03-07 10:23 ` [PATCH 2/3] gpio: pca953x: sync DT compatibles with Linux Ahmad Fatoum 2023-03-07 10:23 ` [PATCH 3/3] gpio: pca953x: add optional support for regulator and reset GPIO Ahmad Fatoum 2023-03-09 10:51 ` [PATCH 1/3] gpio: gpioinfo: use dev_name to get device name Sascha Hauer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox