add enable gpio support for a24 eeprom driver
cover add enable gpio support for a24 eeprom driver
First patch describes the new binding property. Second patch adds the functionality to the driver.
Eliav Farber (2):
dt-bindings: at24: new optional property - enable-gpios
eeprom: at24: add enable gpio support
Documentation/devicetree/bindings/eeprom/at24.txt | 3 +++ drivers/misc/eeprom/at24.c | 5 +++++ 2 files changed, 8 insertions(+)
Signature · 1 line
2.37.1
PATCH 1/2 dt-bindings: at24: new optional property - enable-gpios
Boards using the AT24 EEPROMs might have a GPIO that must be set to enable the chip (e.g. pin that controls the power supply).
Add a new optional property to the device tree binding document, which allows to specify the GPIO line to which the enable pin is connected.
On Linux this means that we need to hog the line at the beginning of probe function.
--- Documentation/devicetree/bindings/eeprom/at24.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/eeprom/at24.txt +3 -0
@@ -73,6 +73,9 @@ Optional properties: - wp-gpios: GPIO to which the write-protect pin of the chip is connected. + - enable-gpios: GPIO to enables the chip (e.g. pin that controls the eeprom + power supply). + - address-width: number of address bits (one of 8, 16). Example:
Signature · 1 line
2.37.1
Rob Herring
maintainerRe: [PATCH 1/2] dt-bindings: at24: new optional property - enable-gpios
Quoted 3 lines · Eliav Farber
Boards using the AT24 EEPROMs might have a GPIO that must be set to enable the chip (e.g. pin that controls the power supply).
If this is a power supply control, use a gpio regulator.
Quoted 28 lines
Add a new optional property to the device tree binding document, which allows to specify the GPIO line to which the enable pin is connected.
On Linux this means that we need to hog the line at the beginning of probe function.
Signed-off-by Eliav Farber <[email protected]>--- Documentation/devicetree/bindings/eeprom/at24.txt | 3 +++ 1 file changed, 3 insertions(+)Documentation/devicetree/bindings/eeprom/at24.txt +3
-0@@ -73,6 +73,9 @@ Optional properties: - wp-gpios: GPIO to which the write-protect pin of the chip is connected. + - enable-gpios: GPIO to enables the chip (e.g. pin that controls the eeprom + power supply). + - address-width: number of address bits (one of 8, 16). Example:Signature · 1 line
2.37.1
Re: [PATCH 1/2] dt-bindings: at24: new optional property - enable-gpios
Quoted 1 line · Rob Herring
If this is a power supply control, use a gpio regulator.
It is indeed a power supply control.
I'll push a new series that uses a gpio regulator.
--
Thanks, Eliav
PATCH 2/2 eeprom: at24: add enable gpio support
In reply to Eliav FarberAdd gpio support to enable the eeprom device as part of probe sequence.
--- drivers/misc/eeprom/at24.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/misc/eeprom/at24.c +5 -0
@@ -623,6 +623,7 @@ static int at24_probe(struct i2c_client *client)struct device *dev = &client->dev;bool i2c_fn_i2c, i2c_fn_block;unsigned int i, num_addresses; +struct gpio_desc *enable_gpio;struct at24_data *at24;struct regmap *regmap;size_t at24_size;
@@ -630,6 +631,10 @@ static int at24_probe(struct i2c_client *client)u8 test_byte;int err; + enable_gpio =devm_gpiod_get_optional (dev,"enable" ,GPIOD_OUT_HIGH ); +if (IS_ERR (enable_gpio)) +return PTR_ERR (enable_gpio); + i2c_fn_i2c =i2c_check_functionality (client->adapter,I2C_FUNC_I2C ); i2c_fn_block =i2c_check_functionality (client->adapter,I2C_FUNC_SMBUS_WRITE_I2C_BLOCK );
Signature · 1 line
2.37.1