* small pca953x update and fix for of. @ 2015-12-08 10:19 Ben Dooks 2015-12-08 10:19 ` [PATCH 1/2] gpio: pca953x: add onsemi,pca9654 id Ben Dooks 2015-12-08 10:19 ` [PATCH 2/2] gpio: pca935x: fix of-only probed devices Ben Dooks 0 siblings, 2 replies; 6+ messages in thread From: Ben Dooks @ 2015-12-08 10:19 UTC (permalink / raw) To: ben.dooks, linus.walleij, gnurou, linux-gpio When adding support for the OnSemi PCA9654 device to the pca953x driver it was found that the driver did not work with of probing. This small series adds the of-id for onsemi,pca9654 and fixes the of-only probe. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] gpio: pca953x: add onsemi,pca9654 id 2015-12-08 10:19 small pca953x update and fix for of Ben Dooks @ 2015-12-08 10:19 ` Ben Dooks 2015-12-09 7:05 ` Linus Walleij 2015-12-08 10:19 ` [PATCH 2/2] gpio: pca935x: fix of-only probed devices Ben Dooks 1 sibling, 1 reply; 6+ messages in thread From: Ben Dooks @ 2015-12-08 10:19 UTC (permalink / raw) To: ben.dooks, linus.walleij, gnurou, linux-gpio Add onsemi,pca9654 which is also compatible with the nxp,pca9524 as it is an 8bit expander with an interrupt output. Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> --- Documentation/devicetree/bindings/gpio/gpio-pca953x.txt | 1 + drivers/gpio/gpio-pca953x.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt b/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt index 13df993..6b4a98f 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt +++ b/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt @@ -25,6 +25,7 @@ Required properties: ti,tca6416 ti,tca6424 ti,tca9539 + onsemi,pca9654 exar,xra1202 Example: diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 2d4892c..9847931 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -781,6 +781,8 @@ static const struct of_device_id pca953x_dt_ids[] = { { .compatible = "ti,tca6416", }, { .compatible = "ti,tca6424", }, + { .compatible = "onsemi,pca9654" }, + { .compatible = "exar,xra1202", }, { } }; -- 2.6.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] gpio: pca953x: add onsemi,pca9654 id 2015-12-08 10:19 ` [PATCH 1/2] gpio: pca953x: add onsemi,pca9654 id Ben Dooks @ 2015-12-09 7:05 ` Linus Walleij 2015-12-09 9:33 ` Ben Dooks 0 siblings, 1 reply; 6+ messages in thread From: Linus Walleij @ 2015-12-09 7:05 UTC (permalink / raw) To: Ben Dooks; +Cc: Alexandre Courbot, linux-gpio@vger.kernel.org On Tue, Dec 8, 2015 at 11:19 AM, Ben Dooks <ben.dooks@codethink.co.uk> wrote: > Add onsemi,pca9654 which is also compatible with the nxp,pca9524 as it > is an 8bit expander with an interrupt output. > > Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Patch applied. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] gpio: pca953x: add onsemi,pca9654 id 2015-12-09 7:05 ` Linus Walleij @ 2015-12-09 9:33 ` Ben Dooks 0 siblings, 0 replies; 6+ messages in thread From: Ben Dooks @ 2015-12-09 9:33 UTC (permalink / raw) To: Linus Walleij; +Cc: Alexandre Courbot, linux-gpio@vger.kernel.org On 09/12/15 07:05, Linus Walleij wrote: > On Tue, Dec 8, 2015 at 11:19 AM, Ben Dooks <ben.dooks@codethink.co.uk> wrote: > >> Add onsemi,pca9654 which is also compatible with the nxp,pca9524 as it >> is an 8bit expander with an interrupt output. >> >> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> > > Patch applied. > > Yours, > Linus Walleij Thank you. -- Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] gpio: pca935x: fix of-only probed devices 2015-12-08 10:19 small pca953x update and fix for of Ben Dooks 2015-12-08 10:19 ` [PATCH 1/2] gpio: pca953x: add onsemi,pca9654 id Ben Dooks @ 2015-12-08 10:19 ` Ben Dooks 2015-12-09 7:07 ` Linus Walleij 1 sibling, 1 reply; 6+ messages in thread From: Ben Dooks @ 2015-12-08 10:19 UTC (permalink / raw) To: ben.dooks, linus.walleij, gnurou, linux-gpio If the pca953x device is probed from OF using the proper OF probing then the i2c-client will be NULL and the device probe will fail as id is NULL and it isn't an ACPI device (previous drivers would simply OOPS out). Add support for the of_device_id table having the same data as the others so that the correct paths will be taken when registering a device. An example of current valid of node which did not work: gpio@38 { compatible = "onsemi,pca9654", "nxp,pca9534"; reg = <0x38>; interrupt-parent = <&gpio5>; interrupts = <25 IRQ_TYPE_LEVEL_LOW>; }; Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> --- drivers/gpio/gpio-pca953x.c | 76 ++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 9847931..4881774 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -660,6 +660,8 @@ out: return ret; } +static const struct of_device_id pca953x_dt_ids[]; + static int pca953x_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -691,12 +693,18 @@ static int pca953x_probe(struct i2c_client *client, chip->driver_data = id->driver_data; } else { const struct acpi_device_id *id; + const struct of_device_id *match; - id = acpi_match_device(pca953x_acpi_ids, &client->dev); - if (!id) - return -ENODEV; + match = of_match_device(pca953x_dt_ids, &client->dev); + if (match) { + chip->driver_data = (int)(uintptr_t)match->data; + } else { + id = acpi_match_device(pca953x_acpi_ids, &client->dev); + if (!id) + return -ENODEV; - chip->driver_data = id->driver_data; + chip->driver_data = id->driver_data; + } } chip->chip_type = PCA_CHIP_TYPE(chip->driver_data); @@ -755,35 +763,39 @@ static int pca953x_remove(struct i2c_client *client) return 0; } +/* convenience to stop overlong match-table lines */ +#define OF_953X(__nrgpio, __int) (void *)(__nrgpio | PCA953X_TYPE | __int) +#define OF_957X(__nrgpio, __int) (void *)(__nrgpio | PCA957X_TYPE | __int) + static const struct of_device_id pca953x_dt_ids[] = { - { .compatible = "nxp,pca9505", }, - { .compatible = "nxp,pca9534", }, - { .compatible = "nxp,pca9535", }, - { .compatible = "nxp,pca9536", }, - { .compatible = "nxp,pca9537", }, - { .compatible = "nxp,pca9538", }, - { .compatible = "nxp,pca9539", }, - { .compatible = "nxp,pca9554", }, - { .compatible = "nxp,pca9555", }, - { .compatible = "nxp,pca9556", }, - { .compatible = "nxp,pca9557", }, - { .compatible = "nxp,pca9574", }, - { .compatible = "nxp,pca9575", }, - { .compatible = "nxp,pca9698", }, - - { .compatible = "maxim,max7310", }, - { .compatible = "maxim,max7312", }, - { .compatible = "maxim,max7313", }, - { .compatible = "maxim,max7315", }, - - { .compatible = "ti,pca6107", }, - { .compatible = "ti,tca6408", }, - { .compatible = "ti,tca6416", }, - { .compatible = "ti,tca6424", }, - - { .compatible = "onsemi,pca9654" }, - - { .compatible = "exar,xra1202", }, + { .compatible = "nxp,pca9505", .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), }, + { .compatible = "nxp,pca9537", .data = OF_953X( 4, PCA_INT), }, + { .compatible = "nxp,pca9538", .data = OF_953X( 8, PCA_INT), }, + { .compatible = "nxp,pca9539", .data = OF_953X(16, PCA_INT), }, + { .compatible = "nxp,pca9554", .data = OF_953X( 8, PCA_INT), }, + { .compatible = "nxp,pca9555", .data = OF_953X(16, PCA_INT), }, + { .compatible = "nxp,pca9556", .data = OF_953X( 8, 0), }, + { .compatible = "nxp,pca9557", .data = OF_953X( 8, 0), }, + { .compatible = "nxp,pca9574", .data = OF_957X( 8, PCA_INT), }, + { .compatible = "nxp,pca9575", .data = OF_957X(16, PCA_INT), }, + { .compatible = "nxp,pca9698", .data = OF_953X(40, 0), }, + + { .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 = "ti,pca6107", .data = OF_953X( 8, PCA_INT), }, + { .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 = "onsemi,pca9654", .data = OF_953X( 8, PCA_INT), }, + + { .compatible = "exar,xra1202", .data = OF_953X( 8, 0), }, { } }; -- 2.6.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] gpio: pca935x: fix of-only probed devices 2015-12-08 10:19 ` [PATCH 2/2] gpio: pca935x: fix of-only probed devices Ben Dooks @ 2015-12-09 7:07 ` Linus Walleij 0 siblings, 0 replies; 6+ messages in thread From: Linus Walleij @ 2015-12-09 7:07 UTC (permalink / raw) To: Ben Dooks; +Cc: Alexandre Courbot, linux-gpio@vger.kernel.org On Tue, Dec 8, 2015 at 11:19 AM, Ben Dooks <ben.dooks@codethink.co.uk> wrote: > If the pca953x device is probed from OF using the proper OF probing then > the i2c-client will be NULL and the device probe will fail as id is NULL > and it isn't an ACPI device (previous drivers would simply OOPS out). > > Add support for the of_device_id table having the same data as the others > so that the correct paths will be taken when registering a device. > > An example of current valid of node which did not work: > > gpio@38 { > compatible = "onsemi,pca9654", "nxp,pca9534"; > reg = <0x38>; > interrupt-parent = <&gpio5>; > interrupts = <25 IRQ_TYPE_LEVEL_LOW>; > }; > > Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Patch applied. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-12-09 9:33 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-12-08 10:19 small pca953x update and fix for of Ben Dooks 2015-12-08 10:19 ` [PATCH 1/2] gpio: pca953x: add onsemi,pca9654 id Ben Dooks 2015-12-09 7:05 ` Linus Walleij 2015-12-09 9:33 ` Ben Dooks 2015-12-08 10:19 ` [PATCH 2/2] gpio: pca935x: fix of-only probed devices Ben Dooks 2015-12-09 7:07 ` 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).