* '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.
Unified · Split
| @@ -1136,6 +1136,21 @@ When kbuild executes, the following steps are followed (roughly): · 1135 unmodified lines | ||
| 1136 | 1136 | resulting in the target file being recompiled for no |
| 1137 | 1137 | obvious reason. |
| 1138 | 1138 | |
| 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) | |
| 1139 | 1154 | |
| 1140 | 1155 | --- 6.7 Custom kbuild commands |
| 1141 | 1156 | |
| @@ -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 | +}; | |
| @@ -14,7 +14,7 @@ config MICROBLAZE · 13 unmodified lines | ||
| 14 | 14 | select HAVE_DMA_API_DEBUG |
| 15 | 15 | select TRACING_SUPPORT |
| 16 | 16 | select OF |
| 17 | − select OF_FLATTREE | |
| 17 | + select OF_EARLY_FLATTREE | |
| 18 | 18 | |
| 19 | 19 | config SWAP |
| 20 | 20 | def_bool n |
| @@ -10,9 +10,6 @@ targets := linux.bin linux.bin.gz simpleImage.% · 9 unmodified lines | ||
| 10 | 10 | |
| 11 | 11 | OBJCOPYFLAGS := -O binary |
| 12 | 12 | |
| 13 | −# Where the DTS files live | |
| 14 | −dtstree := $(srctree)/$(src)/dts | |
| 15 | − | |
| 16 | 13 | # Ensure system.dtb exists |
| 17 | 14 | $(obj)/linked_dtb.o: $(obj)/system.dtb |
| 18 | 15 | |
| @@ -51,14 +48,11 @@ $(obj)/simpleImage.%: vmlinux FORCE · 32 unmodified lines | ||
| 51 | 48 | $(call if_changed,strip) |
| 52 | 49 | @echo 'Kernel: $@ is ready' ' (#'`cat .version`')' |
| 53 | 50 | |
| 54 | −# Rule to build device tree blobs | |
| 55 | −DTC = $(objtree)/scripts/dtc/dtc | |
| 56 | 51 | |
| 57 | 52 | # 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 | |
| 60 | 54 | |
| 61 | −$(obj)/%.dtb: $(dtstree)/%.dts FORCE | |
| 62 | − $(call if_changed,dtc) | |
| 55 | +$(obj)/%.dtb: $(src)/dts/%.dts FORCE | |
| 56 | + $(call cmd,dtc) | |
| 63 | 57 | |
| 64 | 58 | clean-files += *.dtb simpleImage.*.unstrip linux.bin.ub |
| @@ -64,9 +64,6 @@ extern void kdump_move_device_tree(void); · 63 unmodified lines | ||
| 64 | 64 | /* CPU OF node matching */ |
| 65 | 65 | struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); |
| 66 | 66 | |
| 67 | −/* Get the MAC address */ | |
| 68 | −extern const void *of_get_mac_address(struct device_node *np); | |
| 69 | − | |
| 70 | 67 | /** |
| 71 | 68 | * of_irq_map_pci - Resolve the interrupt for a PCI device |
| 72 | 69 | * @pdev: the device whose interrupt is to be resolved |
| @@ -110,41 +110,3 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, · 109 unmodified lines | ||
| 110 | 110 | cells = prop ? *(u32 *)prop : of_n_size_cells(dn); |
| 111 | 111 | *size = of_read_number(dma_window, cells); |
| 112 | 112 | } |
| 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); | |
| @@ -2218,7 +2218,7 @@ config SECCOMP · 2217 unmodified lines | ||
| 2218 | 2218 | config USE_OF |
| 2219 | 2219 | bool "Flattened Device Tree support" |
| 2220 | 2220 | select OF |
| 2221 | − select OF_FLATTREE | |
| 2221 | + select OF_EARLY_FLATTREE | |
| 2222 | 2222 | help |
| 2223 | 2223 | Include support for flattened device tree machine descriptions. |
| 2224 | 2224 | |
| @@ -116,7 +116,7 @@ config PPC · 115 unmodified lines | ||
| 116 | 116 | bool |
| 117 | 117 | default y |
| 118 | 118 | select OF |
| 119 | − select OF_FLATTREE | |
| 119 | + select OF_EARLY_FLATTREE | |
| 120 | 120 | select HAVE_FTRACE_MCOUNT_RECORD |
| 121 | 121 | select HAVE_DYNAMIC_FTRACE |
| 122 | 122 | select HAVE_FUNCTION_TRACER |
| @@ -35,7 +35,7 @@ endif · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj) |
| 37 | 37 | |
| 38 | −DTS_FLAGS ?= -p 1024 | |
| 38 | +DTC_FLAGS ?= -p 1024 | |
| 39 | 39 | |
| 40 | 40 | $(obj)/4xx.o: BOOTCFLAGS += -mcpu=405 |
| 41 | 41 | $(obj)/ebony.o: BOOTCFLAGS += -mcpu=405 |
| @@ -332,10 +332,8 @@ $(obj)/treeImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) · 290 unmodified lines | ||
| 332 | 332 | $(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb) |
| 333 | 333 | |
| 334 | 334 | # 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) | |
| 339 | 337 | |
| 340 | 338 | # If there isn't a platform selected then just strip the vmlinux. |
| 341 | 339 | ifeq (,$(image-y)) |
| @@ -33,7 +33,7 @@ · 32 unmodified lines | ||
| 33 | 33 | aliases { |
| 34 | 34 | ethernet0 = &EMAC0; |
| 35 | 35 | serial0 = &UART0; |
| 36 | − serial1 = &UART1; | |
| 36 | + //serial1 = &UART1; --gcl missing UART1 label | |
| 37 | 37 | }; |
| 38 | 38 | |
| 39 | 39 | cpus { |
| @@ -52,7 +52,7 @@ · 12 unmodified lines | ||
| 52 | 52 | d-cache-size = <32768>; |
| 53 | 53 | dcr-controller; |
| 54 | 54 | dcr-access-method = "native"; |
| 55 | − next-level-cache = <&L2C0>; | |
| 55 | + //next-level-cache = <&L2C0>; --gcl missing L2C0 label | |
| 56 | 56 | }; |
| 57 | 57 | }; |
| 58 | 58 | |
| @@ -142,7 +142,7 @@ · 83 unmodified lines | ||
| 142 | 142 | /*RXEOB*/ 0x7 0x4 |
| 143 | 143 | /*SERR*/ 0x3 0x4 |
| 144 | 144 | /*TXDE*/ 0x4 0x4 |
| 145 | − /*RXDE*/ 0x5 0x4 | |
| 145 | + /*RXDE*/ 0x5 0x4>; | |
| 146 | 146 | }; |
| 147 | 147 | |
| 148 | 148 | POB0: opb { |
| @@ -182,7 +182,7 @@ · 33 unmodified lines | ||
| 182 | 182 | reg = <0x001a0000 0x00060000>; |
| 183 | 183 | }; |
| 184 | 184 | }; |
| 185 | − } | |
| 185 | + }; | |
| 186 | 186 | |
| 187 | 187 | UART0: serial@ef600300 { |
| 188 | 188 | device_type = "serial"; |
| @@ -10,220 +10,74 @@ · 9 unmodified lines | ||
| 10 | 10 | * option) any later version. |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | −/dts-v1/; | |
| 13 | +/include/ "mpc5200b.dtsi" | |
| 14 | 14 | |
| 15 | 15 | / { |
| 16 | 16 | model = "schindler,cm5200"; |
| 17 | 17 | 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 | − }; | |
| 43 | 18 | |
| 44 | 19 | 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 | − | |
| 66 | 20 | timer@600 { // General Purpose Timer |
| 67 | − compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; | |
| 68 | − reg = <0x600 0x10>; | |
| 69 | − interrupts = <1 9 0>; | |
| 70 | 21 | fsl,has-wdt; |
| 71 | 22 | }; |
| 72 | 23 | |
| 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"; | |
| 113 | 26 | }; |
| 114 | 27 | |
| 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"; | |
| 119 | 30 | }; |
| 120 | 31 | |
| 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"; | |
| 156 | 34 | }; |
| 157 | 35 | |
| 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"; | |
| 161 | 38 | }; |
| 162 | 39 | |
| 163 | − serial@2000 { // PSC1 | |
| 40 | + psc@2400 { // PSC3 | |
| 164 | 41 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 165 | − reg = <0x2000 0x100>; | |
| 166 | − interrupts = <2 1 0>; | |
| 167 | 42 | }; |
| 168 | 43 | |
| 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"; | |
| 173 | 46 | }; |
| 174 | 47 | |
| 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"; | |
| 179 | 50 | }; |
| 180 | 51 | |
| 181 | − serial@2c00 { // PSC6 | |
| 52 | + psc@2c00 { // PSC6 | |
| 182 | 53 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 183 | − reg = <0x2c00 0x100>; | |
| 184 | − interrupts = <2 4 0>; | |
| 185 | 54 | }; |
| 186 | 55 | |
| 187 | 56 | 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>; | |
| 192 | 57 | phy-handle = <&phy0>; |
| 193 | 58 | }; |
| 194 | 59 | |
| 195 | 60 | 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 | − | |
| 202 | 61 | phy0: ethernet-phy@0 { |
| 203 | 62 | reg = <0>; |
| 204 | 63 | }; |
| 205 | 64 | }; |
| 206 | 65 | |
| 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"; | |
| 213 | 68 | }; |
| 214 | 69 | |
| 215 | − sram@8000 { | |
| 216 | − compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram"; | |
| 217 | − reg = <0x8000 0x4000>; | |
| 70 | + i2c@3d00 { | |
| 71 | + status = "disabled"; | |
| 218 | 72 | }; |
| 73 | + | |
| 219 | 74 | }; |
| 220 | 75 | |
| 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 | + }; | |
| 226 | 79 | |
| 80 | + localbus { | |
| 227 | 81 | // 16-bit flash device at LocalPlus Bus CS0 |
| 228 | 82 | flash@0,0 { |
| 229 | 83 | compatible = "cfi-flash"; |
| @@ -11,195 +11,68 @@ · 10 unmodified lines | ||
| 11 | 11 | * option) any later version. |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | −/dts-v1/; | |
| 14 | +/include/ "mpc5200b.dtsi" | |
| 15 | 15 | |
| 16 | 16 | / { |
| 17 | 17 | model = "intercontrol,digsy-mtc"; |
| 18 | 18 | 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 | − }; | |
| 39 | 19 | |
| 40 | 20 | memory { |
| 41 | − device_type = "memory"; | |
| 42 | 21 | reg = <0x00000000 0x02000000>; // 32MB |
| 43 | 22 | }; |
| 44 | 23 | |
| 45 | 24 | 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 | 25 | timer@600 { // General Purpose Timer |
| 68 | − compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; | |
| 69 | − reg = <0x600 0x10>; | |
| 70 | − interrupts = <1 9 0>; | |
| 71 | 26 | fsl,has-wdt; |
| 72 | 27 | }; |
| 73 | 28 | |
| 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"; | |
| 102 | 31 | }; |
| 103 | 32 | |
| 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"; | |
| 108 | 35 | }; |
| 109 | 36 | |
| 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"; | |
| 114 | 39 | }; |
| 115 | 40 | |
| 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"; | |
| 122 | 43 | }; |
| 123 | 44 | |
| 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"; | |
| 130 | 47 | }; |
| 131 | 48 | |
| 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"; | |
| 136 | 51 | }; |
| 137 | 52 | |
| 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"; | |
| 156 | 55 | }; |
| 157 | 56 | |
| 158 | − serial@2600 { // PSC4 | |
| 57 | + psc@2800 { // PSC5 | |
| 159 | 58 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 160 | − reg = <0x2600 0x100>; | |
| 161 | − interrupts = <2 11 0>; | |
| 162 | 59 | }; |
| 163 | 60 | |
| 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"; | |
| 168 | 63 | }; |
| 169 | 64 | |
| 170 | 65 | 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>; | |
| 175 | 66 | phy-handle = <&phy0>; |
| 176 | 67 | }; |
| 177 | 68 | |
| 178 | 69 | 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 | − | |
| 185 | 70 | phy0: ethernet-phy@0 { |
| 186 | 71 | reg = <0>; |
| 187 | 72 | }; |
| 188 | 73 | }; |
| 189 | 74 | |
| 190 | − ata@3a00 { | |
| 191 | − compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata"; | |
| 192 | − reg = <0x3a00 0x100>; | |
| 193 | − interrupts = <2 7 0>; | |
| 194 | − }; | |
| 195 | − | |
| 196 | 75 | 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 | − | |
| 203 | 76 | rtc@50 { |
| 204 | 77 | compatible = "at,24c08"; |
| 205 | 78 | reg = <0x50>; |
| @@ -211,16 +84,16 @@ · 5 unmodified lines | ||
| 211 | 84 | }; |
| 212 | 85 | }; |
| 213 | 86 | |
| 214 | − sram@8000 { | |
| 215 | − compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram"; | |
| 216 | − reg = <0x8000 0x4000>; | |
| 87 | + i2c@3d40 { | |
| 88 | + status = "disabled"; | |
| 217 | 89 | }; |
| 218 | 90 | }; |
| 219 | 91 | |
| 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 { | |
| 224 | 97 | ranges = <0 0 0xff000000 0x1000000>; |
| 225 | 98 | |
| 226 | 99 | // 16-bit flash device at LocalPlus Bus CS0 |
| @@ -117,6 +117,8 @@ · 116 unmodified lines | ||
| 117 | 117 | }; |
| 118 | 118 | |
| 119 | 119 | IIC: i2c@ef600500 { |
| 120 | + #address-cells = <1>; | |
| 121 | + #size-cells = <0>; | |
| 120 | 122 | compatible = "ibm,iic-405ep", "ibm,iic"; |
| 121 | 123 | reg = <0xef600500 0x00000011>; |
| 122 | 124 | interrupt-parent = <&UIC0>; |
| @@ -10,256 +10,75 @@ · 9 unmodified lines | ||
| 10 | 10 | * option) any later version. |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | −/dts-v1/; | |
| 13 | +/include/ "mpc5200b.dtsi" | |
| 14 | 14 | |
| 15 | 15 | / { |
| 16 | 16 | model = "fsl,lite5200b"; |
| 17 | 17 | 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 | − }; | |
| 38 | 18 | |
| 39 | 19 | memory { |
| 40 | − device_type = "memory"; | |
| 41 | 20 | reg = <0x00000000 0x10000000>; // 256MB |
| 42 | 21 | }; |
| 43 | 22 | |
| 44 | 23 | 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 | − | |
| 66 | 24 | timer@600 { // General Purpose Timer |
| 67 | − compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; | |
| 68 | − reg = <0x600 0x10>; | |
| 69 | − interrupts = <1 9 0>; | |
| 70 | 25 | fsl,has-wdt; |
| 71 | 26 | }; |
| 72 | 27 | |
| 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>; | |
| 147 | 31 | }; |
| 148 | 32 | |
| 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"; | |
| 153 | 35 | }; |
| 154 | 36 | |
| 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"; | |
| 159 | 39 | }; |
| 160 | 40 | |
| 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"; | |
| 168 | 43 | }; |
| 169 | 44 | |
| 170 | − xlb@1f00 { | |
| 171 | − compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb"; | |
| 172 | − reg = <0x1f00 0x100>; | |
| 45 | + psc@2800 { // PSC5 | |
| 46 | + status = "disabled"; | |
| 173 | 47 | }; |
| 174 | 48 | |
| 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"; | |
| 180 | 51 | }; |
| 181 | 52 | |
| 182 | 53 | // PSC2 in ac97 mode example |
| 183 | 54 | //ac97@2200 { // PSC2 |
| 184 | 55 | // compatible = "fsl,mpc5200b-psc-ac97","fsl,mpc5200-psc-ac97"; |
| 185 | 56 | // cell-index = <1>; |
| 186 | − // reg = <0x2200 0x100>; | |
| 187 | − // interrupts = <2 2 0>; | |
| 188 | 57 | //}; |
| 189 | 58 | |
| 190 | 59 | // PSC3 in CODEC mode example |
| 191 | 60 | //i2s@2400 { // PSC3 |
| 192 | 61 | // compatible = "fsl,mpc5200b-psc-i2s"; //not 5200 compatible |
| 193 | 62 | // 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>; | |
| 212 | 63 | //}; |
| 213 | 64 | |
| 214 | 65 | // PSC6 in spi mode example |
| 215 | 66 | //spi@2c00 { // PSC6 |
| 216 | 67 | // compatible = "fsl,mpc5200b-psc-spi","fsl,mpc5200-psc-spi"; |
| 217 | 68 | // cell-index = <5>; |
| 218 | − // reg = <0x2c00 0x100>; | |
| 219 | − // interrupts = <2 4 0>; | |
| 220 | 69 | //}; |
| 221 | 70 | |
| 222 | 71 | 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>; | |
| 227 | 72 | phy-handle = <&phy0>; |
| 228 | 73 | }; |
| 229 | 74 | |
| 230 | 75 | 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 | − | |
| 237 | 76 | phy0: ethernet-phy@0 { |
| 238 | 77 | reg = <0>; |
| 239 | 78 | }; |
| 240 | 79 | }; |
| 241 | 80 | |
| 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 | − | |
| 256 | 81 | 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 | − | |
| 263 | 82 | eeprom@50 { |
| 264 | 83 | compatible = "atmel,24c02"; |
| 265 | 84 | reg = <0x50>; |
| @@ -273,12 +92,6 @@ · 7 unmodified lines | ||
| 273 | 92 | }; |
| 274 | 93 | |
| 275 | 94 | 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>; | |
| 282 | 95 | interrupt-map-mask = <0xf800 0 0 7>; |
| 283 | 96 | interrupt-map = <0xc000 0 0 1 &mpc5200_pic 0 0 3 // 1st slot |
| 284 | 97 | 0xc000 0 0 2 &mpc5200_pic 1 1 3 |
| @@ -298,11 +111,6 @@ · 13 unmodified lines | ||
| 298 | 111 | }; |
| 299 | 112 | |
| 300 | 113 | localbus { |
| 301 | − compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus"; | |
| 302 | − | |
| 303 | − #address-cells = <2>; | |
| 304 | − #size-cells = <1>; | |
| 305 | − | |
| 306 | 114 | ranges = <0 0 0xfe000000 0x02000000>; |
| 307 | 115 | |
| 308 | 116 | flash@0,0 { |
| @@ -11,14 +11,11 @@ · 10 unmodified lines | ||
| 11 | 11 | * option) any later version. |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | −/dts-v1/; | |
| 14 | +/include/ "mpc5200b.dtsi" | |
| 15 | 15 | |
| 16 | 16 | / { |
| 17 | 17 | model = "fsl,media5200"; |
| 18 | 18 | compatible = "fsl,media5200"; |
| 19 | − #address-cells = <1>; | |
| 20 | − #size-cells = <1>; | |
| 21 | − interrupt-parent = <&mpc5200_pic>; | |
| 22 | 19 | |
| 23 | 20 | aliases { |
| 24 | 21 | console = &console; |
| @@ -30,16 +27,7 @@ · 5 unmodified lines | ||
| 30 | 27 | }; |
| 31 | 28 | |
| 32 | 29 | cpus { |
| 33 | − #address-cells = <1>; | |
| 34 | − #size-cells = <0>; | |
| 35 | − | |
| 36 | 30 | 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 | |
| 43 | 31 | timebase-frequency = <33000000>; // 33 MHz, these were configured by U-Boot |
| 44 | 32 | bus-frequency = <132000000>; // 132 MHz |
| 45 | 33 | clock-frequency = <396000000>; // 396 MHz |
| @@ -47,205 +35,57 @@ · 1 unmodified line | ||
| 47 | 35 | }; |
| 48 | 36 | |
| 49 | 37 | memory { |
| 50 | − device_type = "memory"; | |
| 51 | 38 | reg = <0x00000000 0x08000000>; // 128MB RAM |
| 52 | 39 | }; |
| 53 | 40 | |
| 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 { | |
| 60 | 42 | 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 | − }; | |
| 75 | 43 | |
| 76 | 44 | timer@600 { // General Purpose Timer |
| 77 | − compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; | |
| 78 | − reg = <0x600 0x10>; | |
| 79 | − interrupts = <1 9 0>; | |
| 80 | 45 | fsl,has-wdt; |
| 81 | 46 | }; |
| 82 | 47 | |
| 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"; | |
| 135 | 50 | }; |
| 136 | 51 | |
| 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"; | |
| 141 | 54 | }; |
| 142 | 55 | |
| 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"; | |
| 149 | 58 | }; |
| 150 | 59 | |
| 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"; | |
| 157 | 62 | }; |
| 158 | 63 | |
| 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"; | |
| 183 | 66 | }; |
| 184 | 67 | |
| 185 | 68 | // PSC6 in uart mode |
| 186 | − console: serial@2c00 { // PSC6 | |
| 69 | + console: psc@2c00 { // PSC6 | |
| 187 | 70 | 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>; | |
| 192 | 71 | }; |
| 193 | 72 | |
| 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 { | |
| 199 | 74 | phy-handle = <&phy0>; |
| 200 | 75 | }; |
| 201 | 76 | |
| 202 | 77 | 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 | − | |
| 209 | 78 | phy0: ethernet-phy@0 { |
| 210 | 79 | reg = <0>; |
| 211 | 80 | }; |
| 212 | 81 | }; |
| 213 | 82 | |
| 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>; | |
| 239 | 85 | }; |
| 240 | 86 | }; |
| 241 | 87 | |
| 242 | 88 | 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>; | |
| 249 | 89 | interrupt-map-mask = <0xf800 0 0 7>; |
| 250 | 90 | interrupt-map = <0xc000 0 0 1 &media5200_fpga 0 2 // 1st slot |
| 251 | 91 | 0xc000 0 0 2 &media5200_fpga 0 3 |
| @@ -262,37 +102,29 @@ · 10 unmodified lines | ||
| 262 | 102 | |
| 263 | 103 | 0xe000 0 0 1 &media5200_fpga 0 5 // CoralIP |
| 264 | 104 | >; |
| 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>; | |
| 269 | 105 | ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000 |
| 270 | 106 | 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000 |
| 271 | 107 | 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>; |
| 108 | + interrupt-parent = <&mpc5200_pic>; | |
| 272 | 109 | }; |
| 273 | 110 | |
| 274 | 111 | localbus { |
| 275 | − compatible = "fsl,mpc5200b-lpb","simple-bus"; | |
| 276 | − #address-cells = <2>; | |
| 277 | − #size-cells = <1>; | |
| 278 | − | |
| 279 | 112 | ranges = < 0 0 0xfc000000 0x02000000 |
| 280 | 113 | 1 0 0xfe000000 0x02000000 |
| 281 | 114 | 2 0 0xf0010000 0x00010000 |
| 282 | 115 | 3 0 0xf0020000 0x00010000 >; |
| 283 | − | |
| 284 | 116 | flash@0,0 { |
| 285 | 117 | 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 | |
| 289 | 121 | }; |
| 290 | 122 | |
| 291 | 123 | flash@1,0 { |
| 292 | 124 | 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 | |
| 296 | 128 | }; |
| 297 | 129 | |
| 298 | 130 | media5200_fpga: fpga@2,0 { |
| @@ -10,219 +10,73 @@ · 9 unmodified lines | ||
| 10 | 10 | * option) any later version. |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | −/dts-v1/; | |
| 13 | +/include/ "mpc5200b.dtsi" | |
| 14 | 14 | |
| 15 | 15 | / { |
| 16 | 16 | model = "promess,motionpro"; |
| 17 | 17 | 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 | − }; | |
| 43 | 18 | |
| 44 | 19 | 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 | − | |
| 66 | 20 | timer@600 { // General Purpose Timer |
| 67 | − compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; | |
| 68 | − reg = <0x600 0x10>; | |
| 69 | − interrupts = <1 9 0>; | |
| 70 | 21 | fsl,has-wdt; |
| 71 | 22 | }; |
| 72 | 23 | |
| 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 | |
| 104 | 25 | compatible = "promess,motionpro-led"; |
| 105 | 26 | label = "motionpro-statusled"; |
| 106 | − reg = <0x660 0x10>; | |
| 107 | − interrupts = <1 15 0>; | |
| 108 | 27 | blink-delay = <100>; // 100 msec |
| 109 | 28 | }; |
| 110 | 29 | |
| 111 | − motionpro-led@670 { // Motion-PRO ready LED | |
| 30 | + timer@670 { // Motion-PRO ready LED | |
| 112 | 31 | compatible = "promess,motionpro-led"; |
| 113 | 32 | 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>; | |
| 128 | 33 | }; |
| 129 | 34 | |
| 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"; | |
| 136 | 37 | }; |
| 137 | 38 | |
| 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"; | |
| 150 | 41 | }; |
| 151 | 42 | |
| 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>; | |
| 156 | 47 | }; |
| 157 | 48 | |
| 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"; | |
| 165 | 51 | }; |
| 166 | 52 | |
| 167 | − xlb@1f00 { | |
| 168 | − compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb"; | |
| 169 | − reg = <0x1f00 0x100>; | |
| 53 | + psc@2600 { // PSC4 | |
| 54 | + status = "disabled"; | |
| 170 | 55 | }; |
| 171 | 56 | |
| 172 | − serial@2000 { // PSC1 | |
| 57 | + psc@2800 { // PSC5 | |
| 173 | 58 | 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>; | |
| 184 | 59 | }; |
| 185 | 60 | |
| 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"; | |
| 191 | 63 | }; |
| 192 | 64 | |
| 193 | 65 | 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>; | |
| 198 | 66 | phy-handle = <&phy0>; |
| 199 | 67 | }; |
| 200 | 68 | |
| 201 | 69 | 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 | − | |
| 208 | 70 | phy0: ethernet-phy@2 { |
| 209 | 71 | reg = <2>; |
| 210 | 72 | }; |
| 211 | 73 | }; |
| 212 | 74 | |
| 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"; | |
| 217 | 77 | }; |
| 218 | 78 | |
| 219 | 79 | 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 | − | |
| 226 | 80 | rtc@68 { |
| 227 | 81 | compatible = "dallas,ds1339"; |
| 228 | 82 | reg = <0x68>; |
| @@ -235,10 +89,11 @@ · 6 unmodified lines | ||
| 235 | 89 | }; |
| 236 | 90 | }; |
| 237 | 91 | |
| 92 | + pci@f0000d00 { | |
| 93 | + status = "disabled"; | |
| 94 | + }; | |
| 95 | + | |
| 238 | 96 | localbus { |
| 239 | − compatible = "fsl,mpc5200b-lpb","simple-bus"; | |
| 240 | − #address-cells = <2>; | |
| 241 | − #size-cells = <1>; | |
| 242 | 97 | ranges = <0 0 0xff000000 0x01000000 |
| 243 | 98 | 1 0 0x50000000 0x00010000 |
| 244 | 99 | 2 0 0x50010000 0x00010000 |
| @@ -280,5 +135,6 @@ · 35 unmodified lines | ||
| 280 | 135 | #size-cells = <1>; |
| 281 | 136 | #address-cells = <1>; |
| 282 | 137 | }; |
| 138 | + | |
| 283 | 139 | }; |
| 284 | 140 | }; |
| @@ -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 | +}; | |
| @@ -11,172 +11,109 @@ · 10 unmodified lines | ||
| 11 | 11 | * option) any later version. |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | −/dts-v1/; | |
| 14 | +/include/ "mpc5200b.dtsi" | |
| 15 | 15 | |
| 16 | 16 | / { |
| 17 | 17 | model = "manroland,mucmc52"; |
| 18 | 18 | 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 | − }; | |
| 44 | 19 | |
| 45 | 20 | 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 | 21 | 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>; | |
| 71 | 22 | gpio-controller; |
| 72 | 23 | #gpio-cells = <2>; |
| 73 | 24 | }; |
| 74 | 25 | |
| 75 | 26 | 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>; | |
| 79 | 27 | gpio-controller; |
| 80 | 28 | #gpio-cells = <2>; |
| 81 | 29 | }; |
| 82 | 30 | |
| 83 | 31 | 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>; | |
| 87 | 32 | gpio-controller; |
| 88 | 33 | #gpio-cells = <2>; |
| 89 | 34 | }; |
| 90 | 35 | |
| 91 | 36 | 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>; | |
| 95 | 37 | gpio-controller; |
| 96 | 38 | #gpio-cells = <2>; |
| 97 | 39 | }; |
| 98 | 40 | |
| 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"; | |
| 105 | 43 | }; |
| 106 | 44 | |
| 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"; | |
| 113 | 55 | }; |
| 114 | 56 | |
| 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"; | |
| 122 | 59 | }; |
| 123 | 60 | |
| 124 | − xlb@1f00 { | |
| 125 | − compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb"; | |
| 126 | − reg = <0x1f00 0x100>; | |
| 61 | + can@900 { | |
| 62 | + status = "disabled"; | |
| 127 | 63 | }; |
| 128 | 64 | |
| 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 | |
| 130 | 78 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 131 | − reg = <0x2000 0x100>; | |
| 132 | − interrupts = <2 1 0>; | |
| 133 | 79 | }; |
| 134 | 80 | |
| 135 | − serial@2200 { /* PSC2 in UART mode */ | |
| 81 | + psc@2200 { // PSC2 | |
| 136 | 82 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 137 | − reg = <0x2200 0x100>; | |
| 138 | − interrupts = <2 2 0>; | |
| 139 | 83 | }; |
| 140 | 84 | |
| 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 | |
| 142 | 98 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 143 | − reg = <0x2c00 0x100>; | |
| 144 | − interrupts = <2 4 0>; | |
| 145 | 99 | }; |
| 146 | 100 | |
| 147 | 101 | 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>; | |
| 152 | 102 | phy-handle = <&phy0>; |
| 153 | 103 | }; |
| 154 | 104 | |
| 155 | 105 | 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 | − | |
| 162 | 106 | phy0: ethernet-phy@0 { |
| 163 | 107 | compatible = "intel,lxt971"; |
| 164 | 108 | reg = <0>; |
| 165 | 109 | }; |
| 166 | 110 | }; |
| 167 | 111 | |
| 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"; | |
| 172 | 114 | }; |
| 173 | 115 | |
| 174 | 116 | 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>; | |
| 180 | 117 | hwmon@2c { |
| 181 | 118 | compatible = "ad,adm9240"; |
| 182 | 119 | reg = <0x2c>; |
| @@ -186,20 +123,9 @@ · 3 unmodified lines | ||
| 186 | 123 | reg = <0x51>; |
| 187 | 124 | }; |
| 188 | 125 | }; |
| 189 | − | |
| 190 | − sram@8000 { | |
| 191 | − compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram"; | |
| 192 | − reg = <0x8000 0x4000>; | |
| 193 | − }; | |
| 194 | 126 | }; |
| 195 | 127 | |
| 196 | 128 | 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>; | |
| 203 | 129 | interrupt-map-mask = <0xf800 0 0 7>; |
| 204 | 130 | interrupt-map = < |
| 205 | 131 | /* IDSEL 0x10 */ |
| @@ -208,20 +134,12 @@ · 2 unmodified lines | ||
| 208 | 134 | 0x8000 0 0 3 &mpc5200_pic 0 2 3 |
| 209 | 135 | 0x8000 0 0 4 &mpc5200_pic 0 1 3 |
| 210 | 136 | >; |
| 211 | − clock-frequency = <0>; // From boot loader | |
| 212 | − interrupts = <2 8 0 2 9 0 2 10 0>; | |
| 213 | − bus-range = <0 0>; | |
| 214 | 137 | ranges = <0x42000000 0 0x60000000 0x60000000 0 0x10000000 |
| 215 | 138 | 0x02000000 0 0x90000000 0x90000000 0 0x10000000 |
| 216 | 139 | 0x01000000 0 0x00000000 0xa0000000 0 0x01000000>; |
| 217 | 140 | }; |
| 218 | 141 | |
| 219 | 142 | localbus { |
| 220 | − compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus"; | |
| 221 | − | |
| 222 | − #address-cells = <2>; | |
| 223 | − #size-cells = <1>; | |
| 224 | − | |
| 225 | 143 | ranges = <0 0 0xff800000 0x00800000 |
| 226 | 144 | 1 0 0x80000000 0x00800000 |
| 227 | 145 | 3 0 0x80000000 0x00800000>; |
| @@ -12,246 +12,92 @@ · 11 unmodified lines | ||
| 12 | 12 | * option) any later version. |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | −/dts-v1/; | |
| 15 | +/include/ "mpc5200b.dtsi" | |
| 16 | 16 | |
| 17 | 17 | / { |
| 18 | 18 | model = "phytec,pcm030"; |
| 19 | 19 | 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 | − }; | |
| 45 | 20 | |
| 46 | 21 | 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 | |
| 71 | 23 | fsl,has-wdt; |
| 72 | 24 | }; |
| 73 | 25 | |
| 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 | 26 | gpt2: timer@620 { // General Purpose Timer in GPIO mode |
| 81 | 27 | compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio"; |
| 82 | − reg = <0x620 0x10>; | |
| 83 | − interrupts = <1 11 0>; | |
| 84 | 28 | gpio-controller; |
| 85 | 29 | #gpio-cells = <2>; |
| 86 | 30 | }; |
| 87 | 31 | |
| 88 | 32 | gpt3: timer@630 { // General Purpose Timer in GPIO mode |
| 89 | 33 | compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio"; |
| 90 | − reg = <0x630 0x10>; | |
| 91 | − interrupts = <1 12 0>; | |
| 92 | 34 | gpio-controller; |
| 93 | 35 | #gpio-cells = <2>; |
| 94 | 36 | }; |
| 95 | 37 | |
| 96 | 38 | gpt4: timer@640 { // General Purpose Timer in GPIO mode |
| 97 | 39 | compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio"; |
| 98 | − reg = <0x640 0x10>; | |
| 99 | − interrupts = <1 13 0>; | |
| 100 | 40 | gpio-controller; |
| 101 | 41 | #gpio-cells = <2>; |
| 102 | 42 | }; |
| 103 | 43 | |
| 104 | 44 | gpt5: timer@650 { // General Purpose Timer in GPIO mode |
| 105 | 45 | compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio"; |
| 106 | − reg = <0x650 0x10>; | |
| 107 | − interrupts = <1 14 0>; | |
| 108 | 46 | gpio-controller; |
| 109 | 47 | #gpio-cells = <2>; |
| 110 | 48 | }; |
| 111 | 49 | |
| 112 | 50 | gpt6: timer@660 { // General Purpose Timer in GPIO mode |
| 113 | 51 | compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio"; |
| 114 | − reg = <0x660 0x10>; | |
| 115 | − interrupts = <1 15 0>; | |
| 116 | 52 | gpio-controller; |
| 117 | 53 | #gpio-cells = <2>; |
| 118 | 54 | }; |
| 119 | 55 | |
| 120 | 56 | gpt7: timer@670 { // General Purpose Timer in GPIO mode |
| 121 | 57 | 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>; | |
| 150 | 58 | gpio-controller; |
| 151 | 59 | #gpio-cells = <2>; |
| 152 | 60 | }; |
| 153 | 61 | |
| 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 */ | |
| 189 | 63 | compatible = "mpc5200b-psc-ac97","fsl,mpc5200b-psc-ac97"; |
| 190 | 64 | cell-index = <0>; |
| 191 | − reg = <0x2000 0x100>; | |
| 192 | − interrupts = <2 1 0>; | |
| 193 | 65 | }; |
| 194 | 66 | |
| 195 | 67 | /* PSC2 port is used by CAN1/2 */ |
| 68 | + psc@2200 { | |
| 69 | + status = "disabled"; | |
| 70 | + }; | |
| 196 | 71 | |
| 197 | − serial@2400 { /* PSC3 in UART mode */ | |
| 72 | + psc@2400 { /* PSC3 in UART mode */ | |
| 198 | 73 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 199 | − cell-index = <2>; | |
| 200 | − reg = <0x2400 0x100>; | |
| 201 | − interrupts = <2 3 0>; | |
| 202 | 74 | }; |
| 203 | 75 | |
| 204 | 76 | /* PSC4 is ??? */ |
| 77 | + psc@2600 { | |
| 78 | + status = "disabled"; | |
| 79 | + }; | |
| 205 | 80 | |
| 206 | 81 | /* PSC5 is ??? */ |
| 82 | + psc@2800 { | |
| 83 | + status = "disabled"; | |
| 84 | + }; | |
| 207 | 85 | |
| 208 | − serial@2c00 { /* PSC6 in UART mode */ | |
| 86 | + psc@2c00 { /* PSC6 in UART mode */ | |
| 209 | 87 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 210 | − cell-index = <5>; | |
| 211 | − reg = <0x2c00 0x100>; | |
| 212 | − interrupts = <2 4 0>; | |
| 213 | 88 | }; |
| 214 | 89 | |
| 215 | 90 | 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>; | |
| 220 | 91 | phy-handle = <&phy0>; |
| 221 | 92 | }; |
| 222 | 93 | |
| 223 | 94 | 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 | − | |
| 230 | 95 | phy0: ethernet-phy@0 { |
| 231 | 96 | reg = <0>; |
| 232 | 97 | }; |
| 233 | 98 | }; |
| 234 | 99 | |
| 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 | − | |
| 249 | 100 | 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>; | |
| 255 | 101 | rtc@51 { |
| 256 | 102 | compatible = "nxp,pcf8563"; |
| 257 | 103 | reg = <0x51>; |
| @@ -259,6 +105,7 @@ · 1 unmodified line | ||
| 259 | 105 | eeprom@52 { |
| 260 | 106 | compatible = "catalyst,24c32"; |
| 261 | 107 | reg = <0x52>; |
| 108 | + pagesize = <32>; | |
| 262 | 109 | }; |
| 263 | 110 | }; |
| 264 | 111 | |
| @@ -269,12 +116,6 @@ · 4 unmodified lines | ||
| 269 | 116 | }; |
| 270 | 117 | |
| 271 | 118 | 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>; | |
| 278 | 119 | interrupt-map-mask = <0xf800 0 0 7>; |
| 279 | 120 | interrupt-map = <0xc000 0 0 1 &mpc5200_pic 0 0 3 // 1st slot |
| 280 | 121 | 0xc000 0 0 2 &mpc5200_pic 1 1 3 |
| @@ -285,11 +126,12 @@ · 4 unmodified lines | ||
| 285 | 126 | 0xc800 0 0 2 &mpc5200_pic 1 2 3 |
| 286 | 127 | 0xc800 0 0 3 &mpc5200_pic 1 3 3 |
| 287 | 128 | 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>; | |
| 291 | 129 | ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000 |
| 292 | 130 | 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000 |
| 293 | 131 | 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>; |
| 294 | 132 | }; |
| 133 | + | |
| 134 | + localbus { | |
| 135 | + status = "disabled"; | |
| 136 | + }; | |
| 295 | 137 | }; |
| @@ -12,99 +12,37 @@ · 11 unmodified lines | ||
| 12 | 12 | * option) any later version. |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | −/dts-v1/; | |
| 15 | +/include/ "mpc5200b.dtsi" | |
| 16 | 16 | |
| 17 | 17 | / { |
| 18 | 18 | model = "phytec,pcm032"; |
| 19 | 19 | 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 | − }; | |
| 40 | 20 | |
| 41 | 21 | memory { |
| 42 | − device_type = "memory"; | |
| 43 | 22 | reg = <0x00000000 0x08000000>; // 128MB |
| 44 | 23 | }; |
| 45 | 24 | |
| 46 | 25 | 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 | |
| 71 | 27 | fsl,has-wdt; |
| 72 | 28 | }; |
| 73 | 29 | |
| 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 | 30 | 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>; | |
| 84 | 31 | gpio-controller; |
| 85 | 32 | #gpio-cells = <2>; |
| 86 | 33 | }; |
| 87 | 34 | |
| 88 | 35 | 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>; | |
| 92 | 36 | gpio-controller; |
| 93 | 37 | #gpio-cells = <2>; |
| 94 | 38 | }; |
| 95 | 39 | |
| 96 | 40 | 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>; | |
| 100 | 41 | gpio-controller; |
| 101 | 42 | #gpio-cells = <2>; |
| 102 | 43 | }; |
| 103 | 44 | |
| 104 | 45 | 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>; | |
| 108 | 46 | gpio-controller; |
| 109 | 47 | #gpio-cells = <2>; |
| 110 | 48 | }; |
| @@ -118,163 +56,62 @@ · 7 unmodified lines | ||
| 118 | 56 | }; |
| 119 | 57 | |
| 120 | 58 | 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>; | |
| 124 | 59 | gpio-controller; |
| 125 | 60 | #gpio-cells = <2>; |
| 126 | 61 | }; |
| 127 | 62 | |
| 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 */ | |
| 189 | 64 | compatible = "fsl,mpc5200b-psc-ac97","fsl,mpc5200-psc-ac97"; |
| 190 | 65 | cell-index = <0>; |
| 191 | − reg = <0x2000 0x100>; | |
| 192 | − interrupts = <2 1 0>; | |
| 193 | 66 | }; |
| 194 | 67 | |
| 195 | 68 | /* PSC2 port is used by CAN1/2 */ |
| 69 | + psc@2200 { | |
| 70 | + status = "disabled"; | |
| 71 | + }; | |
| 196 | 72 | |
| 197 | − serial@2400 { /* PSC3 in UART mode */ | |
| 73 | + psc@2400 { /* PSC3 in UART mode */ | |
| 198 | 74 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 199 | − cell-index = <2>; | |
| 200 | − reg = <0x2400 0x100>; | |
| 201 | − interrupts = <2 3 0>; | |
| 202 | 75 | }; |
| 203 | 76 | |
| 204 | 77 | /* PSC4 is ??? */ |
| 78 | + psc@2600 { | |
| 79 | + status = "disabled"; | |
| 80 | + }; | |
| 205 | 81 | |
| 206 | 82 | /* PSC5 is ??? */ |
| 83 | + psc@2800 { | |
| 84 | + status = "disabled"; | |
| 85 | + }; | |
| 207 | 86 | |
| 208 | − serial@2c00 { /* PSC6 in UART mode */ | |
| 87 | + psc@2c00 { /* PSC6 in UART mode */ | |
| 209 | 88 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 210 | − cell-index = <5>; | |
| 211 | − reg = <0x2c00 0x100>; | |
| 212 | − interrupts = <2 4 0>; | |
| 213 | 89 | }; |
| 214 | 90 | |
| 215 | 91 | 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>; | |
| 220 | 92 | phy-handle = <&phy0>; |
| 221 | 93 | }; |
| 222 | 94 | |
| 223 | 95 | 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 | − | |
| 230 | 96 | phy0: ethernet-phy@0 { |
| 231 | 97 | reg = <0>; |
| 232 | 98 | }; |
| 233 | 99 | }; |
| 234 | 100 | |
| 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 | − | |
| 249 | 101 | 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>; | |
| 255 | 102 | rtc@51 { |
| 256 | 103 | compatible = "nxp,pcf8563"; |
| 257 | 104 | reg = <0x51>; |
| 258 | 105 | }; |
| 259 | 106 | eeprom@52 { |
| 260 | − compatible = "at24,24c32"; | |
| 107 | + compatible = "catalyst,24c32"; | |
| 261 | 108 | reg = <0x52>; |
| 109 | + pagesize = <32>; | |
| 262 | 110 | }; |
| 263 | 111 | }; |
| 264 | − | |
| 265 | − sram@8000 { | |
| 266 | − compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram"; | |
| 267 | − reg = <0x8000 0x4000>; | |
| 268 | − }; | |
| 269 | 112 | }; |
| 270 | 113 | |
| 271 | 114 | 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>; | |
| 278 | 115 | interrupt-map-mask = <0xf800 0 0 7>; |
| 279 | 116 | interrupt-map = <0xc000 0 0 1 &mpc5200_pic 0 0 3 // 1st slot |
| 280 | 117 | 0xc000 0 0 2 &mpc5200_pic 1 1 3 |
| @@ -285,20 +122,12 @@ · 4 unmodified lines | ||
| 285 | 122 | 0xc800 0 0 2 &mpc5200_pic 1 2 3 |
| 286 | 123 | 0xc800 0 0 3 &mpc5200_pic 1 3 3 |
| 287 | 124 | 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>; | |
| 291 | 125 | ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000 |
| 292 | 126 | 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000 |
| 293 | 127 | 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>; |
| 294 | 128 | }; |
| 295 | 129 | |
| 296 | 130 | localbus { |
| 297 | − compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus"; | |
| 298 | − | |
| 299 | − #address-cells = <2>; | |
| 300 | − #size-cells = <1>; | |
| 301 | − | |
| 302 | 131 | ranges = <0 0 0xfe000000 0x02000000 |
| 303 | 132 | 1 0 0xfc000000 0x02000000 |
| 304 | 133 | 2 0 0xfbe00000 0x00200000 |
| @@ -351,40 +180,39 @@ · 46 unmodified lines | ||
| 351 | 180 | bank-width = <2>; |
| 352 | 181 | }; |
| 353 | 182 | |
| 354 | − /* | |
| 183 | + /* | |
| 355 | 184 | * example snippets for FPGA |
| 356 | 185 | * |
| 357 | 186 | * 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>; | |
| 361 | 190 | * }; |
| 362 | 191 | * |
| 363 | 192 | * 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>; | |
| 367 | 196 | * }; |
| 368 | − */ | |
| 197 | + */ | |
| 369 | 198 | |
| 370 | − /* | |
| 199 | + /* | |
| 371 | 200 | * example snippets for free chipselects |
| 372 | − * | |
| 201 | + * | |
| 373 | 202 | * device@5,0 { |
| 374 | − * compatible = "custom_driver"; | |
| 375 | − * reg = <5 0 0x02000000>; | |
| 203 | + * compatible = "custom_driver"; | |
| 204 | + * reg = <5 0 0x02000000>; | |
| 376 | 205 | * }; |
| 377 | − * | |
| 206 | + * | |
| 378 | 207 | * device@6,0 { |
| 379 | − * compatible = "custom_driver"; | |
| 380 | − * reg = <6 0 0x02000000>; | |
| 208 | + * compatible = "custom_driver"; | |
| 209 | + * reg = <6 0 0x02000000>; | |
| 381 | 210 | * }; |
| 382 | − * | |
| 211 | + * | |
| 383 | 212 | * device@7,0 { |
| 384 | − * compatible = "custom_driver"; | |
| 385 | − * reg = <7 0 0x02000000>; | |
| 213 | + * compatible = "custom_driver"; | |
| 214 | + * reg = <7 0 0x02000000>; | |
| 386 | 215 | * }; |
| 387 | − */ | |
| 216 | + */ | |
| 388 | 217 | }; |
| 389 | 218 | }; |
| 390 | − | |
| @@ -11,79 +11,24 @@ · 10 unmodified lines | ||
| 11 | 11 | * option) any later version. |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | −/dts-v1/; | |
| 14 | +/include/ "mpc5200b.dtsi" | |
| 15 | 15 | |
| 16 | 16 | / { |
| 17 | 17 | model = "manroland,uc101"; |
| 18 | 18 | 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 | − }; | |
| 44 | 19 | |
| 45 | 20 | 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 | 21 | 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>; | |
| 71 | 22 | gpio-controller; |
| 72 | 23 | #gpio-cells = <2>; |
| 73 | 24 | }; |
| 74 | 25 | |
| 75 | 26 | 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>; | |
| 79 | 27 | gpio-controller; |
| 80 | 28 | #gpio-cells = <2>; |
| 81 | 29 | }; |
| 82 | 30 | |
| 83 | 31 | 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>; | |
| 87 | 32 | gpio-controller; |
| 88 | 33 | #gpio-cells = <2>; |
| 89 | 34 | }; |
| @@ -97,118 +42,85 @@ · 7 unmodified lines | ||
| 97 | 42 | }; |
| 98 | 43 | |
| 99 | 44 | 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>; | |
| 103 | 45 | gpio-controller; |
| 104 | 46 | #gpio-cells = <2>; |
| 105 | 47 | }; |
| 106 | 48 | |
| 107 | 49 | 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>; | |
| 111 | 50 | gpio-controller; |
| 112 | 51 | #gpio-cells = <2>; |
| 113 | 52 | }; |
| 114 | 53 | |
| 115 | 54 | 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>; | |
| 119 | 55 | gpio-controller; |
| 120 | 56 | #gpio-cells = <2>; |
| 121 | 57 | }; |
| 122 | 58 | |
| 123 | 59 | 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>; | |
| 127 | 60 | gpio-controller; |
| 128 | 61 | #gpio-cells = <2>; |
| 129 | 62 | }; |
| 130 | 63 | |
| 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"; | |
| 137 | 66 | }; |
| 138 | 67 | |
| 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"; | |
| 145 | 74 | }; |
| 146 | 75 | |
| 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"; | |
| 154 | 78 | }; |
| 155 | 79 | |
| 156 | − xlb@1f00 { | |
| 157 | − compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb"; | |
| 158 | − reg = <0x1f00 0x100>; | |
| 80 | + usb@1000 { | |
| 81 | + status = "disabled"; | |
| 159 | 82 | }; |
| 160 | 83 | |
| 161 | − serial@2000 { /* PSC1 in UART mode */ | |
| 84 | + psc@2000 { // PSC1 | |
| 162 | 85 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 163 | − reg = <0x2000 0x100>; | |
| 164 | − interrupts = <2 1 0>; | |
| 165 | 86 | }; |
| 166 | 87 | |
| 167 | − serial@2200 { /* PSC2 in UART mode */ | |
| 88 | + psc@2200 { // PSC2 | |
| 168 | 89 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 169 | − reg = <0x2200 0x100>; | |
| 170 | − interrupts = <2 2 0>; | |
| 171 | 90 | }; |
| 172 | 91 | |
| 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 | |
| 174 | 105 | compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; |
| 175 | − reg = <0x2c00 0x100>; | |
| 176 | − interrupts = <2 4 0>; | |
| 177 | 106 | }; |
| 178 | 107 | |
| 179 | 108 | 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>; | |
| 184 | 109 | phy-handle = <&phy0>; |
| 185 | 110 | }; |
| 186 | 111 | |
| 187 | 112 | 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 | − | |
| 194 | 113 | phy0: ethernet-phy@0 { |
| 195 | 114 | compatible = "intel,lxt971"; |
| 196 | 115 | reg = <0>; |
| 197 | 116 | }; |
| 198 | 117 | }; |
| 199 | 118 | |
| 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"; | |
| 204 | 121 | }; |
| 205 | 122 | |
| 206 | 123 | 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>; | |
| 212 | 124 | fsl,preserve-clocking; |
| 213 | 125 | clock-frequency = <400000>; |
| 214 | 126 | |
| @@ -221,19 +133,13 @@ · 6 unmodified lines | ||
| 221 | 133 | reg = <0x51>; |
| 222 | 134 | }; |
| 223 | 135 | }; |
| 136 | + }; | |
| 224 | 137 | |
| 225 | − sram@8000 { | |
| 226 | − compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram"; | |
| 227 | − reg = <0x8000 0x4000>; | |
| 228 | − }; | |
| 138 | + pci@f0000d00 { | |
| 139 | + status = "disabled"; | |
| 229 | 140 | }; |
| 230 | 141 | |
| 231 | 142 | localbus { |
| 232 | − compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus"; | |
| 233 | − | |
| 234 | − #address-cells = <2>; | |
| 235 | − #size-cells = <1>; | |
| 236 | − | |
| 237 | 143 | ranges = <0 0 0xff800000 0x00800000 |
| 238 | 144 | 1 0 0x80000000 0x00800000 |
| 239 | 145 | 3 0 0x80000000 0x00800000>; |
| @@ -42,7 +42,7 @@ extern void pci_create_OF_bus_map(void); · 41 unmodified lines | ||
| 42 | 42 | |
| 43 | 43 | /* Translate a DMA address from device space to CPU space */ |
| 44 | 44 | extern u64 of_translate_dma_address(struct device_node *dev, |
| 45 | − const u32 *in_addr); | |
| 45 | + const __be32 *in_addr); | |
| 46 | 46 | |
| 47 | 47 | #ifdef CONFIG_PCI |
| 48 | 48 | 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 | ||
| 63 | 63 | /* cache lookup */ |
| 64 | 64 | struct device_node *of_find_next_cache_node(struct device_node *np); |
| 65 | 65 | |
| 66 | −/* Get the MAC address */ | |
| 67 | −extern const void *of_get_mac_address(struct device_node *np); | |
| 68 | − | |
| 69 | 66 | #ifdef CONFIG_NUMA |
| 70 | 67 | extern int of_node_to_nid(struct device_node *device); |
| 71 | 68 | #else |
| @@ -117,41 +117,3 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, · 116 unmodified lines | ||
| 117 | 117 | cells = prop ? *(u32 *)prop : of_n_size_cells(dn); |
| 118 | 118 | *size = of_read_number(dma_window, cells); |
| 119 | 119 | } |
| 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); | |
| @@ -50,7 +50,7 @@ machine_device_initcall(ppc40x_simple, ppc40x_device_probe); · 49 unmodified lines | ||
| 50 | 50 | * Again, if your board needs to do things differently then create a |
| 51 | 51 | * board.c file for it rather than adding it to this list. |
| 52 | 52 | */ |
| 53 | −static char *board[] __initdata = { | |
| 53 | +static const char *board[] __initdata = { | |
| 54 | 54 | "amcc,acadia", |
| 55 | 55 | "amcc,haleakala", |
| 56 | 56 | "amcc,kilauea", |
| @@ -60,14 +60,9 @@ static char *board[] __initdata = { · 3 unmodified lines | ||
| 60 | 60 | |
| 61 | 61 | static int __init ppc40x_probe(void) |
| 62 | 62 | { |
| 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; | |
| 71 | 66 | } |
| 72 | 67 | |
| 73 | 68 | return 0; |
| @@ -26,7 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | /* |
| 27 | 27 | * list of supported boards |
| 28 | 28 | */ |
| 29 | −static char *board[] __initdata = { | |
| 29 | +static const char *board[] __initdata = { | |
| 30 | 30 | "prt,prtlvt", |
| 31 | 31 | NULL |
| 32 | 32 | }; |
| @@ -36,16 +36,7 @@ static char *board[] __initdata = { · 3 unmodified lines | ||
| 36 | 36 | */ |
| 37 | 37 | static int __init mpc5121_generic_probe(void) |
| 38 | 38 | { |
| 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); | |
| 49 | 40 | } |
| 50 | 41 | |
| 51 | 42 | define_machine(mpc5121_generic) { |
| @@ -172,20 +172,18 @@ static void __init lite5200_setup_arch(void) · 171 unmodified lines | ||
| 172 | 172 | mpc52xx_setup_pci(); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | +static const char *board[] __initdata = { | |
| 176 | + "fsl,lite5200", | |
| 177 | + "fsl,lite5200b", | |
| 178 | + NULL, | |
| 179 | +}; | |
| 180 | + | |
| 175 | 181 | /* |
| 176 | 182 | * Called very early, MMU is off, device-tree isn't unflattened |
| 177 | 183 | */ |
| 178 | 184 | static int __init lite5200_probe(void) |
| 179 | 185 | { |
| 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); | |
| 189 | 187 | } |
| 190 | 188 | |
| 191 | 189 | define_machine(lite5200) { |
| @@ -239,7 +239,7 @@ static void __init media5200_setup_arch(void) · 238 unmodified lines | ||
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /* list of the supported boards */ |
| 242 | −static char *board[] __initdata = { | |
| 242 | +static const char *board[] __initdata = { | |
| 243 | 243 | "fsl,media5200", |
| 244 | 244 | NULL |
| 245 | 245 | }; |
| @@ -249,16 +249,7 @@ static char *board[] __initdata = { · 3 unmodified lines | ||
| 249 | 249 | */ |
| 250 | 250 | static int __init media5200_probe(void) |
| 251 | 251 | { |
| 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); | |
| 262 | 253 | } |
| 263 | 254 | |
| 264 | 255 | define_machine(media5200_platform) { |
| @@ -49,7 +49,7 @@ static void __init mpc5200_simple_setup_arch(void) · 48 unmodified lines | ||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /* list of the supported boards */ |
| 52 | −static char *board[] __initdata = { | |
| 52 | +static const char *board[] __initdata = { | |
| 53 | 53 | "intercontrol,digsy-mtc", |
| 54 | 54 | "manroland,mucmc52", |
| 55 | 55 | "manroland,uc101", |
| @@ -66,16 +66,7 @@ static char *board[] __initdata = { · 10 unmodified lines | ||
| 66 | 66 | */ |
| 67 | 67 | static int __init mpc5200_simple_probe(void) |
| 68 | 68 | { |
| 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); | |
| 79 | 70 | } |
| 80 | 71 | |
| 81 | 72 | define_machine(mpc5200_simple_platform) { |
| @@ -57,16 +57,19 @@ static void __init mpc830x_rdb_init_IRQ(void) · 56 unmodified lines | ||
| 57 | 57 | ipic_set_default_priority(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | +struct const char *board[] __initdata = { | |
| 61 | + "MPC8308RDB", | |
| 62 | + "fsl,mpc8308rdb", | |
| 63 | + "denx,mpc8308_p1m", | |
| 64 | + NULL | |
| 65 | +} | |
| 66 | + | |
| 60 | 67 | /* |
| 61 | 68 | * Called very early, MMU is off, device-tree isn't unflattened |
| 62 | 69 | */ |
| 63 | 70 | static int __init mpc830x_rdb_probe(void) |
| 64 | 71 | { |
| 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); | |
| 70 | 73 | } |
| 71 | 74 | |
| 72 | 75 | static struct of_device_id __initdata of_bus_ids[] = { |
| @@ -60,15 +60,18 @@ static void __init mpc831x_rdb_init_IRQ(void) · 59 unmodified lines | ||
| 60 | 60 | ipic_set_default_priority(); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | +struct const char *board[] __initdata = { | |
| 64 | + "MPC8313ERDB", | |
| 65 | + "fsl,mpc8315erdb", | |
| 66 | + NULL | |
| 67 | +} | |
| 68 | + | |
| 63 | 69 | /* |
| 64 | 70 | * Called very early, MMU is off, device-tree isn't unflattened |
| 65 | 71 | */ |
| 66 | 72 | static int __init mpc831x_rdb_probe(void) |
| 67 | 73 | { |
| 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); | |
| 72 | 75 | } |
| 73 | 76 | |
| 74 | 77 | static struct of_device_id __initdata of_bus_ids[] = { |
| @@ -101,17 +101,20 @@ static void __init mpc837x_rdb_init_IRQ(void) · 100 unmodified lines | ||
| 101 | 101 | ipic_set_default_priority(); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | +static const char *board[] __initdata = { | |
| 105 | + "fsl,mpc8377rdb", | |
| 106 | + "fsl,mpc8378rdb", | |
| 107 | + "fsl,mpc8379rdb", | |
| 108 | + "fsl,mpc8377wlan", | |
| 109 | + NULL | |
| 110 | +}; | |
| 111 | + | |
| 104 | 112 | /* |
| 105 | 113 | * Called very early, MMU is off, device-tree isn't unflattened |
| 106 | 114 | */ |
| 107 | 115 | static int __init mpc837x_rdb_probe(void) |
| 108 | 116 | { |
| 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); | |
| 115 | 118 | } |
| 116 | 119 | |
| 117 | 120 | define_machine(mpc837x_rdb) { |
| @@ -186,21 +186,21 @@ static int __init declare_of_platform_devices(void) · 185 unmodified lines | ||
| 186 | 186 | } |
| 187 | 187 | machine_device_initcall(tqm85xx, declare_of_platform_devices); |
| 188 | 188 | |
| 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 | + | |
| 189 | 198 | /* |
| 190 | 199 | * Called very early, device-tree isn't unflattened |
| 191 | 200 | */ |
| 192 | 201 | static int __init tqm85xx_probe(void) |
| 193 | 202 | { |
| 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); | |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | define_machine(tqm85xx) { |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 16 | 16 | #include <linux/mv643xx.h> |
| 17 | 17 | #include <linux/platform_device.h> |
| 18 | 18 | #include <linux/of_platform.h> |
| 19 | +#include <linux/of_net.h> | |
| 19 | 20 | #include <linux/dma-mapping.h> |
| 20 | 21 | |
| 21 | 22 | #include <asm/prom.h> |
| @@ -19,6 +19,7 @@ · 18 unmodified lines | ||
| 19 | 19 | #include <linux/module.h> |
| 20 | 20 | #include <linux/device.h> |
| 21 | 21 | #include <linux/platform_device.h> |
| 22 | +#include <linux/of_net.h> | |
| 22 | 23 | #include <asm/tsi108.h> |
| 23 | 24 | |
| 24 | 25 | #include <asm/system.h> |
| @@ -121,7 +121,7 @@ void __init auxio_power_probe(void) · 120 unmodified lines | ||
| 121 | 121 | node = prom_searchsiblings(node, "obio"); |
| 122 | 122 | node = prom_getchild(node); |
| 123 | 123 | node = prom_searchsiblings(node, "power"); |
| 124 | − if (node == 0 || node == -1) | |
| 124 | + if (node == 0 || (s32)node == -1) | |
| 125 | 125 | return; |
| 126 | 126 | |
| 127 | 127 | /* Map the power control register. */ |
| @@ -24,7 +24,7 @@ int this_is_starfire = 0; · 23 unmodified lines | ||
| 24 | 24 | void check_if_starfire(void) |
| 25 | 25 | { |
| 26 | 26 | phandle ssnode = prom_finddevice("/ssp-serial"); |
| 27 | − if (ssnode != 0 && ssnode != -1) | |
| 27 | + if (ssnode != 0 && (s32)ssnode != -1) | |
| 28 | 28 | this_is_starfire = 1; |
| 29 | 29 | } |
| 30 | 30 | |
| @@ -60,7 +60,7 @@ void __init prom_init(struct linux_romvec *rp) · 59 unmodified lines | ||
| 60 | 60 | prom_nodeops = romvec->pv_nodeops; |
| 61 | 61 | |
| 62 | 62 | 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)) | |
| 64 | 64 | prom_halt(); |
| 65 | 65 | |
| 66 | 66 | if((((unsigned long) prom_nodeops) == 0) || |
| @@ -35,13 +35,13 @@ void __init prom_init(void *cif_handler, void *cif_stack) · 34 unmodified lines | ||
| 35 | 35 | prom_cif_init(cif_handler, cif_stack); |
| 36 | 36 | |
| 37 | 37 | 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) | |
| 39 | 39 | prom_halt(); |
| 40 | 40 | |
| 41 | 41 | prom_stdout = prom_getint(prom_chosen_node, "stdout"); |
| 42 | 42 | |
| 43 | 43 | node = prom_finddevice("/openprom"); |
| 44 | − if (!node || node == -1) | |
| 44 | + if (!node || (s32)node == -1) | |
| 45 | 45 | prom_halt(); |
| 46 | 46 | |
| 47 | 47 | prom_getstring(node, "version", prom_version, sizeof(prom_version)); |
| @@ -40,11 +40,11 @@ phandle prom_getchild(phandle node) · 39 unmodified lines | ||
| 40 | 40 | { |
| 41 | 41 | phandle cnode; |
| 42 | 42 | |
| 43 | − if (node == -1) | |
| 43 | + if ((s32)node == -1) | |
| 44 | 44 | return 0; |
| 45 | 45 | |
| 46 | 46 | cnode = __prom_getchild(node); |
| 47 | − if (cnode == 0 || cnode == -1) | |
| 47 | + if (cnode == 0 || (s32)cnode == -1) | |
| 48 | 48 | return 0; |
| 49 | 49 | |
| 50 | 50 | return cnode; |
| @@ -72,11 +72,11 @@ phandle prom_getsibling(phandle node) · 21 unmodified lines | ||
| 72 | 72 | { |
| 73 | 73 | phandle sibnode; |
| 74 | 74 | |
| 75 | − if (node == -1) | |
| 75 | + if ((s32)node == -1) | |
| 76 | 76 | return 0; |
| 77 | 77 | |
| 78 | 78 | sibnode = __prom_getsibling(node); |
| 79 | − if (sibnode == 0 || sibnode == -1) | |
| 79 | + if (sibnode == 0 || (s32)sibnode == -1) | |
| 80 | 80 | return 0; |
| 81 | 81 | |
| 82 | 82 | return sibnode; |
| @@ -219,7 +219,7 @@ static char *__prom_nextprop(phandle node, char * oprop) · 136 unmodified lines | ||
| 219 | 219 | */ |
| 220 | 220 | char *prom_nextprop(phandle node, char *oprop, char *buffer) |
| 221 | 221 | { |
| 222 | − if (node == 0 || node == -1) | |
| 222 | + if (node == 0 || (s32)node == -1) | |
| 223 | 223 | return ""; |
| 224 | 224 | |
| 225 | 225 | return __prom_nextprop(node, oprop); |
| @@ -253,7 +253,7 @@ phandle prom_finddevice(char *name) · 27 unmodified lines | ||
| 253 | 253 | if (d != s + 3 && (!*d || *d == '/') |
| 254 | 254 | && d <= s + 3 + 8) { |
| 255 | 255 | node2 = node; |
| 256 | − while (node2 && node2 != -1) { | |
| 256 | + while (node2 && (s32)node2 != -1) { | |
| 257 | 257 | if (prom_getproperty (node2, "reg", (char *)reg, sizeof (reg)) > 0) { |
| 258 | 258 | if (which_io == reg[0].which_io && phys_addr == reg[0].phys_addr) { |
| 259 | 259 | node = node2; |
| @@ -261,7 +261,7 @@ phandle prom_finddevice(char *name) · 1 unmodified line | ||
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | node2 = prom_getsibling(node2); |
| 264 | − if (!node2 || node2 == -1) | |
| 264 | + if (!node2 || (s32)node2 == -1) | |
| 265 | 265 | break; |
| 266 | 266 | node2 = prom_searchsiblings(prom_getsibling(node2), nbuf); |
| 267 | 267 | } |
| @@ -303,6 +303,7 @@ phandle prom_inst2pkg(int inst) · 35 unmodified lines | ||
| 303 | 303 | node = (*romvec->pv_v2devops.v2_inst2pkg)(inst); |
| 304 | 304 | restore_current(); |
| 305 | 305 | spin_unlock_irqrestore(&prom_lock, flags); |
| 306 | − if (node == -1) return 0; | |
| 306 | + if ((s32)node == -1) | |
| 307 | + return 0; | |
| 307 | 308 | return node; |
| 308 | 309 | } |
| @@ -43,10 +43,10 @@ inline phandle prom_getchild(phandle node) · 42 unmodified lines | ||
| 43 | 43 | { |
| 44 | 44 | phandle cnode; |
| 45 | 45 | |
| 46 | − if (node == -1) | |
| 46 | + if ((s32)node == -1) | |
| 47 | 47 | return 0; |
| 48 | 48 | cnode = __prom_getchild(node); |
| 49 | − if (cnode == -1) | |
| 49 | + if ((s32)cnode == -1) | |
| 50 | 50 | return 0; |
| 51 | 51 | return cnode; |
| 52 | 52 | } |
| @@ -56,10 +56,10 @@ inline phandle prom_getparent(phandle node) · 3 unmodified lines | ||
| 56 | 56 | { |
| 57 | 57 | phandle cnode; |
| 58 | 58 | |
| 59 | − if (node == -1) | |
| 59 | + if ((s32)node == -1) | |
| 60 | 60 | return 0; |
| 61 | 61 | cnode = prom_node_to_node("parent", node); |
| 62 | − if (cnode == -1) | |
| 62 | + if ((s32)cnode == -1) | |
| 63 | 63 | return 0; |
| 64 | 64 | return cnode; |
| 65 | 65 | } |
| @@ -76,10 +76,10 @@ inline phandle prom_getsibling(phandle node) · 10 unmodified lines | ||
| 76 | 76 | { |
| 77 | 77 | phandle sibnode; |
| 78 | 78 | |
| 79 | − if (node == -1) | |
| 79 | + if ((s32)node == -1) | |
| 80 | 80 | return 0; |
| 81 | 81 | sibnode = __prom_getsibling(node); |
| 82 | − if (sibnode == -1) | |
| 82 | + if ((s32)sibnode == -1) | |
| 83 | 83 | return 0; |
| 84 | 84 | |
| 85 | 85 | return sibnode; |
| @@ -240,7 +240,7 @@ inline char *prom_firstprop(phandle node, char *buffer) · 154 unmodified lines | ||
| 240 | 240 | unsigned long args[7]; |
| 241 | 241 | |
| 242 | 242 | *buffer = 0; |
| 243 | − if (node == -1) | |
| 243 | + if ((s32)node == -1) | |
| 244 | 244 | return buffer; |
| 245 | 245 | |
| 246 | 246 | 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 | ||
| 266 | 266 | unsigned long args[7]; |
| 267 | 267 | char buf[32]; |
| 268 | 268 | |
| 269 | − if (node == -1) { | |
| 269 | + if ((s32)node == -1) { | |
| 270 | 270 | *buffer = 0; |
| 271 | 271 | return buffer; |
| 272 | 272 | } |
| @@ -369,7 +369,7 @@ inline phandle prom_inst2pkg(int inst) · 96 unmodified lines | ||
| 369 | 369 | p1275_cmd_direct(args); |
| 370 | 370 | |
| 371 | 371 | node = (int) args[4]; |
| 372 | − if (node == -1) | |
| 372 | + if ((s32)node == -1) | |
| 373 | 373 | return 0; |
| 374 | 374 | return node; |
| 375 | 375 | } |
| @@ -69,6 +69,8 @@ · 68 unmodified lines | ||
| 69 | 69 | #ifdef CONFIG_PPC_OF |
| 70 | 70 | #include <linux/of_device.h> |
| 71 | 71 | #include <linux/of_platform.h> |
| 72 | +#include <linux/of_address.h> | |
| 73 | +#include <linux/of_irq.h> | |
| 72 | 74 | #endif |
| 73 | 75 | |
| 74 | 76 | #define PFX "ipmi_si: " |
| @@ -2546,7 +2548,7 @@ static int __devinit ipmi_of_probe(struct platform_device *dev, · 2471 unmodified lines | ||
| 2546 | 2548 | { |
| 2547 | 2549 | struct smi_info *info; |
| 2548 | 2550 | struct resource resource; |
| 2549 | − const int *regsize, *regspacing, *regshift; | |
| 2551 | + const __be32 *regsize, *regspacing, *regshift; | |
| 2550 | 2552 | struct device_node *np = dev->dev.of_node; |
| 2551 | 2553 | int ret; |
| 2552 | 2554 | int proplen; |
| @@ -2599,9 +2601,9 @@ static int __devinit ipmi_of_probe(struct platform_device *dev, · 46 unmodified lines | ||
| 2599 | 2601 | |
| 2600 | 2602 | info->io.addr_data = resource.start; |
| 2601 | 2603 | |
| 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; | |
| 2605 | 2607 | |
| 2606 | 2608 | info->irq = irq_of_parse_and_map(dev->dev.of_node, 0); |
| 2607 | 2609 | info->dev = &dev->dev; |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | #include <linux/log2.h> |
| 21 | 21 | #include <linux/bitops.h> |
| 22 | 22 | #include <linux/jiffies.h> |
| 23 | +#include <linux/of.h> | |
| 23 | 24 | #include <linux/i2c.h> |
| 24 | 25 | #include <linux/i2c/at24.h> |
| 25 | 26 | |
| @@ -457,6 +458,27 @@ static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf, · 431 unmodified lines | ||
| 457 | 458 | |
| 458 | 459 | /*-------------------------------------------------------------------------*/ |
| 459 | 460 | |
| 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 | + | |
| 460 | 482 | static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) |
| 461 | 483 | { |
| 462 | 484 | 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 | ||
| 485 | 507 | */ |
| 486 | 508 | chip.page_size = 1; |
| 487 | 509 | |
| 510 | + /* update chipdata if OF is present */ | |
| 511 | + at24_get_ofdata(client, &chip); | |
| 512 | + | |
| 488 | 513 | chip.setup = NULL; |
| 489 | 514 | chip.context = NULL; |
| 490 | 515 | } |
| @@ -492,6 +517,11 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) · 1 unmodified line | ||
| 492 | 517 | if (!is_power_of_2(chip.byte_len)) |
| 493 | 518 | dev_warn(&client->dev, |
| 494 | 519 | "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 | + } | |
| 495 | 525 | if (!is_power_of_2(chip.page_size)) |
| 496 | 526 | dev_warn(&client->dev, |
| 497 | 527 | "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 | ||
| 597 | 627 | |
| 598 | 628 | i2c_set_clientdata(client, at24); |
| 599 | 629 | |
| 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", | |
| 601 | 631 | at24->bin.size, client->name, |
| 602 | − writable ? "(writable)" : "(read-only)"); | |
| 632 | + writable ? "writable" : "read-only", at24->write_max); | |
| 603 | 633 | if (use_smbus == I2C_SMBUS_WORD_DATA || |
| 604 | 634 | use_smbus == I2C_SMBUS_BYTE_DATA) { |
| 605 | 635 | dev_notice(&client->dev, "Falling back to %s reads, " |
| 606 | 636 | "performance will suffer\n", use_smbus == |
| 607 | 637 | I2C_SMBUS_WORD_DATA ? "word" : "byte"); |
| 608 | 638 | } |
| 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); | |
| 613 | 639 | |
| 614 | 640 | /* export data to kernel code */ |
| 615 | 641 | if (chip.setup) |
| @@ -660,6 +686,11 @@ static struct i2c_driver at24_driver = { · 44 unmodified lines | ||
| 660 | 686 | |
| 661 | 687 | static int __init at24_init(void) |
| 662 | 688 | { |
| 689 | + if (!io_limit) { | |
| 690 | + pr_err("at24: io_limit must not be 0!\n"); | |
| 691 | + return -EINVAL; | |
| 692 | + } | |
| 693 | + | |
| 663 | 694 | io_limit = rounddown_pow_of_two(io_limit); |
| 664 | 695 | return i2c_add_driver(&at24_driver); |
| 665 | 696 | } |
| @@ -83,7 +83,7 @@ config MMC_RICOH_MMC · 82 unmodified lines | ||
| 83 | 83 | |
| 84 | 84 | config MMC_SDHCI_OF |
| 85 | 85 | tristate "SDHCI support on OpenFirmware platforms" |
| 86 | − depends on MMC_SDHCI && PPC_OF | |
| 86 | + depends on MMC_SDHCI && OF | |
| 87 | 87 | help |
| 88 | 88 | This selects the OF support for Secure Digital Host Controller |
| 89 | 89 | Interfaces. |
| @@ -93,6 +93,7 @@ config MMC_SDHCI_OF · 3 unmodified lines | ||
| 93 | 93 | config MMC_SDHCI_OF_ESDHC |
| 94 | 94 | bool "SDHCI OF support for the Freescale eSDHC controller" |
| 95 | 95 | depends on MMC_SDHCI_OF |
| 96 | + depends on PPC_OF | |
| 96 | 97 | select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER |
| 97 | 98 | help |
| 98 | 99 | This selects the Freescale eSDHC controller support. |
| @@ -102,6 +103,7 @@ config MMC_SDHCI_OF_ESDHC · 3 unmodified lines | ||
| 102 | 103 | config MMC_SDHCI_OF_HLWD |
| 103 | 104 | bool "SDHCI OF support for the Nintendo Wii SDHCI controllers" |
| 104 | 105 | depends on MMC_SDHCI_OF |
| 106 | + depends on PPC_OF | |
| 105 | 107 | select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER |
| 106 | 108 | help |
| 107 | 109 | This selects the Secure Digital Host Controller Interface (SDHCI) |
| @@ -122,7 +122,7 @@ static int __devinit sdhci_of_probe(struct platform_device *ofdev, · 121 unmodified lines | ||
| 122 | 122 | struct sdhci_of_data *sdhci_of_data = match->data; |
| 123 | 123 | struct sdhci_host *host; |
| 124 | 124 | struct sdhci_of_host *of_host; |
| 125 | − const u32 *clk; | |
| 125 | + const __be32 *clk; | |
| 126 | 126 | int size; |
| 127 | 127 | int ret; |
| 128 | 128 | |
| @@ -166,7 +166,7 @@ static int __devinit sdhci_of_probe(struct platform_device *ofdev, · 37 unmodified lines | ||
| 166 | 166 | |
| 167 | 167 | clk = of_get_property(np, "clock-frequency", &size); |
| 168 | 168 | if (clk && size == sizeof(*clk) && *clk) |
| 169 | − of_host->clock = *clk; | |
| 169 | + of_host->clock = be32_to_cpup(clk); | |
| 170 | 170 | |
| 171 | 171 | ret = sdhci_add_host(host); |
| 172 | 172 | if (ret) |
| @@ -159,7 +159,7 @@ config MTD_AFS_PARTS · 158 unmodified lines | ||
| 159 | 159 | |
| 160 | 160 | config MTD_OF_PARTS |
| 161 | 161 | tristate "Flash partition map based on OF description" |
| 162 | − depends on (MICROBLAZE || PPC_OF) && MTD_PARTITIONS | |
| 162 | + depends on OF && MTD_PARTITIONS | |
| 163 | 163 | help |
| 164 | 164 | This provides a partition parsing function which derives |
| 165 | 165 | the partition map from the children of the flash node, |
| @@ -72,7 +72,7 @@ config MTD_PHYSMAP_BANKWIDTH · 71 unmodified lines | ||
| 72 | 72 | |
| 73 | 73 | config MTD_PHYSMAP_OF |
| 74 | 74 | 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) | |
| 76 | 76 | help |
| 77 | 77 | This provides a 'mapping' driver which allows the NOR Flash and |
| 78 | 78 | ROM driver code to communicate with chips which are mapped |
| @@ -40,6 +40,7 @@ · 39 unmodified lines | ||
| 40 | 40 | #include <linux/of_mdio.h> |
| 41 | 41 | #include <linux/of_platform.h> |
| 42 | 42 | #include <linux/of_gpio.h> |
| 43 | +#include <linux/of_net.h> | |
| 43 | 44 | |
| 44 | 45 | #include <linux/vmalloc.h> |
| 45 | 46 | #include <asm/pgtable.h> |
| @@ -95,6 +95,7 @@ · 94 unmodified lines | ||
| 95 | 95 | #include <linux/phy.h> |
| 96 | 96 | #include <linux/phy_fixed.h> |
| 97 | 97 | #include <linux/of.h> |
| 98 | +#include <linux/of_net.h> | |
| 98 | 99 | |
| 99 | 100 | #include "gianfar.h" |
| 100 | 101 | #include "fsl_pq_mdio.h" |
| @@ -28,6 +28,7 @@ · 27 unmodified lines | ||
| 28 | 28 | #include <linux/phy.h> |
| 29 | 29 | #include <linux/workqueue.h> |
| 30 | 30 | #include <linux/of_mdio.h> |
| 31 | +#include <linux/of_net.h> | |
| 31 | 32 | #include <linux/of_platform.h> |
| 32 | 33 | |
| 33 | 34 | #include <asm/uaccess.h> |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | #include <linux/of_device.h> |
| 25 | 25 | #include <linux/of_platform.h> |
| 26 | 26 | #include <linux/of_mdio.h> |
| 27 | +#include <linux/of_net.h> | |
| 27 | 28 | #include <linux/phy.h> |
| 28 | 29 | |
| 29 | 30 | #define DRIVER_NAME "xilinx_emaclite" |
| @@ -19,6 +19,10 @@ config OF_FLATTREE · 18 unmodified lines | ||
| 19 | 19 | bool |
| 20 | 20 | select DTC |
| 21 | 21 | |
| 22 | +config OF_EARLY_FLATTREE | |
| 23 | + bool | |
| 24 | + select OF_FLATTREE | |
| 25 | + | |
| 22 | 26 | config OF_PROMTREE |
| 23 | 27 | bool |
| 24 | 28 | |
| @@ -49,6 +53,10 @@ config OF_I2C · 24 unmodified lines | ||
| 49 | 53 | help |
| 50 | 54 | OpenFirmware I2C accessors |
| 51 | 55 | |
| 56 | +config OF_NET | |
| 57 | + depends on NETDEVICES | |
| 58 | + def_bool y | |
| 59 | + | |
| 52 | 60 | config OF_SPI |
| 53 | 61 | def_tristate SPI |
| 54 | 62 | depends on SPI && !SPARC |
| @@ -6,5 +6,6 @@ obj-$(CONFIG_OF_IRQ) += irq.o · 5 unmodified lines | ||
| 6 | 6 | obj-$(CONFIG_OF_DEVICE) += device.o platform.o |
| 7 | 7 | obj-$(CONFIG_OF_GPIO) += gpio.o |
| 8 | 8 | obj-$(CONFIG_OF_I2C) += of_i2c.o |
| 9 | +obj-$(CONFIG_OF_NET) += of_net.o | |
| 9 | 10 | obj-$(CONFIG_OF_SPI) += of_spi.o |
| 10 | 11 | obj-$(CONFIG_OF_MDIO) += of_mdio.o |
| @@ -12,13 +12,13 @@ · 11 unmodified lines | ||
| 12 | 12 | (ns) > 0) |
| 13 | 13 | |
| 14 | 14 | 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, | |
| 17 | 17 | struct resource *r); |
| 18 | 18 | |
| 19 | 19 | /* Debug utility */ |
| 20 | 20 | #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) | |
| 22 | 22 | { |
| 23 | 23 | printk(KERN_DEBUG "%s", s); |
| 24 | 24 | while (na--) |
| @@ -26,7 +26,7 @@ static void of_dump_addr(const char *s, const u32 *addr, int na) · 1 unmodified line | ||
| 26 | 26 | printk("\n"); |
| 27 | 27 | } |
| 28 | 28 | #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) { } | |
| 30 | 30 | #endif |
| 31 | 31 | |
| 32 | 32 | /* Callbacks for bus specific translators */ |
| @@ -36,10 +36,10 @@ struct of_bus { · 3 unmodified lines | ||
| 36 | 36 | int (*match)(struct device_node *parent); |
| 37 | 37 | void (*count_cells)(struct device_node *child, |
| 38 | 38 | int *addrc, int *sizec); |
| 39 | − u64 (*map)(u32 *addr, const u32 *range, | |
| 39 | + u64 (*map)(u32 *addr, const __be32 *range, | |
| 40 | 40 | int na, int ns, int pna); |
| 41 | 41 | int (*translate)(u32 *addr, u64 offset, int na); |
| 42 | − unsigned int (*get_flags)(const u32 *addr); | |
| 42 | + unsigned int (*get_flags)(const __be32 *addr); | |
| 43 | 43 | }; |
| 44 | 44 | |
| 45 | 45 | /* |
| @@ -55,7 +55,7 @@ static void of_bus_default_count_cells(struct device_node *dev, · 9 unmodified lines | ||
| 55 | 55 | *sizec = of_n_size_cells(dev); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | −static u64 of_bus_default_map(u32 *addr, const u32 *range, | |
| 58 | +static u64 of_bus_default_map(u32 *addr, const __be32 *range, | |
| 59 | 59 | int na, int ns, int pna) |
| 60 | 60 | { |
| 61 | 61 | u64 cp, s, da; |
| @@ -85,7 +85,7 @@ static int of_bus_default_translate(u32 *addr, u64 offset, int na) · 23 unmodified lines | ||
| 85 | 85 | return 0; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | −static unsigned int of_bus_default_get_flags(const u32 *addr) | |
| 88 | +static unsigned int of_bus_default_get_flags(const __be32 *addr) | |
| 89 | 89 | { |
| 90 | 90 | return IORESOURCE_MEM; |
| 91 | 91 | } |
| @@ -110,10 +110,10 @@ static void of_bus_pci_count_cells(struct device_node *np, · 18 unmodified lines | ||
| 110 | 110 | *sizec = 2; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | −static unsigned int of_bus_pci_get_flags(const u32 *addr) | |
| 113 | +static unsigned int of_bus_pci_get_flags(const __be32 *addr) | |
| 114 | 114 | { |
| 115 | 115 | unsigned int flags = 0; |
| 116 | − u32 w = addr[0]; | |
| 116 | + u32 w = be32_to_cpup(addr); | |
| 117 | 117 | |
| 118 | 118 | switch((w >> 24) & 0x03) { |
| 119 | 119 | case 0x01: |
| @@ -129,7 +129,8 @@ static unsigned int of_bus_pci_get_flags(const u32 *addr) · 9 unmodified lines | ||
| 129 | 129 | return flags; |
| 130 | 130 | } |
| 131 | 131 | |
| 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) | |
| 133 | 134 | { |
| 134 | 135 | u64 cp, s, da; |
| 135 | 136 | unsigned int af, rf; |
| @@ -160,7 +161,7 @@ static int of_bus_pci_translate(u32 *addr, u64 offset, int na) · 24 unmodified lines | ||
| 160 | 161 | return of_bus_default_translate(addr + 1, offset, na - 1); |
| 161 | 162 | } |
| 162 | 163 | |
| 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, | |
| 164 | 165 | unsigned int *flags) |
| 165 | 166 | { |
| 166 | 167 | const __be32 *prop; |
| @@ -207,7 +208,7 @@ EXPORT_SYMBOL(of_get_pci_address); · 40 unmodified lines | ||
| 207 | 208 | int of_pci_address_to_resource(struct device_node *dev, int bar, |
| 208 | 209 | struct resource *r) |
| 209 | 210 | { |
| 210 | − const u32 *addrp; | |
| 211 | + const __be32 *addrp; | |
| 211 | 212 | u64 size; |
| 212 | 213 | unsigned int flags; |
| 213 | 214 | |
| @@ -237,12 +238,13 @@ static void of_bus_isa_count_cells(struct device_node *child, · 23 unmodified lines | ||
| 237 | 238 | *sizec = 1; |
| 238 | 239 | } |
| 239 | 240 | |
| 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) | |
| 241 | 243 | { |
| 242 | 244 | u64 cp, s, da; |
| 243 | 245 | |
| 244 | 246 | /* Check address type match */ |
| 245 | − if ((addr[0] ^ range[0]) & 0x00000001) | |
| 247 | + if ((addr[0] ^ range[0]) & cpu_to_be32(1)) | |
| 246 | 248 | return OF_BAD_ADDR; |
| 247 | 249 | |
| 248 | 250 | /* 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 | ||
| 264 | 266 | return of_bus_default_translate(addr + 1, offset, na - 1); |
| 265 | 267 | } |
| 266 | 268 | |
| 267 | −static unsigned int of_bus_isa_get_flags(const u32 *addr) | |
| 269 | +static unsigned int of_bus_isa_get_flags(const __be32 *addr) | |
| 268 | 270 | { |
| 269 | 271 | unsigned int flags = 0; |
| 270 | − u32 w = addr[0]; | |
| 272 | + u32 w = be32_to_cpup(addr); | |
| 271 | 273 | |
| 272 | 274 | if (w & 1) |
| 273 | 275 | flags |= IORESOURCE_IO; |
| @@ -330,7 +332,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, · 56 unmodified lines | ||
| 330 | 332 | struct of_bus *pbus, u32 *addr, |
| 331 | 333 | int na, int ns, int pna, const char *rprop) |
| 332 | 334 | { |
| 333 | − const u32 *ranges; | |
| 335 | + const __be32 *ranges; | |
| 334 | 336 | unsigned int rlen; |
| 335 | 337 | int rone; |
| 336 | 338 | 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 | ||
| 398 | 400 | * that can be mapped to a cpu physical address). This is not really specified |
| 399 | 401 | * that way, but this is traditionally the way IBM at least do things |
| 400 | 402 | */ |
| 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, | |
| 402 | 404 | const char *rprop) |
| 403 | 405 | { |
| 404 | 406 | struct device_node *parent = NULL; |
| @@ -475,22 +477,22 @@ u64 __of_translate_address(struct device_node *dev, const u32 *in_addr, · 70 unmodified lines | ||
| 475 | 477 | return result; |
| 476 | 478 | } |
| 477 | 479 | |
| 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) | |
| 479 | 481 | { |
| 480 | 482 | return __of_translate_address(dev, in_addr, "ranges"); |
| 481 | 483 | } |
| 482 | 484 | EXPORT_SYMBOL(of_translate_address); |
| 483 | 485 | |
| 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) | |
| 485 | 487 | { |
| 486 | 488 | return __of_translate_address(dev, in_addr, "dma-ranges"); |
| 487 | 489 | } |
| 488 | 490 | EXPORT_SYMBOL(of_translate_dma_address); |
| 489 | 491 | |
| 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, | |
| 491 | 493 | unsigned int *flags) |
| 492 | 494 | { |
| 493 | − const u32 *prop; | |
| 495 | + const __be32 *prop; | |
| 494 | 496 | unsigned int psize; |
| 495 | 497 | struct device_node *parent; |
| 496 | 498 | struct of_bus *bus; |
| @@ -525,8 +527,8 @@ const u32 *of_get_address(struct device_node *dev, int index, u64 *size, · 28 unmodified lines | ||
| 525 | 527 | } |
| 526 | 528 | EXPORT_SYMBOL(of_get_address); |
| 527 | 529 | |
| 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, | |
| 530 | 532 | struct resource *r) |
| 531 | 533 | { |
| 532 | 534 | u64 taddr; |
| @@ -564,7 +566,7 @@ static int __of_address_to_resource(struct device_node *dev, const u32 *addrp, · 31 unmodified lines | ||
| 564 | 566 | int of_address_to_resource(struct device_node *dev, int index, |
| 565 | 567 | struct resource *r) |
| 566 | 568 | { |
| 567 | − const u32 *addrp; | |
| 569 | + const __be32 *addrp; | |
| 568 | 570 | u64 size; |
| 569 | 571 | unsigned int flags; |
| 570 | 572 | |
| @@ -11,10 +11,12 @@ · 10 unmodified lines | ||
| 11 | 11 | |
| 12 | 12 | #include <linux/kernel.h> |
| 13 | 13 | #include <linux/initrd.h> |
| 14 | +#include <linux/module.h> | |
| 14 | 15 | #include <linux/of.h> |
| 15 | 16 | #include <linux/of_fdt.h> |
| 16 | 17 | #include <linux/string.h> |
| 17 | 18 | #include <linux/errno.h> |
| 19 | +#include <linux/slab.h> | |
| 18 | 20 | |
| 19 | 21 | #ifdef CONFIG_PPC |
| 20 | 22 | #include <asm/machdep.h> |
| @@ -22,104 +24,19 @@ · 1 unmodified line | ||
| 22 | 24 | |
| 23 | 25 | #include <asm/page.h> |
| 24 | 26 | |
| 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) | |
| 31 | 28 | { |
| 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; | |
| 98 | 31 | } |
| 99 | 32 | |
| 100 | 33 | /** |
| 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 | |
| 102 | 36 | */ |
| 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) | |
| 123 | 40 | { |
| 124 | 41 | unsigned long p = node; |
| 125 | 42 | |
| @@ -137,10 +54,10 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name, · 11 unmodified lines | ||
| 137 | 54 | sz = be32_to_cpup((__be32 *)p); |
| 138 | 55 | noff = be32_to_cpup((__be32 *)(p + 4)); |
| 139 | 56 | p += 8; |
| 140 | − if (be32_to_cpu(initial_boot_params->version) < 0x10) | |
| 57 | + if (be32_to_cpu(blob->version) < 0x10) | |
| 141 | 58 | p = ALIGN(p, sz >= 8 ? 8 : 4); |
| 142 | 59 | |
| 143 | − nstr = find_flat_dt_string(noff); | |
| 60 | + nstr = of_fdt_get_string(blob, noff); | |
| 144 | 61 | if (nstr == NULL) { |
| 145 | 62 | pr_warning("Can't find property index name !\n"); |
| 146 | 63 | return NULL; |
| @@ -156,21 +73,28 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name, · 9 unmodified lines | ||
| 156 | 73 | } |
| 157 | 74 | |
| 158 | 75 | /** |
| 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 | |
| 160 | 79 | * @node: node to test |
| 161 | 80 | * @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. | |
| 162 | 84 | */ |
| 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) | |
| 164 | 87 | { |
| 165 | 88 | const char *cp; |
| 166 | − unsigned long cplen, l; | |
| 89 | + unsigned long cplen, l, score = 0; | |
| 167 | 90 | |
| 168 | − cp = of_get_flat_dt_prop(node, "compatible", &cplen); | |
| 91 | + cp = of_fdt_get_property(blob, node, "compatible", &cplen); | |
| 169 | 92 | if (cp == NULL) |
| 170 | 93 | return 0; |
| 171 | 94 | while (cplen > 0) { |
| 95 | + score++; | |
| 172 | 96 | if (of_compat_cmp(cp, compat, strlen(compat)) == 0) |
| 173 | − return 1; | |
| 97 | + return score; | |
| 174 | 98 | l = strlen(cp) + 1; |
| 175 | 99 | cp += l; |
| 176 | 100 | cplen -= l; |
| @@ -179,7 +103,28 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) · 2 unmodified lines | ||
| 179 | 103 | return 0; |
| 180 | 104 | } |
| 181 | 105 | |
| 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, | |
| 183 | 128 | unsigned long align) |
| 184 | 129 | { |
| 185 | 130 | void *res; |
| @@ -193,16 +138,18 @@ static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size, · 7 unmodified lines | ||
| 193 | 138 | |
| 194 | 139 | /** |
| 195 | 140 | * unflatten_dt_node - Alloc and populate a device_node from the flat tree |
| 141 | + * @blob: The parent device tree blob | |
| 196 | 142 | * @p: pointer to node in flat tree |
| 197 | 143 | * @dad: Parent struct device_node |
| 198 | 144 | * @allnextpp: pointer to ->allnext from last allocated device_node |
| 199 | 145 | * @fpsize: Size of the node path up at the current depth. |
| 200 | 146 | */ |
| 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) | |
| 206 | 153 | { |
| 207 | 154 | struct device_node *np; |
| 208 | 155 | struct property *pp, **prev_pp = NULL; |
| @@ -298,10 +245,10 @@ unsigned long __init unflatten_dt_node(unsigned long mem, · 89 unmodified lines | ||
| 298 | 245 | sz = be32_to_cpup((__be32 *)(*p)); |
| 299 | 246 | noff = be32_to_cpup((__be32 *)((*p) + 4)); |
| 300 | 247 | *p += 8; |
| 301 | − if (be32_to_cpu(initial_boot_params->version) < 0x10) | |
| 248 | + if (be32_to_cpu(blob->version) < 0x10) | |
| 302 | 249 | *p = ALIGN(*p, sz >= 8 ? 8 : 4); |
| 303 | 250 | |
| 304 | − pname = find_flat_dt_string(noff); | |
| 251 | + pname = of_fdt_get_string(blob, noff); | |
| 305 | 252 | if (pname == NULL) { |
| 306 | 253 | pr_info("Can't find property name in list !\n"); |
| 307 | 254 | break; |
| @@ -380,7 +327,8 @@ unsigned long __init unflatten_dt_node(unsigned long mem, · 72 unmodified lines | ||
| 380 | 327 | if (tag == OF_DT_NOP) |
| 381 | 328 | *p += 4; |
| 382 | 329 | else |
| 383 | − mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize); | |
| 330 | + mem = unflatten_dt_node(blob, mem, p, np, allnextpp, | |
| 331 | + fpsize); | |
| 384 | 332 | tag = be32_to_cpup((__be32 *)(*p)); |
| 385 | 333 | } |
| 386 | 334 | if (tag != OF_DT_END_NODE) { |
| @@ -391,6 +339,211 @@ unsigned long __init unflatten_dt_node(unsigned long mem, · 4 unmodified lines | ||
| 391 | 339 | return mem; |
| 392 | 340 | } |
| 393 | 341 | |
| 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 | + | |
| 394 | 547 | #ifdef CONFIG_BLK_DEV_INITRD |
| 395 | 548 | /** |
| 396 | 549 | * 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 | ||
| 539 | 692 | return 1; |
| 540 | 693 | } |
| 541 | 694 | |
| 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 | + | |
| 542 | 701 | /** |
| 543 | 702 | * unflatten_device_tree - create tree of device_nodes from flat blob |
| 544 | 703 | * |
| @@ -549,58 +708,13 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, · 4 unmodified lines | ||
| 549 | 708 | */ |
| 550 | 709 | void __init unflatten_device_tree(void) |
| 551 | 710 | { |
| 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); | |
| 599 | 713 | |
| 600 | 714 | /* Get pointer to OF "/chosen" node for use everywhere */ |
| 601 | 715 | of_chosen = of_find_node_by_path("/chosen"); |
| 602 | 716 | if (of_chosen == NULL) |
| 603 | 717 | of_chosen = of_find_node_by_path("/chosen@0"); |
| 604 | − | |
| 605 | − pr_debug(" <- unflatten_device_tree()\n"); | |
| 606 | 718 | } |
| 719 | + | |
| 720 | +#endif /* CONFIG_OF_EARLY_FLATTREE */ | |
| @@ -52,27 +52,35 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) · 51 unmodified lines | ||
| 52 | 52 | |
| 53 | 53 | /* Loop over the child nodes and register a phy_device for each one */ |
| 54 | 54 | for_each_child_of_node(np, child) { |
| 55 | − const __be32 *addr; | |
| 55 | + const __be32 *paddr; | |
| 56 | + u32 addr; | |
| 56 | 57 | int len; |
| 57 | 58 | |
| 58 | 59 | /* 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)) { | |
| 61 | 62 | dev_err(&mdio->dev, "%s has invalid PHY address\n", |
| 62 | 63 | child->full_name); |
| 63 | 64 | continue; |
| 64 | 65 | } |
| 65 | 66 | |
| 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 | + | |
| 66 | 74 | 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; | |
| 70 | 78 | } |
| 71 | 79 | |
| 72 | − phy = get_phy_device(mdio, be32_to_cpup(addr)); | |
| 80 | + phy = get_phy_device(mdio, addr); | |
| 73 | 81 | if (!phy || IS_ERR(phy)) { |
| 74 | 82 | dev_err(&mdio->dev, "error probing PHY at address %i\n", |
| 75 | − *addr); | |
| 83 | + addr); | |
| 76 | 84 | continue; |
| 77 | 85 | } |
| 78 | 86 | phy_scan_fixups(phy); |
| @@ -91,7 +99,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) · 12 unmodified lines | ||
| 91 | 99 | } |
| 92 | 100 | |
| 93 | 101 | dev_dbg(&mdio->dev, "registered phy %s at address %i\n", |
| 94 | − child->name, *addr); | |
| 102 | + child->name, addr); | |
| 95 | 103 | } |
| 96 | 104 | |
| 97 | 105 | return 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); | |
| @@ -633,6 +633,9 @@ EXPORT_SYMBOL(of_device_alloc); · 632 unmodified lines | ||
| 633 | 633 | * @np: pointer to node to create device for |
| 634 | 634 | * @bus_id: name to assign device |
| 635 | 635 | * @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. | |
| 636 | 639 | */ |
| 637 | 640 | struct platform_device *of_platform_device_create(struct device_node *np, |
| 638 | 641 | const char *bus_id, |
| @@ -640,6 +643,9 @@ struct platform_device *of_platform_device_create(struct device_node *np, · 1 unmodified line | ||
| 640 | 643 | { |
| 641 | 644 | struct platform_device *dev; |
| 642 | 645 | |
| 646 | + if (!of_device_is_available(np)) | |
| 647 | + return NULL; | |
| 648 | + | |
| 643 | 649 | dev = of_device_alloc(np, bus_id, parent); |
| 644 | 650 | if (!dev) |
| 645 | 651 | return NULL; |
| @@ -683,8 +689,9 @@ static int of_platform_bus_create(const struct device_node *bus, · 37 unmodified lines | ||
| 683 | 689 | pr_debug(" create child: %s\n", child->full_name); |
| 684 | 690 | dev = of_platform_device_create(child, NULL, parent); |
| 685 | 691 | if (dev == NULL) |
| 686 | − rc = -ENOMEM; | |
| 687 | − else if (!of_match_node(matches, child)) | |
| 692 | + continue; | |
| 693 | + | |
| 694 | + if (!of_match_node(matches, child)) | |
| 688 | 695 | continue; |
| 689 | 696 | if (rc == 0) { |
| 690 | 697 | pr_debug(" and sub busses\n"); |
| @@ -733,10 +740,9 @@ int of_platform_bus_probe(struct device_node *root, · 42 unmodified lines | ||
| 733 | 740 | if (of_match_node(matches, root)) { |
| 734 | 741 | pr_debug(" root match, create all sub devices\n"); |
| 735 | 742 | dev = of_platform_device_create(root, NULL, parent); |
| 736 | − if (dev == NULL) { | |
| 737 | − rc = -ENOMEM; | |
| 743 | + if (dev == NULL) | |
| 738 | 744 | goto bail; |
| 739 | − } | |
| 745 | + | |
| 740 | 746 | pr_debug(" create all sub busses\n"); |
| 741 | 747 | rc = of_platform_bus_create(root, matches, &dev->dev); |
| 742 | 748 | goto bail; |
| @@ -748,9 +754,9 @@ int of_platform_bus_probe(struct device_node *root, · 5 unmodified lines | ||
| 748 | 754 | pr_debug(" match: %s\n", child->full_name); |
| 749 | 755 | dev = of_platform_device_create(child, NULL, parent); |
| 750 | 756 | 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); | |
| 754 | 760 | if (rc) { |
| 755 | 761 | of_node_put(child); |
| 756 | 762 | break; |
| @@ -467,7 +467,7 @@ static int jsflash_init(void) · 466 unmodified lines | ||
| 467 | 467 | |
| 468 | 468 | node = prom_getchild(prom_root_node); |
| 469 | 469 | node = prom_searchsiblings(node, "flash-memory"); |
| 470 | − if (node != 0 && node != -1) { | |
| 470 | + if (node != 0 && (s32)node != -1) { | |
| 471 | 471 | if (prom_getproperty(node, "reg", |
| 472 | 472 | (char *)®0, sizeof(reg0)) == -1) { |
| 473 | 473 | printk("jsflash: no \"reg\" property\n"); |
| @@ -1412,7 +1412,7 @@ config SERIAL_NETX_CONSOLE · 1411 unmodified lines | ||
| 1412 | 1412 | |
| 1413 | 1413 | config SERIAL_OF_PLATFORM |
| 1414 | 1414 | tristate "Serial port on Open Firmware platform bus" |
| 1415 | − depends on PPC_OF || MICROBLAZE | |
| 1415 | + depends on OF | |
| 1416 | 1416 | depends on SERIAL_8250 || SERIAL_OF_PLATFORM_NWPSERIAL |
| 1417 | 1417 | help |
| 1418 | 1418 | If you have a PowerPC based system that has serial ports |
| @@ -15,6 +15,7 @@ · 14 unmodified lines | ||
| 15 | 15 | #include <linux/serial_core.h> |
| 16 | 16 | #include <linux/serial_8250.h> |
| 17 | 17 | #include <linux/of_address.h> |
| 18 | +#include <linux/of_irq.h> | |
| 18 | 19 | #include <linux/of_platform.h> |
| 19 | 20 | #include <linux/nwpserial.h> |
| 20 | 21 | |
| @@ -67,7 +67,8 @@ · 66 unmodified lines | ||
| 67 | 67 | * Align to a 32 byte boundary equal to the |
| 68 | 68 | * alignment gcc 4.5 uses for a struct |
| 69 | 69 | */ |
| 70 | −#define STRUCT_ALIGN() . = ALIGN(32) | |
| 70 | +#define STRUCT_ALIGNMENT 32 | |
| 71 | +#define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT) | |
| 71 | 72 | |
| 72 | 73 | /* The actual configuration determine if the init/exit sections |
| 73 | 74 | * are handled as text/data or they can be discarded (which |
| @@ -146,6 +147,13 @@ · 72 unmodified lines | ||
| 146 | 147 | #define TRACE_SYSCALLS() |
| 147 | 148 | #endif |
| 148 | 149 | |
| 150 | + | |
| 151 | +#define KERNEL_DTB() \ | |
| 152 | + STRUCT_ALIGN(); \ | |
| 153 | + VMLINUX_SYMBOL(__dtb_start) = .; \ | |
| 154 | + *(.dtb.init.rodata) \ | |
| 155 | + VMLINUX_SYMBOL(__dtb_end) = .; | |
| 156 | + | |
| 149 | 157 | /* .data section */ |
| 150 | 158 | #define DATA_DATA \ |
| 151 | 159 | *(.data) \ |
| @@ -468,7 +476,8 @@ · 316 unmodified lines | ||
| 468 | 476 | MCOUNT_REC() \ |
| 469 | 477 | DEV_DISCARD(init.rodata) \ |
| 470 | 478 | CPU_DISCARD(init.rodata) \ |
| 471 | − MEM_DISCARD(init.rodata) | |
| 479 | + MEM_DISCARD(init.rodata) \ | |
| 480 | + KERNEL_DTB() | |
| 472 | 481 | |
| 473 | 482 | #define INIT_TEXT \ |
| 474 | 483 | *(.init.text) \ |
| @@ -3,7 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | #include <linux/ioport.h> |
| 4 | 4 | #include <linux/of.h> |
| 5 | 5 | |
| 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); | |
| 7 | 7 | extern int of_address_to_resource(struct device_node *dev, int index, |
| 8 | 8 | struct resource *r); |
| 9 | 9 | 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 | ||
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | #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, | |
| 25 | 25 | u64 *size, unsigned int *flags); |
| 26 | 26 | extern int of_pci_address_to_resource(struct device_node *dev, int bar, |
| 27 | 27 | struct resource *r); |
| @@ -32,7 +32,7 @@ static inline int of_pci_address_to_resource(struct device_node *dev, int bar, · 4 unmodified lines | ||
| 32 | 32 | return -ENOSYS; |
| 33 | 33 | } |
| 34 | 34 | |
| 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, | |
| 36 | 36 | int bar_no, u64 *size, unsigned int *flags) |
| 37 | 37 | { |
| 38 | 38 | return NULL; |
| @@ -58,6 +58,23 @@ struct boot_param_header { · 57 unmodified lines | ||
| 58 | 58 | }; |
| 59 | 59 | |
| 60 | 60 | #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 | + | |
| 61 | 78 | /* TBD: Temporary export of fdt globals - remove when code fully merged */ |
| 62 | 79 | extern int __initdata dt_root_addr_cells; |
| 63 | 80 | 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 | ||
| 71 | 88 | extern void *of_get_flat_dt_prop(unsigned long node, const char *name, |
| 72 | 89 | unsigned long *size); |
| 73 | 90 | 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); | |
| 74 | 92 | extern unsigned long of_get_flat_dt_root(void); |
| 75 | 93 | |
| 76 | 94 | extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, |
| @@ -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 */ | |
| @@ -200,6 +200,29 @@ quiet_cmd_gzip = GZIP $@ · 199 unmodified lines | ||
| 200 | 200 | cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \ |
| 201 | 201 | (rm -f $@ ; false) |
| 202 | 202 | |
| 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) $< | |
| 203 | 226 | |
| 204 | 227 | # Bzip2 |
| 205 | 228 | # --------------------------------------------------------------------------- |
| @@ -4,7 +4,7 @@ hostprogs-y := dtc · 3 unmodified lines | ||
| 4 | 4 | always := $(hostprogs-y) |
| 5 | 5 | |
| 6 | 6 | 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 | |
| 8 | 8 | dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o |
| 9 | 9 | |
| 10 | 10 | # 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 | ||
| 19 | 19 | HOSTCFLAGS_livetree.o := $(HOSTCFLAGS_DTC) |
| 20 | 20 | HOSTCFLAGS_srcpos.o := $(HOSTCFLAGS_DTC) |
| 21 | 21 | HOSTCFLAGS_treesource.o := $(HOSTCFLAGS_DTC) |
| 22 | +HOSTCFLAGS_util.o := $(HOSTCFLAGS_DTC) | |
| 22 | 23 | |
| 23 | 24 | HOSTCFLAGS_dtc-lexer.lex.o := $(HOSTCFLAGS_DTC) |
| 24 | 25 | HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC) |
| @@ -278,32 +278,112 @@ static void check_property_name_chars(struct check *c, struct node *dt, · 277 unmodified lines | ||
| 278 | 278 | } |
| 279 | 279 | PROP_CHECK(property_name_chars, PROPNODECHARS, ERROR); |
| 280 | 280 | |
| 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 | + | |
| 281 | 337 | static void check_explicit_phandles(struct check *c, struct node *root, |
| 282 | − struct node *node) | |
| 338 | + struct node *node, struct property *prop) | |
| 283 | 339 | { |
| 284 | − struct property *prop; | |
| 340 | + struct marker *m; | |
| 285 | 341 | struct node *other; |
| 286 | 342 | cell_t phandle; |
| 287 | 343 | |
| 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; | |
| 291 | 347 | |
| 292 | 348 | 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. */ | |
| 295 | 370 | return; |
| 296 | 371 | } |
| 297 | 372 | |
| 298 | 373 | phandle = propval_cell(prop); |
| 374 | + | |
| 299 | 375 | 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); | |
| 302 | 378 | return; |
| 303 | 379 | } |
| 304 | 380 | |
| 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 | + | |
| 305 | 385 | other = get_node_by_phandle(root, phandle); |
| 306 | − if (other) { | |
| 386 | + if (other && (other != node)) { | |
| 307 | 387 | FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)", |
| 308 | 388 | node->fullpath, phandle, other->fullpath); |
| 309 | 389 | return; |
| @@ -311,7 +391,7 @@ static void check_explicit_phandles(struct check *c, struct node *root, · 1 unmodified line | ||
| 311 | 391 | |
| 312 | 392 | node->phandle = phandle; |
| 313 | 393 | } |
| 314 | −NODE_CHECK(explicit_phandles, NULL, ERROR); | |
| 394 | +PROP_CHECK(explicit_phandles, NULL, ERROR); | |
| 315 | 395 | |
| 316 | 396 | static void check_name_properties(struct check *c, struct node *root, |
| 317 | 397 | struct node *node) |
| @@ -549,6 +629,9 @@ static struct check *check_table[] = { · 231 unmodified lines | ||
| 549 | 629 | &duplicate_node_names, &duplicate_property_names, |
| 550 | 630 | &node_name_chars, &node_name_format, &property_name_chars, |
| 551 | 631 | &name_is_string, &name_properties, |
| 632 | + | |
| 633 | + &duplicate_label, | |
| 634 | + | |
| 552 | 635 | &explicit_phandles, |
| 553 | 636 | &phandle_references, &path_references, |
| 554 | 637 | |
| @@ -18,7 +18,7 @@ · 17 unmodified lines | ||
| 18 | 18 | * USA |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | −%option noyywrap noinput nounput yylineno | |
| 21 | +%option noyywrap nounput noinput never-interactive | |
| 22 | 22 | |
| 23 | 23 | %x INCLUDE |
| 24 | 24 | %x BYTESTRING |
| @@ -38,6 +38,13 @@ LINECOMMENT "//".*\n · 13 unmodified lines | ||
| 38 | 38 | #include "srcpos.h" |
| 39 | 39 | #include "dtc-parser.tab.h" |
| 40 | 40 | |
| 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 | + } | |
| 41 | 48 | |
| 42 | 49 | /*#define LEXDEBUG 1*/ |
| 43 | 50 | |
| @@ -47,15 +54,10 @@ LINECOMMENT "//".*\n · 3 unmodified lines | ||
| 47 | 54 | #define DPRINT(fmt, ...) do { } while (0) |
| 48 | 55 | #endif |
| 49 | 56 | |
| 50 | −static int dts_version; /* = 0 */ | |
| 57 | +static int dts_version = 1; | |
| 51 | 58 | |
| 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"); \ | |
| 57 | 60 | BEGIN(V1); \ |
| 58 | − } | |
| 59 | 61 | |
| 60 | 62 | static void push_input_file(const char *filename); |
| 61 | 63 | static int pop_input_file(void); |
| @@ -75,18 +77,13 @@ static int pop_input_file(void); · 13 unmodified lines | ||
| 75 | 77 | } |
| 76 | 78 | |
| 77 | 79 | <*>{STRING} { |
| 78 | − yylloc.file = srcpos_file; | |
| 79 | − yylloc.first_line = yylineno; | |
| 80 | 80 | DPRINT("String: %s\n", yytext); |
| 81 | 81 | yylval.data = data_copy_escape_string(yytext+1, |
| 82 | 82 | yyleng-2); |
| 83 | − yylloc.first_line = yylineno; | |
| 84 | 83 | return DT_STRING; |
| 85 | 84 | } |
| 86 | 85 | |
| 87 | 86 | <*>"/dts-v1/" { |
| 88 | − yylloc.file = srcpos_file; | |
| 89 | − yylloc.first_line = yylineno; | |
| 90 | 87 | DPRINT("Keyword: /dts-v1/\n"); |
| 91 | 88 | dts_version = 1; |
| 92 | 89 | BEGIN_DEFAULT(); |
| @@ -94,106 +91,57 @@ static int pop_input_file(void); · 1 unmodified line | ||
| 94 | 91 | } |
| 95 | 92 | |
| 96 | 93 | <*>"/memreserve/" { |
| 97 | − yylloc.file = srcpos_file; | |
| 98 | − yylloc.first_line = yylineno; | |
| 99 | 94 | DPRINT("Keyword: /memreserve/\n"); |
| 100 | 95 | BEGIN_DEFAULT(); |
| 101 | 96 | return DT_MEMRESERVE; |
| 102 | 97 | } |
| 103 | 98 | |
| 104 | 99 | <*>{LABEL}: { |
| 105 | − yylloc.file = srcpos_file; | |
| 106 | − yylloc.first_line = yylineno; | |
| 107 | 100 | DPRINT("Label: %s\n", yytext); |
| 108 | − yylval.labelref = strdup(yytext); | |
| 101 | + yylval.labelref = xstrdup(yytext); | |
| 109 | 102 | yylval.labelref[yyleng-1] = '\0'; |
| 110 | 103 | return DT_LABEL; |
| 111 | 104 | } |
| 112 | 105 | |
| 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 | − | |
| 136 | 106 | <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); | |
| 140 | 108 | DPRINT("Literal: '%s'\n", yylval.literal); |
| 141 | 109 | return DT_LITERAL; |
| 142 | 110 | } |
| 143 | 111 | |
| 144 | −\&{LABEL} { /* label reference */ | |
| 145 | − yylloc.file = srcpos_file; | |
| 146 | − yylloc.first_line = yylineno; | |
| 112 | +<*>\&{LABEL} { /* label reference */ | |
| 147 | 113 | DPRINT("Ref: %s\n", yytext+1); |
| 148 | − yylval.labelref = strdup(yytext+1); | |
| 114 | + yylval.labelref = xstrdup(yytext+1); | |
| 149 | 115 | return DT_REF; |
| 150 | 116 | } |
| 151 | 117 | |
| 152 | −"&{/"{PATHCHAR}+\} { /* new-style path reference */ | |
| 153 | − yylloc.file = srcpos_file; | |
| 154 | − yylloc.first_line = yylineno; | |
| 118 | +<*>"&{/"{PATHCHAR}+\} { /* new-style path reference */ | |
| 155 | 119 | yytext[yyleng-1] = '\0'; |
| 156 | 120 | 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); | |
| 166 | 122 | return DT_REF; |
| 167 | 123 | } |
| 168 | 124 | |
| 169 | 125 | <BYTESTRING>[0-9a-fA-F]{2} { |
| 170 | − yylloc.file = srcpos_file; | |
| 171 | − yylloc.first_line = yylineno; | |
| 172 | 126 | yylval.byte = strtol(yytext, NULL, 16); |
| 173 | 127 | DPRINT("Byte: %02x\n", (int)yylval.byte); |
| 174 | 128 | return DT_BYTE; |
| 175 | 129 | } |
| 176 | 130 | |
| 177 | 131 | <BYTESTRING>"]" { |
| 178 | − yylloc.file = srcpos_file; | |
| 179 | − yylloc.first_line = yylineno; | |
| 180 | 132 | DPRINT("/BYTESTRING\n"); |
| 181 | 133 | BEGIN_DEFAULT(); |
| 182 | 134 | return ']'; |
| 183 | 135 | } |
| 184 | 136 | |
| 185 | 137 | <PROPNODENAME>{PROPNODECHAR}+ { |
| 186 | − yylloc.file = srcpos_file; | |
| 187 | − yylloc.first_line = yylineno; | |
| 188 | 138 | DPRINT("PropNodeName: %s\n", yytext); |
| 189 | − yylval.propnodename = strdup(yytext); | |
| 139 | + yylval.propnodename = xstrdup(yytext); | |
| 190 | 140 | BEGIN_DEFAULT(); |
| 191 | 141 | return DT_PROPNODENAME; |
| 192 | 142 | } |
| 193 | 143 | |
| 194 | 144 | "/incbin/" { |
| 195 | − yylloc.file = srcpos_file; | |
| 196 | − yylloc.first_line = yylineno; | |
| 197 | 145 | DPRINT("Binary Include\n"); |
| 198 | 146 | return DT_INCBIN; |
| 199 | 147 | } |
| @@ -203,8 +151,6 @@ static int pop_input_file(void); · 3 unmodified lines | ||
| 203 | 151 | <*>{LINECOMMENT}+ /* eat C++-style comments */ |
| 204 | 152 | |
| 205 | 153 | <*>. { |
| 206 | − yylloc.file = srcpos_file; | |
| 207 | − yylloc.first_line = yylineno; | |
| 208 | 154 | DPRINT("Char: %c (\\x%02x)\n", yytext[0], |
| 209 | 155 | (unsigned)yytext[0]); |
| 210 | 156 | if (yytext[0] == '[') { |
| @@ -221,100 +167,25 @@ static int pop_input_file(void); · 10 unmodified lines | ||
| 221 | 167 | |
| 222 | 168 | %% |
| 223 | 169 | |
| 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 | − | |
| 247 | 170 | static void push_input_file(const char *filename) |
| 248 | 171 | { |
| 249 | − struct incl_file *incl_file; | |
| 250 | − struct dtc_file *newfile; | |
| 251 | − struct search_path search, *searchptr = NULL; | |
| 252 | − | |
| 253 | 172 | assert(filename); |
| 254 | 173 | |
| 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); | |
| 266 | 175 | |
| 267 | − incl_file = xmalloc(sizeof(struct incl_file)); | |
| 176 | + yyin = current_srcfile->f; | |
| 268 | 177 | |
| 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)); | |
| 286 | 179 | } |
| 287 | 180 | |
| 288 | 181 | |
| 289 | 182 | static int pop_input_file(void) |
| 290 | 183 | { |
| 291 | − struct incl_file *incl_file; | |
| 292 | − | |
| 293 | − if (incl_file_stack == 0) | |
| 184 | + if (srcfile_pop() == 0) | |
| 294 | 185 | return 0; |
| 295 | 186 | |
| 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; | |
| 318 | 189 | |
| 319 | 190 | return 1; |
| 320 | 191 | } |
| @@ -170,20 +170,7 @@ extern FILE *yyin, *yyout; · 169 unmodified lines | ||
| 170 | 170 | #define EOB_ACT_END_OF_FILE 1 |
| 171 | 171 | #define EOB_ACT_LAST_MATCH 2 |
| 172 | 172 | |
| 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) | |
| 187 | 174 | |
| 188 | 175 | /* Return all but the first "n" matched characters back to the input stream. */ |
| 189 | 176 | #define yyless(n) \ |
| @@ -385,8 +372,8 @@ static void yy_fatal_error (yyconst char msg[] ); · 195 unmodified lines | ||
| 385 | 372 | *yy_cp = '\0'; \ |
| 386 | 373 | (yy_c_buf_p) = yy_cp; |
| 387 | 374 | |
| 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 | |
| 390 | 377 | /* This struct is not used in this scanner, |
| 391 | 378 | but its presence is necessary. */ |
| 392 | 379 | struct yy_trans_info |
| @@ -394,20 +381,19 @@ struct yy_trans_info · 1 unmodified line | ||
| 394 | 381 | flex_int32_t yy_verify; |
| 395 | 382 | flex_int32_t yy_nxt; |
| 396 | 383 | }; |
| 397 | −static yyconst flex_int16_t yy_accept[104] = | |
| 384 | +static yyconst flex_int16_t yy_accept[94] = | |
| 398 | 385 | { 0, |
| 399 | 386 | 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, | |
| 408 | 394 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, |
| 409 | − | |
| 410 | 395 | 0, 4, 0 |
| 396 | + | |
| 411 | 397 | } ; |
| 412 | 398 | |
| 413 | 399 | static yyconst flex_int32_t yy_ec[256] = |
| @@ -416,16 +402,16 @@ static yyconst flex_int32_t yy_ec[256] = · 2 unmodified lines | ||
| 416 | 402 | 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, |
| 417 | 403 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 418 | 404 | 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, | |
| 429 | 415 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 430 | 416 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 431 | 417 | 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 | ||
| 442 | 428 | 1, 1, 1, 1, 1 |
| 443 | 429 | } ; |
| 444 | 430 | |
| 445 | −static yyconst flex_int32_t yy_meta[36] = | |
| 431 | +static yyconst flex_int32_t yy_meta[34] = | |
| 446 | 432 | { 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 | |
| 451 | 437 | } ; |
| 452 | 438 | |
| 453 | −static yyconst flex_int16_t yy_base[117] = | |
| 439 | +static yyconst flex_int16_t yy_base[106] = | |
| 454 | 440 | { 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 | |
| 468 | 453 | } ; |
| 469 | 454 | |
| 470 | −static yyconst flex_int16_t yy_def[117] = | |
| 455 | +static yyconst flex_int16_t yy_def[106] = | |
| 471 | 456 | { 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 | |
| 485 | 469 | } ; |
| 486 | 470 | |
| 487 | −static yyconst flex_int16_t yy_nxt[339] = | |
| 471 | +static yyconst flex_int16_t yy_nxt[281] = | |
| 488 | 472 | { 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 | |
| 526 | 503 | } ; |
| 527 | 504 | |
| 528 | −static yyconst flex_int16_t yy_chk[339] = | |
| 505 | +static yyconst flex_int16_t yy_chk[281] = | |
| 529 | 506 | { 0, |
| 530 | 507 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 531 | 508 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 532 | 509 | 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, | |
| 537 | 512 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 538 | 513 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 539 | 514 | 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 | |
| 567 | 537 | } ; |
| 568 | 538 | |
| 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 | − | |
| 575 | 539 | static yy_state_type yy_last_accepting_state; |
| 576 | 540 | static char *yy_last_accepting_cpos; |
| 577 | 541 | |
| @@ -616,6 +580,13 @@ char *yytext; · 38 unmodified lines | ||
| 616 | 580 | #include "srcpos.h" |
| 617 | 581 | #include "dtc-parser.tab.h" |
| 618 | 582 | |
| 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 | + } | |
| 619 | 590 | |
| 620 | 591 | /*#define LEXDEBUG 1*/ |
| 621 | 592 | |
| @@ -625,19 +596,14 @@ char *yytext; · 3 unmodified lines | ||
| 625 | 596 | #define DPRINT(fmt, ...) do { } while (0) |
| 626 | 597 | #endif |
| 627 | 598 | |
| 628 | −static int dts_version; /* = 0 */ | |
| 599 | +static int dts_version = 1; | |
| 629 | 600 | |
| 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"); \ | |
| 635 | 602 | BEGIN(V1); \ |
| 636 | − } | |
| 637 | 603 | |
| 638 | 604 | static void push_input_file(const char *filename); |
| 639 | 605 | static int pop_input_file(void); |
| 640 | −#line 641 "dtc-lexer.lex.c" | |
| 606 | +#line 607 "dtc-lexer.lex.c" | |
| 641 | 607 | |
| 642 | 608 | #define INITIAL 0 |
| 643 | 609 | #define INCLUDE 1 |
| @@ -826,9 +792,9 @@ YY_DECL · 182 unmodified lines | ||
| 826 | 792 | register char *yy_cp, *yy_bp; |
| 827 | 793 | register int yy_act; |
| 828 | 794 | |
| 829 | −#line 64 "dtc-lexer.l" | |
| 795 | +#line 66 "dtc-lexer.l" | |
| 830 | 796 | |
| 831 | −#line 832 "dtc-lexer.lex.c" | |
| 797 | +#line 798 "dtc-lexer.lex.c" | |
| 832 | 798 | |
| 833 | 799 | if ( !(yy_init) ) |
| 834 | 800 | { |
| @@ -881,35 +847,21 @@ yy_match: · 46 unmodified lines | ||
| 881 | 847 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
| 882 | 848 | { |
| 883 | 849 | yy_current_state = (int) yy_def[yy_current_state]; |
| 884 | − if ( yy_current_state >= 104 ) | |
| 850 | + if ( yy_current_state >= 94 ) | |
| 885 | 851 | yy_c = yy_meta[(unsigned int) yy_c]; |
| 886 | 852 | } |
| 887 | 853 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; |
| 888 | 854 | ++yy_cp; |
| 889 | 855 | } |
| 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); | |
| 891 | 859 | |
| 892 | 860 | yy_find_action: |
| 893 | 861 | 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 | − } | |
| 900 | 862 | |
| 901 | 863 | YY_DO_BEFORE_ACTION; |
| 902 | 864 | |
| 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 | − | |
| 913 | 865 | do_action: /* This label is used only to access EOF actions. */ |
| 914 | 866 | |
| 915 | 867 | switch ( yy_act ) |
| @@ -924,7 +876,7 @@ do_action: /* This label is used only to access EOF actions. */ · 8 unmodified lines | ||
| 924 | 876 | case 1: |
| 925 | 877 | /* rule 1 can match eol */ |
| 926 | 878 | YY_RULE_SETUP |
| 927 | −#line 65 "dtc-lexer.l" | |
| 879 | +#line 67 "dtc-lexer.l" | |
| 928 | 880 | { |
| 929 | 881 | char *name = strchr(yytext, '\"') + 1; |
| 930 | 882 | yytext[yyleng-1] = '\0'; |
| @@ -936,7 +888,7 @@ case YY_STATE_EOF(INCLUDE): · 5 unmodified lines | ||
| 936 | 888 | case YY_STATE_EOF(BYTESTRING): |
| 937 | 889 | case YY_STATE_EOF(PROPNODENAME): |
| 938 | 890 | case YY_STATE_EOF(V1): |
| 939 | −#line 71 "dtc-lexer.l" | |
| 891 | +#line 73 "dtc-lexer.l" | |
| 940 | 892 | { |
| 941 | 893 | if (!pop_input_file()) { |
| 942 | 894 | yyterminate(); |
| @@ -946,23 +898,18 @@ case YY_STATE_EOF(V1): · 3 unmodified lines | ||
| 946 | 898 | case 2: |
| 947 | 899 | /* rule 2 can match eol */ |
| 948 | 900 | YY_RULE_SETUP |
| 949 | −#line 77 "dtc-lexer.l" | |
| 901 | +#line 79 "dtc-lexer.l" | |
| 950 | 902 | { |
| 951 | − yylloc.file = srcpos_file; | |
| 952 | − yylloc.first_line = yylineno; | |
| 953 | 903 | DPRINT("String: %s\n", yytext); |
| 954 | 904 | yylval.data = data_copy_escape_string(yytext+1, |
| 955 | 905 | yyleng-2); |
| 956 | − yylloc.first_line = yylineno; | |
| 957 | 906 | return DT_STRING; |
| 958 | 907 | } |
| 959 | 908 | YY_BREAK |
| 960 | 909 | case 3: |
| 961 | 910 | YY_RULE_SETUP |
| 962 | −#line 87 "dtc-lexer.l" | |
| 911 | +#line 86 "dtc-lexer.l" | |
| 963 | 912 | { |
| 964 | − yylloc.file = srcpos_file; | |
| 965 | − yylloc.first_line = yylineno; | |
| 966 | 913 | DPRINT("Keyword: /dts-v1/\n"); |
| 967 | 914 | dts_version = 1; |
| 968 | 915 | BEGIN_DEFAULT(); |
| @@ -971,10 +918,8 @@ YY_RULE_SETUP · 2 unmodified lines | ||
| 971 | 918 | YY_BREAK |
| 972 | 919 | case 4: |
| 973 | 920 | YY_RULE_SETUP |
| 974 | −#line 96 "dtc-lexer.l" | |
| 921 | +#line 93 "dtc-lexer.l" | |
| 975 | 922 | { |
| 976 | − yylloc.file = srcpos_file; | |
| 977 | − yylloc.first_line = yylineno; | |
| 978 | 923 | DPRINT("Keyword: /memreserve/\n"); |
| 979 | 924 | BEGIN_DEFAULT(); |
| 980 | 925 | return DT_MEMRESERVE; |
| @@ -982,158 +927,100 @@ YY_RULE_SETUP · 1 unmodified line | ||
| 982 | 927 | YY_BREAK |
| 983 | 928 | case 5: |
| 984 | 929 | YY_RULE_SETUP |
| 985 | −#line 104 "dtc-lexer.l" | |
| 930 | +#line 99 "dtc-lexer.l" | |
| 986 | 931 | { |
| 987 | − yylloc.file = srcpos_file; | |
| 988 | − yylloc.first_line = yylineno; | |
| 989 | 932 | DPRINT("Label: %s\n", yytext); |
| 990 | − yylval.labelref = strdup(yytext); | |
| 933 | + yylval.labelref = xstrdup(yytext); | |
| 991 | 934 | yylval.labelref[yyleng-1] = '\0'; |
| 992 | 935 | return DT_LABEL; |
| 993 | 936 | } |
| 994 | 937 | YY_BREAK |
| 995 | 938 | case 6: |
| 996 | 939 | 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" | |
| 1016 | 941 | { |
| 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); | |
| 1031 | 943 | DPRINT("Literal: '%s'\n", yylval.literal); |
| 1032 | 944 | return DT_LITERAL; |
| 1033 | 945 | } |
| 1034 | 946 | YY_BREAK |
| 1035 | −case 9: | |
| 947 | +case 7: | |
| 1036 | 948 | YY_RULE_SETUP |
| 1037 | −#line 144 "dtc-lexer.l" | |
| 949 | +#line 112 "dtc-lexer.l" | |
| 1038 | 950 | { /* label reference */ |
| 1039 | − yylloc.file = srcpos_file; | |
| 1040 | − yylloc.first_line = yylineno; | |
| 1041 | 951 | DPRINT("Ref: %s\n", yytext+1); |
| 1042 | − yylval.labelref = strdup(yytext+1); | |
| 952 | + yylval.labelref = xstrdup(yytext+1); | |
| 1043 | 953 | return DT_REF; |
| 1044 | 954 | } |
| 1045 | 955 | YY_BREAK |
| 1046 | −case 10: | |
| 956 | +case 8: | |
| 1047 | 957 | YY_RULE_SETUP |
| 1048 | −#line 152 "dtc-lexer.l" | |
| 958 | +#line 118 "dtc-lexer.l" | |
| 1049 | 959 | { /* new-style path reference */ |
| 1050 | − yylloc.file = srcpos_file; | |
| 1051 | − yylloc.first_line = yylineno; | |
| 1052 | 960 | yytext[yyleng-1] = '\0'; |
| 1053 | 961 | DPRINT("Ref: %s\n", yytext+2); |
| 1054 | − yylval.labelref = strdup(yytext+2); | |
| 962 | + yylval.labelref = xstrdup(yytext+2); | |
| 1055 | 963 | return DT_REF; |
| 1056 | 964 | } |
| 1057 | 965 | 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: | |
| 1070 | 967 | YY_RULE_SETUP |
| 1071 | −#line 169 "dtc-lexer.l" | |
| 968 | +#line 125 "dtc-lexer.l" | |
| 1072 | 969 | { |
| 1073 | − yylloc.file = srcpos_file; | |
| 1074 | − yylloc.first_line = yylineno; | |
| 1075 | 970 | yylval.byte = strtol(yytext, NULL, 16); |
| 1076 | 971 | DPRINT("Byte: %02x\n", (int)yylval.byte); |
| 1077 | 972 | return DT_BYTE; |
| 1078 | 973 | } |
| 1079 | 974 | YY_BREAK |
| 1080 | −case 13: | |
| 975 | +case 10: | |
| 1081 | 976 | YY_RULE_SETUP |
| 1082 | −#line 177 "dtc-lexer.l" | |
| 977 | +#line 131 "dtc-lexer.l" | |
| 1083 | 978 | { |
| 1084 | − yylloc.file = srcpos_file; | |
| 1085 | − yylloc.first_line = yylineno; | |
| 1086 | 979 | DPRINT("/BYTESTRING\n"); |
| 1087 | 980 | BEGIN_DEFAULT(); |
| 1088 | 981 | return ']'; |
| 1089 | 982 | } |
| 1090 | 983 | YY_BREAK |
| 1091 | −case 14: | |
| 984 | +case 11: | |
| 1092 | 985 | YY_RULE_SETUP |
| 1093 | −#line 185 "dtc-lexer.l" | |
| 986 | +#line 137 "dtc-lexer.l" | |
| 1094 | 987 | { |
| 1095 | − yylloc.file = srcpos_file; | |
| 1096 | − yylloc.first_line = yylineno; | |
| 1097 | 988 | DPRINT("PropNodeName: %s\n", yytext); |
| 1098 | − yylval.propnodename = strdup(yytext); | |
| 989 | + yylval.propnodename = xstrdup(yytext); | |
| 1099 | 990 | BEGIN_DEFAULT(); |
| 1100 | 991 | return DT_PROPNODENAME; |
| 1101 | 992 | } |
| 1102 | 993 | YY_BREAK |
| 1103 | −case 15: | |
| 994 | +case 12: | |
| 1104 | 995 | YY_RULE_SETUP |
| 1105 | −#line 194 "dtc-lexer.l" | |
| 996 | +#line 144 "dtc-lexer.l" | |
| 1106 | 997 | { |
| 1107 | − yylloc.file = srcpos_file; | |
| 1108 | − yylloc.first_line = yylineno; | |
| 1109 | 998 | DPRINT("Binary Include\n"); |
| 1110 | 999 | return DT_INCBIN; |
| 1111 | 1000 | } |
| 1112 | 1001 | YY_BREAK |
| 1113 | −case 16: | |
| 1114 | −/* rule 16 can match eol */ | |
| 1002 | +case 13: | |
| 1003 | +/* rule 13 can match eol */ | |
| 1115 | 1004 | YY_RULE_SETUP |
| 1116 | −#line 201 "dtc-lexer.l" | |
| 1005 | +#line 149 "dtc-lexer.l" | |
| 1117 | 1006 | /* eat whitespace */ |
| 1118 | 1007 | YY_BREAK |
| 1119 | −case 17: | |
| 1120 | −/* rule 17 can match eol */ | |
| 1008 | +case 14: | |
| 1009 | +/* rule 14 can match eol */ | |
| 1121 | 1010 | YY_RULE_SETUP |
| 1122 | −#line 202 "dtc-lexer.l" | |
| 1011 | +#line 150 "dtc-lexer.l" | |
| 1123 | 1012 | /* eat C-style comments */ |
| 1124 | 1013 | YY_BREAK |
| 1125 | −case 18: | |
| 1126 | −/* rule 18 can match eol */ | |
| 1014 | +case 15: | |
| 1015 | +/* rule 15 can match eol */ | |
| 1127 | 1016 | YY_RULE_SETUP |
| 1128 | −#line 203 "dtc-lexer.l" | |
| 1017 | +#line 151 "dtc-lexer.l" | |
| 1129 | 1018 | /* eat C++-style comments */ |
| 1130 | 1019 | YY_BREAK |
| 1131 | −case 19: | |
| 1020 | +case 16: | |
| 1132 | 1021 | YY_RULE_SETUP |
| 1133 | −#line 205 "dtc-lexer.l" | |
| 1022 | +#line 153 "dtc-lexer.l" | |
| 1134 | 1023 | { |
| 1135 | − yylloc.file = srcpos_file; | |
| 1136 | − yylloc.first_line = yylineno; | |
| 1137 | 1024 | DPRINT("Char: %c (\\x%02x)\n", yytext[0], |
| 1138 | 1025 | (unsigned)yytext[0]); |
| 1139 | 1026 | if (yytext[0] == '[') { |
| @@ -1148,12 +1035,12 @@ YY_RULE_SETUP · 8 unmodified lines | ||
| 1148 | 1035 | return yytext[0]; |
| 1149 | 1036 | } |
| 1150 | 1037 | YY_BREAK |
| 1151 | −case 20: | |
| 1038 | +case 17: | |
| 1152 | 1039 | YY_RULE_SETUP |
| 1153 | −#line 222 "dtc-lexer.l" | |
| 1040 | +#line 168 "dtc-lexer.l" | |
| 1154 | 1041 | ECHO; |
| 1155 | 1042 | YY_BREAK |
| 1156 | −#line 1157 "dtc-lexer.lex.c" | |
| 1043 | +#line 1044 "dtc-lexer.lex.c" | |
| 1157 | 1044 | |
| 1158 | 1045 | case YY_END_OF_BUFFER: |
| 1159 | 1046 | { |
| @@ -1218,7 +1105,8 @@ ECHO; · 58 unmodified lines | ||
| 1218 | 1105 | |
| 1219 | 1106 | else |
| 1220 | 1107 | { |
| 1221 | − yy_cp = (yy_c_buf_p); | |
| 1108 | + yy_cp = (yy_last_accepting_cpos); | |
| 1109 | + yy_current_state = (yy_last_accepting_state); | |
| 1222 | 1110 | goto yy_find_action; |
| 1223 | 1111 | } |
| 1224 | 1112 | } |
| @@ -1443,7 +1331,7 @@ static int yy_get_next_buffer (void) · 218 unmodified lines | ||
| 1443 | 1331 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
| 1444 | 1332 | { |
| 1445 | 1333 | yy_current_state = (int) yy_def[yy_current_state]; |
| 1446 | − if ( yy_current_state >= 104 ) | |
| 1334 | + if ( yy_current_state >= 94 ) | |
| 1447 | 1335 | yy_c = yy_meta[(unsigned int) yy_c]; |
| 1448 | 1336 | } |
| 1449 | 1337 | 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 | ||
| 1471 | 1359 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
| 1472 | 1360 | { |
| 1473 | 1361 | yy_current_state = (int) yy_def[yy_current_state]; |
| 1474 | − if ( yy_current_state >= 104 ) | |
| 1362 | + if ( yy_current_state >= 94 ) | |
| 1475 | 1363 | yy_c = yy_meta[(unsigned int) yy_c]; |
| 1476 | 1364 | } |
| 1477 | 1365 | 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); | |
| 1479 | 1367 | |
| 1480 | 1368 | return yy_is_jam ? 0 : yy_current_state; |
| 1481 | 1369 | } |
| @@ -1550,11 +1438,6 @@ static int yy_get_next_buffer (void) · 68 unmodified lines | ||
| 1550 | 1438 | *(yy_c_buf_p) = '\0'; /* preserve yytext */ |
| 1551 | 1439 | (yy_hold_char) = *++(yy_c_buf_p); |
| 1552 | 1440 | |
| 1553 | − if ( c == '\n' ) | |
| 1554 | − | |
| 1555 | − yylineno++; | |
| 1556 | −; | |
| 1557 | − | |
| 1558 | 1441 | return c; |
| 1559 | 1442 | } |
| 1560 | 1443 | #endif /* ifndef YY_NO_INPUT */ |
| @@ -1669,10 +1552,6 @@ static void yy_load_buffer_state (void) · 108 unmodified lines | ||
| 1669 | 1552 | yyfree((void *) b ); |
| 1670 | 1553 | } |
| 1671 | 1554 | |
| 1672 | −#ifndef __cplusplus | |
| 1673 | −extern int isatty (int ); | |
| 1674 | −#endif /* __cplusplus */ | |
| 1675 | − | |
| 1676 | 1555 | /* Initializes or reinitializes a buffer. |
| 1677 | 1556 | * This function is sometimes called more than once on the same buffer, |
| 1678 | 1557 | * such as during a yyrestart() or at EOF. |
| @@ -1696,7 +1575,7 @@ extern int isatty (int ); · 17 unmodified lines | ||
| 1696 | 1575 | b->yy_bs_column = 0; |
| 1697 | 1576 | } |
| 1698 | 1577 | |
| 1699 | − b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; | |
| 1578 | + b->yy_is_interactive = 0; | |
| 1700 | 1579 | |
| 1701 | 1580 | errno = oerrno; |
| 1702 | 1581 | } |
| @@ -2025,9 +1904,6 @@ static int yy_init_globals (void) · 322 unmodified lines | ||
| 2025 | 1904 | * This function is called from yylex_destroy(), so don't allocate here. |
| 2026 | 1905 | */ |
| 2027 | 1906 | |
| 2028 | − /* We do not touch yylineno unless the option is enabled. */ | |
| 2029 | − yylineno = 1; | |
| 2030 | − | |
| 2031 | 1907 | (yy_buffer_stack) = 0; |
| 2032 | 1908 | (yy_buffer_stack_top) = 0; |
| 2033 | 1909 | (yy_buffer_stack_max) = 0; |
| @@ -2120,104 +1996,29 @@ void yyfree (void * ptr ) · 86 unmodified lines | ||
| 2120 | 1996 | |
| 2121 | 1997 | #define YYTABLES_NAME "yytables" |
| 2122 | 1998 | |
| 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" | |
| 2140 | 2000 | |
| 2141 | 2001 | |
| 2142 | −/* | |
| 2143 | − * Detect infinite include recursion. | |
| 2144 | − */ | |
| 2145 | −#define MAX_INCLUDE_DEPTH (100) | |
| 2146 | − | |
| 2147 | −static int incl_depth = 0; | |
| 2148 | − | |
| 2149 | 2002 | |
| 2150 | 2003 | static void push_input_file(const char *filename) |
| 2151 | 2004 | { |
| 2152 | − struct incl_file *incl_file; | |
| 2153 | − struct dtc_file *newfile; | |
| 2154 | − struct search_path search, *searchptr = NULL; | |
| 2155 | − | |
| 2156 | 2005 | assert(filename); |
| 2157 | 2006 | |
| 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); | |
| 2169 | 2008 | |
| 2170 | − incl_file = xmalloc(sizeof(struct incl_file)); | |
| 2009 | + yyin = current_srcfile->f; | |
| 2171 | 2010 | |
| 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)); | |
| 2189 | 2012 | } |
| 2190 | 2013 | |
| 2191 | 2014 | |
| 2192 | 2015 | static int pop_input_file(void) |
| 2193 | 2016 | { |
| 2194 | − struct incl_file *incl_file; | |
| 2195 | − | |
| 2196 | − if (incl_file_stack == 0) | |
| 2017 | + if (srcfile_pop() == 0) | |
| 2197 | 2018 | return 0; |
| 2198 | 2019 | |
| 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; | |
| 2221 | 2022 | |
| 2222 | 2023 | return 1; |
| 2223 | 2024 | } |
| @@ -1,24 +1,23 @@ | ||
| 1 | −/* A Bison parser, made by GNU Bison 2.3. */ | |
| 2 | 1 | |
| 3 | −/* Skeleton implementation for Bison's Yacc-like parsers in C | |
| 2 | +/* A Bison parser, made by GNU Bison 2.4.1. */ | |
| 4 | 3 | |
| 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 | |
| 6 | 7 | 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 | |
| 9 | 10 | 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 | + | |
| 13 | 14 | This program is distributed in the hope that it will be useful, |
| 14 | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | 17 | GNU General Public License for more details. |
| 17 | − | |
| 18 | + | |
| 18 | 19 | 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/>. */ | |
| 22 | 21 | |
| 23 | 22 | /* As a special exception, you may create a larger work that contains |
| 24 | 23 | part or all of the Bison parser skeleton and distribute that work |
| @@ -29,7 +28,7 @@ · 4 unmodified lines | ||
| 29 | 28 | special exception, which will cause the skeleton and the resulting |
| 30 | 29 | Bison output files to be licensed under the GNU General Public |
| 31 | 30 | License without this special exception. |
| 32 | − | |
| 31 | + | |
| 33 | 32 | This special exception was added by the Free Software Foundation in |
| 34 | 33 | version 2.2 of Bison. */ |
| 35 | 34 | |
| @@ -47,7 +46,7 @@ · 11 unmodified lines | ||
| 47 | 46 | #define YYBISON 1 |
| 48 | 47 | |
| 49 | 48 | /* Bison version. */ |
| 50 | −#define YYBISON_VERSION "2.3" | |
| 49 | +#define YYBISON_VERSION "2.4.1" | |
| 51 | 50 | |
| 52 | 51 | /* Skeleton name. */ |
| 53 | 52 | #define YYSKELETON_NAME "yacc.c" |
| @@ -55,55 +54,32 @@ · 1 unmodified line | ||
| 55 | 54 | /* Pure parsers. */ |
| 56 | 55 | #define YYPURE 0 |
| 57 | 56 | |
| 58 | −/* Using locations. */ | |
| 59 | −#define YYLSP_NEEDED 1 | |
| 60 | − | |
| 57 | +/* Push parsers. */ | |
| 58 | +#define YYPUSH 0 | |
| 61 | 59 | |
| 60 | +/* Pull parsers. */ | |
| 61 | +#define YYPULL 1 | |
| 62 | 62 | |
| 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 | |
| 95 | 65 | |
| 96 | 66 | |
| 97 | 67 | |
| 98 | 68 | /* 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" | |
| 100 | 72 | |
| 101 | 73 | #include <stdio.h> |
| 102 | 74 | |
| 103 | 75 | #include "dtc.h" |
| 104 | 76 | #include "srcpos.h" |
| 105 | 77 | |
| 78 | +YYLTYPE yylloc; | |
| 79 | + | |
| 106 | 80 | extern int yylex(void); |
| 81 | +extern void print_error(char const *fmt, ...); | |
| 82 | +extern void yyerror(char const *s); | |
| 107 | 83 | |
| 108 | 84 | extern struct boot_info *the_boot_info; |
| 109 | 85 | extern int treesource_error; |
| @@ -111,6 +87,9 @@ extern int treesource_error; · 1 unmodified line | ||
| 111 | 87 | static unsigned long long eval_literal(const char *s, int base, int bits); |
| 112 | 88 | |
| 113 | 89 | |
| 90 | +/* Line 189 of yacc.c */ | |
| 91 | +#line 92 "dtc-parser.tab.c" | |
| 92 | + | |
| 114 | 93 | /* Enabling traces. */ |
| 115 | 94 | #ifndef YYDEBUG |
| 116 | 95 | # define YYDEBUG 0 |
| @@ -129,10 +108,35 @@ static unsigned long long eval_literal(const char *s, int base, int bits); · 12 unmodified lines | ||
| 129 | 108 | # define YYTOKEN_TABLE 0 |
| 130 | 109 | #endif |
| 131 | 110 | |
| 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 | + | |
| 132 | 133 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
| 133 | 134 | typedef union YYSTYPE |
| 134 | −#line 37 "dtc-parser.y" | |
| 135 | 135 | { |
| 136 | + | |
| 137 | +/* Line 214 of yacc.c */ | |
| 138 | +#line 39 "dtc-parser.y" | |
| 139 | + | |
| 136 | 140 | char *propnodename; |
| 137 | 141 | char *literal; |
| 138 | 142 | char *labelref; |
| @@ -147,34 +151,23 @@ typedef union YYSTYPE · 8 unmodified lines | ||
| 147 | 151 | struct node *node; |
| 148 | 152 | struct node *nodelist; |
| 149 | 153 | 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 | |
| 154 | 161 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 155 | 162 | # 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 | |
| 170 | 163 | #endif |
| 171 | 164 | |
| 172 | 165 | |
| 173 | 166 | /* Copy the second part of user declarations. */ |
| 174 | 167 | |
| 175 | 168 | |
| 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" | |
| 178 | 171 | |
| 179 | 172 | #ifdef short |
| 180 | 173 | # undef short |
| @@ -249,14 +242,14 @@ typedef short int yytype_int16; · 68 unmodified lines | ||
| 249 | 242 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 250 | 243 | || defined __cplusplus || defined _MSC_VER) |
| 251 | 244 | static int |
| 252 | −YYID (int i) | |
| 245 | +YYID (int yyi) | |
| 253 | 246 | #else |
| 254 | 247 | static int |
| 255 | −YYID (i) | |
| 256 | − int i; | |
| 248 | +YYID (yyi) | |
| 249 | + int yyi; | |
| 257 | 250 | #endif |
| 258 | 251 | { |
| 259 | − return i; | |
| 252 | + return yyi; | |
| 260 | 253 | } |
| 261 | 254 | #endif |
| 262 | 255 | |
| @@ -332,15 +325,13 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ · 69 unmodified lines | ||
| 332 | 325 | |
| 333 | 326 | #if (! defined yyoverflow \ |
| 334 | 327 | && (! 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))) | |
| 337 | 329 | |
| 338 | 330 | /* A type that is properly aligned for any stack member. */ |
| 339 | 331 | union yyalloc |
| 340 | 332 | { |
| 341 | − yytype_int16 yyss; | |
| 342 | − YYSTYPE yyvs; | |
| 343 | − YYLTYPE yyls; | |
| 333 | + yytype_int16 yyss_alloc; | |
| 334 | + YYSTYPE yyvs_alloc; | |
| 344 | 335 | }; |
| 345 | 336 | |
| 346 | 337 | /* The size of the maximum gap between one aligned stack and the next. */ |
| @@ -349,8 +340,8 @@ union yyalloc · 2 unmodified lines | ||
| 349 | 340 | /* The size of an array large to enough to hold all stacks, each with |
| 350 | 341 | N elements. */ |
| 351 | 342 | # 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) | |
| 354 | 345 | |
| 355 | 346 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 356 | 347 | not overlap. */ |
| @@ -375,12 +366,12 @@ union yyalloc · 18 unmodified lines | ||
| 375 | 366 | elements in the stack, and YYPTR gives the new location of the |
| 376 | 367 | stack. Advance YYPTR to a properly aligned location for the next |
| 377 | 368 | stack. */ |
| 378 | −# define YYSTACK_RELOCATE(Stack) \ | |
| 369 | +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ | |
| 379 | 370 | do \ |
| 380 | 371 | { \ |
| 381 | 372 | 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; \ | |
| 384 | 375 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 385 | 376 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 386 | 377 | } \ |
| @@ -389,22 +380,22 @@ union yyalloc · 2 unmodified lines | ||
| 389 | 380 | #endif |
| 390 | 381 | |
| 391 | 382 | /* YYFINAL -- State number of the termination state. */ |
| 392 | −#define YYFINAL 9 | |
| 383 | +#define YYFINAL 4 | |
| 393 | 384 | /* YYLAST -- Last index in YYTABLE. */ |
| 394 | −#define YYLAST 73 | |
| 385 | +#define YYLAST 56 | |
| 395 | 386 | |
| 396 | 387 | /* YYNTOKENS -- Number of terminals. */ |
| 397 | −#define YYNTOKENS 27 | |
| 388 | +#define YYNTOKENS 25 | |
| 398 | 389 | /* YYNNTS -- Number of nonterminals. */ |
| 399 | −#define YYNNTS 20 | |
| 390 | +#define YYNNTS 16 | |
| 400 | 391 | /* YYNRULES -- Number of rules. */ |
| 401 | −#define YYNRULES 45 | |
| 392 | +#define YYNRULES 39 | |
| 402 | 393 | /* YYNRULES -- Number of states. */ |
| 403 | −#define YYNSTATES 76 | |
| 394 | +#define YYNSTATES 67 | |
| 404 | 395 | |
| 405 | 396 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 406 | 397 | #define YYUNDEFTOK 2 |
| 407 | −#define YYMAXUTOK 268 | |
| 398 | +#define YYMAXUTOK 267 | |
| 408 | 399 | |
| 409 | 400 | #define YYTRANSLATE(YYX) \ |
| 410 | 401 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| @@ -416,15 +407,15 @@ static const yytype_uint8 yytranslate[] = · 5 unmodified lines | ||
| 416 | 407 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 417 | 408 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 418 | 409 | 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, | |
| 422 | 413 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 423 | 414 | 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, | |
| 425 | 416 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 426 | 417 | 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, | |
| 428 | 419 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 429 | 420 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 430 | 421 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| @@ -438,7 +429,7 @@ static const yytype_uint8 yytranslate[] = · 7 unmodified lines | ||
| 438 | 429 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 439 | 430 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 440 | 431 | 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 | |
| 442 | 433 | }; |
| 443 | 434 | |
| 444 | 435 | #if YYDEBUG |
| @@ -446,41 +437,37 @@ static const yytype_uint8 yytranslate[] = · 1 unmodified line | ||
| 446 | 437 | YYRHS. */ |
| 447 | 438 | static const yytype_uint8 yyprhs[] = |
| 448 | 439 | { |
| 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 | |
| 454 | 444 | }; |
| 455 | 445 | |
| 456 | 446 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 457 | 447 | static const yytype_int8 yyrhs[] = |
| 458 | 448 | { |
| 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 | |
| 474 | 462 | }; |
| 475 | 463 | |
| 476 | 464 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 477 | 465 | static const yytype_uint16 yyrline[] = |
| 478 | 466 | { |
| 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 | |
| 484 | 471 | }; |
| 485 | 472 | #endif |
| 486 | 473 | |
| @@ -490,13 +477,12 @@ static const yytype_uint16 yyrline[] = · 3 unmodified lines | ||
| 490 | 477 | static const char *const yytname[] = |
| 491 | 478 | { |
| 492 | 479 | "$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 | |
| 500 | 486 | }; |
| 501 | 487 | #endif |
| 502 | 488 | |
| @@ -506,29 +492,27 @@ static const char *const yytname[] = · 3 unmodified lines | ||
| 506 | 492 | static const yytype_uint16 yytoknum[] = |
| 507 | 493 | { |
| 508 | 494 | 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 | |
| 511 | 497 | }; |
| 512 | 498 | # endif |
| 513 | 499 | |
| 514 | 500 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 515 | 501 | static const yytype_uint8 yyr1[] = |
| 516 | 502 | { |
| 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 | |
| 522 | 507 | }; |
| 523 | 508 | |
| 524 | 509 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 525 | 510 | static const yytype_uint8 yyr2[] = |
| 526 | 511 | { |
| 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 | |
| 532 | 516 | }; |
| 533 | 517 | |
| 534 | 518 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| @@ -536,86 +520,79 @@ static const yytype_uint8 yyr2[] = · 1 unmodified line | ||
| 536 | 520 | means the default is an error. */ |
| 537 | 521 | static const yytype_uint8 yydefact[] = |
| 538 | 522 | { |
| 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 | |
| 547 | 530 | }; |
| 548 | 531 | |
| 549 | 532 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 550 | 533 | static const yytype_int8 yydefgoto[] = |
| 551 | 534 | { |
| 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 | |
| 554 | 537 | }; |
| 555 | 538 | |
| 556 | 539 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 557 | 540 | STATE-NUM. */ |
| 558 | −#define YYPACT_NINF -14 | |
| 541 | +#define YYPACT_NINF -12 | |
| 559 | 542 | static const yytype_int8 yypact[] = |
| 560 | 543 | { |
| 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 | |
| 569 | 551 | }; |
| 570 | 552 | |
| 571 | 553 | /* YYPGOTO[NTERM-NUM]. */ |
| 572 | 554 | static const yytype_int8 yypgoto[] = |
| 573 | 555 | { |
| 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 | |
| 576 | 558 | }; |
| 577 | 559 | |
| 578 | 560 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 579 | 561 | positive, shift that token. If negative, reduce the rule which |
| 580 | 562 | number is the opposite. If zero, do what YYDEFACT says. |
| 581 | 563 | 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[] = | |
| 584 | 566 | { |
| 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 | |
| 593 | 573 | }; |
| 594 | 574 | |
| 595 | 575 | static const yytype_int8 yycheck[] = |
| 596 | 576 | { |
| 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 | |
| 605 | 583 | }; |
| 606 | 584 | |
| 607 | 585 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 608 | 586 | symbol of state STATE-NUM. */ |
| 609 | 587 | static const yytype_uint8 yystos[] = |
| 610 | 588 | { |
| 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 | |
| 619 | 596 | }; |
| 620 | 597 | |
| 621 | 598 | #define yyerrok (yyerrstatus = 0) |
| @@ -728,7 +705,7 @@ do { \ · 106 unmodified lines | ||
| 728 | 705 | { \ |
| 729 | 706 | YYFPRINTF (stderr, "%s ", Title); \ |
| 730 | 707 | yy_symbol_print (stderr, \ |
| 731 | − Type, Value, Location); \ | |
| 708 | + Type, Value); \ | |
| 732 | 709 | YYFPRINTF (stderr, "\n"); \ |
| 733 | 710 | } \ |
| 734 | 711 | } while (YYID (0)) |
| @@ -742,19 +719,17 @@ do { \ · 7 unmodified lines | ||
| 742 | 719 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 743 | 720 | || defined __cplusplus || defined _MSC_VER) |
| 744 | 721 | 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) | |
| 746 | 723 | #else |
| 747 | 724 | static void |
| 748 | −yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) | |
| 725 | +yy_symbol_value_print (yyoutput, yytype, yyvaluep) | |
| 749 | 726 | FILE *yyoutput; |
| 750 | 727 | int yytype; |
| 751 | 728 | YYSTYPE const * const yyvaluep; |
| 752 | − YYLTYPE const * const yylocationp; | |
| 753 | 729 | #endif |
| 754 | 730 | { |
| 755 | 731 | if (!yyvaluep) |
| 756 | 732 | return; |
| 757 | − YYUSE (yylocationp); | |
| 758 | 733 | # ifdef YYPRINT |
| 759 | 734 | if (yytype < YYNTOKENS) |
| 760 | 735 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| @@ -776,14 +751,13 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) · 15 unmodified lines | ||
| 776 | 751 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 777 | 752 | || defined __cplusplus || defined _MSC_VER) |
| 778 | 753 | 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) | |
| 780 | 755 | #else |
| 781 | 756 | static void |
| 782 | −yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) | |
| 757 | +yy_symbol_print (yyoutput, yytype, yyvaluep) | |
| 783 | 758 | FILE *yyoutput; |
| 784 | 759 | int yytype; |
| 785 | 760 | YYSTYPE const * const yyvaluep; |
| 786 | − YYLTYPE const * const yylocationp; | |
| 787 | 761 | #endif |
| 788 | 762 | { |
| 789 | 763 | if (yytype < YYNTOKENS) |
| @@ -791,9 +765,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) · 1 unmodified line | ||
| 791 | 765 | else |
| 792 | 766 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 793 | 767 | |
| 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); | |
| 797 | 769 | YYFPRINTF (yyoutput, ")"); |
| 798 | 770 | } |
| 799 | 771 | |
| @@ -805,17 +777,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) · 5 unmodified lines | ||
| 805 | 777 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 806 | 778 | || defined __cplusplus || defined _MSC_VER) |
| 807 | 779 | static void |
| 808 | −yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) | |
| 780 | +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) | |
| 809 | 781 | #else |
| 810 | 782 | 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; | |
| 814 | 786 | #endif |
| 815 | 787 | { |
| 816 | 788 | 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 | + } | |
| 819 | 794 | YYFPRINTF (stderr, "\n"); |
| 820 | 795 | } |
| 821 | 796 | |
| @@ -833,12 +808,11 @@ do { \ · 11 unmodified lines | ||
| 833 | 808 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 834 | 809 | || defined __cplusplus || defined _MSC_VER) |
| 835 | 810 | static void |
| 836 | −yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) | |
| 811 | +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) | |
| 837 | 812 | #else |
| 838 | 813 | static void |
| 839 | −yy_reduce_print (yyvsp, yylsp, yyrule) | |
| 814 | +yy_reduce_print (yyvsp, yyrule) | |
| 840 | 815 | YYSTYPE *yyvsp; |
| 841 | − YYLTYPE *yylsp; | |
| 842 | 816 | int yyrule; |
| 843 | 817 | #endif |
| 844 | 818 | { |
| @@ -850,18 +824,18 @@ yy_reduce_print (yyvsp, yylsp, yyrule) · 5 unmodified lines | ||
| 850 | 824 | /* The symbols being reduced. */ |
| 851 | 825 | for (yyi = 0; yyi < yynrhs; yyi++) |
| 852 | 826 | { |
| 853 | − fprintf (stderr, " $%d = ", yyi + 1); | |
| 827 | + YYFPRINTF (stderr, " $%d = ", yyi + 1); | |
| 854 | 828 | yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], |
| 855 | 829 | &(yyvsp[(yyi + 1) - (yynrhs)]) |
| 856 | − , &(yylsp[(yyi + 1) - (yynrhs)]) ); | |
| 857 | − fprintf (stderr, "\n"); | |
| 830 | + ); | |
| 831 | + YYFPRINTF (stderr, "\n"); | |
| 858 | 832 | } |
| 859 | 833 | } |
| 860 | 834 | |
| 861 | 835 | # define YY_REDUCE_PRINT(Rule) \ |
| 862 | 836 | do { \ |
| 863 | 837 | if (yydebug) \ |
| 864 | − yy_reduce_print (yyvsp, yylsp, Rule); \ | |
| 838 | + yy_reduce_print (yyvsp, Rule); \ | |
| 865 | 839 | } while (YYID (0)) |
| 866 | 840 | |
| 867 | 841 | /* 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 | ||
| 1112 | 1086 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 1113 | 1087 | || defined __cplusplus || defined _MSC_VER) |
| 1114 | 1088 | static void |
| 1115 | −yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) | |
| 1089 | +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) | |
| 1116 | 1090 | #else |
| 1117 | 1091 | static void |
| 1118 | −yydestruct (yymsg, yytype, yyvaluep, yylocationp) | |
| 1092 | +yydestruct (yymsg, yytype, yyvaluep) | |
| 1119 | 1093 | const char *yymsg; |
| 1120 | 1094 | int yytype; |
| 1121 | 1095 | YYSTYPE *yyvaluep; |
| 1122 | − YYLTYPE *yylocationp; | |
| 1123 | 1096 | #endif |
| 1124 | 1097 | { |
| 1125 | 1098 | YYUSE (yyvaluep); |
| 1126 | − YYUSE (yylocationp); | |
| 1127 | 1099 | |
| 1128 | 1100 | if (!yymsg) |
| 1129 | 1101 | yymsg = "Deleting"; |
| @@ -1136,10 +1108,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp) · 6 unmodified lines | ||
| 1136 | 1108 | break; |
| 1137 | 1109 | } |
| 1138 | 1110 | } |
| 1139 | − | |
| 1140 | 1111 | |
| 1141 | 1112 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 1142 | − | |
| 1143 | 1113 | #ifdef YYPARSE_PARAM |
| 1144 | 1114 | #if defined __STDC__ || defined __cplusplus |
| 1145 | 1115 | int yyparse (void *YYPARSE_PARAM); |
| @@ -1155,23 +1125,20 @@ int yyparse (); · 9 unmodified lines | ||
| 1155 | 1125 | #endif /* ! YYPARSE_PARAM */ |
| 1156 | 1126 | |
| 1157 | 1127 | |
| 1158 | − | |
| 1159 | −/* The look-ahead symbol. */ | |
| 1128 | +/* The lookahead symbol. */ | |
| 1160 | 1129 | int yychar; |
| 1161 | 1130 | |
| 1162 | −/* The semantic value of the look-ahead symbol. */ | |
| 1131 | +/* The semantic value of the lookahead symbol. */ | |
| 1163 | 1132 | YYSTYPE yylval; |
| 1164 | 1133 | |
| 1165 | 1134 | /* Number of syntax errors so far. */ |
| 1166 | 1135 | int yynerrs; |
| 1167 | −/* Location data for the look-ahead symbol. */ | |
| 1168 | −YYLTYPE yylloc; | |
| 1169 | 1136 | |
| 1170 | 1137 | |
| 1171 | 1138 | |
| 1172 | −/*----------. | |
| 1173 | −| yyparse. | | |
| 1174 | −`----------*/ | |
| 1139 | +/*-------------------------. | |
| 1140 | +| yyparse or yypush_parse. | | |
| 1141 | +`-------------------------*/ | |
| 1175 | 1142 | |
| 1176 | 1143 | #ifdef YYPARSE_PARAM |
| 1177 | 1144 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| @@ -1195,79 +1162,70 @@ yyparse () · 17 unmodified lines | ||
| 1195 | 1162 | #endif |
| 1196 | 1163 | #endif |
| 1197 | 1164 | { |
| 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 | |
| 1212 | 1165 | |
| 1213 | − /* Three stacks and their tools: | |
| 1214 | − `yyss': related to states, | |
| 1215 | − `yyvs': related to semantic values, | |
| 1216 | − `yyls': related to locations. | |
| 1217 | 1166 | |
| 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; | |
| 1220 | 1170 | |
| 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. | |
| 1225 | 1174 | |
| 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. */ | |
| 1230 | 1177 | |
| 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; | |
| 1237 | 1182 | |
| 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; | |
| 1239 | 1187 | |
| 1240 | − YYSIZE_T yystacksize = YYINITDEPTH; | |
| 1188 | + YYSIZE_T yystacksize; | |
| 1241 | 1189 | |
| 1190 | + int yyn; | |
| 1191 | + int yyresult; | |
| 1192 | + /* Lookahead token as an internal (translated) token number. */ | |
| 1193 | + int yytoken; | |
| 1242 | 1194 | /* The variables used to return semantic value and location from the |
| 1243 | 1195 | action routines. */ |
| 1244 | 1196 | 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)) | |
| 1246 | 1206 | |
| 1247 | 1207 | /* The number of symbols on the RHS of the reduced rule. |
| 1248 | 1208 | Keep to zero when no symbol should be popped. */ |
| 1249 | 1209 | int yylen = 0; |
| 1250 | 1210 | |
| 1211 | + yytoken = 0; | |
| 1212 | + yyss = yyssa; | |
| 1213 | + yyvs = yyvsa; | |
| 1214 | + yystacksize = YYINITDEPTH; | |
| 1215 | + | |
| 1251 | 1216 | YYDPRINTF ((stderr, "Starting parse\n")); |
| 1252 | 1217 | |
| 1253 | 1218 | yystate = 0; |
| 1254 | 1219 | yyerrstatus = 0; |
| 1255 | 1220 | yynerrs = 0; |
| 1256 | − yychar = YYEMPTY; /* Cause a token to be read. */ | |
| 1221 | + yychar = YYEMPTY; /* Cause a token to be read. */ | |
| 1257 | 1222 | |
| 1258 | 1223 | /* Initialize stack pointers. |
| 1259 | 1224 | Waste one element of value and location stack |
| 1260 | 1225 | so that they stay on the same level as the state stack. |
| 1261 | 1226 | The wasted elements are never initialized. */ |
| 1262 | − | |
| 1263 | 1227 | yyssp = yyss; |
| 1264 | 1228 | 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 | |
| 1271 | 1229 | |
| 1272 | 1230 | goto yysetstate; |
| 1273 | 1231 | |
| @@ -1294,7 +1252,6 @@ yyparse () · 20 unmodified lines | ||
| 1294 | 1252 | memory. */ |
| 1295 | 1253 | YYSTYPE *yyvs1 = yyvs; |
| 1296 | 1254 | yytype_int16 *yyss1 = yyss; |
| 1297 | − YYLTYPE *yyls1 = yyls; | |
| 1298 | 1255 | |
| 1299 | 1256 | /* Each stack pointer address is followed by the size of the |
| 1300 | 1257 | data in use in that stack, in bytes. This used to be a |
| @@ -1303,9 +1260,8 @@ yyparse () · 2 unmodified lines | ||
| 1303 | 1260 | yyoverflow (YY_("memory exhausted"), |
| 1304 | 1261 | &yyss1, yysize * sizeof (*yyssp), |
| 1305 | 1262 | &yyvs1, yysize * sizeof (*yyvsp), |
| 1306 | − &yyls1, yysize * sizeof (*yylsp), | |
| 1307 | 1263 | &yystacksize); |
| 1308 | − yyls = yyls1; | |
| 1264 | + | |
| 1309 | 1265 | yyss = yyss1; |
| 1310 | 1266 | yyvs = yyvs1; |
| 1311 | 1267 | } |
| @@ -1326,9 +1282,8 @@ yyparse () · 14 unmodified lines | ||
| 1326 | 1282 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 1327 | 1283 | if (! yyptr) |
| 1328 | 1284 | 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); | |
| 1332 | 1287 | # undef YYSTACK_RELOCATE |
| 1333 | 1288 | if (yyss1 != yyssa) |
| 1334 | 1289 | YYSTACK_FREE (yyss1); |
| @@ -1338,7 +1293,6 @@ yyparse () · 3 unmodified lines | ||
| 1338 | 1293 | |
| 1339 | 1294 | yyssp = yyss + yysize - 1; |
| 1340 | 1295 | yyvsp = yyvs + yysize - 1; |
| 1341 | − yylsp = yyls + yysize - 1; | |
| 1342 | 1296 | |
| 1343 | 1297 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 1344 | 1298 | (unsigned long int) yystacksize)); |
| @@ -1349,6 +1303,9 @@ yyparse () · 4 unmodified lines | ||
| 1349 | 1303 | |
| 1350 | 1304 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
| 1351 | 1305 | |
| 1306 | + if (yystate == YYFINAL) | |
| 1307 | + YYACCEPT; | |
| 1308 | + | |
| 1352 | 1309 | goto yybackup; |
| 1353 | 1310 | |
| 1354 | 1311 | /*-----------. |
| @@ -1357,16 +1314,16 @@ yyparse () · 2 unmodified lines | ||
| 1357 | 1314 | yybackup: |
| 1358 | 1315 | |
| 1359 | 1316 | /* 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. */ | |
| 1361 | 1318 | |
| 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. */ | |
| 1363 | 1320 | yyn = yypact[yystate]; |
| 1364 | 1321 | if (yyn == YYPACT_NINF) |
| 1365 | 1322 | goto yydefault; |
| 1366 | 1323 | |
| 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. */ | |
| 1368 | 1325 | |
| 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. */ | |
| 1370 | 1327 | if (yychar == YYEMPTY) |
| 1371 | 1328 | { |
| 1372 | 1329 | YYDPRINTF ((stderr, "Reading a token: ")); |
| @@ -1398,24 +1355,20 @@ yybackup: · 25 unmodified lines | ||
| 1398 | 1355 | goto yyreduce; |
| 1399 | 1356 | } |
| 1400 | 1357 | |
| 1401 | − if (yyn == YYFINAL) | |
| 1402 | − YYACCEPT; | |
| 1403 | − | |
| 1404 | 1358 | /* Count tokens shifted since error; after three, turn off error |
| 1405 | 1359 | status. */ |
| 1406 | 1360 | if (yyerrstatus) |
| 1407 | 1361 | yyerrstatus--; |
| 1408 | 1362 | |
| 1409 | − /* Shift the look-ahead token. */ | |
| 1363 | + /* Shift the lookahead token. */ | |
| 1410 | 1364 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
| 1411 | 1365 | |
| 1412 | − /* Discard the shifted token unless it is eof. */ | |
| 1413 | − if (yychar != YYEOF) | |
| 1414 | − yychar = YYEMPTY; | |
| 1366 | + /* Discard the shifted token. */ | |
| 1367 | + yychar = YYEMPTY; | |
| 1415 | 1368 | |
| 1416 | 1369 | yystate = yyn; |
| 1417 | 1370 | *++yyvsp = yylval; |
| 1418 | − *++yylsp = yylloc; | |
| 1371 | + | |
| 1419 | 1372 | goto yynewstate; |
| 1420 | 1373 | |
| 1421 | 1374 | |
| @@ -1446,337 +1399,387 @@ yyreduce: · 24 unmodified lines | ||
| 1446 | 1399 | GCC warning that YYVAL may be used uninitialized. */ |
| 1447 | 1400 | yyval = yyvsp[1-yylen]; |
| 1448 | 1401 | |
| 1449 | − /* Default location. */ | |
| 1450 | − YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); | |
| 1402 | + | |
| 1451 | 1403 | YY_REDUCE_PRINT (yyn); |
| 1452 | 1404 | switch (yyn) |
| 1453 | 1405 | { |
| 1454 | 1406 | case 2: |
| 1455 | −#line 90 "dtc-parser.y" | |
| 1407 | + | |
| 1408 | +/* Line 1455 of yacc.c */ | |
| 1409 | +#line 87 "dtc-parser.y" | |
| 1456 | 1410 | { |
| 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))); | |
| 1458 | 1413 | ;} |
| 1459 | 1414 | break; |
| 1460 | 1415 | |
| 1461 | 1416 | case 3: |
| 1462 | −#line 94 "dtc-parser.y" | |
| 1417 | + | |
| 1418 | +/* Line 1455 of yacc.c */ | |
| 1419 | +#line 95 "dtc-parser.y" | |
| 1463 | 1420 | { |
| 1464 | − the_boot_info = build_boot_info((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].node), 0); | |
| 1421 | + (yyval.re) = NULL; | |
| 1465 | 1422 | ;} |
| 1466 | 1423 | break; |
| 1467 | 1424 | |
| 1468 | 1425 | case 4: |
| 1469 | −#line 101 "dtc-parser.y" | |
| 1426 | + | |
| 1427 | +/* Line 1455 of yacc.c */ | |
| 1428 | +#line 99 "dtc-parser.y" | |
| 1470 | 1429 | { |
| 1471 | − (yyval.re) = NULL; | |
| 1430 | + (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); | |
| 1472 | 1431 | ;} |
| 1473 | 1432 | break; |
| 1474 | 1433 | |
| 1475 | 1434 | case 5: |
| 1476 | −#line 105 "dtc-parser.y" | |
| 1435 | + | |
| 1436 | +/* Line 1455 of yacc.c */ | |
| 1437 | +#line 106 "dtc-parser.y" | |
| 1477 | 1438 | { |
| 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)); | |
| 1479 | 1440 | ;} |
| 1480 | 1441 | break; |
| 1481 | 1442 | |
| 1482 | 1443 | case 6: |
| 1483 | −#line 112 "dtc-parser.y" | |
| 1444 | + | |
| 1445 | +/* Line 1455 of yacc.c */ | |
| 1446 | +#line 110 "dtc-parser.y" | |
| 1484 | 1447 | { |
| 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); | |
| 1486 | 1450 | ;} |
| 1487 | 1451 | break; |
| 1488 | 1452 | |
| 1489 | 1453 | case 7: |
| 1490 | −#line 119 "dtc-parser.y" | |
| 1454 | + | |
| 1455 | +/* Line 1455 of yacc.c */ | |
| 1456 | +#line 118 "dtc-parser.y" | |
| 1491 | 1457 | { |
| 1492 | − (yyval.re) = NULL; | |
| 1458 | + (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); | |
| 1493 | 1459 | ;} |
| 1494 | 1460 | break; |
| 1495 | 1461 | |
| 1496 | 1462 | case 8: |
| 1497 | −#line 123 "dtc-parser.y" | |
| 1463 | + | |
| 1464 | +/* Line 1455 of yacc.c */ | |
| 1465 | +#line 125 "dtc-parser.y" | |
| 1498 | 1466 | { |
| 1499 | − (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); | |
| 1467 | + (yyval.node) = name_node((yyvsp[(2) - (2)].node), ""); | |
| 1500 | 1468 | ;} |
| 1501 | 1469 | break; |
| 1502 | 1470 | |
| 1503 | 1471 | case 9: |
| 1504 | −#line 130 "dtc-parser.y" | |
| 1472 | + | |
| 1473 | +/* Line 1455 of yacc.c */ | |
| 1474 | +#line 129 "dtc-parser.y" | |
| 1505 | 1475 | { |
| 1506 | − (yyval.re) = (yyvsp[(1) - (1)].re); | |
| 1476 | + (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); | |
| 1507 | 1477 | ;} |
| 1508 | 1478 | break; |
| 1509 | 1479 | |
| 1510 | 1480 | case 10: |
| 1511 | −#line 134 "dtc-parser.y" | |
| 1481 | + | |
| 1482 | +/* Line 1455 of yacc.c */ | |
| 1483 | +#line 133 "dtc-parser.y" | |
| 1512 | 1484 | { |
| 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); | |
| 1514 | 1492 | ;} |
| 1515 | 1493 | break; |
| 1516 | 1494 | |
| 1517 | 1495 | case 11: |
| 1518 | −#line 141 "dtc-parser.y" | |
| 1496 | + | |
| 1497 | +/* Line 1455 of yacc.c */ | |
| 1498 | +#line 146 "dtc-parser.y" | |
| 1519 | 1499 | { |
| 1520 | − (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); | |
| 1500 | + (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); | |
| 1521 | 1501 | ;} |
| 1522 | 1502 | break; |
| 1523 | 1503 | |
| 1524 | 1504 | case 12: |
| 1525 | −#line 145 "dtc-parser.y" | |
| 1505 | + | |
| 1506 | +/* Line 1455 of yacc.c */ | |
| 1507 | +#line 153 "dtc-parser.y" | |
| 1526 | 1508 | { |
| 1527 | − (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 16, 64); | |
| 1509 | + (yyval.proplist) = NULL; | |
| 1528 | 1510 | ;} |
| 1529 | 1511 | break; |
| 1530 | 1512 | |
| 1531 | 1513 | case 13: |
| 1532 | −#line 152 "dtc-parser.y" | |
| 1514 | + | |
| 1515 | +/* Line 1455 of yacc.c */ | |
| 1516 | +#line 157 "dtc-parser.y" | |
| 1533 | 1517 | { |
| 1534 | − (yyval.node) = name_node((yyvsp[(2) - (2)].node), "", NULL); | |
| 1518 | + (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); | |
| 1535 | 1519 | ;} |
| 1536 | 1520 | break; |
| 1537 | 1521 | |
| 1538 | 1522 | case 14: |
| 1539 | −#line 159 "dtc-parser.y" | |
| 1523 | + | |
| 1524 | +/* Line 1455 of yacc.c */ | |
| 1525 | +#line 164 "dtc-parser.y" | |
| 1540 | 1526 | { |
| 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)); | |
| 1542 | 1528 | ;} |
| 1543 | 1529 | break; |
| 1544 | 1530 | |
| 1545 | 1531 | case 15: |
| 1546 | −#line 166 "dtc-parser.y" | |
| 1532 | + | |
| 1533 | +/* Line 1455 of yacc.c */ | |
| 1534 | +#line 168 "dtc-parser.y" | |
| 1547 | 1535 | { |
| 1548 | − (yyval.proplist) = NULL; | |
| 1536 | + (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data); | |
| 1549 | 1537 | ;} |
| 1550 | 1538 | break; |
| 1551 | 1539 | |
| 1552 | 1540 | case 16: |
| 1553 | −#line 170 "dtc-parser.y" | |
| 1541 | + | |
| 1542 | +/* Line 1455 of yacc.c */ | |
| 1543 | +#line 172 "dtc-parser.y" | |
| 1554 | 1544 | { |
| 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); | |
| 1556 | 1547 | ;} |
| 1557 | 1548 | break; |
| 1558 | 1549 | |
| 1559 | 1550 | case 17: |
| 1560 | −#line 177 "dtc-parser.y" | |
| 1551 | + | |
| 1552 | +/* Line 1455 of yacc.c */ | |
| 1553 | +#line 180 "dtc-parser.y" | |
| 1561 | 1554 | { |
| 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)); | |
| 1563 | 1556 | ;} |
| 1564 | 1557 | break; |
| 1565 | 1558 | |
| 1566 | 1559 | case 18: |
| 1567 | −#line 181 "dtc-parser.y" | |
| 1560 | + | |
| 1561 | +/* Line 1455 of yacc.c */ | |
| 1562 | +#line 184 "dtc-parser.y" | |
| 1568 | 1563 | { |
| 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)); | |
| 1570 | 1565 | ;} |
| 1571 | 1566 | break; |
| 1572 | 1567 | |
| 1573 | 1568 | case 19: |
| 1569 | + | |
| 1570 | +/* Line 1455 of yacc.c */ | |
| 1574 | 1571 | #line 188 "dtc-parser.y" |
| 1575 | 1572 | { |
| 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)); | |
| 1577 | 1574 | ;} |
| 1578 | 1575 | break; |
| 1579 | 1576 | |
| 1580 | 1577 | case 20: |
| 1578 | + | |
| 1579 | +/* Line 1455 of yacc.c */ | |
| 1581 | 1580 | #line 192 "dtc-parser.y" |
| 1582 | 1581 | { |
| 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)); | |
| 1584 | 1583 | ;} |
| 1585 | 1584 | break; |
| 1586 | 1585 | |
| 1587 | 1586 | 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; | |
| 1600 | 1587 | |
| 1601 | − case 23: | |
| 1602 | −#line 204 "dtc-parser.y" | |
| 1588 | +/* Line 1455 of yacc.c */ | |
| 1589 | +#line 196 "dtc-parser.y" | |
| 1603 | 1590 | { |
| 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; | |
| 1607 | 1593 | |
| 1608 | 1594 | 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)); | |
| 1613 | 1600 | |
| 1614 | − d = data_copy_file(file->file, (yyvsp[(8) - (9)].addr)); | |
| 1601 | + d = data_copy_file(f, (yyvsp[(8) - (9)].addr)); | |
| 1615 | 1602 | |
| 1616 | 1603 | (yyval.data) = data_merge((yyvsp[(1) - (9)].data), d); |
| 1617 | − dtc_close_file(file); | |
| 1604 | + fclose(f); | |
| 1618 | 1605 | ;} |
| 1619 | 1606 | break; |
| 1620 | 1607 | |
| 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" | |
| 1623 | 1612 | { |
| 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); | |
| 1626 | 1614 | struct data d = empty_data; |
| 1627 | 1615 | |
| 1628 | − d = data_copy_file(file->file, -1); | |
| 1616 | + d = data_copy_file(f, -1); | |
| 1629 | 1617 | |
| 1630 | 1618 | (yyval.data) = data_merge((yyvsp[(1) - (5)].data), d); |
| 1631 | − dtc_close_file(file); | |
| 1619 | + fclose(f); | |
| 1632 | 1620 | ;} |
| 1633 | 1621 | break; |
| 1634 | 1622 | |
| 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" | |
| 1637 | 1627 | { |
| 1638 | 1628 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); |
| 1639 | 1629 | ;} |
| 1640 | 1630 | break; |
| 1641 | 1631 | |
| 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" | |
| 1644 | 1636 | { |
| 1645 | 1637 | (yyval.data) = empty_data; |
| 1646 | 1638 | ;} |
| 1647 | 1639 | break; |
| 1648 | 1640 | |
| 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" | |
| 1651 | 1645 | { |
| 1652 | 1646 | (yyval.data) = (yyvsp[(1) - (2)].data); |
| 1653 | 1647 | ;} |
| 1654 | 1648 | break; |
| 1655 | 1649 | |
| 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" | |
| 1658 | 1654 | { |
| 1659 | 1655 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); |
| 1660 | 1656 | ;} |
| 1661 | 1657 | break; |
| 1662 | 1658 | |
| 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" | |
| 1665 | 1663 | { |
| 1666 | 1664 | (yyval.data) = empty_data; |
| 1667 | 1665 | ;} |
| 1668 | 1666 | break; |
| 1669 | 1667 | |
| 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" | |
| 1672 | 1672 | { |
| 1673 | 1673 | (yyval.data) = data_append_cell((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].cell)); |
| 1674 | 1674 | ;} |
| 1675 | 1675 | break; |
| 1676 | 1676 | |
| 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" | |
| 1679 | 1681 | { |
| 1680 | 1682 | (yyval.data) = data_append_cell(data_add_marker((yyvsp[(1) - (2)].data), REF_PHANDLE, |
| 1681 | 1683 | (yyvsp[(2) - (2)].labelref)), -1); |
| 1682 | 1684 | ;} |
| 1683 | 1685 | break; |
| 1684 | 1686 | |
| 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" | |
| 1687 | 1691 | { |
| 1688 | 1692 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); |
| 1689 | 1693 | ;} |
| 1690 | 1694 | break; |
| 1691 | 1695 | |
| 1692 | − case 33: | |
| 1693 | −#line 274 "dtc-parser.y" | |
| 1694 | − { | |
| 1695 | − (yyval.cbase) = 16; | |
| 1696 | − ;} | |
| 1697 | − break; | |
| 1696 | + case 31: | |
| 1698 | 1697 | |
| 1699 | − case 35: | |
| 1700 | −#line 282 "dtc-parser.y" | |
| 1698 | +/* Line 1455 of yacc.c */ | |
| 1699 | +#line 265 "dtc-parser.y" | |
| 1701 | 1700 | { |
| 1702 | 1701 | (yyval.cell) = eval_literal((yyvsp[(1) - (1)].literal), 0, 32); |
| 1703 | 1702 | ;} |
| 1704 | 1703 | break; |
| 1705 | 1704 | |
| 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: | |
| 1712 | 1706 | |
| 1713 | − case 37: | |
| 1714 | −#line 293 "dtc-parser.y" | |
| 1707 | +/* Line 1455 of yacc.c */ | |
| 1708 | +#line 272 "dtc-parser.y" | |
| 1715 | 1709 | { |
| 1716 | 1710 | (yyval.data) = empty_data; |
| 1717 | 1711 | ;} |
| 1718 | 1712 | break; |
| 1719 | 1713 | |
| 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" | |
| 1722 | 1718 | { |
| 1723 | 1719 | (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); |
| 1724 | 1720 | ;} |
| 1725 | 1721 | break; |
| 1726 | 1722 | |
| 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" | |
| 1729 | 1727 | { |
| 1730 | 1728 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); |
| 1731 | 1729 | ;} |
| 1732 | 1730 | break; |
| 1733 | 1731 | |
| 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" | |
| 1736 | 1736 | { |
| 1737 | 1737 | (yyval.nodelist) = NULL; |
| 1738 | 1738 | ;} |
| 1739 | 1739 | break; |
| 1740 | 1740 | |
| 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" | |
| 1743 | 1745 | { |
| 1744 | 1746 | (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); |
| 1745 | 1747 | ;} |
| 1746 | 1748 | break; |
| 1747 | 1749 | |
| 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" | |
| 1750 | 1754 | { |
| 1751 | − yyerror("syntax error: properties must precede subnodes"); | |
| 1755 | + print_error("syntax error: properties must precede subnodes"); | |
| 1752 | 1756 | YYERROR; |
| 1753 | 1757 | ;} |
| 1754 | 1758 | break; |
| 1755 | 1759 | |
| 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: | |
| 1762 | 1761 | |
| 1763 | − case 44: | |
| 1764 | −#line 331 "dtc-parser.y" | |
| 1762 | +/* Line 1455 of yacc.c */ | |
| 1763 | +#line 303 "dtc-parser.y" | |
| 1765 | 1764 | { |
| 1766 | − (yyval.labelref) = NULL; | |
| 1765 | + (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename)); | |
| 1767 | 1766 | ;} |
| 1768 | 1767 | break; |
| 1769 | 1768 | |
| 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" | |
| 1772 | 1773 | { |
| 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); | |
| 1774 | 1776 | ;} |
| 1775 | 1777 | break; |
| 1776 | 1778 | |
| 1777 | 1779 | |
| 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" | |
| 1780 | 1783 | default: break; |
| 1781 | 1784 | } |
| 1782 | 1785 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); |
| @@ -1786,7 +1789,6 @@ yyreduce: · 3 unmodified lines | ||
| 1786 | 1789 | YY_STACK_PRINT (yyss, yyssp); |
| 1787 | 1790 | |
| 1788 | 1791 | *++yyvsp = yyval; |
| 1789 | − *++yylsp = yyloc; | |
| 1790 | 1792 | |
| 1791 | 1793 | /* Now `shift' the result of the reduction. Determine what state |
| 1792 | 1794 | that goes to, based on the state we popped back to and the rule |
| @@ -1848,11 +1850,11 @@ yyerrlab: · 55 unmodified lines | ||
| 1848 | 1850 | #endif |
| 1849 | 1851 | } |
| 1850 | 1852 | |
| 1851 | − yyerror_range[0] = yylloc; | |
| 1853 | + | |
| 1852 | 1854 | |
| 1853 | 1855 | if (yyerrstatus == 3) |
| 1854 | 1856 | { |
| 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 | |
| 1856 | 1858 | error, discard it. */ |
| 1857 | 1859 | |
| 1858 | 1860 | if (yychar <= YYEOF) |
| @@ -1864,12 +1866,12 @@ yyerrlab: · 5 unmodified lines | ||
| 1864 | 1866 | else |
| 1865 | 1867 | { |
| 1866 | 1868 | yydestruct ("Error: discarding", |
| 1867 | − yytoken, &yylval, &yylloc); | |
| 1869 | + yytoken, &yylval); | |
| 1868 | 1870 | yychar = YYEMPTY; |
| 1869 | 1871 | } |
| 1870 | 1872 | } |
| 1871 | 1873 | |
| 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 | |
| 1873 | 1875 | token. */ |
| 1874 | 1876 | goto yyerrlab1; |
| 1875 | 1877 | |
| @@ -1885,7 +1887,6 @@ yyerrorlab: · 9 unmodified lines | ||
| 1885 | 1887 | if (/*CONSTCOND*/ 0) |
| 1886 | 1888 | goto yyerrorlab; |
| 1887 | 1889 | |
| 1888 | − yyerror_range[0] = yylsp[1-yylen]; | |
| 1889 | 1890 | /* Do not reclaim the symbols of the rule which action triggered |
| 1890 | 1891 | this YYERROR. */ |
| 1891 | 1892 | YYPOPSTACK (yylen); |
| @@ -1919,24 +1920,16 @@ yyerrlab1: · 27 unmodified lines | ||
| 1919 | 1920 | if (yyssp == yyss) |
| 1920 | 1921 | YYABORT; |
| 1921 | 1922 | |
| 1922 | − yyerror_range[0] = *yylsp; | |
| 1923 | + | |
| 1923 | 1924 | yydestruct ("Error: popping", |
| 1924 | − yystos[yystate], yyvsp, yylsp); | |
| 1925 | + yystos[yystate], yyvsp); | |
| 1925 | 1926 | YYPOPSTACK (1); |
| 1926 | 1927 | yystate = *yyssp; |
| 1927 | 1928 | YY_STACK_PRINT (yyss, yyssp); |
| 1928 | 1929 | } |
| 1929 | 1930 | |
| 1930 | − if (yyn == YYFINAL) | |
| 1931 | − YYACCEPT; | |
| 1932 | − | |
| 1933 | 1931 | *++yyvsp = yylval; |
| 1934 | 1932 | |
| 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; | |
| 1940 | 1933 | |
| 1941 | 1934 | /* Shift the error token. */ |
| 1942 | 1935 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
| @@ -1959,7 +1952,7 @@ yyabortlab: · 16 unmodified lines | ||
| 1959 | 1952 | yyresult = 1; |
| 1960 | 1953 | goto yyreturn; |
| 1961 | 1954 | |
| 1962 | −#ifndef yyoverflow | |
| 1955 | +#if !defined(yyoverflow) || YYERROR_VERBOSE | |
| 1963 | 1956 | /*-------------------------------------------------. |
| 1964 | 1957 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 1965 | 1958 | `-------------------------------------------------*/ |
| @@ -1970,9 +1963,9 @@ yyexhaustedlab: · 4 unmodified lines | ||
| 1970 | 1963 | #endif |
| 1971 | 1964 | |
| 1972 | 1965 | yyreturn: |
| 1973 | − if (yychar != YYEOF && yychar != YYEMPTY) | |
| 1966 | + if (yychar != YYEMPTY) | |
| 1974 | 1967 | yydestruct ("Cleanup: discarding lookahead", |
| 1975 | − yytoken, &yylval, &yylloc); | |
| 1968 | + yytoken, &yylval); | |
| 1976 | 1969 | /* Do not reclaim the symbols of the rule which action triggered |
| 1977 | 1970 | this YYABORT or YYACCEPT. */ |
| 1978 | 1971 | YYPOPSTACK (yylen); |
| @@ -1980,7 +1973,7 @@ yyreturn: · 1 unmodified line | ||
| 1980 | 1973 | while (yyssp != yyss) |
| 1981 | 1974 | { |
| 1982 | 1975 | yydestruct ("Cleanup: popping", |
| 1983 | − yystos[*yyssp], yyvsp, yylsp); | |
| 1976 | + yystos[*yyssp], yyvsp); | |
| 1984 | 1977 | YYPOPSTACK (1); |
| 1985 | 1978 | } |
| 1986 | 1979 | #ifndef yyoverflow |
| @@ -1996,29 +1989,24 @@ yyreturn: · 9 unmodified lines | ||
| 1996 | 1989 | } |
| 1997 | 1990 | |
| 1998 | 1991 | |
| 1999 | −#line 340 "dtc-parser.y" | |
| 1992 | + | |
| 1993 | +/* Line 1675 of yacc.c */ | |
| 1994 | +#line 313 "dtc-parser.y" | |
| 2000 | 1995 | |
| 2001 | 1996 | |
| 2002 | −void yyerrorf(char const *s, ...) | |
| 1997 | +void print_error(char const *fmt, ...) | |
| 2003 | 1998 | { |
| 2004 | − const char *fname = srcpos_file ? srcpos_file->name : "<no-file>"; | |
| 2005 | 1999 | va_list va; |
| 2006 | − va_start(va, s); | |
| 2007 | − | |
| 2008 | − if (strcmp(fname, "-") == 0) | |
| 2009 | − fname = "stdin"; | |
| 2010 | 2000 | |
| 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); | |
| 2014 | 2004 | |
| 2015 | 2005 | treesource_error = 1; |
| 2016 | − va_end(va); | |
| 2017 | 2006 | } |
| 2018 | 2007 | |
| 2019 | −void yyerror (char const *s) | |
| 2020 | −{ | |
| 2021 | − yyerrorf("%s", s); | |
| 2008 | +void yyerror(char const *s) { | |
| 2009 | + print_error("%s", s); | |
| 2022 | 2010 | } |
| 2023 | 2011 | |
| 2024 | 2012 | 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 | ||
| 2029 | 2017 | errno = 0; |
| 2030 | 2018 | val = strtoull(s, &e, base); |
| 2031 | 2019 | if (*e) |
| 2032 | − yyerror("bad characters in literal"); | |
| 2020 | + print_error("bad characters in literal"); | |
| 2033 | 2021 | else if ((errno == ERANGE) |
| 2034 | 2022 | || ((bits < 64) && (val >= (1ULL << bits)))) |
| 2035 | − yyerror("literal out of range"); | |
| 2023 | + print_error("literal out of range"); | |
| 2036 | 2024 | else if (errno != 0) |
| 2037 | − yyerror("bad literal"); | |
| 2025 | + print_error("bad literal"); | |
| 2038 | 2026 | return val; |
| 2039 | 2027 | } |
| 2040 | 2028 | |
| @@ -1,24 +1,23 @@ | ||
| 1 | −/* A Bison parser, made by GNU Bison 2.3. */ | |
| 2 | 1 | |
| 3 | −/* Skeleton interface for Bison's Yacc-like parsers in C | |
| 2 | +/* A Bison parser, made by GNU Bison 2.4.1. */ | |
| 4 | 3 | |
| 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 | |
| 6 | 7 | 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 | |
| 9 | 10 | 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 | + | |
| 13 | 14 | This program is distributed in the hope that it will be useful, |
| 14 | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | 17 | GNU General Public License for more details. |
| 17 | − | |
| 18 | + | |
| 18 | 19 | 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/>. */ | |
| 22 | 21 | |
| 23 | 22 | /* As a special exception, you may create a larger work that contains |
| 24 | 23 | part or all of the Bison parser skeleton and distribute that work |
| @@ -29,10 +28,11 @@ · 4 unmodified lines | ||
| 29 | 28 | special exception, which will cause the skeleton and the resulting |
| 30 | 29 | Bison output files to be licensed under the GNU General Public |
| 31 | 30 | License without this special exception. |
| 32 | − | |
| 31 | + | |
| 33 | 32 | This special exception was added by the Free Software Foundation in |
| 34 | 33 | version 2.2 of Bison. */ |
| 35 | 34 | |
| 35 | + | |
| 36 | 36 | /* Tokens. */ |
| 37 | 37 | #ifndef YYTOKENTYPE |
| 38 | 38 | # define YYTOKENTYPE |
| @@ -43,35 +43,24 @@ · 4 unmodified lines | ||
| 43 | 43 | DT_MEMRESERVE = 259, |
| 44 | 44 | DT_PROPNODENAME = 260, |
| 45 | 45 | 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 | |
| 53 | 52 | }; |
| 54 | 53 | #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 | − | |
| 68 | 54 | |
| 69 | 55 | |
| 70 | 56 | |
| 71 | 57 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
| 72 | 58 | typedef union YYSTYPE |
| 73 | −#line 37 "dtc-parser.y" | |
| 74 | 59 | { |
| 60 | + | |
| 61 | +/* Line 1676 of yacc.c */ | |
| 62 | +#line 39 "dtc-parser.y" | |
| 63 | + | |
| 75 | 64 | char *propnodename; |
| 76 | 65 | char *literal; |
| 77 | 66 | char *labelref; |
| @@ -86,28 +75,17 @@ typedef union YYSTYPE · 8 unmodified lines | ||
| 86 | 75 | struct node *node; |
| 87 | 76 | struct node *nodelist; |
| 88 | 77 | 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 | |
| 93 | 85 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 94 | 86 | # define YYSTYPE_IS_DECLARED 1 |
| 95 | −# define YYSTYPE_IS_TRIVIAL 1 | |
| 96 | 87 | #endif |
| 97 | 88 | |
| 98 | 89 | extern YYSTYPE yylval; |
| 99 | 90 | |
| 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 | |
| 112 | 91 | |
| 113 | −extern YYLTYPE yylloc; | |
| @@ -18,15 +18,17 @@ · 17 unmodified lines | ||
| 18 | 18 | * USA |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | −%locations | |
| 22 | − | |
| 23 | 21 | %{ |
| 24 | 22 | #include <stdio.h> |
| 25 | 23 | |
| 26 | 24 | #include "dtc.h" |
| 27 | 25 | #include "srcpos.h" |
| 28 | 26 | |
| 27 | +YYLTYPE yylloc; | |
| 28 | + | |
| 29 | 29 | extern int yylex(void); |
| 30 | +extern void print_error(char const *fmt, ...); | |
| 31 | +extern void yyerror(char const *s); | |
| 30 | 32 | |
| 31 | 33 | extern struct boot_info *the_boot_info; |
| 32 | 34 | extern int treesource_error; |
| @@ -55,7 +57,6 @@ static unsigned long long eval_literal(const char *s, int base, int bits); · 22 unmodified lines | ||
| 55 | 57 | %token DT_MEMRESERVE |
| 56 | 58 | %token <propnodename> DT_PROPNODENAME |
| 57 | 59 | %token <literal> DT_LITERAL |
| 58 | −%token <literal> DT_LEGACYLITERAL | |
| 59 | 60 | %token <cbase> DT_BASE |
| 60 | 61 | %token <byte> DT_BYTE |
| 61 | 62 | %token <data> DT_STRING |
| @@ -67,11 +68,8 @@ static unsigned long long eval_literal(const char *s, int base, int bits); · 5 unmodified lines | ||
| 67 | 68 | %type <data> propdataprefix |
| 68 | 69 | %type <re> memreserve |
| 69 | 70 | %type <re> memreserves |
| 70 | −%type <re> v0_memreserve | |
| 71 | −%type <re> v0_memreserves | |
| 72 | 71 | %type <addr> addr |
| 73 | 72 | %type <data> celllist |
| 74 | −%type <cbase> cellbase | |
| 75 | 73 | %type <cell> cellval |
| 76 | 74 | %type <data> bytestring |
| 77 | 75 | %type <prop> propdef |
| @@ -81,18 +79,14 @@ static unsigned long long eval_literal(const char *s, int base, int bits); · 3 unmodified lines | ||
| 81 | 79 | %type <node> nodedef |
| 82 | 80 | %type <node> subnode |
| 83 | 81 | %type <nodelist> subnodes |
| 84 | −%type <labelref> label | |
| 85 | 82 | |
| 86 | 83 | %% |
| 87 | 84 | |
| 88 | 85 | sourcefile: |
| 89 | 86 | DT_V1 ';' memreserves devicetree |
| 90 | 87 | { |
| 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)); | |
| 96 | 90 | } |
| 97 | 91 | ; |
| 98 | 92 | |
| @@ -108,31 +102,14 @@ memreserves: · 9 unmodified lines | ||
| 108 | 102 | ; |
| 109 | 103 | |
| 110 | 104 | memreserve: |
| 111 | − label DT_MEMRESERVE addr addr ';' | |
| 105 | + DT_MEMRESERVE addr addr ';' | |
| 112 | 106 | { |
| 113 | − $$ = build_reserve_entry($3, $4, $1); | |
| 107 | + $$ = build_reserve_entry($2, $3); | |
| 114 | 108 | } |
| 115 | − ; | |
| 116 | − | |
| 117 | −v0_memreserves: | |
| 118 | − /* empty */ | |
| 109 | + | DT_LABEL memreserve | |
| 119 | 110 | { |
| 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; | |
| 136 | 113 | } |
| 137 | 114 | ; |
| 138 | 115 | |
| @@ -141,16 +118,26 @@ addr: · 2 unmodified lines | ||
| 141 | 118 | { |
| 142 | 119 | $$ = eval_literal($1, 0, 64); |
| 143 | 120 | } |
| 144 | − | DT_LEGACYLITERAL | |
| 145 | − { | |
| 146 | − $$ = eval_literal($1, 16, 64); | |
| 147 | − } | |
| 148 | 121 | ; |
| 149 | 122 | |
| 150 | 123 | devicetree: |
| 151 | 124 | '/' nodedef |
| 152 | 125 | { |
| 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; | |
| 154 | 141 | } |
| 155 | 142 | ; |
| 156 | 143 | |
| @@ -173,13 +160,18 @@ proplist: · 16 unmodified lines | ||
| 173 | 160 | ; |
| 174 | 161 | |
| 175 | 162 | propdef: |
| 176 | − label DT_PROPNODENAME '=' propdata ';' | |
| 163 | + DT_PROPNODENAME '=' propdata ';' | |
| 164 | + { | |
| 165 | + $$ = build_property($1, $3); | |
| 166 | + } | |
| 167 | + | DT_PROPNODENAME ';' | |
| 177 | 168 | { |
| 178 | − $$ = build_property($2, $4, $1); | |
| 169 | + $$ = build_property($1, empty_data); | |
| 179 | 170 | } |
| 180 | − | label DT_PROPNODENAME ';' | |
| 171 | + | DT_LABEL propdef | |
| 181 | 172 | { |
| 182 | − $$ = build_property($2, empty_data, $1); | |
| 173 | + add_label(&$2->labels, $1); | |
| 174 | + $$ = $2; | |
| 183 | 175 | } |
| 184 | 176 | ; |
| 185 | 177 | |
| @@ -202,31 +194,30 @@ propdata: · 16 unmodified lines | ||
| 202 | 194 | } |
| 203 | 195 | | propdataprefix DT_INCBIN '(' DT_STRING ',' addr ',' addr ')' |
| 204 | 196 | { |
| 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; | |
| 208 | 199 | |
| 209 | 200 | 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)); | |
| 214 | 206 | |
| 215 | − d = data_copy_file(file->file, $8); | |
| 207 | + d = data_copy_file(f, $8); | |
| 216 | 208 | |
| 217 | 209 | $$ = data_merge($1, d); |
| 218 | − dtc_close_file(file); | |
| 210 | + fclose(f); | |
| 219 | 211 | } |
| 220 | 212 | | propdataprefix DT_INCBIN '(' DT_STRING ')' |
| 221 | 213 | { |
| 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); | |
| 224 | 215 | struct data d = empty_data; |
| 225 | 216 | |
| 226 | − d = data_copy_file(file->file, -1); | |
| 217 | + d = data_copy_file(f, -1); | |
| 227 | 218 | |
| 228 | 219 | $$ = data_merge($1, d); |
| 229 | − dtc_close_file(file); | |
| 220 | + fclose(f); | |
| 230 | 221 | } |
| 231 | 222 | | propdata DT_LABEL |
| 232 | 223 | { |
| @@ -269,23 +260,11 @@ celllist: · 36 unmodified lines | ||
| 269 | 260 | } |
| 270 | 261 | ; |
| 271 | 262 | |
| 272 | −cellbase: | |
| 273 | − /* empty */ | |
| 274 | − { | |
| 275 | − $$ = 16; | |
| 276 | − } | |
| 277 | − | DT_BASE | |
| 278 | − ; | |
| 279 | − | |
| 280 | 263 | cellval: |
| 281 | 264 | DT_LITERAL |
| 282 | 265 | { |
| 283 | 266 | $$ = eval_literal($1, 0, 32); |
| 284 | 267 | } |
| 285 | − | cellbase DT_LEGACYLITERAL | |
| 286 | − { | |
| 287 | − $$ = eval_literal($2, $1, 32); | |
| 288 | − } | |
| 289 | 268 | ; |
| 290 | 269 | |
| 291 | 270 | bytestring: |
| @@ -308,57 +287,44 @@ subnodes: · 16 unmodified lines | ||
| 308 | 287 | { |
| 309 | 288 | $$ = NULL; |
| 310 | 289 | } |
| 311 | − | subnode subnodes | |
| 290 | + | subnode subnodes | |
| 312 | 291 | { |
| 313 | 292 | $$ = chain_node($1, $2); |
| 314 | 293 | } |
| 315 | 294 | | subnode propdef |
| 316 | 295 | { |
| 317 | − yyerror("syntax error: properties must precede subnodes"); | |
| 296 | + print_error("syntax error: properties must precede subnodes"); | |
| 318 | 297 | YYERROR; |
| 319 | 298 | } |
| 320 | 299 | ; |
| 321 | 300 | |
| 322 | 301 | subnode: |
| 323 | − label DT_PROPNODENAME nodedef | |
| 302 | + DT_PROPNODENAME nodedef | |
| 324 | 303 | { |
| 325 | − $$ = name_node($3, $2, $1); | |
| 304 | + $$ = name_node($2, $1); | |
| 326 | 305 | } |
| 327 | − ; | |
| 328 | − | |
| 329 | −label: | |
| 330 | − /* empty */ | |
| 306 | + | DT_LABEL subnode | |
| 331 | 307 | { |
| 332 | − $$ = NULL; | |
| 333 | − } | |
| 334 | − | DT_LABEL | |
| 335 | − { | |
| 336 | − $$ = $1; | |
| 308 | + add_label(&$2->labels, $1); | |
| 309 | + $$ = $2; | |
| 337 | 310 | } |
| 338 | 311 | ; |
| 339 | 312 | |
| 340 | 313 | %% |
| 341 | 314 | |
| 342 | −void yyerrorf(char const *s, ...) | |
| 315 | +void print_error(char const *fmt, ...) | |
| 343 | 316 | { |
| 344 | − const char *fname = srcpos_file ? srcpos_file->name : "<no-file>"; | |
| 345 | 317 | va_list va; |
| 346 | − va_start(va, s); | |
| 347 | − | |
| 348 | − if (strcmp(fname, "-") == 0) | |
| 349 | − fname = "stdin"; | |
| 350 | 318 | |
| 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); | |
| 354 | 322 | |
| 355 | 323 | treesource_error = 1; |
| 356 | − va_end(va); | |
| 357 | 324 | } |
| 358 | 325 | |
| 359 | −void yyerror (char const *s) | |
| 360 | −{ | |
| 361 | − yyerrorf("%s", s); | |
| 326 | +void yyerror(char const *s) { | |
| 327 | + print_error("%s", s); | |
| 362 | 328 | } |
| 363 | 329 | |
| 364 | 330 | 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 | ||
| 369 | 335 | errno = 0; |
| 370 | 336 | val = strtoull(s, &e, base); |
| 371 | 337 | if (*e) |
| 372 | − yyerror("bad characters in literal"); | |
| 338 | + print_error("bad characters in literal"); | |
| 373 | 339 | else if ((errno == ERANGE) |
| 374 | 340 | || ((bits < 64) && (val >= (1ULL << bits)))) |
| 375 | − yyerror("literal out of range"); | |
| 341 | + print_error("literal out of range"); | |
| 376 | 342 | else if (errno != 0) |
| 377 | − yyerror("bad literal"); | |
| 343 | + print_error("bad literal"); | |
| 378 | 344 | return val; |
| 379 | 345 | } |
| @@ -30,30 +30,7 @@ int quiet; /* Level of quietness */ · 29 unmodified lines | ||
| 30 | 30 | int reservenum; /* Number of memory reservation slots */ |
| 31 | 31 | int minsize; /* Minimum blob size */ |
| 32 | 32 | 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 */ | |
| 57 | 34 | |
| 58 | 35 | static void fill_fullpaths(struct node *tree, const char *prefix) |
| 59 | 36 | { |
| @@ -104,8 +81,15 @@ static void __attribute__ ((noreturn)) usage(void) · 44 unmodified lines | ||
| 104 | 81 | fprintf(stderr, "\t\tSet the physical boot cpu\n"); |
| 105 | 82 | fprintf(stderr, "\t-f\n"); |
| 106 | 83 | 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"); | |
| 107 | 86 | fprintf(stderr, "\t-v\n"); |
| 108 | 87 | 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"); | |
| 109 | 93 | exit(3); |
| 110 | 94 | } |
| 111 | 95 | |
| @@ -115,7 +99,7 @@ int main(int argc, char *argv[]) · 3 unmodified lines | ||
| 115 | 99 | const char *inform = "dts"; |
| 116 | 100 | const char *outform = "dts"; |
| 117 | 101 | const char *outname = "-"; |
| 118 | − int force = 0, check = 0; | |
| 102 | + int force = 0, check = 0, sort = 0; | |
| 119 | 103 | const char *arg; |
| 120 | 104 | int opt; |
| 121 | 105 | FILE *outf = NULL; |
| @@ -127,7 +111,7 @@ int main(int argc, char *argv[]) · 5 unmodified lines | ||
| 127 | 111 | minsize = 0; |
| 128 | 112 | padsize = 0; |
| 129 | 113 | |
| 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) { | |
| 131 | 115 | switch (opt) { |
| 132 | 116 | case 'I': |
| 133 | 117 | inform = optarg; |
| @@ -165,6 +149,22 @@ int main(int argc, char *argv[]) · 31 unmodified lines | ||
| 165 | 149 | case 'v': |
| 166 | 150 | printf("Version: %s\n", DTC_VERSION); |
| 167 | 151 | 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 | + | |
| 168 | 168 | case 'h': |
| 169 | 169 | default: |
| 170 | 170 | usage(); |
| @@ -182,6 +182,9 @@ int main(int argc, char *argv[]) · 11 unmodified lines | ||
| 182 | 182 | if (minsize && padsize) |
| 183 | 183 | die("Can't set both -p and -S\n"); |
| 184 | 184 | |
| 185 | + if (minsize) | |
| 186 | + fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n"); | |
| 187 | + | |
| 185 | 188 | fprintf(stderr, "DTC: %s->%s on file \"%s\"\n", |
| 186 | 189 | inform, outform, arg); |
| 187 | 190 | |
| @@ -200,6 +203,8 @@ int main(int argc, char *argv[]) · 12 unmodified lines | ||
| 200 | 203 | fill_fullpaths(bi->dt, ""); |
| 201 | 204 | process_checks(force, bi); |
| 202 | 205 | |
| 206 | + if (sort) | |
| 207 | + sort_tree(bi); | |
| 203 | 208 | |
| 204 | 209 | if (streq(outname, "-")) { |
| 205 | 210 | outf = stdout; |
| @@ -34,7 +34,17 @@ · 33 unmodified lines | ||
| 34 | 34 | #include <libfdt_env.h> |
| 35 | 35 | #include <fdt.h> |
| 36 | 36 | |
| 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 | + | |
| 37 | 46 | #define DEFAULT_FDT_VERSION 17 |
| 47 | + | |
| 38 | 48 | /* |
| 39 | 49 | * Command line options |
| 40 | 50 | */ |
| @@ -42,36 +52,11 @@ extern int quiet; /* Level of quietness */ · 1 unmodified line | ||
| 42 | 52 | extern int reservenum; /* Number of memory reservation slots */ |
| 43 | 53 | extern int minsize; /* Minimum blob size */ |
| 44 | 54 | extern int padsize; /* Additional padding to blob */ |
| 55 | +extern int phandle_format; /* Use linux,phandle or phandle properties */ | |
| 45 | 56 | |
| 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 | |
| 75 | 60 | |
| 76 | 61 | typedef uint32_t cell_t; |
| 77 | 62 | |
| @@ -140,13 +125,18 @@ int data_is_one_string(struct data d); · 62 unmodified lines | ||
| 140 | 125 | #define MAX_NODENAME_LEN 31 |
| 141 | 126 | |
| 142 | 127 | /* Live trees */ |
| 128 | +struct label { | |
| 129 | + char *label; | |
| 130 | + struct label *next; | |
| 131 | +}; | |
| 132 | + | |
| 143 | 133 | struct property { |
| 144 | 134 | char *name; |
| 145 | 135 | struct data val; |
| 146 | 136 | |
| 147 | 137 | struct property *next; |
| 148 | 138 | |
| 149 | − char *label; | |
| 139 | + struct label *labels; | |
| 150 | 140 | }; |
| 151 | 141 | |
| 152 | 142 | struct node { |
| @@ -163,22 +153,28 @@ struct node { · 10 unmodified lines | ||
| 163 | 153 | cell_t phandle; |
| 164 | 154 | int addr_cells, size_cells; |
| 165 | 155 | |
| 166 | − char *label; | |
| 156 | + struct label *labels; | |
| 167 | 157 | }; |
| 168 | 158 | |
| 159 | +#define for_each_label(l0, l) \ | |
| 160 | + for ((l) = (l0); (l); (l) = (l)->next) | |
| 161 | + | |
| 169 | 162 | #define for_each_property(n, p) \ |
| 170 | 163 | for ((p) = (n)->proplist; (p); (p) = (p)->next) |
| 171 | 164 | |
| 172 | 165 | #define for_each_child(n, c) \ |
| 173 | 166 | for ((c) = (n)->children; (c); (c) = (c)->next_sibling) |
| 174 | 167 | |
| 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); | |
| 176 | 171 | struct property *chain_property(struct property *first, struct property *list); |
| 177 | 172 | struct property *reverse_properties(struct property *first); |
| 178 | 173 | |
| 179 | 174 | 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); | |
| 181 | 176 | struct node *chain_node(struct node *first, struct node *list); |
| 177 | +struct node *merge_nodes(struct node *old_node, struct node *new_node); | |
| 182 | 178 | |
| 183 | 179 | void add_property(struct node *node, struct property *prop); |
| 184 | 180 | 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 | ||
| 186 | 182 | const char *get_unitname(struct node *node); |
| 187 | 183 | struct property *get_property(struct node *node, const char *propname); |
| 188 | 184 | 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); | |
| 189 | 189 | struct node *get_subnode(struct node *node, const char *nodename); |
| 190 | 190 | struct node *get_node_by_path(struct node *tree, const char *path); |
| 191 | 191 | 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 | ||
| 193 | 193 | struct node *get_node_by_ref(struct node *tree, const char *ref); |
| 194 | 194 | cell_t get_node_phandle(struct node *root, struct node *node); |
| 195 | 195 | |
| 196 | +uint32_t guess_boot_cpuid(struct node *tree); | |
| 197 | + | |
| 196 | 198 | /* Boot info (tree plus memreserve information */ |
| 197 | 199 | |
| 198 | 200 | struct reserve_info { |
| @@ -200,10 +202,10 @@ struct reserve_info { · 1 unmodified line | ||
| 200 | 202 | |
| 201 | 203 | struct reserve_info *next; |
| 202 | 204 | |
| 203 | − char *label; | |
| 205 | + struct label *labels; | |
| 204 | 206 | }; |
| 205 | 207 | |
| 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); | |
| 207 | 209 | struct reserve_info *chain_reserve_entry(struct reserve_info *first, |
| 208 | 210 | struct reserve_info *list); |
| 209 | 211 | struct reserve_info *add_reserve_entry(struct reserve_info *list, |
| @@ -218,6 +220,7 @@ struct boot_info { · 8 unmodified lines | ||
| 218 | 220 | |
| 219 | 221 | struct boot_info *build_boot_info(struct reserve_info *reservelist, |
| 220 | 222 | struct node *tree, uint32_t boot_cpuid_phys); |
| 223 | +void sort_tree(struct boot_info *bi); | |
| 221 | 224 | |
| 222 | 225 | /* Checks */ |
| 223 | 226 | |
| @@ -239,8 +242,4 @@ struct boot_info *dt_from_source(const char *f); · 15 unmodified lines | ||
| 239 | 242 | |
| 240 | 243 | struct boot_info *dt_from_fs(const char *dirname); |
| 241 | 244 | |
| 242 | −/* misc */ | |
| 243 | − | |
| 244 | −char *join_path(const char *path, const char *name); | |
| 245 | − | |
| 246 | 245 | #endif /* _DTC_H */ |
| @@ -52,9 +52,9 @@ struct emitter { · 51 unmodified lines | ||
| 52 | 52 | void (*string)(void *, char *, int); |
| 53 | 53 | void (*align)(void *, int); |
| 54 | 54 | 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); | |
| 58 | 58 | }; |
| 59 | 59 | |
| 60 | 60 | 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 | ||
| 89 | 89 | *dtbuf = data_append_data(*dtbuf, d.val, d.len); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | −static void bin_emit_beginnode(void *e, const char *label) | |
| 92 | +static void bin_emit_beginnode(void *e, struct label *labels) | |
| 93 | 93 | { |
| 94 | 94 | bin_emit_cell(e, FDT_BEGIN_NODE); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | −static void bin_emit_endnode(void *e, const char *label) | |
| 97 | +static void bin_emit_endnode(void *e, struct label *labels) | |
| 98 | 98 | { |
| 99 | 99 | bin_emit_cell(e, FDT_END_NODE); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | −static void bin_emit_property(void *e, const char *label) | |
| 102 | +static void bin_emit_property(void *e, struct label *labels) | |
| 103 | 103 | { |
| 104 | 104 | bin_emit_cell(e, FDT_PROP); |
| 105 | 105 | } |
| @@ -127,11 +127,21 @@ static void emit_offset_label(FILE *f, const char *label, int offset) · 21 unmodified lines | ||
| 127 | 127 | fprintf(f, "%s\t= . + %d\n", label, offset); |
| 128 | 128 | } |
| 129 | 129 | |
| 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 | + | |
| 130 | 138 | static void asm_emit_cell(void *e, cell_t val) |
| 131 | 139 | { |
| 132 | 140 | FILE *f = e; |
| 133 | 141 | |
| 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); | |
| 135 | 145 | } |
| 136 | 146 | |
| 137 | 147 | 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 | ||
| 156 | 166 | { |
| 157 | 167 | FILE *f = e; |
| 158 | 168 | |
| 159 | − fprintf(f, "\t.balign\t%d\n", a); | |
| 169 | + fprintf(f, "\t.balign\t%d, 0\n", a); | |
| 160 | 170 | } |
| 161 | 171 | |
| 162 | 172 | 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 | ||
| 169 | 179 | emit_offset_label(f, m->ref, m->offset); |
| 170 | 180 | |
| 171 | 181 | 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)))); | |
| 174 | 183 | off += sizeof(uint32_t); |
| 175 | 184 | } |
| 176 | 185 | |
| @@ -182,37 +191,43 @@ static void asm_emit_data(void *e, struct data d) · 5 unmodified lines | ||
| 182 | 191 | assert(off == d.len); |
| 183 | 192 | } |
| 184 | 193 | |
| 185 | −static void asm_emit_beginnode(void *e, const char *label) | |
| 194 | +static void asm_emit_beginnode(void *e, struct label *labels) | |
| 186 | 195 | { |
| 187 | 196 | FILE *f = e; |
| 197 | + struct label *l; | |
| 188 | 198 | |
| 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); | |
| 192 | 202 | } |
| 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); | |
| 194 | 205 | } |
| 195 | 206 | |
| 196 | −static void asm_emit_endnode(void *e, const char *label) | |
| 207 | +static void asm_emit_endnode(void *e, struct label *labels) | |
| 197 | 208 | { |
| 198 | 209 | FILE *f = e; |
| 210 | + struct label *l; | |
| 199 | 211 | |
| 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); | |
| 204 | 217 | } |
| 205 | 218 | } |
| 206 | 219 | |
| 207 | −static void asm_emit_property(void *e, const char *label) | |
| 220 | +static void asm_emit_property(void *e, struct label *labels) | |
| 208 | 221 | { |
| 209 | 222 | FILE *f = e; |
| 223 | + struct label *l; | |
| 210 | 224 | |
| 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); | |
| 214 | 228 | } |
| 215 | − fprintf(f, "\t.long\tFDT_PROP\n"); | |
| 229 | + fprintf(f, "\t/* FDT_PROP */\n"); | |
| 230 | + asm_emit_cell(e, FDT_PROP); | |
| 216 | 231 | } |
| 217 | 232 | |
| 218 | 233 | static struct emitter asm_emitter = { |
| @@ -248,7 +263,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, · 29 unmodified lines | ||
| 248 | 263 | struct node *child; |
| 249 | 264 | int seen_name_prop = 0; |
| 250 | 265 | |
| 251 | − emit->beginnode(etarget, tree->label); | |
| 266 | + emit->beginnode(etarget, tree->labels); | |
| 252 | 267 | |
| 253 | 268 | if (vi->flags & FTF_FULLPATH) |
| 254 | 269 | emit->string(etarget, tree->fullpath, 0); |
| @@ -265,7 +280,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, · 10 unmodified lines | ||
| 265 | 280 | |
| 266 | 281 | nameoff = stringtable_insert(strbuf, prop->name); |
| 267 | 282 | |
| 268 | − emit->property(etarget, prop->label); | |
| 283 | + emit->property(etarget, prop->labels); | |
| 269 | 284 | emit->cell(etarget, prop->val.len); |
| 270 | 285 | emit->cell(etarget, nameoff); |
| 271 | 286 | |
| @@ -292,7 +307,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, · 20 unmodified lines | ||
| 292 | 307 | flatten_tree(child, emit, etarget, strbuf, vi); |
| 293 | 308 | } |
| 294 | 309 | |
| 295 | − emit->endnode(etarget, tree->label); | |
| 310 | + emit->endnode(etarget, tree->labels); | |
| 296 | 311 | } |
| 297 | 312 | |
| 298 | 313 | 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 | ||
| 413 | 428 | if (padlen > 0) |
| 414 | 429 | blob = data_append_zeroes(blob, padlen); |
| 415 | 430 | |
| 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 | + } | |
| 420 | 438 | |
| 421 | 439 | /* |
| 422 | 440 | * 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 | ||
| 455 | 473 | die("Unknown device tree blob version %d\n", version); |
| 456 | 474 | |
| 457 | 475 | 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"); | |
| 464 | 476 | |
| 465 | 477 | emit_label(f, symprefix, "blob_start"); |
| 466 | 478 | 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", | |
| 471 | 486 | 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", | |
| 473 | 489 | 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", | |
| 475 | 492 | 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 | + } | |
| 483 | 502 | |
| 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 | + } | |
| 487 | 508 | |
| 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", | |
| 490 | 512 | symprefix, symprefix); |
| 513 | + } | |
| 491 | 514 | |
| 492 | 515 | /* |
| 493 | 516 | * Reserve map entries. |
| @@ -505,16 +528,17 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) · 11 unmodified lines | ||
| 505 | 528 | * as it appears .quad isn't available in some assemblers. |
| 506 | 529 | */ |
| 507 | 530 | 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); | |
| 511 | 536 | } |
| 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)); | |
| 518 | 542 | } |
| 519 | 543 | for (i = 0; i < reservenum; i++) { |
| 520 | 544 | 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 | ||
| 524 | 548 | |
| 525 | 549 | emit_label(f, symprefix, "struct_start"); |
| 526 | 550 | 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); | |
| 528 | 554 | emit_label(f, symprefix, "struct_end"); |
| 529 | 555 | |
| 530 | 556 | emit_label(f, symprefix, "strings_start"); |
| @@ -601,7 +627,7 @@ static char *flat_read_string(struct inbuf *inb) · 70 unmodified lines | ||
| 601 | 627 | len++; |
| 602 | 628 | } while ((*p++) != '\0'); |
| 603 | 629 | |
| 604 | − str = strdup(inb->ptr); | |
| 630 | + str = xstrdup(inb->ptr); | |
| 605 | 631 | |
| 606 | 632 | inb->ptr += len; |
| 607 | 633 | |
| @@ -643,7 +669,7 @@ static char *flat_read_stringtable(struct inbuf *inb, int offset) · 35 unmodified lines | ||
| 643 | 669 | p++; |
| 644 | 670 | } |
| 645 | 671 | |
| 646 | − return strdup(inb->base + offset); | |
| 672 | + return xstrdup(inb->base + offset); | |
| 647 | 673 | } |
| 648 | 674 | |
| 649 | 675 | 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 | ||
| 663 | 689 | |
| 664 | 690 | val = flat_read_data(dtbuf, proplen); |
| 665 | 691 | |
| 666 | − return build_property(name, val, NULL); | |
| 692 | + return build_property(name, val); | |
| 667 | 693 | } |
| 668 | 694 | |
| 669 | 695 | |
| @@ -688,7 +714,7 @@ static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb) · 18 unmodified lines | ||
| 688 | 714 | if (re.size == 0) |
| 689 | 715 | break; |
| 690 | 716 | |
| 691 | − new = build_reserve_entry(re.address, re.size, NULL); | |
| 717 | + new = build_reserve_entry(re.address, re.size); | |
| 692 | 718 | reservelist = add_reserve_entry(reservelist, new); |
| 693 | 719 | } |
| 694 | 720 | |
| @@ -710,7 +736,7 @@ static char *nodename_from_path(const char *ppath, const char *cpath) · 15 unmodified lines | ||
| 710 | 736 | if (!streq(ppath, "/")) |
| 711 | 737 | plen++; |
| 712 | 738 | |
| 713 | − return strdup(cpath + plen); | |
| 739 | + return xstrdup(cpath + plen); | |
| 714 | 740 | } |
| 715 | 741 | |
| 716 | 742 | static struct node *unflatten_tree(struct inbuf *dtbuf, |
| @@ -776,7 +802,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf, · 59 unmodified lines | ||
| 776 | 802 | |
| 777 | 803 | struct boot_info *dt_from_blob(const char *fname) |
| 778 | 804 | { |
| 779 | − struct dtc_file *dtcf; | |
| 805 | + FILE *f; | |
| 780 | 806 | uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys; |
| 781 | 807 | uint32_t off_dt, off_str, off_mem_rsvmap; |
| 782 | 808 | int rc; |
| @@ -791,14 +817,14 @@ struct boot_info *dt_from_blob(const char *fname) · 8 unmodified lines | ||
| 791 | 817 | uint32_t val; |
| 792 | 818 | int flags = 0; |
| 793 | 819 | |
| 794 | − dtcf = dtc_open_file(fname, NULL); | |
| 820 | + f = srcfile_relative_open(fname, NULL); | |
| 795 | 821 | |
| 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)) | |
| 798 | 824 | die("Error reading DT blob magic number: %s\n", |
| 799 | 825 | strerror(errno)); |
| 800 | 826 | if (rc < 1) { |
| 801 | − if (feof(dtcf->file)) | |
| 827 | + if (feof(f)) | |
| 802 | 828 | die("EOF reading DT blob magic number\n"); |
| 803 | 829 | else |
| 804 | 830 | die("Mysterious short read reading magic number\n"); |
| @@ -808,11 +834,11 @@ struct boot_info *dt_from_blob(const char *fname) · 3 unmodified lines | ||
| 808 | 834 | if (magic != FDT_MAGIC) |
| 809 | 835 | die("Blob has incorrect magic number\n"); |
| 810 | 836 | |
| 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)) | |
| 813 | 839 | die("Error reading DT blob size: %s\n", strerror(errno)); |
| 814 | 840 | if (rc < 1) { |
| 815 | − if (feof(dtcf->file)) | |
| 841 | + if (feof(f)) | |
| 816 | 842 | die("EOF reading DT blob size\n"); |
| 817 | 843 | else |
| 818 | 844 | die("Mysterious short read reading blob size\n"); |
| @@ -832,12 +858,12 @@ struct boot_info *dt_from_blob(const char *fname) · 13 unmodified lines | ||
| 832 | 858 | p = blob + sizeof(magic) + sizeof(totalsize); |
| 833 | 859 | |
| 834 | 860 | while (sizeleft) { |
| 835 | − if (feof(dtcf->file)) | |
| 861 | + if (feof(f)) | |
| 836 | 862 | die("EOF before reading %d bytes of DT blob\n", |
| 837 | 863 | totalsize); |
| 838 | 864 | |
| 839 | − rc = fread(p, 1, sizeleft, dtcf->file); | |
| 840 | − if (ferror(dtcf->file)) | |
| 865 | + rc = fread(p, 1, sizeleft, f); | |
| 866 | + if (ferror(f)) | |
| 841 | 867 | die("Error reading DT blob: %s\n", |
| 842 | 868 | strerror(errno)); |
| 843 | 869 | |
| @@ -900,7 +926,7 @@ struct boot_info *dt_from_blob(const char *fname) · 56 unmodified lines | ||
| 900 | 926 | |
| 901 | 927 | free(blob); |
| 902 | 928 | |
| 903 | − dtc_close_file(dtcf); | |
| 929 | + fclose(f); | |
| 904 | 930 | |
| 905 | 931 | return build_boot_info(reservelist, tree, boot_cpuid_phys); |
| 906 | 932 | } |
| @@ -58,10 +58,9 @@ static struct node *read_fstree(const char *dirname) · 57 unmodified lines | ||
| 58 | 58 | "WARNING: Cannot open %s: %s\n", |
| 59 | 59 | tmpnam, strerror(errno)); |
| 60 | 60 | } else { |
| 61 | − prop = build_property(strdup(de->d_name), | |
| 61 | + prop = build_property(xstrdup(de->d_name), | |
| 62 | 62 | data_copy_file(pfile, |
| 63 | − st.st_size), | |
| 64 | − NULL); | |
| 63 | + st.st_size)); | |
| 65 | 64 | add_property(tree, prop); |
| 66 | 65 | fclose(pfile); |
| 67 | 66 | } |
| @@ -69,8 +68,7 @@ static struct node *read_fstree(const char *dirname) · 1 unmodified line | ||
| 69 | 68 | struct node *newchild; |
| 70 | 69 | |
| 71 | 70 | newchild = read_fstree(tmpnam); |
| 72 | − newchild = name_node(newchild, strdup(de->d_name), | |
| 73 | − NULL); | |
| 71 | + newchild = name_node(newchild, xstrdup(de->d_name)); | |
| 74 | 72 | add_child(tree, newchild); |
| 75 | 73 | } |
| 76 | 74 | |
| @@ -86,8 +84,8 @@ struct boot_info *dt_from_fs(const char *dirname) · 9 unmodified lines | ||
| 86 | 84 | struct node *tree; |
| 87 | 85 | |
| 88 | 86 | tree = read_fstree(dirname); |
| 89 | − tree = name_node(tree, "", NULL); | |
| 87 | + tree = name_node(tree, ""); | |
| 90 | 88 | |
| 91 | − return build_boot_info(NULL, tree, 0); | |
| 89 | + return build_boot_info(NULL, tree, guess_boot_cpuid(tree)); | |
| 92 | 90 | } |
| 93 | 91 | |
| @@ -24,17 +24,30 @@ · 23 unmodified lines | ||
| 24 | 24 | * Tree building functions |
| 25 | 25 | */ |
| 26 | 26 | |
| 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) | |
| 28 | 43 | { |
| 29 | 44 | struct property *new = xmalloc(sizeof(*new)); |
| 30 | 45 | |
| 46 | + memset(new, 0, sizeof(*new)); | |
| 47 | + | |
| 31 | 48 | new->name = name; |
| 32 | 49 | new->val = val; |
| 33 | 50 | |
| 34 | − new->next = NULL; | |
| 35 | − | |
| 36 | − new->label = label; | |
| 37 | − | |
| 38 | 51 | return new; |
| 39 | 52 | } |
| 40 | 53 | |
| @@ -78,17 +91,82 @@ struct node *build_node(struct property *proplist, struct node *children) · 37 unmodified lines | ||
| 78 | 91 | return new; |
| 79 | 92 | } |
| 80 | 93 | |
| 81 | −struct node *name_node(struct node *node, char *name, char * label) | |
| 94 | +struct node *name_node(struct node *node, char *name) | |
| 82 | 95 | { |
| 83 | 96 | assert(node->name == NULL); |
| 84 | 97 | |
| 85 | 98 | node->name = name; |
| 86 | 99 | |
| 87 | − node->label = label; | |
| 88 | − | |
| 89 | 100 | return node; |
| 90 | 101 | } |
| 91 | 102 | |
| 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 | + | |
| 92 | 170 | struct node *chain_node(struct node *first, struct node *list) |
| 93 | 171 | { |
| 94 | 172 | assert(first->next_sibling == NULL); |
| @@ -124,18 +202,15 @@ void add_child(struct node *parent, struct node *child) · 29 unmodified lines | ||
| 124 | 202 | *p = child; |
| 125 | 203 | } |
| 126 | 204 | |
| 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) | |
| 129 | 206 | { |
| 130 | 207 | struct reserve_info *new = xmalloc(sizeof(*new)); |
| 131 | 208 | |
| 209 | + memset(new, 0, sizeof(*new)); | |
| 210 | + | |
| 132 | 211 | new->re.address = address; |
| 133 | 212 | new->re.size = size; |
| 134 | 213 | |
| 135 | − new->next = NULL; | |
| 136 | − | |
| 137 | − new->label = label; | |
| 138 | − | |
| 139 | 214 | return new; |
| 140 | 215 | } |
| 141 | 216 | |
| @@ -208,6 +283,60 @@ cell_t propval_cell(struct property *prop) · 66 unmodified lines | ||
| 208 | 283 | return fdt32_to_cpu(*((cell_t *)prop->val.val)); |
| 209 | 284 | } |
| 210 | 285 | |
| 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 | + | |
| 211 | 340 | struct node *get_subnode(struct node *node, const char *nodename) |
| 212 | 341 | { |
| 213 | 342 | struct node *child; |
| @@ -245,11 +374,13 @@ struct node *get_node_by_path(struct node *tree, const char *path) · 31 unmodified lines | ||
| 245 | 374 | struct node *get_node_by_label(struct node *tree, const char *label) |
| 246 | 375 | { |
| 247 | 376 | struct node *child, *node; |
| 377 | + struct label *l; | |
| 248 | 378 | |
| 249 | 379 | assert(label && (strlen(label) > 0)); |
| 250 | 380 | |
| 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; | |
| 253 | 384 | |
| 254 | 385 | for_each_child(tree, child) { |
| 255 | 386 | 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 | ||
| 293 | 424 | if ((node->phandle != 0) && (node->phandle != -1)) |
| 294 | 425 | return node->phandle; |
| 295 | 426 | |
| 296 | − assert(! get_property(node, "linux,phandle")); | |
| 297 | − | |
| 298 | 427 | while (get_node_by_phandle(root, phandle)) |
| 299 | 428 | phandle++; |
| 300 | 429 | |
| 301 | 430 | 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 */ | |
| 306 | 447 | |
| 307 | 448 | return node->phandle; |
| 308 | 449 | } |
| 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 | +} | |
| @@ -17,100 +17,232 @@ · 16 unmodified lines | ||
| 17 | 17 | * USA |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | +#define _GNU_SOURCE | |
| 21 | + | |
| 22 | +#include <stdio.h> | |
| 23 | + | |
| 20 | 24 | #include "dtc.h" |
| 21 | 25 | #include "srcpos.h" |
| 22 | 26 | |
| 23 | −/* | |
| 24 | − * Like yylineno, this is the current open file pos. | |
| 25 | − */ | |
| 26 | 27 | |
| 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 */ | |
| 28 | 44 | |
| 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) | |
| 32 | 50 | { |
| 51 | + FILE *f; | |
| 33 | 52 | char *fullname; |
| 34 | 53 | |
| 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>"); | |
| 41 | 57 | } 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)); | |
| 43 | 68 | } |
| 44 | 69 | |
| 45 | − file->file = fopen(fullname, "r"); | |
| 46 | − if (!file->file) { | |
| 70 | + if (fullnamep) | |
| 71 | + *fullnamep = fullname; | |
| 72 | + else | |
| 47 | 73 | free(fullname); |
| 48 | − return 0; | |
| 49 | − } | |
| 50 | 74 | |
| 51 | − file->name = fullname; | |
| 52 | − return 1; | |
| 75 | + return f; | |
| 53 | 76 | } |
| 54 | 77 | |
| 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 | +} | |
| 55 | 96 | |
| 56 | −struct dtc_file *dtc_open_file(const char *fname, | |
| 57 | − const struct search_path *search) | |
| 97 | +int srcfile_pop(void) | |
| 58 | 98 | { |
| 59 | − static const struct search_path default_search = { NULL, NULL, NULL }; | |
| 99 | + struct srcfile_state *srcfile = current_srcfile; | |
| 60 | 100 | |
| 61 | − struct dtc_file *file; | |
| 62 | − const char *slash; | |
| 101 | + assert(srcfile); | |
| 63 | 102 | |
| 64 | − file = xmalloc(sizeof(struct dtc_file)); | |
| 103 | + current_srcfile = srcfile->prev; | |
| 65 | 104 | |
| 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)); | |
| 69 | 108 | |
| 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. */ | |
| 76 | 114 | |
| 77 | − if (streq(fname, "-")) { | |
| 78 | − file->name = "stdin"; | |
| 79 | − file->file = stdin; | |
| 80 | − return file; | |
| 81 | − } | |
| 115 | + return current_srcfile ? 1 : 0; | |
| 116 | +} | |
| 82 | 117 | |
| 83 | − if (fname[0] == '/') { | |
| 84 | − file->file = fopen(fname, "r"); | |
| 85 | − if (!file->file) | |
| 86 | − goto fail; | |
| 118 | +/* | |
| 119 | + * The empty source position. | |
| 120 | + */ | |
| 87 | 121 | |
| 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 | +}; | |
| 91 | 129 | |
| 92 | − if (!search) | |
| 93 | − search = &default_search; | |
| 130 | +#define TAB_SIZE 8 | |
| 94 | 131 | |
| 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 | +} | |
| 98 | 155 | |
| 99 | − if (errno != ENOENT) | |
| 100 | − goto fail; | |
| 156 | +struct srcpos * | |
| 157 | +srcpos_copy(struct srcpos *pos) | |
| 158 | +{ | |
| 159 | + struct srcpos *pos_new; | |
| 101 | 160 | |
| 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 | +} | |
| 104 | 180 | |
| 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"); | |
| 107 | 221 | } |
| 108 | 222 | |
| 109 | −void dtc_close_file(struct dtc_file *file) | |
| 223 | +void | |
| 224 | +srcpos_error(struct srcpos *pos, char const *fmt, ...) | |
| 110 | 225 | { |
| 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"); | |
| 113 | 246 | |
| 114 | − free(file->dir); | |
| 115 | − free(file); | |
| 247 | + va_end(va); | |
| 116 | 248 | } |
| @@ -17,69 +17,70 @@ · 16 unmodified lines | ||
| 17 | 17 | * USA |
| 18 | 18 | */ |
| 19 | 19 | |
| 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_ | |
| 24 | 22 | |
| 25 | 23 | #include <stdio.h> |
| 26 | 24 | |
| 27 | −struct dtc_file { | |
| 25 | +struct srcfile_state { | |
| 26 | + FILE *f; | |
| 27 | + char *name; | |
| 28 | 28 | char *dir; |
| 29 | − const char *name; | |
| 30 | − FILE *file; | |
| 29 | + int lineno, colno; | |
| 30 | + struct srcfile_state *prev; | |
| 31 | 31 | }; |
| 32 | 32 | |
| 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 { | |
| 35 | 40 | int first_line; |
| 36 | 41 | int first_column; |
| 37 | 42 | int last_line; |
| 38 | 43 | 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 | +}; | |
| 50 | 46 | |
| 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 | |
| 70 | 48 | |
| 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) | |
| 71 | 65 | |
| 72 | 66 | |
| 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; | |
| 75 | 73 | |
| 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); | |
| 77 | 78 | |
| 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))); | |
| 82 | 85 | |
| 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_ */ | |
| @@ -32,8 +32,8 @@ struct boot_info *dt_from_source(const char *fname) · 31 unmodified lines | ||
| 32 | 32 | the_boot_info = NULL; |
| 33 | 33 | treesource_error = 0; |
| 34 | 34 | |
| 35 | − srcpos_file = dtc_open_file(fname, NULL); | |
| 36 | − yyin = srcpos_file->file; | |
| 35 | + srcfile_push(fname); | |
| 36 | + yyin = current_srcfile->f; | |
| 37 | 37 | |
| 38 | 38 | if (yyparse() != 0) |
| 39 | 39 | die("Unable to parse input tree\n"); |
| @@ -63,26 +63,20 @@ static void write_propval_string(FILE *f, struct data val) · 23 unmodified lines | ||
| 63 | 63 | { |
| 64 | 64 | const char *str = val.val; |
| 65 | 65 | int i; |
| 66 | − int newchunk = 1; | |
| 67 | 66 | struct marker *m = val.markers; |
| 68 | 67 | |
| 69 | 68 | assert(str[val.len-1] == '\0'); |
| 70 | 69 | |
| 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 | + | |
| 71 | 77 | for (i = 0; i < (val.len-1); i++) { |
| 72 | 78 | char c = str[i]; |
| 73 | 79 | |
| 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 | − | |
| 86 | 80 | switch (c) { |
| 87 | 81 | case '\a': |
| 88 | 82 | fprintf(f, "\\a"); |
| @@ -113,7 +107,14 @@ static void write_propval_string(FILE *f, struct data val) · 24 unmodified lines | ||
| 113 | 107 | break; |
| 114 | 108 | case '\0': |
| 115 | 109 | 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, "\""); | |
| 117 | 118 | break; |
| 118 | 119 | default: |
| 119 | 120 | if (isprint(c)) |
| @@ -234,10 +235,11 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level) · 114 unmodified lines | ||
| 234 | 235 | { |
| 235 | 236 | struct property *prop; |
| 236 | 237 | struct node *child; |
| 238 | + struct label *l; | |
| 237 | 239 | |
| 238 | 240 | 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); | |
| 241 | 243 | if (tree->name && (*tree->name)) |
| 242 | 244 | fprintf(f, "%s {\n", tree->name); |
| 243 | 245 | else |
| @@ -245,8 +247,8 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level) · 1 unmodified line | ||
| 245 | 247 | |
| 246 | 248 | for_each_property(tree, prop) { |
| 247 | 249 | 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); | |
| 250 | 252 | fprintf(f, "%s", prop->name); |
| 251 | 253 | write_propval(f, prop); |
| 252 | 254 | } |
| @@ -266,8 +268,10 @@ void dt_to_source(FILE *f, struct boot_info *bi) · 13 unmodified lines | ||
| 266 | 268 | fprintf(f, "/dts-v1/;\n\n"); |
| 267 | 269 | |
| 268 | 270 | 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); | |
| 271 | 275 | fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n", |
| 272 | 276 | (unsigned long long)re->re.address, |
| 273 | 277 | (unsigned long long)re->re.size); |
| @@ -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 | +} | |
| @@ -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 */ | |
| @@ -1 +1 @@ | ||
| 1 | −#define DTC_VERSION "DTC 1.2.0" | |
| 1 | +#define DTC_VERSION "DTC 1.2.0-g37c0b6a0" | |