Skip to contentSkip to conversation

add enable gpio support for a24 eeprom driver

PATCH In review Eliav Farber 2 participants 5 messages Aug 16, 2022 – Aug 18, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index f9a7c984274c..553b53ed3e4c 100644
@@ -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
maintainer
#2 lore raw

Re: [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.

---
 Documentation/devicetree/bindings/eeprom/at24.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/eeprom/at24.txt +3 -0
index f9a7c984274c..553b53ed3e4c 100644
@@ -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
#3 lore raw

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

#4 lore raw

PATCH 2/2 eeprom: at24: add enable gpio support

In reply to Eliav Farber

Add 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
index dc3537651b80..06535b9e1da5 100644
@@ -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