* [PATCH 1/2] dt-bindings: at24: add the 'num-addresses' property
2019-02-05 13:59 [PATCH 0/2] eeprom: at24: new property Bartosz Golaszewski
@ 2019-02-05 13:59 ` Bartosz Golaszewski
2019-02-05 13:59 ` [PATCH 2/2] eeprom: at24: implement support for " Bartosz Golaszewski
2019-02-12 14:12 ` [PATCH 0/2] eeprom: at24: new property Bartosz Golaszewski
2 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-02-05 13:59 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, Arnd Bergmann, Greg Kroah-Hartman
Cc: linux-i2c, devicetree, linux-kernel, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Currently the at24 driver only creates additional i2c dummies for
atmel,24c00 and it's hard-coded. Some other chips (like for example
Microchip's 24AA02T) also take more slave addresses despite being
otherwise compatible with already supported variants.
Add a new property to the device tree binding document that defines
the total number of i2c slave addresses taken by the device. The
addresses are counted starting from the one in the reg property.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
Documentation/devicetree/bindings/eeprom/at24.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/eeprom/at24.txt b/Documentation/devicetree/bindings/eeprom/at24.txt
index f9a7c984274c..0e456bbc1213 100644
--- a/Documentation/devicetree/bindings/eeprom/at24.txt
+++ b/Documentation/devicetree/bindings/eeprom/at24.txt
@@ -75,6 +75,8 @@ Optional properties:
- address-width: number of address bits (one of 8, 16).
+ - num-addresses: total number of i2c slave addresses this device takes
+
Example:
eeprom@52 {
@@ -82,4 +84,5 @@ eeprom@52 {
reg = <0x52>;
pagesize = <32>;
wp-gpios = <&gpio1 3 0>;
+ num-addresses = <8>;
};
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] eeprom: at24: implement support for 'num-addresses' property
2019-02-05 13:59 [PATCH 0/2] eeprom: at24: new property Bartosz Golaszewski
2019-02-05 13:59 ` [PATCH 1/2] dt-bindings: at24: add the 'num-addresses' property Bartosz Golaszewski
@ 2019-02-05 13:59 ` Bartosz Golaszewski
2019-02-12 14:12 ` [PATCH 0/2] eeprom: at24: new property Bartosz Golaszewski
2 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-02-05 13:59 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, Arnd Bergmann, Greg Kroah-Hartman
Cc: linux-i2c, devicetree, linux-kernel, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
If the device node defines 'num-addresses', let it override the default
behavior.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/misc/eeprom/at24.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index b806a403ca46..63aa541c9608 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -641,11 +641,14 @@ static int at24_probe(struct i2c_client *client)
if (!is_power_of_2(page_size))
dev_warn(dev, "page_size looks suspicious (no power of 2)!\n");
- if (flags & AT24_FLAG_TAKE8ADDR)
- num_addresses = 8;
- else
- num_addresses = DIV_ROUND_UP(byte_len,
- (flags & AT24_FLAG_ADDR16) ? 65536 : 256);
+ err = device_property_read_u32(dev, "num-addresses", &num_addresses);
+ if (err) {
+ if (flags & AT24_FLAG_TAKE8ADDR)
+ num_addresses = 8;
+ else
+ num_addresses = DIV_ROUND_UP(byte_len,
+ (flags & AT24_FLAG_ADDR16) ? 65536 : 256);
+ }
if ((flags & AT24_FLAG_SERIAL) && (flags & AT24_FLAG_MAC)) {
dev_err(dev,
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 0/2] eeprom: at24: new property
2019-02-05 13:59 [PATCH 0/2] eeprom: at24: new property Bartosz Golaszewski
2019-02-05 13:59 ` [PATCH 1/2] dt-bindings: at24: add the 'num-addresses' property Bartosz Golaszewski
2019-02-05 13:59 ` [PATCH 2/2] eeprom: at24: implement support for " Bartosz Golaszewski
@ 2019-02-12 14:12 ` Bartosz Golaszewski
2019-02-19 12:39 ` Greg Kroah-Hartman
2 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-02-12 14:12 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, Arnd Bergmann, Greg Kroah-Hartman
Cc: linux-i2c, devicetree, Linux Kernel Mailing List,
Bartosz Golaszewski
wt., 5 lut 2019 o 15:00 Bartosz Golaszewski <brgl@bgdev.pl> napisał(a):
>
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Microchip 24aa02t EEPROM is compatible with Atmel 24c02 except that
> it's visible on 8 i2c slave addresses. We already support such a
> use case with hard-coded config for 'atmel,24c00'. Let's add a more
> flexible device tree property - 'num-addresses' - to the binding
> document and support it in the driver.
>
> Bartosz Golaszewski (2):
> dt-bindings: at24: add the 'num-addresses' property
> eeprom: at24: implement support for 'num-addresses' property
>
> Documentation/devicetree/bindings/eeprom/at24.txt | 3 +++
> drivers/misc/eeprom/at24.c | 13 ++++++++-----
> 2 files changed, 11 insertions(+), 5 deletions(-)
>
> --
> 2.20.1
>
If there are no objections, I will apply these in 2 days and include
them in the PR for v5.1.
Bart
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] eeprom: at24: new property
2019-02-12 14:12 ` [PATCH 0/2] eeprom: at24: new property Bartosz Golaszewski
@ 2019-02-19 12:39 ` Greg Kroah-Hartman
0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2019-02-19 12:39 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Rob Herring, Mark Rutland, Arnd Bergmann, linux-i2c, devicetree,
Linux Kernel Mailing List, Bartosz Golaszewski
On Tue, Feb 12, 2019 at 03:12:05PM +0100, Bartosz Golaszewski wrote:
> wt., 5 lut 2019 o 15:00 Bartosz Golaszewski <brgl@bgdev.pl> napisał(a):
> >
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > Microchip 24aa02t EEPROM is compatible with Atmel 24c02 except that
> > it's visible on 8 i2c slave addresses. We already support such a
> > use case with hard-coded config for 'atmel,24c00'. Let's add a more
> > flexible device tree property - 'num-addresses' - to the binding
> > document and support it in the driver.
> >
> > Bartosz Golaszewski (2):
> > dt-bindings: at24: add the 'num-addresses' property
> > eeprom: at24: implement support for 'num-addresses' property
> >
> > Documentation/devicetree/bindings/eeprom/at24.txt | 3 +++
> > drivers/misc/eeprom/at24.c | 13 ++++++++-----
> > 2 files changed, 11 insertions(+), 5 deletions(-)
> >
> > --
> > 2.20.1
> >
>
> If there are no objections, I will apply these in 2 days and include
> them in the PR for v5.1.
No objections from me:
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 5+ messages in thread