History

Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6

* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6: (29 commits) of/flattree: forward declare struct device_node in of_fdt.h ipmi: explicitly include of_address.h and of_irq.h sparc: explicitly cast negative phandle checks to s32 powerpc/405: Fix missing #{address,size}-cells in i2c node powerpc/5200: dts: refactor dts files powerpc/5200: dts: Change combatible strings on localbus powerpc/5200: dts: remove unused properties powerpc/5200: dts: rename nodes to prepare for refactoring dts files of/flattree: Update dtc to current mainline. of/device: Don't register disabled devices powerpc/dts: fix syntax bugs in bluestone.dts of: Fixes for OF probing on little endian systems of: make drivers depend on CONFIG_OF instead of CONFIG_PPC_OF of/flattree: Add of_flat_dt_match() helper function of_serial: explicitly include of_irq.h of/flattree: Refactor unflatten_device_tree and add fdt_unflatten_tree of/flattree: Reorder unflatten_dt_node of/flattree: Refactor unflatten_dt_node of/flattree: Add non-boottime device tree functions of/flattree: Add Kconfig for EARLY_FLATTREE ... Fix up trivial conflict in arch/sparc/prom/tree_32.c as per Grant.

Linus Torvalds committed 15 years ago

Commit 0bd2cbc2 parents 57cc721 a08174883 files · +2890 −3404Browse files

Unified · Split

83 files
  1. Documentation/kbuild/makefiles.txt +15 −0
  2. Documentation/powerpc/dts-bindings/eeprom.txt +28 −0
  3. arch/microblaze/Kconfig +1 −1
  4. arch/microblaze/boot/Makefile +3 −9
  5. arch/microblaze/include/asm/prom.h +0 −3
  6. arch/microblaze/kernel/prom_parse.c +0 −38
  7. arch/mips/Kconfig +1 −1
  8. arch/powerpc/Kconfig +1 −1
  9. arch/powerpc/boot/Makefile +3 −5
  10. arch/powerpc/boot/dts/bluestone.dts +4 −4
  11. arch/powerpc/boot/dts/cm5200.dts +24 −170
  12. arch/powerpc/boot/dts/digsy_mtc.dts +25 −152
  13. arch/powerpc/boot/dts/hotfoot.dts +2 −0
  14. arch/powerpc/boot/dts/lite5200b.dts +14 −206
  15. arch/powerpc/boot/dts/media5200.dts +23 −191
  16. arch/powerpc/boot/dts/motionpro.dts +25 −169
  17. arch/powerpc/boot/dts/mpc5200b.dtsi +275 −0
  18. arch/powerpc/boot/dts/mucmc52.dts +46 −128
  19. arch/powerpc/boot/dts/pcm030.dts +19 −177
  20. arch/powerpc/boot/dts/pcm032.dts +35 −207
  21. arch/powerpc/boot/dts/uc101.dts +33 −127
  22. arch/powerpc/include/asm/prom.h +1 −4
  23. arch/powerpc/kernel/prom_parse.c +0 −38
  24. arch/powerpc/platforms/40x/ppc40x_simple.c +4 −9
  25. arch/powerpc/platforms/512x/mpc5121_generic.c +2 −11
  26. arch/powerpc/platforms/52xx/lite5200.c +7 −9
  27. arch/powerpc/platforms/52xx/media5200.c +2 −11
  28. arch/powerpc/platforms/52xx/mpc5200_simple.c +2 −11
  29. arch/powerpc/platforms/83xx/mpc830x_rdb.c +8 −5
  30. arch/powerpc/platforms/83xx/mpc831x_rdb.c +7 −4
  31. arch/powerpc/platforms/83xx/mpc837x_rdb.c +9 −6
  32. arch/powerpc/platforms/85xx/tqm85xx.c +10 −10
  33. arch/powerpc/sysdev/mv64x60_dev.c +1 −0
  34. arch/powerpc/sysdev/tsi108_dev.c +1 −0
  35. arch/sparc/kernel/auxio_32.c +1 −1
  36. arch/sparc/kernel/starfire.c +1 −1
  37. arch/sparc/prom/init_32.c +1 −1
  38. arch/sparc/prom/init_64.c +2 −2
  39. arch/sparc/prom/tree_32.c +9 −8
  40. arch/sparc/prom/tree_64.c +9 −9
  41. drivers/char/ipmi/ipmi_si_intf.c +6 −4
  42. drivers/misc/eeprom/at24.c +37 −6
  43. drivers/mmc/host/Kconfig +3 −1
  44. drivers/mmc/host/sdhci-of-core.c +2 −2
  45. drivers/mtd/Kconfig +1 −1
  46. drivers/mtd/maps/Kconfig +1 −1
  47. drivers/net/fs_enet/fs_enet-main.c +1 −0
  48. drivers/net/gianfar.c +1 −0
  49. drivers/net/ucc_geth.c +1 −0
  50. drivers/net/xilinx_emaclite.c +1 −0
  51. drivers/of/Kconfig +8 −0
  52. drivers/of/Makefile +1 −0
  53. drivers/of/address.c +28 −26
  54. drivers/of/fdt.c +272 −158
  55. drivers/of/of_mdio.c +17 −9
  56. drivers/of/of_net.c +48 −0
  57. drivers/of/platform.c +14 −8
  58. drivers/sbus/char/jsflash.c +1 −1
  59. drivers/serial/Kconfig +1 −1
  60. drivers/serial/of_serial.c +1 −0
  61. include/asm-generic/vmlinux.lds.h +11 −2
  62. include/linux/of_address.h +3 −3
  63. include/linux/of_fdt.h +18 −0
  64. include/linux/of_net.h +15 −0
  65. scripts/Makefile.lib +23 −0
  66. scripts/dtc/Makefile +2 −1
  67. scripts/dtc/checks.c +94 −11
  68. scripts/dtc/dtc-lexer.l +23 −152
  69. scripts/dtc/dtc-lexer.lex.c_shipped +176 −375
  70. scripts/dtc/dtc-parser.tab.c_shipped +440 −452
  71. scripts/dtc/dtc-parser.tab.h_shipped +30 −52
  72. scripts/dtc/dtc-parser.y +63 −97
  73. scripts/dtc/dtc.c +31 −26
  74. scripts/dtc/dtc.h +38 −39
  75. scripts/dtc/flattree.c +109 −83
  76. scripts/dtc/fstree.c +5 −7
  77. scripts/dtc/livetree.c +323 −22
  78. scripts/dtc/srcpos.c +195 −63
  79. scripts/dtc/srcpos.h +50 −49
  80. scripts/dtc/treesource.c +26 −22
  81. scripts/dtc/util.c +59 −0
  82. scripts/dtc/util.h +56 −0
  83. scripts/dtc/version_gen.h +1 −1
Documentation/kbuild/makefiles.txt+15−0
@@ -1136,6 +1136,21 @@ When kbuild executes, the following steps are followed (roughly): · 1135 unmodified lines
11361136 resulting in the target file being recompiled for no
11371137 obvious reason.
11381138
1139+ dtc
1140+ Create flattend device tree blob object suitable for linking
1141+ into vmlinux. Device tree blobs linked into vmlinux are placed
1142+ in an init section in the image. Platform code *must* copy the
1143+ blob to non-init memory prior to calling unflatten_device_tree().
1144+
1145+ Example:
1146+ #arch/x86/platform/ce4100/Makefile
1147+ clean-files := *dtb.S
1148+
1149+ DTC_FLAGS := -p 1024
1150+ obj-y += foo.dtb.o
1151+
1152+ $(obj)/%.dtb: $(src)/%.dts
1153+ $(call cmd,dtc)
11391154
11401155 --- 6.7 Custom kbuild commands
11411156
Documentation/powerpc/dts-bindings/eeprom.txt+28−0
@@ -0,0 +1,28 @@
1+EEPROMs (I2C)
2+
3+Required properties:
4+
5+ - compatible : should be "<manufacturer>,<type>"
6+ If there is no specific driver for <manufacturer>, a generic
7+ driver based on <type> is selected. Possible types are:
8+ 24c00, 24c01, 24c02, 24c04, 24c08, 24c16, 24c32, 24c64,
9+ 24c128, 24c256, 24c512, 24c1024, spd
10+
11+ - reg : the I2C address of the EEPROM
12+
13+Optional properties:
14+
15+ - pagesize : the length of the pagesize for writing. Please consult the
16+ manual of your device, that value varies a lot. A wrong value
17+ may result in data loss! If not specified, a safety value of
18+ '1' is used which will be very slow.
19+
20+ - read-only: this parameterless property disables writes to the eeprom
21+
22+Example:
23+
24+eeprom@52 {
25+ compatible = "atmel,24c32";
26+ reg = <0x52>;
27+ pagesize = <32>;
28+};
arch/microblaze/Kconfig+1−1
@@ -14,7 +14,7 @@ config MICROBLAZE · 13 unmodified lines
1414 select HAVE_DMA_API_DEBUG
1515 select TRACING_SUPPORT
1616 select OF
17− select OF_FLATTREE
17+ select OF_EARLY_FLATTREE
1818
1919 config SWAP
2020 def_bool n
arch/microblaze/boot/Makefile+3−9
@@ -10,9 +10,6 @@ targets := linux.bin linux.bin.gz simpleImage.% · 9 unmodified lines
1010
1111 OBJCOPYFLAGS := -O binary
1212
13−# Where the DTS files live
14−dtstree := $(srctree)/$(src)/dts
15−
1613 # Ensure system.dtb exists
1714 $(obj)/linked_dtb.o: $(obj)/system.dtb
1815
@@ -51,14 +48,11 @@ $(obj)/simpleImage.%: vmlinux FORCE · 32 unmodified lines
5148 $(call if_changed,strip)
5249 @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
5350
54−# Rule to build device tree blobs
55−DTC = $(objtree)/scripts/dtc/dtc
5651
5752 # Rule to build device tree blobs
58−quiet_cmd_dtc = DTC $@
59− cmd_dtc = $(DTC) -O dtb -o $(obj)/$*.dtb -b 0 -p 1024 $(dtstree)/$*.dts
53+DTC_FLAGS := -p 1024
6054
61−$(obj)/%.dtb: $(dtstree)/%.dts FORCE
62− $(call if_changed,dtc)
55+$(obj)/%.dtb: $(src)/dts/%.dts FORCE
56+ $(call cmd,dtc)
6357
6458 clean-files += *.dtb simpleImage.*.unstrip linux.bin.ub
arch/microblaze/include/asm/prom.h+0−3
@@ -64,9 +64,6 @@ extern void kdump_move_device_tree(void); · 63 unmodified lines
6464 /* CPU OF node matching */
6565 struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
6666
67−/* Get the MAC address */
68−extern const void *of_get_mac_address(struct device_node *np);
69−
7067 /**
7168 * of_irq_map_pci - Resolve the interrupt for a PCI device
7269 * @pdev: the device whose interrupt is to be resolved
arch/microblaze/kernel/prom_parse.c+0−38
@@ -110,41 +110,3 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, · 109 unmodified lines
110110 cells = prop ? *(u32 *)prop : of_n_size_cells(dn);
111111 *size = of_read_number(dma_window, cells);
112112 }
113−
114−/**
115− * Search the device tree for the best MAC address to use. 'mac-address' is
116− * checked first, because that is supposed to contain to "most recent" MAC
117− * address. If that isn't set, then 'local-mac-address' is checked next,
118− * because that is the default address. If that isn't set, then the obsolete
119− * 'address' is checked, just in case we're using an old device tree.
120− *
121− * Note that the 'address' property is supposed to contain a virtual address of
122− * the register set, but some DTS files have redefined that property to be the
123− * MAC address.
124− *
125− * All-zero MAC addresses are rejected, because those could be properties that
126− * exist in the device tree, but were not set by U-Boot. For example, the
127− * DTS could define 'mac-address' and 'local-mac-address', with zero MAC
128− * addresses. Some older U-Boots only initialized 'local-mac-address'. In
129− * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
130− * but is all zeros.
131−*/
132−const void *of_get_mac_address(struct device_node *np)
133−{
134− struct property *pp;
135−
136− pp = of_find_property(np, "mac-address", NULL);
137− if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
138− return pp->value;
139−
140− pp = of_find_property(np, "local-mac-address", NULL);
141− if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
142− return pp->value;
143−
144− pp = of_find_property(np, "address", NULL);
145− if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
146− return pp->value;
147−
148− return NULL;
149−}
150−EXPORT_SYMBOL(of_get_mac_address);
arch/mips/Kconfig+1−1
@@ -2218,7 +2218,7 @@ config SECCOMP · 2217 unmodified lines
22182218 config USE_OF
22192219 bool "Flattened Device Tree support"
22202220 select OF
2221− select OF_FLATTREE
2221+ select OF_EARLY_FLATTREE
22222222 help
22232223 Include support for flattened device tree machine descriptions.
22242224
arch/powerpc/Kconfig+1−1
@@ -116,7 +116,7 @@ config PPC · 115 unmodified lines
116116 bool
117117 default y
118118 select OF
119− select OF_FLATTREE
119+ select OF_EARLY_FLATTREE
120120 select HAVE_FTRACE_MCOUNT_RECORD
121121 select HAVE_DYNAMIC_FTRACE
122122 select HAVE_FUNCTION_TRACER
arch/powerpc/boot/Makefile+3−5
@@ -35,7 +35,7 @@ endif · 34 unmodified lines
3535
3636 BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj)
3737
38−DTS_FLAGS ?= -p 1024
38+DTC_FLAGS ?= -p 1024
3939
4040 $(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
4141 $(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
@@ -332,10 +332,8 @@ $(obj)/treeImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) · 290 unmodified lines
332332 $(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb)
333333
334334 # Rule to build device tree blobs
335−DTC = $(objtree)/scripts/dtc/dtc
336−
337−$(obj)/%.dtb: $(dtstree)/%.dts
338− $(DTC) -O dtb -o $(obj)/$*.dtb -b 0 $(DTS_FLAGS) $(dtstree)/$*.dts
335+$(obj)/%.dtb: $(src)/dts/%.dts
336+ $(call cmd,dtc)
339337
340338 # If there isn't a platform selected then just strip the vmlinux.
341339 ifeq (,$(image-y))
arch/powerpc/boot/dts/bluestone.dts+4−4
@@ -33,7 +33,7 @@ · 32 unmodified lines
3333 aliases {
3434 ethernet0 = &EMAC0;
3535 serial0 = &UART0;
36− serial1 = &UART1;
36+ //serial1 = &UART1; --gcl missing UART1 label
3737 };
3838
3939 cpus {
@@ -52,7 +52,7 @@ · 12 unmodified lines
5252 d-cache-size = <32768>;
5353 dcr-controller;
5454 dcr-access-method = "native";
55− next-level-cache = <&L2C0>;
55+ //next-level-cache = <&L2C0>; --gcl missing L2C0 label
5656 };
5757 };
5858
@@ -142,7 +142,7 @@ · 83 unmodified lines
142142 /*RXEOB*/ 0x7 0x4
143143 /*SERR*/ 0x3 0x4
144144 /*TXDE*/ 0x4 0x4
145− /*RXDE*/ 0x5 0x4
145+ /*RXDE*/ 0x5 0x4>;
146146 };
147147
148148 POB0: opb {
@@ -182,7 +182,7 @@ · 33 unmodified lines
182182 reg = <0x001a0000 0x00060000>;
183183 };
184184 };
185− }
185+ };
186186
187187 UART0: serial@ef600300 {
188188 device_type = "serial";
arch/powerpc/boot/dts/cm5200.dts+24−170
@@ -10,220 +10,74 @@ · 9 unmodified lines
1010 * option) any later version.
1111 */
1212
13−/dts-v1/;
13+/include/ "mpc5200b.dtsi"
1414
1515 / {
1616 model = "schindler,cm5200";
1717 compatible = "schindler,cm5200";
18− #address-cells = <1>;
19− #size-cells = <1>;
20− interrupt-parent = <&mpc5200_pic>;
21−
22− cpus {
23− #address-cells = <1>;
24− #size-cells = <0>;
25−
26− PowerPC,5200@0 {
27− device_type = "cpu";
28− reg = <0>;
29− d-cache-line-size = <32>;
30− i-cache-line-size = <32>;
31− d-cache-size = <0x4000>; // L1, 16K
32− i-cache-size = <0x4000>; // L1, 16K
33− timebase-frequency = <0>; // from bootloader
34− bus-frequency = <0>; // from bootloader
35− clock-frequency = <0>; // from bootloader
36− };
37− };
38−
39− memory {
40− device_type = "memory";
41− reg = <0x00000000 0x04000000>; // 64MB
42− };
4318
4419 soc5200@f0000000 {
45− #address-cells = <1>;
46− #size-cells = <1>;
47− compatible = "fsl,mpc5200b-immr";
48− ranges = <0 0xf0000000 0x0000c000>;
49− reg = <0xf0000000 0x00000100>;
50− bus-frequency = <0>; // from bootloader
51− system-frequency = <0>; // from bootloader
52−
53− cdm@200 {
54− compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
55− reg = <0x200 0x38>;
56− };
57−
58− mpc5200_pic: interrupt-controller@500 {
59− // 5200 interrupts are encoded into two levels;
60− interrupt-controller;
61− #interrupt-cells = <3>;
62− compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
63− reg = <0x500 0x80>;
64− };
65−
6620 timer@600 { // General Purpose Timer
67− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
68− reg = <0x600 0x10>;
69− interrupts = <1 9 0>;
7021 fsl,has-wdt;
7122 };
7223
73− timer@610 { // General Purpose Timer
74− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
75− reg = <0x610 0x10>;
76− interrupts = <1 10 0>;
77− };
78−
79− timer@620 { // General Purpose Timer
80− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
81− reg = <0x620 0x10>;
82− interrupts = <1 11 0>;
83− };
84−
85− timer@630 { // General Purpose Timer
86− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
87− reg = <0x630 0x10>;
88− interrupts = <1 12 0>;
89− };
90−
91− timer@640 { // General Purpose Timer
92− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
93− reg = <0x640 0x10>;
94− interrupts = <1 13 0>;
95− };
96−
97− timer@650 { // General Purpose Timer
98− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
99− reg = <0x650 0x10>;
100− interrupts = <1 14 0>;
101− };
102−
103− timer@660 { // General Purpose Timer
104− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
105− reg = <0x660 0x10>;
106− interrupts = <1 15 0>;
107− };
108−
109− timer@670 { // General Purpose Timer
110− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
111− reg = <0x670 0x10>;
112− interrupts = <1 16 0>;
24+ can@900 {
25+ status = "disabled";
11326 };
11427
115− rtc@800 { // Real time clock
116− compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
117− reg = <0x800 0x100>;
118− interrupts = <1 5 0 1 6 0>;
28+ can@980 {
29+ status = "disabled";
11930 };
12031
121− gpio_simple: gpio@b00 {
122− compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
123− reg = <0xb00 0x40>;
124− interrupts = <1 7 0>;
125− gpio-controller;
126− #gpio-cells = <2>;
127− };
128−
129− gpio_wkup: gpio@c00 {
130− compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
131− reg = <0xc00 0x40>;
132− interrupts = <1 8 0 0 3 0>;
133− gpio-controller;
134− #gpio-cells = <2>;
135− };
136−
137− spi@f00 {
138− compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
139− reg = <0xf00 0x20>;
140− interrupts = <2 13 0 2 14 0>;
141− };
142−
143− usb@1000 {
144− compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
145− reg = <0x1000 0xff>;
146− interrupts = <2 6 0>;
147− };
148−
149− dma-controller@1200 {
150− compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
151− reg = <0x1200 0x80>;
152− interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
153− 3 4 0 3 5 0 3 6 0 3 7 0
154− 3 8 0 3 9 0 3 10 0 3 11 0
155− 3 12 0 3 13 0 3 14 0 3 15 0>;
32+ psc@2000 { // PSC1
33+ compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
15634 };
15735
158− xlb@1f00 {
159− compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
160− reg = <0x1f00 0x100>;
36+ psc@2200 { // PSC2
37+ compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
16138 };
16239
163− serial@2000 { // PSC1
40+ psc@2400 { // PSC3
16441 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
165− reg = <0x2000 0x100>;
166− interrupts = <2 1 0>;
16742 };
16843
169− serial@2200 { // PSC2
170− compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
171− reg = <0x2200 0x100>;
172− interrupts = <2 2 0>;
44+ psc@2600 { // PSC4
45+ status = "disabled";
17346 };
17447
175− serial@2400 { // PSC3
176− compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
177− reg = <0x2400 0x100>;
178− interrupts = <2 3 0>;
48+ psc@2800 { // PSC5
49+ status = "disabled";
17950 };
18051
181− serial@2c00 { // PSC6
52+ psc@2c00 { // PSC6
18253 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
183− reg = <0x2c00 0x100>;
184− interrupts = <2 4 0>;
18554 };
18655
18756 ethernet@3000 {
188− compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
189− reg = <0x3000 0x400>;
190− local-mac-address = [ 00 00 00 00 00 00 ];
191− interrupts = <2 5 0>;
19257 phy-handle = <&phy0>;
19358 };
19459
19560 mdio@3000 {
196− #address-cells = <1>;
197− #size-cells = <0>;
198− compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
199− reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
200− interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
201−
20261 phy0: ethernet-phy@0 {
20362 reg = <0>;
20463 };
20564 };
20665
207− i2c@3d40 {
208− #address-cells = <1>;
209− #size-cells = <0>;
210− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
211− reg = <0x3d40 0x40>;
212− interrupts = <2 16 0>;
66+ ata@3a00 {
67+ status = "disabled";
21368 };
21469
215− sram@8000 {
216− compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
217− reg = <0x8000 0x4000>;
70+ i2c@3d00 {
71+ status = "disabled";
21872 };
73+
21974 };
22075
221− localbus {
222− compatible = "fsl,mpc5200b-lpb","simple-bus";
223− #address-cells = <2>;
224− #size-cells = <1>;
225− ranges = <0 0 0xfc000000 0x2000000>;
76+ pci@f0000d00 {
77+ status = "disabled";
78+ };
22679
80+ localbus {
22781 // 16-bit flash device at LocalPlus Bus CS0
22882 flash@0,0 {
22983 compatible = "cfi-flash";
arch/powerpc/boot/dts/digsy_mtc.dts+25−152
@@ -11,195 +11,68 @@ · 10 unmodified lines
1111 * option) any later version.
1212 */
1313
14−/dts-v1/;
14+/include/ "mpc5200b.dtsi"
1515
1616 / {
1717 model = "intercontrol,digsy-mtc";
1818 compatible = "intercontrol,digsy-mtc";
19− #address-cells = <1>;
20− #size-cells = <1>;
21− interrupt-parent = <&mpc5200_pic>;
22−
23− cpus {
24− #address-cells = <1>;
25− #size-cells = <0>;
26−
27− PowerPC,5200@0 {
28− device_type = "cpu";
29− reg = <0>;
30− d-cache-line-size = <32>;
31− i-cache-line-size = <32>;
32− d-cache-size = <0x4000>; // L1, 16K
33− i-cache-size = <0x4000>; // L1, 16K
34− timebase-frequency = <0>; // from bootloader
35− bus-frequency = <0>; // from bootloader
36− clock-frequency = <0>; // from bootloader
37− };
38− };
3919
4020 memory {
41− device_type = "memory";
4221 reg = <0x00000000 0x02000000>; // 32MB
4322 };
4423
4524 soc5200@f0000000 {
46− #address-cells = <1>;
47− #size-cells = <1>;
48− compatible = "fsl,mpc5200b-immr";
49− ranges = <0 0xf0000000 0x0000c000>;
50− reg = <0xf0000000 0x00000100>;
51− bus-frequency = <0>; // from bootloader
52− system-frequency = <0>; // from bootloader
53−
54− cdm@200 {
55− compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
56− reg = <0x200 0x38>;
57− };
58−
59− mpc5200_pic: interrupt-controller@500 {
60− // 5200 interrupts are encoded into two levels;
61− interrupt-controller;
62− #interrupt-cells = <3>;
63− compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
64− reg = <0x500 0x80>;
65− };
66−
6725 timer@600 { // General Purpose Timer
68− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
69− reg = <0x600 0x10>;
70− interrupts = <1 9 0>;
7126 fsl,has-wdt;
7227 };
7328
74− timer@610 { // General Purpose Timer
75− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
76− reg = <0x610 0x10>;
77− interrupts = <1 10 0>;
78− };
79−
80− timer@620 { // General Purpose Timer
81− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
82− reg = <0x620 0x10>;
83− interrupts = <1 11 0>;
84− };
85−
86− timer@630 { // General Purpose Timer
87− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
88− reg = <0x630 0x10>;
89− interrupts = <1 12 0>;
90− };
91−
92− timer@640 { // General Purpose Timer
93− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
94− reg = <0x640 0x10>;
95− interrupts = <1 13 0>;
96− };
97−
98− timer@650 { // General Purpose Timer
99− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
100− reg = <0x650 0x10>;
101− interrupts = <1 14 0>;
29+ rtc@800 {
30+ status = "disabled";
10231 };
10332
104− timer@660 { // General Purpose Timer
105− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
106− reg = <0x660 0x10>;
107− interrupts = <1 15 0>;
33+ can@900 {
34+ status = "disabled";
10835 };
10936
110− timer@670 { // General Purpose Timer
111− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
112− reg = <0x670 0x10>;
113− interrupts = <1 16 0>;
37+ can@980 {
38+ status = "disabled";
11439 };
11540
116− gpio_simple: gpio@b00 {
117− compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
118− reg = <0xb00 0x40>;
119− interrupts = <1 7 0>;
120− gpio-controller;
121− #gpio-cells = <2>;
41+ psc@2000 { // PSC1
42+ status = "disabled";
12243 };
12344
124− gpio_wkup: gpio@c00 {
125− compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
126− reg = <0xc00 0x40>;
127− interrupts = <1 8 0 0 3 0>;
128− gpio-controller;
129− #gpio-cells = <2>;
45+ psc@2200 { // PSC2
46+ status = "disabled";
13047 };
13148
132− spi@f00 {
133− compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
134− reg = <0xf00 0x20>;
135− interrupts = <2 13 0 2 14 0>;
49+ psc@2400 { // PSC3
50+ status = "disabled";
13651 };
13752
138− usb@1000 {
139− compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
140− reg = <0x1000 0xff>;
141− interrupts = <2 6 0>;
142− };
143−
144− dma-controller@1200 {
145− compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
146− reg = <0x1200 0x80>;
147− interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
148− 3 4 0 3 5 0 3 6 0 3 7 0
149− 3 8 0 3 9 0 3 10 0 3 11 0
150− 3 12 0 3 13 0 3 14 0 3 15 0>;
151− };
152−
153− xlb@1f00 {
154− compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
155− reg = <0x1f00 0x100>;
53+ psc@2600 { // PSC4
54+ compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
15655 };
15756
158− serial@2600 { // PSC4
57+ psc@2800 { // PSC5
15958 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
160− reg = <0x2600 0x100>;
161− interrupts = <2 11 0>;
16259 };
16360
164− serial@2800 { // PSC5
165− compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
166− reg = <0x2800 0x100>;
167− interrupts = <2 12 0>;
61+ psc@2c00 { // PSC6
62+ status = "disabled";
16863 };
16964
17065 ethernet@3000 {
171− compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
172− reg = <0x3000 0x400>;
173− local-mac-address = [ 00 00 00 00 00 00 ];
174− interrupts = <2 5 0>;
17566 phy-handle = <&phy0>;
17667 };
17768
17869 mdio@3000 {
179− #address-cells = <1>;
180− #size-cells = <0>;
181− compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
182− reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
183− interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
184−
18570 phy0: ethernet-phy@0 {
18671 reg = <0>;
18772 };
18873 };
18974
190− ata@3a00 {
191− compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
192− reg = <0x3a00 0x100>;
193− interrupts = <2 7 0>;
194− };
195−
19675 i2c@3d00 {
197− #address-cells = <1>;
198− #size-cells = <0>;
199− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
200− reg = <0x3d00 0x40>;
201− interrupts = <2 15 0>;
202−
20376 rtc@50 {
20477 compatible = "at,24c08";
20578 reg = <0x50>;
@@ -211,16 +84,16 @@ · 5 unmodified lines
21184 };
21285 };
21386
214− sram@8000 {
215− compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
216− reg = <0x8000 0x4000>;
87+ i2c@3d40 {
88+ status = "disabled";
21789 };
21890 };
21991
220− lpb {
221− compatible = "fsl,mpc5200b-lpb","simple-bus";
222− #address-cells = <2>;
223− #size-cells = <1>;
92+ pci@f0000d00 {
93+ status = "disabled";
94+ };
95+
96+ localbus {
22497 ranges = <0 0 0xff000000 0x1000000>;
22598
22699 // 16-bit flash device at LocalPlus Bus CS0
arch/powerpc/boot/dts/hotfoot.dts+2−0
@@ -117,6 +117,8 @@ · 116 unmodified lines
117117 };
118118
119119 IIC: i2c@ef600500 {
120+ #address-cells = <1>;
121+ #size-cells = <0>;
120122 compatible = "ibm,iic-405ep", "ibm,iic";
121123 reg = <0xef600500 0x00000011>;
122124 interrupt-parent = <&UIC0>;
arch/powerpc/boot/dts/lite5200b.dts+14−206
@@ -10,256 +10,75 @@ · 9 unmodified lines
1010 * option) any later version.
1111 */
1212
13−/dts-v1/;
13+/include/ "mpc5200b.dtsi"
1414
1515 / {
1616 model = "fsl,lite5200b";
1717 compatible = "fsl,lite5200b";
18− #address-cells = <1>;
19− #size-cells = <1>;
20− interrupt-parent = <&mpc5200_pic>;
21−
22− cpus {
23− #address-cells = <1>;
24− #size-cells = <0>;
25−
26− PowerPC,5200@0 {
27− device_type = "cpu";
28− reg = <0>;
29− d-cache-line-size = <32>;
30− i-cache-line-size = <32>;
31− d-cache-size = <0x4000>; // L1, 16K
32− i-cache-size = <0x4000>; // L1, 16K
33− timebase-frequency = <0>; // from bootloader
34− bus-frequency = <0>; // from bootloader
35− clock-frequency = <0>; // from bootloader
36− };
37− };
3818
3919 memory {
40− device_type = "memory";
4120 reg = <0x00000000 0x10000000>; // 256MB
4221 };
4322
4423 soc5200@f0000000 {
45− #address-cells = <1>;
46− #size-cells = <1>;
47− compatible = "fsl,mpc5200b-immr";
48− ranges = <0 0xf0000000 0x0000c000>;
49− reg = <0xf0000000 0x00000100>;
50− bus-frequency = <0>; // from bootloader
51− system-frequency = <0>; // from bootloader
52−
53− cdm@200 {
54− compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
55− reg = <0x200 0x38>;
56− };
57−
58− mpc5200_pic: interrupt-controller@500 {
59− // 5200 interrupts are encoded into two levels;
60− interrupt-controller;
61− #interrupt-cells = <3>;
62− compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
63− reg = <0x500 0x80>;
64− };
65−
6624 timer@600 { // General Purpose Timer
67− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
68− reg = <0x600 0x10>;
69− interrupts = <1 9 0>;
7025 fsl,has-wdt;
7126 };
7227
73− timer@610 { // General Purpose Timer
74− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
75− reg = <0x610 0x10>;
76− interrupts = <1 10 0>;
77− };
78−
79− timer@620 { // General Purpose Timer
80− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
81− reg = <0x620 0x10>;
82− interrupts = <1 11 0>;
83− };
84−
85− timer@630 { // General Purpose Timer
86− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
87− reg = <0x630 0x10>;
88− interrupts = <1 12 0>;
89− };
90−
91− timer@640 { // General Purpose Timer
92− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
93− reg = <0x640 0x10>;
94− interrupts = <1 13 0>;
95− };
96−
97− timer@650 { // General Purpose Timer
98− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
99− reg = <0x650 0x10>;
100− interrupts = <1 14 0>;
101− };
102−
103− timer@660 { // General Purpose Timer
104− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
105− reg = <0x660 0x10>;
106− interrupts = <1 15 0>;
107− };
108−
109− timer@670 { // General Purpose Timer
110− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
111− reg = <0x670 0x10>;
112− interrupts = <1 16 0>;
113− };
114−
115− rtc@800 { // Real time clock
116− compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
117− reg = <0x800 0x100>;
118− interrupts = <1 5 0 1 6 0>;
119− };
120−
121− can@900 {
122− compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
123− interrupts = <2 17 0>;
124− reg = <0x900 0x80>;
125− };
126−
127− can@980 {
128− compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
129− interrupts = <2 18 0>;
130− reg = <0x980 0x80>;
131− };
132−
133− gpio_simple: gpio@b00 {
134− compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
135− reg = <0xb00 0x40>;
136− interrupts = <1 7 0>;
137− gpio-controller;
138− #gpio-cells = <2>;
139− };
140−
141− gpio_wkup: gpio@c00 {
142− compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
143− reg = <0xc00 0x40>;
144− interrupts = <1 8 0 0 3 0>;
145− gpio-controller;
146− #gpio-cells = <2>;
28+ psc@2000 { // PSC1
29+ compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
30+ cell-index = <0>;
14731 };
14832
149− spi@f00 {
150− compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
151− reg = <0xf00 0x20>;
152− interrupts = <2 13 0 2 14 0>;
33+ psc@2200 { // PSC2
34+ status = "disabled";
15335 };
15436
155− usb@1000 {
156− compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
157− reg = <0x1000 0xff>;
158− interrupts = <2 6 0>;
37+ psc@2400 { // PSC3
38+ status = "disabled";
15939 };
16040
161− dma-controller@1200 {
162− compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
163− reg = <0x1200 0x80>;
164− interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
165− 3 4 0 3 5 0 3 6 0 3 7 0
166− 3 8 0 3 9 0 3 10 0 3 11 0
167− 3 12 0 3 13 0 3 14 0 3 15 0>;
41+ psc@2600 { // PSC4
42+ status = "disabled";
16843 };
16944
170− xlb@1f00 {
171− compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
172− reg = <0x1f00 0x100>;
45+ psc@2800 { // PSC5
46+ status = "disabled";
17347 };
17448
175− serial@2000 { // PSC1
176− compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
177− cell-index = <0>;
178− reg = <0x2000 0x100>;
179− interrupts = <2 1 0>;
49+ psc@2c00 { // PSC6
50+ status = "disabled";
18051 };
18152
18253 // PSC2 in ac97 mode example
18354 //ac97@2200 { // PSC2
18455 // compatible = "fsl,mpc5200b-psc-ac97","fsl,mpc5200-psc-ac97";
18556 // cell-index = <1>;
186− // reg = <0x2200 0x100>;
187− // interrupts = <2 2 0>;
18857 //};
18958
19059 // PSC3 in CODEC mode example
19160 //i2s@2400 { // PSC3
19261 // compatible = "fsl,mpc5200b-psc-i2s"; //not 5200 compatible
19362 // cell-index = <2>;
194− // reg = <0x2400 0x100>;
195− // interrupts = <2 3 0>;
196− //};
197−
198− // PSC4 in uart mode example
199− //serial@2600 { // PSC4
200− // compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
201− // cell-index = <3>;
202− // reg = <0x2600 0x100>;
203− // interrupts = <2 11 0>;
204− //};
205−
206− // PSC5 in uart mode example
207− //serial@2800 { // PSC5
208− // compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
209− // cell-index = <4>;
210− // reg = <0x2800 0x100>;
211− // interrupts = <2 12 0>;
21263 //};
21364
21465 // PSC6 in spi mode example
21566 //spi@2c00 { // PSC6
21667 // compatible = "fsl,mpc5200b-psc-spi","fsl,mpc5200-psc-spi";
21768 // cell-index = <5>;
218− // reg = <0x2c00 0x100>;
219− // interrupts = <2 4 0>;
22069 //};
22170
22271 ethernet@3000 {
223− compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
224− reg = <0x3000 0x400>;
225− local-mac-address = [ 00 00 00 00 00 00 ];
226− interrupts = <2 5 0>;
22772 phy-handle = <&phy0>;
22873 };
22974
23075 mdio@3000 {
231− #address-cells = <1>;
232− #size-cells = <0>;
233− compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
234− reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
235− interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
236−
23776 phy0: ethernet-phy@0 {
23877 reg = <0>;
23978 };
24079 };
24180
242− ata@3a00 {
243− compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
244− reg = <0x3a00 0x100>;
245− interrupts = <2 7 0>;
246− };
247−
248− i2c@3d00 {
249− #address-cells = <1>;
250− #size-cells = <0>;
251− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
252− reg = <0x3d00 0x40>;
253− interrupts = <2 15 0>;
254− };
255−
25681 i2c@3d40 {
257− #address-cells = <1>;
258− #size-cells = <0>;
259− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
260− reg = <0x3d40 0x40>;
261− interrupts = <2 16 0>;
262−
26382 eeprom@50 {
26483 compatible = "atmel,24c02";
26584 reg = <0x50>;
@@ -273,12 +92,6 @@ · 7 unmodified lines
27392 };
27493
27594 pci@f0000d00 {
276− #interrupt-cells = <1>;
277− #size-cells = <2>;
278− #address-cells = <3>;
279− device_type = "pci";
280− compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
281− reg = <0xf0000d00 0x100>;
28295 interrupt-map-mask = <0xf800 0 0 7>;
28396 interrupt-map = <0xc000 0 0 1 &mpc5200_pic 0 0 3 // 1st slot
28497 0xc000 0 0 2 &mpc5200_pic 1 1 3
@@ -298,11 +111,6 @@ · 13 unmodified lines
298111 };
299112
300113 localbus {
301− compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus";
302−
303− #address-cells = <2>;
304− #size-cells = <1>;
305−
306114 ranges = <0 0 0xfe000000 0x02000000>;
307115
308116 flash@0,0 {
arch/powerpc/boot/dts/media5200.dts+23−191
@@ -11,14 +11,11 @@ · 10 unmodified lines
1111 * option) any later version.
1212 */
1313
14−/dts-v1/;
14+/include/ "mpc5200b.dtsi"
1515
1616 / {
1717 model = "fsl,media5200";
1818 compatible = "fsl,media5200";
19− #address-cells = <1>;
20− #size-cells = <1>;
21− interrupt-parent = <&mpc5200_pic>;
2219
2320 aliases {
2421 console = &console;
@@ -30,16 +27,7 @@ · 5 unmodified lines
3027 };
3128
3229 cpus {
33− #address-cells = <1>;
34− #size-cells = <0>;
35−
3630 PowerPC,5200@0 {
37− device_type = "cpu";
38− reg = <0>;
39− d-cache-line-size = <32>;
40− i-cache-line-size = <32>;
41− d-cache-size = <0x4000>; // L1, 16K
42− i-cache-size = <0x4000>; // L1, 16K
4331 timebase-frequency = <33000000>; // 33 MHz, these were configured by U-Boot
4432 bus-frequency = <132000000>; // 132 MHz
4533 clock-frequency = <396000000>; // 396 MHz
@@ -47,205 +35,57 @@ · 1 unmodified line
4735 };
4836
4937 memory {
50− device_type = "memory";
5138 reg = <0x00000000 0x08000000>; // 128MB RAM
5239 };
5340
54− soc@f0000000 {
55− #address-cells = <1>;
56− #size-cells = <1>;
57− compatible = "fsl,mpc5200b-immr";
58− ranges = <0 0xf0000000 0x0000c000>;
59− reg = <0xf0000000 0x00000100>;
41+ soc5200@f0000000 {
6042 bus-frequency = <132000000>;// 132 MHz
61− system-frequency = <0>; // from bootloader
62−
63− cdm@200 {
64− compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
65− reg = <0x200 0x38>;
66− };
67−
68− mpc5200_pic: interrupt-controller@500 {
69− // 5200 interrupts are encoded into two levels;
70− interrupt-controller;
71− #interrupt-cells = <3>;
72− compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
73− reg = <0x500 0x80>;
74− };
7543
7644 timer@600 { // General Purpose Timer
77− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
78− reg = <0x600 0x10>;
79− interrupts = <1 9 0>;
8045 fsl,has-wdt;
8146 };
8247
83− timer@610 { // General Purpose Timer
84− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
85− reg = <0x610 0x10>;
86− interrupts = <1 10 0>;
87− };
88−
89− timer@620 { // General Purpose Timer
90− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
91− reg = <0x620 0x10>;
92− interrupts = <1 11 0>;
93− };
94−
95− timer@630 { // General Purpose Timer
96− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
97− reg = <0x630 0x10>;
98− interrupts = <1 12 0>;
99− };
100−
101− timer@640 { // General Purpose Timer
102− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
103− reg = <0x640 0x10>;
104− interrupts = <1 13 0>;
105− };
106−
107− timer@650 { // General Purpose Timer
108− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
109− reg = <0x650 0x10>;
110− interrupts = <1 14 0>;
111− };
112−
113− timer@660 { // General Purpose Timer
114− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
115− reg = <0x660 0x10>;
116− interrupts = <1 15 0>;
117− };
118−
119− timer@670 { // General Purpose Timer
120− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
121− reg = <0x670 0x10>;
122− interrupts = <1 16 0>;
123− };
124−
125− rtc@800 { // Real time clock
126− compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
127− reg = <0x800 0x100>;
128− interrupts = <1 5 0 1 6 0>;
129− };
130−
131− can@900 {
132− compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
133− interrupts = <2 17 0>;
134− reg = <0x900 0x80>;
48+ psc@2000 { // PSC1
49+ status = "disabled";
13550 };
13651
137− can@980 {
138− compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
139− interrupts = <2 18 0>;
140− reg = <0x980 0x80>;
52+ psc@2200 { // PSC2
53+ status = "disabled";
14154 };
14255
143− gpio_simple: gpio@b00 {
144− compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
145− reg = <0xb00 0x40>;
146− interrupts = <1 7 0>;
147− gpio-controller;
148− #gpio-cells = <2>;
56+ psc@2400 { // PSC3
57+ status = "disabled";
14958 };
15059
151− gpio_wkup: gpio@c00 {
152− compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
153− reg = <0xc00 0x40>;
154− interrupts = <1 8 0 0 3 0>;
155− gpio-controller;
156− #gpio-cells = <2>;
60+ psc@2600 { // PSC4
61+ status = "disabled";
15762 };
15863
159− spi@f00 {
160− compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
161− reg = <0xf00 0x20>;
162− interrupts = <2 13 0 2 14 0>;
163− };
164−
165− usb@1000 {
166− compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
167− reg = <0x1000 0x100>;
168− interrupts = <2 6 0>;
169− };
170−
171− dma-controller@1200 {
172− compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
173− reg = <0x1200 0x80>;
174− interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
175− 3 4 0 3 5 0 3 6 0 3 7 0
176− 3 8 0 3 9 0 3 10 0 3 11 0
177− 3 12 0 3 13 0 3 14 0 3 15 0>;
178− };
179−
180− xlb@1f00 {
181− compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
182− reg = <0x1f00 0x100>;
64+ psc@2800 { // PSC5
65+ status = "disabled";
18366 };
18467
18568 // PSC6 in uart mode
186− console: serial@2c00 { // PSC6
69+ console: psc@2c00 { // PSC6
18770 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
188− cell-index = <5>;
189− port-number = <0>; // Logical port assignment
190− reg = <0x2c00 0x100>;
191− interrupts = <2 4 0>;
19271 };
19372
194− eth0: ethernet@3000 {
195− compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
196− reg = <0x3000 0x400>;
197− local-mac-address = [ 00 00 00 00 00 00 ];
198− interrupts = <2 5 0>;
73+ ethernet@3000 {
19974 phy-handle = <&phy0>;
20075 };
20176
20277 mdio@3000 {
203− #address-cells = <1>;
204− #size-cells = <0>;
205− compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
206− reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
207− interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
208−
20978 phy0: ethernet-phy@0 {
21079 reg = <0>;
21180 };
21281 };
21382
214− ata@3a00 {
215− compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
216− reg = <0x3a00 0x100>;
217− interrupts = <2 7 0>;
218− };
219−
220− i2c@3d00 {
221− #address-cells = <1>;
222− #size-cells = <0>;
223− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
224− reg = <0x3d00 0x40>;
225− interrupts = <2 15 0>;
226− };
227−
228− i2c@3d40 {
229− #address-cells = <1>;
230− #size-cells = <0>;
231− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
232− reg = <0x3d40 0x40>;
233− interrupts = <2 16 0>;
234− };
235−
236− sram@8000 {
237− compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
238− reg = <0x8000 0x4000>;
83+ usb@1000 {
84+ reg = <0x1000 0x100>;
23985 };
24086 };
24187
24288 pci@f0000d00 {
243− #interrupt-cells = <1>;
244− #size-cells = <2>;
245− #address-cells = <3>;
246− device_type = "pci";
247− compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
248− reg = <0xf0000d00 0x100>;
24989 interrupt-map-mask = <0xf800 0 0 7>;
25090 interrupt-map = <0xc000 0 0 1 &media5200_fpga 0 2 // 1st slot
25191 0xc000 0 0 2 &media5200_fpga 0 3
@@ -262,37 +102,29 @@ · 10 unmodified lines
262102
263103 0xe000 0 0 1 &media5200_fpga 0 5 // CoralIP
264104 >;
265− clock-frequency = <0>; // From boot loader
266− interrupts = <2 8 0 2 9 0 2 10 0>;
267− interrupt-parent = <&mpc5200_pic>;
268− bus-range = <0 0>;
269105 ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
270106 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
271107 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
108+ interrupt-parent = <&mpc5200_pic>;
272109 };
273110
274111 localbus {
275− compatible = "fsl,mpc5200b-lpb","simple-bus";
276− #address-cells = <2>;
277− #size-cells = <1>;
278−
279112 ranges = < 0 0 0xfc000000 0x02000000
280113 1 0 0xfe000000 0x02000000
281114 2 0 0xf0010000 0x00010000
282115 3 0 0xf0020000 0x00010000 >;
283−
284116 flash@0,0 {
285117 compatible = "amd,am29lv28ml", "cfi-flash";
286− reg = <0 0x0 0x2000000>; // 32 MB
287− bank-width = <4>; // Width in bytes of the flash bank
288− device-width = <2>; // Two devices on each bank
118+ reg = <0 0x0 0x2000000>; // 32 MB
119+ bank-width = <4>; // Width in bytes of the flash bank
120+ device-width = <2>; // Two devices on each bank
289121 };
290122
291123 flash@1,0 {
292124 compatible = "amd,am29lv28ml", "cfi-flash";
293− reg = <1 0 0x2000000>; // 32 MB
294− bank-width = <4>; // Width in bytes of the flash bank
295− device-width = <2>; // Two devices on each bank
125+ reg = <1 0 0x2000000>; // 32 MB
126+ bank-width = <4>; // Width in bytes of the flash bank
127+ device-width = <2>; // Two devices on each bank
296128 };
297129
298130 media5200_fpga: fpga@2,0 {
arch/powerpc/boot/dts/motionpro.dts+25−169
@@ -10,219 +10,73 @@ · 9 unmodified lines
1010 * option) any later version.
1111 */
1212
13−/dts-v1/;
13+/include/ "mpc5200b.dtsi"
1414
1515 / {
1616 model = "promess,motionpro";
1717 compatible = "promess,motionpro";
18− #address-cells = <1>;
19− #size-cells = <1>;
20− interrupt-parent = <&mpc5200_pic>;
21−
22− cpus {
23− #address-cells = <1>;
24− #size-cells = <0>;
25−
26− PowerPC,5200@0 {
27− device_type = "cpu";
28− reg = <0>;
29− d-cache-line-size = <32>;
30− i-cache-line-size = <32>;
31− d-cache-size = <0x4000>; // L1, 16K
32− i-cache-size = <0x4000>; // L1, 16K
33− timebase-frequency = <0>; // from bootloader
34− bus-frequency = <0>; // from bootloader
35− clock-frequency = <0>; // from bootloader
36− };
37− };
38−
39− memory {
40− device_type = "memory";
41− reg = <0x00000000 0x04000000>; // 64MB
42− };
4318
4419 soc5200@f0000000 {
45− #address-cells = <1>;
46− #size-cells = <1>;
47− compatible = "fsl,mpc5200b-immr";
48− ranges = <0 0xf0000000 0x0000c000>;
49− reg = <0xf0000000 0x00000100>;
50− bus-frequency = <0>; // from bootloader
51− system-frequency = <0>; // from bootloader
52−
53− cdm@200 {
54− compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
55− reg = <0x200 0x38>;
56− };
57−
58− mpc5200_pic: interrupt-controller@500 {
59− // 5200 interrupts are encoded into two levels;
60− interrupt-controller;
61− #interrupt-cells = <3>;
62− compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
63− reg = <0x500 0x80>;
64− };
65−
6620 timer@600 { // General Purpose Timer
67− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
68− reg = <0x600 0x10>;
69− interrupts = <1 9 0>;
7021 fsl,has-wdt;
7122 };
7223
73− timer@610 { // General Purpose Timer
74− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
75− reg = <0x610 0x10>;
76− interrupts = <1 10 0>;
77− };
78−
79− timer@620 { // General Purpose Timer
80− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
81− reg = <0x620 0x10>;
82− interrupts = <1 11 0>;
83− };
84−
85− timer@630 { // General Purpose Timer
86− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
87− reg = <0x630 0x10>;
88− interrupts = <1 12 0>;
89− };
90−
91− timer@640 { // General Purpose Timer
92− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
93− reg = <0x640 0x10>;
94− interrupts = <1 13 0>;
95− };
96−
97− timer@650 { // General Purpose Timer
98− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
99− reg = <0x650 0x10>;
100− interrupts = <1 14 0>;
101− };
102−
103− motionpro-led@660 { // Motion-PRO status LED
24+ timer@660 { // Motion-PRO status LED
10425 compatible = "promess,motionpro-led";
10526 label = "motionpro-statusled";
106− reg = <0x660 0x10>;
107− interrupts = <1 15 0>;
10827 blink-delay = <100>; // 100 msec
10928 };
11029
111− motionpro-led@670 { // Motion-PRO ready LED
30+ timer@670 { // Motion-PRO ready LED
11231 compatible = "promess,motionpro-led";
11332 label = "motionpro-readyled";
114− reg = <0x670 0x10>;
115− interrupts = <1 16 0>;
116− };
117−
118− rtc@800 { // Real time clock
119− compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
120− reg = <0x800 0x100>;
121− interrupts = <1 5 0 1 6 0>;
122− };
123−
124− can@980 {
125− compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
126− interrupts = <2 18 0>;
127− reg = <0x980 0x80>;
12833 };
12934
130− gpio_simple: gpio@b00 {
131− compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
132− reg = <0xb00 0x40>;
133− interrupts = <1 7 0>;
134− gpio-controller;
135− #gpio-cells = <2>;
35+ can@900 {
36+ status = "disabled";
13637 };
13738
138− gpio_wkup: gpio@c00 {
139− compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
140− reg = <0xc00 0x40>;
141− interrupts = <1 8 0 0 3 0>;
142− gpio-controller;
143− #gpio-cells = <2>;
144− };
145−
146− spi@f00 {
147− compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
148− reg = <0xf00 0x20>;
149− interrupts = <2 13 0 2 14 0>;
39+ psc@2000 { // PSC1
40+ compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
15041 };
15142
152− usb@1000 {
153− compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
154− reg = <0x1000 0xff>;
155− interrupts = <2 6 0>;
43+ // PSC2 in spi master mode
44+ psc@2200 { // PSC2
45+ compatible = "fsl,mpc5200b-psc-spi","fsl,mpc5200-psc-spi";
46+ cell-index = <1>;
15647 };
15748
158− dma-controller@1200 {
159− compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
160− reg = <0x1200 0x80>;
161− interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
162− 3 4 0 3 5 0 3 6 0 3 7 0
163− 3 8 0 3 9 0 3 10 0 3 11 0
164− 3 12 0 3 13 0 3 14 0 3 15 0>;
49+ psc@2400 { // PSC3
50+ status = "disabled";
16551 };
16652
167− xlb@1f00 {
168− compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
169− reg = <0x1f00 0x100>;
53+ psc@2600 { // PSC4
54+ status = "disabled";
17055 };
17156
172− serial@2000 { // PSC1
57+ psc@2800 { // PSC5
17358 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
174− reg = <0x2000 0x100>;
175− interrupts = <2 1 0>;
176− };
177−
178− // PSC2 in spi master mode
179− spi@2200 { // PSC2
180− compatible = "fsl,mpc5200b-psc-spi","fsl,mpc5200-psc-spi";
181− cell-index = <1>;
182− reg = <0x2200 0x100>;
183− interrupts = <2 2 0>;
18459 };
18560
186− // PSC5 in uart mode
187− serial@2800 { // PSC5
188− compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
189− reg = <0x2800 0x100>;
190− interrupts = <2 12 0>;
61+ psc@2c00 { // PSC6
62+ status = "disabled";
19163 };
19264
19365 ethernet@3000 {
194− compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
195− reg = <0x3000 0x400>;
196− local-mac-address = [ 00 00 00 00 00 00 ];
197− interrupts = <2 5 0>;
19866 phy-handle = <&phy0>;
19967 };
20068
20169 mdio@3000 {
202− #address-cells = <1>;
203− #size-cells = <0>;
204− compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
205− reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
206− interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
207−
20870 phy0: ethernet-phy@2 {
20971 reg = <2>;
21072 };
21173 };
21274
213− ata@3a00 {
214− compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
215− reg = <0x3a00 0x100>;
216− interrupts = <2 7 0>;
75+ i2c@3d00 {
76+ status = "disabled";
21777 };
21878
21979 i2c@3d40 {
220− #address-cells = <1>;
221− #size-cells = <0>;
222− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
223− reg = <0x3d40 0x40>;
224− interrupts = <2 16 0>;
225−
22680 rtc@68 {
22781 compatible = "dallas,ds1339";
22882 reg = <0x68>;
@@ -235,10 +89,11 @@ · 6 unmodified lines
23589 };
23690 };
23791
92+ pci@f0000d00 {
93+ status = "disabled";
94+ };
95+
23896 localbus {
239− compatible = "fsl,mpc5200b-lpb","simple-bus";
240− #address-cells = <2>;
241− #size-cells = <1>;
24297 ranges = <0 0 0xff000000 0x01000000
24398 1 0 0x50000000 0x00010000
24499 2 0 0x50010000 0x00010000
@@ -280,5 +135,6 @@ · 35 unmodified lines
280135 #size-cells = <1>;
281136 #address-cells = <1>;
282137 };
138+
283139 };
284140 };
arch/powerpc/boot/dts/mpc5200b.dtsi+275−0
@@ -0,0 +1,275 @@
1+/*
2+ * base MPC5200b Device Tree Source
3+ *
4+ * Copyright (C) 2010 SecretLab
5+ * Grant Likely <grant@secretlab.ca>
6+ * John Bonesio <bones@secretlab.ca>
7+ *
8+ * This program is free software; you can redistribute it and/or modify it
9+ * under the terms of the GNU General Public License as published by the
10+ * Free Software Foundation; either version 2 of the License, or (at your
11+ * option) any later version.
12+ */
13+
14+/dts-v1/;
15+
16+/ {
17+ model = "fsl,mpc5200b";
18+ compatible = "fsl,mpc5200b";
19+ #address-cells = <1>;
20+ #size-cells = <1>;
21+ interrupt-parent = <&mpc5200_pic>;
22+
23+ cpus {
24+ #address-cells = <1>;
25+ #size-cells = <0>;
26+
27+ powerpc: PowerPC,5200@0 {
28+ device_type = "cpu";
29+ reg = <0>;
30+ d-cache-line-size = <32>;
31+ i-cache-line-size = <32>;
32+ d-cache-size = <0x4000>; // L1, 16K
33+ i-cache-size = <0x4000>; // L1, 16K
34+ timebase-frequency = <0>; // from bootloader
35+ bus-frequency = <0>; // from bootloader
36+ clock-frequency = <0>; // from bootloader
37+ };
38+ };
39+
40+ memory: memory {
41+ device_type = "memory";
42+ reg = <0x00000000 0x04000000>; // 64MB
43+ };
44+
45+ soc: soc5200@f0000000 {
46+ #address-cells = <1>;
47+ #size-cells = <1>;
48+ compatible = "fsl,mpc5200b-immr";
49+ ranges = <0 0xf0000000 0x0000c000>;
50+ reg = <0xf0000000 0x00000100>;
51+ bus-frequency = <0>; // from bootloader
52+ system-frequency = <0>; // from bootloader
53+
54+ cdm@200 {
55+ compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
56+ reg = <0x200 0x38>;
57+ };
58+
59+ mpc5200_pic: interrupt-controller@500 {
60+ // 5200 interrupts are encoded into two levels;
61+ interrupt-controller;
62+ #interrupt-cells = <3>;
63+ compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
64+ reg = <0x500 0x80>;
65+ };
66+
67+ timer@600 { // General Purpose Timer
68+ compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
69+ reg = <0x600 0x10>;
70+ interrupts = <1 9 0>;
71+ };
72+
73+ timer@610 { // General Purpose Timer
74+ compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
75+ reg = <0x610 0x10>;
76+ interrupts = <1 10 0>;
77+ };
78+
79+ timer@620 { // General Purpose Timer
80+ compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
81+ reg = <0x620 0x10>;
82+ interrupts = <1 11 0>;
83+ };
84+
85+ timer@630 { // General Purpose Timer
86+ compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
87+ reg = <0x630 0x10>;
88+ interrupts = <1 12 0>;
89+ };
90+
91+ timer@640 { // General Purpose Timer
92+ compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
93+ reg = <0x640 0x10>;
94+ interrupts = <1 13 0>;
95+ };
96+
97+ timer@650 { // General Purpose Timer
98+ compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
99+ reg = <0x650 0x10>;
100+ interrupts = <1 14 0>;
101+ };
102+
103+ timer@660 { // General Purpose Timer
104+ compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
105+ reg = <0x660 0x10>;
106+ interrupts = <1 15 0>;
107+ };
108+
109+ timer@670 { // General Purpose Timer
110+ compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
111+ reg = <0x670 0x10>;
112+ interrupts = <1 16 0>;
113+ };
114+
115+ rtc@800 { // Real time clock
116+ compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
117+ reg = <0x800 0x100>;
118+ interrupts = <1 5 0 1 6 0>;
119+ };
120+
121+ can@900 {
122+ compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
123+ interrupts = <2 17 0>;
124+ reg = <0x900 0x80>;
125+ };
126+
127+ can@980 {
128+ compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
129+ interrupts = <2 18 0>;
130+ reg = <0x980 0x80>;
131+ };
132+
133+ gpio_simple: gpio@b00 {
134+ compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
135+ reg = <0xb00 0x40>;
136+ interrupts = <1 7 0>;
137+ gpio-controller;
138+ #gpio-cells = <2>;
139+ };
140+
141+ gpio_wkup: gpio@c00 {
142+ compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
143+ reg = <0xc00 0x40>;
144+ interrupts = <1 8 0 0 3 0>;
145+ gpio-controller;
146+ #gpio-cells = <2>;
147+ };
148+
149+ spi@f00 {
150+ compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
151+ reg = <0xf00 0x20>;
152+ interrupts = <2 13 0 2 14 0>;
153+ };
154+
155+ usb: usb@1000 {
156+ compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
157+ reg = <0x1000 0xff>;
158+ interrupts = <2 6 0>;
159+ };
160+
161+ dma-controller@1200 {
162+ compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
163+ reg = <0x1200 0x80>;
164+ interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
165+ 3 4 0 3 5 0 3 6 0 3 7 0
166+ 3 8 0 3 9 0 3 10 0 3 11 0
167+ 3 12 0 3 13 0 3 14 0 3 15 0>;
168+ };
169+
170+ xlb@1f00 {
171+ compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
172+ reg = <0x1f00 0x100>;
173+ };
174+
175+ psc1: psc@2000 { // PSC1
176+ compatible = "fsl,mpc5200b-psc","fsl,mpc5200-psc";
177+ reg = <0x2000 0x100>;
178+ interrupts = <2 1 0>;
179+ };
180+
181+ psc2: psc@2200 { // PSC2
182+ compatible = "fsl,mpc5200b-psc","fsl,mpc5200-psc";
183+ reg = <0x2200 0x100>;
184+ interrupts = <2 2 0>;
185+ };
186+
187+ psc3: psc@2400 { // PSC3
188+ compatible = "fsl,mpc5200b-psc","fsl,mpc5200-psc";
189+ reg = <0x2400 0x100>;
190+ interrupts = <2 3 0>;
191+ };
192+
193+ psc4: psc@2600 { // PSC4
194+ compatible = "fsl,mpc5200b-psc","fsl,mpc5200-psc";
195+ reg = <0x2600 0x100>;
196+ interrupts = <2 11 0>;
197+ };
198+
199+ psc5: psc@2800 { // PSC5
200+ compatible = "fsl,mpc5200b-psc","fsl,mpc5200-psc";
201+ reg = <0x2800 0x100>;
202+ interrupts = <2 12 0>;
203+ };
204+
205+ psc6: psc@2c00 { // PSC6
206+ compatible = "fsl,mpc5200b-psc","fsl,mpc5200-psc";
207+ reg = <0x2c00 0x100>;
208+ interrupts = <2 4 0>;
209+ };
210+
211+ eth0: ethernet@3000 {
212+ compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
213+ reg = <0x3000 0x400>;
214+ local-mac-address = [ 00 00 00 00 00 00 ];
215+ interrupts = <2 5 0>;
216+ };
217+
218+ mdio@3000 {
219+ #address-cells = <1>;
220+ #size-cells = <0>;
221+ compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
222+ reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
223+ interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
224+ };
225+
226+ ata@3a00 {
227+ compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
228+ reg = <0x3a00 0x100>;
229+ interrupts = <2 7 0>;
230+ };
231+
232+ i2c@3d00 {
233+ #address-cells = <1>;
234+ #size-cells = <0>;
235+ compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
236+ reg = <0x3d00 0x40>;
237+ interrupts = <2 15 0>;
238+ };
239+
240+ i2c@3d40 {
241+ #address-cells = <1>;
242+ #size-cells = <0>;
243+ compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
244+ reg = <0x3d40 0x40>;
245+ interrupts = <2 16 0>;
246+ };
247+
248+ sram@8000 {
249+ compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
250+ reg = <0x8000 0x4000>;
251+ };
252+ };
253+
254+ pci: pci@f0000d00 {
255+ #interrupt-cells = <1>;
256+ #size-cells = <2>;
257+ #address-cells = <3>;
258+ device_type = "pci";
259+ compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
260+ reg = <0xf0000d00 0x100>;
261+ // interrupt-map-mask = need to add
262+ // interrupt-map = need to add
263+ clock-frequency = <0>; // From boot loader
264+ interrupts = <2 8 0 2 9 0 2 10 0>;
265+ bus-range = <0 0>;
266+ // ranges = need to add
267+ };
268+
269+ localbus: localbus {
270+ compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus";
271+ #address-cells = <2>;
272+ #size-cells = <1>;
273+ ranges = <0 0 0xfc000000 0x2000000>;
274+ };
275+};
arch/powerpc/boot/dts/mucmc52.dts+46−128
@@ -11,172 +11,109 @@ · 10 unmodified lines
1111 * option) any later version.
1212 */
1313
14−/dts-v1/;
14+/include/ "mpc5200b.dtsi"
1515
1616 / {
1717 model = "manroland,mucmc52";
1818 compatible = "manroland,mucmc52";
19− #address-cells = <1>;
20− #size-cells = <1>;
21− interrupt-parent = <&mpc5200_pic>;
22−
23− cpus {
24− #address-cells = <1>;
25− #size-cells = <0>;
26−
27− PowerPC,5200@0 {
28− device_type = "cpu";
29− reg = <0>;
30− d-cache-line-size = <32>;
31− i-cache-line-size = <32>;
32− d-cache-size = <0x4000>; // L1, 16K
33− i-cache-size = <0x4000>; // L1, 16K
34− timebase-frequency = <0>; // from bootloader
35− bus-frequency = <0>; // from bootloader
36− clock-frequency = <0>; // from bootloader
37− };
38− };
39−
40− memory {
41− device_type = "memory";
42− reg = <0x00000000 0x04000000>; // 64MB
43− };
4419
4520 soc5200@f0000000 {
46− #address-cells = <1>;
47− #size-cells = <1>;
48− compatible = "fsl,mpc5200b-immr";
49− ranges = <0 0xf0000000 0x0000c000>;
50− reg = <0xf0000000 0x00000100>;
51− bus-frequency = <0>; // from bootloader
52− system-frequency = <0>; // from bootloader
53−
54− cdm@200 {
55− compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
56− reg = <0x200 0x38>;
57− };
58−
59− mpc5200_pic: interrupt-controller@500 {
60− // 5200 interrupts are encoded into two levels;
61− interrupt-controller;
62− #interrupt-cells = <3>;
63− compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
64− reg = <0x500 0x80>;
65− };
66−
6721 gpt0: timer@600 { // GPT 0 in GPIO mode
68− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
69− reg = <0x600 0x10>;
70− interrupts = <1 9 0>;
7122 gpio-controller;
7223 #gpio-cells = <2>;
7324 };
7425
7526 gpt1: timer@610 { // General Purpose Timer in GPIO mode
76− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
77− reg = <0x610 0x10>;
78− interrupts = <1 10 0>;
7927 gpio-controller;
8028 #gpio-cells = <2>;
8129 };
8230
8331 gpt2: timer@620 { // General Purpose Timer in GPIO mode
84− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
85− reg = <0x620 0x10>;
86− interrupts = <1 11 0>;
8732 gpio-controller;
8833 #gpio-cells = <2>;
8934 };
9035
9136 gpt3: timer@630 { // General Purpose Timer in GPIO mode
92− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
93− reg = <0x630 0x10>;
94− interrupts = <1 12 0>;
9537 gpio-controller;
9638 #gpio-cells = <2>;
9739 };
9840
99− gpio_simple: gpio@b00 {
100− compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
101− reg = <0xb00 0x40>;
102− interrupts = <1 7 0>;
103− gpio-controller;
104− #gpio-cells = <2>;
41+ timer@640 {
42+ status = "disabled";
10543 };
10644
107− gpio_wkup: gpio@c00 {
108− compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
109− reg = <0xc00 0x40>;
110− interrupts = <1 8 0 0 3 0>;
111− gpio-controller;
112− #gpio-cells = <2>;
45+ timer@650 {
46+ status = "disabled";
47+ };
48+
49+ timer@660 {
50+ status = "disabled";
51+ };
52+
53+ timer@670 {
54+ status = "disabled";
11355 };
11456
115− dma-controller@1200 {
116− compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
117− reg = <0x1200 0x80>;
118− interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
119− 3 4 0 3 5 0 3 6 0 3 7 0
120− 3 8 0 3 9 0 3 10 0 3 11 0
121− 3 12 0 3 13 0 3 14 0 3 15 0>;
57+ rtc@800 {
58+ status = "disabled";
12259 };
12360
124− xlb@1f00 {
125− compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
126− reg = <0x1f00 0x100>;
61+ can@900 {
62+ status = "disabled";
12763 };
12864
129− serial@2000 { /* PSC1 in UART mode */
65+ can@980 {
66+ status = "disabled";
67+ };
68+
69+ spi@f00 {
70+ status = "disabled";
71+ };
72+
73+ usb@1000 {
74+ status = "disabled";
75+ };
76+
77+ psc@2000 { // PSC1
13078 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
131− reg = <0x2000 0x100>;
132− interrupts = <2 1 0>;
13379 };
13480
135− serial@2200 { /* PSC2 in UART mode */
81+ psc@2200 { // PSC2
13682 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
137− reg = <0x2200 0x100>;
138− interrupts = <2 2 0>;
13983 };
14084
141− serial@2c00 { /* PSC6 in UART mode */
85+ psc@2400 { // PSC3
86+ status = "disabled";
87+ };
88+
89+ psc@2600 { // PSC4
90+ status = "disabled";
91+ };
92+
93+ psc@2800 { // PSC5
94+ status = "disabled";
95+ };
96+
97+ psc@2c00 { // PSC6
14298 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
143− reg = <0x2c00 0x100>;
144− interrupts = <2 4 0>;
14599 };
146100
147101 ethernet@3000 {
148− compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
149− reg = <0x3000 0x400>;
150− local-mac-address = [ 00 00 00 00 00 00 ];
151− interrupts = <2 5 0>;
152102 phy-handle = <&phy0>;
153103 };
154104
155105 mdio@3000 {
156− #address-cells = <1>;
157− #size-cells = <0>;
158− compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
159− reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
160− interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
161−
162106 phy0: ethernet-phy@0 {
163107 compatible = "intel,lxt971";
164108 reg = <0>;
165109 };
166110 };
167111
168− ata@3a00 {
169− compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
170− reg = <0x3a00 0x100>;
171− interrupts = <2 7 0>;
112+ i2c@3d00 {
113+ status = "disabled";
172114 };
173115
174116 i2c@3d40 {
175− #address-cells = <1>;
176− #size-cells = <0>;
177− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
178− reg = <0x3d40 0x40>;
179− interrupts = <2 16 0>;
180117 hwmon@2c {
181118 compatible = "ad,adm9240";
182119 reg = <0x2c>;
@@ -186,20 +123,9 @@ · 3 unmodified lines
186123 reg = <0x51>;
187124 };
188125 };
189−
190− sram@8000 {
191− compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
192− reg = <0x8000 0x4000>;
193− };
194126 };
195127
196128 pci@f0000d00 {
197− #interrupt-cells = <1>;
198− #size-cells = <2>;
199− #address-cells = <3>;
200− device_type = "pci";
201− compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
202− reg = <0xf0000d00 0x100>;
203129 interrupt-map-mask = <0xf800 0 0 7>;
204130 interrupt-map = <
205131 /* IDSEL 0x10 */
@@ -208,20 +134,12 @@ · 2 unmodified lines
208134 0x8000 0 0 3 &mpc5200_pic 0 2 3
209135 0x8000 0 0 4 &mpc5200_pic 0 1 3
210136 >;
211− clock-frequency = <0>; // From boot loader
212− interrupts = <2 8 0 2 9 0 2 10 0>;
213− bus-range = <0 0>;
214137 ranges = <0x42000000 0 0x60000000 0x60000000 0 0x10000000
215138 0x02000000 0 0x90000000 0x90000000 0 0x10000000
216139 0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
217140 };
218141
219142 localbus {
220− compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus";
221−
222− #address-cells = <2>;
223− #size-cells = <1>;
224−
225143 ranges = <0 0 0xff800000 0x00800000
226144 1 0 0x80000000 0x00800000
227145 3 0 0x80000000 0x00800000>;
arch/powerpc/boot/dts/pcm030.dts+19−177
@@ -12,246 +12,92 @@ · 11 unmodified lines
1212 * option) any later version.
1313 */
1414
15−/dts-v1/;
15+/include/ "mpc5200b.dtsi"
1616
1717 / {
1818 model = "phytec,pcm030";
1919 compatible = "phytec,pcm030";
20− #address-cells = <1>;
21− #size-cells = <1>;
22− interrupt-parent = <&mpc5200_pic>;
23−
24− cpus {
25− #address-cells = <1>;
26− #size-cells = <0>;
27−
28− PowerPC,5200@0 {
29− device_type = "cpu";
30− reg = <0>;
31− d-cache-line-size = <32>;
32− i-cache-line-size = <32>;
33− d-cache-size = <0x4000>; // L1, 16K
34− i-cache-size = <0x4000>; // L1, 16K
35− timebase-frequency = <0>; // from bootloader
36− bus-frequency = <0>; // from bootloader
37− clock-frequency = <0>; // from bootloader
38− };
39− };
40−
41− memory {
42− device_type = "memory";
43− reg = <0x00000000 0x04000000>; // 64MB
44− };
4520
4621 soc5200@f0000000 {
47− #address-cells = <1>;
48− #size-cells = <1>;
49− compatible = "fsl,mpc5200b-immr";
50− ranges = <0 0xf0000000 0x0000c000>;
51− bus-frequency = <0>; // from bootloader
52− system-frequency = <0>; // from bootloader
53−
54− cdm@200 {
55− compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
56− reg = <0x200 0x38>;
57− };
58−
59− mpc5200_pic: interrupt-controller@500 {
60− // 5200 interrupts are encoded into two levels;
61− interrupt-controller;
62− #interrupt-cells = <3>;
63− compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
64− reg = <0x500 0x80>;
65− };
66−
67− timer@600 { // General Purpose Timer
68− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
69− reg = <0x600 0x10>;
70− interrupts = <1 9 0>;
22+ timer@600 { // General Purpose Timer
7123 fsl,has-wdt;
7224 };
7325
74− timer@610 { // General Purpose Timer
75− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
76− reg = <0x610 0x10>;
77− interrupts = <1 10 0>;
78− };
79−
8026 gpt2: timer@620 { // General Purpose Timer in GPIO mode
8127 compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
82− reg = <0x620 0x10>;
83− interrupts = <1 11 0>;
8428 gpio-controller;
8529 #gpio-cells = <2>;
8630 };
8731
8832 gpt3: timer@630 { // General Purpose Timer in GPIO mode
8933 compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
90− reg = <0x630 0x10>;
91− interrupts = <1 12 0>;
9234 gpio-controller;
9335 #gpio-cells = <2>;
9436 };
9537
9638 gpt4: timer@640 { // General Purpose Timer in GPIO mode
9739 compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
98− reg = <0x640 0x10>;
99− interrupts = <1 13 0>;
10040 gpio-controller;
10141 #gpio-cells = <2>;
10242 };
10343
10444 gpt5: timer@650 { // General Purpose Timer in GPIO mode
10545 compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
106− reg = <0x650 0x10>;
107− interrupts = <1 14 0>;
10846 gpio-controller;
10947 #gpio-cells = <2>;
11048 };
11149
11250 gpt6: timer@660 { // General Purpose Timer in GPIO mode
11351 compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
114− reg = <0x660 0x10>;
115− interrupts = <1 15 0>;
11652 gpio-controller;
11753 #gpio-cells = <2>;
11854 };
11955
12056 gpt7: timer@670 { // General Purpose Timer in GPIO mode
12157 compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
122− reg = <0x670 0x10>;
123− interrupts = <1 16 0>;
124− gpio-controller;
125− #gpio-cells = <2>;
126− };
127−
128− rtc@800 { // Real time clock
129− compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
130− reg = <0x800 0x100>;
131− interrupts = <1 5 0 1 6 0>;
132− };
133−
134− can@900 {
135− compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
136− interrupts = <2 17 0>;
137− reg = <0x900 0x80>;
138− };
139−
140− can@980 {
141− compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
142− interrupts = <2 18 0>;
143− reg = <0x980 0x80>;
144− };
145−
146− gpio_simple: gpio@b00 {
147− compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
148− reg = <0xb00 0x40>;
149− interrupts = <1 7 0>;
15058 gpio-controller;
15159 #gpio-cells = <2>;
15260 };
15361
154− gpio_wkup: gpio@c00 {
155− compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
156− reg = <0xc00 0x40>;
157− interrupts = <1 8 0 0 3 0>;
158− gpio-controller;
159− #gpio-cells = <2>;
160− };
161−
162− spi@f00 {
163− compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
164− reg = <0xf00 0x20>;
165− interrupts = <2 13 0 2 14 0>;
166− };
167−
168− usb@1000 {
169− compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
170− reg = <0x1000 0xff>;
171− interrupts = <2 6 0>;
172− };
173−
174− dma-controller@1200 {
175− compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
176− reg = <0x1200 0x80>;
177− interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
178− 3 4 0 3 5 0 3 6 0 3 7 0
179− 3 8 0 3 9 0 3 10 0 3 11 0
180− 3 12 0 3 13 0 3 14 0 3 15 0>;
181− };
182−
183− xlb@1f00 {
184− compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
185− reg = <0x1f00 0x100>;
186− };
187−
188− ac97@2000 { /* PSC1 in ac97 mode */
62+ psc@2000 { /* PSC1 in ac97 mode */
18963 compatible = "mpc5200b-psc-ac97","fsl,mpc5200b-psc-ac97";
19064 cell-index = <0>;
191− reg = <0x2000 0x100>;
192− interrupts = <2 1 0>;
19365 };
19466
19567 /* PSC2 port is used by CAN1/2 */
68+ psc@2200 {
69+ status = "disabled";
70+ };
19671
197− serial@2400 { /* PSC3 in UART mode */
72+ psc@2400 { /* PSC3 in UART mode */
19873 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
199− cell-index = <2>;
200− reg = <0x2400 0x100>;
201− interrupts = <2 3 0>;
20274 };
20375
20476 /* PSC4 is ??? */
77+ psc@2600 {
78+ status = "disabled";
79+ };
20580
20681 /* PSC5 is ??? */
82+ psc@2800 {
83+ status = "disabled";
84+ };
20785
208− serial@2c00 { /* PSC6 in UART mode */
86+ psc@2c00 { /* PSC6 in UART mode */
20987 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
210− cell-index = <5>;
211− reg = <0x2c00 0x100>;
212− interrupts = <2 4 0>;
21388 };
21489
21590 ethernet@3000 {
216− compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
217− reg = <0x3000 0x400>;
218− local-mac-address = [ 00 00 00 00 00 00 ];
219− interrupts = <2 5 0>;
22091 phy-handle = <&phy0>;
22192 };
22293
22394 mdio@3000 {
224− #address-cells = <1>;
225− #size-cells = <0>;
226− compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
227− reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
228− interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
229−
23095 phy0: ethernet-phy@0 {
23196 reg = <0>;
23297 };
23398 };
23499
235− ata@3a00 {
236− compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
237− reg = <0x3a00 0x100>;
238− interrupts = <2 7 0>;
239− };
240−
241− i2c@3d00 {
242− #address-cells = <1>;
243− #size-cells = <0>;
244− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
245− reg = <0x3d00 0x40>;
246− interrupts = <2 15 0>;
247− };
248−
249100 i2c@3d40 {
250− #address-cells = <1>;
251− #size-cells = <0>;
252− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
253− reg = <0x3d40 0x40>;
254− interrupts = <2 16 0>;
255101 rtc@51 {
256102 compatible = "nxp,pcf8563";
257103 reg = <0x51>;
@@ -259,6 +105,7 @@ · 1 unmodified line
259105 eeprom@52 {
260106 compatible = "catalyst,24c32";
261107 reg = <0x52>;
108+ pagesize = <32>;
262109 };
263110 };
264111
@@ -269,12 +116,6 @@ · 4 unmodified lines
269116 };
270117
271118 pci@f0000d00 {
272− #interrupt-cells = <1>;
273− #size-cells = <2>;
274− #address-cells = <3>;
275− device_type = "pci";
276− compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
277− reg = <0xf0000d00 0x100>;
278119 interrupt-map-mask = <0xf800 0 0 7>;
279120 interrupt-map = <0xc000 0 0 1 &mpc5200_pic 0 0 3 // 1st slot
280121 0xc000 0 0 2 &mpc5200_pic 1 1 3
@@ -285,11 +126,12 @@ · 4 unmodified lines
285126 0xc800 0 0 2 &mpc5200_pic 1 2 3
286127 0xc800 0 0 3 &mpc5200_pic 1 3 3
287128 0xc800 0 0 4 &mpc5200_pic 0 0 3>;
288− clock-frequency = <0>; // From boot loader
289− interrupts = <2 8 0 2 9 0 2 10 0>;
290− bus-range = <0 0>;
291129 ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
292130 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
293131 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
294132 };
133+
134+ localbus {
135+ status = "disabled";
136+ };
295137 };
arch/powerpc/boot/dts/pcm032.dts+35−207
@@ -12,99 +12,37 @@ · 11 unmodified lines
1212 * option) any later version.
1313 */
1414
15−/dts-v1/;
15+/include/ "mpc5200b.dtsi"
1616
1717 / {
1818 model = "phytec,pcm032";
1919 compatible = "phytec,pcm032";
20− #address-cells = <1>;
21− #size-cells = <1>;
22− interrupt-parent = <&mpc5200_pic>;
23−
24− cpus {
25− #address-cells = <1>;
26− #size-cells = <0>;
27−
28− PowerPC,5200@0 {
29− device_type = "cpu";
30− reg = <0>;
31− d-cache-line-size = <32>;
32− i-cache-line-size = <32>;
33− d-cache-size = <0x4000>; // L1, 16K
34− i-cache-size = <0x4000>; // L1, 16K
35− timebase-frequency = <0>; // from bootloader
36− bus-frequency = <0>; // from bootloader
37− clock-frequency = <0>; // from bootloader
38− };
39− };
4020
4121 memory {
42− device_type = "memory";
4322 reg = <0x00000000 0x08000000>; // 128MB
4423 };
4524
4625 soc5200@f0000000 {
47− #address-cells = <1>;
48− #size-cells = <1>;
49− compatible = "fsl,mpc5200b-immr";
50− ranges = <0 0xf0000000 0x0000c000>;
51− bus-frequency = <0>; // from bootloader
52− system-frequency = <0>; // from bootloader
53−
54− cdm@200 {
55− compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
56− reg = <0x200 0x38>;
57− };
58−
59− mpc5200_pic: interrupt-controller@500 {
60− // 5200 interrupts are encoded into two levels;
61− interrupt-controller;
62− #interrupt-cells = <3>;
63− compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
64− reg = <0x500 0x80>;
65− };
66−
67− timer@600 { // General Purpose Timer
68− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
69− reg = <0x600 0x10>;
70− interrupts = <1 9 0>;
26+ timer@600 { // General Purpose Timer
7127 fsl,has-wdt;
7228 };
7329
74− timer@610 { // General Purpose Timer
75− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
76− reg = <0x610 0x10>;
77− interrupts = <1 10 0>;
78− };
79−
8030 gpt2: timer@620 { // General Purpose Timer in GPIO mode
81− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
82− reg = <0x620 0x10>;
83− interrupts = <1 11 0>;
8431 gpio-controller;
8532 #gpio-cells = <2>;
8633 };
8734
8835 gpt3: timer@630 { // General Purpose Timer in GPIO mode
89− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
90− reg = <0x630 0x10>;
91− interrupts = <1 12 0>;
9236 gpio-controller;
9337 #gpio-cells = <2>;
9438 };
9539
9640 gpt4: timer@640 { // General Purpose Timer in GPIO mode
97− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
98− reg = <0x640 0x10>;
99− interrupts = <1 13 0>;
10041 gpio-controller;
10142 #gpio-cells = <2>;
10243 };
10344
10445 gpt5: timer@650 { // General Purpose Timer in GPIO mode
105− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
106− reg = <0x650 0x10>;
107− interrupts = <1 14 0>;
10846 gpio-controller;
10947 #gpio-cells = <2>;
11048 };
@@ -118,163 +56,62 @@ · 7 unmodified lines
11856 };
11957
12058 gpt7: timer@670 { // General Purpose Timer in GPIO mode
121− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
122− reg = <0x670 0x10>;
123− interrupts = <1 16 0>;
12459 gpio-controller;
12560 #gpio-cells = <2>;
12661 };
12762
128− rtc@800 { // Real time clock
129− compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
130− reg = <0x800 0x100>;
131− interrupts = <1 5 0 1 6 0>;
132− };
133−
134− can@900 {
135− compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
136− interrupts = <2 17 0>;
137− reg = <0x900 0x80>;
138− };
139−
140− can@980 {
141− compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
142− interrupts = <2 18 0>;
143− reg = <0x980 0x80>;
144− };
145−
146− gpio_simple: gpio@b00 {
147− compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
148− reg = <0xb00 0x40>;
149− interrupts = <1 7 0>;
150− gpio-controller;
151− #gpio-cells = <2>;
152− };
153−
154− gpio_wkup: gpio@c00 {
155− compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
156− reg = <0xc00 0x40>;
157− interrupts = <1 8 0 0 3 0>;
158− gpio-controller;
159− #gpio-cells = <2>;
160− };
161−
162− spi@f00 {
163− compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
164− reg = <0xf00 0x20>;
165− interrupts = <2 13 0 2 14 0>;
166− };
167−
168− usb@1000 {
169− compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
170− reg = <0x1000 0xff>;
171− interrupts = <2 6 0>;
172− };
173−
174− dma-controller@1200 {
175− compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
176− reg = <0x1200 0x80>;
177− interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
178− 3 4 0 3 5 0 3 6 0 3 7 0
179− 3 8 0 3 9 0 3 10 0 3 11 0
180− 3 12 0 3 13 0 3 14 0 3 15 0>;
181− };
182−
183− xlb@1f00 {
184− compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
185− reg = <0x1f00 0x100>;
186− };
187−
188− ac97@2000 { /* PSC1 is ac97 */
63+ psc@2000 { /* PSC1 is ac97 */
18964 compatible = "fsl,mpc5200b-psc-ac97","fsl,mpc5200-psc-ac97";
19065 cell-index = <0>;
191− reg = <0x2000 0x100>;
192− interrupts = <2 1 0>;
19366 };
19467
19568 /* PSC2 port is used by CAN1/2 */
69+ psc@2200 {
70+ status = "disabled";
71+ };
19672
197− serial@2400 { /* PSC3 in UART mode */
73+ psc@2400 { /* PSC3 in UART mode */
19874 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
199− cell-index = <2>;
200− reg = <0x2400 0x100>;
201− interrupts = <2 3 0>;
20275 };
20376
20477 /* PSC4 is ??? */
78+ psc@2600 {
79+ status = "disabled";
80+ };
20581
20682 /* PSC5 is ??? */
83+ psc@2800 {
84+ status = "disabled";
85+ };
20786
208− serial@2c00 { /* PSC6 in UART mode */
87+ psc@2c00 { /* PSC6 in UART mode */
20988 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
210− cell-index = <5>;
211− reg = <0x2c00 0x100>;
212− interrupts = <2 4 0>;
21389 };
21490
21591 ethernet@3000 {
216− compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
217− reg = <0x3000 0x400>;
218− local-mac-address = [ 00 00 00 00 00 00 ];
219− interrupts = <2 5 0>;
22092 phy-handle = <&phy0>;
22193 };
22294
22395 mdio@3000 {
224− #address-cells = <1>;
225− #size-cells = <0>;
226− compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
227− reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
228− interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
229−
23096 phy0: ethernet-phy@0 {
23197 reg = <0>;
23298 };
23399 };
234100
235− ata@3a00 {
236− compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
237− reg = <0x3a00 0x100>;
238− interrupts = <2 7 0>;
239− };
240−
241− i2c@3d00 {
242− #address-cells = <1>;
243− #size-cells = <0>;
244− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
245− reg = <0x3d00 0x40>;
246− interrupts = <2 15 0>;
247− };
248−
249101 i2c@3d40 {
250− #address-cells = <1>;
251− #size-cells = <0>;
252− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
253− reg = <0x3d40 0x40>;
254− interrupts = <2 16 0>;
255102 rtc@51 {
256103 compatible = "nxp,pcf8563";
257104 reg = <0x51>;
258105 };
259106 eeprom@52 {
260− compatible = "at24,24c32";
107+ compatible = "catalyst,24c32";
261108 reg = <0x52>;
109+ pagesize = <32>;
262110 };
263111 };
264−
265− sram@8000 {
266− compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
267− reg = <0x8000 0x4000>;
268− };
269112 };
270113
271114 pci@f0000d00 {
272− #interrupt-cells = <1>;
273− #size-cells = <2>;
274− #address-cells = <3>;
275− device_type = "pci";
276− compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
277− reg = <0xf0000d00 0x100>;
278115 interrupt-map-mask = <0xf800 0 0 7>;
279116 interrupt-map = <0xc000 0 0 1 &mpc5200_pic 0 0 3 // 1st slot
280117 0xc000 0 0 2 &mpc5200_pic 1 1 3
@@ -285,20 +122,12 @@ · 4 unmodified lines
285122 0xc800 0 0 2 &mpc5200_pic 1 2 3
286123 0xc800 0 0 3 &mpc5200_pic 1 3 3
287124 0xc800 0 0 4 &mpc5200_pic 0 0 3>;
288− clock-frequency = <0>; // From boot loader
289− interrupts = <2 8 0 2 9 0 2 10 0>;
290− bus-range = <0 0>;
291125 ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
292126 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
293127 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
294128 };
295129
296130 localbus {
297− compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus";
298−
299− #address-cells = <2>;
300− #size-cells = <1>;
301−
302131 ranges = <0 0 0xfe000000 0x02000000
303132 1 0 0xfc000000 0x02000000
304133 2 0 0xfbe00000 0x00200000
@@ -351,40 +180,39 @@ · 46 unmodified lines
351180 bank-width = <2>;
352181 };
353182
354− /*
183+ /*
355184 * example snippets for FPGA
356185 *
357186 * fpga@3,0 {
358− * compatible = "fpga_driver";
359− * reg = <3 0 0x02000000>;
360− * bank-width = <4>;
187+ * compatible = "fpga_driver";
188+ * reg = <3 0 0x02000000>;
189+ * bank-width = <4>;
361190 * };
362191 *
363192 * fpga@4,0 {
364− * compatible = "fpga_driver";
365− * reg = <4 0 0x02000000>;
366− * bank-width = <4>;
193+ * compatible = "fpga_driver";
194+ * reg = <4 0 0x02000000>;
195+ * bank-width = <4>;
367196 * };
368− */
197+ */
369198
370− /*
199+ /*
371200 * example snippets for free chipselects
372− *
201+ *
373202 * device@5,0 {
374− * compatible = "custom_driver";
375− * reg = <5 0 0x02000000>;
203+ * compatible = "custom_driver";
204+ * reg = <5 0 0x02000000>;
376205 * };
377− *
206+ *
378207 * device@6,0 {
379− * compatible = "custom_driver";
380− * reg = <6 0 0x02000000>;
208+ * compatible = "custom_driver";
209+ * reg = <6 0 0x02000000>;
381210 * };
382− *
211+ *
383212 * device@7,0 {
384− * compatible = "custom_driver";
385− * reg = <7 0 0x02000000>;
213+ * compatible = "custom_driver";
214+ * reg = <7 0 0x02000000>;
386215 * };
387− */
216+ */
388217 };
389218 };
390−
arch/powerpc/boot/dts/uc101.dts+33−127
@@ -11,79 +11,24 @@ · 10 unmodified lines
1111 * option) any later version.
1212 */
1313
14−/dts-v1/;
14+/include/ "mpc5200b.dtsi"
1515
1616 / {
1717 model = "manroland,uc101";
1818 compatible = "manroland,uc101";
19− #address-cells = <1>;
20− #size-cells = <1>;
21− interrupt-parent = <&mpc5200_pic>;
22−
23− cpus {
24− #address-cells = <1>;
25− #size-cells = <0>;
26−
27− PowerPC,5200@0 {
28− device_type = "cpu";
29− reg = <0>;
30− d-cache-line-size = <32>;
31− i-cache-line-size = <32>;
32− d-cache-size = <0x4000>; // L1, 16K
33− i-cache-size = <0x4000>; // L1, 16K
34− timebase-frequency = <0>; // from bootloader
35− bus-frequency = <0>; // from bootloader
36− clock-frequency = <0>; // from bootloader
37− };
38− };
39−
40− memory {
41− device_type = "memory";
42− reg = <0x00000000 0x04000000>; // 64MB
43− };
4419
4520 soc5200@f0000000 {
46− #address-cells = <1>;
47− #size-cells = <1>;
48− compatible = "fsl,mpc5200b-immr";
49− ranges = <0 0xf0000000 0x0000c000>;
50− reg = <0xf0000000 0x00000100>;
51− bus-frequency = <0>; // from bootloader
52− system-frequency = <0>; // from bootloader
53−
54− cdm@200 {
55− compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
56− reg = <0x200 0x38>;
57− };
58−
59− mpc5200_pic: interrupt-controller@500 {
60− // 5200 interrupts are encoded into two levels;
61− interrupt-controller;
62− #interrupt-cells = <3>;
63− compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
64− reg = <0x500 0x80>;
65− };
66−
6721 gpt0: timer@600 { // General Purpose Timer in GPIO mode
68− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
69− reg = <0x600 0x10>;
70− interrupts = <1 9 0>;
7122 gpio-controller;
7223 #gpio-cells = <2>;
7324 };
7425
7526 gpt1: timer@610 { // General Purpose Timer in GPIO mode
76− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
77− reg = <0x610 0x10>;
78− interrupts = <1 10 0>;
7927 gpio-controller;
8028 #gpio-cells = <2>;
8129 };
8230
8331 gpt2: timer@620 { // General Purpose Timer in GPIO mode
84− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
85− reg = <0x620 0x10>;
86− interrupts = <1 11 0>;
8732 gpio-controller;
8833 #gpio-cells = <2>;
8934 };
@@ -97,118 +42,85 @@ · 7 unmodified lines
9742 };
9843
9944 gpt4: timer@640 { // General Purpose Timer in GPIO mode
100− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
101− reg = <0x640 0x10>;
102− interrupts = <1 13 0>;
10345 gpio-controller;
10446 #gpio-cells = <2>;
10547 };
10648
10749 gpt5: timer@650 { // General Purpose Timer in GPIO mode
108− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
109− reg = <0x650 0x10>;
110− interrupts = <1 14 0>;
11150 gpio-controller;
11251 #gpio-cells = <2>;
11352 };
11453
11554 gpt6: timer@660 { // General Purpose Timer in GPIO mode
116− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
117− reg = <0x660 0x10>;
118− interrupts = <1 15 0>;
11955 gpio-controller;
12056 #gpio-cells = <2>;
12157 };
12258
12359 gpt7: timer@670 { // General Purpose Timer in GPIO mode
124− compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
125− reg = <0x670 0x10>;
126− interrupts = <1 16 0>;
12760 gpio-controller;
12861 #gpio-cells = <2>;
12962 };
13063
131− gpio_simple: gpio@b00 {
132− compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
133− reg = <0xb00 0x40>;
134− interrupts = <1 7 0>;
135− gpio-controller;
136− #gpio-cells = <2>;
64+ rtc@800 {
65+ status = "disabled";
13766 };
13867
139− gpio_wkup: gpio@c00 {
140− compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
141− reg = <0xc00 0x40>;
142− interrupts = <1 8 0 0 3 0>;
143− gpio-controller;
144− #gpio-cells = <2>;
68+ can@900 {
69+ status = "disabled";
70+ };
71+
72+ can@980 {
73+ status = "disabled";
14574 };
14675
147− dma-controller@1200 {
148− compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
149− reg = <0x1200 0x80>;
150− interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
151− 3 4 0 3 5 0 3 6 0 3 7 0
152− 3 8 0 3 9 0 3 10 0 3 11 0
153− 3 12 0 3 13 0 3 14 0 3 15 0>;
76+ spi@f00 {
77+ status = "disabled";
15478 };
15579
156− xlb@1f00 {
157− compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
158− reg = <0x1f00 0x100>;
80+ usb@1000 {
81+ status = "disabled";
15982 };
16083
161− serial@2000 { /* PSC1 in UART mode */
84+ psc@2000 { // PSC1
16285 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
163− reg = <0x2000 0x100>;
164− interrupts = <2 1 0>;
16586 };
16687
167− serial@2200 { /* PSC2 in UART mode */
88+ psc@2200 { // PSC2
16889 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
169− reg = <0x2200 0x100>;
170− interrupts = <2 2 0>;
17190 };
17291
173− serial@2c00 { /* PSC6 in UART mode */
92+ psc@2400 { // PSC3
93+ status = "disabled";
94+ };
95+
96+ psc@2600 { // PSC4
97+ status = "disabled";
98+ };
99+
100+ psc@2800 { // PSC5
101+ status = "disabled";
102+ };
103+
104+ psc@2c00 { // PSC6
174105 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
175− reg = <0x2c00 0x100>;
176− interrupts = <2 4 0>;
177106 };
178107
179108 ethernet@3000 {
180− compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
181− reg = <0x3000 0x400>;
182− local-mac-address = [ 00 00 00 00 00 00 ];
183− interrupts = <2 5 0>;
184109 phy-handle = <&phy0>;
185110 };
186111
187112 mdio@3000 {
188− #address-cells = <1>;
189− #size-cells = <0>;
190− compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
191− reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
192− interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
193−
194113 phy0: ethernet-phy@0 {
195114 compatible = "intel,lxt971";
196115 reg = <0>;
197116 };
198117 };
199118
200− ata@3a00 {
201− compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
202− reg = <0x3a00 0x100>;
203− interrupts = <2 7 0>;
119+ i2c@3d00 {
120+ status = "disabled";
204121 };
205122
206123 i2c@3d40 {
207− #address-cells = <1>;
208− #size-cells = <0>;
209− compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
210− reg = <0x3d40 0x40>;
211− interrupts = <2 16 0>;
212124 fsl,preserve-clocking;
213125 clock-frequency = <400000>;
214126
@@ -221,19 +133,13 @@ · 6 unmodified lines
221133 reg = <0x51>;
222134 };
223135 };
136+ };
224137
225− sram@8000 {
226− compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
227− reg = <0x8000 0x4000>;
228− };
138+ pci@f0000d00 {
139+ status = "disabled";
229140 };
230141
231142 localbus {
232− compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus";
233−
234− #address-cells = <2>;
235− #size-cells = <1>;
236−
237143 ranges = <0 0 0xff800000 0x00800000
238144 1 0 0x80000000 0x00800000
239145 3 0 0x80000000 0x00800000>;
arch/powerpc/include/asm/prom.h+1−4
@@ -42,7 +42,7 @@ extern void pci_create_OF_bus_map(void); · 41 unmodified lines
4242
4343 /* Translate a DMA address from device space to CPU space */
4444 extern u64 of_translate_dma_address(struct device_node *dev,
45− const u32 *in_addr);
45+ const __be32 *in_addr);
4646
4747 #ifdef CONFIG_PCI
4848 extern unsigned long pci_address_to_pio(phys_addr_t address);
@@ -63,9 +63,6 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); · 14 unmodified lines
6363 /* cache lookup */
6464 struct device_node *of_find_next_cache_node(struct device_node *np);
6565
66−/* Get the MAC address */
67−extern const void *of_get_mac_address(struct device_node *np);
68−
6966 #ifdef CONFIG_NUMA
7067 extern int of_node_to_nid(struct device_node *device);
7168 #else
arch/powerpc/kernel/prom_parse.c+0−38
@@ -117,41 +117,3 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, · 116 unmodified lines
117117 cells = prop ? *(u32 *)prop : of_n_size_cells(dn);
118118 *size = of_read_number(dma_window, cells);
119119 }
120−
121−/**
122− * Search the device tree for the best MAC address to use. 'mac-address' is
123− * checked first, because that is supposed to contain to "most recent" MAC
124− * address. If that isn't set, then 'local-mac-address' is checked next,
125− * because that is the default address. If that isn't set, then the obsolete
126− * 'address' is checked, just in case we're using an old device tree.
127− *
128− * Note that the 'address' property is supposed to contain a virtual address of
129− * the register set, but some DTS files have redefined that property to be the
130− * MAC address.
131− *
132− * All-zero MAC addresses are rejected, because those could be properties that
133− * exist in the device tree, but were not set by U-Boot. For example, the
134− * DTS could define 'mac-address' and 'local-mac-address', with zero MAC
135− * addresses. Some older U-Boots only initialized 'local-mac-address'. In
136− * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
137− * but is all zeros.
138−*/
139−const void *of_get_mac_address(struct device_node *np)
140−{
141− struct property *pp;
142−
143− pp = of_find_property(np, "mac-address", NULL);
144− if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
145− return pp->value;
146−
147− pp = of_find_property(np, "local-mac-address", NULL);
148− if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
149− return pp->value;
150−
151− pp = of_find_property(np, "address", NULL);
152− if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
153− return pp->value;
154−
155− return NULL;
156−}
157−EXPORT_SYMBOL(of_get_mac_address);
arch/powerpc/platforms/40x/ppc40x_simple.c+4−9
@@ -50,7 +50,7 @@ machine_device_initcall(ppc40x_simple, ppc40x_device_probe); · 49 unmodified lines
5050 * Again, if your board needs to do things differently then create a
5151 * board.c file for it rather than adding it to this list.
5252 */
53−static char *board[] __initdata = {
53+static const char *board[] __initdata = {
5454 "amcc,acadia",
5555 "amcc,haleakala",
5656 "amcc,kilauea",
@@ -60,14 +60,9 @@ static char *board[] __initdata = { · 3 unmodified lines
6060
6161 static int __init ppc40x_probe(void)
6262 {
63− unsigned long root = of_get_flat_dt_root();
64− int i = 0;
65−
66− for (i = 0; i < ARRAY_SIZE(board); i++) {
67− if (of_flat_dt_is_compatible(root, board[i])) {
68− ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
69− return 1;
70− }
63+ if (of_flat_dt_match(of_get_flat_dt_root(), board)) {
64+ ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
65+ return 1;
7166 }
7267
7368 return 0;
arch/powerpc/platforms/512x/mpc5121_generic.c+2−11
@@ -26,7 +26,7 @@ · 25 unmodified lines
2626 /*
2727 * list of supported boards
2828 */
29−static char *board[] __initdata = {
29+static const char *board[] __initdata = {
3030 "prt,prtlvt",
3131 NULL
3232 };
@@ -36,16 +36,7 @@ static char *board[] __initdata = { · 3 unmodified lines
3636 */
3737 static int __init mpc5121_generic_probe(void)
3838 {
39− unsigned long node = of_get_flat_dt_root();
40− int i = 0;
41−
42− while (board[i]) {
43− if (of_flat_dt_is_compatible(node, board[i]))
44− break;
45− i++;
46− }
47−
48− return board[i] != NULL;
39+ return of_flat_dt_match(of_get_flat_dt_root(), board);
4940 }
5041
5142 define_machine(mpc5121_generic) {
arch/powerpc/platforms/52xx/lite5200.c+7−9
@@ -172,20 +172,18 @@ static void __init lite5200_setup_arch(void) · 171 unmodified lines
172172 mpc52xx_setup_pci();
173173 }
174174
175+static const char *board[] __initdata = {
176+ "fsl,lite5200",
177+ "fsl,lite5200b",
178+ NULL,
179+};
180+
175181 /*
176182 * Called very early, MMU is off, device-tree isn't unflattened
177183 */
178184 static int __init lite5200_probe(void)
179185 {
180− unsigned long node = of_get_flat_dt_root();
181− const char *model = of_get_flat_dt_prop(node, "model", NULL);
182−
183− if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
184− !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
185− return 0;
186− pr_debug("%s board found\n", model ? model : "unknown");
187−
188− return 1;
186+ return of_flat_dt_match(of_get_flat_dt_root(), board);
189187 }
190188
191189 define_machine(lite5200) {
arch/powerpc/platforms/52xx/media5200.c+2−11
@@ -239,7 +239,7 @@ static void __init media5200_setup_arch(void) · 238 unmodified lines
239239 }
240240
241241 /* list of the supported boards */
242−static char *board[] __initdata = {
242+static const char *board[] __initdata = {
243243 "fsl,media5200",
244244 NULL
245245 };
@@ -249,16 +249,7 @@ static char *board[] __initdata = { · 3 unmodified lines
249249 */
250250 static int __init media5200_probe(void)
251251 {
252− unsigned long node = of_get_flat_dt_root();
253− int i = 0;
254−
255− while (board[i]) {
256− if (of_flat_dt_is_compatible(node, board[i]))
257− break;
258− i++;
259− }
260−
261− return (board[i] != NULL);
252+ return of_flat_dt_match(of_get_flat_dt_root(), board);
262253 }
263254
264255 define_machine(media5200_platform) {
arch/powerpc/platforms/52xx/mpc5200_simple.c+2−11
@@ -49,7 +49,7 @@ static void __init mpc5200_simple_setup_arch(void) · 48 unmodified lines
4949 }
5050
5151 /* list of the supported boards */
52−static char *board[] __initdata = {
52+static const char *board[] __initdata = {
5353 "intercontrol,digsy-mtc",
5454 "manroland,mucmc52",
5555 "manroland,uc101",
@@ -66,16 +66,7 @@ static char *board[] __initdata = { · 10 unmodified lines
6666 */
6767 static int __init mpc5200_simple_probe(void)
6868 {
69− unsigned long node = of_get_flat_dt_root();
70− int i = 0;
71−
72− while (board[i]) {
73− if (of_flat_dt_is_compatible(node, board[i]))
74− break;
75− i++;
76− }
77−
78− return (board[i] != NULL);
69+ return of_flat_dt_match(of_get_flat_dt_root(), board);
7970 }
8071
8172 define_machine(mpc5200_simple_platform) {
arch/powerpc/platforms/83xx/mpc830x_rdb.c+8−5
@@ -57,16 +57,19 @@ static void __init mpc830x_rdb_init_IRQ(void) · 56 unmodified lines
5757 ipic_set_default_priority();
5858 }
5959
60+struct const char *board[] __initdata = {
61+ "MPC8308RDB",
62+ "fsl,mpc8308rdb",
63+ "denx,mpc8308_p1m",
64+ NULL
65+}
66+
6067 /*
6168 * Called very early, MMU is off, device-tree isn't unflattened
6269 */
6370 static int __init mpc830x_rdb_probe(void)
6471 {
65− unsigned long root = of_get_flat_dt_root();
66−
67− return of_flat_dt_is_compatible(root, "MPC8308RDB") ||
68− of_flat_dt_is_compatible(root, "fsl,mpc8308rdb") ||
69− of_flat_dt_is_compatible(root, "denx,mpc8308_p1m");
72+ return of_flat_dt_match(of_get_flat_dt_root(), board);
7073 }
7174
7275 static struct of_device_id __initdata of_bus_ids[] = {
arch/powerpc/platforms/83xx/mpc831x_rdb.c+7−4
@@ -60,15 +60,18 @@ static void __init mpc831x_rdb_init_IRQ(void) · 59 unmodified lines
6060 ipic_set_default_priority();
6161 }
6262
63+struct const char *board[] __initdata = {
64+ "MPC8313ERDB",
65+ "fsl,mpc8315erdb",
66+ NULL
67+}
68+
6369 /*
6470 * Called very early, MMU is off, device-tree isn't unflattened
6571 */
6672 static int __init mpc831x_rdb_probe(void)
6773 {
68− unsigned long root = of_get_flat_dt_root();
69−
70− return of_flat_dt_is_compatible(root, "MPC8313ERDB") ||
71− of_flat_dt_is_compatible(root, "fsl,mpc8315erdb");
74+ return of_flat_dt_match(of_get_flat_dt_root(), board);
7275 }
7376
7477 static struct of_device_id __initdata of_bus_ids[] = {
arch/powerpc/platforms/83xx/mpc837x_rdb.c+9−6
@@ -101,17 +101,20 @@ static void __init mpc837x_rdb_init_IRQ(void) · 100 unmodified lines
101101 ipic_set_default_priority();
102102 }
103103
104+static const char *board[] __initdata = {
105+ "fsl,mpc8377rdb",
106+ "fsl,mpc8378rdb",
107+ "fsl,mpc8379rdb",
108+ "fsl,mpc8377wlan",
109+ NULL
110+};
111+
104112 /*
105113 * Called very early, MMU is off, device-tree isn't unflattened
106114 */
107115 static int __init mpc837x_rdb_probe(void)
108116 {
109− unsigned long root = of_get_flat_dt_root();
110−
111− return of_flat_dt_is_compatible(root, "fsl,mpc8377rdb") ||
112− of_flat_dt_is_compatible(root, "fsl,mpc8378rdb") ||
113− of_flat_dt_is_compatible(root, "fsl,mpc8379rdb") ||
114− of_flat_dt_is_compatible(root, "fsl,mpc8377wlan");
117+ return of_flat_dt_match(of_get_flat_dt_root(), board);
115118 }
116119
117120 define_machine(mpc837x_rdb) {
arch/powerpc/platforms/85xx/tqm85xx.c+10−10
@@ -186,21 +186,21 @@ static int __init declare_of_platform_devices(void) · 185 unmodified lines
186186 }
187187 machine_device_initcall(tqm85xx, declare_of_platform_devices);
188188
189+static const char *board[] __initdata = {
190+ "tqc,tqm8540",
191+ "tqc,tqm8541",
192+ "tqc,tqm8548",
193+ "tqc,tqm8555",
194+ "tqc,tqm8560",
195+ NULL
196+};
197+
189198 /*
190199 * Called very early, device-tree isn't unflattened
191200 */
192201 static int __init tqm85xx_probe(void)
193202 {
194− unsigned long root = of_get_flat_dt_root();
195−
196− if ((of_flat_dt_is_compatible(root, "tqc,tqm8540")) ||
197− (of_flat_dt_is_compatible(root, "tqc,tqm8541")) ||
198− (of_flat_dt_is_compatible(root, "tqc,tqm8548")) ||
199− (of_flat_dt_is_compatible(root, "tqc,tqm8555")) ||
200− (of_flat_dt_is_compatible(root, "tqc,tqm8560")))
201− return 1;
202−
203− return 0;
203+ return of_flat_dt_match(of_get_flat_dt_root(), board);
204204 }
205205
206206 define_machine(tqm85xx) {
arch/powerpc/sysdev/mv64x60_dev.c+1−0
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include <linux/mv643xx.h>
1717 #include <linux/platform_device.h>
1818 #include <linux/of_platform.h>
19+#include <linux/of_net.h>
1920 #include <linux/dma-mapping.h>
2021
2122 #include <asm/prom.h>
arch/powerpc/sysdev/tsi108_dev.c+1−0
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #include <linux/module.h>
2020 #include <linux/device.h>
2121 #include <linux/platform_device.h>
22+#include <linux/of_net.h>
2223 #include <asm/tsi108.h>
2324
2425 #include <asm/system.h>
arch/sparc/kernel/auxio_32.c+1−1
@@ -121,7 +121,7 @@ void __init auxio_power_probe(void) · 120 unmodified lines
121121 node = prom_searchsiblings(node, "obio");
122122 node = prom_getchild(node);
123123 node = prom_searchsiblings(node, "power");
124− if (node == 0 || node == -1)
124+ if (node == 0 || (s32)node == -1)
125125 return;
126126
127127 /* Map the power control register. */
arch/sparc/kernel/starfire.c+1−1
@@ -24,7 +24,7 @@ int this_is_starfire = 0; · 23 unmodified lines
2424 void check_if_starfire(void)
2525 {
2626 phandle ssnode = prom_finddevice("/ssp-serial");
27− if (ssnode != 0 && ssnode != -1)
27+ if (ssnode != 0 && (s32)ssnode != -1)
2828 this_is_starfire = 1;
2929 }
3030
arch/sparc/prom/init_32.c+1−1
@@ -60,7 +60,7 @@ void __init prom_init(struct linux_romvec *rp) · 59 unmodified lines
6060 prom_nodeops = romvec->pv_nodeops;
6161
6262 prom_root_node = prom_getsibling(0);
63− if((prom_root_node == 0) || (prom_root_node == -1))
63+ if ((prom_root_node == 0) || ((s32)prom_root_node == -1))
6464 prom_halt();
6565
6666 if((((unsigned long) prom_nodeops) == 0) ||
arch/sparc/prom/init_64.c+2−2
@@ -35,13 +35,13 @@ void __init prom_init(void *cif_handler, void *cif_stack) · 34 unmodified lines
3535 prom_cif_init(cif_handler, cif_stack);
3636
3737 prom_chosen_node = prom_finddevice(prom_chosen_path);
38− if (!prom_chosen_node || prom_chosen_node == -1)
38+ if (!prom_chosen_node || (s32)prom_chosen_node == -1)
3939 prom_halt();
4040
4141 prom_stdout = prom_getint(prom_chosen_node, "stdout");
4242
4343 node = prom_finddevice("/openprom");
44− if (!node || node == -1)
44+ if (!node || (s32)node == -1)
4545 prom_halt();
4646
4747 prom_getstring(node, "version", prom_version, sizeof(prom_version));
arch/sparc/prom/tree_32.c+9−8
@@ -40,11 +40,11 @@ phandle prom_getchild(phandle node) · 39 unmodified lines
4040 {
4141 phandle cnode;
4242
43− if (node == -1)
43+ if ((s32)node == -1)
4444 return 0;
4545
4646 cnode = __prom_getchild(node);
47− if (cnode == 0 || cnode == -1)
47+ if (cnode == 0 || (s32)cnode == -1)
4848 return 0;
4949
5050 return cnode;
@@ -72,11 +72,11 @@ phandle prom_getsibling(phandle node) · 21 unmodified lines
7272 {
7373 phandle sibnode;
7474
75− if (node == -1)
75+ if ((s32)node == -1)
7676 return 0;
7777
7878 sibnode = __prom_getsibling(node);
79− if (sibnode == 0 || sibnode == -1)
79+ if (sibnode == 0 || (s32)sibnode == -1)
8080 return 0;
8181
8282 return sibnode;
@@ -219,7 +219,7 @@ static char *__prom_nextprop(phandle node, char * oprop) · 136 unmodified lines
219219 */
220220 char *prom_nextprop(phandle node, char *oprop, char *buffer)
221221 {
222− if (node == 0 || node == -1)
222+ if (node == 0 || (s32)node == -1)
223223 return "";
224224
225225 return __prom_nextprop(node, oprop);
@@ -253,7 +253,7 @@ phandle prom_finddevice(char *name) · 27 unmodified lines
253253 if (d != s + 3 && (!*d || *d == '/')
254254 && d <= s + 3 + 8) {
255255 node2 = node;
256− while (node2 && node2 != -1) {
256+ while (node2 && (s32)node2 != -1) {
257257 if (prom_getproperty (node2, "reg", (char *)reg, sizeof (reg)) > 0) {
258258 if (which_io == reg[0].which_io && phys_addr == reg[0].phys_addr) {
259259 node = node2;
@@ -261,7 +261,7 @@ phandle prom_finddevice(char *name) · 1 unmodified line
261261 }
262262 }
263263 node2 = prom_getsibling(node2);
264− if (!node2 || node2 == -1)
264+ if (!node2 || (s32)node2 == -1)
265265 break;
266266 node2 = prom_searchsiblings(prom_getsibling(node2), nbuf);
267267 }
@@ -303,6 +303,7 @@ phandle prom_inst2pkg(int inst) · 35 unmodified lines
303303 node = (*romvec->pv_v2devops.v2_inst2pkg)(inst);
304304 restore_current();
305305 spin_unlock_irqrestore(&prom_lock, flags);
306− if (node == -1) return 0;
306+ if ((s32)node == -1)
307+ return 0;
307308 return node;
308309 }
arch/sparc/prom/tree_64.c+9−9
@@ -43,10 +43,10 @@ inline phandle prom_getchild(phandle node) · 42 unmodified lines
4343 {
4444 phandle cnode;
4545
46− if (node == -1)
46+ if ((s32)node == -1)
4747 return 0;
4848 cnode = __prom_getchild(node);
49− if (cnode == -1)
49+ if ((s32)cnode == -1)
5050 return 0;
5151 return cnode;
5252 }
@@ -56,10 +56,10 @@ inline phandle prom_getparent(phandle node) · 3 unmodified lines
5656 {
5757 phandle cnode;
5858
59− if (node == -1)
59+ if ((s32)node == -1)
6060 return 0;
6161 cnode = prom_node_to_node("parent", node);
62− if (cnode == -1)
62+ if ((s32)cnode == -1)
6363 return 0;
6464 return cnode;
6565 }
@@ -76,10 +76,10 @@ inline phandle prom_getsibling(phandle node) · 10 unmodified lines
7676 {
7777 phandle sibnode;
7878
79− if (node == -1)
79+ if ((s32)node == -1)
8080 return 0;
8181 sibnode = __prom_getsibling(node);
82− if (sibnode == -1)
82+ if ((s32)sibnode == -1)
8383 return 0;
8484
8585 return sibnode;
@@ -240,7 +240,7 @@ inline char *prom_firstprop(phandle node, char *buffer) · 154 unmodified lines
240240 unsigned long args[7];
241241
242242 *buffer = 0;
243− if (node == -1)
243+ if ((s32)node == -1)
244244 return buffer;
245245
246246 args[0] = (unsigned long) prom_nextprop_name;
@@ -266,7 +266,7 @@ inline char *prom_nextprop(phandle node, const char *oprop, char *buffer) · 19 unmodified lines
266266 unsigned long args[7];
267267 char buf[32];
268268
269− if (node == -1) {
269+ if ((s32)node == -1) {
270270 *buffer = 0;
271271 return buffer;
272272 }
@@ -369,7 +369,7 @@ inline phandle prom_inst2pkg(int inst) · 96 unmodified lines
369369 p1275_cmd_direct(args);
370370
371371 node = (int) args[4];
372− if (node == -1)
372+ if ((s32)node == -1)
373373 return 0;
374374 return node;
375375 }
drivers/char/ipmi/ipmi_si_intf.c+6−4
@@ -69,6 +69,8 @@ · 68 unmodified lines
6969 #ifdef CONFIG_PPC_OF
7070 #include <linux/of_device.h>
7171 #include <linux/of_platform.h>
72+#include <linux/of_address.h>
73+#include <linux/of_irq.h>
7274 #endif
7375
7476 #define PFX "ipmi_si: "
@@ -2546,7 +2548,7 @@ static int __devinit ipmi_of_probe(struct platform_device *dev, · 2471 unmodified lines
25462548 {
25472549 struct smi_info *info;
25482550 struct resource resource;
2549− const int *regsize, *regspacing, *regshift;
2551+ const __be32 *regsize, *regspacing, *regshift;
25502552 struct device_node *np = dev->dev.of_node;
25512553 int ret;
25522554 int proplen;
@@ -2599,9 +2601,9 @@ static int __devinit ipmi_of_probe(struct platform_device *dev, · 46 unmodified lines
25992601
26002602 info->io.addr_data = resource.start;
26012603
2602− info->io.regsize = regsize ? *regsize : DEFAULT_REGSIZE;
2603− info->io.regspacing = regspacing ? *regspacing : DEFAULT_REGSPACING;
2604− info->io.regshift = regshift ? *regshift : 0;
2604+ info->io.regsize = regsize ? be32_to_cpup(regsize) : DEFAULT_REGSIZE;
2605+ info->io.regspacing = regspacing ? be32_to_cpup(regspacing) : DEFAULT_REGSPACING;
2606+ info->io.regshift = regshift ? be32_to_cpup(regshift) : 0;
26052607
26062608 info->irq = irq_of_parse_and_map(dev->dev.of_node, 0);
26072609 info->dev = &dev->dev;
drivers/misc/eeprom/at24.c+37−6
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 #include <linux/log2.h>
2121 #include <linux/bitops.h>
2222 #include <linux/jiffies.h>
23+#include <linux/of.h>
2324 #include <linux/i2c.h>
2425 #include <linux/i2c/at24.h>
2526
@@ -457,6 +458,27 @@ static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf, · 431 unmodified lines
457458
458459 /*-------------------------------------------------------------------------*/
459460
461+#ifdef CONFIG_OF
462+static void at24_get_ofdata(struct i2c_client *client,
463+ struct at24_platform_data *chip)
464+{
465+ const __be32 *val;
466+ struct device_node *node = client->dev.of_node;
467+
468+ if (node) {
469+ if (of_get_property(node, "read-only", NULL))
470+ chip->flags |= AT24_FLAG_READONLY;
471+ val = of_get_property(node, "pagesize", NULL);
472+ if (val)
473+ chip->page_size = be32_to_cpup(val);
474+ }
475+}
476+#else
477+static void at24_get_ofdata(struct i2c_client *client,
478+ struct at24_platform_data *chip)
479+{ }
480+#endif /* CONFIG_OF */
481+
460482 static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
461483 {
462484 struct at24_platform_data chip;
@@ -485,6 +507,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) · 22 unmodified lines
485507 */
486508 chip.page_size = 1;
487509
510+ /* update chipdata if OF is present */
511+ at24_get_ofdata(client, &chip);
512+
488513 chip.setup = NULL;
489514 chip.context = NULL;
490515 }
@@ -492,6 +517,11 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) · 1 unmodified line
492517 if (!is_power_of_2(chip.byte_len))
493518 dev_warn(&client->dev,
494519 "byte_len looks suspicious (no power of 2)!\n");
520+ if (!chip.page_size) {
521+ dev_err(&client->dev, "page_size must not be 0!\n");
522+ err = -EINVAL;
523+ goto err_out;
524+ }
495525 if (!is_power_of_2(chip.page_size))
496526 dev_warn(&client->dev,
497527 "page_size looks suspicious (no power of 2)!\n");
@@ -597,19 +627,15 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) · 99 unmodified lines
597627
598628 i2c_set_clientdata(client, at24);
599629
600− dev_info(&client->dev, "%zu byte %s EEPROM %s\n",
630+ dev_info(&client->dev, "%zu byte %s EEPROM, %s, %u bytes/write\n",
601631 at24->bin.size, client->name,
602− writable ? "(writable)" : "(read-only)");
632+ writable ? "writable" : "read-only", at24->write_max);
603633 if (use_smbus == I2C_SMBUS_WORD_DATA ||
604634 use_smbus == I2C_SMBUS_BYTE_DATA) {
605635 dev_notice(&client->dev, "Falling back to %s reads, "
606636 "performance will suffer\n", use_smbus ==
607637 I2C_SMBUS_WORD_DATA ? "word" : "byte");
608638 }
609− dev_dbg(&client->dev,
610− "page_size %d, num_addresses %d, write_max %d, use_smbus %d\n",
611− chip.page_size, num_addresses,
612− at24->write_max, use_smbus);
613639
614640 /* export data to kernel code */
615641 if (chip.setup)
@@ -660,6 +686,11 @@ static struct i2c_driver at24_driver = { · 44 unmodified lines
660686
661687 static int __init at24_init(void)
662688 {
689+ if (!io_limit) {
690+ pr_err("at24: io_limit must not be 0!\n");
691+ return -EINVAL;
692+ }
693+
663694 io_limit = rounddown_pow_of_two(io_limit);
664695 return i2c_add_driver(&at24_driver);
665696 }
drivers/mmc/host/Kconfig+3−1
@@ -83,7 +83,7 @@ config MMC_RICOH_MMC · 82 unmodified lines
8383
8484 config MMC_SDHCI_OF
8585 tristate "SDHCI support on OpenFirmware platforms"
86− depends on MMC_SDHCI && PPC_OF
86+ depends on MMC_SDHCI && OF
8787 help
8888 This selects the OF support for Secure Digital Host Controller
8989 Interfaces.
@@ -93,6 +93,7 @@ config MMC_SDHCI_OF · 3 unmodified lines
9393 config MMC_SDHCI_OF_ESDHC
9494 bool "SDHCI OF support for the Freescale eSDHC controller"
9595 depends on MMC_SDHCI_OF
96+ depends on PPC_OF
9697 select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
9798 help
9899 This selects the Freescale eSDHC controller support.
@@ -102,6 +103,7 @@ config MMC_SDHCI_OF_ESDHC · 3 unmodified lines
102103 config MMC_SDHCI_OF_HLWD
103104 bool "SDHCI OF support for the Nintendo Wii SDHCI controllers"
104105 depends on MMC_SDHCI_OF
106+ depends on PPC_OF
105107 select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
106108 help
107109 This selects the Secure Digital Host Controller Interface (SDHCI)
drivers/mmc/host/sdhci-of-core.c+2−2
@@ -122,7 +122,7 @@ static int __devinit sdhci_of_probe(struct platform_device *ofdev, · 121 unmodified lines
122122 struct sdhci_of_data *sdhci_of_data = match->data;
123123 struct sdhci_host *host;
124124 struct sdhci_of_host *of_host;
125− const u32 *clk;
125+ const __be32 *clk;
126126 int size;
127127 int ret;
128128
@@ -166,7 +166,7 @@ static int __devinit sdhci_of_probe(struct platform_device *ofdev, · 37 unmodified lines
166166
167167 clk = of_get_property(np, "clock-frequency", &size);
168168 if (clk && size == sizeof(*clk) && *clk)
169− of_host->clock = *clk;
169+ of_host->clock = be32_to_cpup(clk);
170170
171171 ret = sdhci_add_host(host);
172172 if (ret)
drivers/mtd/Kconfig+1−1
@@ -159,7 +159,7 @@ config MTD_AFS_PARTS · 158 unmodified lines
159159
160160 config MTD_OF_PARTS
161161 tristate "Flash partition map based on OF description"
162− depends on (MICROBLAZE || PPC_OF) && MTD_PARTITIONS
162+ depends on OF && MTD_PARTITIONS
163163 help
164164 This provides a partition parsing function which derives
165165 the partition map from the children of the flash node,
drivers/mtd/maps/Kconfig+1−1
@@ -72,7 +72,7 @@ config MTD_PHYSMAP_BANKWIDTH · 71 unmodified lines
7272
7373 config MTD_PHYSMAP_OF
7474 tristate "Flash device in physical memory map based on OF description"
75− depends on (MICROBLAZE || PPC_OF) && (MTD_CFI || MTD_JEDECPROBE || MTD_ROM)
75+ depends on OF && (MTD_CFI || MTD_JEDECPROBE || MTD_ROM)
7676 help
7777 This provides a 'mapping' driver which allows the NOR Flash and
7878 ROM driver code to communicate with chips which are mapped
drivers/net/fs_enet/fs_enet-main.c+1−0
@@ -40,6 +40,7 @@ · 39 unmodified lines
4040 #include <linux/of_mdio.h>
4141 #include <linux/of_platform.h>
4242 #include <linux/of_gpio.h>
43+#include <linux/of_net.h>
4344
4445 #include <linux/vmalloc.h>
4546 #include <asm/pgtable.h>
drivers/net/gianfar.c+1−0
@@ -95,6 +95,7 @@ · 94 unmodified lines
9595 #include <linux/phy.h>
9696 #include <linux/phy_fixed.h>
9797 #include <linux/of.h>
98+#include <linux/of_net.h>
9899
99100 #include "gianfar.h"
100101 #include "fsl_pq_mdio.h"
drivers/net/ucc_geth.c+1−0
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include <linux/phy.h>
2929 #include <linux/workqueue.h>
3030 #include <linux/of_mdio.h>
31+#include <linux/of_net.h>
3132 #include <linux/of_platform.h>
3233
3334 #include <asm/uaccess.h>
drivers/net/xilinx_emaclite.c+1−0
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include <linux/of_device.h>
2525 #include <linux/of_platform.h>
2626 #include <linux/of_mdio.h>
27+#include <linux/of_net.h>
2728 #include <linux/phy.h>
2829
2930 #define DRIVER_NAME "xilinx_emaclite"
drivers/of/Kconfig+8−0
@@ -19,6 +19,10 @@ config OF_FLATTREE · 18 unmodified lines
1919 bool
2020 select DTC
2121
22+config OF_EARLY_FLATTREE
23+ bool
24+ select OF_FLATTREE
25+
2226 config OF_PROMTREE
2327 bool
2428
@@ -49,6 +53,10 @@ config OF_I2C · 24 unmodified lines
4953 help
5054 OpenFirmware I2C accessors
5155
56+config OF_NET
57+ depends on NETDEVICES
58+ def_bool y
59+
5260 config OF_SPI
5361 def_tristate SPI
5462 depends on SPI && !SPARC
drivers/of/Makefile+1−0
@@ -6,5 +6,6 @@ obj-$(CONFIG_OF_IRQ) += irq.o · 5 unmodified lines
66 obj-$(CONFIG_OF_DEVICE) += device.o platform.o
77 obj-$(CONFIG_OF_GPIO) += gpio.o
88 obj-$(CONFIG_OF_I2C) += of_i2c.o
9+obj-$(CONFIG_OF_NET) += of_net.o
910 obj-$(CONFIG_OF_SPI) += of_spi.o
1011 obj-$(CONFIG_OF_MDIO) += of_mdio.o
drivers/of/address.c+28−26
@@ -12,13 +12,13 @@ · 11 unmodified lines
1212 (ns) > 0)
1313
1414 static struct of_bus *of_match_bus(struct device_node *np);
15−static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
16− u64 size, unsigned int flags,
15+static int __of_address_to_resource(struct device_node *dev,
16+ const __be32 *addrp, u64 size, unsigned int flags,
1717 struct resource *r);
1818
1919 /* Debug utility */
2020 #ifdef DEBUG
21−static void of_dump_addr(const char *s, const u32 *addr, int na)
21+static void of_dump_addr(const char *s, const __be32 *addr, int na)
2222 {
2323 printk(KERN_DEBUG "%s", s);
2424 while (na--)
@@ -26,7 +26,7 @@ static void of_dump_addr(const char *s, const u32 *addr, int na) · 1 unmodified line
2626 printk("\n");
2727 }
2828 #else
29−static void of_dump_addr(const char *s, const u32 *addr, int na) { }
29+static void of_dump_addr(const char *s, const __be32 *addr, int na) { }
3030 #endif
3131
3232 /* Callbacks for bus specific translators */
@@ -36,10 +36,10 @@ struct of_bus { · 3 unmodified lines
3636 int (*match)(struct device_node *parent);
3737 void (*count_cells)(struct device_node *child,
3838 int *addrc, int *sizec);
39− u64 (*map)(u32 *addr, const u32 *range,
39+ u64 (*map)(u32 *addr, const __be32 *range,
4040 int na, int ns, int pna);
4141 int (*translate)(u32 *addr, u64 offset, int na);
42− unsigned int (*get_flags)(const u32 *addr);
42+ unsigned int (*get_flags)(const __be32 *addr);
4343 };
4444
4545 /*
@@ -55,7 +55,7 @@ static void of_bus_default_count_cells(struct device_node *dev, · 9 unmodified lines
5555 *sizec = of_n_size_cells(dev);
5656 }
5757
58−static u64 of_bus_default_map(u32 *addr, const u32 *range,
58+static u64 of_bus_default_map(u32 *addr, const __be32 *range,
5959 int na, int ns, int pna)
6060 {
6161 u64 cp, s, da;
@@ -85,7 +85,7 @@ static int of_bus_default_translate(u32 *addr, u64 offset, int na) · 23 unmodified lines
8585 return 0;
8686 }
8787
88−static unsigned int of_bus_default_get_flags(const u32 *addr)
88+static unsigned int of_bus_default_get_flags(const __be32 *addr)
8989 {
9090 return IORESOURCE_MEM;
9191 }
@@ -110,10 +110,10 @@ static void of_bus_pci_count_cells(struct device_node *np, · 18 unmodified lines
110110 *sizec = 2;
111111 }
112112
113−static unsigned int of_bus_pci_get_flags(const u32 *addr)
113+static unsigned int of_bus_pci_get_flags(const __be32 *addr)
114114 {
115115 unsigned int flags = 0;
116− u32 w = addr[0];
116+ u32 w = be32_to_cpup(addr);
117117
118118 switch((w >> 24) & 0x03) {
119119 case 0x01:
@@ -129,7 +129,8 @@ static unsigned int of_bus_pci_get_flags(const u32 *addr) · 9 unmodified lines
129129 return flags;
130130 }
131131
132−static u64 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna)
132+static u64 of_bus_pci_map(u32 *addr, const __be32 *range, int na, int ns,
133+ int pna)
133134 {
134135 u64 cp, s, da;
135136 unsigned int af, rf;
@@ -160,7 +161,7 @@ static int of_bus_pci_translate(u32 *addr, u64 offset, int na) · 24 unmodified lines
160161 return of_bus_default_translate(addr + 1, offset, na - 1);
161162 }
162163
163−const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
164+const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
164165 unsigned int *flags)
165166 {
166167 const __be32 *prop;
@@ -207,7 +208,7 @@ EXPORT_SYMBOL(of_get_pci_address); · 40 unmodified lines
207208 int of_pci_address_to_resource(struct device_node *dev, int bar,
208209 struct resource *r)
209210 {
210− const u32 *addrp;
211+ const __be32 *addrp;
211212 u64 size;
212213 unsigned int flags;
213214
@@ -237,12 +238,13 @@ static void of_bus_isa_count_cells(struct device_node *child, · 23 unmodified lines
237238 *sizec = 1;
238239 }
239240
240−static u64 of_bus_isa_map(u32 *addr, const u32 *range, int na, int ns, int pna)
241+static u64 of_bus_isa_map(u32 *addr, const __be32 *range, int na, int ns,
242+ int pna)
241243 {
242244 u64 cp, s, da;
243245
244246 /* Check address type match */
245− if ((addr[0] ^ range[0]) & 0x00000001)
247+ if ((addr[0] ^ range[0]) & cpu_to_be32(1))
246248 return OF_BAD_ADDR;
247249
248250 /* Read address values, skipping high cell */
@@ -264,10 +266,10 @@ static int of_bus_isa_translate(u32 *addr, u64 offset, int na) · 15 unmodified lines
264266 return of_bus_default_translate(addr + 1, offset, na - 1);
265267 }
266268
267−static unsigned int of_bus_isa_get_flags(const u32 *addr)
269+static unsigned int of_bus_isa_get_flags(const __be32 *addr)
268270 {
269271 unsigned int flags = 0;
270− u32 w = addr[0];
272+ u32 w = be32_to_cpup(addr);
271273
272274 if (w & 1)
273275 flags |= IORESOURCE_IO;
@@ -330,7 +332,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, · 56 unmodified lines
330332 struct of_bus *pbus, u32 *addr,
331333 int na, int ns, int pna, const char *rprop)
332334 {
333− const u32 *ranges;
335+ const __be32 *ranges;
334336 unsigned int rlen;
335337 int rone;
336338 u64 offset = OF_BAD_ADDR;
@@ -398,7 +400,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, · 61 unmodified lines
398400 * that can be mapped to a cpu physical address). This is not really specified
399401 * that way, but this is traditionally the way IBM at least do things
400402 */
401−u64 __of_translate_address(struct device_node *dev, const u32 *in_addr,
403+u64 __of_translate_address(struct device_node *dev, const __be32 *in_addr,
402404 const char *rprop)
403405 {
404406 struct device_node *parent = NULL;
@@ -475,22 +477,22 @@ u64 __of_translate_address(struct device_node *dev, const u32 *in_addr, · 70 unmodified lines
475477 return result;
476478 }
477479
478−u64 of_translate_address(struct device_node *dev, const u32 *in_addr)
480+u64 of_translate_address(struct device_node *dev, const __be32 *in_addr)
479481 {
480482 return __of_translate_address(dev, in_addr, "ranges");
481483 }
482484 EXPORT_SYMBOL(of_translate_address);
483485
484−u64 of_translate_dma_address(struct device_node *dev, const u32 *in_addr)
486+u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_addr)
485487 {
486488 return __of_translate_address(dev, in_addr, "dma-ranges");
487489 }
488490 EXPORT_SYMBOL(of_translate_dma_address);
489491
490−const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
492+const __be32 *of_get_address(struct device_node *dev, int index, u64 *size,
491493 unsigned int *flags)
492494 {
493− const u32 *prop;
495+ const __be32 *prop;
494496 unsigned int psize;
495497 struct device_node *parent;
496498 struct of_bus *bus;
@@ -525,8 +527,8 @@ const u32 *of_get_address(struct device_node *dev, int index, u64 *size, · 28 unmodified lines
525527 }
526528 EXPORT_SYMBOL(of_get_address);
527529
528−static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
529− u64 size, unsigned int flags,
530+static int __of_address_to_resource(struct device_node *dev,
531+ const __be32 *addrp, u64 size, unsigned int flags,
530532 struct resource *r)
531533 {
532534 u64 taddr;
@@ -564,7 +566,7 @@ static int __of_address_to_resource(struct device_node *dev, const u32 *addrp, · 31 unmodified lines
564566 int of_address_to_resource(struct device_node *dev, int index,
565567 struct resource *r)
566568 {
567− const u32 *addrp;
569+ const __be32 *addrp;
568570 u64 size;
569571 unsigned int flags;
570572
drivers/of/fdt.c+272−158
@@ -11,10 +11,12 @@ · 10 unmodified lines
1111
1212 #include <linux/kernel.h>
1313 #include <linux/initrd.h>
14+#include <linux/module.h>
1415 #include <linux/of.h>
1516 #include <linux/of_fdt.h>
1617 #include <linux/string.h>
1718 #include <linux/errno.h>
19+#include <linux/slab.h>
1820
1921 #ifdef CONFIG_PPC
2022 #include <asm/machdep.h>
@@ -22,104 +24,19 @@ · 1 unmodified line
2224
2325 #include <asm/page.h>
2426
25−int __initdata dt_root_addr_cells;
26−int __initdata dt_root_size_cells;
27−
28−struct boot_param_header *initial_boot_params;
29−
30−char *find_flat_dt_string(u32 offset)
27+char *of_fdt_get_string(struct boot_param_header *blob, u32 offset)
3128 {
32− return ((char *)initial_boot_params) +
33− be32_to_cpu(initial_boot_params->off_dt_strings) + offset;
34−}
35−
36−/**
37− * of_scan_flat_dt - scan flattened tree blob and call callback on each.
38− * @it: callback function
39− * @data: context data pointer
40− *
41− * This function is used to scan the flattened device-tree, it is
42− * used to extract the memory information at boot before we can
43− * unflatten the tree
44− */
45−int __init of_scan_flat_dt(int (*it)(unsigned long node,
46− const char *uname, int depth,
47− void *data),
48− void *data)
49−{
50− unsigned long p = ((unsigned long)initial_boot_params) +
51− be32_to_cpu(initial_boot_params->off_dt_struct);
52− int rc = 0;
53− int depth = -1;
54−
55− do {
56− u32 tag = be32_to_cpup((__be32 *)p);
57− char *pathp;
58−
59− p += 4;
60− if (tag == OF_DT_END_NODE) {
61− depth--;
62− continue;
63− }
64− if (tag == OF_DT_NOP)
65− continue;
66− if (tag == OF_DT_END)
67− break;
68− if (tag == OF_DT_PROP) {
69− u32 sz = be32_to_cpup((__be32 *)p);
70− p += 8;
71− if (be32_to_cpu(initial_boot_params->version) < 0x10)
72− p = ALIGN(p, sz >= 8 ? 8 : 4);
73− p += sz;
74− p = ALIGN(p, 4);
75− continue;
76− }
77− if (tag != OF_DT_BEGIN_NODE) {
78− pr_err("Invalid tag %x in flat device tree!\n", tag);
79− return -EINVAL;
80− }
81− depth++;
82− pathp = (char *)p;
83− p = ALIGN(p + strlen(pathp) + 1, 4);
84− if ((*pathp) == '/') {
85− char *lp, *np;
86− for (lp = NULL, np = pathp; *np; np++)
87− if ((*np) == '/')
88− lp = np+1;
89− if (lp != NULL)
90− pathp = lp;
91− }
92− rc = it(p, pathp, depth, data);
93− if (rc != 0)
94− break;
95− } while (1);
96−
97− return rc;
29+ return ((char *)blob) +
30+ be32_to_cpu(blob->off_dt_strings) + offset;
9831 }
9932
10033 /**
101− * of_get_flat_dt_root - find the root node in the flat blob
34+ * of_fdt_get_property - Given a node in the given flat blob, return
35+ * the property ptr
10236 */
103−unsigned long __init of_get_flat_dt_root(void)
104−{
105− unsigned long p = ((unsigned long)initial_boot_params) +
106− be32_to_cpu(initial_boot_params->off_dt_struct);
107−
108− while (be32_to_cpup((__be32 *)p) == OF_DT_NOP)
109− p += 4;
110− BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE);
111− p += 4;
112− return ALIGN(p + strlen((char *)p) + 1, 4);
113−}
114−
115−/**
116− * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr
117− *
118− * This function can be used within scan_flattened_dt callback to get
119− * access to properties
120− */
121−void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
122− unsigned long *size)
37+void *of_fdt_get_property(struct boot_param_header *blob,
38+ unsigned long node, const char *name,
39+ unsigned long *size)
12340 {
12441 unsigned long p = node;
12542
@@ -137,10 +54,10 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name, · 11 unmodified lines
13754 sz = be32_to_cpup((__be32 *)p);
13855 noff = be32_to_cpup((__be32 *)(p + 4));
13956 p += 8;
140− if (be32_to_cpu(initial_boot_params->version) < 0x10)
57+ if (be32_to_cpu(blob->version) < 0x10)
14158 p = ALIGN(p, sz >= 8 ? 8 : 4);
14259
143− nstr = find_flat_dt_string(noff);
60+ nstr = of_fdt_get_string(blob, noff);
14461 if (nstr == NULL) {
14562 pr_warning("Can't find property index name !\n");
14663 return NULL;
@@ -156,21 +73,28 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name, · 9 unmodified lines
15673 }
15774
15875 /**
159− * of_flat_dt_is_compatible - Return true if given node has compat in compatible list
76+ * of_fdt_is_compatible - Return true if given node from the given blob has
77+ * compat in its compatible list
78+ * @blob: A device tree blob
16079 * @node: node to test
16180 * @compat: compatible string to compare with compatible list.
81+ *
82+ * On match, returns a non-zero value with smaller values returned for more
83+ * specific compatible values.
16284 */
163−int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
85+int of_fdt_is_compatible(struct boot_param_header *blob,
86+ unsigned long node, const char *compat)
16487 {
16588 const char *cp;
166− unsigned long cplen, l;
89+ unsigned long cplen, l, score = 0;
16790
168− cp = of_get_flat_dt_prop(node, "compatible", &cplen);
91+ cp = of_fdt_get_property(blob, node, "compatible", &cplen);
16992 if (cp == NULL)
17093 return 0;
17194 while (cplen > 0) {
95+ score++;
17296 if (of_compat_cmp(cp, compat, strlen(compat)) == 0)
173− return 1;
97+ return score;
17498 l = strlen(cp) + 1;
17599 cp += l;
176100 cplen -= l;
@@ -179,7 +103,28 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) · 2 unmodified lines
179103 return 0;
180104 }
181105
182−static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
106+/**
107+ * of_fdt_match - Return true if node matches a list of compatible values
108+ */
109+int of_fdt_match(struct boot_param_header *blob, unsigned long node,
110+ const char **compat)
111+{
112+ unsigned int tmp, score = 0;
113+
114+ if (!compat)
115+ return 0;
116+
117+ while (*compat) {
118+ tmp = of_fdt_is_compatible(blob, node, *compat);
119+ if (tmp && (score == 0 || (tmp < score)))
120+ score = tmp;
121+ compat++;
122+ }
123+
124+ return score;
125+}
126+
127+static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size,
183128 unsigned long align)
184129 {
185130 void *res;
@@ -193,16 +138,18 @@ static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size, · 7 unmodified lines
193138
194139 /**
195140 * unflatten_dt_node - Alloc and populate a device_node from the flat tree
141+ * @blob: The parent device tree blob
196142 * @p: pointer to node in flat tree
197143 * @dad: Parent struct device_node
198144 * @allnextpp: pointer to ->allnext from last allocated device_node
199145 * @fpsize: Size of the node path up at the current depth.
200146 */
201−unsigned long __init unflatten_dt_node(unsigned long mem,
202− unsigned long *p,
203− struct device_node *dad,
204− struct device_node ***allnextpp,
205− unsigned long fpsize)
147+unsigned long unflatten_dt_node(struct boot_param_header *blob,
148+ unsigned long mem,
149+ unsigned long *p,
150+ struct device_node *dad,
151+ struct device_node ***allnextpp,
152+ unsigned long fpsize)
206153 {
207154 struct device_node *np;
208155 struct property *pp, **prev_pp = NULL;
@@ -298,10 +245,10 @@ unsigned long __init unflatten_dt_node(unsigned long mem, · 89 unmodified lines
298245 sz = be32_to_cpup((__be32 *)(*p));
299246 noff = be32_to_cpup((__be32 *)((*p) + 4));
300247 *p += 8;
301− if (be32_to_cpu(initial_boot_params->version) < 0x10)
248+ if (be32_to_cpu(blob->version) < 0x10)
302249 *p = ALIGN(*p, sz >= 8 ? 8 : 4);
303250
304− pname = find_flat_dt_string(noff);
251+ pname = of_fdt_get_string(blob, noff);
305252 if (pname == NULL) {
306253 pr_info("Can't find property name in list !\n");
307254 break;
@@ -380,7 +327,8 @@ unsigned long __init unflatten_dt_node(unsigned long mem, · 72 unmodified lines
380327 if (tag == OF_DT_NOP)
381328 *p += 4;
382329 else
383− mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);
330+ mem = unflatten_dt_node(blob, mem, p, np, allnextpp,
331+ fpsize);
384332 tag = be32_to_cpup((__be32 *)(*p));
385333 }
386334 if (tag != OF_DT_END_NODE) {
@@ -391,6 +339,211 @@ unsigned long __init unflatten_dt_node(unsigned long mem, · 4 unmodified lines
391339 return mem;
392340 }
393341
342+/**
343+ * __unflatten_device_tree - create tree of device_nodes from flat blob
344+ *
345+ * unflattens a device-tree, creating the
346+ * tree of struct device_node. It also fills the "name" and "type"
347+ * pointers of the nodes so the normal device-tree walking functions
348+ * can be used.
349+ * @blob: The blob to expand
350+ * @mynodes: The device_node tree created by the call
351+ * @dt_alloc: An allocator that provides a virtual address to memory
352+ * for the resulting tree
353+ */
354+void __unflatten_device_tree(struct boot_param_header *blob,
355+ struct device_node **mynodes,
356+ void * (*dt_alloc)(u64 size, u64 align))
357+{
358+ unsigned long start, mem, size;
359+ struct device_node **allnextp = mynodes;
360+
361+ pr_debug(" -> unflatten_device_tree()\n");
362+
363+ if (!blob) {
364+ pr_debug("No device tree pointer\n");
365+ return;
366+ }
367+
368+ pr_debug("Unflattening device tree:\n");
369+ pr_debug("magic: %08x\n", be32_to_cpu(blob->magic));
370+ pr_debug("size: %08x\n", be32_to_cpu(blob->totalsize));
371+ pr_debug("version: %08x\n", be32_to_cpu(blob->version));
372+
373+ if (be32_to_cpu(blob->magic) != OF_DT_HEADER) {
374+ pr_err("Invalid device tree blob header\n");
375+ return;
376+ }
377+
378+ /* First pass, scan for size */
379+ start = ((unsigned long)blob) +
380+ be32_to_cpu(blob->off_dt_struct);
381+ size = unflatten_dt_node(blob, 0, &start, NULL, NULL, 0);
382+ size = (size | 3) + 1;
383+
384+ pr_debug(" size is %lx, allocating...\n", size);
385+
386+ /* Allocate memory for the expanded device tree */
387+ mem = (unsigned long)
388+ dt_alloc(size + 4, __alignof__(struct device_node));
389+
390+ ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
391+
392+ pr_debug(" unflattening %lx...\n", mem);
393+
394+ /* Second pass, do actual unflattening */
395+ start = ((unsigned long)blob) +
396+ be32_to_cpu(blob->off_dt_struct);
397+ unflatten_dt_node(blob, mem, &start, NULL, &allnextp, 0);
398+ if (be32_to_cpup((__be32 *)start) != OF_DT_END)
399+ pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start));
400+ if (be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeef)
401+ pr_warning("End of tree marker overwritten: %08x\n",
402+ be32_to_cpu(((__be32 *)mem)[size / 4]));
403+ *allnextp = NULL;
404+
405+ pr_debug(" <- unflatten_device_tree()\n");
406+}
407+
408+static void *kernel_tree_alloc(u64 size, u64 align)
409+{
410+ return kzalloc(size, GFP_KERNEL);
411+}
412+
413+/**
414+ * of_fdt_unflatten_tree - create tree of device_nodes from flat blob
415+ *
416+ * unflattens the device-tree passed by the firmware, creating the
417+ * tree of struct device_node. It also fills the "name" and "type"
418+ * pointers of the nodes so the normal device-tree walking functions
419+ * can be used.
420+ */
421+void of_fdt_unflatten_tree(unsigned long *blob,
422+ struct device_node **mynodes)
423+{
424+ struct boot_param_header *device_tree =
425+ (struct boot_param_header *)blob;
426+ __unflatten_device_tree(device_tree, mynodes, &kernel_tree_alloc);
427+}
428+EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree);
429+
430+/* Everything below here references initial_boot_params directly. */
431+int __initdata dt_root_addr_cells;
432+int __initdata dt_root_size_cells;
433+
434+struct boot_param_header *initial_boot_params;
435+
436+#ifdef CONFIG_OF_EARLY_FLATTREE
437+
438+/**
439+ * of_scan_flat_dt - scan flattened tree blob and call callback on each.
440+ * @it: callback function
441+ * @data: context data pointer
442+ *
443+ * This function is used to scan the flattened device-tree, it is
444+ * used to extract the memory information at boot before we can
445+ * unflatten the tree
446+ */
447+int __init of_scan_flat_dt(int (*it)(unsigned long node,
448+ const char *uname, int depth,
449+ void *data),
450+ void *data)
451+{
452+ unsigned long p = ((unsigned long)initial_boot_params) +
453+ be32_to_cpu(initial_boot_params->off_dt_struct);
454+ int rc = 0;
455+ int depth = -1;
456+
457+ do {
458+ u32 tag = be32_to_cpup((__be32 *)p);
459+ char *pathp;
460+
461+ p += 4;
462+ if (tag == OF_DT_END_NODE) {
463+ depth--;
464+ continue;
465+ }
466+ if (tag == OF_DT_NOP)
467+ continue;
468+ if (tag == OF_DT_END)
469+ break;
470+ if (tag == OF_DT_PROP) {
471+ u32 sz = be32_to_cpup((__be32 *)p);
472+ p += 8;
473+ if (be32_to_cpu(initial_boot_params->version) < 0x10)
474+ p = ALIGN(p, sz >= 8 ? 8 : 4);
475+ p += sz;
476+ p = ALIGN(p, 4);
477+ continue;
478+ }
479+ if (tag != OF_DT_BEGIN_NODE) {
480+ pr_err("Invalid tag %x in flat device tree!\n", tag);
481+ return -EINVAL;
482+ }
483+ depth++;
484+ pathp = (char *)p;
485+ p = ALIGN(p + strlen(pathp) + 1, 4);
486+ if ((*pathp) == '/') {
487+ char *lp, *np;
488+ for (lp = NULL, np = pathp; *np; np++)
489+ if ((*np) == '/')
490+ lp = np+1;
491+ if (lp != NULL)
492+ pathp = lp;
493+ }
494+ rc = it(p, pathp, depth, data);
495+ if (rc != 0)
496+ break;
497+ } while (1);
498+
499+ return rc;
500+}
501+
502+/**
503+ * of_get_flat_dt_root - find the root node in the flat blob
504+ */
505+unsigned long __init of_get_flat_dt_root(void)
506+{
507+ unsigned long p = ((unsigned long)initial_boot_params) +
508+ be32_to_cpu(initial_boot_params->off_dt_struct);
509+
510+ while (be32_to_cpup((__be32 *)p) == OF_DT_NOP)
511+ p += 4;
512+ BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE);
513+ p += 4;
514+ return ALIGN(p + strlen((char *)p) + 1, 4);
515+}
516+
517+/**
518+ * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr
519+ *
520+ * This function can be used within scan_flattened_dt callback to get
521+ * access to properties
522+ */
523+void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
524+ unsigned long *size)
525+{
526+ return of_fdt_get_property(initial_boot_params, node, name, size);
527+}
528+
529+/**
530+ * of_flat_dt_is_compatible - Return true if given node has compat in compatible list
531+ * @node: node to test
532+ * @compat: compatible string to compare with compatible list.
533+ */
534+int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
535+{
536+ return of_fdt_is_compatible(initial_boot_params, node, compat);
537+}
538+
539+/**
540+ * of_flat_dt_match - Return true if node matches a list of compatible values
541+ */
542+int __init of_flat_dt_match(unsigned long node, const char **compat)
543+{
544+ return of_fdt_match(initial_boot_params, node, compat);
545+}
546+
394547 #ifdef CONFIG_BLK_DEV_INITRD
395548 /**
396549 * early_init_dt_check_for_initrd - Decode initrd location from flat tree
@@ -539,6 +692,12 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, · 142 unmodified lines
539692 return 1;
540693 }
541694
695+static void *__init early_device_tree_alloc(u64 size, u64 align)
696+{
697+ unsigned long mem = early_init_dt_alloc_memory_arch(size, align);
698+ return __va(mem);
699+}
700+
542701 /**
543702 * unflatten_device_tree - create tree of device_nodes from flat blob
544703 *
@@ -549,58 +708,13 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, · 4 unmodified lines
549708 */
550709 void __init unflatten_device_tree(void)
551710 {
552− unsigned long start, mem, size;
553− struct device_node **allnextp = &allnodes;
554−
555− pr_debug(" -> unflatten_device_tree()\n");
556−
557− if (!initial_boot_params) {
558− pr_debug("No device tree pointer\n");
559− return;
560− }
561−
562− pr_debug("Unflattening device tree:\n");
563− pr_debug("magic: %08x\n", be32_to_cpu(initial_boot_params->magic));
564− pr_debug("size: %08x\n", be32_to_cpu(initial_boot_params->totalsize));
565− pr_debug("version: %08x\n", be32_to_cpu(initial_boot_params->version));
566−
567− if (be32_to_cpu(initial_boot_params->magic) != OF_DT_HEADER) {
568− pr_err("Invalid device tree blob header\n");
569− return;
570− }
571−
572− /* First pass, scan for size */
573− start = ((unsigned long)initial_boot_params) +
574− be32_to_cpu(initial_boot_params->off_dt_struct);
575− size = unflatten_dt_node(0, &start, NULL, NULL, 0);
576− size = (size | 3) + 1;
577−
578− pr_debug(" size is %lx, allocating...\n", size);
579−
580− /* Allocate memory for the expanded device tree */
581− mem = early_init_dt_alloc_memory_arch(size + 4,
582− __alignof__(struct device_node));
583− mem = (unsigned long) __va(mem);
584−
585− ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
586−
587− pr_debug(" unflattening %lx...\n", mem);
588−
589− /* Second pass, do actual unflattening */
590− start = ((unsigned long)initial_boot_params) +
591− be32_to_cpu(initial_boot_params->off_dt_struct);
592− unflatten_dt_node(mem, &start, NULL, &allnextp, 0);
593− if (be32_to_cpup((__be32 *)start) != OF_DT_END)
594− pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start));
595− if (be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeef)
596− pr_warning("End of tree marker overwritten: %08x\n",
597− be32_to_cpu(((__be32 *)mem)[size / 4]));
598− *allnextp = NULL;
711+ __unflatten_device_tree(initial_boot_params, &allnodes,
712+ early_device_tree_alloc);
599713
600714 /* Get pointer to OF "/chosen" node for use everywhere */
601715 of_chosen = of_find_node_by_path("/chosen");
602716 if (of_chosen == NULL)
603717 of_chosen = of_find_node_by_path("/chosen@0");
604−
605− pr_debug(" <- unflatten_device_tree()\n");
606718 }
719+
720+#endif /* CONFIG_OF_EARLY_FLATTREE */
drivers/of/of_mdio.c+17−9
@@ -52,27 +52,35 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) · 51 unmodified lines
5252
5353 /* Loop over the child nodes and register a phy_device for each one */
5454 for_each_child_of_node(np, child) {
55− const __be32 *addr;
55+ const __be32 *paddr;
56+ u32 addr;
5657 int len;
5758
5859 /* A PHY must have a reg property in the range [0-31] */
59− addr = of_get_property(child, "reg", &len);
60− if (!addr || len < sizeof(*addr) || *addr >= 32 || *addr < 0) {
60+ paddr = of_get_property(child, "reg", &len);
61+ if (!paddr || len < sizeof(*paddr)) {
6162 dev_err(&mdio->dev, "%s has invalid PHY address\n",
6263 child->full_name);
6364 continue;
6465 }
6566
67+ addr = be32_to_cpup(paddr);
68+ if (addr >= 32) {
69+ dev_err(&mdio->dev, "%s PHY address %i is too large\n",
70+ child->full_name, addr);
71+ continue;
72+ }
73+
6674 if (mdio->irq) {
67− mdio->irq[*addr] = irq_of_parse_and_map(child, 0);
68− if (!mdio->irq[*addr])
69− mdio->irq[*addr] = PHY_POLL;
75+ mdio->irq[addr] = irq_of_parse_and_map(child, 0);
76+ if (!mdio->irq[addr])
77+ mdio->irq[addr] = PHY_POLL;
7078 }
7179
72− phy = get_phy_device(mdio, be32_to_cpup(addr));
80+ phy = get_phy_device(mdio, addr);
7381 if (!phy || IS_ERR(phy)) {
7482 dev_err(&mdio->dev, "error probing PHY at address %i\n",
75− *addr);
83+ addr);
7684 continue;
7785 }
7886 phy_scan_fixups(phy);
@@ -91,7 +99,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) · 12 unmodified lines
9199 }
92100
93101 dev_dbg(&mdio->dev, "registered phy %s at address %i\n",
94− child->name, *addr);
102+ child->name, addr);
95103 }
96104
97105 return 0;
drivers/of/of_net.c+48−0
@@ -0,0 +1,48 @@
1+/*
2+ * OF helpers for network devices.
3+ *
4+ * This file is released under the GPLv2
5+ *
6+ * Initially copied out of arch/powerpc/kernel/prom_parse.c
7+ */
8+#include <linux/etherdevice.h>
9+#include <linux/kernel.h>
10+#include <linux/of_net.h>
11+
12+/**
13+ * Search the device tree for the best MAC address to use. 'mac-address' is
14+ * checked first, because that is supposed to contain to "most recent" MAC
15+ * address. If that isn't set, then 'local-mac-address' is checked next,
16+ * because that is the default address. If that isn't set, then the obsolete
17+ * 'address' is checked, just in case we're using an old device tree.
18+ *
19+ * Note that the 'address' property is supposed to contain a virtual address of
20+ * the register set, but some DTS files have redefined that property to be the
21+ * MAC address.
22+ *
23+ * All-zero MAC addresses are rejected, because those could be properties that
24+ * exist in the device tree, but were not set by U-Boot. For example, the
25+ * DTS could define 'mac-address' and 'local-mac-address', with zero MAC
26+ * addresses. Some older U-Boots only initialized 'local-mac-address'. In
27+ * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
28+ * but is all zeros.
29+*/
30+const void *of_get_mac_address(struct device_node *np)
31+{
32+ struct property *pp;
33+
34+ pp = of_find_property(np, "mac-address", NULL);
35+ if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
36+ return pp->value;
37+
38+ pp = of_find_property(np, "local-mac-address", NULL);
39+ if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
40+ return pp->value;
41+
42+ pp = of_find_property(np, "address", NULL);
43+ if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
44+ return pp->value;
45+
46+ return NULL;
47+}
48+EXPORT_SYMBOL(of_get_mac_address);
drivers/of/platform.c+14−8
@@ -633,6 +633,9 @@ EXPORT_SYMBOL(of_device_alloc); · 632 unmodified lines
633633 * @np: pointer to node to create device for
634634 * @bus_id: name to assign device
635635 * @parent: Linux device model parent device.
636+ *
637+ * Returns pointer to created platform device, or NULL if a device was not
638+ * registered. Unavailable devices will not get registered.
636639 */
637640 struct platform_device *of_platform_device_create(struct device_node *np,
638641 const char *bus_id,
@@ -640,6 +643,9 @@ struct platform_device *of_platform_device_create(struct device_node *np, · 1 unmodified line
640643 {
641644 struct platform_device *dev;
642645
646+ if (!of_device_is_available(np))
647+ return NULL;
648+
643649 dev = of_device_alloc(np, bus_id, parent);
644650 if (!dev)
645651 return NULL;
@@ -683,8 +689,9 @@ static int of_platform_bus_create(const struct device_node *bus, · 37 unmodified lines
683689 pr_debug(" create child: %s\n", child->full_name);
684690 dev = of_platform_device_create(child, NULL, parent);
685691 if (dev == NULL)
686− rc = -ENOMEM;
687− else if (!of_match_node(matches, child))
692+ continue;
693+
694+ if (!of_match_node(matches, child))
688695 continue;
689696 if (rc == 0) {
690697 pr_debug(" and sub busses\n");
@@ -733,10 +740,9 @@ int of_platform_bus_probe(struct device_node *root, · 42 unmodified lines
733740 if (of_match_node(matches, root)) {
734741 pr_debug(" root match, create all sub devices\n");
735742 dev = of_platform_device_create(root, NULL, parent);
736− if (dev == NULL) {
737− rc = -ENOMEM;
743+ if (dev == NULL)
738744 goto bail;
739− }
745+
740746 pr_debug(" create all sub busses\n");
741747 rc = of_platform_bus_create(root, matches, &dev->dev);
742748 goto bail;
@@ -748,9 +754,9 @@ int of_platform_bus_probe(struct device_node *root, · 5 unmodified lines
748754 pr_debug(" match: %s\n", child->full_name);
749755 dev = of_platform_device_create(child, NULL, parent);
750756 if (dev == NULL)
751− rc = -ENOMEM;
752− else
753− rc = of_platform_bus_create(child, matches, &dev->dev);
757+ continue;
758+
759+ rc = of_platform_bus_create(child, matches, &dev->dev);
754760 if (rc) {
755761 of_node_put(child);
756762 break;
drivers/sbus/char/jsflash.c+1−1
@@ -467,7 +467,7 @@ static int jsflash_init(void) · 466 unmodified lines
467467
468468 node = prom_getchild(prom_root_node);
469469 node = prom_searchsiblings(node, "flash-memory");
470− if (node != 0 && node != -1) {
470+ if (node != 0 && (s32)node != -1) {
471471 if (prom_getproperty(node, "reg",
472472 (char *)&reg0, sizeof(reg0)) == -1) {
473473 printk("jsflash: no \"reg\" property\n");
drivers/serial/Kconfig+1−1
@@ -1412,7 +1412,7 @@ config SERIAL_NETX_CONSOLE · 1411 unmodified lines
14121412
14131413 config SERIAL_OF_PLATFORM
14141414 tristate "Serial port on Open Firmware platform bus"
1415− depends on PPC_OF || MICROBLAZE
1415+ depends on OF
14161416 depends on SERIAL_8250 || SERIAL_OF_PLATFORM_NWPSERIAL
14171417 help
14181418 If you have a PowerPC based system that has serial ports
drivers/serial/of_serial.c+1−0
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include <linux/serial_core.h>
1616 #include <linux/serial_8250.h>
1717 #include <linux/of_address.h>
18+#include <linux/of_irq.h>
1819 #include <linux/of_platform.h>
1920 #include <linux/nwpserial.h>
2021
include/asm-generic/vmlinux.lds.h+11−2
@@ -67,7 +67,8 @@ · 66 unmodified lines
6767 * Align to a 32 byte boundary equal to the
6868 * alignment gcc 4.5 uses for a struct
6969 */
70−#define STRUCT_ALIGN() . = ALIGN(32)
70+#define STRUCT_ALIGNMENT 32
71+#define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT)
7172
7273 /* The actual configuration determine if the init/exit sections
7374 * are handled as text/data or they can be discarded (which
@@ -146,6 +147,13 @@ · 72 unmodified lines
146147 #define TRACE_SYSCALLS()
147148 #endif
148149
150+
151+#define KERNEL_DTB() \
152+ STRUCT_ALIGN(); \
153+ VMLINUX_SYMBOL(__dtb_start) = .; \
154+ *(.dtb.init.rodata) \
155+ VMLINUX_SYMBOL(__dtb_end) = .;
156+
149157 /* .data section */
150158 #define DATA_DATA \
151159 *(.data) \
@@ -468,7 +476,8 @@ · 316 unmodified lines
468476 MCOUNT_REC() \
469477 DEV_DISCARD(init.rodata) \
470478 CPU_DISCARD(init.rodata) \
471− MEM_DISCARD(init.rodata)
479+ MEM_DISCARD(init.rodata) \
480+ KERNEL_DTB()
472481
473482 #define INIT_TEXT \
474483 *(.init.text) \
include/linux/of_address.h+3−3
@@ -3,7 +3,7 @@ · 2 unmodified lines
33 #include <linux/ioport.h>
44 #include <linux/of.h>
55
6−extern u64 of_translate_address(struct device_node *np, const u32 *addr);
6+extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
77 extern int of_address_to_resource(struct device_node *dev, int index,
88 struct resource *r);
99 extern void __iomem *of_iomap(struct device_node *device, int index);
@@ -21,7 +21,7 @@ static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; } · 11 unmodified lines
2121 #endif
2222
2323 #ifdef CONFIG_PCI
24−extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
24+extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
2525 u64 *size, unsigned int *flags);
2626 extern int of_pci_address_to_resource(struct device_node *dev, int bar,
2727 struct resource *r);
@@ -32,7 +32,7 @@ static inline int of_pci_address_to_resource(struct device_node *dev, int bar, · 4 unmodified lines
3232 return -ENOSYS;
3333 }
3434
35−static inline const u32 *of_get_pci_address(struct device_node *dev,
35+static inline const __be32 *of_get_pci_address(struct device_node *dev,
3636 int bar_no, u64 *size, unsigned int *flags)
3737 {
3838 return NULL;
include/linux/of_fdt.h+18−0
@@ -58,6 +58,23 @@ struct boot_param_header { · 57 unmodified lines
5858 };
5959
6060 #if defined(CONFIG_OF_FLATTREE)
61+
62+struct device_node;
63+
64+/* For scanning an arbitrary device-tree at any time */
65+extern char *of_fdt_get_string(struct boot_param_header *blob, u32 offset);
66+extern void *of_fdt_get_property(struct boot_param_header *blob,
67+ unsigned long node,
68+ const char *name,
69+ unsigned long *size);
70+extern int of_fdt_is_compatible(struct boot_param_header *blob,
71+ unsigned long node,
72+ const char *compat);
73+extern int of_fdt_match(struct boot_param_header *blob, unsigned long node,
74+ const char **compat);
75+extern void of_fdt_unflatten_tree(unsigned long *blob,
76+ struct device_node **mynodes);
77+
6178 /* TBD: Temporary export of fdt globals - remove when code fully merged */
6279 extern int __initdata dt_root_addr_cells;
6380 extern int __initdata dt_root_size_cells;
@@ -71,6 +88,7 @@ extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname, · 7 unmodified lines
7188 extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
7289 unsigned long *size);
7390 extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
91+extern int of_flat_dt_match(unsigned long node, const char **matches);
7492 extern unsigned long of_get_flat_dt_root(void);
7593
7694 extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
include/linux/of_net.h+15−0
@@ -0,0 +1,15 @@
1+/*
2+ * OF helpers for network devices.
3+ *
4+ * This file is released under the GPLv2
5+ */
6+
7+#ifndef __LINUX_OF_NET_H
8+#define __LINUX_OF_NET_H
9+
10+#ifdef CONFIG_OF_NET
11+#include <linux/of.h>
12+extern const void *of_get_mac_address(struct device_node *np);
13+#endif
14+
15+#endif /* __LINUX_OF_NET_H */
scripts/Makefile.lib+23−0
@@ -200,6 +200,29 @@ quiet_cmd_gzip = GZIP $@ · 199 unmodified lines
200200 cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \
201201 (rm -f $@ ; false)
202202
203+# DTC
204+# ---------------------------------------------------------------------------
205+
206+# Generate an assembly file to wrap the output of the device tree compiler
207+quiet_cmd_dt_S_dtb= DTB $@
208+cmd_dt_S_dtb= \
209+( \
210+ echo '\#include <asm-generic/vmlinux.lds.h>'; \
211+ echo '.section .dtb.init.rodata,"a"'; \
212+ echo '.balign STRUCT_ALIGNMENT'; \
213+ echo '.global __dtb_$(*F)_begin'; \
214+ echo '__dtb_$(*F)_begin:'; \
215+ echo '.incbin "$<" '; \
216+ echo '__dtb_$(*F)_end:'; \
217+ echo '.global __dtb_$(*F)_end'; \
218+ echo '.balign STRUCT_ALIGNMENT'; \
219+) > $@
220+
221+$(obj)/%.dtb.S: $(obj)/%.dtb
222+ $(call cmd,dt_S_dtb)
223+
224+quiet_cmd_dtc = DTC $@
225+cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $<
203226
204227 # Bzip2
205228 # ---------------------------------------------------------------------------
scripts/dtc/Makefile+2−1
@@ -4,7 +4,7 @@ hostprogs-y := dtc · 3 unmodified lines
44 always := $(hostprogs-y)
55
66 dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
7− srcpos.o checks.o
7+ srcpos.o checks.o util.o
88 dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o
99
1010 # Source files need to get at the userspace version of libfdt_env.h to compile
@@ -19,6 +19,7 @@ HOSTCFLAGS_fstree.o := $(HOSTCFLAGS_DTC) · 8 unmodified lines
1919 HOSTCFLAGS_livetree.o := $(HOSTCFLAGS_DTC)
2020 HOSTCFLAGS_srcpos.o := $(HOSTCFLAGS_DTC)
2121 HOSTCFLAGS_treesource.o := $(HOSTCFLAGS_DTC)
22+HOSTCFLAGS_util.o := $(HOSTCFLAGS_DTC)
2223
2324 HOSTCFLAGS_dtc-lexer.lex.o := $(HOSTCFLAGS_DTC)
2425 HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC)
scripts/dtc/checks.c+94−11
@@ -278,32 +278,112 @@ static void check_property_name_chars(struct check *c, struct node *dt, · 277 unmodified lines
278278 }
279279 PROP_CHECK(property_name_chars, PROPNODECHARS, ERROR);
280280
281+#define DESCLABEL_FMT "%s%s%s%s%s"
282+#define DESCLABEL_ARGS(node,prop,mark) \
283+ ((mark) ? "value of " : ""), \
284+ ((prop) ? "'" : ""), \
285+ ((prop) ? (prop)->name : ""), \
286+ ((prop) ? "' in " : ""), (node)->fullpath
287+
288+static void check_duplicate_label(struct check *c, struct node *dt,
289+ const char *label, struct node *node,
290+ struct property *prop, struct marker *mark)
291+{
292+ struct node *othernode = NULL;
293+ struct property *otherprop = NULL;
294+ struct marker *othermark = NULL;
295+
296+ othernode = get_node_by_label(dt, label);
297+
298+ if (!othernode)
299+ otherprop = get_property_by_label(dt, label, &othernode);
300+ if (!othernode)
301+ othermark = get_marker_label(dt, label, &othernode,
302+ &otherprop);
303+
304+ if (!othernode)
305+ return;
306+
307+ if ((othernode != node) || (otherprop != prop) || (othermark != mark))
308+ FAIL(c, "Duplicate label '%s' on " DESCLABEL_FMT
309+ " and " DESCLABEL_FMT,
310+ label, DESCLABEL_ARGS(node, prop, mark),
311+ DESCLABEL_ARGS(othernode, otherprop, othermark));
312+}
313+
314+static void check_duplicate_label_node(struct check *c, struct node *dt,
315+ struct node *node)
316+{
317+ struct label *l;
318+
319+ for_each_label(node->labels, l)
320+ check_duplicate_label(c, dt, l->label, node, NULL, NULL);
321+}
322+static void check_duplicate_label_prop(struct check *c, struct node *dt,
323+ struct node *node, struct property *prop)
324+{
325+ struct marker *m = prop->val.markers;
326+ struct label *l;
327+
328+ for_each_label(prop->labels, l)
329+ check_duplicate_label(c, dt, l->label, node, prop, NULL);
330+
331+ for_each_marker_of_type(m, LABEL)
332+ check_duplicate_label(c, dt, m->ref, node, prop, m);
333+}
334+CHECK(duplicate_label, NULL, check_duplicate_label_node,
335+ check_duplicate_label_prop, NULL, ERROR);
336+
281337 static void check_explicit_phandles(struct check *c, struct node *root,
282− struct node *node)
338+ struct node *node, struct property *prop)
283339 {
284− struct property *prop;
340+ struct marker *m;
285341 struct node *other;
286342 cell_t phandle;
287343
288− prop = get_property(node, "linux,phandle");
289− if (! prop)
290− return; /* No phandle, that's fine */
344+ if (!streq(prop->name, "phandle")
345+ && !streq(prop->name, "linux,phandle"))
346+ return;
291347
292348 if (prop->val.len != sizeof(cell_t)) {
293− FAIL(c, "%s has bad length (%d) linux,phandle property",
294− node->fullpath, prop->val.len);
349+ FAIL(c, "%s has bad length (%d) %s property",
350+ node->fullpath, prop->val.len, prop->name);
351+ return;
352+ }
353+
354+ m = prop->val.markers;
355+ for_each_marker_of_type(m, REF_PHANDLE) {
356+ assert(m->offset == 0);
357+ if (node != get_node_by_ref(root, m->ref))
358+ /* "Set this node's phandle equal to some
359+ * other node's phandle". That's nonsensical
360+ * by construction. */ {
361+ FAIL(c, "%s in %s is a reference to another node",
362+ prop->name, node->fullpath);
363+ return;
364+ }
365+ /* But setting this node's phandle equal to its own
366+ * phandle is allowed - that means allocate a unique
367+ * phandle for this node, even if it's not otherwise
368+ * referenced. The value will be filled in later, so
369+ * no further checking for now. */
295370 return;
296371 }
297372
298373 phandle = propval_cell(prop);
374+
299375 if ((phandle == 0) || (phandle == -1)) {
300− FAIL(c, "%s has invalid linux,phandle value 0x%x",
301− node->fullpath, phandle);
376+ FAIL(c, "%s has bad value (0x%x) in %s property",
377+ node->fullpath, phandle, prop->name);
302378 return;
303379 }
304380
381+ if (node->phandle && (node->phandle != phandle))
382+ FAIL(c, "%s has %s property which replaces existing phandle information",
383+ node->fullpath, prop->name);
384+
305385 other = get_node_by_phandle(root, phandle);
306− if (other) {
386+ if (other && (other != node)) {
307387 FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)",
308388 node->fullpath, phandle, other->fullpath);
309389 return;
@@ -311,7 +391,7 @@ static void check_explicit_phandles(struct check *c, struct node *root, · 1 unmodified line
311391
312392 node->phandle = phandle;
313393 }
314−NODE_CHECK(explicit_phandles, NULL, ERROR);
394+PROP_CHECK(explicit_phandles, NULL, ERROR);
315395
316396 static void check_name_properties(struct check *c, struct node *root,
317397 struct node *node)
@@ -549,6 +629,9 @@ static struct check *check_table[] = { · 231 unmodified lines
549629 &duplicate_node_names, &duplicate_property_names,
550630 &node_name_chars, &node_name_format, &property_name_chars,
551631 &name_is_string, &name_properties,
632+
633+ &duplicate_label,
634+
552635 &explicit_phandles,
553636 &phandle_references, &path_references,
554637
scripts/dtc/dtc-lexer.l+23−152
@@ -18,7 +18,7 @@ · 17 unmodified lines
1818 * USA
1919 */
2020
21−%option noyywrap noinput nounput yylineno
21+%option noyywrap nounput noinput never-interactive
2222
2323 %x INCLUDE
2424 %x BYTESTRING
@@ -38,6 +38,13 @@ LINECOMMENT "//".*\n · 13 unmodified lines
3838 #include "srcpos.h"
3939 #include "dtc-parser.tab.h"
4040
41+YYLTYPE yylloc;
42+
43+/* CAUTION: this will stop working if we ever use yyless() or yyunput() */
44+#define YY_USER_ACTION \
45+ { \
46+ srcpos_update(&yylloc, yytext, yyleng); \
47+ }
4148
4249 /*#define LEXDEBUG 1*/
4350
@@ -47,15 +54,10 @@ LINECOMMENT "//".*\n · 3 unmodified lines
4754 #define DPRINT(fmt, ...) do { } while (0)
4855 #endif
4956
50−static int dts_version; /* = 0 */
57+static int dts_version = 1;
5158
52−#define BEGIN_DEFAULT() if (dts_version == 0) { \
53− DPRINT("<INITIAL>\n"); \
54− BEGIN(INITIAL); \
55− } else { \
56− DPRINT("<V1>\n"); \
59+#define BEGIN_DEFAULT() DPRINT("<V1>\n"); \
5760 BEGIN(V1); \
58− }
5961
6062 static void push_input_file(const char *filename);
6163 static int pop_input_file(void);
@@ -75,18 +77,13 @@ static int pop_input_file(void); · 13 unmodified lines
7577 }
7678
7779 <*>{STRING} {
78− yylloc.file = srcpos_file;
79− yylloc.first_line = yylineno;
8080 DPRINT("String: %s\n", yytext);
8181 yylval.data = data_copy_escape_string(yytext+1,
8282 yyleng-2);
83− yylloc.first_line = yylineno;
8483 return DT_STRING;
8584 }
8685
8786 <*>"/dts-v1/" {
88− yylloc.file = srcpos_file;
89− yylloc.first_line = yylineno;
9087 DPRINT("Keyword: /dts-v1/\n");
9188 dts_version = 1;
9289 BEGIN_DEFAULT();
@@ -94,106 +91,57 @@ static int pop_input_file(void); · 1 unmodified line
9491 }
9592
9693 <*>"/memreserve/" {
97− yylloc.file = srcpos_file;
98− yylloc.first_line = yylineno;
9994 DPRINT("Keyword: /memreserve/\n");
10095 BEGIN_DEFAULT();
10196 return DT_MEMRESERVE;
10297 }
10398
10499 <*>{LABEL}: {
105− yylloc.file = srcpos_file;
106− yylloc.first_line = yylineno;
107100 DPRINT("Label: %s\n", yytext);
108− yylval.labelref = strdup(yytext);
101+ yylval.labelref = xstrdup(yytext);
109102 yylval.labelref[yyleng-1] = '\0';
110103 return DT_LABEL;
111104 }
112105
113−<INITIAL>[bodh]# {
114− yylloc.file = srcpos_file;
115− yylloc.first_line = yylineno;
116− if (*yytext == 'b')
117− yylval.cbase = 2;
118− else if (*yytext == 'o')
119− yylval.cbase = 8;
120− else if (*yytext == 'd')
121− yylval.cbase = 10;
122− else
123− yylval.cbase = 16;
124− DPRINT("Base: %d\n", yylval.cbase);
125− return DT_BASE;
126− }
127−
128−<INITIAL>[0-9a-fA-F]+ {
129− yylloc.file = srcpos_file;
130− yylloc.first_line = yylineno;
131− yylval.literal = strdup(yytext);
132− DPRINT("Literal: '%s'\n", yylval.literal);
133− return DT_LEGACYLITERAL;
134− }
135−
136106 <V1>[0-9]+|0[xX][0-9a-fA-F]+ {
137− yylloc.file = srcpos_file;
138− yylloc.first_line = yylineno;
139− yylval.literal = strdup(yytext);
107+ yylval.literal = xstrdup(yytext);
140108 DPRINT("Literal: '%s'\n", yylval.literal);
141109 return DT_LITERAL;
142110 }
143111
144−\&{LABEL} { /* label reference */
145− yylloc.file = srcpos_file;
146− yylloc.first_line = yylineno;
112+<*>\&{LABEL} { /* label reference */
147113 DPRINT("Ref: %s\n", yytext+1);
148− yylval.labelref = strdup(yytext+1);
114+ yylval.labelref = xstrdup(yytext+1);
149115 return DT_REF;
150116 }
151117
152−"&{/"{PATHCHAR}+\} { /* new-style path reference */
153− yylloc.file = srcpos_file;
154− yylloc.first_line = yylineno;
118+<*>"&{/"{PATHCHAR}+\} { /* new-style path reference */
155119 yytext[yyleng-1] = '\0';
156120 DPRINT("Ref: %s\n", yytext+2);
157− yylval.labelref = strdup(yytext+2);
158− return DT_REF;
159− }
160−
161−<INITIAL>"&/"{PATHCHAR}+ { /* old-style path reference */
162− yylloc.file = srcpos_file;
163− yylloc.first_line = yylineno;
164− DPRINT("Ref: %s\n", yytext+1);
165− yylval.labelref = strdup(yytext+1);
121+ yylval.labelref = xstrdup(yytext+2);
166122 return DT_REF;
167123 }
168124
169125 <BYTESTRING>[0-9a-fA-F]{2} {
170− yylloc.file = srcpos_file;
171− yylloc.first_line = yylineno;
172126 yylval.byte = strtol(yytext, NULL, 16);
173127 DPRINT("Byte: %02x\n", (int)yylval.byte);
174128 return DT_BYTE;
175129 }
176130
177131 <BYTESTRING>"]" {
178− yylloc.file = srcpos_file;
179− yylloc.first_line = yylineno;
180132 DPRINT("/BYTESTRING\n");
181133 BEGIN_DEFAULT();
182134 return ']';
183135 }
184136
185137 <PROPNODENAME>{PROPNODECHAR}+ {
186− yylloc.file = srcpos_file;
187− yylloc.first_line = yylineno;
188138 DPRINT("PropNodeName: %s\n", yytext);
189− yylval.propnodename = strdup(yytext);
139+ yylval.propnodename = xstrdup(yytext);
190140 BEGIN_DEFAULT();
191141 return DT_PROPNODENAME;
192142 }
193143
194144 "/incbin/" {
195− yylloc.file = srcpos_file;
196− yylloc.first_line = yylineno;
197145 DPRINT("Binary Include\n");
198146 return DT_INCBIN;
199147 }
@@ -203,8 +151,6 @@ static int pop_input_file(void); · 3 unmodified lines
203151 <*>{LINECOMMENT}+ /* eat C++-style comments */
204152
205153 <*>. {
206− yylloc.file = srcpos_file;
207− yylloc.first_line = yylineno;
208154 DPRINT("Char: %c (\\x%02x)\n", yytext[0],
209155 (unsigned)yytext[0]);
210156 if (yytext[0] == '[') {
@@ -221,100 +167,25 @@ static int pop_input_file(void); · 10 unmodified lines
221167
222168 %%
223169
224−
225−/*
226− * Stack of nested include file contexts.
227− */
228−
229−struct incl_file {
230− struct dtc_file *file;
231− YY_BUFFER_STATE yy_prev_buf;
232− int yy_prev_lineno;
233− struct incl_file *prev;
234−};
235−
236−static struct incl_file *incl_file_stack;
237−
238−
239−/*
240− * Detect infinite include recursion.
241− */
242−#define MAX_INCLUDE_DEPTH (100)
243−
244−static int incl_depth = 0;
245−
246−
247170 static void push_input_file(const char *filename)
248171 {
249− struct incl_file *incl_file;
250− struct dtc_file *newfile;
251− struct search_path search, *searchptr = NULL;
252−
253172 assert(filename);
254173
255− if (incl_depth++ >= MAX_INCLUDE_DEPTH)
256− die("Includes nested too deeply");
257−
258− if (srcpos_file) {
259− search.dir = srcpos_file->dir;
260− search.next = NULL;
261− search.prev = NULL;
262− searchptr = &search;
263− }
264−
265− newfile = dtc_open_file(filename, searchptr);
174+ srcfile_push(filename);
266175
267− incl_file = xmalloc(sizeof(struct incl_file));
176+ yyin = current_srcfile->f;
268177
269− /*
270− * Save current context.
271− */
272− incl_file->yy_prev_buf = YY_CURRENT_BUFFER;
273− incl_file->yy_prev_lineno = yylineno;
274− incl_file->file = srcpos_file;
275− incl_file->prev = incl_file_stack;
276−
277− incl_file_stack = incl_file;
278−
279− /*
280− * Establish new context.
281− */
282− srcpos_file = newfile;
283− yylineno = 1;
284− yyin = newfile->file;
285− yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
178+ yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE));
286179 }
287180
288181
289182 static int pop_input_file(void)
290183 {
291− struct incl_file *incl_file;
292−
293− if (incl_file_stack == 0)
184+ if (srcfile_pop() == 0)
294185 return 0;
295186
296− dtc_close_file(srcpos_file);
297−
298− /*
299− * Pop.
300− */
301− --incl_depth;
302− incl_file = incl_file_stack;
303− incl_file_stack = incl_file->prev;
304−
305− /*
306− * Recover old context.
307− */
308− yy_delete_buffer(YY_CURRENT_BUFFER);
309− yy_switch_to_buffer(incl_file->yy_prev_buf);
310− yylineno = incl_file->yy_prev_lineno;
311− srcpos_file = incl_file->file;
312− yyin = incl_file->file ? incl_file->file->file : NULL;
313−
314− /*
315− * Free old state.
316− */
317− free(incl_file);
187+ yypop_buffer_state();
188+ yyin = current_srcfile->f;
318189
319190 return 1;
320191 }
scripts/dtc/dtc-lexer.lex.c_shipped+176−375
@@ -170,20 +170,7 @@ extern FILE *yyin, *yyout; · 169 unmodified lines
170170 #define EOB_ACT_END_OF_FILE 1
171171 #define EOB_ACT_LAST_MATCH 2
172172
173− /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
174− * access to the local variable yy_act. Since yyless() is a macro, it would break
175− * existing scanners that call yyless() from OUTSIDE yylex.
176− * One obvious solution it to make yy_act a global. I tried that, and saw
177− * a 5% performance hit in a non-yylineno scanner, because yy_act is
178− * normally declared as a register variable-- so it is not worth it.
179− */
180− #define YY_LESS_LINENO(n) \
181− do { \
182− int yyl;\
183− for ( yyl = n; yyl < yyleng; ++yyl )\
184− if ( yytext[yyl] == '\n' )\
185− --yylineno;\
186− }while(0)
173+ #define YY_LESS_LINENO(n)
187174
188175 /* Return all but the first "n" matched characters back to the input stream. */
189176 #define yyless(n) \
@@ -385,8 +372,8 @@ static void yy_fatal_error (yyconst char msg[] ); · 195 unmodified lines
385372 *yy_cp = '\0'; \
386373 (yy_c_buf_p) = yy_cp;
387374
388−#define YY_NUM_RULES 20
389−#define YY_END_OF_BUFFER 21
375+#define YY_NUM_RULES 17
376+#define YY_END_OF_BUFFER 18
390377 /* This struct is not used in this scanner,
391378 but its presence is necessary. */
392379 struct yy_trans_info
@@ -394,20 +381,19 @@ struct yy_trans_info · 1 unmodified line
394381 flex_int32_t yy_verify;
395382 flex_int32_t yy_nxt;
396383 };
397−static yyconst flex_int16_t yy_accept[104] =
384+static yyconst flex_int16_t yy_accept[94] =
398385 { 0,
399386 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
400− 21, 19, 16, 16, 19, 19, 19, 7, 7, 19,
401− 7, 19, 19, 19, 19, 13, 14, 14, 19, 8,
402− 8, 16, 0, 2, 0, 0, 9, 0, 0, 0,
403− 0, 0, 0, 7, 7, 5, 0, 6, 0, 12,
404− 12, 14, 14, 8, 0, 11, 9, 0, 0, 0,
405− 0, 18, 0, 0, 0, 0, 8, 0, 17, 0,
406− 0, 0, 0, 0, 10, 0, 0, 0, 0, 0,
407− 0, 0, 0, 0, 0, 0, 0, 0, 3, 15,
387+ 18, 16, 13, 13, 16, 16, 16, 16, 16, 16,
388+ 16, 10, 11, 11, 6, 6, 13, 0, 2, 0,
389+ 7, 0, 0, 0, 0, 0, 0, 0, 5, 0,
390+ 9, 9, 11, 11, 6, 0, 7, 0, 0, 0,
391+ 0, 15, 0, 0, 0, 0, 6, 0, 14, 0,
392+ 0, 0, 0, 0, 8, 0, 0, 0, 0, 0,
393+ 0, 0, 0, 0, 0, 0, 0, 0, 3, 12,
408394 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
409−
410395 0, 4, 0
396+
411397 } ;
412398
413399 static yyconst flex_int32_t yy_ec[256] =
@@ -416,16 +402,16 @@ static yyconst flex_int32_t yy_ec[256] = · 2 unmodified lines
416402 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
417403 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
418404 1, 2, 1, 4, 5, 1, 1, 6, 1, 1,
419− 1, 7, 8, 8, 9, 8, 10, 11, 12, 13,
420− 13, 13, 13, 13, 13, 13, 13, 14, 1, 1,
421− 1, 1, 8, 8, 15, 15, 15, 15, 15, 15,
422− 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
423− 16, 16, 16, 16, 16, 16, 16, 17, 16, 16,
424− 1, 18, 19, 1, 16, 1, 15, 20, 21, 22,
425−
426− 23, 15, 16, 24, 25, 16, 16, 26, 27, 28,
427− 24, 16, 16, 29, 30, 31, 32, 33, 16, 17,
428− 16, 16, 34, 1, 35, 1, 1, 1, 1, 1,
405+ 1, 7, 5, 5, 8, 5, 9, 10, 11, 12,
406+ 12, 12, 12, 12, 12, 12, 12, 13, 1, 1,
407+ 1, 1, 5, 5, 14, 14, 14, 14, 14, 14,
408+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
409+ 15, 15, 15, 15, 15, 15, 15, 16, 15, 15,
410+ 1, 17, 18, 1, 15, 1, 14, 19, 20, 21,
411+
412+ 22, 14, 15, 15, 23, 15, 15, 24, 25, 26,
413+ 15, 15, 15, 27, 28, 29, 30, 31, 15, 16,
414+ 15, 15, 32, 1, 33, 1, 1, 1, 1, 1,
429415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
431417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -442,136 +428,114 @@ static yyconst flex_int32_t yy_ec[256] = · 10 unmodified lines
442428 1, 1, 1, 1, 1
443429 } ;
444430
445−static yyconst flex_int32_t yy_meta[36] =
431+static yyconst flex_int32_t yy_meta[34] =
446432 { 0,
447− 1, 1, 1, 1, 2, 1, 2, 2, 2, 3,
448− 4, 4, 4, 5, 6, 7, 7, 1, 1, 6,
449− 6, 6, 6, 7, 7, 7, 7, 7, 7, 7,
450− 7, 7, 7, 8, 1
433+ 1, 1, 1, 1, 2, 1, 2, 2, 3, 4,
434+ 4, 4, 5, 6, 7, 7, 1, 1, 6, 6,
435+ 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
436+ 7, 8, 1
451437 } ;
452438
453−static yyconst flex_int16_t yy_base[117] =
439+static yyconst flex_int16_t yy_base[106] =
454440 { 0,
455− 0, 0, 30, 0, 44, 0, 67, 0, 97, 105,
456− 302, 303, 35, 44, 40, 94, 112, 0, 129, 152,
457− 296, 295, 159, 0, 176, 303, 0, 116, 95, 165,
458− 49, 46, 102, 303, 296, 0, 0, 288, 290, 293,
459− 264, 266, 270, 0, 0, 303, 0, 303, 264, 303,
460− 0, 0, 195, 101, 0, 0, 0, 0, 284, 125,
461− 277, 265, 225, 230, 216, 218, 0, 202, 224, 221,
462− 217, 107, 196, 188, 303, 206, 179, 186, 178, 185,
463− 183, 162, 161, 150, 169, 160, 145, 125, 303, 303,
464− 137, 109, 190, 103, 203, 167, 108, 197, 303, 123,
465−
466− 29, 303, 303, 215, 221, 226, 229, 234, 240, 246,
467− 250, 257, 265, 270, 275, 282
441+ 0, 0, 237, 236, 25, 0, 47, 0, 30, 71,
442+ 244, 247, 82, 84, 84, 211, 95, 229, 218, 0,
443+ 111, 247, 0, 84, 83, 95, 106, 86, 247, 237,
444+ 0, 230, 231, 234, 207, 209, 212, 220, 247, 206,
445+ 247, 218, 0, 106, 116, 0, 0, 0, 223, 89,
446+ 226, 219, 199, 206, 200, 204, 0, 190, 213, 212,
447+ 202, 91, 178, 161, 247, 172, 144, 150, 140, 130,
448+ 140, 124, 128, 120, 138, 137, 123, 122, 247, 247,
449+ 134, 114, 132, 86, 135, 125, 90, 136, 247, 97,
450+ 29, 247, 247, 153, 156, 161, 165, 170, 176, 180,
451+
452+ 187, 195, 200, 205, 212
468453 } ;
469454
470−static yyconst flex_int16_t yy_def[117] =
455+static yyconst flex_int16_t yy_def[106] =
471456 { 0,
472− 103, 1, 1, 3, 3, 5, 103, 7, 3, 3,
473− 103, 103, 103, 103, 104, 105, 103, 106, 103, 19,
474− 19, 20, 103, 107, 20, 103, 108, 109, 105, 103,
475− 103, 103, 104, 103, 104, 110, 111, 103, 112, 113,
476− 103, 103, 103, 106, 19, 103, 20, 103, 103, 103,
477− 20, 108, 109, 103, 114, 110, 111, 115, 112, 112,
478− 113, 103, 103, 103, 103, 103, 114, 115, 103, 103,
479− 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
480− 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
481− 103, 103, 103, 103, 103, 116, 103, 116, 103, 116,
482−
483− 103, 103, 0, 103, 103, 103, 103, 103, 103, 103,
484− 103, 103, 103, 103, 103, 103
457+ 93, 1, 1, 1, 1, 5, 93, 7, 1, 1,
458+ 93, 93, 93, 93, 94, 95, 93, 96, 17, 97,
459+ 96, 93, 98, 99, 93, 93, 93, 94, 93, 94,
460+ 100, 93, 101, 102, 93, 93, 93, 96, 93, 93,
461+ 93, 96, 98, 99, 93, 103, 100, 104, 101, 101,
462+ 102, 93, 93, 93, 93, 93, 103, 104, 93, 93,
463+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
464+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
465+ 93, 93, 93, 93, 93, 105, 93, 105, 93, 105,
466+ 93, 93, 0, 93, 93, 93, 93, 93, 93, 93,
467+
468+ 93, 93, 93, 93, 93
485469 } ;
486470
487−static yyconst flex_int16_t yy_nxt[339] =
471+static yyconst flex_int16_t yy_nxt[281] =
488472 { 0,
489− 12, 13, 14, 15, 12, 16, 12, 12, 12, 17,
490− 18, 18, 18, 12, 19, 20, 20, 12, 12, 21,
491− 19, 21, 19, 22, 20, 20, 20, 20, 20, 20,
492− 20, 20, 20, 12, 12, 12, 32, 32, 102, 23,
493− 12, 12, 12, 34, 20, 32, 32, 32, 32, 20,
494− 20, 20, 20, 20, 24, 24, 24, 35, 25, 54,
495− 54, 54, 26, 25, 25, 25, 25, 12, 13, 14,
496− 15, 27, 12, 27, 27, 27, 23, 27, 27, 27,
497− 12, 28, 28, 28, 12, 12, 28, 28, 28, 28,
498− 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
499−
500− 12, 12, 29, 36, 103, 34, 17, 30, 31, 31,
501− 29, 54, 54, 54, 17, 30, 31, 31, 39, 35,
502− 52, 40, 52, 52, 52, 103, 78, 38, 38, 46,
503− 101, 60, 79, 41, 69, 97, 42, 94, 43, 45,
504− 45, 45, 46, 45, 47, 47, 93, 92, 45, 45,
505− 45, 45, 47, 47, 47, 47, 47, 47, 47, 47,
506− 47, 47, 47, 47, 47, 39, 47, 91, 40, 90,
507− 99, 47, 47, 47, 47, 54, 54, 54, 89, 88,
508− 41, 55, 87, 49, 100, 43, 51, 51, 51, 86,
509− 51, 95, 95, 96, 85, 51, 51, 51, 51, 52,
510−
511− 99, 52, 52, 52, 95, 95, 96, 84, 46, 83,
512− 82, 81, 39, 79, 100, 33, 33, 33, 33, 33,
513− 33, 33, 33, 37, 80, 77, 37, 37, 37, 44,
514− 40, 44, 50, 76, 50, 52, 75, 52, 74, 52,
515− 52, 53, 73, 53, 53, 53, 53, 56, 56, 56,
516− 72, 56, 56, 57, 71, 57, 57, 59, 59, 59,
517− 59, 59, 59, 59, 59, 61, 61, 61, 61, 61,
518− 61, 61, 61, 67, 70, 67, 68, 68, 68, 62,
519− 68, 68, 98, 98, 98, 98, 98, 98, 98, 98,
520− 60, 66, 65, 64, 63, 62, 60, 58, 103, 48,
521−
522− 48, 103, 11, 103, 103, 103, 103, 103, 103, 103,
523− 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
524− 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
525− 103, 103, 103, 103, 103, 103, 103, 103
473+ 12, 13, 14, 15, 12, 16, 12, 12, 17, 12,
474+ 12, 12, 12, 18, 18, 18, 12, 12, 18, 18,
475+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
476+ 18, 12, 12, 19, 20, 20, 20, 92, 21, 25,
477+ 26, 26, 22, 21, 21, 21, 21, 12, 13, 14,
478+ 15, 23, 16, 23, 23, 19, 23, 23, 23, 12,
479+ 24, 24, 24, 12, 12, 24, 24, 24, 24, 24,
480+ 24, 24, 24, 24, 24, 24, 24, 24, 12, 12,
481+ 25, 26, 26, 27, 27, 27, 27, 29, 43, 29,
482+ 43, 43, 45, 45, 45, 50, 39, 59, 46, 93,
483+
484+ 30, 33, 30, 34, 45, 45, 45, 27, 27, 68,
485+ 43, 91, 43, 43, 69, 35, 87, 36, 39, 37,
486+ 42, 42, 42, 39, 42, 45, 45, 45, 89, 42,
487+ 42, 42, 42, 85, 85, 86, 85, 85, 86, 89,
488+ 84, 90, 83, 82, 81, 80, 79, 78, 77, 76,
489+ 75, 74, 90, 28, 28, 28, 28, 28, 28, 28,
490+ 28, 31, 31, 31, 38, 38, 38, 38, 41, 73,
491+ 41, 43, 72, 43, 71, 43, 43, 44, 33, 44,
492+ 44, 44, 44, 47, 69, 47, 47, 49, 49, 49,
493+ 49, 49, 49, 49, 49, 51, 51, 51, 51, 51,
494+
495+ 51, 51, 51, 57, 70, 57, 58, 58, 58, 67,
496+ 58, 58, 88, 88, 88, 88, 88, 88, 88, 88,
497+ 34, 66, 65, 64, 63, 62, 61, 60, 52, 50,
498+ 39, 56, 39, 55, 54, 53, 52, 50, 48, 93,
499+ 40, 39, 32, 93, 19, 19, 11, 93, 93, 93,
500+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
501+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
502+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93
526503 } ;
527504
528−static yyconst flex_int16_t yy_chk[339] =
505+static yyconst flex_int16_t yy_chk[281] =
529506 { 0,
530507 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
531508 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
532509 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
533− 1, 1, 1, 1, 1, 3, 13, 13, 101, 3,
534− 3, 3, 3, 15, 3, 14, 14, 32, 32, 3,
535− 3, 3, 3, 3, 5, 5, 5, 15, 5, 31,
536− 31, 31, 5, 5, 5, 5, 5, 7, 7, 7,
510+ 1, 1, 1, 5, 5, 5, 5, 91, 5, 9,
511+ 9, 9, 5, 5, 5, 5, 5, 7, 7, 7,
537512 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
538513 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
539514 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
540−
541− 7, 7, 9, 16, 29, 33, 9, 9, 9, 9,
542− 10, 54, 54, 54, 10, 10, 10, 10, 17, 33,
543− 28, 17, 28, 28, 28, 100, 72, 16, 29, 28,
544− 97, 60, 72, 17, 60, 94, 17, 92, 17, 19,
545− 19, 19, 19, 19, 19, 19, 91, 88, 19, 19,
546− 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
547− 19, 19, 20, 20, 20, 23, 20, 87, 23, 86,
548− 96, 20, 20, 20, 20, 30, 30, 30, 85, 84,
549− 23, 30, 83, 23, 96, 23, 25, 25, 25, 82,
550− 25, 93, 93, 93, 81, 25, 25, 25, 25, 53,
551−
552− 98, 53, 53, 53, 95, 95, 95, 80, 53, 79,
553− 78, 77, 76, 74, 98, 104, 104, 104, 104, 104,
554− 104, 104, 104, 105, 73, 71, 105, 105, 105, 106,
555− 70, 106, 107, 69, 107, 108, 68, 108, 66, 108,
556− 108, 109, 65, 109, 109, 109, 109, 110, 110, 110,
557− 64, 110, 110, 111, 63, 111, 111, 112, 112, 112,
558− 112, 112, 112, 112, 112, 113, 113, 113, 113, 113,
559− 113, 113, 113, 114, 62, 114, 115, 115, 115, 61,
560− 115, 115, 116, 116, 116, 116, 116, 116, 116, 116,
561− 59, 49, 43, 42, 41, 40, 39, 38, 35, 22,
562−
563− 21, 11, 103, 103, 103, 103, 103, 103, 103, 103,
564− 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
565− 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
566− 103, 103, 103, 103, 103, 103, 103, 103
515+ 10, 10, 10, 13, 13, 14, 14, 15, 24, 28,
516+ 24, 24, 25, 25, 25, 50, 24, 50, 25, 90,
517+
518+ 15, 17, 28, 17, 26, 26, 26, 27, 27, 62,
519+ 44, 87, 44, 44, 62, 17, 84, 17, 44, 17,
520+ 21, 21, 21, 21, 21, 45, 45, 45, 86, 21,
521+ 21, 21, 21, 83, 83, 83, 85, 85, 85, 88,
522+ 82, 86, 81, 78, 77, 76, 75, 74, 73, 72,
523+ 71, 70, 88, 94, 94, 94, 94, 94, 94, 94,
524+ 94, 95, 95, 95, 96, 96, 96, 96, 97, 69,
525+ 97, 98, 68, 98, 67, 98, 98, 99, 66, 99,
526+ 99, 99, 99, 100, 64, 100, 100, 101, 101, 101,
527+ 101, 101, 101, 101, 101, 102, 102, 102, 102, 102,
528+
529+ 102, 102, 102, 103, 63, 103, 104, 104, 104, 61,
530+ 104, 104, 105, 105, 105, 105, 105, 105, 105, 105,
531+ 60, 59, 58, 56, 55, 54, 53, 52, 51, 49,
532+ 42, 40, 38, 37, 36, 35, 34, 33, 32, 30,
533+ 19, 18, 16, 11, 4, 3, 93, 93, 93, 93,
534+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
535+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
536+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93
567537 } ;
568538
569−/* Table of booleans, true if rule could match eol. */
570−static yyconst flex_int32_t yy_rule_can_match_eol[21] =
571− { 0,
572−1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0,
573− 0, };
574−
575539 static yy_state_type yy_last_accepting_state;
576540 static char *yy_last_accepting_cpos;
577541
@@ -616,6 +580,13 @@ char *yytext; · 38 unmodified lines
616580 #include "srcpos.h"
617581 #include "dtc-parser.tab.h"
618582
583+YYLTYPE yylloc;
584+
585+/* CAUTION: this will stop working if we ever use yyless() or yyunput() */
586+#define YY_USER_ACTION \
587+ { \
588+ srcpos_update(&yylloc, yytext, yyleng); \
589+ }
619590
620591 /*#define LEXDEBUG 1*/
621592
@@ -625,19 +596,14 @@ char *yytext; · 3 unmodified lines
625596 #define DPRINT(fmt, ...) do { } while (0)
626597 #endif
627598
628−static int dts_version; /* = 0 */
599+static int dts_version = 1;
629600
630−#define BEGIN_DEFAULT() if (dts_version == 0) { \
631− DPRINT("<INITIAL>\n"); \
632− BEGIN(INITIAL); \
633− } else { \
634− DPRINT("<V1>\n"); \
601+#define BEGIN_DEFAULT() DPRINT("<V1>\n"); \
635602 BEGIN(V1); \
636− }
637603
638604 static void push_input_file(const char *filename);
639605 static int pop_input_file(void);
640−#line 641 "dtc-lexer.lex.c"
606+#line 607 "dtc-lexer.lex.c"
641607
642608 #define INITIAL 0
643609 #define INCLUDE 1
@@ -826,9 +792,9 @@ YY_DECL · 182 unmodified lines
826792 register char *yy_cp, *yy_bp;
827793 register int yy_act;
828794
829−#line 64 "dtc-lexer.l"
795+#line 66 "dtc-lexer.l"
830796
831−#line 832 "dtc-lexer.lex.c"
797+#line 798 "dtc-lexer.lex.c"
832798
833799 if ( !(yy_init) )
834800 {
@@ -881,35 +847,21 @@ yy_match: · 46 unmodified lines
881847 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
882848 {
883849 yy_current_state = (int) yy_def[yy_current_state];
884− if ( yy_current_state >= 104 )
850+ if ( yy_current_state >= 94 )
885851 yy_c = yy_meta[(unsigned int) yy_c];
886852 }
887853 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
888854 ++yy_cp;
889855 }
890− while ( yy_base[yy_current_state] != 303 );
856+ while ( yy_current_state != 93 );
857+ yy_cp = (yy_last_accepting_cpos);
858+ yy_current_state = (yy_last_accepting_state);
891859
892860 yy_find_action:
893861 yy_act = yy_accept[yy_current_state];
894− if ( yy_act == 0 )
895− { /* have to back up */
896− yy_cp = (yy_last_accepting_cpos);
897− yy_current_state = (yy_last_accepting_state);
898− yy_act = yy_accept[yy_current_state];
899− }
900862
901863 YY_DO_BEFORE_ACTION;
902864
903− if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
904− {
905− int yyl;
906− for ( yyl = 0; yyl < yyleng; ++yyl )
907− if ( yytext[yyl] == '\n' )
908−
909− yylineno++;
910−;
911− }
912−
913865 do_action: /* This label is used only to access EOF actions. */
914866
915867 switch ( yy_act )
@@ -924,7 +876,7 @@ do_action: /* This label is used only to access EOF actions. */ · 8 unmodified lines
924876 case 1:
925877 /* rule 1 can match eol */
926878 YY_RULE_SETUP
927−#line 65 "dtc-lexer.l"
879+#line 67 "dtc-lexer.l"
928880 {
929881 char *name = strchr(yytext, '\"') + 1;
930882 yytext[yyleng-1] = '\0';
@@ -936,7 +888,7 @@ case YY_STATE_EOF(INCLUDE): · 5 unmodified lines
936888 case YY_STATE_EOF(BYTESTRING):
937889 case YY_STATE_EOF(PROPNODENAME):
938890 case YY_STATE_EOF(V1):
939−#line 71 "dtc-lexer.l"
891+#line 73 "dtc-lexer.l"
940892 {
941893 if (!pop_input_file()) {
942894 yyterminate();
@@ -946,23 +898,18 @@ case YY_STATE_EOF(V1): · 3 unmodified lines
946898 case 2:
947899 /* rule 2 can match eol */
948900 YY_RULE_SETUP
949−#line 77 "dtc-lexer.l"
901+#line 79 "dtc-lexer.l"
950902 {
951− yylloc.file = srcpos_file;
952− yylloc.first_line = yylineno;
953903 DPRINT("String: %s\n", yytext);
954904 yylval.data = data_copy_escape_string(yytext+1,
955905 yyleng-2);
956− yylloc.first_line = yylineno;
957906 return DT_STRING;
958907 }
959908 YY_BREAK
960909 case 3:
961910 YY_RULE_SETUP
962−#line 87 "dtc-lexer.l"
911+#line 86 "dtc-lexer.l"
963912 {
964− yylloc.file = srcpos_file;
965− yylloc.first_line = yylineno;
966913 DPRINT("Keyword: /dts-v1/\n");
967914 dts_version = 1;
968915 BEGIN_DEFAULT();
@@ -971,10 +918,8 @@ YY_RULE_SETUP · 2 unmodified lines
971918 YY_BREAK
972919 case 4:
973920 YY_RULE_SETUP
974−#line 96 "dtc-lexer.l"
921+#line 93 "dtc-lexer.l"
975922 {
976− yylloc.file = srcpos_file;
977− yylloc.first_line = yylineno;
978923 DPRINT("Keyword: /memreserve/\n");
979924 BEGIN_DEFAULT();
980925 return DT_MEMRESERVE;
@@ -982,158 +927,100 @@ YY_RULE_SETUP · 1 unmodified line
982927 YY_BREAK
983928 case 5:
984929 YY_RULE_SETUP
985−#line 104 "dtc-lexer.l"
930+#line 99 "dtc-lexer.l"
986931 {
987− yylloc.file = srcpos_file;
988− yylloc.first_line = yylineno;
989932 DPRINT("Label: %s\n", yytext);
990− yylval.labelref = strdup(yytext);
933+ yylval.labelref = xstrdup(yytext);
991934 yylval.labelref[yyleng-1] = '\0';
992935 return DT_LABEL;
993936 }
994937 YY_BREAK
995938 case 6:
996939 YY_RULE_SETUP
997−#line 113 "dtc-lexer.l"
998−{
999− yylloc.file = srcpos_file;
1000− yylloc.first_line = yylineno;
1001− if (*yytext == 'b')
1002− yylval.cbase = 2;
1003− else if (*yytext == 'o')
1004− yylval.cbase = 8;
1005− else if (*yytext == 'd')
1006− yylval.cbase = 10;
1007− else
1008− yylval.cbase = 16;
1009− DPRINT("Base: %d\n", yylval.cbase);
1010− return DT_BASE;
1011− }
1012− YY_BREAK
1013−case 7:
1014−YY_RULE_SETUP
1015−#line 128 "dtc-lexer.l"
940+#line 106 "dtc-lexer.l"
1016941 {
1017− yylloc.file = srcpos_file;
1018− yylloc.first_line = yylineno;
1019− yylval.literal = strdup(yytext);
1020− DPRINT("Literal: '%s'\n", yylval.literal);
1021− return DT_LEGACYLITERAL;
1022− }
1023− YY_BREAK
1024−case 8:
1025−YY_RULE_SETUP
1026−#line 136 "dtc-lexer.l"
1027−{
1028− yylloc.file = srcpos_file;
1029− yylloc.first_line = yylineno;
1030− yylval.literal = strdup(yytext);
942+ yylval.literal = xstrdup(yytext);
1031943 DPRINT("Literal: '%s'\n", yylval.literal);
1032944 return DT_LITERAL;
1033945 }
1034946 YY_BREAK
1035−case 9:
947+case 7:
1036948 YY_RULE_SETUP
1037−#line 144 "dtc-lexer.l"
949+#line 112 "dtc-lexer.l"
1038950 { /* label reference */
1039− yylloc.file = srcpos_file;
1040− yylloc.first_line = yylineno;
1041951 DPRINT("Ref: %s\n", yytext+1);
1042− yylval.labelref = strdup(yytext+1);
952+ yylval.labelref = xstrdup(yytext+1);
1043953 return DT_REF;
1044954 }
1045955 YY_BREAK
1046−case 10:
956+case 8:
1047957 YY_RULE_SETUP
1048−#line 152 "dtc-lexer.l"
958+#line 118 "dtc-lexer.l"
1049959 { /* new-style path reference */
1050− yylloc.file = srcpos_file;
1051− yylloc.first_line = yylineno;
1052960 yytext[yyleng-1] = '\0';
1053961 DPRINT("Ref: %s\n", yytext+2);
1054− yylval.labelref = strdup(yytext+2);
962+ yylval.labelref = xstrdup(yytext+2);
1055963 return DT_REF;
1056964 }
1057965 YY_BREAK
1058−case 11:
1059−YY_RULE_SETUP
1060−#line 161 "dtc-lexer.l"
1061−{ /* old-style path reference */
1062− yylloc.file = srcpos_file;
1063− yylloc.first_line = yylineno;
1064− DPRINT("Ref: %s\n", yytext+1);
1065− yylval.labelref = strdup(yytext+1);
1066− return DT_REF;
1067− }
1068− YY_BREAK
1069−case 12:
966+case 9:
1070967 YY_RULE_SETUP
1071−#line 169 "dtc-lexer.l"
968+#line 125 "dtc-lexer.l"
1072969 {
1073− yylloc.file = srcpos_file;
1074− yylloc.first_line = yylineno;
1075970 yylval.byte = strtol(yytext, NULL, 16);
1076971 DPRINT("Byte: %02x\n", (int)yylval.byte);
1077972 return DT_BYTE;
1078973 }
1079974 YY_BREAK
1080−case 13:
975+case 10:
1081976 YY_RULE_SETUP
1082−#line 177 "dtc-lexer.l"
977+#line 131 "dtc-lexer.l"
1083978 {
1084− yylloc.file = srcpos_file;
1085− yylloc.first_line = yylineno;
1086979 DPRINT("/BYTESTRING\n");
1087980 BEGIN_DEFAULT();
1088981 return ']';
1089982 }
1090983 YY_BREAK
1091−case 14:
984+case 11:
1092985 YY_RULE_SETUP
1093−#line 185 "dtc-lexer.l"
986+#line 137 "dtc-lexer.l"
1094987 {
1095− yylloc.file = srcpos_file;
1096− yylloc.first_line = yylineno;
1097988 DPRINT("PropNodeName: %s\n", yytext);
1098− yylval.propnodename = strdup(yytext);
989+ yylval.propnodename = xstrdup(yytext);
1099990 BEGIN_DEFAULT();
1100991 return DT_PROPNODENAME;
1101992 }
1102993 YY_BREAK
1103−case 15:
994+case 12:
1104995 YY_RULE_SETUP
1105−#line 194 "dtc-lexer.l"
996+#line 144 "dtc-lexer.l"
1106997 {
1107− yylloc.file = srcpos_file;
1108− yylloc.first_line = yylineno;
1109998 DPRINT("Binary Include\n");
1110999 return DT_INCBIN;
11111000 }
11121001 YY_BREAK
1113−case 16:
1114−/* rule 16 can match eol */
1002+case 13:
1003+/* rule 13 can match eol */
11151004 YY_RULE_SETUP
1116−#line 201 "dtc-lexer.l"
1005+#line 149 "dtc-lexer.l"
11171006 /* eat whitespace */
11181007 YY_BREAK
1119−case 17:
1120−/* rule 17 can match eol */
1008+case 14:
1009+/* rule 14 can match eol */
11211010 YY_RULE_SETUP
1122−#line 202 "dtc-lexer.l"
1011+#line 150 "dtc-lexer.l"
11231012 /* eat C-style comments */
11241013 YY_BREAK
1125−case 18:
1126−/* rule 18 can match eol */
1014+case 15:
1015+/* rule 15 can match eol */
11271016 YY_RULE_SETUP
1128−#line 203 "dtc-lexer.l"
1017+#line 151 "dtc-lexer.l"
11291018 /* eat C++-style comments */
11301019 YY_BREAK
1131−case 19:
1020+case 16:
11321021 YY_RULE_SETUP
1133−#line 205 "dtc-lexer.l"
1022+#line 153 "dtc-lexer.l"
11341023 {
1135− yylloc.file = srcpos_file;
1136− yylloc.first_line = yylineno;
11371024 DPRINT("Char: %c (\\x%02x)\n", yytext[0],
11381025 (unsigned)yytext[0]);
11391026 if (yytext[0] == '[') {
@@ -1148,12 +1035,12 @@ YY_RULE_SETUP · 8 unmodified lines
11481035 return yytext[0];
11491036 }
11501037 YY_BREAK
1151−case 20:
1038+case 17:
11521039 YY_RULE_SETUP
1153−#line 222 "dtc-lexer.l"
1040+#line 168 "dtc-lexer.l"
11541041 ECHO;
11551042 YY_BREAK
1156−#line 1157 "dtc-lexer.lex.c"
1043+#line 1044 "dtc-lexer.lex.c"
11571044
11581045 case YY_END_OF_BUFFER:
11591046 {
@@ -1218,7 +1105,8 @@ ECHO; · 58 unmodified lines
12181105
12191106 else
12201107 {
1221− yy_cp = (yy_c_buf_p);
1108+ yy_cp = (yy_last_accepting_cpos);
1109+ yy_current_state = (yy_last_accepting_state);
12221110 goto yy_find_action;
12231111 }
12241112 }
@@ -1443,7 +1331,7 @@ static int yy_get_next_buffer (void) · 218 unmodified lines
14431331 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
14441332 {
14451333 yy_current_state = (int) yy_def[yy_current_state];
1446− if ( yy_current_state >= 104 )
1334+ if ( yy_current_state >= 94 )
14471335 yy_c = yy_meta[(unsigned int) yy_c];
14481336 }
14491337 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1471,11 +1359,11 @@ static int yy_get_next_buffer (void) · 21 unmodified lines
14711359 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
14721360 {
14731361 yy_current_state = (int) yy_def[yy_current_state];
1474− if ( yy_current_state >= 104 )
1362+ if ( yy_current_state >= 94 )
14751363 yy_c = yy_meta[(unsigned int) yy_c];
14761364 }
14771365 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1478− yy_is_jam = (yy_current_state == 103);
1366+ yy_is_jam = (yy_current_state == 93);
14791367
14801368 return yy_is_jam ? 0 : yy_current_state;
14811369 }
@@ -1550,11 +1438,6 @@ static int yy_get_next_buffer (void) · 68 unmodified lines
15501438 *(yy_c_buf_p) = '\0'; /* preserve yytext */
15511439 (yy_hold_char) = *++(yy_c_buf_p);
15521440
1553− if ( c == '\n' )
1554−
1555− yylineno++;
1556−;
1557−
15581441 return c;
15591442 }
15601443 #endif /* ifndef YY_NO_INPUT */
@@ -1669,10 +1552,6 @@ static void yy_load_buffer_state (void) · 108 unmodified lines
16691552 yyfree((void *) b );
16701553 }
16711554
1672−#ifndef __cplusplus
1673−extern int isatty (int );
1674−#endif /* __cplusplus */
1675−
16761555 /* Initializes or reinitializes a buffer.
16771556 * This function is sometimes called more than once on the same buffer,
16781557 * such as during a yyrestart() or at EOF.
@@ -1696,7 +1575,7 @@ extern int isatty (int ); · 17 unmodified lines
16961575 b->yy_bs_column = 0;
16971576 }
16981577
1699− b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1578+ b->yy_is_interactive = 0;
17001579
17011580 errno = oerrno;
17021581 }
@@ -2025,9 +1904,6 @@ static int yy_init_globals (void) · 322 unmodified lines
20251904 * This function is called from yylex_destroy(), so don't allocate here.
20261905 */
20271906
2028− /* We do not touch yylineno unless the option is enabled. */
2029− yylineno = 1;
2030−
20311907 (yy_buffer_stack) = 0;
20321908 (yy_buffer_stack_top) = 0;
20331909 (yy_buffer_stack_max) = 0;
@@ -2120,104 +1996,29 @@ void yyfree (void * ptr ) · 86 unmodified lines
21201996
21211997 #define YYTABLES_NAME "yytables"
21221998
2123−#line 222 "dtc-lexer.l"
2124−
2125−
2126−
2127−
2128−/*
2129− * Stack of nested include file contexts.
2130− */
2131−
2132−struct incl_file {
2133− struct dtc_file *file;
2134− YY_BUFFER_STATE yy_prev_buf;
2135− int yy_prev_lineno;
2136− struct incl_file *prev;
2137−};
2138−
2139−static struct incl_file *incl_file_stack;
1999+#line 168 "dtc-lexer.l"
21402000
21412001
2142−/*
2143− * Detect infinite include recursion.
2144− */
2145−#define MAX_INCLUDE_DEPTH (100)
2146−
2147−static int incl_depth = 0;
2148−
21492002
21502003 static void push_input_file(const char *filename)
21512004 {
2152− struct incl_file *incl_file;
2153− struct dtc_file *newfile;
2154− struct search_path search, *searchptr = NULL;
2155−
21562005 assert(filename);
21572006
2158− if (incl_depth++ >= MAX_INCLUDE_DEPTH)
2159− die("Includes nested too deeply");
2160−
2161− if (srcpos_file) {
2162− search.dir = srcpos_file->dir;
2163− search.next = NULL;
2164− search.prev = NULL;
2165− searchptr = &search;
2166− }
2167−
2168− newfile = dtc_open_file(filename, searchptr);
2007+ srcfile_push(filename);
21692008
2170− incl_file = xmalloc(sizeof(struct incl_file));
2009+ yyin = current_srcfile->f;
21712010
2172− /*
2173− * Save current context.
2174− */
2175− incl_file->yy_prev_buf = YY_CURRENT_BUFFER;
2176− incl_file->yy_prev_lineno = yylineno;
2177− incl_file->file = srcpos_file;
2178− incl_file->prev = incl_file_stack;
2179−
2180− incl_file_stack = incl_file;
2181−
2182− /*
2183− * Establish new context.
2184− */
2185− srcpos_file = newfile;
2186− yylineno = 1;
2187− yyin = newfile->file;
2188− yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
2011+ yypush_buffer_state(yy_create_buffer(yyin,YY_BUF_SIZE));
21892012 }
21902013
21912014
21922015 static int pop_input_file(void)
21932016 {
2194− struct incl_file *incl_file;
2195−
2196− if (incl_file_stack == 0)
2017+ if (srcfile_pop() == 0)
21972018 return 0;
21982019
2199− dtc_close_file(srcpos_file);
2200−
2201− /*
2202− * Pop.
2203− */
2204− --incl_depth;
2205− incl_file = incl_file_stack;
2206− incl_file_stack = incl_file->prev;
2207−
2208− /*
2209− * Recover old context.
2210− */
2211− yy_delete_buffer(YY_CURRENT_BUFFER);
2212− yy_switch_to_buffer(incl_file->yy_prev_buf);
2213− yylineno = incl_file->yy_prev_lineno;
2214− srcpos_file = incl_file->file;
2215− yyin = incl_file->file ? incl_file->file->file : NULL;
2216−
2217− /*
2218− * Free old state.
2219− */
2220− free(incl_file);
2020+ yypop_buffer_state();
2021+ yyin = current_srcfile->f;
22212022
22222023 return 1;
22232024 }
scripts/dtc/dtc-parser.tab.c_shipped+440−452
@@ -1,24 +1,23 @@
1−/* A Bison parser, made by GNU Bison 2.3. */
21
3−/* Skeleton implementation for Bison's Yacc-like parsers in C
2+/* A Bison parser, made by GNU Bison 2.4.1. */
43
5− Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
4+/* Skeleton implementation for Bison's Yacc-like parsers in C
5+
6+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
67 Free Software Foundation, Inc.
7−
8− This program is free software; you can redistribute it and/or modify
8+
9+ This program is free software: you can redistribute it and/or modify
910 it under the terms of the GNU General Public License as published by
10− the Free Software Foundation; either version 2, or (at your option)
11− any later version.
12−
11+ the Free Software Foundation, either version 3 of the License, or
12+ (at your option) any later version.
13+
1314 This program is distributed in the hope that it will be useful,
1415 but WITHOUT ANY WARRANTY; without even the implied warranty of
1516 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1617 GNU General Public License for more details.
17−
18+
1819 You should have received a copy of the GNU General Public License
19− along with this program; if not, write to the Free Software
20− Foundation, Inc., 51 Franklin Street, Fifth Floor,
21− Boston, MA 02110-1301, USA. */
20+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2221
2322 /* As a special exception, you may create a larger work that contains
2423 part or all of the Bison parser skeleton and distribute that work
@@ -29,7 +28,7 @@ · 4 unmodified lines
2928 special exception, which will cause the skeleton and the resulting
3029 Bison output files to be licensed under the GNU General Public
3130 License without this special exception.
32−
31+
3332 This special exception was added by the Free Software Foundation in
3433 version 2.2 of Bison. */
3534
@@ -47,7 +46,7 @@ · 11 unmodified lines
4746 #define YYBISON 1
4847
4948 /* Bison version. */
50−#define YYBISON_VERSION "2.3"
49+#define YYBISON_VERSION "2.4.1"
5150
5251 /* Skeleton name. */
5352 #define YYSKELETON_NAME "yacc.c"
@@ -55,55 +54,32 @@ · 1 unmodified line
5554 /* Pure parsers. */
5655 #define YYPURE 0
5756
58−/* Using locations. */
59−#define YYLSP_NEEDED 1
60−
57+/* Push parsers. */
58+#define YYPUSH 0
6159
60+/* Pull parsers. */
61+#define YYPULL 1
6262
63−/* Tokens. */
64−#ifndef YYTOKENTYPE
65−# define YYTOKENTYPE
66− /* Put the tokens into the symbol table, so that GDB and other debuggers
67− know about them. */
68− enum yytokentype {
69− DT_V1 = 258,
70− DT_MEMRESERVE = 259,
71− DT_PROPNODENAME = 260,
72− DT_LITERAL = 261,
73− DT_LEGACYLITERAL = 262,
74− DT_BASE = 263,
75− DT_BYTE = 264,
76− DT_STRING = 265,
77− DT_LABEL = 266,
78− DT_REF = 267,
79− DT_INCBIN = 268
80− };
81−#endif
82−/* Tokens. */
83−#define DT_V1 258
84−#define DT_MEMRESERVE 259
85−#define DT_PROPNODENAME 260
86−#define DT_LITERAL 261
87−#define DT_LEGACYLITERAL 262
88−#define DT_BASE 263
89−#define DT_BYTE 264
90−#define DT_STRING 265
91−#define DT_LABEL 266
92−#define DT_REF 267
93−#define DT_INCBIN 268
94−
63+/* Using locations. */
64+#define YYLSP_NEEDED 0
9565
9666
9767
9868 /* Copy the first part of user declarations. */
99−#line 23 "dtc-parser.y"
69+
70+/* Line 189 of yacc.c */
71+#line 21 "dtc-parser.y"
10072
10173 #include <stdio.h>
10274
10375 #include "dtc.h"
10476 #include "srcpos.h"
10577
78+YYLTYPE yylloc;
79+
10680 extern int yylex(void);
81+extern void print_error(char const *fmt, ...);
82+extern void yyerror(char const *s);
10783
10884 extern struct boot_info *the_boot_info;
10985 extern int treesource_error;
@@ -111,6 +87,9 @@ extern int treesource_error; · 1 unmodified line
11187 static unsigned long long eval_literal(const char *s, int base, int bits);
11288
11389
90+/* Line 189 of yacc.c */
91+#line 92 "dtc-parser.tab.c"
92+
11493 /* Enabling traces. */
11594 #ifndef YYDEBUG
11695 # define YYDEBUG 0
@@ -129,10 +108,35 @@ static unsigned long long eval_literal(const char *s, int base, int bits); · 12 unmodified lines
129108 # define YYTOKEN_TABLE 0
130109 #endif
131110
111+
112+/* Tokens. */
113+#ifndef YYTOKENTYPE
114+# define YYTOKENTYPE
115+ /* Put the tokens into the symbol table, so that GDB and other debuggers
116+ know about them. */
117+ enum yytokentype {
118+ DT_V1 = 258,
119+ DT_MEMRESERVE = 259,
120+ DT_PROPNODENAME = 260,
121+ DT_LITERAL = 261,
122+ DT_BASE = 262,
123+ DT_BYTE = 263,
124+ DT_STRING = 264,
125+ DT_LABEL = 265,
126+ DT_REF = 266,
127+ DT_INCBIN = 267
128+ };
129+#endif
130+
131+
132+
132133 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
133134 typedef union YYSTYPE
134−#line 37 "dtc-parser.y"
135135 {
136+
137+/* Line 214 of yacc.c */
138+#line 39 "dtc-parser.y"
139+
136140 char *propnodename;
137141 char *literal;
138142 char *labelref;
@@ -147,34 +151,23 @@ typedef union YYSTYPE · 8 unmodified lines
147151 struct node *node;
148152 struct node *nodelist;
149153 struct reserve_info *re;
150−}
151−/* Line 187 of yacc.c. */
152−#line 153 "dtc-parser.tab.c"
153− YYSTYPE;
154+
155+
156+
157+/* Line 214 of yacc.c */
158+#line 159 "dtc-parser.tab.c"
159+} YYSTYPE;
160+# define YYSTYPE_IS_TRIVIAL 1
154161 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
155162 # define YYSTYPE_IS_DECLARED 1
156−# define YYSTYPE_IS_TRIVIAL 1
157−#endif
158−
159−#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
160−typedef struct YYLTYPE
161−{
162− int first_line;
163− int first_column;
164− int last_line;
165− int last_column;
166−} YYLTYPE;
167−# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
168−# define YYLTYPE_IS_DECLARED 1
169−# define YYLTYPE_IS_TRIVIAL 1
170163 #endif
171164
172165
173166 /* Copy the second part of user declarations. */
174167
175168
176−/* Line 216 of yacc.c. */
177−#line 178 "dtc-parser.tab.c"
169+/* Line 264 of yacc.c */
170+#line 171 "dtc-parser.tab.c"
178171
179172 #ifdef short
180173 # undef short
@@ -249,14 +242,14 @@ typedef short int yytype_int16; · 68 unmodified lines
249242 #if (defined __STDC__ || defined __C99__FUNC__ \
250243 || defined __cplusplus || defined _MSC_VER)
251244 static int
252−YYID (int i)
245+YYID (int yyi)
253246 #else
254247 static int
255−YYID (i)
256− int i;
248+YYID (yyi)
249+ int yyi;
257250 #endif
258251 {
259− return i;
252+ return yyi;
260253 }
261254 #endif
262255
@@ -332,15 +325,13 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ · 69 unmodified lines
332325
333326 #if (! defined yyoverflow \
334327 && (! defined __cplusplus \
335− || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
336− && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
328+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
337329
338330 /* A type that is properly aligned for any stack member. */
339331 union yyalloc
340332 {
341− yytype_int16 yyss;
342− YYSTYPE yyvs;
343− YYLTYPE yyls;
333+ yytype_int16 yyss_alloc;
334+ YYSTYPE yyvs_alloc;
344335 };
345336
346337 /* The size of the maximum gap between one aligned stack and the next. */
@@ -349,8 +340,8 @@ union yyalloc · 2 unmodified lines
349340 /* The size of an array large to enough to hold all stacks, each with
350341 N elements. */
351342 # define YYSTACK_BYTES(N) \
352− ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
353− + 2 * YYSTACK_GAP_MAXIMUM)
343+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
344+ + YYSTACK_GAP_MAXIMUM)
354345
355346 /* Copy COUNT objects from FROM to TO. The source and destination do
356347 not overlap. */
@@ -375,12 +366,12 @@ union yyalloc · 18 unmodified lines
375366 elements in the stack, and YYPTR gives the new location of the
376367 stack. Advance YYPTR to a properly aligned location for the next
377368 stack. */
378−# define YYSTACK_RELOCATE(Stack) \
369+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
379370 do \
380371 { \
381372 YYSIZE_T yynewbytes; \
382− YYCOPY (&yyptr->Stack, Stack, yysize); \
383− Stack = &yyptr->Stack; \
373+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
374+ Stack = &yyptr->Stack_alloc; \
384375 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
385376 yyptr += yynewbytes / sizeof (*yyptr); \
386377 } \
@@ -389,22 +380,22 @@ union yyalloc · 2 unmodified lines
389380 #endif
390381
391382 /* YYFINAL -- State number of the termination state. */
392−#define YYFINAL 9
383+#define YYFINAL 4
393384 /* YYLAST -- Last index in YYTABLE. */
394−#define YYLAST 73
385+#define YYLAST 56
395386
396387 /* YYNTOKENS -- Number of terminals. */
397−#define YYNTOKENS 27
388+#define YYNTOKENS 25
398389 /* YYNNTS -- Number of nonterminals. */
399−#define YYNNTS 20
390+#define YYNNTS 16
400391 /* YYNRULES -- Number of rules. */
401−#define YYNRULES 45
392+#define YYNRULES 39
402393 /* YYNRULES -- Number of states. */
403−#define YYNSTATES 76
394+#define YYNSTATES 67
404395
405396 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
406397 #define YYUNDEFTOK 2
407−#define YYMAXUTOK 268
398+#define YYMAXUTOK 267
408399
409400 #define YYTRANSLATE(YYX) \
410401 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -416,15 +407,15 @@ static const yytype_uint8 yytranslate[] = · 5 unmodified lines
416407 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
417408 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418409 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419− 24, 26, 2, 2, 25, 15, 2, 16, 2, 2,
420− 2, 2, 2, 2, 2, 2, 2, 2, 2, 14,
421− 20, 19, 21, 2, 2, 2, 2, 2, 2, 2,
410+ 22, 24, 2, 2, 23, 2, 2, 14, 2, 2,
411+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 13,
412+ 18, 17, 19, 2, 2, 2, 2, 2, 2, 2,
422413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
423414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424− 2, 22, 2, 23, 2, 2, 2, 2, 2, 2,
415+ 2, 20, 2, 21, 2, 2, 2, 2, 2, 2,
425416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
426417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427− 2, 2, 2, 17, 2, 18, 2, 2, 2, 2,
418+ 2, 2, 2, 15, 2, 16, 2, 2, 2, 2,
428419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
429420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -438,7 +429,7 @@ static const yytype_uint8 yytranslate[] = · 7 unmodified lines
438429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
440431 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
441− 5, 6, 7, 8, 9, 10, 11, 12, 13
432+ 5, 6, 7, 8, 9, 10, 11, 12
442433 };
443434
444435 #if YYDEBUG
@@ -446,41 +437,37 @@ static const yytype_uint8 yytranslate[] = · 1 unmodified line
446437 YYRHS. */
447438 static const yytype_uint8 yyprhs[] =
448439 {
449− 0, 0, 3, 8, 11, 12, 15, 21, 22, 25,
450− 27, 34, 36, 38, 41, 47, 48, 51, 57, 61,
451− 64, 69, 74, 77, 87, 93, 96, 97, 100, 103,
452− 104, 107, 110, 113, 114, 116, 118, 121, 122, 125,
453− 128, 129, 132, 135, 139, 140
440+ 0, 0, 3, 8, 9, 12, 17, 20, 22, 25,
441+ 29, 33, 39, 40, 43, 48, 51, 54, 57, 62,
442+ 67, 70, 80, 86, 89, 90, 93, 96, 97, 100,
443+ 103, 106, 108, 109, 112, 115, 116, 119, 122, 125
454444 };
455445
456446 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
457447 static const yytype_int8 yyrhs[] =
458448 {
459− 28, 0, -1, 3, 14, 29, 34, -1, 31, 34,
460− -1, -1, 30, 29, -1, 46, 4, 33, 33, 14,
461− -1, -1, 32, 31, -1, 30, -1, 46, 4, 33,
462− 15, 33, 14, -1, 6, -1, 7, -1, 16, 35,
463− -1, 17, 36, 44, 18, 14, -1, -1, 36, 37,
464− -1, 46, 5, 19, 38, 14, -1, 46, 5, 14,
465− -1, 39, 10, -1, 39, 20, 40, 21, -1, 39,
466− 22, 43, 23, -1, 39, 12, -1, 39, 13, 24,
467− 10, 25, 33, 25, 33, 26, -1, 39, 13, 24,
468− 10, 26, -1, 38, 11, -1, -1, 38, 25, -1,
469− 39, 11, -1, -1, 40, 42, -1, 40, 12, -1,
470− 40, 11, -1, -1, 8, -1, 6, -1, 41, 7,
471− -1, -1, 43, 9, -1, 43, 11, -1, -1, 45,
472− 44, -1, 45, 37, -1, 46, 5, 35, -1, -1,
473− 11, -1
449+ 26, 0, -1, 3, 13, 27, 30, -1, -1, 28,
450+ 27, -1, 4, 29, 29, 13, -1, 10, 28, -1,
451+ 6, -1, 14, 31, -1, 30, 14, 31, -1, 30,
452+ 11, 31, -1, 15, 32, 39, 16, 13, -1, -1,
453+ 32, 33, -1, 5, 17, 34, 13, -1, 5, 13,
454+ -1, 10, 33, -1, 35, 9, -1, 35, 18, 36,
455+ 19, -1, 35, 20, 38, 21, -1, 35, 11, -1,
456+ 35, 12, 22, 9, 23, 29, 23, 29, 24, -1,
457+ 35, 12, 22, 9, 24, -1, 34, 10, -1, -1,
458+ 34, 23, -1, 35, 10, -1, -1, 36, 37, -1,
459+ 36, 11, -1, 36, 10, -1, 6, -1, -1, 38,
460+ 8, -1, 38, 10, -1, -1, 40, 39, -1, 40,
461+ 33, -1, 5, 31, -1, 10, 40, -1
474462 };
475463
476464 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
477465 static const yytype_uint16 yyrline[] =
478466 {
479− 0, 89, 89, 93, 101, 104, 111, 119, 122, 129,
480− 133, 140, 144, 151, 158, 166, 169, 176, 180, 187,
481− 191, 195, 199, 203, 220, 231, 239, 242, 246, 254,
482− 257, 261, 266, 274, 277, 281, 285, 293, 296, 300,
483− 308, 311, 315, 323, 331, 334
467+ 0, 86, 86, 95, 98, 105, 109, 117, 124, 128,
468+ 132, 145, 153, 156, 163, 167, 171, 179, 183, 187,
469+ 191, 195, 212, 222, 230, 233, 237, 245, 248, 252,
470+ 257, 264, 272, 275, 279, 287, 290, 294, 302, 306
484471 };
485472 #endif
486473
@@ -490,13 +477,12 @@ static const yytype_uint16 yyrline[] = · 3 unmodified lines
490477 static const char *const yytname[] =
491478 {
492479 "$end", "error", "$undefined", "DT_V1", "DT_MEMRESERVE",
493− "DT_PROPNODENAME", "DT_LITERAL", "DT_LEGACYLITERAL", "DT_BASE",
494− "DT_BYTE", "DT_STRING", "DT_LABEL", "DT_REF", "DT_INCBIN", "';'", "'-'",
495− "'/'", "'{'", "'}'", "'='", "'<'", "'>'", "'['", "']'", "'('", "','",
496− "')'", "$accept", "sourcefile", "memreserves", "memreserve",
497− "v0_memreserves", "v0_memreserve", "addr", "devicetree", "nodedef",
498− "proplist", "propdef", "propdata", "propdataprefix", "celllist",
499− "cellbase", "cellval", "bytestring", "subnodes", "subnode", "label", 0
480+ "DT_PROPNODENAME", "DT_LITERAL", "DT_BASE", "DT_BYTE", "DT_STRING",
481+ "DT_LABEL", "DT_REF", "DT_INCBIN", "';'", "'/'", "'{'", "'}'", "'='",
482+ "'<'", "'>'", "'['", "']'", "'('", "','", "')'", "$accept", "sourcefile",
483+ "memreserves", "memreserve", "addr", "devicetree", "nodedef", "proplist",
484+ "propdef", "propdata", "propdataprefix", "celllist", "cellval",
485+ "bytestring", "subnodes", "subnode", 0
500486 };
501487 #endif
502488
@@ -506,29 +492,27 @@ static const char *const yytname[] = · 3 unmodified lines
506492 static const yytype_uint16 yytoknum[] =
507493 {
508494 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
509− 265, 266, 267, 268, 59, 45, 47, 123, 125, 61,
510− 60, 62, 91, 93, 40, 44, 41
495+ 265, 266, 267, 59, 47, 123, 125, 61, 60, 62,
496+ 91, 93, 40, 44, 41
511497 };
512498 # endif
513499
514500 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
515501 static const yytype_uint8 yyr1[] =
516502 {
517− 0, 27, 28, 28, 29, 29, 30, 31, 31, 32,
518− 32, 33, 33, 34, 35, 36, 36, 37, 37, 38,
519− 38, 38, 38, 38, 38, 38, 39, 39, 39, 40,
520− 40, 40, 40, 41, 41, 42, 42, 43, 43, 43,
521− 44, 44, 44, 45, 46, 46
503+ 0, 25, 26, 27, 27, 28, 28, 29, 30, 30,
504+ 30, 31, 32, 32, 33, 33, 33, 34, 34, 34,
505+ 34, 34, 34, 34, 35, 35, 35, 36, 36, 36,
506+ 36, 37, 38, 38, 38, 39, 39, 39, 40, 40
522507 };
523508
524509 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
525510 static const yytype_uint8 yyr2[] =
526511 {
527− 0, 2, 4, 2, 0, 2, 5, 0, 2, 1,
528− 6, 1, 1, 2, 5, 0, 2, 5, 3, 2,
529− 4, 4, 2, 9, 5, 2, 0, 2, 2, 0,
530− 2, 2, 2, 0, 1, 1, 2, 0, 2, 2,
531− 0, 2, 2, 3, 0, 1
512+ 0, 2, 4, 0, 2, 4, 2, 1, 2, 3,
513+ 3, 5, 0, 2, 4, 2, 2, 2, 4, 4,
514+ 2, 9, 5, 2, 0, 2, 2, 0, 2, 2,
515+ 2, 1, 0, 2, 2, 0, 2, 2, 2, 2
532516 };
533517
534518 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -536,86 +520,79 @@ static const yytype_uint8 yyr2[] = · 1 unmodified line
536520 means the default is an error. */
537521 static const yytype_uint8 yydefact[] =
538522 {
539− 7, 0, 45, 0, 9, 0, 7, 0, 4, 1,
540− 0, 3, 8, 0, 0, 4, 0, 15, 13, 11,
541− 12, 0, 2, 5, 0, 40, 0, 0, 0, 16,
542− 0, 40, 0, 0, 6, 0, 42, 41, 0, 10,
543− 14, 18, 26, 43, 0, 0, 25, 17, 27, 19,
544− 28, 22, 0, 29, 37, 0, 33, 0, 0, 35,
545− 34, 32, 31, 20, 0, 30, 38, 39, 21, 0,
546− 24, 36, 0, 0, 0, 23
523+ 0, 0, 0, 3, 1, 0, 0, 0, 3, 7,
524+ 0, 6, 0, 2, 4, 0, 12, 8, 0, 0,
525+ 5, 35, 10, 9, 0, 0, 13, 0, 35, 15,
526+ 24, 38, 16, 39, 0, 37, 36, 0, 0, 11,
527+ 23, 14, 25, 17, 26, 20, 0, 27, 32, 0,
528+ 0, 0, 0, 31, 30, 29, 18, 28, 33, 34,
529+ 19, 0, 22, 0, 0, 0, 21
547530 };
548531
549532 /* YYDEFGOTO[NTERM-NUM]. */
550533 static const yytype_int8 yydefgoto[] =
551534 {
552− -1, 3, 14, 4, 5, 6, 27, 11, 18, 25,
553− 29, 44, 45, 56, 64, 65, 57, 30, 31, 7
535+ -1, 2, 7, 8, 10, 13, 17, 21, 26, 37,
536+ 38, 50, 57, 51, 27, 28
554537 };
555538
556539 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
557540 STATE-NUM. */
558−#define YYPACT_NINF -14
541+#define YYPACT_NINF -12
559542 static const yytype_int8 yypact[] =
560543 {
561− 30, -11, -14, 7, -14, -1, 27, 13, 27, -14,
562− 8, -14, -14, 40, -1, 27, 35, -14, -14, -14,
563− -14, 21, -14, -14, 40, 24, 40, 28, 40, -14,
564− 32, 24, 46, 38, -14, 39, -14, -14, 26, -14,
565− -14, -14, -14, -14, -9, 10, -14, -14, -14, -14,
566− -14, -14, 31, -14, -14, 44, -2, 3, 23, -14,
567− -14, -14, -14, -14, 50, -14, -14, -14, -14, 40,
568− -14, -14, 33, 40, 36, -14
544+ 10, -11, 18, -1, -12, 22, -1, 15, -1, -12,
545+ 22, -12, 20, 1, -12, 17, -12, -12, 20, 20,
546+ -12, 6, -12, -12, 21, 6, -12, 23, 6, -12,
547+ -12, -12, -12, -12, 28, -12, -12, -6, 13, -12,
548+ -12, -12, -12, -12, -12, -12, 24, -12, -12, 33,
549+ -5, 0, -4, -12, -12, -12, -12, -12, -12, -12,
550+ -12, 22, -12, 25, 22, 19, -12
569551 };
570552
571553 /* YYPGOTO[NTERM-NUM]. */
572554 static const yytype_int8 yypgoto[] =
573555 {
574− -14, -14, 48, 29, 53, -14, -13, 47, 34, -14,
575− 37, -14, -14, -14, -14, -14, -14, 42, -14, -7
556+ -12, -12, 36, 39, -10, -12, 8, -12, 12, -12,
557+ -12, -12, -12, -12, 27, 31
576558 };
577559
578560 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
579561 positive, shift that token. If negative, reduce the rule which
580562 number is the opposite. If zero, do what YYDEFACT says.
581563 If YYTABLE_NINF, syntax error. */
582−#define YYTABLE_NINF -45
583−static const yytype_int8 yytable[] =
564+#define YYTABLE_NINF -1
565+static const yytype_uint8 yytable[] =
584566 {
585− 21, 16, 46, 8, 59, 47, 60, 9, 16, 61,
586− 62, 28, 66, 33, 67, 10, 48, 13, 32, 63,
587− 49, 50, 51, 52, 32, 17, 68, 19, 20, -44,
588− 53, -44, 54, 1, -44, 2, 26, 15, 2, 24,
589− 41, 2, 34, 17, 15, 42, 19, 20, 69, 70,
590− 35, 38, 39, 40, 58, 55, 72, 71, 73, 12,
591− 74, 22, 75, 23, 0, 0, 0, 0, 36, 0,
592− 0, 0, 43, 37
567+ 15, 53, 3, 5, 40, 54, 55, 41, 58, 6,
568+ 59, 24, 18, 1, 56, 19, 25, 42, 4, 61,
569+ 62, 60, 43, 44, 45, 46, 22, 23, 9, 12,
570+ 20, 47, 31, 48, 29, 16, 16, 32, 30, 34,
571+ 35, 39, 52, 66, 14, 11, 49, 0, 64, 0,
572+ 0, 63, 0, 0, 65, 36, 33
593573 };
594574
595575 static const yytype_int8 yycheck[] =
596576 {
597− 13, 8, 11, 14, 6, 14, 8, 0, 15, 11,
598− 12, 24, 9, 26, 11, 16, 25, 4, 25, 21,
599− 10, 11, 12, 13, 31, 17, 23, 6, 7, 5,
600− 20, 4, 22, 3, 4, 11, 15, 8, 11, 4,
601− 14, 11, 14, 17, 15, 19, 6, 7, 25, 26,
602− 18, 5, 14, 14, 10, 24, 69, 7, 25, 6,
603− 73, 14, 26, 15, -1, -1, -1, -1, 31, -1,
604− -1, -1, 38, 31
577+ 10, 6, 13, 4, 10, 10, 11, 13, 8, 10,
578+ 10, 5, 11, 3, 19, 14, 10, 23, 0, 23,
579+ 24, 21, 9, 10, 11, 12, 18, 19, 6, 14,
580+ 13, 18, 24, 20, 13, 15, 15, 25, 17, 16,
581+ 28, 13, 9, 24, 8, 6, 22, -1, 23, -1,
582+ -1, 61, -1, -1, 64, 28, 25
605583 };
606584
607585 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
608586 symbol of state STATE-NUM. */
609587 static const yytype_uint8 yystos[] =
610588 {
611− 0, 3, 11, 28, 30, 31, 32, 46, 14, 0,
612− 16, 34, 31, 4, 29, 30, 46, 17, 35, 6,
613− 7, 33, 34, 29, 4, 36, 15, 33, 33, 37,
614− 44, 45, 46, 33, 14, 18, 37, 44, 5, 14,
615− 14, 14, 19, 35, 38, 39, 11, 14, 25, 10,
616− 11, 12, 13, 20, 22, 24, 40, 43, 10, 6,
617− 8, 11, 12, 21, 41, 42, 9, 11, 23, 25,
618− 26, 7, 33, 25, 33, 26
589+ 0, 3, 26, 13, 0, 4, 10, 27, 28, 6,
590+ 29, 28, 14, 30, 27, 29, 15, 31, 11, 14,
591+ 13, 32, 31, 31, 5, 10, 33, 39, 40, 13,
592+ 17, 31, 33, 40, 16, 33, 39, 34, 35, 13,
593+ 10, 13, 23, 9, 10, 11, 12, 18, 20, 22,
594+ 36, 38, 9, 6, 10, 11, 19, 37, 8, 10,
595+ 21, 23, 24, 29, 23, 29, 24
619596 };
620597
621598 #define yyerrok (yyerrstatus = 0)
@@ -728,7 +705,7 @@ do { \ · 106 unmodified lines
728705 { \
729706 YYFPRINTF (stderr, "%s ", Title); \
730707 yy_symbol_print (stderr, \
731− Type, Value, Location); \
708+ Type, Value); \
732709 YYFPRINTF (stderr, "\n"); \
733710 } \
734711 } while (YYID (0))
@@ -742,19 +719,17 @@ do { \ · 7 unmodified lines
742719 #if (defined __STDC__ || defined __C99__FUNC__ \
743720 || defined __cplusplus || defined _MSC_VER)
744721 static void
745−yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
722+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
746723 #else
747724 static void
748−yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
725+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
749726 FILE *yyoutput;
750727 int yytype;
751728 YYSTYPE const * const yyvaluep;
752− YYLTYPE const * const yylocationp;
753729 #endif
754730 {
755731 if (!yyvaluep)
756732 return;
757− YYUSE (yylocationp);
758733 # ifdef YYPRINT
759734 if (yytype < YYNTOKENS)
760735 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
@@ -776,14 +751,13 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) · 15 unmodified lines
776751 #if (defined __STDC__ || defined __C99__FUNC__ \
777752 || defined __cplusplus || defined _MSC_VER)
778753 static void
779−yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
754+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
780755 #else
781756 static void
782−yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
757+yy_symbol_print (yyoutput, yytype, yyvaluep)
783758 FILE *yyoutput;
784759 int yytype;
785760 YYSTYPE const * const yyvaluep;
786− YYLTYPE const * const yylocationp;
787761 #endif
788762 {
789763 if (yytype < YYNTOKENS)
@@ -791,9 +765,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) · 1 unmodified line
791765 else
792766 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
793767
794− YY_LOCATION_PRINT (yyoutput, *yylocationp);
795− YYFPRINTF (yyoutput, ": ");
796− yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
768+ yy_symbol_value_print (yyoutput, yytype, yyvaluep);
797769 YYFPRINTF (yyoutput, ")");
798770 }
799771
@@ -805,17 +777,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) · 5 unmodified lines
805777 #if (defined __STDC__ || defined __C99__FUNC__ \
806778 || defined __cplusplus || defined _MSC_VER)
807779 static void
808−yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
780+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
809781 #else
810782 static void
811−yy_stack_print (bottom, top)
812− yytype_int16 *bottom;
813− yytype_int16 *top;
783+yy_stack_print (yybottom, yytop)
784+ yytype_int16 *yybottom;
785+ yytype_int16 *yytop;
814786 #endif
815787 {
816788 YYFPRINTF (stderr, "Stack now");
817− for (; bottom <= top; ++bottom)
818− YYFPRINTF (stderr, " %d", *bottom);
789+ for (; yybottom <= yytop; yybottom++)
790+ {
791+ int yybot = *yybottom;
792+ YYFPRINTF (stderr, " %d", yybot);
793+ }
819794 YYFPRINTF (stderr, "\n");
820795 }
821796
@@ -833,12 +808,11 @@ do { \ · 11 unmodified lines
833808 #if (defined __STDC__ || defined __C99__FUNC__ \
834809 || defined __cplusplus || defined _MSC_VER)
835810 static void
836−yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
811+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
837812 #else
838813 static void
839−yy_reduce_print (yyvsp, yylsp, yyrule)
814+yy_reduce_print (yyvsp, yyrule)
840815 YYSTYPE *yyvsp;
841− YYLTYPE *yylsp;
842816 int yyrule;
843817 #endif
844818 {
@@ -850,18 +824,18 @@ yy_reduce_print (yyvsp, yylsp, yyrule) · 5 unmodified lines
850824 /* The symbols being reduced. */
851825 for (yyi = 0; yyi < yynrhs; yyi++)
852826 {
853− fprintf (stderr, " $%d = ", yyi + 1);
827+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
854828 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
855829 &(yyvsp[(yyi + 1) - (yynrhs)])
856− , &(yylsp[(yyi + 1) - (yynrhs)]) );
857− fprintf (stderr, "\n");
830+ );
831+ YYFPRINTF (stderr, "\n");
858832 }
859833 }
860834
861835 # define YY_REDUCE_PRINT(Rule) \
862836 do { \
863837 if (yydebug) \
864− yy_reduce_print (yyvsp, yylsp, Rule); \
838+ yy_reduce_print (yyvsp, Rule); \
865839 } while (YYID (0))
866840
867841 /* Nonzero means print parse trace. It is left uninitialized so that
@@ -1112,18 +1086,16 @@ yysyntax_error (char *yyresult, int yystate, int yychar) · 244 unmodified lines
11121086 #if (defined __STDC__ || defined __C99__FUNC__ \
11131087 || defined __cplusplus || defined _MSC_VER)
11141088 static void
1115−yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
1089+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
11161090 #else
11171091 static void
1118−yydestruct (yymsg, yytype, yyvaluep, yylocationp)
1092+yydestruct (yymsg, yytype, yyvaluep)
11191093 const char *yymsg;
11201094 int yytype;
11211095 YYSTYPE *yyvaluep;
1122− YYLTYPE *yylocationp;
11231096 #endif
11241097 {
11251098 YYUSE (yyvaluep);
1126− YYUSE (yylocationp);
11271099
11281100 if (!yymsg)
11291101 yymsg = "Deleting";
@@ -1136,10 +1108,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp) · 6 unmodified lines
11361108 break;
11371109 }
11381110 }
1139−
11401111
11411112 /* Prevent warnings from -Wmissing-prototypes. */
1142−
11431113 #ifdef YYPARSE_PARAM
11441114 #if defined __STDC__ || defined __cplusplus
11451115 int yyparse (void *YYPARSE_PARAM);
@@ -1155,23 +1125,20 @@ int yyparse (); · 9 unmodified lines
11551125 #endif /* ! YYPARSE_PARAM */
11561126
11571127
1158−
1159−/* The look-ahead symbol. */
1128+/* The lookahead symbol. */
11601129 int yychar;
11611130
1162−/* The semantic value of the look-ahead symbol. */
1131+/* The semantic value of the lookahead symbol. */
11631132 YYSTYPE yylval;
11641133
11651134 /* Number of syntax errors so far. */
11661135 int yynerrs;
1167−/* Location data for the look-ahead symbol. */
1168−YYLTYPE yylloc;
11691136
11701137
11711138
1172−/*----------.
1173−| yyparse. |
1174−`----------*/
1139+/*-------------------------.
1140+| yyparse or yypush_parse. |
1141+`-------------------------*/
11751142
11761143 #ifdef YYPARSE_PARAM
11771144 #if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1195,79 +1162,70 @@ yyparse () · 17 unmodified lines
11951162 #endif
11961163 #endif
11971164 {
1198−
1199− int yystate;
1200− int yyn;
1201− int yyresult;
1202− /* Number of tokens to shift before error messages enabled. */
1203− int yyerrstatus;
1204− /* Look-ahead token as an internal (translated) token number. */
1205− int yytoken = 0;
1206−#if YYERROR_VERBOSE
1207− /* Buffer for error messages, and its allocated size. */
1208− char yymsgbuf[128];
1209− char *yymsg = yymsgbuf;
1210− YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1211−#endif
12121165
1213− /* Three stacks and their tools:
1214− `yyss': related to states,
1215− `yyvs': related to semantic values,
1216− `yyls': related to locations.
12171166
1218− Refer to the stacks thru separate pointers, to allow yyoverflow
1219− to reallocate them elsewhere. */
1167+ int yystate;
1168+ /* Number of tokens to shift before error messages enabled. */
1169+ int yyerrstatus;
12201170
1221− /* The state stack. */
1222− yytype_int16 yyssa[YYINITDEPTH];
1223− yytype_int16 *yyss = yyssa;
1224− yytype_int16 *yyssp;
1171+ /* The stacks and their tools:
1172+ `yyss': related to states.
1173+ `yyvs': related to semantic values.
12251174
1226− /* The semantic value stack. */
1227− YYSTYPE yyvsa[YYINITDEPTH];
1228− YYSTYPE *yyvs = yyvsa;
1229− YYSTYPE *yyvsp;
1175+ Refer to the stacks thru separate pointers, to allow yyoverflow
1176+ to reallocate them elsewhere. */
12301177
1231− /* The location stack. */
1232− YYLTYPE yylsa[YYINITDEPTH];
1233− YYLTYPE *yyls = yylsa;
1234− YYLTYPE *yylsp;
1235− /* The locations where the error started and ended. */
1236− YYLTYPE yyerror_range[2];
1178+ /* The state stack. */
1179+ yytype_int16 yyssa[YYINITDEPTH];
1180+ yytype_int16 *yyss;
1181+ yytype_int16 *yyssp;
12371182
1238−#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1183+ /* The semantic value stack. */
1184+ YYSTYPE yyvsa[YYINITDEPTH];
1185+ YYSTYPE *yyvs;
1186+ YYSTYPE *yyvsp;
12391187
1240− YYSIZE_T yystacksize = YYINITDEPTH;
1188+ YYSIZE_T yystacksize;
12411189
1190+ int yyn;
1191+ int yyresult;
1192+ /* Lookahead token as an internal (translated) token number. */
1193+ int yytoken;
12421194 /* The variables used to return semantic value and location from the
12431195 action routines. */
12441196 YYSTYPE yyval;
1245− YYLTYPE yyloc;
1197+
1198+#if YYERROR_VERBOSE
1199+ /* Buffer for error messages, and its allocated size. */
1200+ char yymsgbuf[128];
1201+ char *yymsg = yymsgbuf;
1202+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1203+#endif
1204+
1205+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
12461206
12471207 /* The number of symbols on the RHS of the reduced rule.
12481208 Keep to zero when no symbol should be popped. */
12491209 int yylen = 0;
12501210
1211+ yytoken = 0;
1212+ yyss = yyssa;
1213+ yyvs = yyvsa;
1214+ yystacksize = YYINITDEPTH;
1215+
12511216 YYDPRINTF ((stderr, "Starting parse\n"));
12521217
12531218 yystate = 0;
12541219 yyerrstatus = 0;
12551220 yynerrs = 0;
1256− yychar = YYEMPTY; /* Cause a token to be read. */
1221+ yychar = YYEMPTY; /* Cause a token to be read. */
12571222
12581223 /* Initialize stack pointers.
12591224 Waste one element of value and location stack
12601225 so that they stay on the same level as the state stack.
12611226 The wasted elements are never initialized. */
1262−
12631227 yyssp = yyss;
12641228 yyvsp = yyvs;
1265− yylsp = yyls;
1266−#if YYLTYPE_IS_TRIVIAL
1267− /* Initialize the default location before parsing starts. */
1268− yylloc.first_line = yylloc.last_line = 1;
1269− yylloc.first_column = yylloc.last_column = 0;
1270−#endif
12711229
12721230 goto yysetstate;
12731231
@@ -1294,7 +1252,6 @@ yyparse () · 20 unmodified lines
12941252 memory. */
12951253 YYSTYPE *yyvs1 = yyvs;
12961254 yytype_int16 *yyss1 = yyss;
1297− YYLTYPE *yyls1 = yyls;
12981255
12991256 /* Each stack pointer address is followed by the size of the
13001257 data in use in that stack, in bytes. This used to be a
@@ -1303,9 +1260,8 @@ yyparse () · 2 unmodified lines
13031260 yyoverflow (YY_("memory exhausted"),
13041261 &yyss1, yysize * sizeof (*yyssp),
13051262 &yyvs1, yysize * sizeof (*yyvsp),
1306− &yyls1, yysize * sizeof (*yylsp),
13071263 &yystacksize);
1308− yyls = yyls1;
1264+
13091265 yyss = yyss1;
13101266 yyvs = yyvs1;
13111267 }
@@ -1326,9 +1282,8 @@ yyparse () · 14 unmodified lines
13261282 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
13271283 if (! yyptr)
13281284 goto yyexhaustedlab;
1329− YYSTACK_RELOCATE (yyss);
1330− YYSTACK_RELOCATE (yyvs);
1331− YYSTACK_RELOCATE (yyls);
1285+ YYSTACK_RELOCATE (yyss_alloc, yyss);
1286+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
13321287 # undef YYSTACK_RELOCATE
13331288 if (yyss1 != yyssa)
13341289 YYSTACK_FREE (yyss1);
@@ -1338,7 +1293,6 @@ yyparse () · 3 unmodified lines
13381293
13391294 yyssp = yyss + yysize - 1;
13401295 yyvsp = yyvs + yysize - 1;
1341− yylsp = yyls + yysize - 1;
13421296
13431297 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
13441298 (unsigned long int) yystacksize));
@@ -1349,6 +1303,9 @@ yyparse () · 4 unmodified lines
13491303
13501304 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
13511305
1306+ if (yystate == YYFINAL)
1307+ YYACCEPT;
1308+
13521309 goto yybackup;
13531310
13541311 /*-----------.
@@ -1357,16 +1314,16 @@ yyparse () · 2 unmodified lines
13571314 yybackup:
13581315
13591316 /* Do appropriate processing given the current state. Read a
1360− look-ahead token if we need one and don't already have one. */
1317+ lookahead token if we need one and don't already have one. */
13611318
1362− /* First try to decide what to do without reference to look-ahead token. */
1319+ /* First try to decide what to do without reference to lookahead token. */
13631320 yyn = yypact[yystate];
13641321 if (yyn == YYPACT_NINF)
13651322 goto yydefault;
13661323
1367− /* Not known => get a look-ahead token if don't already have one. */
1324+ /* Not known => get a lookahead token if don't already have one. */
13681325
1369− /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1326+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
13701327 if (yychar == YYEMPTY)
13711328 {
13721329 YYDPRINTF ((stderr, "Reading a token: "));
@@ -1398,24 +1355,20 @@ yybackup: · 25 unmodified lines
13981355 goto yyreduce;
13991356 }
14001357
1401− if (yyn == YYFINAL)
1402− YYACCEPT;
1403−
14041358 /* Count tokens shifted since error; after three, turn off error
14051359 status. */
14061360 if (yyerrstatus)
14071361 yyerrstatus--;
14081362
1409− /* Shift the look-ahead token. */
1363+ /* Shift the lookahead token. */
14101364 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
14111365
1412− /* Discard the shifted token unless it is eof. */
1413− if (yychar != YYEOF)
1414− yychar = YYEMPTY;
1366+ /* Discard the shifted token. */
1367+ yychar = YYEMPTY;
14151368
14161369 yystate = yyn;
14171370 *++yyvsp = yylval;
1418− *++yylsp = yylloc;
1371+
14191372 goto yynewstate;
14201373
14211374
@@ -1446,337 +1399,387 @@ yyreduce: · 24 unmodified lines
14461399 GCC warning that YYVAL may be used uninitialized. */
14471400 yyval = yyvsp[1-yylen];
14481401
1449− /* Default location. */
1450− YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1402+
14511403 YY_REDUCE_PRINT (yyn);
14521404 switch (yyn)
14531405 {
14541406 case 2:
1455−#line 90 "dtc-parser.y"
1407+
1408+/* Line 1455 of yacc.c */
1409+#line 87 "dtc-parser.y"
14561410 {
1457− the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), 0);
1411+ the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node),
1412+ guess_boot_cpuid((yyvsp[(4) - (4)].node)));
14581413 ;}
14591414 break;
14601415
14611416 case 3:
1462−#line 94 "dtc-parser.y"
1417+
1418+/* Line 1455 of yacc.c */
1419+#line 95 "dtc-parser.y"
14631420 {
1464− the_boot_info = build_boot_info((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].node), 0);
1421+ (yyval.re) = NULL;
14651422 ;}
14661423 break;
14671424
14681425 case 4:
1469−#line 101 "dtc-parser.y"
1426+
1427+/* Line 1455 of yacc.c */
1428+#line 99 "dtc-parser.y"
14701429 {
1471− (yyval.re) = NULL;
1430+ (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re));
14721431 ;}
14731432 break;
14741433
14751434 case 5:
1476−#line 105 "dtc-parser.y"
1435+
1436+/* Line 1455 of yacc.c */
1437+#line 106 "dtc-parser.y"
14771438 {
1478− (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re));
1439+ (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].addr), (yyvsp[(3) - (4)].addr));
14791440 ;}
14801441 break;
14811442
14821443 case 6:
1483−#line 112 "dtc-parser.y"
1444+
1445+/* Line 1455 of yacc.c */
1446+#line 110 "dtc-parser.y"
14841447 {
1485− (yyval.re) = build_reserve_entry((yyvsp[(3) - (5)].addr), (yyvsp[(4) - (5)].addr), (yyvsp[(1) - (5)].labelref));
1448+ add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref));
1449+ (yyval.re) = (yyvsp[(2) - (2)].re);
14861450 ;}
14871451 break;
14881452
14891453 case 7:
1490−#line 119 "dtc-parser.y"
1454+
1455+/* Line 1455 of yacc.c */
1456+#line 118 "dtc-parser.y"
14911457 {
1492− (yyval.re) = NULL;
1458+ (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64);
14931459 ;}
14941460 break;
14951461
14961462 case 8:
1497−#line 123 "dtc-parser.y"
1463+
1464+/* Line 1455 of yacc.c */
1465+#line 125 "dtc-parser.y"
14981466 {
1499− (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re));
1467+ (yyval.node) = name_node((yyvsp[(2) - (2)].node), "");
15001468 ;}
15011469 break;
15021470
15031471 case 9:
1504−#line 130 "dtc-parser.y"
1472+
1473+/* Line 1455 of yacc.c */
1474+#line 129 "dtc-parser.y"
15051475 {
1506− (yyval.re) = (yyvsp[(1) - (1)].re);
1476+ (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
15071477 ;}
15081478 break;
15091479
15101480 case 10:
1511−#line 134 "dtc-parser.y"
1481+
1482+/* Line 1455 of yacc.c */
1483+#line 133 "dtc-parser.y"
15121484 {
1513− (yyval.re) = build_reserve_entry((yyvsp[(3) - (6)].addr), (yyvsp[(5) - (6)].addr) - (yyvsp[(3) - (6)].addr) + 1, (yyvsp[(1) - (6)].labelref));
1485+ struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref));
1486+
1487+ if (target)
1488+ merge_nodes(target, (yyvsp[(3) - (3)].node));
1489+ else
1490+ print_error("label or path, '%s', not found", (yyvsp[(2) - (3)].labelref));
1491+ (yyval.node) = (yyvsp[(1) - (3)].node);
15141492 ;}
15151493 break;
15161494
15171495 case 11:
1518−#line 141 "dtc-parser.y"
1496+
1497+/* Line 1455 of yacc.c */
1498+#line 146 "dtc-parser.y"
15191499 {
1520− (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64);
1500+ (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist));
15211501 ;}
15221502 break;
15231503
15241504 case 12:
1525−#line 145 "dtc-parser.y"
1505+
1506+/* Line 1455 of yacc.c */
1507+#line 153 "dtc-parser.y"
15261508 {
1527− (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 16, 64);
1509+ (yyval.proplist) = NULL;
15281510 ;}
15291511 break;
15301512
15311513 case 13:
1532−#line 152 "dtc-parser.y"
1514+
1515+/* Line 1455 of yacc.c */
1516+#line 157 "dtc-parser.y"
15331517 {
1534− (yyval.node) = name_node((yyvsp[(2) - (2)].node), "", NULL);
1518+ (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist));
15351519 ;}
15361520 break;
15371521
15381522 case 14:
1539−#line 159 "dtc-parser.y"
1523+
1524+/* Line 1455 of yacc.c */
1525+#line 164 "dtc-parser.y"
15401526 {
1541− (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist));
1527+ (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data));
15421528 ;}
15431529 break;
15441530
15451531 case 15:
1546−#line 166 "dtc-parser.y"
1532+
1533+/* Line 1455 of yacc.c */
1534+#line 168 "dtc-parser.y"
15471535 {
1548− (yyval.proplist) = NULL;
1536+ (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data);
15491537 ;}
15501538 break;
15511539
15521540 case 16:
1553−#line 170 "dtc-parser.y"
1541+
1542+/* Line 1455 of yacc.c */
1543+#line 172 "dtc-parser.y"
15541544 {
1555− (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist));
1545+ add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref));
1546+ (yyval.prop) = (yyvsp[(2) - (2)].prop);
15561547 ;}
15571548 break;
15581549
15591550 case 17:
1560−#line 177 "dtc-parser.y"
1551+
1552+/* Line 1455 of yacc.c */
1553+#line 180 "dtc-parser.y"
15611554 {
1562− (yyval.prop) = build_property((yyvsp[(2) - (5)].propnodename), (yyvsp[(4) - (5)].data), (yyvsp[(1) - (5)].labelref));
1555+ (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data));
15631556 ;}
15641557 break;
15651558
15661559 case 18:
1567−#line 181 "dtc-parser.y"
1560+
1561+/* Line 1455 of yacc.c */
1562+#line 184 "dtc-parser.y"
15681563 {
1569− (yyval.prop) = build_property((yyvsp[(2) - (3)].propnodename), empty_data, (yyvsp[(1) - (3)].labelref));
1564+ (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
15701565 ;}
15711566 break;
15721567
15731568 case 19:
1569+
1570+/* Line 1455 of yacc.c */
15741571 #line 188 "dtc-parser.y"
15751572 {
1576− (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data));
1573+ (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
15771574 ;}
15781575 break;
15791576
15801577 case 20:
1578+
1579+/* Line 1455 of yacc.c */
15811580 #line 192 "dtc-parser.y"
15821581 {
1583− (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
1582+ (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref));
15841583 ;}
15851584 break;
15861585
15871586 case 21:
1588−#line 196 "dtc-parser.y"
1589− {
1590− (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
1591− ;}
1592− break;
1593−
1594− case 22:
1595−#line 200 "dtc-parser.y"
1596− {
1597− (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref));
1598− ;}
1599− break;
16001587
1601− case 23:
1602−#line 204 "dtc-parser.y"
1588+/* Line 1455 of yacc.c */
1589+#line 196 "dtc-parser.y"
16031590 {
1604− struct search_path path = { srcpos_file->dir, NULL, NULL };
1605− struct dtc_file *file = dtc_open_file((yyvsp[(4) - (9)].data).val, &path);
1606− struct data d = empty_data;
1591+ FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL);
1592+ struct data d;
16071593
16081594 if ((yyvsp[(6) - (9)].addr) != 0)
1609− if (fseek(file->file, (yyvsp[(6) - (9)].addr), SEEK_SET) != 0)
1610− yyerrorf("Couldn't seek to offset %llu in \"%s\": %s",
1611− (unsigned long long)(yyvsp[(6) - (9)].addr),
1612− (yyvsp[(4) - (9)].data).val, strerror(errno));
1595+ if (fseek(f, (yyvsp[(6) - (9)].addr), SEEK_SET) != 0)
1596+ print_error("Couldn't seek to offset %llu in \"%s\": %s",
1597+ (unsigned long long)(yyvsp[(6) - (9)].addr),
1598+ (yyvsp[(4) - (9)].data).val,
1599+ strerror(errno));
16131600
1614− d = data_copy_file(file->file, (yyvsp[(8) - (9)].addr));
1601+ d = data_copy_file(f, (yyvsp[(8) - (9)].addr));
16151602
16161603 (yyval.data) = data_merge((yyvsp[(1) - (9)].data), d);
1617− dtc_close_file(file);
1604+ fclose(f);
16181605 ;}
16191606 break;
16201607
1621− case 24:
1622−#line 221 "dtc-parser.y"
1608+ case 22:
1609+
1610+/* Line 1455 of yacc.c */
1611+#line 213 "dtc-parser.y"
16231612 {
1624− struct search_path path = { srcpos_file->dir, NULL, NULL };
1625− struct dtc_file *file = dtc_open_file((yyvsp[(4) - (5)].data).val, &path);
1613+ FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL);
16261614 struct data d = empty_data;
16271615
1628− d = data_copy_file(file->file, -1);
1616+ d = data_copy_file(f, -1);
16291617
16301618 (yyval.data) = data_merge((yyvsp[(1) - (5)].data), d);
1631− dtc_close_file(file);
1619+ fclose(f);
16321620 ;}
16331621 break;
16341622
1635− case 25:
1636−#line 232 "dtc-parser.y"
1623+ case 23:
1624+
1625+/* Line 1455 of yacc.c */
1626+#line 223 "dtc-parser.y"
16371627 {
16381628 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
16391629 ;}
16401630 break;
16411631
1642− case 26:
1643−#line 239 "dtc-parser.y"
1632+ case 24:
1633+
1634+/* Line 1455 of yacc.c */
1635+#line 230 "dtc-parser.y"
16441636 {
16451637 (yyval.data) = empty_data;
16461638 ;}
16471639 break;
16481640
1649− case 27:
1650−#line 243 "dtc-parser.y"
1641+ case 25:
1642+
1643+/* Line 1455 of yacc.c */
1644+#line 234 "dtc-parser.y"
16511645 {
16521646 (yyval.data) = (yyvsp[(1) - (2)].data);
16531647 ;}
16541648 break;
16551649
1656− case 28:
1657−#line 247 "dtc-parser.y"
1650+ case 26:
1651+
1652+/* Line 1455 of yacc.c */
1653+#line 238 "dtc-parser.y"
16581654 {
16591655 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
16601656 ;}
16611657 break;
16621658
1663− case 29:
1664−#line 254 "dtc-parser.y"
1659+ case 27:
1660+
1661+/* Line 1455 of yacc.c */
1662+#line 245 "dtc-parser.y"
16651663 {
16661664 (yyval.data) = empty_data;
16671665 ;}
16681666 break;
16691667
1670− case 30:
1671−#line 258 "dtc-parser.y"
1668+ case 28:
1669+
1670+/* Line 1455 of yacc.c */
1671+#line 249 "dtc-parser.y"
16721672 {
16731673 (yyval.data) = data_append_cell((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].cell));
16741674 ;}
16751675 break;
16761676
1677− case 31:
1678−#line 262 "dtc-parser.y"
1677+ case 29:
1678+
1679+/* Line 1455 of yacc.c */
1680+#line 253 "dtc-parser.y"
16791681 {
16801682 (yyval.data) = data_append_cell(data_add_marker((yyvsp[(1) - (2)].data), REF_PHANDLE,
16811683 (yyvsp[(2) - (2)].labelref)), -1);
16821684 ;}
16831685 break;
16841686
1685− case 32:
1686−#line 267 "dtc-parser.y"
1687+ case 30:
1688+
1689+/* Line 1455 of yacc.c */
1690+#line 258 "dtc-parser.y"
16871691 {
16881692 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
16891693 ;}
16901694 break;
16911695
1692− case 33:
1693−#line 274 "dtc-parser.y"
1694− {
1695− (yyval.cbase) = 16;
1696− ;}
1697− break;
1696+ case 31:
16981697
1699− case 35:
1700−#line 282 "dtc-parser.y"
1698+/* Line 1455 of yacc.c */
1699+#line 265 "dtc-parser.y"
17011700 {
17021701 (yyval.cell) = eval_literal((yyvsp[(1) - (1)].literal), 0, 32);
17031702 ;}
17041703 break;
17051704
1706− case 36:
1707−#line 286 "dtc-parser.y"
1708− {
1709− (yyval.cell) = eval_literal((yyvsp[(2) - (2)].literal), (yyvsp[(1) - (2)].cbase), 32);
1710− ;}
1711− break;
1705+ case 32:
17121706
1713− case 37:
1714−#line 293 "dtc-parser.y"
1707+/* Line 1455 of yacc.c */
1708+#line 272 "dtc-parser.y"
17151709 {
17161710 (yyval.data) = empty_data;
17171711 ;}
17181712 break;
17191713
1720− case 38:
1721−#line 297 "dtc-parser.y"
1714+ case 33:
1715+
1716+/* Line 1455 of yacc.c */
1717+#line 276 "dtc-parser.y"
17221718 {
17231719 (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte));
17241720 ;}
17251721 break;
17261722
1727− case 39:
1728−#line 301 "dtc-parser.y"
1723+ case 34:
1724+
1725+/* Line 1455 of yacc.c */
1726+#line 280 "dtc-parser.y"
17291727 {
17301728 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
17311729 ;}
17321730 break;
17331731
1734− case 40:
1735−#line 308 "dtc-parser.y"
1732+ case 35:
1733+
1734+/* Line 1455 of yacc.c */
1735+#line 287 "dtc-parser.y"
17361736 {
17371737 (yyval.nodelist) = NULL;
17381738 ;}
17391739 break;
17401740
1741− case 41:
1742−#line 312 "dtc-parser.y"
1741+ case 36:
1742+
1743+/* Line 1455 of yacc.c */
1744+#line 291 "dtc-parser.y"
17431745 {
17441746 (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist));
17451747 ;}
17461748 break;
17471749
1748− case 42:
1749−#line 316 "dtc-parser.y"
1750+ case 37:
1751+
1752+/* Line 1455 of yacc.c */
1753+#line 295 "dtc-parser.y"
17501754 {
1751− yyerror("syntax error: properties must precede subnodes");
1755+ print_error("syntax error: properties must precede subnodes");
17521756 YYERROR;
17531757 ;}
17541758 break;
17551759
1756− case 43:
1757−#line 324 "dtc-parser.y"
1758− {
1759− (yyval.node) = name_node((yyvsp[(3) - (3)].node), (yyvsp[(2) - (3)].propnodename), (yyvsp[(1) - (3)].labelref));
1760− ;}
1761− break;
1760+ case 38:
17621761
1763− case 44:
1764−#line 331 "dtc-parser.y"
1762+/* Line 1455 of yacc.c */
1763+#line 303 "dtc-parser.y"
17651764 {
1766− (yyval.labelref) = NULL;
1765+ (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename));
17671766 ;}
17681767 break;
17691768
1770− case 45:
1771−#line 335 "dtc-parser.y"
1769+ case 39:
1770+
1771+/* Line 1455 of yacc.c */
1772+#line 307 "dtc-parser.y"
17721773 {
1773− (yyval.labelref) = (yyvsp[(1) - (1)].labelref);
1774+ add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref));
1775+ (yyval.node) = (yyvsp[(2) - (2)].node);
17741776 ;}
17751777 break;
17761778
17771779
1778−/* Line 1267 of yacc.c. */
1779−#line 1780 "dtc-parser.tab.c"
1780+
1781+/* Line 1455 of yacc.c */
1782+#line 1783 "dtc-parser.tab.c"
17801783 default: break;
17811784 }
17821785 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1786,7 +1789,6 @@ yyreduce: · 3 unmodified lines
17861789 YY_STACK_PRINT (yyss, yyssp);
17871790
17881791 *++yyvsp = yyval;
1789− *++yylsp = yyloc;
17901792
17911793 /* Now `shift' the result of the reduction. Determine what state
17921794 that goes to, based on the state we popped back to and the rule
@@ -1848,11 +1850,11 @@ yyerrlab: · 55 unmodified lines
18481850 #endif
18491851 }
18501852
1851− yyerror_range[0] = yylloc;
1853+
18521854
18531855 if (yyerrstatus == 3)
18541856 {
1855− /* If just tried and failed to reuse look-ahead token after an
1857+ /* If just tried and failed to reuse lookahead token after an
18561858 error, discard it. */
18571859
18581860 if (yychar <= YYEOF)
@@ -1864,12 +1866,12 @@ yyerrlab: · 5 unmodified lines
18641866 else
18651867 {
18661868 yydestruct ("Error: discarding",
1867− yytoken, &yylval, &yylloc);
1869+ yytoken, &yylval);
18681870 yychar = YYEMPTY;
18691871 }
18701872 }
18711873
1872− /* Else will try to reuse look-ahead token after shifting the error
1874+ /* Else will try to reuse lookahead token after shifting the error
18731875 token. */
18741876 goto yyerrlab1;
18751877
@@ -1885,7 +1887,6 @@ yyerrorlab: · 9 unmodified lines
18851887 if (/*CONSTCOND*/ 0)
18861888 goto yyerrorlab;
18871889
1888− yyerror_range[0] = yylsp[1-yylen];
18891890 /* Do not reclaim the symbols of the rule which action triggered
18901891 this YYERROR. */
18911892 YYPOPSTACK (yylen);
@@ -1919,24 +1920,16 @@ yyerrlab1: · 27 unmodified lines
19191920 if (yyssp == yyss)
19201921 YYABORT;
19211922
1922− yyerror_range[0] = *yylsp;
1923+
19231924 yydestruct ("Error: popping",
1924− yystos[yystate], yyvsp, yylsp);
1925+ yystos[yystate], yyvsp);
19251926 YYPOPSTACK (1);
19261927 yystate = *yyssp;
19271928 YY_STACK_PRINT (yyss, yyssp);
19281929 }
19291930
1930− if (yyn == YYFINAL)
1931− YYACCEPT;
1932−
19331931 *++yyvsp = yylval;
19341932
1935− yyerror_range[1] = yylloc;
1936− /* Using YYLLOC is tempting, but would change the location of
1937− the look-ahead. YYLOC is available though. */
1938− YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
1939− *++yylsp = yyloc;
19401933
19411934 /* Shift the error token. */
19421935 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
@@ -1959,7 +1952,7 @@ yyabortlab: · 16 unmodified lines
19591952 yyresult = 1;
19601953 goto yyreturn;
19611954
1962−#ifndef yyoverflow
1955+#if !defined(yyoverflow) || YYERROR_VERBOSE
19631956 /*-------------------------------------------------.
19641957 | yyexhaustedlab -- memory exhaustion comes here. |
19651958 `-------------------------------------------------*/
@@ -1970,9 +1963,9 @@ yyexhaustedlab: · 4 unmodified lines
19701963 #endif
19711964
19721965 yyreturn:
1973− if (yychar != YYEOF && yychar != YYEMPTY)
1966+ if (yychar != YYEMPTY)
19741967 yydestruct ("Cleanup: discarding lookahead",
1975− yytoken, &yylval, &yylloc);
1968+ yytoken, &yylval);
19761969 /* Do not reclaim the symbols of the rule which action triggered
19771970 this YYABORT or YYACCEPT. */
19781971 YYPOPSTACK (yylen);
@@ -1980,7 +1973,7 @@ yyreturn: · 1 unmodified line
19801973 while (yyssp != yyss)
19811974 {
19821975 yydestruct ("Cleanup: popping",
1983− yystos[*yyssp], yyvsp, yylsp);
1976+ yystos[*yyssp], yyvsp);
19841977 YYPOPSTACK (1);
19851978 }
19861979 #ifndef yyoverflow
@@ -1996,29 +1989,24 @@ yyreturn: · 9 unmodified lines
19961989 }
19971990
19981991
1999−#line 340 "dtc-parser.y"
1992+
1993+/* Line 1675 of yacc.c */
1994+#line 313 "dtc-parser.y"
20001995
20011996
2002−void yyerrorf(char const *s, ...)
1997+void print_error(char const *fmt, ...)
20031998 {
2004− const char *fname = srcpos_file ? srcpos_file->name : "<no-file>";
20051999 va_list va;
2006− va_start(va, s);
2007−
2008− if (strcmp(fname, "-") == 0)
2009− fname = "stdin";
20102000
2011− fprintf(stderr, "%s:%d ", fname, yylloc.first_line);
2012− vfprintf(stderr, s, va);
2013− fprintf(stderr, "\n");
2001+ va_start(va, fmt);
2002+ srcpos_verror(&yylloc, fmt, va);
2003+ va_end(va);
20142004
20152005 treesource_error = 1;
2016− va_end(va);
20172006 }
20182007
2019−void yyerror (char const *s)
2020−{
2021− yyerrorf("%s", s);
2008+void yyerror(char const *s) {
2009+ print_error("%s", s);
20222010 }
20232011
20242012 static unsigned long long eval_literal(const char *s, int base, int bits)
@@ -2029,12 +2017,12 @@ static unsigned long long eval_literal(const char *s, int base, int bits) · 4 unmodified lines
20292017 errno = 0;
20302018 val = strtoull(s, &e, base);
20312019 if (*e)
2032− yyerror("bad characters in literal");
2020+ print_error("bad characters in literal");
20332021 else if ((errno == ERANGE)
20342022 || ((bits < 64) && (val >= (1ULL << bits))))
2035− yyerror("literal out of range");
2023+ print_error("literal out of range");
20362024 else if (errno != 0)
2037− yyerror("bad literal");
2025+ print_error("bad literal");
20382026 return val;
20392027 }
20402028
scripts/dtc/dtc-parser.tab.h_shipped+30−52
@@ -1,24 +1,23 @@
1−/* A Bison parser, made by GNU Bison 2.3. */
21
3−/* Skeleton interface for Bison's Yacc-like parsers in C
2+/* A Bison parser, made by GNU Bison 2.4.1. */
43
5− Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
4+/* Skeleton interface for Bison's Yacc-like parsers in C
5+
6+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
67 Free Software Foundation, Inc.
7−
8− This program is free software; you can redistribute it and/or modify
8+
9+ This program is free software: you can redistribute it and/or modify
910 it under the terms of the GNU General Public License as published by
10− the Free Software Foundation; either version 2, or (at your option)
11− any later version.
12−
11+ the Free Software Foundation, either version 3 of the License, or
12+ (at your option) any later version.
13+
1314 This program is distributed in the hope that it will be useful,
1415 but WITHOUT ANY WARRANTY; without even the implied warranty of
1516 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1617 GNU General Public License for more details.
17−
18+
1819 You should have received a copy of the GNU General Public License
19− along with this program; if not, write to the Free Software
20− Foundation, Inc., 51 Franklin Street, Fifth Floor,
21− Boston, MA 02110-1301, USA. */
20+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2221
2322 /* As a special exception, you may create a larger work that contains
2423 part or all of the Bison parser skeleton and distribute that work
@@ -29,10 +28,11 @@ · 4 unmodified lines
2928 special exception, which will cause the skeleton and the resulting
3029 Bison output files to be licensed under the GNU General Public
3130 License without this special exception.
32−
31+
3332 This special exception was added by the Free Software Foundation in
3433 version 2.2 of Bison. */
3534
35+
3636 /* Tokens. */
3737 #ifndef YYTOKENTYPE
3838 # define YYTOKENTYPE
@@ -43,35 +43,24 @@ · 4 unmodified lines
4343 DT_MEMRESERVE = 259,
4444 DT_PROPNODENAME = 260,
4545 DT_LITERAL = 261,
46− DT_LEGACYLITERAL = 262,
47− DT_BASE = 263,
48− DT_BYTE = 264,
49− DT_STRING = 265,
50− DT_LABEL = 266,
51− DT_REF = 267,
52− DT_INCBIN = 268
46+ DT_BASE = 262,
47+ DT_BYTE = 263,
48+ DT_STRING = 264,
49+ DT_LABEL = 265,
50+ DT_REF = 266,
51+ DT_INCBIN = 267
5352 };
5453 #endif
55−/* Tokens. */
56−#define DT_V1 258
57−#define DT_MEMRESERVE 259
58−#define DT_PROPNODENAME 260
59−#define DT_LITERAL 261
60−#define DT_LEGACYLITERAL 262
61−#define DT_BASE 263
62−#define DT_BYTE 264
63−#define DT_STRING 265
64−#define DT_LABEL 266
65−#define DT_REF 267
66−#define DT_INCBIN 268
67−
6854
6955
7056
7157 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
7258 typedef union YYSTYPE
73−#line 37 "dtc-parser.y"
7459 {
60+
61+/* Line 1676 of yacc.c */
62+#line 39 "dtc-parser.y"
63+
7564 char *propnodename;
7665 char *literal;
7766 char *labelref;
@@ -86,28 +75,17 @@ typedef union YYSTYPE · 8 unmodified lines
8675 struct node *node;
8776 struct node *nodelist;
8877 struct reserve_info *re;
89−}
90−/* Line 1489 of yacc.c. */
91−#line 92 "dtc-parser.tab.h"
92− YYSTYPE;
78+
79+
80+
81+/* Line 1676 of yacc.c */
82+#line 83 "dtc-parser.tab.h"
83+} YYSTYPE;
84+# define YYSTYPE_IS_TRIVIAL 1
9385 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
9486 # define YYSTYPE_IS_DECLARED 1
95−# define YYSTYPE_IS_TRIVIAL 1
9687 #endif
9788
9889 extern YYSTYPE yylval;
9990
100−#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
101−typedef struct YYLTYPE
102−{
103− int first_line;
104− int first_column;
105− int last_line;
106− int last_column;
107−} YYLTYPE;
108−# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
109−# define YYLTYPE_IS_DECLARED 1
110−# define YYLTYPE_IS_TRIVIAL 1
111−#endif
11291
113−extern YYLTYPE yylloc;
scripts/dtc/dtc-parser.y+63−97
@@ -18,15 +18,17 @@ · 17 unmodified lines
1818 * USA
1919 */
2020
21−%locations
22−
2321 %{
2422 #include <stdio.h>
2523
2624 #include "dtc.h"
2725 #include "srcpos.h"
2826
27+YYLTYPE yylloc;
28+
2929 extern int yylex(void);
30+extern void print_error(char const *fmt, ...);
31+extern void yyerror(char const *s);
3032
3133 extern struct boot_info *the_boot_info;
3234 extern int treesource_error;
@@ -55,7 +57,6 @@ static unsigned long long eval_literal(const char *s, int base, int bits); · 22 unmodified lines
5557 %token DT_MEMRESERVE
5658 %token <propnodename> DT_PROPNODENAME
5759 %token <literal> DT_LITERAL
58−%token <literal> DT_LEGACYLITERAL
5960 %token <cbase> DT_BASE
6061 %token <byte> DT_BYTE
6162 %token <data> DT_STRING
@@ -67,11 +68,8 @@ static unsigned long long eval_literal(const char *s, int base, int bits); · 5 unmodified lines
6768 %type <data> propdataprefix
6869 %type <re> memreserve
6970 %type <re> memreserves
70−%type <re> v0_memreserve
71−%type <re> v0_memreserves
7271 %type <addr> addr
7372 %type <data> celllist
74−%type <cbase> cellbase
7573 %type <cell> cellval
7674 %type <data> bytestring
7775 %type <prop> propdef
@@ -81,18 +79,14 @@ static unsigned long long eval_literal(const char *s, int base, int bits); · 3 unmodified lines
8179 %type <node> nodedef
8280 %type <node> subnode
8381 %type <nodelist> subnodes
84−%type <labelref> label
8582
8683 %%
8784
8885 sourcefile:
8986 DT_V1 ';' memreserves devicetree
9087 {
91− the_boot_info = build_boot_info($3, $4, 0);
92− }
93− | v0_memreserves devicetree
94− {
95− the_boot_info = build_boot_info($1, $2, 0);
88+ the_boot_info = build_boot_info($3, $4,
89+ guess_boot_cpuid($4));
9690 }
9791 ;
9892
@@ -108,31 +102,14 @@ memreserves: · 9 unmodified lines
108102 ;
109103
110104 memreserve:
111− label DT_MEMRESERVE addr addr ';'
105+ DT_MEMRESERVE addr addr ';'
112106 {
113− $$ = build_reserve_entry($3, $4, $1);
107+ $$ = build_reserve_entry($2, $3);
114108 }
115− ;
116−
117−v0_memreserves:
118− /* empty */
109+ | DT_LABEL memreserve
119110 {
120− $$ = NULL;
121− }
122− | v0_memreserve v0_memreserves
123− {
124− $$ = chain_reserve_entry($1, $2);
125− };
126− ;
127−
128−v0_memreserve:
129− memreserve
130− {
131− $$ = $1;
132− }
133− | label DT_MEMRESERVE addr '-' addr ';'
134− {
135− $$ = build_reserve_entry($3, $5 - $3 + 1, $1);
111+ add_label(&$2->labels, $1);
112+ $$ = $2;
136113 }
137114 ;
138115
@@ -141,16 +118,26 @@ addr: · 2 unmodified lines
141118 {
142119 $$ = eval_literal($1, 0, 64);
143120 }
144− | DT_LEGACYLITERAL
145− {
146− $$ = eval_literal($1, 16, 64);
147− }
148121 ;
149122
150123 devicetree:
151124 '/' nodedef
152125 {
153− $$ = name_node($2, "", NULL);
126+ $$ = name_node($2, "");
127+ }
128+ | devicetree '/' nodedef
129+ {
130+ $$ = merge_nodes($1, $3);
131+ }
132+ | devicetree DT_REF nodedef
133+ {
134+ struct node *target = get_node_by_ref($1, $2);
135+
136+ if (target)
137+ merge_nodes(target, $3);
138+ else
139+ print_error("label or path, '%s', not found", $2);
140+ $$ = $1;
154141 }
155142 ;
156143
@@ -173,13 +160,18 @@ proplist: · 16 unmodified lines
173160 ;
174161
175162 propdef:
176− label DT_PROPNODENAME '=' propdata ';'
163+ DT_PROPNODENAME '=' propdata ';'
164+ {
165+ $$ = build_property($1, $3);
166+ }
167+ | DT_PROPNODENAME ';'
177168 {
178− $$ = build_property($2, $4, $1);
169+ $$ = build_property($1, empty_data);
179170 }
180− | label DT_PROPNODENAME ';'
171+ | DT_LABEL propdef
181172 {
182− $$ = build_property($2, empty_data, $1);
173+ add_label(&$2->labels, $1);
174+ $$ = $2;
183175 }
184176 ;
185177
@@ -202,31 +194,30 @@ propdata: · 16 unmodified lines
202194 }
203195 | propdataprefix DT_INCBIN '(' DT_STRING ',' addr ',' addr ')'
204196 {
205− struct search_path path = { srcpos_file->dir, NULL, NULL };
206− struct dtc_file *file = dtc_open_file($4.val, &path);
207− struct data d = empty_data;
197+ FILE *f = srcfile_relative_open($4.val, NULL);
198+ struct data d;
208199
209200 if ($6 != 0)
210− if (fseek(file->file, $6, SEEK_SET) != 0)
211− yyerrorf("Couldn't seek to offset %llu in \"%s\": %s",
212− (unsigned long long)$6,
213− $4.val, strerror(errno));
201+ if (fseek(f, $6, SEEK_SET) != 0)
202+ print_error("Couldn't seek to offset %llu in \"%s\": %s",
203+ (unsigned long long)$6,
204+ $4.val,
205+ strerror(errno));
214206
215− d = data_copy_file(file->file, $8);
207+ d = data_copy_file(f, $8);
216208
217209 $$ = data_merge($1, d);
218− dtc_close_file(file);
210+ fclose(f);
219211 }
220212 | propdataprefix DT_INCBIN '(' DT_STRING ')'
221213 {
222− struct search_path path = { srcpos_file->dir, NULL, NULL };
223− struct dtc_file *file = dtc_open_file($4.val, &path);
214+ FILE *f = srcfile_relative_open($4.val, NULL);
224215 struct data d = empty_data;
225216
226− d = data_copy_file(file->file, -1);
217+ d = data_copy_file(f, -1);
227218
228219 $$ = data_merge($1, d);
229− dtc_close_file(file);
220+ fclose(f);
230221 }
231222 | propdata DT_LABEL
232223 {
@@ -269,23 +260,11 @@ celllist: · 36 unmodified lines
269260 }
270261 ;
271262
272−cellbase:
273− /* empty */
274− {
275− $$ = 16;
276− }
277− | DT_BASE
278− ;
279−
280263 cellval:
281264 DT_LITERAL
282265 {
283266 $$ = eval_literal($1, 0, 32);
284267 }
285− | cellbase DT_LEGACYLITERAL
286− {
287− $$ = eval_literal($2, $1, 32);
288− }
289268 ;
290269
291270 bytestring:
@@ -308,57 +287,44 @@ subnodes: · 16 unmodified lines
308287 {
309288 $$ = NULL;
310289 }
311− | subnode subnodes
290+ | subnode subnodes
312291 {
313292 $$ = chain_node($1, $2);
314293 }
315294 | subnode propdef
316295 {
317− yyerror("syntax error: properties must precede subnodes");
296+ print_error("syntax error: properties must precede subnodes");
318297 YYERROR;
319298 }
320299 ;
321300
322301 subnode:
323− label DT_PROPNODENAME nodedef
302+ DT_PROPNODENAME nodedef
324303 {
325− $$ = name_node($3, $2, $1);
304+ $$ = name_node($2, $1);
326305 }
327− ;
328−
329−label:
330− /* empty */
306+ | DT_LABEL subnode
331307 {
332− $$ = NULL;
333− }
334− | DT_LABEL
335− {
336− $$ = $1;
308+ add_label(&$2->labels, $1);
309+ $$ = $2;
337310 }
338311 ;
339312
340313 %%
341314
342−void yyerrorf(char const *s, ...)
315+void print_error(char const *fmt, ...)
343316 {
344− const char *fname = srcpos_file ? srcpos_file->name : "<no-file>";
345317 va_list va;
346− va_start(va, s);
347−
348− if (strcmp(fname, "-") == 0)
349− fname = "stdin";
350318
351− fprintf(stderr, "%s:%d ", fname, yylloc.first_line);
352− vfprintf(stderr, s, va);
353− fprintf(stderr, "\n");
319+ va_start(va, fmt);
320+ srcpos_verror(&yylloc, fmt, va);
321+ va_end(va);
354322
355323 treesource_error = 1;
356− va_end(va);
357324 }
358325
359−void yyerror (char const *s)
360−{
361− yyerrorf("%s", s);
326+void yyerror(char const *s) {
327+ print_error("%s", s);
362328 }
363329
364330 static unsigned long long eval_literal(const char *s, int base, int bits)
@@ -369,11 +335,11 @@ static unsigned long long eval_literal(const char *s, int base, int bits) · 4 unmodified lines
369335 errno = 0;
370336 val = strtoull(s, &e, base);
371337 if (*e)
372− yyerror("bad characters in literal");
338+ print_error("bad characters in literal");
373339 else if ((errno == ERANGE)
374340 || ((bits < 64) && (val >= (1ULL << bits))))
375− yyerror("literal out of range");
341+ print_error("literal out of range");
376342 else if (errno != 0)
377− yyerror("bad literal");
343+ print_error("bad literal");
378344 return val;
379345 }
scripts/dtc/dtc.c+31−26
@@ -30,30 +30,7 @@ int quiet; /* Level of quietness */ · 29 unmodified lines
3030 int reservenum; /* Number of memory reservation slots */
3131 int minsize; /* Minimum blob size */
3232 int padsize; /* Additional padding to blob */
33−
34−char *join_path(const char *path, const char *name)
35−{
36− int lenp = strlen(path);
37− int lenn = strlen(name);
38− int len;
39− int needslash = 1;
40− char *str;
41−
42− len = lenp + lenn + 2;
43− if ((lenp > 0) && (path[lenp-1] == '/')) {
44− needslash = 0;
45− len--;
46− }
47−
48− str = xmalloc(len);
49− memcpy(str, path, lenp);
50− if (needslash) {
51− str[lenp] = '/';
52− lenp++;
53− }
54− memcpy(str+lenp, name, lenn+1);
55− return str;
56−}
33+int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */
5734
5835 static void fill_fullpaths(struct node *tree, const char *prefix)
5936 {
@@ -104,8 +81,15 @@ static void __attribute__ ((noreturn)) usage(void) · 44 unmodified lines
10481 fprintf(stderr, "\t\tSet the physical boot cpu\n");
10582 fprintf(stderr, "\t-f\n");
10683 fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n");
84+ fprintf(stderr, "\t-s\n");
85+ fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n");
10786 fprintf(stderr, "\t-v\n");
10887 fprintf(stderr, "\t\tPrint DTC version and exit\n");
88+ fprintf(stderr, "\t-H <phandle format>\n");
89+ fprintf(stderr, "\t\tphandle formats are:\n");
90+ fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n");
91+ fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n");
92+ fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n");
10993 exit(3);
11094 }
11195
@@ -115,7 +99,7 @@ int main(int argc, char *argv[]) · 3 unmodified lines
11599 const char *inform = "dts";
116100 const char *outform = "dts";
117101 const char *outname = "-";
118− int force = 0, check = 0;
102+ int force = 0, check = 0, sort = 0;
119103 const char *arg;
120104 int opt;
121105 FILE *outf = NULL;
@@ -127,7 +111,7 @@ int main(int argc, char *argv[]) · 5 unmodified lines
127111 minsize = 0;
128112 padsize = 0;
129113
130− while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:v")) != EOF) {
114+ while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:s")) != EOF) {
131115 switch (opt) {
132116 case 'I':
133117 inform = optarg;
@@ -165,6 +149,22 @@ int main(int argc, char *argv[]) · 31 unmodified lines
165149 case 'v':
166150 printf("Version: %s\n", DTC_VERSION);
167151 exit(0);
152+ case 'H':
153+ if (streq(optarg, "legacy"))
154+ phandle_format = PHANDLE_LEGACY;
155+ else if (streq(optarg, "epapr"))
156+ phandle_format = PHANDLE_EPAPR;
157+ else if (streq(optarg, "both"))
158+ phandle_format = PHANDLE_BOTH;
159+ else
160+ die("Invalid argument \"%s\" to -H option\n",
161+ optarg);
162+ break;
163+
164+ case 's':
165+ sort = 1;
166+ break;
167+
168168 case 'h':
169169 default:
170170 usage();
@@ -182,6 +182,9 @@ int main(int argc, char *argv[]) · 11 unmodified lines
182182 if (minsize && padsize)
183183 die("Can't set both -p and -S\n");
184184
185+ if (minsize)
186+ fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n");
187+
185188 fprintf(stderr, "DTC: %s->%s on file \"%s\"\n",
186189 inform, outform, arg);
187190
@@ -200,6 +203,8 @@ int main(int argc, char *argv[]) · 12 unmodified lines
200203 fill_fullpaths(bi->dt, "");
201204 process_checks(force, bi);
202205
206+ if (sort)
207+ sort_tree(bi);
203208
204209 if (streq(outname, "-")) {
205210 outf = stdout;
scripts/dtc/dtc.h+38−39
@@ -34,7 +34,17 @@ · 33 unmodified lines
3434 #include <libfdt_env.h>
3535 #include <fdt.h>
3636
37+#include "util.h"
38+
39+#ifdef DEBUG
40+#define debug(fmt,args...) printf(fmt, ##args)
41+#else
42+#define debug(fmt,args...)
43+#endif
44+
45+
3746 #define DEFAULT_FDT_VERSION 17
47+
3848 /*
3949 * Command line options
4050 */
@@ -42,36 +52,11 @@ extern int quiet; /* Level of quietness */ · 1 unmodified line
4252 extern int reservenum; /* Number of memory reservation slots */
4353 extern int minsize; /* Minimum blob size */
4454 extern int padsize; /* Additional padding to blob */
55+extern int phandle_format; /* Use linux,phandle or phandle properties */
4556
46−static inline void __attribute__((noreturn)) die(char * str, ...)
47−{
48− va_list ap;
49−
50− va_start(ap, str);
51− fprintf(stderr, "FATAL ERROR: ");
52− vfprintf(stderr, str, ap);
53− exit(1);
54−}
55−
56−static inline void *xmalloc(size_t len)
57−{
58− void *new = malloc(len);
59−
60− if (! new)
61− die("malloc() failed\n");
62−
63− return new;
64−}
65−
66−static inline void *xrealloc(void *p, size_t len)
67−{
68− void *new = realloc(p, len);
69−
70− if (! new)
71− die("realloc() failed (len=%d)\n", len);
72−
73− return new;
74−}
57+#define PHANDLE_LEGACY 0x1
58+#define PHANDLE_EPAPR 0x2
59+#define PHANDLE_BOTH 0x3
7560
7661 typedef uint32_t cell_t;
7762
@@ -140,13 +125,18 @@ int data_is_one_string(struct data d); · 62 unmodified lines
140125 #define MAX_NODENAME_LEN 31
141126
142127 /* Live trees */
128+struct label {
129+ char *label;
130+ struct label *next;
131+};
132+
143133 struct property {
144134 char *name;
145135 struct data val;
146136
147137 struct property *next;
148138
149− char *label;
139+ struct label *labels;
150140 };
151141
152142 struct node {
@@ -163,22 +153,28 @@ struct node { · 10 unmodified lines
163153 cell_t phandle;
164154 int addr_cells, size_cells;
165155
166− char *label;
156+ struct label *labels;
167157 };
168158
159+#define for_each_label(l0, l) \
160+ for ((l) = (l0); (l); (l) = (l)->next)
161+
169162 #define for_each_property(n, p) \
170163 for ((p) = (n)->proplist; (p); (p) = (p)->next)
171164
172165 #define for_each_child(n, c) \
173166 for ((c) = (n)->children; (c); (c) = (c)->next_sibling)
174167
175−struct property *build_property(char *name, struct data val, char *label);
168+void add_label(struct label **labels, char *label);
169+
170+struct property *build_property(char *name, struct data val);
176171 struct property *chain_property(struct property *first, struct property *list);
177172 struct property *reverse_properties(struct property *first);
178173
179174 struct node *build_node(struct property *proplist, struct node *children);
180−struct node *name_node(struct node *node, char *name, char *label);
175+struct node *name_node(struct node *node, char *name);
181176 struct node *chain_node(struct node *first, struct node *list);
177+struct node *merge_nodes(struct node *old_node, struct node *new_node);
182178
183179 void add_property(struct node *node, struct property *prop);
184180 void add_child(struct node *parent, struct node *child);
@@ -186,6 +182,10 @@ void add_child(struct node *parent, struct node *child); · 1 unmodified line
186182 const char *get_unitname(struct node *node);
187183 struct property *get_property(struct node *node, const char *propname);
188184 cell_t propval_cell(struct property *prop);
185+struct property *get_property_by_label(struct node *tree, const char *label,
186+ struct node **node);
187+struct marker *get_marker_label(struct node *tree, const char *label,
188+ struct node **node, struct property **prop);
189189 struct node *get_subnode(struct node *node, const char *nodename);
190190 struct node *get_node_by_path(struct node *tree, const char *path);
191191 struct node *get_node_by_label(struct node *tree, const char *label);
@@ -193,6 +193,8 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle); · 1 unmodified line
193193 struct node *get_node_by_ref(struct node *tree, const char *ref);
194194 cell_t get_node_phandle(struct node *root, struct node *node);
195195
196+uint32_t guess_boot_cpuid(struct node *tree);
197+
196198 /* Boot info (tree plus memreserve information */
197199
198200 struct reserve_info {
@@ -200,10 +202,10 @@ struct reserve_info { · 1 unmodified line
200202
201203 struct reserve_info *next;
202204
203− char *label;
205+ struct label *labels;
204206 };
205207
206−struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len, char *label);
208+struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len);
207209 struct reserve_info *chain_reserve_entry(struct reserve_info *first,
208210 struct reserve_info *list);
209211 struct reserve_info *add_reserve_entry(struct reserve_info *list,
@@ -218,6 +220,7 @@ struct boot_info { · 8 unmodified lines
218220
219221 struct boot_info *build_boot_info(struct reserve_info *reservelist,
220222 struct node *tree, uint32_t boot_cpuid_phys);
223+void sort_tree(struct boot_info *bi);
221224
222225 /* Checks */
223226
@@ -239,8 +242,4 @@ struct boot_info *dt_from_source(const char *f); · 15 unmodified lines
239242
240243 struct boot_info *dt_from_fs(const char *dirname);
241244
242−/* misc */
243−
244−char *join_path(const char *path, const char *name);
245−
246245 #endif /* _DTC_H */
scripts/dtc/flattree.c+109−83
@@ -52,9 +52,9 @@ struct emitter { · 51 unmodified lines
5252 void (*string)(void *, char *, int);
5353 void (*align)(void *, int);
5454 void (*data)(void *, struct data);
55− void (*beginnode)(void *, const char *);
56− void (*endnode)(void *, const char *);
57− void (*property)(void *, const char *);
55+ void (*beginnode)(void *, struct label *labels);
56+ void (*endnode)(void *, struct label *labels);
57+ void (*property)(void *, struct label *labels);
5858 };
5959
6060 static void bin_emit_cell(void *e, cell_t val)
@@ -89,17 +89,17 @@ static void bin_emit_data(void *e, struct data d) · 28 unmodified lines
8989 *dtbuf = data_append_data(*dtbuf, d.val, d.len);
9090 }
9191
92−static void bin_emit_beginnode(void *e, const char *label)
92+static void bin_emit_beginnode(void *e, struct label *labels)
9393 {
9494 bin_emit_cell(e, FDT_BEGIN_NODE);
9595 }
9696
97−static void bin_emit_endnode(void *e, const char *label)
97+static void bin_emit_endnode(void *e, struct label *labels)
9898 {
9999 bin_emit_cell(e, FDT_END_NODE);
100100 }
101101
102−static void bin_emit_property(void *e, const char *label)
102+static void bin_emit_property(void *e, struct label *labels)
103103 {
104104 bin_emit_cell(e, FDT_PROP);
105105 }
@@ -127,11 +127,21 @@ static void emit_offset_label(FILE *f, const char *label, int offset) · 21 unmodified lines
127127 fprintf(f, "%s\t= . + %d\n", label, offset);
128128 }
129129
130+#define ASM_EMIT_BELONG(f, fmt, ...) \
131+ { \
132+ fprintf((f), "\t.byte\t((" fmt ") >> 24) & 0xff\n", __VA_ARGS__); \
133+ fprintf((f), "\t.byte\t((" fmt ") >> 16) & 0xff\n", __VA_ARGS__); \
134+ fprintf((f), "\t.byte\t((" fmt ") >> 8) & 0xff\n", __VA_ARGS__); \
135+ fprintf((f), "\t.byte\t(" fmt ") & 0xff\n", __VA_ARGS__); \
136+ }
137+
130138 static void asm_emit_cell(void *e, cell_t val)
131139 {
132140 FILE *f = e;
133141
134− fprintf(f, "\t.long\t0x%x\n", val);
142+ fprintf(f, "\t.byte 0x%02x; .byte 0x%02x; .byte 0x%02x; .byte 0x%02x\n",
143+ (val >> 24) & 0xff, (val >> 16) & 0xff,
144+ (val >> 8) & 0xff, val & 0xff);
135145 }
136146
137147 static void asm_emit_string(void *e, char *str, int len)
@@ -156,7 +166,7 @@ static void asm_emit_align(void *e, int a) · 18 unmodified lines
156166 {
157167 FILE *f = e;
158168
159− fprintf(f, "\t.balign\t%d\n", a);
169+ fprintf(f, "\t.balign\t%d, 0\n", a);
160170 }
161171
162172 static void asm_emit_data(void *e, struct data d)
@@ -169,8 +179,7 @@ static void asm_emit_data(void *e, struct data d) · 6 unmodified lines
169179 emit_offset_label(f, m->ref, m->offset);
170180
171181 while ((d.len - off) >= sizeof(uint32_t)) {
172− fprintf(f, "\t.long\t0x%x\n",
173− fdt32_to_cpu(*((uint32_t *)(d.val+off))));
182+ asm_emit_cell(e, fdt32_to_cpu(*((uint32_t *)(d.val+off))));
174183 off += sizeof(uint32_t);
175184 }
176185
@@ -182,37 +191,43 @@ static void asm_emit_data(void *e, struct data d) · 5 unmodified lines
182191 assert(off == d.len);
183192 }
184193
185−static void asm_emit_beginnode(void *e, const char *label)
194+static void asm_emit_beginnode(void *e, struct label *labels)
186195 {
187196 FILE *f = e;
197+ struct label *l;
188198
189− if (label) {
190− fprintf(f, "\t.globl\t%s\n", label);
191− fprintf(f, "%s:\n", label);
199+ for_each_label(labels, l) {
200+ fprintf(f, "\t.globl\t%s\n", l->label);
201+ fprintf(f, "%s:\n", l->label);
192202 }
193− fprintf(f, "\t.long\tFDT_BEGIN_NODE\n");
203+ fprintf(f, "\t/* FDT_BEGIN_NODE */\n");
204+ asm_emit_cell(e, FDT_BEGIN_NODE);
194205 }
195206
196−static void asm_emit_endnode(void *e, const char *label)
207+static void asm_emit_endnode(void *e, struct label *labels)
197208 {
198209 FILE *f = e;
210+ struct label *l;
199211
200− fprintf(f, "\t.long\tFDT_END_NODE\n");
201− if (label) {
202− fprintf(f, "\t.globl\t%s_end\n", label);
203− fprintf(f, "%s_end:\n", label);
212+ fprintf(f, "\t/* FDT_END_NODE */\n");
213+ asm_emit_cell(e, FDT_END_NODE);
214+ for_each_label(labels, l) {
215+ fprintf(f, "\t.globl\t%s_end\n", l->label);
216+ fprintf(f, "%s_end:\n", l->label);
204217 }
205218 }
206219
207−static void asm_emit_property(void *e, const char *label)
220+static void asm_emit_property(void *e, struct label *labels)
208221 {
209222 FILE *f = e;
223+ struct label *l;
210224
211− if (label) {
212− fprintf(f, "\t.globl\t%s\n", label);
213− fprintf(f, "%s:\n", label);
225+ for_each_label(labels, l) {
226+ fprintf(f, "\t.globl\t%s\n", l->label);
227+ fprintf(f, "%s:\n", l->label);
214228 }
215− fprintf(f, "\t.long\tFDT_PROP\n");
229+ fprintf(f, "\t/* FDT_PROP */\n");
230+ asm_emit_cell(e, FDT_PROP);
216231 }
217232
218233 static struct emitter asm_emitter = {
@@ -248,7 +263,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, · 29 unmodified lines
248263 struct node *child;
249264 int seen_name_prop = 0;
250265
251− emit->beginnode(etarget, tree->label);
266+ emit->beginnode(etarget, tree->labels);
252267
253268 if (vi->flags & FTF_FULLPATH)
254269 emit->string(etarget, tree->fullpath, 0);
@@ -265,7 +280,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, · 10 unmodified lines
265280
266281 nameoff = stringtable_insert(strbuf, prop->name);
267282
268− emit->property(etarget, prop->label);
283+ emit->property(etarget, prop->labels);
269284 emit->cell(etarget, prop->val.len);
270285 emit->cell(etarget, nameoff);
271286
@@ -292,7 +307,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, · 20 unmodified lines
292307 flatten_tree(child, emit, etarget, strbuf, vi);
293308 }
294309
295− emit->endnode(etarget, tree->label);
310+ emit->endnode(etarget, tree->labels);
296311 }
297312
298313 static struct data flatten_reserve_list(struct reserve_info *reservelist,
@@ -413,10 +428,13 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version) · 114 unmodified lines
413428 if (padlen > 0)
414429 blob = data_append_zeroes(blob, padlen);
415430
416− fwrite(blob.val, blob.len, 1, f);
417−
418− if (ferror(f))
419− die("Error writing device tree blob: %s\n", strerror(errno));
431+ if (fwrite(blob.val, blob.len, 1, f) != 1) {
432+ if (ferror(f))
433+ die("Error writing device tree blob: %s\n",
434+ strerror(errno));
435+ else
436+ die("Short write on device tree blob\n");
437+ }
420438
421439 /*
422440 * data_merge() frees the right-hand element so only the blob
@@ -455,39 +473,44 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) · 32 unmodified lines
455473 die("Unknown device tree blob version %d\n", version);
456474
457475 fprintf(f, "/* autogenerated by dtc, do not edit */\n\n");
458− fprintf(f, "#define FDT_MAGIC 0x%x\n", FDT_MAGIC);
459− fprintf(f, "#define FDT_BEGIN_NODE 0x%x\n", FDT_BEGIN_NODE);
460− fprintf(f, "#define FDT_END_NODE 0x%x\n", FDT_END_NODE);
461− fprintf(f, "#define FDT_PROP 0x%x\n", FDT_PROP);
462− fprintf(f, "#define FDT_END 0x%x\n", FDT_END);
463− fprintf(f, "\n");
464476
465477 emit_label(f, symprefix, "blob_start");
466478 emit_label(f, symprefix, "header");
467− fprintf(f, "\t.long\tFDT_MAGIC\t\t\t\t/* magic */\n");
468− fprintf(f, "\t.long\t_%s_blob_abs_end - _%s_blob_start\t/* totalsize */\n",
469− symprefix, symprefix);
470− fprintf(f, "\t.long\t_%s_struct_start - _%s_blob_start\t/* off_dt_struct */\n",
479+ fprintf(f, "\t/* magic */\n");
480+ asm_emit_cell(f, FDT_MAGIC);
481+ fprintf(f, "\t/* totalsize */\n");
482+ ASM_EMIT_BELONG(f, "_%s_blob_abs_end - _%s_blob_start",
483+ symprefix, symprefix);
484+ fprintf(f, "\t/* off_dt_struct */\n");
485+ ASM_EMIT_BELONG(f, "_%s_struct_start - _%s_blob_start",
471486 symprefix, symprefix);
472− fprintf(f, "\t.long\t_%s_strings_start - _%s_blob_start\t/* off_dt_strings */\n",
487+ fprintf(f, "\t/* off_dt_strings */\n");
488+ ASM_EMIT_BELONG(f, "_%s_strings_start - _%s_blob_start",
473489 symprefix, symprefix);
474− fprintf(f, "\t.long\t_%s_reserve_map - _%s_blob_start\t/* off_dt_strings */\n",
490+ fprintf(f, "\t/* off_mem_rsvmap */\n");
491+ ASM_EMIT_BELONG(f, "_%s_reserve_map - _%s_blob_start",
475492 symprefix, symprefix);
476− fprintf(f, "\t.long\t%d\t\t\t\t\t/* version */\n", vi->version);
477− fprintf(f, "\t.long\t%d\t\t\t\t\t/* last_comp_version */\n",
478− vi->last_comp_version);
479−
480− if (vi->flags & FTF_BOOTCPUID)
481− fprintf(f, "\t.long\t%i\t\t\t\t\t/* boot_cpuid_phys */\n",
482− bi->boot_cpuid_phys);
493+ fprintf(f, "\t/* version */\n");
494+ asm_emit_cell(f, vi->version);
495+ fprintf(f, "\t/* last_comp_version */\n");
496+ asm_emit_cell(f, vi->last_comp_version);
497+
498+ if (vi->flags & FTF_BOOTCPUID) {
499+ fprintf(f, "\t/* boot_cpuid_phys */\n");
500+ asm_emit_cell(f, bi->boot_cpuid_phys);
501+ }
483502
484− if (vi->flags & FTF_STRTABSIZE)
485− fprintf(f, "\t.long\t_%s_strings_end - _%s_strings_start\t/* size_dt_strings */\n",
486− symprefix, symprefix);
503+ if (vi->flags & FTF_STRTABSIZE) {
504+ fprintf(f, "\t/* size_dt_strings */\n");
505+ ASM_EMIT_BELONG(f, "_%s_strings_end - _%s_strings_start",
506+ symprefix, symprefix);
507+ }
487508
488− if (vi->flags & FTF_STRUCTSIZE)
489− fprintf(f, "\t.long\t_%s_struct_end - _%s_struct_start\t/* size_dt_struct */\n",
509+ if (vi->flags & FTF_STRUCTSIZE) {
510+ fprintf(f, "\t/* size_dt_struct */\n");
511+ ASM_EMIT_BELONG(f, "_%s_struct_end - _%s_struct_start",
490512 symprefix, symprefix);
513+ }
491514
492515 /*
493516 * Reserve map entries.
@@ -505,16 +528,17 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) · 11 unmodified lines
505528 * as it appears .quad isn't available in some assemblers.
506529 */
507530 for (re = bi->reservelist; re; re = re->next) {
508− if (re->label) {
509− fprintf(f, "\t.globl\t%s\n", re->label);
510− fprintf(f, "%s:\n", re->label);
531+ struct label *l;
532+
533+ for_each_label(re->labels, l) {
534+ fprintf(f, "\t.globl\t%s\n", l->label);
535+ fprintf(f, "%s:\n", l->label);
511536 }
512− fprintf(f, "\t.long\t0x%08x, 0x%08x\n",
513− (unsigned int)(re->re.address >> 32),
514− (unsigned int)(re->re.address & 0xffffffff));
515− fprintf(f, "\t.long\t0x%08x, 0x%08x\n",
516− (unsigned int)(re->re.size >> 32),
517− (unsigned int)(re->re.size & 0xffffffff));
537+ ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.address >> 32));
538+ ASM_EMIT_BELONG(f, "0x%08x",
539+ (unsigned int)(re->re.address & 0xffffffff));
540+ ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size >> 32));
541+ ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size & 0xffffffff));
518542 }
519543 for (i = 0; i < reservenum; i++) {
520544 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
@@ -524,7 +548,9 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) · 3 unmodified lines
524548
525549 emit_label(f, symprefix, "struct_start");
526550 flatten_tree(bi->dt, &asm_emitter, f, &strbuf, vi);
527− fprintf(f, "\t.long\tFDT_END\n");
551+
552+ fprintf(f, "\t/* FDT_END */\n");
553+ asm_emit_cell(f, FDT_END);
528554 emit_label(f, symprefix, "struct_end");
529555
530556 emit_label(f, symprefix, "strings_start");
@@ -601,7 +627,7 @@ static char *flat_read_string(struct inbuf *inb) · 70 unmodified lines
601627 len++;
602628 } while ((*p++) != '\0');
603629
604− str = strdup(inb->ptr);
630+ str = xstrdup(inb->ptr);
605631
606632 inb->ptr += len;
607633
@@ -643,7 +669,7 @@ static char *flat_read_stringtable(struct inbuf *inb, int offset) · 35 unmodified lines
643669 p++;
644670 }
645671
646− return strdup(inb->base + offset);
672+ return xstrdup(inb->base + offset);
647673 }
648674
649675 static struct property *flat_read_property(struct inbuf *dtbuf,
@@ -663,7 +689,7 @@ static struct property *flat_read_property(struct inbuf *dtbuf, · 13 unmodified lines
663689
664690 val = flat_read_data(dtbuf, proplen);
665691
666− return build_property(name, val, NULL);
692+ return build_property(name, val);
667693 }
668694
669695
@@ -688,7 +714,7 @@ static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb) · 18 unmodified lines
688714 if (re.size == 0)
689715 break;
690716
691− new = build_reserve_entry(re.address, re.size, NULL);
717+ new = build_reserve_entry(re.address, re.size);
692718 reservelist = add_reserve_entry(reservelist, new);
693719 }
694720
@@ -710,7 +736,7 @@ static char *nodename_from_path(const char *ppath, const char *cpath) · 15 unmodified lines
710736 if (!streq(ppath, "/"))
711737 plen++;
712738
713− return strdup(cpath + plen);
739+ return xstrdup(cpath + plen);
714740 }
715741
716742 static struct node *unflatten_tree(struct inbuf *dtbuf,
@@ -776,7 +802,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf, · 59 unmodified lines
776802
777803 struct boot_info *dt_from_blob(const char *fname)
778804 {
779− struct dtc_file *dtcf;
805+ FILE *f;
780806 uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys;
781807 uint32_t off_dt, off_str, off_mem_rsvmap;
782808 int rc;
@@ -791,14 +817,14 @@ struct boot_info *dt_from_blob(const char *fname) · 8 unmodified lines
791817 uint32_t val;
792818 int flags = 0;
793819
794− dtcf = dtc_open_file(fname, NULL);
820+ f = srcfile_relative_open(fname, NULL);
795821
796− rc = fread(&magic, sizeof(magic), 1, dtcf->file);
797− if (ferror(dtcf->file))
822+ rc = fread(&magic, sizeof(magic), 1, f);
823+ if (ferror(f))
798824 die("Error reading DT blob magic number: %s\n",
799825 strerror(errno));
800826 if (rc < 1) {
801− if (feof(dtcf->file))
827+ if (feof(f))
802828 die("EOF reading DT blob magic number\n");
803829 else
804830 die("Mysterious short read reading magic number\n");
@@ -808,11 +834,11 @@ struct boot_info *dt_from_blob(const char *fname) · 3 unmodified lines
808834 if (magic != FDT_MAGIC)
809835 die("Blob has incorrect magic number\n");
810836
811− rc = fread(&totalsize, sizeof(totalsize), 1, dtcf->file);
812− if (ferror(dtcf->file))
837+ rc = fread(&totalsize, sizeof(totalsize), 1, f);
838+ if (ferror(f))
813839 die("Error reading DT blob size: %s\n", strerror(errno));
814840 if (rc < 1) {
815− if (feof(dtcf->file))
841+ if (feof(f))
816842 die("EOF reading DT blob size\n");
817843 else
818844 die("Mysterious short read reading blob size\n");
@@ -832,12 +858,12 @@ struct boot_info *dt_from_blob(const char *fname) · 13 unmodified lines
832858 p = blob + sizeof(magic) + sizeof(totalsize);
833859
834860 while (sizeleft) {
835− if (feof(dtcf->file))
861+ if (feof(f))
836862 die("EOF before reading %d bytes of DT blob\n",
837863 totalsize);
838864
839− rc = fread(p, 1, sizeleft, dtcf->file);
840− if (ferror(dtcf->file))
865+ rc = fread(p, 1, sizeleft, f);
866+ if (ferror(f))
841867 die("Error reading DT blob: %s\n",
842868 strerror(errno));
843869
@@ -900,7 +926,7 @@ struct boot_info *dt_from_blob(const char *fname) · 56 unmodified lines
900926
901927 free(blob);
902928
903− dtc_close_file(dtcf);
929+ fclose(f);
904930
905931 return build_boot_info(reservelist, tree, boot_cpuid_phys);
906932 }
scripts/dtc/fstree.c+5−7
@@ -58,10 +58,9 @@ static struct node *read_fstree(const char *dirname) · 57 unmodified lines
5858 "WARNING: Cannot open %s: %s\n",
5959 tmpnam, strerror(errno));
6060 } else {
61− prop = build_property(strdup(de->d_name),
61+ prop = build_property(xstrdup(de->d_name),
6262 data_copy_file(pfile,
63− st.st_size),
64− NULL);
63+ st.st_size));
6564 add_property(tree, prop);
6665 fclose(pfile);
6766 }
@@ -69,8 +68,7 @@ static struct node *read_fstree(const char *dirname) · 1 unmodified line
6968 struct node *newchild;
7069
7170 newchild = read_fstree(tmpnam);
72− newchild = name_node(newchild, strdup(de->d_name),
73− NULL);
71+ newchild = name_node(newchild, xstrdup(de->d_name));
7472 add_child(tree, newchild);
7573 }
7674
@@ -86,8 +84,8 @@ struct boot_info *dt_from_fs(const char *dirname) · 9 unmodified lines
8684 struct node *tree;
8785
8886 tree = read_fstree(dirname);
89− tree = name_node(tree, "", NULL);
87+ tree = name_node(tree, "");
9088
91− return build_boot_info(NULL, tree, 0);
89+ return build_boot_info(NULL, tree, guess_boot_cpuid(tree));
9290 }
9391
scripts/dtc/livetree.c+323−22
@@ -24,17 +24,30 @@ · 23 unmodified lines
2424 * Tree building functions
2525 */
2626
27−struct property *build_property(char *name, struct data val, char *label)
27+void add_label(struct label **labels, char *label)
28+{
29+ struct label *new;
30+
31+ /* Make sure the label isn't already there */
32+ for_each_label(*labels, new)
33+ if (streq(new->label, label))
34+ return;
35+
36+ new = xmalloc(sizeof(*new));
37+ new->label = label;
38+ new->next = *labels;
39+ *labels = new;
40+}
41+
42+struct property *build_property(char *name, struct data val)
2843 {
2944 struct property *new = xmalloc(sizeof(*new));
3045
46+ memset(new, 0, sizeof(*new));
47+
3148 new->name = name;
3249 new->val = val;
3350
34− new->next = NULL;
35−
36− new->label = label;
37−
3851 return new;
3952 }
4053
@@ -78,17 +91,82 @@ struct node *build_node(struct property *proplist, struct node *children) · 37 unmodified lines
7891 return new;
7992 }
8093
81−struct node *name_node(struct node *node, char *name, char * label)
94+struct node *name_node(struct node *node, char *name)
8295 {
8396 assert(node->name == NULL);
8497
8598 node->name = name;
8699
87− node->label = label;
88−
89100 return node;
90101 }
91102
103+struct node *merge_nodes(struct node *old_node, struct node *new_node)
104+{
105+ struct property *new_prop, *old_prop;
106+ struct node *new_child, *old_child;
107+ struct label *l;
108+
109+ /* Add new node labels to old node */
110+ for_each_label(new_node->labels, l)
111+ add_label(&old_node->labels, l->label);
112+
113+ /* Move properties from the new node to the old node. If there
114+ * is a collision, replace the old value with the new */
115+ while (new_node->proplist) {
116+ /* Pop the property off the list */
117+ new_prop = new_node->proplist;
118+ new_node->proplist = new_prop->next;
119+ new_prop->next = NULL;
120+
121+ /* Look for a collision, set new value if there is */
122+ for_each_property(old_node, old_prop) {
123+ if (streq(old_prop->name, new_prop->name)) {
124+ /* Add new labels to old property */
125+ for_each_label(new_prop->labels, l)
126+ add_label(&old_prop->labels, l->label);
127+
128+ old_prop->val = new_prop->val;
129+ free(new_prop);
130+ new_prop = NULL;
131+ break;
132+ }
133+ }
134+
135+ /* if no collision occurred, add property to the old node. */
136+ if (new_prop)
137+ add_property(old_node, new_prop);
138+ }
139+
140+ /* Move the override child nodes into the primary node. If
141+ * there is a collision, then merge the nodes. */
142+ while (new_node->children) {
143+ /* Pop the child node off the list */
144+ new_child = new_node->children;
145+ new_node->children = new_child->next_sibling;
146+ new_child->parent = NULL;
147+ new_child->next_sibling = NULL;
148+
149+ /* Search for a collision. Merge if there is */
150+ for_each_child(old_node, old_child) {
151+ if (streq(old_child->name, new_child->name)) {
152+ merge_nodes(old_child, new_child);
153+ new_child = NULL;
154+ break;
155+ }
156+ }
157+
158+ /* if no collision occured, add child to the old node. */
159+ if (new_child)
160+ add_child(old_node, new_child);
161+ }
162+
163+ /* The new node contents are now merged into the old node. Free
164+ * the new node. */
165+ free(new_node);
166+
167+ return old_node;
168+}
169+
92170 struct node *chain_node(struct node *first, struct node *list)
93171 {
94172 assert(first->next_sibling == NULL);
@@ -124,18 +202,15 @@ void add_child(struct node *parent, struct node *child) · 29 unmodified lines
124202 *p = child;
125203 }
126204
127−struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size,
128− char *label)
205+struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size)
129206 {
130207 struct reserve_info *new = xmalloc(sizeof(*new));
131208
209+ memset(new, 0, sizeof(*new));
210+
132211 new->re.address = address;
133212 new->re.size = size;
134213
135− new->next = NULL;
136−
137− new->label = label;
138−
139214 return new;
140215 }
141216
@@ -208,6 +283,60 @@ cell_t propval_cell(struct property *prop) · 66 unmodified lines
208283 return fdt32_to_cpu(*((cell_t *)prop->val.val));
209284 }
210285
286+struct property *get_property_by_label(struct node *tree, const char *label,
287+ struct node **node)
288+{
289+ struct property *prop;
290+ struct node *c;
291+
292+ *node = tree;
293+
294+ for_each_property(tree, prop) {
295+ struct label *l;
296+
297+ for_each_label(prop->labels, l)
298+ if (streq(l->label, label))
299+ return prop;
300+ }
301+
302+ for_each_child(tree, c) {
303+ prop = get_property_by_label(c, label, node);
304+ if (prop)
305+ return prop;
306+ }
307+
308+ *node = NULL;
309+ return NULL;
310+}
311+
312+struct marker *get_marker_label(struct node *tree, const char *label,
313+ struct node **node, struct property **prop)
314+{
315+ struct marker *m;
316+ struct property *p;
317+ struct node *c;
318+
319+ *node = tree;
320+
321+ for_each_property(tree, p) {
322+ *prop = p;
323+ m = p->val.markers;
324+ for_each_marker_of_type(m, LABEL)
325+ if (streq(m->ref, label))
326+ return m;
327+ }
328+
329+ for_each_child(tree, c) {
330+ m = get_marker_label(c, label, node, prop);
331+ if (m)
332+ return m;
333+ }
334+
335+ *prop = NULL;
336+ *node = NULL;
337+ return NULL;
338+}
339+
211340 struct node *get_subnode(struct node *node, const char *nodename)
212341 {
213342 struct node *child;
@@ -245,11 +374,13 @@ struct node *get_node_by_path(struct node *tree, const char *path) · 31 unmodified lines
245374 struct node *get_node_by_label(struct node *tree, const char *label)
246375 {
247376 struct node *child, *node;
377+ struct label *l;
248378
249379 assert(label && (strlen(label) > 0));
250380
251− if (tree->label && streq(tree->label, label))
252− return tree;
381+ for_each_label(tree->labels, l)
382+ if (streq(l->label, label))
383+ return tree;
253384
254385 for_each_child(tree, child) {
255386 node = get_node_by_label(child, label);
@@ -293,16 +424,186 @@ cell_t get_node_phandle(struct node *root, struct node *node) · 37 unmodified lines
293424 if ((node->phandle != 0) && (node->phandle != -1))
294425 return node->phandle;
295426
296− assert(! get_property(node, "linux,phandle"));
297−
298427 while (get_node_by_phandle(root, phandle))
299428 phandle++;
300429
301430 node->phandle = phandle;
302− add_property(node,
303− build_property("linux,phandle",
304− data_append_cell(empty_data, phandle),
305− NULL));
431+
432+ if (!get_property(node, "linux,phandle")
433+ && (phandle_format & PHANDLE_LEGACY))
434+ add_property(node,
435+ build_property("linux,phandle",
436+ data_append_cell(empty_data, phandle)));
437+
438+ if (!get_property(node, "phandle")
439+ && (phandle_format & PHANDLE_EPAPR))
440+ add_property(node,
441+ build_property("phandle",
442+ data_append_cell(empty_data, phandle)));
443+
444+ /* If the node *does* have a phandle property, we must
445+ * be dealing with a self-referencing phandle, which will be
446+ * fixed up momentarily in the caller */
306447
307448 return node->phandle;
308449 }
450+
451+uint32_t guess_boot_cpuid(struct node *tree)
452+{
453+ struct node *cpus, *bootcpu;
454+ struct property *reg;
455+
456+ cpus = get_node_by_path(tree, "/cpus");
457+ if (!cpus)
458+ return 0;
459+
460+
461+ bootcpu = cpus->children;
462+ if (!bootcpu)
463+ return 0;
464+
465+ reg = get_property(bootcpu, "reg");
466+ if (!reg || (reg->val.len != sizeof(uint32_t)))
467+ return 0;
468+
469+ /* FIXME: Sanity check node? */
470+
471+ return propval_cell(reg);
472+}
473+
474+static int cmp_reserve_info(const void *ax, const void *bx)
475+{
476+ const struct reserve_info *a, *b;
477+
478+ a = *((const struct reserve_info * const *)ax);
479+ b = *((const struct reserve_info * const *)bx);
480+
481+ if (a->re.address < b->re.address)
482+ return -1;
483+ else if (a->re.address > b->re.address)
484+ return 1;
485+ else if (a->re.size < b->re.size)
486+ return -1;
487+ else if (a->re.size > b->re.size)
488+ return 1;
489+ else
490+ return 0;
491+}
492+
493+static void sort_reserve_entries(struct boot_info *bi)
494+{
495+ struct reserve_info *ri, **tbl;
496+ int n = 0, i = 0;
497+
498+ for (ri = bi->reservelist;
499+ ri;
500+ ri = ri->next)
501+ n++;
502+
503+ if (n == 0)
504+ return;
505+
506+ tbl = xmalloc(n * sizeof(*tbl));
507+
508+ for (ri = bi->reservelist;
509+ ri;
510+ ri = ri->next)
511+ tbl[i++] = ri;
512+
513+ qsort(tbl, n, sizeof(*tbl), cmp_reserve_info);
514+
515+ bi->reservelist = tbl[0];
516+ for (i = 0; i < (n-1); i++)
517+ tbl[i]->next = tbl[i+1];
518+ tbl[n-1]->next = NULL;
519+
520+ free(tbl);
521+}
522+
523+static int cmp_prop(const void *ax, const void *bx)
524+{
525+ const struct property *a, *b;
526+
527+ a = *((const struct property * const *)ax);
528+ b = *((const struct property * const *)bx);
529+
530+ return strcmp(a->name, b->name);
531+}
532+
533+static void sort_properties(struct node *node)
534+{
535+ int n = 0, i = 0;
536+ struct property *prop, **tbl;
537+
538+ for_each_property(node, prop)
539+ n++;
540+
541+ if (n == 0)
542+ return;
543+
544+ tbl = xmalloc(n * sizeof(*tbl));
545+
546+ for_each_property(node, prop)
547+ tbl[i++] = prop;
548+
549+ qsort(tbl, n, sizeof(*tbl), cmp_prop);
550+
551+ node->proplist = tbl[0];
552+ for (i = 0; i < (n-1); i++)
553+ tbl[i]->next = tbl[i+1];
554+ tbl[n-1]->next = NULL;
555+
556+ free(tbl);
557+}
558+
559+static int cmp_subnode(const void *ax, const void *bx)
560+{
561+ const struct node *a, *b;
562+
563+ a = *((const struct node * const *)ax);
564+ b = *((const struct node * const *)bx);
565+
566+ return strcmp(a->name, b->name);
567+}
568+
569+static void sort_subnodes(struct node *node)
570+{
571+ int n = 0, i = 0;
572+ struct node *subnode, **tbl;
573+
574+ for_each_child(node, subnode)
575+ n++;
576+
577+ if (n == 0)
578+ return;
579+
580+ tbl = xmalloc(n * sizeof(*tbl));
581+
582+ for_each_child(node, subnode)
583+ tbl[i++] = subnode;
584+
585+ qsort(tbl, n, sizeof(*tbl), cmp_subnode);
586+
587+ node->children = tbl[0];
588+ for (i = 0; i < (n-1); i++)
589+ tbl[i]->next_sibling = tbl[i+1];
590+ tbl[n-1]->next_sibling = NULL;
591+
592+ free(tbl);
593+}
594+
595+static void sort_node(struct node *node)
596+{
597+ struct node *c;
598+
599+ sort_properties(node);
600+ sort_subnodes(node);
601+ for_each_child(node, c)
602+ sort_node(c);
603+}
604+
605+void sort_tree(struct boot_info *bi)
606+{
607+ sort_reserve_entries(bi);
608+ sort_node(bi->dt);
609+}
scripts/dtc/srcpos.c+195−63
@@ -17,100 +17,232 @@ · 16 unmodified lines
1717 * USA
1818 */
1919
20+#define _GNU_SOURCE
21+
22+#include <stdio.h>
23+
2024 #include "dtc.h"
2125 #include "srcpos.h"
2226
23−/*
24− * Like yylineno, this is the current open file pos.
25− */
2627
27−struct dtc_file *srcpos_file;
28+static char *dirname(const char *path)
29+{
30+ const char *slash = strrchr(path, '/');
31+
32+ if (slash) {
33+ int len = slash - path;
34+ char *dir = xmalloc(len + 1);
35+
36+ memcpy(dir, path, len);
37+ dir[len] = '\0';
38+ return dir;
39+ }
40+ return NULL;
41+}
42+
43+struct srcfile_state *current_srcfile; /* = NULL */
2844
29−static int dtc_open_one(struct dtc_file *file,
30− const char *search,
31− const char *fname)
45+/* Detect infinite include recursion. */
46+#define MAX_SRCFILE_DEPTH (100)
47+static int srcfile_depth; /* = 0 */
48+
49+FILE *srcfile_relative_open(const char *fname, char **fullnamep)
3250 {
51+ FILE *f;
3352 char *fullname;
3453
35− if (search) {
36− fullname = xmalloc(strlen(search) + strlen(fname) + 2);
37−
38− strcpy(fullname, search);
39− strcat(fullname, "/");
40− strcat(fullname, fname);
54+ if (streq(fname, "-")) {
55+ f = stdin;
56+ fullname = xstrdup("<stdin>");
4157 } else {
42− fullname = strdup(fname);
58+ if (!current_srcfile || !current_srcfile->dir
59+ || (fname[0] == '/'))
60+ fullname = xstrdup(fname);
61+ else
62+ fullname = join_path(current_srcfile->dir, fname);
63+
64+ f = fopen(fullname, "r");
65+ if (!f)
66+ die("Couldn't open \"%s\": %s\n", fname,
67+ strerror(errno));
4368 }
4469
45− file->file = fopen(fullname, "r");
46− if (!file->file) {
70+ if (fullnamep)
71+ *fullnamep = fullname;
72+ else
4773 free(fullname);
48− return 0;
49− }
5074
51− file->name = fullname;
52− return 1;
75+ return f;
5376 }
5477
78+void srcfile_push(const char *fname)
79+{
80+ struct srcfile_state *srcfile;
81+
82+ if (srcfile_depth++ >= MAX_SRCFILE_DEPTH)
83+ die("Includes nested too deeply");
84+
85+ srcfile = xmalloc(sizeof(*srcfile));
86+
87+ srcfile->f = srcfile_relative_open(fname, &srcfile->name);
88+ srcfile->dir = dirname(srcfile->name);
89+ srcfile->prev = current_srcfile;
90+
91+ srcfile->lineno = 1;
92+ srcfile->colno = 1;
93+
94+ current_srcfile = srcfile;
95+}
5596
56−struct dtc_file *dtc_open_file(const char *fname,
57− const struct search_path *search)
97+int srcfile_pop(void)
5898 {
59− static const struct search_path default_search = { NULL, NULL, NULL };
99+ struct srcfile_state *srcfile = current_srcfile;
60100
61− struct dtc_file *file;
62− const char *slash;
101+ assert(srcfile);
63102
64− file = xmalloc(sizeof(struct dtc_file));
103+ current_srcfile = srcfile->prev;
65104
66− slash = strrchr(fname, '/');
67− if (slash) {
68− char *dir = xmalloc(slash - fname + 1);
105+ if (fclose(srcfile->f))
106+ die("Error closing \"%s\": %s\n", srcfile->name,
107+ strerror(errno));
69108
70− memcpy(dir, fname, slash - fname);
71− dir[slash - fname] = 0;
72− file->dir = dir;
73− } else {
74− file->dir = NULL;
75− }
109+ /* FIXME: We allow the srcfile_state structure to leak,
110+ * because it could still be referenced from a location
111+ * variable being carried through the parser somewhere. To
112+ * fix this we could either allocate all the files from a
113+ * table, or use a pool allocator. */
76114
77− if (streq(fname, "-")) {
78− file->name = "stdin";
79− file->file = stdin;
80− return file;
81− }
115+ return current_srcfile ? 1 : 0;
116+}
82117
83− if (fname[0] == '/') {
84− file->file = fopen(fname, "r");
85− if (!file->file)
86− goto fail;
118+/*
119+ * The empty source position.
120+ */
87121
88− file->name = strdup(fname);
89− return file;
90− }
122+struct srcpos srcpos_empty = {
123+ .first_line = 0,
124+ .first_column = 0,
125+ .last_line = 0,
126+ .last_column = 0,
127+ .file = NULL,
128+};
91129
92− if (!search)
93− search = &default_search;
130+#define TAB_SIZE 8
94131
95− while (search) {
96− if (dtc_open_one(file, search->dir, fname))
97− return file;
132+void srcpos_update(struct srcpos *pos, const char *text, int len)
133+{
134+ int i;
135+
136+ pos->file = current_srcfile;
137+
138+ pos->first_line = current_srcfile->lineno;
139+ pos->first_column = current_srcfile->colno;
140+
141+ for (i = 0; i < len; i++)
142+ if (text[i] == '\n') {
143+ current_srcfile->lineno++;
144+ current_srcfile->colno = 1;
145+ } else if (text[i] == '\t') {
146+ current_srcfile->colno =
147+ ALIGN(current_srcfile->colno, TAB_SIZE);
148+ } else {
149+ current_srcfile->colno++;
150+ }
151+
152+ pos->last_line = current_srcfile->lineno;
153+ pos->last_column = current_srcfile->colno;
154+}
98155
99− if (errno != ENOENT)
100− goto fail;
156+struct srcpos *
157+srcpos_copy(struct srcpos *pos)
158+{
159+ struct srcpos *pos_new;
101160
102− search = search->next;
103− }
161+ pos_new = xmalloc(sizeof(struct srcpos));
162+ memcpy(pos_new, pos, sizeof(struct srcpos));
163+
164+ return pos_new;
165+}
166+
167+
168+
169+void
170+srcpos_dump(struct srcpos *pos)
171+{
172+ printf("file : \"%s\"\n",
173+ pos->file ? (char *) pos->file : "<no file>");
174+ printf("first_line : %d\n", pos->first_line);
175+ printf("first_column: %d\n", pos->first_column);
176+ printf("last_line : %d\n", pos->last_line);
177+ printf("last_column : %d\n", pos->last_column);
178+ printf("file : %s\n", pos->file->name);
179+}
104180
105−fail:
106− die("Couldn't open \"%s\": %s\n", fname, strerror(errno));
181+
182+char *
183+srcpos_string(struct srcpos *pos)
184+{
185+ const char *fname = "<no-file>";
186+ char *pos_str;
187+ int rc;
188+
189+ if (pos)
190+ fname = pos->file->name;
191+
192+
193+ if (pos->first_line != pos->last_line)
194+ rc = asprintf(&pos_str, "%s:%d.%d-%d.%d", fname,
195+ pos->first_line, pos->first_column,
196+ pos->last_line, pos->last_column);
197+ else if (pos->first_column != pos->last_column)
198+ rc = asprintf(&pos_str, "%s:%d.%d-%d", fname,
199+ pos->first_line, pos->first_column,
200+ pos->last_column);
201+ else
202+ rc = asprintf(&pos_str, "%s:%d.%d", fname,
203+ pos->first_line, pos->first_column);
204+
205+ if (rc == -1)
206+ die("Couldn't allocate in srcpos string");
207+
208+ return pos_str;
209+}
210+
211+void
212+srcpos_verror(struct srcpos *pos, char const *fmt, va_list va)
213+{
214+ const char *srcstr;
215+
216+ srcstr = srcpos_string(pos);
217+
218+ fprintf(stdout, "Error: %s ", srcstr);
219+ vfprintf(stdout, fmt, va);
220+ fprintf(stdout, "\n");
107221 }
108222
109−void dtc_close_file(struct dtc_file *file)
223+void
224+srcpos_error(struct srcpos *pos, char const *fmt, ...)
110225 {
111− if (fclose(file->file))
112− die("Error closing \"%s\": %s\n", file->name, strerror(errno));
226+ va_list va;
227+
228+ va_start(va, fmt);
229+ srcpos_verror(pos, fmt, va);
230+ va_end(va);
231+}
232+
233+
234+void
235+srcpos_warn(struct srcpos *pos, char const *fmt, ...)
236+{
237+ const char *srcstr;
238+ va_list va;
239+ va_start(va, fmt);
240+
241+ srcstr = srcpos_string(pos);
242+
243+ fprintf(stderr, "Warning: %s ", srcstr);
244+ vfprintf(stderr, fmt, va);
245+ fprintf(stderr, "\n");
113246
114− free(file->dir);
115− free(file);
247+ va_end(va);
116248 }
scripts/dtc/srcpos.h+50−49
@@ -17,69 +17,70 @@ · 16 unmodified lines
1717 * USA
1818 */
1919
20−/*
21− * Augment the standard YYLTYPE with a filenum index into an
22− * array of all opened filenames.
23− */
20+#ifndef _SRCPOS_H_
21+#define _SRCPOS_H_
2422
2523 #include <stdio.h>
2624
27−struct dtc_file {
25+struct srcfile_state {
26+ FILE *f;
27+ char *name;
2828 char *dir;
29− const char *name;
30− FILE *file;
29+ int lineno, colno;
30+ struct srcfile_state *prev;
3131 };
3232
33−#if ! defined(YYLTYPE) && ! defined(YYLTYPE_IS_DECLARED)
34−typedef struct YYLTYPE {
33+extern struct srcfile_state *current_srcfile; /* = NULL */
34+
35+FILE *srcfile_relative_open(const char *fname, char **fullnamep);
36+void srcfile_push(const char *fname);
37+int srcfile_pop(void);
38+
39+struct srcpos {
3540 int first_line;
3641 int first_column;
3742 int last_line;
3843 int last_column;
39− struct dtc_file *file;
40−} YYLTYPE;
41−
42−#define YYLTYPE_IS_DECLARED 1
43−#define YYLTYPE_IS_TRIVIAL 1
44−#endif
45−
46−/* Cater to old parser templates. */
47−#ifndef YYID
48−#define YYID(n) (n)
49−#endif
44+ struct srcfile_state *file;
45+};
5046
51−#define YYLLOC_DEFAULT(Current, Rhs, N) \
52− do \
53− if (YYID (N)) \
54− { \
55− (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
56− (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
57− (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
58− (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
59− (Current).file = YYRHSLOC (Rhs, N).file; \
60− } \
61− else \
62− { \
63− (Current).first_line = (Current).last_line = \
64− YYRHSLOC (Rhs, 0).last_line; \
65− (Current).first_column = (Current).last_column = \
66− YYRHSLOC (Rhs, 0).last_column; \
67− (Current).file = YYRHSLOC (Rhs, 0).file; \
68− } \
69− while (YYID (0))
47+#define YYLTYPE struct srcpos
7048
49+#define YYLLOC_DEFAULT(Current, Rhs, N) \
50+ do { \
51+ if (N) { \
52+ (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
53+ (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
54+ (Current).last_line = YYRHSLOC(Rhs, N).last_line; \
55+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
56+ (Current).file = YYRHSLOC(Rhs, N).file; \
57+ } else { \
58+ (Current).first_line = (Current).last_line = \
59+ YYRHSLOC(Rhs, 0).last_line; \
60+ (Current).first_column = (Current).last_column = \
61+ YYRHSLOC(Rhs, 0).last_column; \
62+ (Current).file = YYRHSLOC (Rhs, 0).file; \
63+ } \
64+ } while (0)
7165
7266
73−extern void yyerror(char const *);
74−extern void yyerrorf(char const *, ...) __attribute__((format(printf, 1, 2)));
67+/*
68+ * Fictional source position used for IR nodes that are
69+ * created without otherwise knowing a true source position.
70+ * For example,constant definitions from the command line.
71+ */
72+extern struct srcpos srcpos_empty;
7573
76−extern struct dtc_file *srcpos_file;
74+extern void srcpos_update(struct srcpos *pos, const char *text, int len);
75+extern struct srcpos *srcpos_copy(struct srcpos *pos);
76+extern char *srcpos_string(struct srcpos *pos);
77+extern void srcpos_dump(struct srcpos *pos);
7778
78−struct search_path {
79− const char *dir; /* NULL for current directory */
80− struct search_path *prev, *next;
81−};
79+extern void srcpos_verror(struct srcpos *pos, char const *, va_list va)
80+ __attribute__((format(printf, 2, 0)));
81+extern void srcpos_error(struct srcpos *pos, char const *, ...)
82+ __attribute__((format(printf, 2, 3)));
83+extern void srcpos_warn(struct srcpos *pos, char const *, ...)
84+ __attribute__((format(printf, 2, 3)));
8285
83−extern struct dtc_file *dtc_open_file(const char *fname,
84− const struct search_path *search);
85−extern void dtc_close_file(struct dtc_file *file);
86+#endif /* _SRCPOS_H_ */
scripts/dtc/treesource.c+26−22
@@ -32,8 +32,8 @@ struct boot_info *dt_from_source(const char *fname) · 31 unmodified lines
3232 the_boot_info = NULL;
3333 treesource_error = 0;
3434
35− srcpos_file = dtc_open_file(fname, NULL);
36− yyin = srcpos_file->file;
35+ srcfile_push(fname);
36+ yyin = current_srcfile->f;
3737
3838 if (yyparse() != 0)
3939 die("Unable to parse input tree\n");
@@ -63,26 +63,20 @@ static void write_propval_string(FILE *f, struct data val) · 23 unmodified lines
6363 {
6464 const char *str = val.val;
6565 int i;
66− int newchunk = 1;
6766 struct marker *m = val.markers;
6867
6968 assert(str[val.len-1] == '\0');
7069
70+ while (m && (m->offset == 0)) {
71+ if (m->type == LABEL)
72+ fprintf(f, "%s: ", m->ref);
73+ m = m->next;
74+ }
75+ fprintf(f, "\"");
76+
7177 for (i = 0; i < (val.len-1); i++) {
7278 char c = str[i];
7379
74− if (newchunk) {
75− while (m && (m->offset <= i)) {
76− if (m->type == LABEL) {
77− assert(m->offset == i);
78− fprintf(f, "%s: ", m->ref);
79− }
80− m = m->next;
81− }
82− fprintf(f, "\"");
83− newchunk = 0;
84− }
85−
8680 switch (c) {
8781 case '\a':
8882 fprintf(f, "\\a");
@@ -113,7 +107,14 @@ static void write_propval_string(FILE *f, struct data val) · 24 unmodified lines
113107 break;
114108 case '\0':
115109 fprintf(f, "\", ");
116− newchunk = 1;
110+ while (m && (m->offset < i)) {
111+ if (m->type == LABEL) {
112+ assert(m->offset == (i+1));
113+ fprintf(f, "%s: ", m->ref);
114+ }
115+ m = m->next;
116+ }
117+ fprintf(f, "\"");
117118 break;
118119 default:
119120 if (isprint(c))
@@ -234,10 +235,11 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level) · 114 unmodified lines
234235 {
235236 struct property *prop;
236237 struct node *child;
238+ struct label *l;
237239
238240 write_prefix(f, level);
239− if (tree->label)
240− fprintf(f, "%s: ", tree->label);
241+ for_each_label(tree->labels, l)
242+ fprintf(f, "%s: ", l->label);
241243 if (tree->name && (*tree->name))
242244 fprintf(f, "%s {\n", tree->name);
243245 else
@@ -245,8 +247,8 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level) · 1 unmodified line
245247
246248 for_each_property(tree, prop) {
247249 write_prefix(f, level+1);
248− if (prop->label)
249− fprintf(f, "%s: ", prop->label);
250+ for_each_label(prop->labels, l)
251+ fprintf(f, "%s: ", l->label);
250252 fprintf(f, "%s", prop->name);
251253 write_propval(f, prop);
252254 }
@@ -266,8 +268,10 @@ void dt_to_source(FILE *f, struct boot_info *bi) · 13 unmodified lines
266268 fprintf(f, "/dts-v1/;\n\n");
267269
268270 for (re = bi->reservelist; re; re = re->next) {
269− if (re->label)
270− fprintf(f, "%s: ", re->label);
271+ struct label *l;
272+
273+ for_each_label(re->labels, l)
274+ fprintf(f, "%s: ", l->label);
271275 fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n",
272276 (unsigned long long)re->re.address,
273277 (unsigned long long)re->re.size);
scripts/dtc/util.c+59−0
@@ -0,0 +1,59 @@
1+/*
2+ * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
3+ *
4+ * This program is free software; you can redistribute it and/or
5+ * modify it under the terms of the GNU General Public License as
6+ * published by the Free Software Foundation; either version 2 of the
7+ * License, or (at your option) any later version.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ * General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program; if not, write to the Free Software
16+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17+ * USA
18+ */
19+
20+#include <stdio.h>
21+#include <stdlib.h>
22+#include <stdarg.h>
23+#include <string.h>
24+
25+#include "util.h"
26+
27+char *xstrdup(const char *s)
28+{
29+ int len = strlen(s) + 1;
30+ char *dup = xmalloc(len);
31+
32+ memcpy(dup, s, len);
33+
34+ return dup;
35+}
36+
37+char *join_path(const char *path, const char *name)
38+{
39+ int lenp = strlen(path);
40+ int lenn = strlen(name);
41+ int len;
42+ int needslash = 1;
43+ char *str;
44+
45+ len = lenp + lenn + 2;
46+ if ((lenp > 0) && (path[lenp-1] == '/')) {
47+ needslash = 0;
48+ len--;
49+ }
50+
51+ str = xmalloc(len);
52+ memcpy(str, path, lenp);
53+ if (needslash) {
54+ str[lenp] = '/';
55+ lenp++;
56+ }
57+ memcpy(str+lenp, name, lenn+1);
58+ return str;
59+}
scripts/dtc/util.h+56−0
@@ -0,0 +1,56 @@
1+#ifndef _UTIL_H
2+#define _UTIL_H
3+
4+/*
5+ * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License as
9+ * published by the Free Software Foundation; either version 2 of the
10+ * License, or (at your option) any later version.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+ * General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program; if not, write to the Free Software
19+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20+ * USA
21+ */
22+
23+static inline void __attribute__((noreturn)) die(char * str, ...)
24+{
25+ va_list ap;
26+
27+ va_start(ap, str);
28+ fprintf(stderr, "FATAL ERROR: ");
29+ vfprintf(stderr, str, ap);
30+ exit(1);
31+}
32+
33+static inline void *xmalloc(size_t len)
34+{
35+ void *new = malloc(len);
36+
37+ if (!new)
38+ die("malloc() failed\n");
39+
40+ return new;
41+}
42+
43+static inline void *xrealloc(void *p, size_t len)
44+{
45+ void *new = realloc(p, len);
46+
47+ if (!new)
48+ die("realloc() failed (len=%d)\n", len);
49+
50+ return new;
51+}
52+
53+extern char *xstrdup(const char *s);
54+extern char *join_path(const char *path, const char *name);
55+
56+#endif /* _UTIL_H */
scripts/dtc/version_gen.h+1−1
@@ -1 +1 @@
1−#define DTC_VERSION "DTC 1.2.0"
1+#define DTC_VERSION "DTC 1.2.0-g37c0b6a0"