All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Add a property in at24.c
@ 2018-06-27  5:46 alanx.chiang
  2018-06-27  5:46 ` [PATCH v3 1/2] dt-bindings: at24: Add address-width property alanx.chiang
  2018-06-27  5:46 ` [PATCH v3 2/2] eeprom: at24: Add support for " alanx.chiang
  0 siblings, 2 replies; 8+ messages in thread
From: alanx.chiang @ 2018-06-27  5:46 UTC (permalink / raw)
  To: linux-i2c
  Cc: andy.yeh, sakari.ailus, andriy.shevchenko, andriy.shevchenko,
	rajmohan.mani, andy.shevchenko, tfiga, jcliang, brgl, robh+dt,
	mark.rutland, arnd, gregkh, linux-kernel, devicetree,
	Alan Chiang

From: Alan Chiang <alanx.chiang@intel.com>

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                        | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3 1/2] dt-bindings: at24: Add address-width property
  2018-06-27  5:46 [PATCH v3 0/2] Add a property in at24.c alanx.chiang
@ 2018-06-27  5:46 ` alanx.chiang
  2018-06-27  7:59   ` Sakari Ailus
  2018-06-27  8:19   ` Bartosz Golaszewski
  2018-06-27  5:46 ` [PATCH v3 2/2] eeprom: at24: Add support for " alanx.chiang
  1 sibling, 2 replies; 8+ messages in thread
From: alanx.chiang @ 2018-06-27  5:46 UTC (permalink / raw)
  To: linux-i2c
  Cc: andy.yeh, sakari.ailus, andriy.shevchenko, andriy.shevchenko,
	rajmohan.mani, andy.shevchenko, tfiga, jcliang, brgl, robh+dt,
	mark.rutland, arnd, gregkh, linux-kernel, devicetree,
	Alan Chiang

From: Alan Chiang <alanx.chiang@intel.com>

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 <alanx.chiang@intel.com>
Signed-off-by: Andy Yeh <andy.yeh@intel.com>

---
since v1:
-- Remove the address-width field in the example.
since v2:
-- Remove redundant space.

---
 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 2/2] eeprom: at24: Add support for address-width property
  2018-06-27  5:46 [PATCH v3 0/2] Add a property in at24.c alanx.chiang
  2018-06-27  5:46 ` [PATCH v3 1/2] dt-bindings: at24: Add address-width property alanx.chiang
@ 2018-06-27  5:46 ` alanx.chiang
  2018-06-27  7:46   ` Sakari Ailus
  1 sibling, 1 reply; 8+ messages in thread
From: alanx.chiang @ 2018-06-27  5:46 UTC (permalink / raw)
  To: linux-i2c
  Cc: andy.yeh, sakari.ailus, andriy.shevchenko, andriy.shevchenko,
	rajmohan.mani, andy.shevchenko, tfiga, jcliang, brgl, robh+dt,
	mark.rutland, arnd, gregkh, linux-kernel, devicetree,
	Alan Chiang

From: Alan Chiang <alanx.chiang@intel.com>

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 <alanx.chiang@intel.com>
Signed-off-by: Andy Yeh <andy.yeh@intel.com>

---
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.

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

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 0c125f2..d606f3b 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -478,6 +478,24 @@ 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] eeprom: at24: Add support for address-width property
  2018-06-27  5:46 ` [PATCH v3 2/2] eeprom: at24: Add support for " alanx.chiang
@ 2018-06-27  7:46   ` Sakari Ailus
  0 siblings, 0 replies; 8+ messages in thread
From: Sakari Ailus @ 2018-06-27  7:46 UTC (permalink / raw)
  To: alanx.chiang
  Cc: linux-i2c, andy.yeh, andriy.shevchenko, andriy.shevchenko,
	rajmohan.mani, andy.shevchenko, tfiga, jcliang, brgl, robh+dt,
	mark.rutland, arnd, gregkh, linux-kernel, devicetree

On Wed, Jun 27, 2018 at 01:46:25PM +0800, alanx.chiang@intel.com wrote:
> From: Alan Chiang <alanx.chiang@intel.com>
> 
> 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 <alanx.chiang@intel.com>
> Signed-off-by: Andy Yeh <andy.yeh@intel.com>
> 
> ---
> 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.
> 
> ---
>  drivers/misc/eeprom/at24.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> index 0c125f2..d606f3b 100644
> --- a/drivers/misc/eeprom/at24.c
> +++ b/drivers/misc/eeprom/at24.c
> @@ -478,6 +478,24 @@ 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");

Please don't wrap strings --- it breaks grep. Exceeding 80 is ok in this
case.

> +			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
> 

-- 
Sakari Ailus
sakari.ailus@linux.intel.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/2] dt-bindings: at24: Add address-width property
  2018-06-27  5:46 ` [PATCH v3 1/2] dt-bindings: at24: Add address-width property alanx.chiang
@ 2018-06-27  7:59   ` Sakari Ailus
  2018-06-27  8:19   ` Bartosz Golaszewski
  1 sibling, 0 replies; 8+ messages in thread
From: Sakari Ailus @ 2018-06-27  7:59 UTC (permalink / raw)
  To: alanx.chiang
  Cc: linux-i2c, andy.yeh, andriy.shevchenko, andriy.shevchenko,
	rajmohan.mani, andy.shevchenko, tfiga, jcliang, brgl, robh+dt,
	mark.rutland, arnd, gregkh, linux-kernel, devicetree

On Wed, Jun 27, 2018 at 01:46:24PM +0800, alanx.chiang@intel.com wrote:
> From: Alan Chiang <alanx.chiang@intel.com>
> 
> 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 <alanx.chiang@intel.com>
> Signed-off-by: Andy Yeh <andy.yeh@intel.com>

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus
sakari.ailus@linux.intel.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/2] dt-bindings: at24: Add address-width property
  2018-06-27  5:46 ` [PATCH v3 1/2] dt-bindings: at24: Add address-width property alanx.chiang
  2018-06-27  7:59   ` Sakari Ailus
@ 2018-06-27  8:19   ` Bartosz Golaszewski
  2018-06-27  9:40     ` Sakari Ailus
  1 sibling, 1 reply; 8+ messages in thread
From: Bartosz Golaszewski @ 2018-06-27  8:19 UTC (permalink / raw)
  To: alanx.chiang
  Cc: linux-i2c, andy.yeh, Sakari Ailus, Andy Shevchenko,
	andriy.shevchenko, Rajmohan Mani, Andy Shevchenko, tfiga,
	jcliang, Rob Herring, Mark Rutland, Arnd Bergmann,
	Greg Kroah-Hartman, Linux Kernel Mailing List, devicetree

2018-06-27 7:46 GMT+02:00  <alanx.chiang@intel.com>:
> From: Alan Chiang <alanx.chiang@intel.com>
>
> 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 <alanx.chiang@intel.com>
> Signed-off-by: Andy Yeh <andy.yeh@intel.com>
>
> ---
> since v1:
> -- Remove the address-width field in the example.
> since v2:
> -- Remove redundant space.
>
> ---
>  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
>

Rob,

we only have two possibilities here and the default is 8 bits.

What do you think about introducing a boolean property here called:
'address-width-16' instead of an integer?

Best regards,
Bartosz Golaszewski

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/2] dt-bindings: at24: Add address-width property
  2018-06-27  8:19   ` Bartosz Golaszewski
@ 2018-06-27  9:40     ` Sakari Ailus
  2018-06-27 11:41       ` Andy Shevchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Sakari Ailus @ 2018-06-27  9:40 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: alanx.chiang, linux-i2c, andy.yeh, Andy Shevchenko,
	andriy.shevchenko, Rajmohan Mani, Andy Shevchenko, tfiga,
	jcliang, Rob Herring, Mark Rutland, Arnd Bergmann,
	Greg Kroah-Hartman, Linux Kernel Mailing List, devicetree

On Wed, Jun 27, 2018 at 10:19:38AM +0200, Bartosz Golaszewski wrote:
> 2018-06-27 7:46 GMT+02:00  <alanx.chiang@intel.com>:
> > From: Alan Chiang <alanx.chiang@intel.com>
> >
> > 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 <alanx.chiang@intel.com>
> > Signed-off-by: Andy Yeh <andy.yeh@intel.com>
> >
> > ---
> > since v1:
> > -- Remove the address-width field in the example.
> > since v2:
> > -- Remove redundant space.
> >
> > ---
> >  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
> >
> 
> Rob,
> 
> we only have two possibilities here and the default is 8 bits.
> 
> What do you think about introducing a boolean property here called:
> 'address-width-16' instead of an integer?

I'd have thought the same, but it turns out address-width is already being
used by the at25 bindings:

Documentation/devicetree/bindings/eeprom/at25.txt

-- 
Sakari Ailus
sakari.ailus@linux.intel.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/2] dt-bindings: at24: Add address-width property
  2018-06-27  9:40     ` Sakari Ailus
@ 2018-06-27 11:41       ` Andy Shevchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2018-06-27 11:41 UTC (permalink / raw)
  To: Sakari Ailus, Bartosz Golaszewski
  Cc: alanx.chiang, linux-i2c, andy.yeh, Rajmohan Mani,
	Andy Shevchenko, tfiga, jcliang, Rob Herring, Mark Rutland,
	Arnd Bergmann, Greg Kroah-Hartman, Linux Kernel Mailing List,
	devicetree

On Wed, 2018-06-27 at 12:40 +0300, Sakari Ailus wrote:
> On Wed, Jun 27, 2018 at 10:19:38AM +0200, Bartosz Golaszewski wrote:
> > 2018-06-27 7:46 GMT+02:00  <alanx.chiang@intel.com>:
> > > From: Alan Chiang <alanx.chiang@intel.com>
> > > 
> > > 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 <alanx.chiang@intel.com>
> > > Signed-off-by: Andy Yeh <andy.yeh@intel.com>
> > > 
> > > ---
> > > since v1:
> > > -- Remove the address-width field in the example.
> > > since v2:
> > > -- Remove redundant space.
> > > 
> > > ---
> > >  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
> > > 
> > 
> > Rob,
> > 
> > we only have two possibilities here and the default is 8 bits.
> > 
> > What do you think about introducing a boolean property here called:
> > 'address-width-16' instead of an integer?
> 
> I'd have thought the same, but it turns out address-width is already
> being
> used by the at25 bindings:
> 
> Documentation/devicetree/bindings/eeprom/at25.txt
> 

Agree with Sakari, there is no need to evolve a chaos in DT bindings. We
have too many semi-hemi-duplications in bindings. Especially in this
case we have already established property by a similar driver.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-06-27 11:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-27  5:46 [PATCH v3 0/2] Add a property in at24.c alanx.chiang
2018-06-27  5:46 ` [PATCH v3 1/2] dt-bindings: at24: Add address-width property alanx.chiang
2018-06-27  7:59   ` Sakari Ailus
2018-06-27  8:19   ` Bartosz Golaszewski
2018-06-27  9:40     ` Sakari Ailus
2018-06-27 11:41       ` Andy Shevchenko
2018-06-27  5:46 ` [PATCH v3 2/2] eeprom: at24: Add support for " alanx.chiang
2018-06-27  7:46   ` Sakari Ailus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.