2018-06-29 09:44:02

by Chiang, AlanX

[permalink] [raw]
Subject: [PATCH v4 0/2] Add a property in at24.c

From: Alan Chiang <[email protected]>

In at24.c, it uses 8-bit addressing by default. In this patch,
add a property address-width that provides a flexible method to
pass the information to the driver.

Alan Chiang (2):
dt-bindings: at24: Add address-width property
eeprom: at24: Add support for address-width property

Documentation/devicetree/bindings/eeprom/at24.txt | 2 ++
drivers/misc/eeprom/at24.c | 17 +++++++++++++++++
2 files changed, 19 insertions(+)

--
2.7.4



2018-06-29 09:43:37

by Chiang, AlanX

[permalink] [raw]
Subject: [PATCH v4 1/2] dt-bindings: at24: Add address-width property

From: Alan Chiang <[email protected]>

The AT24 series chips use 8-bit address by default. If some
chips would like to support more than 8 bits, the at24 driver
should be added the compatible field for specfic chips.

Provide a flexible way to determine the addressing bits through
address-width in this patch.

Signed-off-by: Alan Chiang <[email protected]>
Signed-off-by: Andy Yeh <[email protected]>
Acked-by: Sakari Ailus <[email protected]>

---
since v1:
-- Remove the address-width field in the example.
since v2:
-- Remove redundant space.
since v3:
-- Add Acked-by.

---
Documentation/devicetree/bindings/eeprom/at24.txt | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/eeprom/at24.txt b/Documentation/devicetree/bindings/eeprom/at24.txt
index 61d833a..aededdb 100644
--- a/Documentation/devicetree/bindings/eeprom/at24.txt
+++ b/Documentation/devicetree/bindings/eeprom/at24.txt
@@ -72,6 +72,8 @@ Optional properties:

- wp-gpios: GPIO to which the write-protect pin of the chip is connected.

+ - address-width: number of address bits (one of 8, 16).
+
Example:

eeprom@52 {
--
2.7.4


2018-06-29 09:44:32

by Chiang, AlanX

[permalink] [raw]
Subject: [PATCH v4 2/2] eeprom: at24: Add support for address-width property

From: Alan Chiang <[email protected]>

Provide a flexible way to determine the addressing bits of eeprom.
Pass the addressing bits to driver through address-width property.

Signed-off-by: Alan Chiang <[email protected]>
Signed-off-by: Andy Yeh <[email protected]>

---
since v1
-- Add a warn message for 8-bit addressing.
since v2
-- Modify the warning message for clear.
-- Move the clearing bit operation outside of a statement.
since v3
-- Merge the warning message into one line.

---
drivers/misc/eeprom/at24.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 0c125f2..7ea640b 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -478,6 +478,23 @@ static void at24_properties_to_pdata(struct device *dev,
if (device_property_present(dev, "no-read-rollover"))
chip->flags |= AT24_FLAG_NO_RDROL;

+ err = device_property_read_u32(dev, "address-width", &val);
+ if (!err) {
+ switch (val) {
+ case 8:
+ if (chip->flags & AT24_FLAG_ADDR16)
+ dev_warn(dev, "Override address width to be 8, while default is 16\n");
+ chip->flags &= ~AT24_FLAG_ADDR16;
+ break;
+ case 16:
+ chip->flags |= AT24_FLAG_ADDR16;
+ break;
+ default:
+ dev_warn(dev, "Bad \"address-width\" property: %u\n",
+ val);
+ }
+ }
+
err = device_property_read_u32(dev, "size", &val);
if (!err)
chip->byte_len = val;
--
2.7.4


2018-06-29 09:47:13

by Sakari Ailus

[permalink] [raw]
Subject: Re: [PATCH v4 2/2] eeprom: at24: Add support for address-width property

On Fri, Jun 29, 2018 at 03:21:55PM +0800, [email protected] wrote:
> From: Alan Chiang <[email protected]>
>
> Provide a flexible way to determine the addressing bits of eeprom.
> Pass the addressing bits to driver through address-width property.
>
> Signed-off-by: Alan Chiang <[email protected]>
> Signed-off-by: Andy Yeh <[email protected]>

Acked-by: Sakari Ailus <[email protected]>

--
Sakari Ailus
[email protected]

2018-06-29 17:32:48

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v4 2/2] eeprom: at24: Add support for address-width property

On Fri, 2018-06-29 at 15:21 +0800, [email protected] wrote:
> From: Alan Chiang <[email protected]>
>
> Provide a flexible way to determine the addressing bits of eeprom.
> Pass the addressing bits to driver through address-width property.
>

Reviewed-by: Andy Shevchenko <[email protected]>

> Signed-off-by: Alan Chiang <[email protected]>
> Signed-off-by: Andy Yeh <[email protected]>
>
> ---
> since v1
> -- Add a warn message for 8-bit addressing.
> since v2
> -- Modify the warning message for clear.
> -- Move the clearing bit operation outside of a statement.
> since v3
> -- Merge the warning message into one line.
>
> ---
> drivers/misc/eeprom/at24.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> index 0c125f2..7ea640b 100644
> --- a/drivers/misc/eeprom/at24.c
> +++ b/drivers/misc/eeprom/at24.c
> @@ -478,6 +478,23 @@ static void at24_properties_to_pdata(struct
> device *dev,
> if (device_property_present(dev, "no-read-rollover"))
> chip->flags |= AT24_FLAG_NO_RDROL;
>
> + err = device_property_read_u32(dev, "address-width", &val);
> + if (!err) {
> + switch (val) {
> + case 8:
> + if (chip->flags & AT24_FLAG_ADDR16)
> + dev_warn(dev, "Override address width
> to be 8, while default is 16\n");
> + chip->flags &= ~AT24_FLAG_ADDR16;
> + break;
> + case 16:
> + chip->flags |= AT24_FLAG_ADDR16;
> + break;
> + default:
> + dev_warn(dev, "Bad \"address-width\"
> property: %u\n",
> + val);
> + }
> + }
> +
> err = device_property_read_u32(dev, "size", &val);
> if (!err)
> chip->byte_len = val;

--
Andy Shevchenko <[email protected]>
Intel Finland Oy