Skip to contentSkip to conversation

lite5200b: flash definition in dts

PATCH New Domen Puncer 3 participants 7 messages Jun 19, 2007 – Aug 7, 2007

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

PATCH 1/1 lite5200b: flash definition in dts

Add flash definition for flash on lite5200b, and while at it fix "ranges" for soc node.

Kernel now writes:

[   11.159134] fe000000.flash: Found 2 x8 devices at 0x0 in 16-bit bank
[   11.165696]  Amd/Fujitsu Extended Query Table at 0x0040
[   11.171109] fe000000.flash: CFI does not contain boot bank location. Assuming top.
[   11.178911] number of CFI chips: 1
[   11.182427] cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
[   11.190402] RedBoot partition parsing not available
[   11.195449] physmap-flash fe000000.flash: Using OF partition information
[   11.202359] Creating 2 MTD partitions on "fe000000.flash":
[   11.208023] 0x00000000-0x01f00000 : "data"
[   11.213712] 0x01f00000-0x02000000 : "u-boot"

I have not managed to write anything to flash from Linux, ideas? JEDEC probe does not succeed.
CFI does (cfi_ident struct is filled and "looks" OK), but mfr and id are 0xffff.

---
 arch/powerpc/boot/dts/lite5200b.dts |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
arch/powerpc/boot/dts/lite5200b.dts +13 -1
Index: work-powerpc.git/arch/powerpc/boot/dts/lite5200b.dts
===================================================================
@@ -52,11 +52,23 @@
 		revision = "";			// from bootloader
 		#interrupt-cells = <3>;
 		device_type = "soc";
-		ranges = <0 f0000000 f0010000>;
+		ranges = <00000000 f0000000 00010000
+			  fe000000 fe000000 02000000>;
 		reg = <f0000000 00010000>;
 		bus-frequency = <0>;		// from bootloader
 		system-frequency = <0>;		// from bootloader
 
+		flash@fe000000 {
+			device_type = "rom";
+			compatible = "direct-mapped";
+			probe-type = "CFI";
+			reg = <fe000000 02000000>;
+			bank-width = <2>;
+			partitions = <00000000 01f00000
+				      01f00000 00100000>;
+			partition-names = "data", "u-boot";
+		};
+
 		cdm@200 {
 			compatible = "mpc5200b-cdm\0mpc5200-cdm";
 			reg = <200 38>;
#1 lore raw

PATCH 1/1 lite5200b: flash definition in dts

Add flash definition for to lite5200b dts, and while at it fix "ranges" for soc node.

---
Hi!

Sylvain, it would be nice to have this merged.

# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 01000000 00020000 "data0"
mtd1: 00f00000 00020000 "data1"
mtd2: 00100000 00020000 "u-boot"

Some benchmarks:

read:  2.3 MB/s
erase: 168 kB/s
write: 7.3 kB/s
 arch/powerpc/boot/dts/lite5200b.dts |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
arch/powerpc/boot/dts/lite5200b.dts +23 -1
Index: work-powerpc.git/arch/powerpc/boot/dts/lite5200b.dts
===================================================================
@@ -52,7 +52,8 @@
 		revision = "";			// from bootloader
 		#interrupt-cells = <3>;
 		device_type = "soc";
-		ranges = <0 f0000000 f0010000>;
+		ranges = <00000000 f0000000 00010000
+			  fe000000 fe000000 02000000>;
 		reg = <f0000000 00010000>;
 		bus-frequency = <0>;		// from bootloader
 		system-frequency = <0>;		// from bootloader
@@ -403,5 +404,26 @@
 			compatible = "mpc5200b-sram\0mpc5200-sram\0sram";
 			reg = <8000 4000>;
 		};
+
+		flash@fe000000 {
+			device_type = "rom";
+			compatible = "direct-mapped";
+			probe-type = "CFI";
+			reg = <fe000000 01000000>;
+			bank-width = <1>;
+			partitions = <00000000 01000000>;
+			partition-names = "data0";
+		};
+
+		flash@ff000000 {
+			device_type = "rom";
+			compatible = "direct-mapped";
+			probe-type = "CFI";
+			reg = <ff000000 01000000>;
+			bank-width = <1>;
+			partitions = <00000000 00f00000
+				      00f00000 00100000>;
+			partition-names = "data1", "u-boot";
+		};
 	};
 };
#2 lore raw
Quoted 31 lines · Domen Puncer

Add flash definition for to lite5200b dts, and while at it fix "ranges" for soc node.

---
Hi!

Sylvain, it would be nice to have this merged.

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 01000000 00020000 "data0"
mtd1: 00f00000 00020000 "data1"
mtd2: 00100000 00020000 "u-boot"

Some benchmarks:

read:  2.3 MB/s
erase: 168 kB/s
write: 7.3 kB/s
 arch/powerpc/boot/dts/lite5200b.dts |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

Index: work-powerpc.git/arch/powerpc/boot/dts/lite5200b.dts
===================================================================

arch/powerpc/boot/dts/lite5200b.dts line 56

Quoted 6 lines
arch/powerpc/boot/dts/lite5200b.dts +2 -1
@@ -52,7 +52,8 @@
                revision = "";                  // from bootloader
                #interrupt-cells = <3>;
                device_type = "soc";
-               ranges = <0 f0000000 f0010000>;
+               ranges = <00000000 f0000000 00010000
+                         fe000000 fe000000 02000000>;

I don't think this is the right approach. I think the SoC node is intended for describing the on-chip devices, and the ranges property reflects that. Shouldn't flash nodes be up 1 level?

Cheers,
g.

Quoted 35 lines
arch/powerpc/boot/dts/lite5200b.dts +21 -0
                reg = <f0000000 00010000>;
                bus-frequency = <0>;            // from bootloader
                system-frequency = <0>;         // from bootloader
@@ -403,5 +404,26 @@
                        compatible = "mpc5200b-sram\0mpc5200-sram\0sram";
                        reg = <8000 4000>;
                };
+
+               flash@fe000000 {
+                       device_type = "rom";
+                       compatible = "direct-mapped";
+                       probe-type = "CFI";
+                       reg = <fe000000 01000000>;
+                       bank-width = <1>;
+                       partitions = <00000000 01000000>;
+                       partition-names = "data0";
+               };
+
+               flash@ff000000 {
+                       device_type = "rom";
+                       compatible = "direct-mapped";
+                       probe-type = "CFI";
+                       reg = <ff000000 01000000>;
+                       bank-width = <1>;
+                       partitions = <00000000 00f00000
+                                     00f00000 00100000>;
+                       partition-names = "data1", "u-boot";
+               };
        };
 };

_______________________________________________
Linuxppc-embedded mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-embedded

Signature · 4 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
[email protected]
(403) 399-0195
#3 lore raw
Quoted 4 lines · Grant Likely
Quoted 3 lines · Domen Puncer

Add flash definition for to lite5200b dts, and while at it fix "ranges" for soc node.

...

Quoted 4 lines
Quoted 4 lines

+++ work-powerpc.git/arch/powerpc/boot/dts/lite5200b.dts

arch/powerpc/boot/dts/lite5200b.dts +0 -0
@@ -52,7 +52,8 @@
                revision = "";                  // from bootloader
                #interrupt-cells = <3>;
Quoted 9 lines

arch/powerpc/boot/dts/lite5200b.dts line 56

Quoted 4 lines
arch/powerpc/boot/dts/lite5200b.dts +2 -1
                device_type = "soc";
-               ranges = <0 f0000000 f0010000>;
+               ranges = <00000000 f0000000 00010000
+                         fe000000 fe000000 02000000>;

I don't think this is the right approach. I think the SoC node is intended for describing the on-chip devices, and the ranges property reflects that. Shouldn't flash nodes be up 1 level?

That would make sense, however, it does not work, probably because:
arch/powerpc/kernel/of_platform.c:

32 /*

 33  * The list of OF IDs below is used for matching bus types in the
 34  * system whose devices are to be exposed as of_platform_devices.
 35  *
 36  * This is the default list valid for most platforms. This file provides
 37  * functions who can take an explicit list if necessary though
 38  *
 39  * The search is always performed recursively looking for children of
 40  * the provided device_node and recursively if such a children matches
 41  * a bus type in the list
 42  */
 43 
 44 static struct of_device_id of_default_bus_ids[] = {
 45         { .type = "soc", },
 46         { .compatible = "soc", },
 47         { .type = "spider", },
 48         { .type = "axon", },
 49         { .type = "plb5", },
 50         { .type = "plb4", },
 51         { .type = "opb", },
 52         { .type = "ebc", },
 53         {},

54 };

Suggestions?
BTW. phy's are also not on chip, but are usualy listed under "soc" (ie. mpc885ads.dts). Or rtc chip connected to i2c in kuroboxHD.dts.

Domen

#4 lore raw
Quoted 20 lines · Domen Puncer
Quoted 4 lines · Grant Likely
Quoted 3 lines · Domen Puncer

Add flash definition for to lite5200b dts, and while at it fix "ranges" for soc node.

...

Quoted 4 lines
Quoted 4 lines

+++ work-powerpc.git/arch/powerpc/boot/dts/lite5200b.dts

arch/powerpc/boot/dts/lite5200b.dts +0 -0
@@ -52,7 +52,8 @@
                revision = "";                  // from bootloader
                #interrupt-cells = <3>;
Quoted 9 lines

arch/powerpc/boot/dts/lite5200b.dts line 56

Quoted 4 lines
arch/powerpc/boot/dts/lite5200b.dts +2 -1
                device_type = "soc";
-               ranges = <0 f0000000 f0010000>;
+               ranges = <00000000 f0000000 00010000
+                         fe000000 fe000000 02000000>;

I don't think this is the right approach. I think the SoC node is intended for describing the on-chip devices, and the ranges property reflects that. Shouldn't flash nodes be up 1 level?

Quoted 5 lines

That would make sense, however, it does not work, probably because:
arch/powerpc/kernel/of_platform.c:
<snip>

Suggestions?

This is fixable in many ways. I don't know if there is an established convention yet, but it's just a matter of making sure the platform setup code adds the devices to the of_platform_bus. Freescale folks, what say you?

Quoted 2 lines

BTW. phy's are also not on chip, but are usualy listed under "soc" (ie. mpc885ads.dts). Or rtc chip connected to i2c in kuroboxHD.dts.

Phy's are also directly connected to MDIO busses and rtc chips directly connected to i2c busses. Both the MDIO and i2c controllers are mapped entirely within the MBAR region which matches the soc node range. Flash seems different to me because it is mapped outside the shared region...

On the other hand there is PCI whose control registers fall within the SoC range; but the memory windows absolutely do not. If my flash argument holds water, then where does that leave PCI which kind of straddles the fence. Gah. Perhaps I'm getting too wrapped up in nothing. Having the flash node as a child of "soc" still describes the platform in an unambiguous way.

Cheers,
g.

Quoted 4 lines

Domen

Signature · 4 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
[email protected]
(403) 399-0195
#5 lore raw
Quoted 4 lines · Grant Likely

On the other hand there is PCI whose control registers fall within the SoC range; but the memory windows absolutely do not. If my flash argument holds water, then where does that leave PCI which kind of straddles the fence.

IMHO, PCI should be split into a bus node that sits outside the SoC, and a control node that sits inside, with phandles between the two.

-Scott

#6 lore raw

PATCH v2 1/1 lite5200b: flash definition in dts

In reply to Grant Likely

Add flash definition for in lite5200b dts, and while at it fix "ranges" for soc node.

---
OK.

Then how about something like this?

# ls /sys/devices/
total 0
drwxr-xr-x 34 root root 0 Dec  9  1993 f0000000.soc5200
drwxr-xr-x  3 root root 0 Dec  9  1993 fe000000.flash
drwxr-xr-x  3 root root 0 Dec  9  1993 ff000000.flash
drwxr-xr-x  4 root root 0 Dec  9  1993 pci0000:00
drwxr-xr-x  5 root root 0 Dec  9  1993 platform
drwxr-xr-x  6 root root 0 Aug  7 08:39 system
# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 01000000 00020000 "data0"
mtd1: 00f00000 00020000 "data1"
mtd2: 00100000 00020000 "u-boot"

Domen

 arch/powerpc/boot/dts/lite5200b.dts          |   23 ++++++++++++++++++++++-
 arch/powerpc/platforms/52xx/mpc52xx_common.c |   15 +++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
arch/powerpc/boot/dts/lite5200b.dts +22 -1
Index: clean-powerpc.git/arch/powerpc/boot/dts/lite5200b.dts
===================================================================
@@ -52,7 +52,7 @@
 		revision = "";			// from bootloader
 		#interrupt-cells = <3>;
 		device_type = "soc";
-		ranges = <0 f0000000 f0010000>;
+		ranges = <00000000 f0000000 00010000>;
 		reg = <f0000000 00010000>;
 		bus-frequency = <0>;		// from bootloader
 		system-frequency = <0>;		// from bootloader
@@ -345,4 +345,25 @@
 			reg = <8000 4000>;
 		};
 	};
+
+	flash@fe000000 {
+		device_type = "rom";
+		compatible = "direct-mapped";
+		probe-type = "CFI";
+		reg = <fe000000 01000000>;
+		bank-width = <1>;
+		partitions = <00000000 01000000>;
+		partition-names = "data0";
+	};
+
+	flash@ff000000 {
+		device_type = "rom";
+		compatible = "direct-mapped";
+		probe-type = "CFI";
+		reg = <ff000000 01000000>;
+		bank-width = <1>;
+		partitions = <00000000 00f00000
+			      00f00000 00100000>;
+		partition-names = "data1", "u-boot";
+	};
 };
arch/powerpc/platforms/52xx/mpc52xx_common.c +15 -0
Index: clean-powerpc.git/arch/powerpc/platforms/52xx/mpc52xx_common.c
===================================================================
@@ -119,9 +119,24 @@ unmap_regs:
 void __init
 mpc52xx_declare_of_platform_devices(void)
 {
+	struct device_node *root, *child;
+	static const struct of_device_id matches[] = {
+		{ .type = "rom", .compatible = "direct-mapped", },
+		{}
+	};
+
 	/* Find every child of the SOC node and add it to of_platform */
 	if (of_platform_bus_probe(NULL, NULL, NULL))
 		printk(KERN_ERR __FILE__ ": "
 			"Error while probing of_platform bus\n");
+
+	/* add flash chips */
+	root = of_find_node_by_path("/");
+	child = NULL;
+	while ((child = of_get_next_child(root, child))) {
+		if (of_match_node(matches, child))
+			of_platform_device_create(child, NULL, NULL);
+	}
+	of_node_put(root);
 }