Skip to contentSkip to conversation

at25: DeviceTree support added

PATCH In review Frederic LAMBERT 2 participants 3 messages Dec 18, 2011 1 message not in the archive

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

PATCH 1/1 at25: DeviceTree support added

From: Frederic Lambert <[email protected]>

---
 Documentation/devicetree/bindings/spi/spi-bus.txt |   19 ++++++
 drivers/misc/eeprom/at25.c                        |   62 ++++++++++++++++----
 2 files changed, 68 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/spi/spi-bus.txt +19 -0
index e782add..168ac87 100644
@@ -33,6 +33,16 @@ contain the following properties.
     		shifted clock phase (CPHA) mode
 - spi-cs-high     - (optional) Empty property indicating device requires
     		chip select active high
+For SPI eeprom using driver 'at25', slave nodes shall also contain the
+following properties.
+- byte_len        - device RAM size
+- dev_name        - device name
+- pagesize        - for writes (see at25.c)
+- flags           - adressing mode and R/O flag
+      - bit 0:  8 bits addrs (EE_ADDR1)
+      - bit 1: 16 bits addrs (EE_ADDR2)
+      - bit 2: 24 bits addrs (EE_ADDR3)
+      - bit 3: disallow writes (EE_READONLY)
 
 SPI example for an MPC5200 SPI bus:
 	spi@f00 {
@@ -54,4 +64,13 @@ SPI example for an MPC5200 SPI bus:
 			spi-max-frequency = <100000>;
 			reg = <1>;
 		};
+		at25@0 {
+			compatible = "eeprom,at25";
+			spi-max-frequency = <2500000>;
+			reg = <3>;
+			byte_len = <131072>;
+			dev_name = "CY14B101P";
+			pagesize = <128>;
+			flags = <4>; // EE_ADDR3
+		};
 	};
drivers/misc/eeprom/at25.c +49 -13

118 lines not on this page · raw message

Signature · 1 line
1.7.4.1

A message that is not in the archive (sent off-list or not yet received): CAMVnO+mCHQtyO3xUQJqoPSbBnDB0Avr0EEVKpEF31GpyQS-snw@mail.gmail.com

#2 lore raw

Patch cleaned and without line wrapped this time (Sorry for the extra "Signed-off-by").
This driver is really useful for lots of devices, not only EEPROMs (I'm using it with a nvSRAM from Cypres...), and the DTS support was really missing.

Hoping it can be useful to other people,

Best regards,
Frederic

2011/12/18 Frederic LAMBERT <[email protected]>

Quoted 10 lines

From: Frederic Lambert <[email protected]>

---
 Documentation/devicetree/bindings/spi/spi-bus.txt |   19 ++++++ drivers/misc/eeprom/at25.c                        |   62 ++++++++++++++++----

 2 files changed, 68 insertions(+), 13 deletions(-)

...

#3 lore raw
In reply to Frederic LAMBERT

Hi,

please also CC [email protected] when adding new bindings.

Quoted 4 lines · Frederic LAMBERT

From: Frederic Lambert <[email protected]>

One is enough :)

Quoted 27 lines
---
 Documentation/devicetree/bindings/spi/spi-bus.txt |   19 ++++++
 drivers/misc/eeprom/at25.c                        |   62 ++++++++++++++++----
 2 files changed, 68 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/spi/spi-bus.txt +10 -0
index e782add..168ac87 100644
@@ -33,6 +33,16 @@ contain the following properties.
     		shifted clock phase (CPHA) mode
 - spi-cs-high     - (optional) Empty property indicating device requires
     		chip select active high
+For SPI eeprom using driver 'at25', slave nodes shall also contain the
+following properties.
+- byte_len        - device RAM size
+- dev_name        - device name
+- pagesize        - for writes (see at25.c)
+- flags           - adressing mode and R/O flag
+      - bit 0:  8 bits addrs (EE_ADDR1)
+      - bit 1: 16 bits addrs (EE_ADDR2)
+      - bit 2: 24 bits addrs (EE_ADDR3)
+      - bit 3: disallow writes (EE_READONLY)
 
 SPI example for an MPC5200 SPI bus:
 	spi@f00 {

Documentation/devicetree/bindings/spi/spi-bus.txt SPI example for an MPC5200 SPI bus: · line 68

Quoted 5 lines
Documentation/devicetree/bindings/spi/spi-bus.txt +2 -0
@@ -54,4 +64,13 @@ SPI example for an MPC5200 SPI bus:
 			spi-max-frequency = <100000>;
 			reg = <1>;
 		};
+		at25@0 {
+			compatible = "eeprom,at25";

No, you can't map the platform data 1:1 to the device tree. The compatible should specify the actual device, for example "atmel,25320". And from that information you can derive...

Documentation/devicetree/bindings/spi/spi-bus.txt SPI example for an MPC5200 SPI bus: · line 72

Quoted 2 lines
Documentation/devicetree/bindings/spi/spi-bus.txt +2 -0
+			byte_len = <131072>;
+			dev_name = "CY14B101P";

those two and the EE_ADDR.

Documentation/devicetree/bindings/spi/spi-bus.txt SPI example for an MPC5200 SPI bus: · line 73

Quoted 1 line
Documentation/devicetree/bindings/spi/spi-bus.txt +1 -0
+			pagesize = <128>;

This is indeed a valid property, "read-only" would be another one of interest.

Check at24.c and see how it is done there.

Thanks,

Wolfram

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |