Commit b8a34582 authored by Shubhrajyoti Datta's avatar Shubhrajyoti Datta Committed by Bartosz Golaszewski

gpio: pca9570: add a platform data structure

Add struct pca9570_platform_data for adding the platform data
structure. Also modify the existing structs for pca9570 and pca9571
Signed-off-by: default avatarShubhrajyoti Datta <shubhrajyoti.datta@amd.com>
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent f7ec74c1
...@@ -15,14 +15,26 @@ ...@@ -15,14 +15,26 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/property.h> #include <linux/property.h>
/**
* struct pca9570_platform_data - GPIO platformdata
* @ngpio: no of gpios
* @command: Command to be sent
*/
struct pca9570_platform_data {
u16 ngpio;
u32 command;
};
/** /**
* struct pca9570 - GPIO driver data * struct pca9570 - GPIO driver data
* @chip: GPIO controller chip * @chip: GPIO controller chip
* @p_data: GPIO controller platform data
* @lock: Protects write sequences * @lock: Protects write sequences
* @out: Buffer for device register * @out: Buffer for device register
*/ */
struct pca9570 { struct pca9570 {
struct gpio_chip chip; struct gpio_chip chip;
const struct pca9570_platform_data *p_data;
struct mutex lock; struct mutex lock;
u8 out; u8 out;
}; };
...@@ -106,7 +118,8 @@ static int pca9570_probe(struct i2c_client *client) ...@@ -106,7 +118,8 @@ static int pca9570_probe(struct i2c_client *client)
gpio->chip.get = pca9570_get; gpio->chip.get = pca9570_get;
gpio->chip.set = pca9570_set; gpio->chip.set = pca9570_set;
gpio->chip.base = -1; gpio->chip.base = -1;
gpio->chip.ngpio = (uintptr_t)device_get_match_data(&client->dev); gpio->p_data = device_get_match_data(&client->dev);
gpio->chip.ngpio = gpio->p_data->ngpio;
gpio->chip.can_sleep = true; gpio->chip.can_sleep = true;
mutex_init(&gpio->lock); mutex_init(&gpio->lock);
...@@ -119,16 +132,24 @@ static int pca9570_probe(struct i2c_client *client) ...@@ -119,16 +132,24 @@ static int pca9570_probe(struct i2c_client *client)
return devm_gpiochip_add_data(&client->dev, &gpio->chip, gpio); return devm_gpiochip_add_data(&client->dev, &gpio->chip, gpio);
} }
static const struct pca9570_platform_data pca9570_gpio = {
.ngpio = 4,
};
static const struct pca9570_platform_data pca9571_gpio = {
.ngpio = 8,
};
static const struct i2c_device_id pca9570_id_table[] = { static const struct i2c_device_id pca9570_id_table[] = {
{ "pca9570", 4 }, { "pca9570", (kernel_ulong_t)&pca9570_gpio},
{ "pca9571", 8 }, { "pca9571", (kernel_ulong_t)&pca9571_gpio },
{ /* sentinel */ } { /* sentinel */ }
}; };
MODULE_DEVICE_TABLE(i2c, pca9570_id_table); MODULE_DEVICE_TABLE(i2c, pca9570_id_table);
static const struct of_device_id pca9570_of_match_table[] = { static const struct of_device_id pca9570_of_match_table[] = {
{ .compatible = "nxp,pca9570", .data = (void *)4 }, { .compatible = "nxp,pca9570", .data = &pca9570_gpio },
{ .compatible = "nxp,pca9571", .data = (void *)8 }, { .compatible = "nxp,pca9571", .data = &pca9571_gpio },
{ /* sentinel */ } { /* sentinel */ }
}; };
MODULE_DEVICE_TABLE(of, pca9570_of_match_table); MODULE_DEVICE_TABLE(of, pca9570_of_match_table);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment