Add DT bindings for the pcf857x-compatible chips and parse the device[...]
tree node in the driver.
Signed-off-by: Laurent Pinchart<laurent.pinchart+renesas@xxxxxxxxxxxxxxxx>
---
.../devicetree/bindings/gpio/gpio-pcf857x.txt | 71 ++++++++++++++++++++++
drivers/gpio/gpio-pcf857x.c | 57 ++++++++++++++---
2 files changed, 119 insertions(+), 9 deletions(-)
create mode 100644 Documentation/devicetree/bindings/gpio/gpio-pcf857x.txt
Changes since v2
- Replace mention about interrupts software configuration in DT bindings
documentation with an explanation of the hardware configuration.
@@ -257,14 +280,29 @@ fail:
static int pcf857x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
- struct pcf857x_platform_data *pdata;
+ struct pcf857x_platform_data *pdata = dev_get_platdata(&client->dev);
+ struct device_node *np = client->dev.of_node;
struct pcf857x *gpio;
+ unsigned int n_latch = 0;
+ unsigned int ngpio;
int status;
- pdata = dev_get_platdata(&client->dev);
- if (!pdata) {
+#ifdef CONFIG_OF
+ if (np) {
+ const struct of_device_id *of_id;
+
+ of_id = of_match_device(pcf857x_of_table,&client->dev);
+ ngpio = (unsigned int)of_id->data;
+ } else
+#endif
+ ngpio = id->driver_data;
+
+ if (pdata)
+ n_latch = pdata->n_latch;
+ else if (IS_ENABLED(CONFIG_OF)&& np)
+ of_property_read_u32(np, "pins-initial-state",&n_latch);
+ else
dev_dbg(&client->dev, "no platform data\n");
- }
/* Allocate, initialize, and register this gpio_chip. */
gpio = devm_kzalloc(&client->dev, sizeof(*gpio), GFP_KERNEL);