Skip to contentSkip to conversation

Document and implement an improved flash device binding

DISCUSSION David Gibson 3 participants 8 messages Aug 29, 2007 – Sep 7, 2007

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

for powerpc (v3)
Reply-To:

This patch replaces the binding for flash chips in booting-without-of.txt with an clarified and improved version. It also makes drivers/mtd/maps/physmap_of.c recognize this new binding. Finally it revises the Ebony device tree source to use the new binding as an example.

---
Third try at this...

Documentation/powerpc/booting-without-of.txt +50 -34
Index: working-2.6/Documentation/powerpc/booting-without-of.txt
===================================================================
@@ -50,7 +50,7 @@
       g) Freescale SOC SEC Security Engines
       h) Board Control and Status (BCSR)
       i) Freescale QUICC Engine module (QE)
-      j) Flash chip nodes
+      j) CFI or JEDEC memory-mapped NOR flash
       k) Global Utilities Block
 
   VII - Specifying interrupt information for devices
@@ -1757,45 +1757,61 @@
 		};
 	};
 
-    j) Flash chip nodes
+   j) CFI or JEDEC memory-mapped NOR flash
 
     Flash chips (Memory Technology Devices) are often used for solid state
     file systems on embedded devices.
 
-    Required properties:
-
-     - device_type : has to be "rom"
-     - compatible : Should specify what this flash device is compatible with.
-       Currently, this is most likely to be "direct-mapped" (which
-       corresponds to the MTD physmap mapping driver).
-     - reg : Offset and length of the register set (or memory mapping) for
-       the device.
-     - bank-width : Width of the flash data bus in bytes. Required
-       for the NOR flashes (compatible == "direct-mapped" and others) ONLY.
-
-    Recommended properties :
-
-     - partitions : Several pairs of 32-bit values where the first value is
-       partition's offset from the start of the device and the second one is
-       partition size in bytes with LSB used to signify a read only
-       partition (so, the partition size should always be an even number).
-     - partition-names : The list of concatenated zero terminated strings
-       representing the partition names.
-     - probe-type : The type of probe which should be done for the chip
-       (JEDEC vs CFI actually). Valid ONLY for NOR flashes.
+     - compatible : should contain the specific model of flash chip(s)
+       used, if known, followed by either "cfi-flash" or "jedec-flash"
+     - reg : Address range of the flash chip
+     - bank-width : Width (in bytes) of the flash bank.  Equal to the
+       device width times the number of interleaved chips.
+     - device-width : (optional) Width of a single flash chip.  If
+       omitted, assumed to be equal to 'bank-width'.
+     - #address-cells, #size-cells : Must be present if the flash has
+       sub-nodes representing partitions (see below).  In this case
+       both #address-cells and #size-cells must be equal to 1.
+
+    For JEDEC compatible devices, the following additional properties
+    are defined:
+
+     - vendor-id : Contains the flash chip's vendor id (1 byte).
+     - device-id : Contains the flash chip's device id (1 byte).
+
+    In addition to the information on the flash bank itself, the
+    device tree may optionally contain additional information
+    describing partitions of the flash address space.  This can be
+    used on platforms which have strong conventions about which
+    portions of the flash are used for what purposes, but which don't
+    use an on-flash partition table such as RedBoot.
+
+    Each partition is represented as a sub-node of the flash device.
+    Each node's name represents the name of the corresponding
+    partition of the flash device.
+
+    Flash partitions
+     - reg : The partition's offset and size within the flash bank.
+     - read-only : (optional) This parameter, if present, is a hint to
+       Linux that this flash partition should only be mounted
+       read-only.  This is usually used for flash partitions
+       containing early-boot firmware images or data which should not
+       be clobbered.
 
-   Example:
+    Example:
 
- 	flash@ff000000 {
- 		device_type = "rom";
- 		compatible = "direct-mapped";
- 		probe-type = "CFI";
- 		reg = <ff000000 01000000>;
- 		bank-width = <4>;
- 		partitions = <00000000 00f80000
- 			      00f80000 00080001>;
- 		partition-names = "fs\0firmware";
- 	};
+	flash@ff000000 {
+		compatible = "amd,am29lv128ml", "cfi-flash";
+		reg = <ff000000 01000000>;
+		bank-width = <4>;
+		fs@0 {
+			reg = <0 f80000>;
+		};
+		firmware@f80000 {
+			reg = <f80000 80000>;
+			read-only;
+		};
+	};
 
    k) Global Utilities Block
 
drivers/mtd/maps/physmap_of.c +165 -66

296 lines not on this page · raw message

arch/powerpc/boot/dts/ebony.dts +16 -11
Index: working-2.6/arch/powerpc/boot/dts/ebony.dts
===================================================================
@@ -142,13 +142,15 @@
 				interrupt-parent = <&UIC1>;
 
 				small-flash@0,80000 {
-					device_type = "rom";
-					compatible = "direct-mapped";
-					probe-type = "JEDEC";
+					compatible = "jedec-flash";
 					bank-width = <1>;
-					partitions = <0 80000>;
-					partition-names = "OpenBIOS";
 					reg = <0 80000 80000>;
+					#address-cells = <1>;
+					#size-cells = <1>;
+					OpenBIOS@0 {
+						reg = <0 80000>;
+						read-only;
+					};
 				};
 
 				ds1743@1,0 {
@@ -158,14 +160,17 @@
 				};
 
 				large-flash@2,0 {
-					device_type = "rom";
-					compatible = "direct-mapped";
-					probe-type = "JEDEC";
+					compatible = "jedec-flash";
 					bank-width = <1>;
-					partitions = <0 380000
-						      380000 80000>;
-					partition-names = "fs", "firmware";
 					reg = <2 0 400000>;
+					#address-cells = <1>;
+					#size-cells = <1>;
+					fs@0 {
+						reg = <0 380000>;
+					};
+					firmware@380000 {
+						reg = <380000 80000>;
+					};
 				};
 
 				ir@3,0 {
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#1 lore raw

On 29/08/07 16:13 +1000, David Gibson wrote:

<snip>

drivers/mtd/maps/physmap_of.c line 240

Quoted 13 lines

static int __devinit of_physmap_probe(struct of_device *dev, const struct of_device_id *match) {

drivers/mtd/maps/physmap_of.c +3 -2
 	struct device_node *dp = dev->node;
 	struct resource res;
 	struct physmap_flash_info *info;
-	const char **probe_type;
-	const char *of_probe;
+	const char *probe_type = (const char *)match->data;
 	const u32 *width;
 	int err;
 
+	dev_warn(&dev->dev, "Device tree uses obsolete \"direct-mapped\" "
+		 "flash binding\n");

This is printed for new binding too :-)

Other than this, it works fine for me.

Domen

#2 lore raw
Quoted 14 lines · Domen Puncer

On 29/08/07 16:13 +1000, David Gibson wrote:

<snip>

Quoted 11 lines

static int __devinit of_physmap_probe(struct of_device *dev, const struct of_device_id *match) {

drivers/mtd/maps/physmap_of.c +1 -2
 	struct device_node *dp = dev->node;
 	struct resource res;
 	struct physmap_flash_info *info;
-	const char **probe_type;
-	const char *of_probe;
+	const char *probe_type = (const char *)match->data;
 	const u32 *width;
 	int err;
Quoted 4 lines

drivers/mtd/maps/physmap_of.c line 240

Quoted 2 lines
drivers/mtd/maps/physmap_of.c +2 -0
+	dev_warn(&dev->dev, "Device tree uses obsolete \"direct-mapped\" "
+		 "flash binding\n");

This is printed for new binding too :-)

Duh, put that warning in completely the wrong place. I was awake, obviously :-/

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw
In reply to David Gibson
Quoted 5 lines

+ j) CFI or JEDEC memory-mapped NOR flash

Flash chips (Memory Technology Devices) are often used for solid
state
file systems on embedded devices.

Well, almost everything has a NOR flash on it, not just embedded boards ;-)

Documentation/powerpc/booting-without-of.txt line 1771

Quoted 4 lines
Documentation/powerpc/booting-without-of.txt +4 -0
+     - bank-width : Width (in bytes) of the flash bank.  Equal to the
+       device width times the number of interleaved chips.
+     - device-width : (optional) Width of a single flash chip.  If
+       omitted, assumed to be equal to 'bank-width'.

Let's have bank-width optional instead, it's more natural that way for the common case of just one chip. Or, you can say that either is optional.

Documentation/powerpc/booting-without-of.txt line 1806

Quoted 4 lines
Documentation/powerpc/booting-without-of.txt +4 -0
+	flash@ff000000 {
+		compatible = "amd,am29lv128ml", "cfi-flash";
+		reg = <ff000000 01000000>;
+		bank-width = <4>;

This is an 8/16-bit part, you need a device-width ;-)

Need #address-cells here for the child nodes:

Documentation/powerpc/booting-without-of.txt line 1809

Quoted 3 lines
Documentation/powerpc/booting-without-of.txt +3 -0
+		fs@0 {
+			reg = <0 f80000>;
+		};

[big snip]

arch/powerpc/boot/dts/ebony.dts line 150

Quoted 1 line
arch/powerpc/boot/dts/ebony.dts +1 -0
+					OpenBIOS@0 {

This show immediately why node name = partition name won't work out. You're not supposed to start a node name with a capital like this.

Segher

#4 lore raw
Quoted 8 lines · Segher Boessenkool
Quoted 5 lines

+ j) CFI or JEDEC memory-mapped NOR flash

Flash chips (Memory Technology Devices) are often used for solid
state
file systems on embedded devices.

Well, almost everything has a NOR flash on it, not just embedded boards ;-)

Well, true.

Quoted 8 lines

Documentation/powerpc/booting-without-of.txt line 1771

Quoted 4 lines
Documentation/powerpc/booting-without-of.txt +4 -0
+     - bank-width : Width (in bytes) of the flash bank.  Equal to the
+       device width times the number of interleaved chips.
+     - device-width : (optional) Width of a single flash chip.  If
+       omitted, assumed to be equal to 'bank-width'.

Let's have bank-width optional instead, it's more natural that way for the common case of just one chip. Or, you can say that either is optional.

No, I'm disinclined to do that since bank-width is the primary bit of information that the driver needs.

Quoted 6 lines

Documentation/powerpc/booting-without-of.txt line 1806

Quoted 4 lines
Documentation/powerpc/booting-without-of.txt +4 -0
+	flash@ff000000 {
+		compatible = "amd,am29lv128ml", "cfi-flash";
+		reg = <ff000000 01000000>;
+		bank-width = <4>;

This is an 8/16-bit part, you need a device-width ;-)

Oops - that comes from grabbing a random flash name, combining it with other example fragments without checking the details. Added a device-width.

Quoted 1 line

Need #address-cells here for the child nodes:

Oops. Added #a and #s.

Quoted 11 lines

Documentation/powerpc/booting-without-of.txt line 1809

Quoted 3 lines
Documentation/powerpc/booting-without-of.txt +3 -0
+		fs@0 {
+			reg = <0 f80000>;
+		};

[big snip]

arch/powerpc/boot/dts/ebony.dts line 150

Quoted 1 line
arch/powerpc/boot/dts/ebony.dts +1 -0
+					OpenBIOS@0 {

This show immediately why node name = partition name won't work out. You're not supposed to start a node name with a capital like this.

According to which?

Nonetheless, I've added a label property, and used it for the ebony tree.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#5 lore raw
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

+ - bank-width : Width (in bytes) of the flash bank. Equal to
the

Documentation/powerpc/booting-without-of.txt +3 -0
+       device width times the number of interleaved chips.
+     - device-width : (optional) Width of a single flash chip.  If
+       omitted, assumed to be equal to 'bank-width'.
Quoted 6 lines
Quoted 3 lines

Let's have bank-width optional instead, it's more natural that way for the common case of just one chip. Or, you can say that either is optional.

No, I'm disinclined to do that since bank-width is the primary bit of information that the driver needs.

Bzzzzt. That's not what the device tree is about; it should describe the hardware, it shouldn't be just a config file for the current Linux drivers.

Besides, like I said, for the common case where your flash chips aren't interleaved, it makes way more sense to talk about device-width than it does to call it bank-width.

Quoted 7 lines
Quoted 5 lines

arch/powerpc/boot/dts/ebony.dts line 150

Quoted 1 line
arch/powerpc/boot/dts/ebony.dts +1 -0
+					OpenBIOS@0 {

This show immediately why node name = partition name won't work out. You're not supposed to start a node name with a capital like this.

According to which?

It's just convention, really.

OTOH, spaces and commas and colons and a whole bunch of special chars are completely disallowed here, so you need...

Quoted 1 line

Nonetheless, I've added a label property,

...something like that :-)

Segher

#6 lore raw
Quoted 10 lines · Segher Boessenkool
Quoted 10 lines
Quoted 9 lines

Documentation/powerpc/booting-without-of.txt line 1771

Quoted 5 lines

+ - bank-width : Width (in bytes) of the flash bank. Equal to
the

Documentation/powerpc/booting-without-of.txt +3 -0
+       device width times the number of interleaved chips.
+     - device-width : (optional) Width of a single flash chip.  If
+       omitted, assumed to be equal to 'bank-width'.

Let's have bank-width optional instead, it's more natural that way for the common case of just one chip. Or, you can say that either is optional.

Quoted 6 lines
Quoted 2 lines

No, I'm disinclined to do that since bank-width is the primary bit of information that the driver needs.

Bzzzzt. That's not what the device tree is about; it should describe the hardware, it shouldn't be just a config file for the current Linux drivers.

Yes, yes, so you've said many times.

But where there are multiple ways of encoding exactly the same information, I don't see that we can't use driver convenience as a deciding factor.

Quoted 3 lines

Besides, like I said, for the common case where your flash chips aren't interleaved, it makes way more sense to talk about device-width than it does to call it bank-width.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#7 lore raw
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

Let's have bank-width optional instead, it's more natural that way for the common case of just one chip. Or, you can say that either is optional.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

No, I'm disinclined to do that since bank-width is the primary bit of information that the driver needs.

Bzzzzt. That's not what the device tree is about; it should describe the hardware, it shouldn't be just a config file for the current Linux drivers.

Yes, yes, so you've said many times.

Glad you noticed :-)

Quoted 3 lines

But where there are multiple ways of encoding exactly the same information, I don't see that we can't use driver convenience as a deciding factor.

But a driver that supports interleaving needs _both_ those pieces of information, and a driver that doesn't needs the device-width only.

Sure, the current MTD driver will use some heuristics to guess the device width, but an interface via which it can get it from the device tree will have to be added anyway.

Segher