forked from mirrors/linux
		
	gpio: pca9570: add slg7xl45106 support
Dialog semiconductors SLG7XL45106 is an 8-bit I2C GPO expander. The output port is controlled by a data byte with register address. Add a compatible string for the same. Also update the driver to write and read from it. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
		
							parent
							
								
									b8a34582c7
								
							
						
					
					
						commit
						fbb19fe17e
					
				
					 1 changed files with 17 additions and 1 deletions
				
			
		|  | @ -15,6 +15,8 @@ | ||||||
| #include <linux/mutex.h> | #include <linux/mutex.h> | ||||||
| #include <linux/property.h> | #include <linux/property.h> | ||||||
| 
 | 
 | ||||||
|  | #define SLG7XL45106_GPO_REG	0xDB | ||||||
|  | 
 | ||||||
| /**
 | /**
 | ||||||
|  * struct pca9570_platform_data - GPIO platformdata |  * struct pca9570_platform_data - GPIO platformdata | ||||||
|  * @ngpio: no of gpios |  * @ngpio: no of gpios | ||||||
|  | @ -44,7 +46,11 @@ static int pca9570_read(struct pca9570 *gpio, u8 *value) | ||||||
| 	struct i2c_client *client = to_i2c_client(gpio->chip.parent); | 	struct i2c_client *client = to_i2c_client(gpio->chip.parent); | ||||||
| 	int ret; | 	int ret; | ||||||
| 
 | 
 | ||||||
| 	ret = i2c_smbus_read_byte(client); | 	if (gpio->p_data->command != 0) | ||||||
|  | 		ret = i2c_smbus_read_byte_data(client, gpio->p_data->command); | ||||||
|  | 	else | ||||||
|  | 		ret = i2c_smbus_read_byte(client); | ||||||
|  | 
 | ||||||
| 	if (ret < 0) | 	if (ret < 0) | ||||||
| 		return ret; | 		return ret; | ||||||
| 
 | 
 | ||||||
|  | @ -56,6 +62,9 @@ static int pca9570_write(struct pca9570 *gpio, u8 value) | ||||||
| { | { | ||||||
| 	struct i2c_client *client = to_i2c_client(gpio->chip.parent); | 	struct i2c_client *client = to_i2c_client(gpio->chip.parent); | ||||||
| 
 | 
 | ||||||
|  | 	if (gpio->p_data->command != 0) | ||||||
|  | 		return i2c_smbus_write_byte_data(client, gpio->p_data->command, value); | ||||||
|  | 
 | ||||||
| 	return i2c_smbus_write_byte(client, value); | 	return i2c_smbus_write_byte(client, value); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -140,14 +149,21 @@ static const struct pca9570_platform_data pca9571_gpio = { | ||||||
| 	.ngpio = 8, | 	.ngpio = 8, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | static const struct pca9570_platform_data slg7xl45106_gpio = { | ||||||
|  | 	.ngpio = 8, | ||||||
|  | 	.command = SLG7XL45106_GPO_REG, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| static const struct i2c_device_id pca9570_id_table[] = { | static const struct i2c_device_id pca9570_id_table[] = { | ||||||
| 	{ "pca9570", (kernel_ulong_t)&pca9570_gpio}, | 	{ "pca9570", (kernel_ulong_t)&pca9570_gpio}, | ||||||
| 	{ "pca9571", (kernel_ulong_t)&pca9571_gpio }, | 	{ "pca9571", (kernel_ulong_t)&pca9571_gpio }, | ||||||
|  | 	{ "slg7xl45106", (kernel_ulong_t)&slg7xl45106_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 = "dlg,slg7xl45106", .data = &slg7xl45106_gpio}, | ||||||
| 	{ .compatible = "nxp,pca9570", .data = &pca9570_gpio }, | 	{ .compatible = "nxp,pca9570", .data = &pca9570_gpio }, | ||||||
| 	{ .compatible = "nxp,pca9571", .data = &pca9571_gpio }, | 	{ .compatible = "nxp,pca9571", .data = &pca9571_gpio }, | ||||||
| 	{ /* sentinel */ } | 	{ /* sentinel */ } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Shubhrajyoti Datta
						Shubhrajyoti Datta