diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-26 15:09:58 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-26 15:09:58 -0400 |
| commit | b27186abb37b7bd19e0ca434f4f425c807dbd708 (patch) | |
| tree | 8f20702cf0744cc66907d3b8578a8083cd25d680 | |
| parent | 0ef7791e2bfb2e10aa95dc492eab72074cef9942 (diff) | |
| parent | d061864b89c3234b53d8884027b0cd6f06bd3149 (diff) | |
Merge tag 'devicetree-for-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
Pull Devicetree updates from Rob Herring:
"A bit bigger than normal as I've been busy this cycle.
There's a few things with dependencies and a few things subsystem
maintainers didn't pick up, so I'm taking them thru my tree.
The fixes from Johan didn't get into linux-next, but they've been
waiting for some time now and they are what's left of what subsystem
maintainers didn't pick up.
Summary:
- Sync dtc with upstream version v1.4.7-14-gc86da84d30e4
- Work to get rid of direct accesses to struct device_node name and
type pointers in preparation for removing them. New helpers for
parsing DT cpu nodes and conversions to use the helpers. printk
conversions to %pOFn for printing DT node names. Most went thru
subystem trees, so this is the remainder.
- Fixes to DT child node lookups to actually be restricted to child
nodes instead of treewide.
- Refactoring of dtb targets out of arch code. This makes the support
more uniform and enables building all dtbs on c6x, microblaze, and
powerpc.
- Various DT binding updates for Renesas r8a7744 SoC
- Vendor prefixes for Facebook, OLPC
- Restructuring of some ARM binding docs moving some peripheral
bindings out of board/SoC binding files
- New "secure-chosen" binding for secure world settings on ARM
- Dual licensing of 2 DT IRQ binding headers"
* tag 'devicetree-for-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (78 commits)
ARM: dt: relicense two DT binding IRQ headers
power: supply: twl4030-charger: fix OF sibling-node lookup
NFC: nfcmrvl_uart: fix OF child-node lookup
net: stmmac: dwmac-sun8i: fix OF child-node lookup
net: bcmgenet: fix OF child-node lookup
drm/msm: fix OF child-node lookup
drm/mediatek: fix OF sibling-node lookup
of: Add missing exports of node name compare functions
dt-bindings: Add OLPC vendor prefix
dt-bindings: misc: bk4: Add device tree binding for Liebherr's BK4 SPI bus
dt-bindings: thermal: samsung: Add SPDX license identifier
dt-bindings: clock: samsung: Add SPDX license identifiers
dt-bindings: timer: ostm: Add R7S9210 support
dt-bindings: phy: rcar-gen2: Add r8a7744 support
dt-bindings: can: rcar_can: Add r8a7744 support
dt-bindings: timer: renesas, cmt: Document r8a7744 CMT support
dt-bindings: watchdog: renesas-wdt: Document r8a7744 support
dt-bindings: thermal: rcar: Add device tree support for r8a7744
Documentation: dt: Add binding for /secure-chosen/stdout-path
dt-bindings: arm: zte: Move sysctrl bindings to their own doc
...
140 files changed, 1736 insertions, 1043 deletions
diff --git a/Documentation/devicetree/bindings/arm/al,alpine.txt b/Documentation/devicetree/bindings/arm/al,alpine.txt index f404a4f9b165..d00debe2e86f 100644 --- a/Documentation/devicetree/bindings/arm/al,alpine.txt +++ b/Documentation/devicetree/bindings/arm/al,alpine.txt | |||
| @@ -14,75 +14,3 @@ compatible: must contain "al,alpine" | |||
| 14 | 14 | ||
| 15 | ... | 15 | ... |
| 16 | } | 16 | } |
| 17 | |||
| 18 | * CPU node: | ||
| 19 | |||
| 20 | The Alpine platform includes cortex-a15 cores. | ||
| 21 | enable-method: must be "al,alpine-smp" to allow smp [1] | ||
| 22 | |||
| 23 | Example: | ||
| 24 | |||
| 25 | cpus { | ||
| 26 | #address-cells = <1>; | ||
| 27 | #size-cells = <0>; | ||
| 28 | enable-method = "al,alpine-smp"; | ||
| 29 | |||
| 30 | cpu@0 { | ||
| 31 | compatible = "arm,cortex-a15"; | ||
| 32 | device_type = "cpu"; | ||
| 33 | reg = <0>; | ||
| 34 | }; | ||
| 35 | |||
| 36 | cpu@1 { | ||
| 37 | compatible = "arm,cortex-a15"; | ||
| 38 | device_type = "cpu"; | ||
| 39 | reg = <1>; | ||
| 40 | }; | ||
| 41 | |||
| 42 | cpu@2 { | ||
| 43 | compatible = "arm,cortex-a15"; | ||
| 44 | device_type = "cpu"; | ||
| 45 | reg = <2>; | ||
| 46 | }; | ||
| 47 | |||
| 48 | cpu@3 { | ||
| 49 | compatible = "arm,cortex-a15"; | ||
| 50 | device_type = "cpu"; | ||
| 51 | reg = <3>; | ||
| 52 | }; | ||
| 53 | }; | ||
| 54 | |||
| 55 | |||
| 56 | * Alpine CPU resume registers | ||
| 57 | |||
| 58 | The CPU resume register are used to define required resume address after | ||
| 59 | reset. | ||
| 60 | |||
| 61 | Properties: | ||
| 62 | - compatible : Should contain "al,alpine-cpu-resume". | ||
| 63 | - reg : Offset and length of the register set for the device | ||
| 64 | |||
| 65 | Example: | ||
| 66 | |||
| 67 | cpu_resume { | ||
| 68 | compatible = "al,alpine-cpu-resume"; | ||
| 69 | reg = <0xfbff5ed0 0x30>; | ||
| 70 | }; | ||
| 71 | |||
| 72 | * Alpine System-Fabric Service Registers | ||
| 73 | |||
| 74 | The System-Fabric Service Registers allow various operation on CPU and | ||
| 75 | system fabric, like powering CPUs off. | ||
| 76 | |||
| 77 | Properties: | ||
| 78 | - compatible : Should contain "al,alpine-sysfabric-service" and "syscon". | ||
| 79 | - reg : Offset and length of the register set for the device | ||
| 80 | |||
| 81 | Example: | ||
| 82 | |||
| 83 | nb_service { | ||
| 84 | compatible = "al,alpine-sysfabric-service", "syscon"; | ||
| 85 | reg = <0xfb070000 0x10000>; | ||
| 86 | }; | ||
| 87 | |||
| 88 | [1] arm/cpu-enable-method/al,alpine-smp | ||
diff --git a/Documentation/devicetree/bindings/arm/atmel-at91.txt b/Documentation/devicetree/bindings/arm/atmel-at91.txt index 31220b54d85d..4bf1b4da7659 100644 --- a/Documentation/devicetree/bindings/arm/atmel-at91.txt +++ b/Documentation/devicetree/bindings/arm/atmel-at91.txt | |||
| @@ -70,173 +70,3 @@ compatible: must be one of: | |||
| 70 | - "atmel,samv71q19" | 70 | - "atmel,samv71q19" |
| 71 | - "atmel,samv71q20" | 71 | - "atmel,samv71q20" |
| 72 | - "atmel,samv71q21" | 72 | - "atmel,samv71q21" |
| 73 | |||
| 74 | Chipid required properties: | ||
| 75 | - compatible: Should be "atmel,sama5d2-chipid" | ||
| 76 | - reg : Should contain registers location and length | ||
| 77 | |||
| 78 | PIT Timer required properties: | ||
| 79 | - compatible: Should be "atmel,at91sam9260-pit" | ||
| 80 | - reg: Should contain registers location and length | ||
| 81 | - interrupts: Should contain interrupt for the PIT which is the IRQ line | ||
| 82 | shared across all System Controller members. | ||
| 83 | |||
| 84 | System Timer (ST) required properties: | ||
| 85 | - compatible: Should be "atmel,at91rm9200-st", "syscon", "simple-mfd" | ||
| 86 | - reg: Should contain registers location and length | ||
| 87 | - interrupts: Should contain interrupt for the ST which is the IRQ line | ||
| 88 | shared across all System Controller members. | ||
| 89 | - clocks: phandle to input clock. | ||
| 90 | Its subnodes can be: | ||
| 91 | - watchdog: compatible should be "atmel,at91rm9200-wdt" | ||
| 92 | |||
| 93 | RSTC Reset Controller required properties: | ||
| 94 | - compatible: Should be "atmel,<chip>-rstc". | ||
| 95 | <chip> can be "at91sam9260" or "at91sam9g45" or "sama5d3" | ||
| 96 | - reg: Should contain registers location and length | ||
| 97 | - clocks: phandle to input clock. | ||
| 98 | |||
| 99 | Example: | ||
| 100 | |||
| 101 | rstc@fffffd00 { | ||
| 102 | compatible = "atmel,at91sam9260-rstc"; | ||
| 103 | reg = <0xfffffd00 0x10>; | ||
| 104 | clocks = <&clk32k>; | ||
| 105 | }; | ||
| 106 | |||
| 107 | RAMC SDRAM/DDR Controller required properties: | ||
| 108 | - compatible: Should be "atmel,at91rm9200-sdramc", "syscon" | ||
| 109 | "atmel,at91sam9260-sdramc", | ||
| 110 | "atmel,at91sam9g45-ddramc", | ||
| 111 | "atmel,sama5d3-ddramc", | ||
| 112 | - reg: Should contain registers location and length | ||
| 113 | |||
| 114 | Examples: | ||
| 115 | |||
| 116 | ramc0: ramc@ffffe800 { | ||
| 117 | compatible = "atmel,at91sam9g45-ddramc"; | ||
| 118 | reg = <0xffffe800 0x200>; | ||
| 119 | }; | ||
| 120 | |||
| 121 | SHDWC Shutdown Controller | ||
| 122 | |||
| 123 | required properties: | ||
| 124 | - compatible: Should be "atmel,<chip>-shdwc". | ||
| 125 | <chip> can be "at91sam9260", "at91sam9rl" or "at91sam9x5". | ||
| 126 | - reg: Should contain registers location and length | ||
| 127 | - clocks: phandle to input clock. | ||
| 128 | |||
| 129 | optional properties: | ||
| 130 | - atmel,wakeup-mode: String, operation mode of the wakeup mode. | ||
| 131 | Supported values are: "none", "high", "low", "any". | ||
| 132 | - atmel,wakeup-counter: Counter on Wake-up 0 (between 0x0 and 0xf). | ||
| 133 | |||
| 134 | optional at91sam9260 properties: | ||
| 135 | - atmel,wakeup-rtt-timer: boolean to enable Real-time Timer Wake-up. | ||
| 136 | |||
| 137 | optional at91sam9rl properties: | ||
| 138 | - atmel,wakeup-rtc-timer: boolean to enable Real-time Clock Wake-up. | ||
| 139 | - atmel,wakeup-rtt-timer: boolean to enable Real-time Timer Wake-up. | ||
| 140 | |||
| 141 | optional at91sam9x5 properties: | ||
| 142 | - atmel,wakeup-rtc-timer: boolean to enable Real-time Clock Wake-up. | ||
| 143 | |||
| 144 | Example: | ||
| 145 | |||
| 146 | shdwc@fffffd10 { | ||
| 147 | compatible = "atmel,at91sam9260-shdwc"; | ||
| 148 | reg = <0xfffffd10 0x10>; | ||
| 149 | clocks = <&clk32k>; | ||
| 150 | }; | ||
| 151 | |||
| 152 | SHDWC SAMA5D2-Compatible Shutdown Controller | ||
| 153 | |||
| 154 | 1) shdwc node | ||
| 155 | |||
| 156 | required properties: | ||
| 157 | - compatible: should be "atmel,sama5d2-shdwc". | ||
| 158 | - reg: should contain registers location and length | ||
| 159 | - clocks: phandle to input clock. | ||
| 160 | - #address-cells: should be one. The cell is the wake-up input index. | ||
| 161 | - #size-cells: should be zero. | ||
| 162 | |||
| 163 | optional properties: | ||
| 164 | |||
| 165 | - debounce-delay-us: minimum wake-up inputs debouncer period in | ||
| 166 | microseconds. It's usually a board-related property. | ||
| 167 | - atmel,wakeup-rtc-timer: boolean to enable Real-Time Clock wake-up. | ||
| 168 | |||
| 169 | The node contains child nodes for each wake-up input that the platform uses. | ||
| 170 | |||
| 171 | 2) input nodes | ||
| 172 | |||
| 173 | Wake-up input nodes are usually described in the "board" part of the Device | ||
| 174 | Tree. Note also that input 0 is linked to the wake-up pin and is frequently | ||
| 175 | used. | ||
| 176 | |||
| 177 | Required properties: | ||
| 178 | - reg: should contain the wake-up input index [0 - 15]. | ||
| 179 | |||
| 180 | Optional properties: | ||
| 181 | - atmel,wakeup-active-high: boolean, the corresponding wake-up input described | ||
| 182 | by the child, forces the wake-up of the core power supply on a high level. | ||
| 183 | The default is to be active low. | ||
| 184 | |||
| 185 | Example: | ||
| 186 | |||
| 187 | On the SoC side: | ||
| 188 | shdwc@f8048010 { | ||
| 189 | compatible = "atmel,sama5d2-shdwc"; | ||
| 190 | reg = <0xf8048010 0x10>; | ||
| 191 | clocks = <&clk32k>; | ||
| 192 | #address-cells = <1>; | ||
| 193 | #size-cells = <0>; | ||
| 194 | atmel,wakeup-rtc-timer; | ||
| 195 | }; | ||
| 196 | |||
| 197 | On the board side: | ||
| 198 | shdwc@f8048010 { | ||
| 199 | debounce-delay-us = <976>; | ||
| 200 | |||
| 201 | input@0 { | ||
| 202 | reg = <0>; | ||
| 203 | }; | ||
| 204 | |||
| 205 | input@1 { | ||
| 206 | reg = <1>; | ||
| 207 | atmel,wakeup-active-high; | ||
| 208 | }; | ||
| 209 | }; | ||
| 210 | |||
| 211 | Special Function Registers (SFR) | ||
| 212 | |||
| 213 | Special Function Registers (SFR) manage specific aspects of the integrated | ||
| 214 | memory, bridge implementations, processor and other functionality not controlled | ||
| 215 | elsewhere. | ||
| 216 | |||
| 217 | required properties: | ||
| 218 | - compatible: Should be "atmel,<chip>-sfr", "syscon" or | ||
| 219 | "atmel,<chip>-sfrbu", "syscon" | ||
| 220 | <chip> can be "sama5d3", "sama5d4" or "sama5d2". | ||
| 221 | - reg: Should contain registers location and length | ||
| 222 | |||
| 223 | sfr@f0038000 { | ||
| 224 | compatible = "atmel,sama5d3-sfr", "syscon"; | ||
| 225 | reg = <0xf0038000 0x60>; | ||
| 226 | }; | ||
| 227 | |||
| 228 | Security Module (SECUMOD) | ||
| 229 | |||
| 230 | The Security Module macrocell provides all necessary secure functions to avoid | ||
| 231 | voltage, temperature, frequency and mechanical attacks on the chip. It also | ||
| 232 | embeds secure memories that can be scrambled | ||
| 233 | |||
| 234 | required properties: | ||
| 235 | - compatible: Should be "atmel,<chip>-secumod", "syscon". | ||
| 236 | <chip> can be "sama5d2". | ||
| 237 | - reg: Should contain registers location and length | ||
| 238 | |||
| 239 | secumod@fc040000 { | ||
| 240 | compatible = "atmel,sama5d2-secumod", "syscon"; | ||
| 241 | reg = <0xfc040000 0x100>; | ||
| 242 | }; | ||
diff --git a/Documentation/devicetree/bindings/arm/atmel-sysregs.txt b/Documentation/devicetree/bindings/arm/atmel-sysregs.txt new file mode 100644 index 000000000000..4b96608ad692 --- /dev/null +++ b/Documentation/devicetree/bindings/arm/atmel-sysregs.txt | |||
| @@ -0,0 +1,171 @@ | |||
| 1 | Atmel system registers | ||
| 2 | |||
| 3 | Chipid required properties: | ||
| 4 | - compatible: Should be "atmel,sama5d2-chipid" | ||
| 5 | - reg : Should contain registers location and length | ||
| 6 | |||
| 7 | PIT Timer required properties: | ||
| 8 | - compatible: Should be "atmel,at91sam9260-pit" | ||
| 9 | - reg: Should contain registers location and length | ||
| 10 | - interrupts: Should contain interrupt for the PIT which is the IRQ line | ||
| 11 | shared across all System Controller members. | ||
| 12 | |||
| 13 | System Timer (ST) required properties: | ||
| 14 | - compatible: Should be "atmel,at91rm9200-st", "syscon", "simple-mfd" | ||
| 15 | - reg: Should contain registers location and length | ||
| 16 | - interrupts: Should contain interrupt for the ST which is the IRQ line | ||
| 17 | shared across all System Controller members. | ||
| 18 | - clocks: phandle to input clock. | ||
| 19 | Its subnodes can be: | ||
| 20 | - watchdog: compatible should be "atmel,at91rm9200-wdt" | ||
| 21 | |||
| 22 | RSTC Reset Controller required properties: | ||
| 23 | - compatible: Should be "atmel,<chip>-rstc". | ||
| 24 | <chip> can be "at91sam9260" or "at91sam9g45" or "sama5d3" | ||
| 25 | - reg: Should contain registers location and length | ||
| 26 | - clocks: phandle to input clock. | ||
| 27 | |||
| 28 | Example: | ||
| 29 | |||
| 30 | rstc@fffffd00 { | ||
| 31 | compatible = "atmel,at91sam9260-rstc"; | ||
| 32 | reg = <0xfffffd00 0x10>; | ||
| 33 | clocks = <&clk32k>; | ||
| 34 | }; | ||
| 35 | |||
| 36 | RAMC SDRAM/DDR Controller required properties: | ||
| 37 | - compatible: Should be "atmel,at91rm9200-sdramc", "syscon" | ||
| 38 | "atmel,at91sam9260-sdramc", | ||
| 39 | "atmel,at91sam9g45-ddramc", | ||
| 40 | "atmel,sama5d3-ddramc", | ||
| 41 | - reg: Should contain registers location and length | ||
| 42 | |||
| 43 | Examples: | ||
| 44 | |||
| 45 | ramc0: ramc@ffffe800 { | ||
| 46 | compatible = "atmel,at91sam9g45-ddramc"; | ||
| 47 | reg = <0xffffe800 0x200>; | ||
| 48 | }; | ||
| 49 | |||
| 50 | SHDWC Shutdown Controller | ||
| 51 | |||
| 52 | required properties: | ||
| 53 | - compatible: Should be "atmel,<chip>-shdwc". | ||
| 54 | <chip> can be "at91sam9260", "at91sam9rl" or "at91sam9x5". | ||
| 55 | - reg: Should contain registers location and length | ||
| 56 | - clocks: phandle to input clock. | ||
| 57 | |||
| 58 | optional properties: | ||
| 59 | - atmel,wakeup-mode: String, operation mode of the wakeup mode. | ||
| 60 | Supported values are: "none", "high", "low", "any". | ||
| 61 | - atmel,wakeup-counter: Counter on Wake-up 0 (between 0x0 and 0xf). | ||
| 62 | |||
| 63 | optional at91sam9260 properties: | ||
| 64 | - atmel,wakeup-rtt-timer: boolean to enable Real-time Timer Wake-up. | ||
| 65 | |||
| 66 | optional at91sam9rl properties: | ||
| 67 | - atmel,wakeup-rtc-timer: boolean to enable Real-time Clock Wake-up. | ||
| 68 | - atmel,wakeup-rtt-timer: boolean to enable Real-time Timer Wake-up. | ||
| 69 | |||
| 70 | optional at91sam9x5 properties: | ||
| 71 | - atmel,wakeup-rtc-timer: boolean to enable Real-time Clock Wake-up. | ||
| 72 | |||
| 73 | Example: | ||
| 74 | |||
| 75 | shdwc@fffffd10 { | ||
| 76 | compatible = "atmel,at91sam9260-shdwc"; | ||
| 77 | reg = <0xfffffd10 0x10>; | ||
| 78 | clocks = <&clk32k>; | ||
| 79 | }; | ||
| 80 | |||
| 81 | SHDWC SAMA5D2-Compatible Shutdown Controller | ||
| 82 | |||
| 83 | 1) shdwc node | ||
| 84 | |||
| 85 | required properties: | ||
| 86 | - compatible: should be "atmel,sama5d2-shdwc". | ||
| 87 | - reg: should contain registers location and length | ||
| 88 | - clocks: phandle to input clock. | ||
| 89 | - #address-cells: should be one. The cell is the wake-up input index. | ||
| 90 | - #size-cells: should be zero. | ||
| 91 | |||
| 92 | optional properties: | ||
| 93 | |||
| 94 | - debounce-delay-us: minimum wake-up inputs debouncer period in | ||
| 95 | microseconds. It's usually a board-related property. | ||
| 96 | - atmel,wakeup-rtc-timer: boolean to enable Real-Time Clock wake-up. | ||
| 97 | |||
| 98 | The node contains child nodes for each wake-up input that the platform uses. | ||
| 99 | |||
| 100 | 2) input nodes | ||
| 101 | |||
| 102 | Wake-up input nodes are usually described in the "board" part of the Device | ||
| 103 | Tree. Note also that input 0 is linked to the wake-up pin and is frequently | ||
| 104 | used. | ||
| 105 | |||
| 106 | Required properties: | ||
| 107 | - reg: should contain the wake-up input index [0 - 15]. | ||
| 108 | |||
| 109 | Optional properties: | ||
| 110 | - atmel,wakeup-active-high: boolean, the corresponding wake-up input described | ||
| 111 | by the child, forces the wake-up of the core power supply on a high level. | ||
| 112 | The default is to be active low. | ||
| 113 | |||
| 114 | Example: | ||
| 115 | |||
| 116 | On the SoC side: | ||
| 117 | shdwc@f8048010 { | ||
| 118 | compatible = "atmel,sama5d2-shdwc"; | ||
| 119 | reg = <0xf8048010 0x10>; | ||
| 120 | clocks = <&clk32k>; | ||
| 121 | #address-cells = <1>; | ||
| 122 | #size-cells = <0>; | ||
| 123 | atmel,wakeup-rtc-timer; | ||
| 124 | }; | ||
| 125 | |||
| 126 | On the board side: | ||
| 127 | shdwc@f8048010 { | ||
| 128 | debounce-delay-us = <976>; | ||
| 129 | |||
| 130 | input@0 { | ||
| 131 | reg = <0>; | ||
| 132 | }; | ||
| 133 | |||
| 134 | input@1 { | ||
| 135 | reg = <1>; | ||
| 136 | atmel,wakeup-active-high; | ||
| 137 | }; | ||
| 138 | }; | ||
| 139 | |||
| 140 | Special Function Registers (SFR) | ||
| 141 | |||
| 142 | Special Function Registers (SFR) manage specific aspects of the integrated | ||
| 143 | memory, bridge implementations, processor and other functionality not controlled | ||
| 144 | elsewhere. | ||
| 145 | |||
| 146 | required properties: | ||
| 147 | - compatible: Should be "atmel,<chip>-sfr", "syscon" or | ||
| 148 | "atmel,<chip>-sfrbu", "syscon" | ||
| 149 | <chip> can be "sama5d3", "sama5d4" or "sama5d2". | ||
| 150 | - reg: Should contain registers location and length | ||
| 151 | |||
| 152 | sfr@f0038000 { | ||
| 153 | compatible = "atmel,sama5d3-sfr", "syscon"; | ||
| 154 | reg = <0xf0038000 0x60>; | ||
| 155 | }; | ||
| 156 | |||
| 157 | Security Module (SECUMOD) | ||
| 158 | |||
| 159 | The Security Module macrocell provides all necessary secure functions to avoid | ||
| 160 | voltage, temperature, frequency and mechanical attacks on the chip. It also | ||
| 161 | embeds secure memories that can be scrambled | ||
| 162 | |||
| 163 | required properties: | ||
| 164 | - compatible: Should be "atmel,<chip>-secumod", "syscon". | ||
| 165 | <chip> can be "sama5d2". | ||
| 166 | - reg: Should contain registers location and length | ||
| 167 | |||
| 168 | secumod@fc040000 { | ||
| 169 | compatible = "atmel,sama5d2-secumod", "syscon"; | ||
| 170 | reg = <0xfc040000 0x100>; | ||
| 171 | }; | ||
diff --git a/Documentation/devicetree/bindings/arm/cpu-enable-method/al,alpine-smp b/Documentation/devicetree/bindings/arm/cpu-enable-method/al,alpine-smp index c2e0cc5e4cfd..35e5afb6d9ad 100644 --- a/Documentation/devicetree/bindings/arm/cpu-enable-method/al,alpine-smp +++ b/Documentation/devicetree/bindings/arm/cpu-enable-method/al,alpine-smp | |||
| @@ -14,7 +14,28 @@ Related properties: (none) | |||
| 14 | 14 | ||
| 15 | Note: | 15 | Note: |
| 16 | This enable method requires valid nodes compatible with | 16 | This enable method requires valid nodes compatible with |
| 17 | "al,alpine-cpu-resume" and "al,alpine-nb-service"[1]. | 17 | "al,alpine-cpu-resume" and "al,alpine-nb-service". |
| 18 | |||
| 19 | |||
| 20 | * Alpine CPU resume registers | ||
| 21 | |||
| 22 | The CPU resume register are used to define required resume address after | ||
| 23 | reset. | ||
| 24 | |||
| 25 | Properties: | ||
| 26 | - compatible : Should contain "al,alpine-cpu-resume". | ||
| 27 | - reg : Offset and length of the register set for the device | ||
| 28 | |||
| 29 | |||
| 30 | * Alpine System-Fabric Service Registers | ||
| 31 | |||
| 32 | The System-Fabric Service Registers allow various operation on CPU and | ||
| 33 | system fabric, like powering CPUs off. | ||
| 34 | |||
| 35 | Properties: | ||
| 36 | - compatible : Should contain "al,alpine-sysfabric-service" and "syscon". | ||
| 37 | - reg : Offset and length of the register set for the device | ||
| 38 | |||
| 18 | 39 | ||
| 19 | Example: | 40 | Example: |
| 20 | 41 | ||
| @@ -48,5 +69,12 @@ cpus { | |||
| 48 | }; | 69 | }; |
| 49 | }; | 70 | }; |
| 50 | 71 | ||
| 51 | -- | 72 | cpu_resume { |
| 52 | [1] arm/al,alpine.txt | 73 | compatible = "al,alpine-cpu-resume"; |
| 74 | reg = <0xfbff5ed0 0x30>; | ||
| 75 | }; | ||
| 76 | |||
| 77 | nb_service { | ||
| 78 | compatible = "al,alpine-sysfabric-service", "syscon"; | ||
| 79 | reg = <0xfb070000 0x10000>; | ||
| 80 | }; | ||
diff --git a/Documentation/devicetree/bindings/arm/cpus.txt b/Documentation/devicetree/bindings/arm/cpus.txt index 96dfccc0faa8..b0198a1cf403 100644 --- a/Documentation/devicetree/bindings/arm/cpus.txt +++ b/Documentation/devicetree/bindings/arm/cpus.txt | |||
| @@ -276,7 +276,7 @@ described below. | |||
| 276 | Usage: optional | 276 | Usage: optional |
| 277 | Value type: <prop-encoded-array> | 277 | Value type: <prop-encoded-array> |
| 278 | Definition: A u32 value that represents the running time dynamic | 278 | Definition: A u32 value that represents the running time dynamic |
| 279 | power coefficient in units of mW/MHz/uV^2. The | 279 | power coefficient in units of uW/MHz/V^2. The |
| 280 | coefficient can either be calculated from power | 280 | coefficient can either be calculated from power |
| 281 | measurements or derived by analysis. | 281 | measurements or derived by analysis. |
| 282 | 282 | ||
| @@ -287,7 +287,7 @@ described below. | |||
| 287 | 287 | ||
| 288 | Pdyn = dynamic-power-coefficient * V^2 * f | 288 | Pdyn = dynamic-power-coefficient * V^2 * f |
| 289 | 289 | ||
| 290 | where voltage is in uV, frequency is in MHz. | 290 | where voltage is in V, frequency is in MHz. |
| 291 | 291 | ||
| 292 | Example 1 (dual-cluster big.LITTLE system 32-bit): | 292 | Example 1 (dual-cluster big.LITTLE system 32-bit): |
| 293 | 293 | ||
diff --git a/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-dcfg.txt b/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-dcfg.txt new file mode 100644 index 000000000000..b5cb374dc47d --- /dev/null +++ b/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-dcfg.txt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | Freescale DCFG | ||
| 2 | |||
| 3 | DCFG is the device configuration unit, that provides general purpose | ||
| 4 | configuration and status for the device. Such as setting the secondary | ||
| 5 | core start address and release the secondary core from holdoff and startup. | ||
| 6 | |||
| 7 | Required properties: | ||
| 8 | - compatible: Should contain a chip-specific compatible string, | ||
| 9 | Chip-specific strings are of the form "fsl,<chip>-dcfg", | ||
| 10 | The following <chip>s are known to be supported: | ||
| 11 | ls1012a, ls1021a, ls1043a, ls1046a, ls2080a. | ||
| 12 | |||
| 13 | - reg : should contain base address and length of DCFG memory-mapped registers | ||
| 14 | |||
| 15 | Example: | ||
| 16 | dcfg: dcfg@1ee0000 { | ||
| 17 | compatible = "fsl,ls1021a-dcfg"; | ||
| 18 | reg = <0x0 0x1ee0000 0x0 0x10000>; | ||
| 19 | }; | ||
diff --git a/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-scfg.txt b/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-scfg.txt new file mode 100644 index 000000000000..0ab67b0b216d --- /dev/null +++ b/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-scfg.txt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | Freescale SCFG | ||
| 2 | |||
| 3 | SCFG is the supplemental configuration unit, that provides SoC specific | ||
| 4 | configuration and status registers for the chip. Such as getting PEX port | ||
| 5 | status. | ||
| 6 | |||
| 7 | Required properties: | ||
| 8 | - compatible: Should contain a chip-specific compatible string, | ||
| 9 | Chip-specific strings are of the form "fsl,<chip>-scfg", | ||
| 10 | The following <chip>s are known to be supported: | ||
| 11 | ls1012a, ls1021a, ls1043a, ls1046a, ls2080a. | ||
| 12 | |||
| 13 | - reg: should contain base address and length of SCFG memory-mapped registers | ||
| 14 | |||
| 15 | Example: | ||
| 16 | scfg: scfg@1570000 { | ||
| 17 | compatible = "fsl,ls1021a-scfg"; | ||
| 18 | reg = <0x0 0x1570000 0x0 0x10000>; | ||
| 19 | }; | ||
diff --git a/Documentation/devicetree/bindings/arm/fsl.txt b/Documentation/devicetree/bindings/arm/fsl.txt index 8a1baa2b9723..1e775aaa5c5b 100644 --- a/Documentation/devicetree/bindings/arm/fsl.txt +++ b/Documentation/devicetree/bindings/arm/fsl.txt | |||
| @@ -101,45 +101,6 @@ Freescale LS1021A Platform Device Tree Bindings | |||
| 101 | Required root node compatible properties: | 101 | Required root node compatible properties: |
| 102 | - compatible = "fsl,ls1021a"; | 102 | - compatible = "fsl,ls1021a"; |
| 103 | 103 | ||
| 104 | Freescale SoC-specific Device Tree Bindings | ||
| 105 | ------------------------------------------- | ||
| 106 | |||
| 107 | Freescale SCFG | ||
| 108 | SCFG is the supplemental configuration unit, that provides SoC specific | ||
| 109 | configuration and status registers for the chip. Such as getting PEX port | ||
| 110 | status. | ||
| 111 | Required properties: | ||
| 112 | - compatible: Should contain a chip-specific compatible string, | ||
| 113 | Chip-specific strings are of the form "fsl,<chip>-scfg", | ||
| 114 | The following <chip>s are known to be supported: | ||
| 115 | ls1012a, ls1021a, ls1043a, ls1046a, ls2080a. | ||
| 116 | |||
| 117 | - reg: should contain base address and length of SCFG memory-mapped registers | ||
| 118 | |||
| 119 | Example: | ||
| 120 | scfg: scfg@1570000 { | ||
| 121 | compatible = "fsl,ls1021a-scfg"; | ||
| 122 | reg = <0x0 0x1570000 0x0 0x10000>; | ||
| 123 | }; | ||
| 124 | |||
| 125 | Freescale DCFG | ||
| 126 | DCFG is the device configuration unit, that provides general purpose | ||
| 127 | configuration and status for the device. Such as setting the secondary | ||
| 128 | core start address and release the secondary core from holdoff and startup. | ||
| 129 | Required properties: | ||
| 130 | - compatible: Should contain a chip-specific compatible string, | ||
| 131 | Chip-specific strings are of the form "fsl,<chip>-dcfg", | ||
| 132 | The following <chip>s are known to be supported: | ||
| 133 | ls1012a, ls1021a, ls1043a, ls1046a, ls2080a. | ||
| 134 | |||
| 135 | - reg : should contain base address and length of DCFG memory-mapped registers | ||
| 136 | |||
| 137 | Example: | ||
| 138 | dcfg: dcfg@1ee0000 { | ||
| 139 | compatible = "fsl,ls1021a-dcfg"; | ||
| 140 | reg = <0x0 0x1ee0000 0x0 0x10000>; | ||
| 141 | }; | ||
| 142 | |||
| 143 | Freescale ARMv8 based Layerscape SoC family Device Tree Bindings | 104 | Freescale ARMv8 based Layerscape SoC family Device Tree Bindings |
| 144 | ---------------------------------------------------------------- | 105 | ---------------------------------------------------------------- |
| 145 | 106 | ||
diff --git a/Documentation/devicetree/bindings/arm/secure.txt b/Documentation/devicetree/bindings/arm/secure.txt index e31303fb233a..f27bbff2c780 100644 --- a/Documentation/devicetree/bindings/arm/secure.txt +++ b/Documentation/devicetree/bindings/arm/secure.txt | |||
| @@ -32,7 +32,8 @@ describe the view of Secure world using the standard bindings. These | |||
| 32 | secure- bindings only need to be used where both the Secure and Normal | 32 | secure- bindings only need to be used where both the Secure and Normal |
| 33 | world views need to be described in a single device tree. | 33 | world views need to be described in a single device tree. |
| 34 | 34 | ||
| 35 | Valid Secure world properties: | 35 | Valid Secure world properties |
| 36 | ----------------------------- | ||
| 36 | 37 | ||
| 37 | - secure-status : specifies whether the device is present and usable | 38 | - secure-status : specifies whether the device is present and usable |
| 38 | in the secure world. The combination of this with "status" allows | 39 | in the secure world. The combination of this with "status" allows |
| @@ -51,3 +52,19 @@ Valid Secure world properties: | |||
| 51 | status = "disabled"; secure-status = "okay"; /* S-only */ | 52 | status = "disabled"; secure-status = "okay"; /* S-only */ |
| 52 | status = "disabled"; /* disabled in both */ | 53 | status = "disabled"; /* disabled in both */ |
| 53 | status = "disabled"; secure-status = "disabled"; /* disabled in both */ | 54 | status = "disabled"; secure-status = "disabled"; /* disabled in both */ |
| 55 | |||
| 56 | The secure-chosen node | ||
| 57 | ---------------------- | ||
| 58 | |||
| 59 | Similar to the /chosen node which serves as a place for passing data | ||
| 60 | between firmware and the operating system, the /secure-chosen node may | ||
| 61 | be used to pass data to the Secure OS. Only the properties defined | ||
| 62 | below may appear in the /secure-chosen node. | ||
| 63 | |||
| 64 | - stdout-path : specifies the device to be used by the Secure OS for | ||
| 65 | its console output. The syntax is the same as for /chosen/stdout-path. | ||
| 66 | If the /secure-chosen node exists but the stdout-path property is not | ||
| 67 | present, the Secure OS should not perform any console output. If | ||
| 68 | /secure-chosen does not exist, the Secure OS should use the value of | ||
| 69 | /chosen/stdout-path instead (that is, use the same device as the | ||
| 70 | Normal world OS). | ||
diff --git a/Documentation/devicetree/bindings/arm/zte,sysctrl.txt b/Documentation/devicetree/bindings/arm/zte,sysctrl.txt new file mode 100644 index 000000000000..7e66b7f7ba96 --- /dev/null +++ b/Documentation/devicetree/bindings/arm/zte,sysctrl.txt | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | ZTE sysctrl Registers | ||
| 2 | |||
| 3 | Registers for 'zte,zx296702' SoC: | ||
| 4 | |||
| 5 | System management required properties: | ||
| 6 | - compatible = "zte,sysctrl" | ||
| 7 | |||
| 8 | Low power management required properties: | ||
| 9 | - compatible = "zte,zx296702-pcu" | ||
| 10 | |||
| 11 | Bus matrix required properties: | ||
| 12 | - compatible = "zte,zx-bus-matrix" | ||
| 13 | |||
| 14 | |||
| 15 | Registers for 'zte,zx296718' SoC: | ||
| 16 | |||
| 17 | System management required properties: | ||
| 18 | - compatible = "zte,zx296718-aon-sysctrl" | ||
| 19 | - compatible = "zte,zx296718-sysctrl" | ||
| 20 | |||
| 21 | Example: | ||
| 22 | aon_sysctrl: aon-sysctrl@116000 { | ||
| 23 | compatible = "zte,zx296718-aon-sysctrl", "syscon"; | ||
| 24 | reg = <0x116000 0x1000>; | ||
| 25 | }; | ||
| 26 | |||
| 27 | sysctrl: sysctrl@1463000 { | ||
| 28 | compatible = "zte,zx296718-sysctrl", "syscon"; | ||
| 29 | reg = <0x1463000 0x1000>; | ||
| 30 | }; | ||
diff --git a/Documentation/devicetree/bindings/arm/zte.txt b/Documentation/devicetree/bindings/arm/zte.txt index 83369785d29c..340612794a37 100644 --- a/Documentation/devicetree/bindings/arm/zte.txt +++ b/Documentation/devicetree/bindings/arm/zte.txt | |||
| @@ -1,20 +1,10 @@ | |||
| 1 | ZTE platforms device tree bindings | 1 | ZTE platforms device tree bindings |
| 2 | --------------------------------------- | ||
| 3 | 2 | ||
| 3 | --------------------------------------- | ||
| 4 | - ZX296702 board: | 4 | - ZX296702 board: |
| 5 | Required root node properties: | 5 | Required root node properties: |
| 6 | - compatible = "zte,zx296702-ad1", "zte,zx296702" | 6 | - compatible = "zte,zx296702-ad1", "zte,zx296702" |
| 7 | 7 | ||
| 8 | System management required properties: | ||
| 9 | - compatible = "zte,sysctrl" | ||
| 10 | |||
| 11 | Low power management required properties: | ||
| 12 | - compatible = "zte,zx296702-pcu" | ||
| 13 | |||
| 14 | Bus matrix required properties: | ||
| 15 | - compatible = "zte,zx-bus-matrix" | ||
| 16 | |||
| 17 | |||
| 18 | --------------------------------------- | 8 | --------------------------------------- |
| 19 | - ZX296718 SoC: | 9 | - ZX296718 SoC: |
| 20 | Required root node properties: | 10 | Required root node properties: |
| @@ -22,18 +12,3 @@ Bus matrix required properties: | |||
| 22 | 12 | ||
| 23 | ZX296718 EVB board: | 13 | ZX296718 EVB board: |
| 24 | - "zte,zx296718-evb" | 14 | - "zte,zx296718-evb" |
| 25 | |||
| 26 | System management required properties: | ||
| 27 | - compatible = "zte,zx296718-aon-sysctrl" | ||
| 28 | - compatible = "zte,zx296718-sysctrl" | ||
| 29 | |||
| 30 | Example: | ||
| 31 | aon_sysctrl: aon-sysctrl@116000 { | ||
| 32 | compatible = "zte,zx296718-aon-sysctrl", "syscon"; | ||
| 33 | reg = <0x116000 0x1000>; | ||
| 34 | }; | ||
| 35 | |||
| 36 | sysctrl: sysctrl@1463000 { | ||
| 37 | compatible = "zte,zx296718-sysctrl", "syscon"; | ||
| 38 | reg = <0x1463000 0x1000>; | ||
| 39 | }; | ||
diff --git a/Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt b/Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt index 78d2db9d4de5..d28fd1af01b4 100644 --- a/Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt +++ b/Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt | |||
| @@ -24,7 +24,7 @@ Optional properties: | |||
| 24 | 24 | ||
| 25 | Example: | 25 | Example: |
| 26 | 26 | ||
| 27 | p1_sec_a: crypto@400,d2000000 { | 27 | p1_sec_a: crypto@400d2000000 { |
| 28 | compatible = "hisilicon,hip07-sec"; | 28 | compatible = "hisilicon,hip07-sec"; |
| 29 | reg = <0x400 0xd0000000 0x0 0x10000 | 29 | reg = <0x400 0xd0000000 0x0 0x10000 |
| 30 | 0x400 0xd2000000 0x0 0x10000 | 30 | 0x400 0xd2000000 0x0 0x10000 |
diff --git a/Documentation/devicetree/bindings/fpga/fpga-region.txt b/Documentation/devicetree/bindings/fpga/fpga-region.txt index 6db8aeda461a..90c44694a30b 100644 --- a/Documentation/devicetree/bindings/fpga/fpga-region.txt +++ b/Documentation/devicetree/bindings/fpga/fpga-region.txt | |||
| @@ -415,7 +415,7 @@ DT Overlay contains: | |||
| 415 | firmware-name = "base.rbf"; | 415 | firmware-name = "base.rbf"; |
| 416 | 416 | ||
| 417 | fpga-bridge@4400 { | 417 | fpga-bridge@4400 { |
| 418 | compatible = "altr,freeze-bridge"; | 418 | compatible = "altr,freeze-bridge-controller"; |
| 419 | reg = <0x4400 0x10>; | 419 | reg = <0x4400 0x10>; |
| 420 | 420 | ||
| 421 | fpga_region1: fpga-region1 { | 421 | fpga_region1: fpga-region1 { |
| @@ -427,7 +427,7 @@ DT Overlay contains: | |||
| 427 | }; | 427 | }; |
| 428 | 428 | ||
| 429 | fpga-bridge@4420 { | 429 | fpga-bridge@4420 { |
| 430 | compatible = "altr,freeze-bridge"; | 430 | compatible = "altr,freeze-bridge-controller"; |
| 431 | reg = <0x4420 0x10>; | 431 | reg = <0x4420 0x10>; |
| 432 | 432 | ||
| 433 | fpga_region2: fpga-region2 { | 433 | fpga_region2: fpga-region2 { |
diff --git a/Documentation/devicetree/bindings/i2c/i2c.txt b/Documentation/devicetree/bindings/i2c/i2c.txt index 11263982470e..44efafdfd7f5 100644 --- a/Documentation/devicetree/bindings/i2c/i2c.txt +++ b/Documentation/devicetree/bindings/i2c/i2c.txt | |||
| @@ -84,7 +84,7 @@ Binding may contain optional "interrupts" property, describing interrupts | |||
| 84 | used by the device. I2C core will assign "irq" interrupt (or the very first | 84 | used by the device. I2C core will assign "irq" interrupt (or the very first |
| 85 | interrupt if not using interrupt names) as primary interrupt for the slave. | 85 | interrupt if not using interrupt names) as primary interrupt for the slave. |
| 86 | 86 | ||
| 87 | Alternatively, devices supporting SMbus Host Notify, and connected to | 87 | Alternatively, devices supporting SMBus Host Notify, and connected to |
| 88 | adapters that support this feature, may use "host-notify" property. I2C | 88 | adapters that support this feature, may use "host-notify" property. I2C |
| 89 | core will create a virtual interrupt for Host Notify and assign it as | 89 | core will create a virtual interrupt for Host Notify and assign it as |
| 90 | primary interrupt for the slave. | 90 | primary interrupt for the slave. |
diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt index 9b62831fdf3e..148ef621a5e5 100644 --- a/Documentation/devicetree/bindings/mfd/arizona.txt +++ b/Documentation/devicetree/bindings/mfd/arizona.txt | |||
| @@ -76,7 +76,7 @@ Deprecated properties: | |||
| 76 | Also see child specific device properties: | 76 | Also see child specific device properties: |
| 77 | Regulator - ../regulator/arizona-regulator.txt | 77 | Regulator - ../regulator/arizona-regulator.txt |
| 78 | Extcon - ../extcon/extcon-arizona.txt | 78 | Extcon - ../extcon/extcon-arizona.txt |
| 79 | Sound - ../sound/arizona.txt | 79 | Sound - ../sound/wlf,arizona.txt |
| 80 | 80 | ||
| 81 | Example: | 81 | Example: |
| 82 | 82 | ||
diff --git a/Documentation/devicetree/bindings/misc/lwn-bk4.txt b/Documentation/devicetree/bindings/misc/lwn-bk4.txt new file mode 100644 index 000000000000..d6a8c188c087 --- /dev/null +++ b/Documentation/devicetree/bindings/misc/lwn-bk4.txt | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | * Liebherr's BK4 controller external SPI | ||
| 2 | |||
| 3 | A device which handles data acquisition from compatible industrial | ||
| 4 | peripherals. | ||
| 5 | The SPI is used for data and management purposes in both master and | ||
| 6 | slave modes. | ||
| 7 | |||
| 8 | Required properties: | ||
| 9 | |||
| 10 | - compatible : Should be "lwn,bk4" | ||
| 11 | |||
| 12 | Required SPI properties: | ||
| 13 | |||
| 14 | - reg : Should be address of the device chip select within | ||
| 15 | the controller. | ||
| 16 | |||
| 17 | - spi-max-frequency : Maximum SPI clocking speed of device in Hz, should be | ||
| 18 | 30MHz at most for the Liebherr's BK4 external bus. | ||
| 19 | |||
| 20 | Example: | ||
| 21 | |||
| 22 | spidev0: spi@0 { | ||
| 23 | compatible = "lwn,bk4"; | ||
| 24 | spi-max-frequency = <30000000>; | ||
| 25 | reg = <0>; | ||
| 26 | }; | ||
diff --git a/Documentation/devicetree/bindings/net/can/rcar_can.txt b/Documentation/devicetree/bindings/net/can/rcar_can.txt index 94a7f33ac5e9..cc4372842bf3 100644 --- a/Documentation/devicetree/bindings/net/can/rcar_can.txt +++ b/Documentation/devicetree/bindings/net/can/rcar_can.txt | |||
| @@ -3,6 +3,7 @@ Renesas R-Car CAN controller Device Tree Bindings | |||
| 3 | 3 | ||
| 4 | Required properties: | 4 | Required properties: |
| 5 | - compatible: "renesas,can-r8a7743" if CAN controller is a part of R8A7743 SoC. | 5 | - compatible: "renesas,can-r8a7743" if CAN controller is a part of R8A7743 SoC. |
| 6 | "renesas,can-r8a7744" if CAN controller is a part of R8A7744 SoC. | ||
| 6 | "renesas,can-r8a7745" if CAN controller is a part of R8A7745 SoC. | 7 | "renesas,can-r8a7745" if CAN controller is a part of R8A7745 SoC. |
| 7 | "renesas,can-r8a7778" if CAN controller is a part of R8A7778 SoC. | 8 | "renesas,can-r8a7778" if CAN controller is a part of R8A7778 SoC. |
| 8 | "renesas,can-r8a7779" if CAN controller is a part of R8A7779 SoC. | 9 | "renesas,can-r8a7779" if CAN controller is a part of R8A7779 SoC. |
diff --git a/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt b/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt index eeb9e1874ea6..4f0879a0ca12 100644 --- a/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt +++ b/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt | |||
| @@ -5,6 +5,7 @@ This file provides information on what the device node for the R-Car generation | |||
| 5 | 5 | ||
| 6 | Required properties: | 6 | Required properties: |
| 7 | - compatible: "renesas,usb-phy-r8a7743" if the device is a part of R8A7743 SoC. | 7 | - compatible: "renesas,usb-phy-r8a7743" if the device is a part of R8A7743 SoC. |
| 8 | "renesas,usb-phy-r8a7744" if the device is a part of R8A7744 SoC. | ||
| 8 | "renesas,usb-phy-r8a7745" if the device is a part of R8A7745 SoC. | 9 | "renesas,usb-phy-r8a7745" if the device is a part of R8A7745 SoC. |
| 9 | "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC. | 10 | "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC. |
| 10 | "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC. | 11 | "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC. |
diff --git a/Documentation/devicetree/bindings/reset/fsl,imx7-src.txt b/Documentation/devicetree/bindings/reset/fsl,imx7-src.txt index 5e1afc3d8480..1ab1d109318e 100644 --- a/Documentation/devicetree/bindings/reset/fsl,imx7-src.txt +++ b/Documentation/devicetree/bindings/reset/fsl,imx7-src.txt | |||
| @@ -5,7 +5,7 @@ Please also refer to reset.txt in this directory for common reset | |||
| 5 | controller binding usage. | 5 | controller binding usage. |
| 6 | 6 | ||
| 7 | Required properties: | 7 | Required properties: |
| 8 | - compatible: Should be "fsl,imx7-src", "syscon" | 8 | - compatible: Should be "fsl,imx7d-src", "syscon" |
| 9 | - reg: should be register base and length as documented in the | 9 | - reg: should be register base and length as documented in the |
| 10 | datasheet | 10 | datasheet |
| 11 | - interrupts: Should contain SRC interrupt | 11 | - interrupts: Should contain SRC interrupt |
diff --git a/Documentation/devicetree/bindings/timer/renesas,cmt.txt b/Documentation/devicetree/bindings/timer/renesas,cmt.txt index 49948fcc0631..33992679a8bd 100644 --- a/Documentation/devicetree/bindings/timer/renesas,cmt.txt +++ b/Documentation/devicetree/bindings/timer/renesas,cmt.txt | |||
| @@ -24,6 +24,8 @@ Required Properties: | |||
| 24 | - "renesas,r8a73a4-cmt1" for the 48-bit CMT1 device included in r8a73a4. | 24 | - "renesas,r8a73a4-cmt1" for the 48-bit CMT1 device included in r8a73a4. |
| 25 | - "renesas,r8a7743-cmt0" for the 32-bit CMT0 device included in r8a7743. | 25 | - "renesas,r8a7743-cmt0" for the 32-bit CMT0 device included in r8a7743. |
| 26 | - "renesas,r8a7743-cmt1" for the 48-bit CMT1 device included in r8a7743. | 26 | - "renesas,r8a7743-cmt1" for the 48-bit CMT1 device included in r8a7743. |
| 27 | - "renesas,r8a7744-cmt0" for the 32-bit CMT0 device included in r8a7744. | ||
| 28 | - "renesas,r8a7744-cmt1" for the 48-bit CMT1 device included in r8a7744. | ||
| 27 | - "renesas,r8a7745-cmt0" for the 32-bit CMT0 device included in r8a7745. | 29 | - "renesas,r8a7745-cmt0" for the 32-bit CMT0 device included in r8a7745. |
| 28 | - "renesas,r8a7745-cmt1" for the 48-bit CMT1 device included in r8a7745. | 30 | - "renesas,r8a7745-cmt1" for the 48-bit CMT1 device included in r8a7745. |
| 29 | - "renesas,r8a7790-cmt0" for the 32-bit CMT0 device included in r8a7790. | 31 | - "renesas,r8a7790-cmt0" for the 32-bit CMT0 device included in r8a7790. |
diff --git a/Documentation/devicetree/bindings/timer/renesas,ostm.txt b/Documentation/devicetree/bindings/timer/renesas,ostm.txt index be3ae0fdf775..81a78f8bcf17 100644 --- a/Documentation/devicetree/bindings/timer/renesas,ostm.txt +++ b/Documentation/devicetree/bindings/timer/renesas,ostm.txt | |||
| @@ -9,7 +9,8 @@ Channels are independent from each other. | |||
| 9 | Required Properties: | 9 | Required Properties: |
| 10 | 10 | ||
| 11 | - compatible: must be one or more of the following: | 11 | - compatible: must be one or more of the following: |
| 12 | - "renesas,r7s72100-ostm" for the r7s72100 OSTM | 12 | - "renesas,r7s72100-ostm" for the R7S72100 (RZ/A1) OSTM |
| 13 | - "renesas,r7s9210-ostm" for the R7S9210 (RZ/A2) OSTM | ||
| 13 | - "renesas,ostm" for any OSTM | 14 | - "renesas,ostm" for any OSTM |
| 14 | This is a fallback for the above renesas,*-ostm entries | 15 | This is a fallback for the above renesas,*-ostm entries |
| 15 | 16 | ||
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index f26bf667e530..376f24484182 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt | |||
| @@ -127,6 +127,7 @@ everspin Everspin Technologies, Inc. | |||
| 127 | exar Exar Corporation | 127 | exar Exar Corporation |
| 128 | excito Excito | 128 | excito Excito |
| 129 | ezchip EZchip Semiconductor | 129 | ezchip EZchip Semiconductor |
| 130 | facebook Facebook | ||
| 130 | fairphone Fairphone B.V. | 131 | fairphone Fairphone B.V. |
| 131 | faraday Faraday Technology Corporation | 132 | faraday Faraday Technology Corporation |
| 132 | fastrax Fastrax Oy | 133 | fastrax Fastrax Oy |
| @@ -275,6 +276,7 @@ nxp NXP Semiconductors | |||
| 275 | okaya Okaya Electric America, Inc. | 276 | okaya Okaya Electric America, Inc. |
| 276 | oki Oki Electric Industry Co., Ltd. | 277 | oki Oki Electric Industry Co., Ltd. |
| 277 | olimex OLIMEX Ltd. | 278 | olimex OLIMEX Ltd. |
| 279 | olpc One Laptop Per Child | ||
| 278 | onion Onion Corporation | 280 | onion Onion Corporation |
| 279 | onnn ON Semiconductor Corp. | 281 | onnn ON Semiconductor Corp. |
| 280 | ontat On Tat Industrial Company | 282 | ontat On Tat Industrial Company |
diff --git a/Documentation/devicetree/bindings/watchdog/renesas-wdt.txt b/Documentation/devicetree/bindings/watchdog/renesas-wdt.txt index 9407212a85a8..d72d1181ec62 100644 --- a/Documentation/devicetree/bindings/watchdog/renesas-wdt.txt +++ b/Documentation/devicetree/bindings/watchdog/renesas-wdt.txt | |||
| @@ -6,6 +6,7 @@ Required properties: | |||
| 6 | version. | 6 | version. |
| 7 | Examples with soctypes are: | 7 | Examples with soctypes are: |
| 8 | - "renesas,r8a7743-wdt" (RZ/G1M) | 8 | - "renesas,r8a7743-wdt" (RZ/G1M) |
| 9 | - "renesas,r8a7744-wdt" (RZ/G1N) | ||
| 9 | - "renesas,r8a7745-wdt" (RZ/G1E) | 10 | - "renesas,r8a7745-wdt" (RZ/G1E) |
| 10 | - "renesas,r8a774a1-wdt" (RZ/G2M) | 11 | - "renesas,r8a774a1-wdt" (RZ/G2M) |
| 11 | - "renesas,r8a7790-wdt" (R-Car H2) | 12 | - "renesas,r8a7790-wdt" (R-Car H2) |
| @@ -1063,7 +1063,7 @@ include/config/kernel.release: $(srctree)/Makefile FORCE | |||
| 1063 | # Carefully list dependencies so we do not try to build scripts twice | 1063 | # Carefully list dependencies so we do not try to build scripts twice |
| 1064 | # in parallel | 1064 | # in parallel |
| 1065 | PHONY += scripts | 1065 | PHONY += scripts |
| 1066 | scripts: scripts_basic asm-generic gcc-plugins $(autoksyms_h) | 1066 | scripts: scripts_basic scripts_dtc asm-generic gcc-plugins $(autoksyms_h) |
| 1067 | $(Q)$(MAKE) $(build)=$(@) | 1067 | $(Q)$(MAKE) $(build)=$(@) |
| 1068 | 1068 | ||
| 1069 | # Things we need to do before we recursively start building the kernel | 1069 | # Things we need to do before we recursively start building the kernel |
| @@ -1213,6 +1213,35 @@ kselftest-merge: | |||
| 1213 | +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig | 1213 | +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig |
| 1214 | 1214 | ||
| 1215 | # --------------------------------------------------------------------------- | 1215 | # --------------------------------------------------------------------------- |
| 1216 | # Devicetree files | ||
| 1217 | |||
| 1218 | ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),) | ||
| 1219 | dtstree := arch/$(SRCARCH)/boot/dts | ||
| 1220 | endif | ||
| 1221 | |||
| 1222 | ifneq ($(dtstree),) | ||
| 1223 | |||
| 1224 | %.dtb: prepare3 scripts_dtc | ||
| 1225 | $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ | ||
| 1226 | |||
| 1227 | PHONY += dtbs dtbs_install | ||
| 1228 | dtbs: prepare3 scripts_dtc | ||
| 1229 | $(Q)$(MAKE) $(build)=$(dtstree) | ||
| 1230 | |||
| 1231 | dtbs_install: | ||
| 1232 | $(Q)$(MAKE) $(dtbinst)=$(dtstree) | ||
| 1233 | |||
| 1234 | ifdef CONFIG_OF_EARLY_FLATTREE | ||
| 1235 | all: dtbs | ||
| 1236 | endif | ||
| 1237 | |||
| 1238 | endif | ||
| 1239 | |||
| 1240 | PHONY += scripts_dtc | ||
| 1241 | scripts_dtc: scripts_basic | ||
| 1242 | $(Q)$(MAKE) $(build)=scripts/dtc | ||
| 1243 | |||
| 1244 | # --------------------------------------------------------------------------- | ||
| 1216 | # Modules | 1245 | # Modules |
| 1217 | 1246 | ||
| 1218 | ifdef CONFIG_MODULES | 1247 | ifdef CONFIG_MODULES |
| @@ -1421,6 +1450,12 @@ help: | |||
| 1421 | @echo ' kselftest-merge - Merge all the config dependencies of kselftest to existing' | 1450 | @echo ' kselftest-merge - Merge all the config dependencies of kselftest to existing' |
| 1422 | @echo ' .config.' | 1451 | @echo ' .config.' |
| 1423 | @echo '' | 1452 | @echo '' |
| 1453 | @$(if $(dtstree), \ | ||
| 1454 | echo 'Devicetree:'; \ | ||
| 1455 | echo '* dtbs - Build device tree blobs for enabled boards'; \ | ||
| 1456 | echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \ | ||
| 1457 | echo '') | ||
| 1458 | |||
| 1424 | @echo 'Userspace tools targets:' | 1459 | @echo 'Userspace tools targets:' |
| 1425 | @echo ' use "make tools/help"' | 1460 | @echo ' use "make tools/help"' |
| 1426 | @echo ' or "cd tools; make help"' | 1461 | @echo ' or "cd tools; make help"' |
diff --git a/arch/arc/Makefile b/arch/arc/Makefile index 644815c0516e..c64c505d966c 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile | |||
| @@ -102,11 +102,5 @@ boot_targets += uImage uImage.bin uImage.gz | |||
| 102 | $(boot_targets): vmlinux | 102 | $(boot_targets): vmlinux |
| 103 | $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ | 103 | $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ |
| 104 | 104 | ||
| 105 | %.dtb %.dtb.S %.dtb.o: scripts | ||
| 106 | $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@ | ||
| 107 | |||
| 108 | dtbs: scripts | ||
| 109 | $(Q)$(MAKE) $(build)=$(boot)/dts | ||
| 110 | |||
| 111 | archclean: | 105 | archclean: |
| 112 | $(Q)$(MAKE) $(clean)=$(boot) | 106 | $(Q)$(MAKE) $(clean)=$(boot) |
diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 5c91e0093ee8..05a91d8b89f3 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile | |||
| @@ -303,12 +303,7 @@ else | |||
| 303 | KBUILD_IMAGE := $(boot)/zImage | 303 | KBUILD_IMAGE := $(boot)/zImage |
| 304 | endif | 304 | endif |
| 305 | 305 | ||
| 306 | # Build the DT binary blobs if we have OF configured | 306 | all: $(notdir $(KBUILD_IMAGE)) |
| 307 | ifeq ($(CONFIG_USE_OF),y) | ||
| 308 | KBUILD_DTBS := dtbs | ||
| 309 | endif | ||
| 310 | |||
| 311 | all: $(notdir $(KBUILD_IMAGE)) $(KBUILD_DTBS) | ||
| 312 | 307 | ||
| 313 | 308 | ||
| 314 | archheaders: | 309 | archheaders: |
| @@ -335,17 +330,6 @@ $(BOOT_TARGETS): vmlinux | |||
| 335 | $(INSTALL_TARGETS): | 330 | $(INSTALL_TARGETS): |
| 336 | $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@ | 331 | $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@ |
| 337 | 332 | ||
| 338 | %.dtb: | scripts | ||
| 339 | $(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) $(boot)/dts/$@ | ||
| 340 | |||
| 341 | PHONY += dtbs dtbs_install | ||
| 342 | |||
| 343 | dtbs: prepare scripts | ||
| 344 | $(Q)$(MAKE) $(build)=$(boot)/dts | ||
| 345 | |||
| 346 | dtbs_install: | ||
| 347 | $(Q)$(MAKE) $(dtbinst)=$(boot)/dts | ||
| 348 | |||
| 349 | PHONY += vdso_install | 333 | PHONY += vdso_install |
| 350 | vdso_install: | 334 | vdso_install: |
| 351 | ifeq ($(CONFIG_VDSO),y) | 335 | ifeq ($(CONFIG_VDSO),y) |
| @@ -367,8 +351,6 @@ define archhelp | |||
| 367 | echo ' uImage - U-Boot wrapped zImage' | 351 | echo ' uImage - U-Boot wrapped zImage' |
| 368 | echo ' bootpImage - Combined zImage and initial RAM disk' | 352 | echo ' bootpImage - Combined zImage and initial RAM disk' |
| 369 | echo ' (supply initrd image via make variable INITRD=<path>)' | 353 | echo ' (supply initrd image via make variable INITRD=<path>)' |
| 370 | echo '* dtbs - Build device tree blobs for enabled boards' | ||
| 371 | echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)' | ||
| 372 | echo ' install - Install uncompressed kernel' | 354 | echo ' install - Install uncompressed kernel' |
| 373 | echo ' zinstall - Install compressed kernel' | 355 | echo ' zinstall - Install compressed kernel' |
| 374 | echo ' uinstall - Install U-Boot wrapped compressed kernel' | 356 | echo ' uinstall - Install U-Boot wrapped compressed kernel' |
diff --git a/arch/arm/boot/compressed/libfdt_env.h b/arch/arm/boot/compressed/libfdt_env.h index 07437816e098..b36c0289a308 100644 --- a/arch/arm/boot/compressed/libfdt_env.h +++ b/arch/arm/boot/compressed/libfdt_env.h | |||
| @@ -6,6 +6,8 @@ | |||
| 6 | #include <linux/string.h> | 6 | #include <linux/string.h> |
| 7 | #include <asm/byteorder.h> | 7 | #include <asm/byteorder.h> |
| 8 | 8 | ||
| 9 | #define INT_MAX ((int)(~0U>>1)) | ||
| 10 | |||
| 9 | typedef __be16 fdt16_t; | 11 | typedef __be16 fdt16_t; |
| 10 | typedef __be32 fdt32_t; | 12 | typedef __be32 fdt32_t; |
| 11 | typedef __be64 fdt64_t; | 13 | typedef __be64 fdt64_t; |
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c index ecaa68dd1af5..13bcd3b867cb 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c | |||
| @@ -87,14 +87,11 @@ void __init arm_dt_init_cpu_maps(void) | |||
| 87 | if (!cpus) | 87 | if (!cpus) |
| 88 | return; | 88 | return; |
| 89 | 89 | ||
| 90 | for_each_child_of_node(cpus, cpu) { | 90 | for_each_of_cpu_node(cpu) { |
| 91 | const __be32 *cell; | 91 | const __be32 *cell; |
| 92 | int prop_bytes; | 92 | int prop_bytes; |
| 93 | u32 hwid; | 93 | u32 hwid; |
| 94 | 94 | ||
| 95 | if (of_node_cmp(cpu->type, "cpu")) | ||
| 96 | continue; | ||
| 97 | |||
| 98 | pr_debug(" * %pOF...\n", cpu); | 95 | pr_debug(" * %pOF...\n", cpu); |
| 99 | /* | 96 | /* |
| 100 | * A device tree containing CPU nodes with missing "reg" | 97 | * A device tree containing CPU nodes with missing "reg" |
diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index 24ac3cab411d..60e375ce1ab2 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c | |||
| @@ -94,12 +94,6 @@ static void __init parse_dt_topology(void) | |||
| 94 | __cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity), | 94 | __cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity), |
| 95 | GFP_NOWAIT); | 95 | GFP_NOWAIT); |
| 96 | 96 | ||
| 97 | cn = of_find_node_by_path("/cpus"); | ||
| 98 | if (!cn) { | ||
| 99 | pr_err("No CPU information found in DT\n"); | ||
| 100 | return; | ||
| 101 | } | ||
| 102 | |||
| 103 | for_each_possible_cpu(cpu) { | 97 | for_each_possible_cpu(cpu) { |
| 104 | const u32 *rate; | 98 | const u32 *rate; |
| 105 | int len; | 99 | int len; |
diff --git a/arch/arm/mach-shmobile/pm-rcar-gen2.c b/arch/arm/mach-shmobile/pm-rcar-gen2.c index 345af3ebcc3a..7efe95bd584f 100644 --- a/arch/arm/mach-shmobile/pm-rcar-gen2.c +++ b/arch/arm/mach-shmobile/pm-rcar-gen2.c | |||
| @@ -50,7 +50,7 @@ void __init rcar_gen2_pm_init(void) | |||
| 50 | void __iomem *p; | 50 | void __iomem *p; |
| 51 | u32 bar; | 51 | u32 bar; |
| 52 | static int once; | 52 | static int once; |
| 53 | struct device_node *np, *cpus; | 53 | struct device_node *np; |
| 54 | bool has_a7 = false; | 54 | bool has_a7 = false; |
| 55 | bool has_a15 = false; | 55 | bool has_a15 = false; |
| 56 | struct resource res; | 56 | struct resource res; |
| @@ -59,11 +59,7 @@ void __init rcar_gen2_pm_init(void) | |||
| 59 | if (once++) | 59 | if (once++) |
| 60 | return; | 60 | return; |
| 61 | 61 | ||
| 62 | cpus = of_find_node_by_path("/cpus"); | 62 | for_each_of_cpu_node(np) { |
| 63 | if (!cpus) | ||
| 64 | return; | ||
| 65 | |||
| 66 | for_each_child_of_node(cpus, np) { | ||
| 67 | if (of_device_is_compatible(np, "arm,cortex-a15")) | 63 | if (of_device_is_compatible(np, "arm,cortex-a15")) |
| 68 | has_a15 = true; | 64 | has_a15 = true; |
| 69 | else if (of_device_is_compatible(np, "arm,cortex-a7")) | 65 | else if (of_device_is_compatible(np, "arm,cortex-a7")) |
diff --git a/arch/arm/mach-shmobile/pm-rmobile.c b/arch/arm/mach-shmobile/pm-rmobile.c index e348bcfe389d..94fdeef11b81 100644 --- a/arch/arm/mach-shmobile/pm-rmobile.c +++ b/arch/arm/mach-shmobile/pm-rmobile.c | |||
| @@ -202,7 +202,7 @@ static void __init get_special_pds(void) | |||
| 202 | const struct of_device_id *id; | 202 | const struct of_device_id *id; |
| 203 | 203 | ||
| 204 | /* PM domains containing CPUs */ | 204 | /* PM domains containing CPUs */ |
| 205 | for_each_node_by_type(np, "cpu") | 205 | for_each_of_cpu_node(np) |
| 206 | add_special_pd(np, PD_CPU); | 206 | add_special_pd(np, PD_CPU); |
| 207 | 207 | ||
| 208 | /* PM domain containing console */ | 208 | /* PM domain containing console */ |
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c index 828e8aea037e..e48b0939693f 100644 --- a/arch/arm/mach-shmobile/timer.c +++ b/arch/arm/mach-shmobile/timer.c | |||
| @@ -22,22 +22,16 @@ | |||
| 22 | 22 | ||
| 23 | void __init shmobile_init_delay(void) | 23 | void __init shmobile_init_delay(void) |
| 24 | { | 24 | { |
| 25 | struct device_node *np, *cpus; | 25 | struct device_node *np; |
| 26 | u32 max_freq = 0; | 26 | u32 max_freq = 0; |
| 27 | 27 | ||
| 28 | cpus = of_find_node_by_path("/cpus"); | 28 | for_each_of_cpu_node(np) { |
| 29 | if (!cpus) | ||
| 30 | return; | ||
| 31 | |||
| 32 | for_each_child_of_node(cpus, np) { | ||
| 33 | u32 freq; | 29 | u32 freq; |
| 34 | 30 | ||
| 35 | if (!of_property_read_u32(np, "clock-frequency", &freq)) | 31 | if (!of_property_read_u32(np, "clock-frequency", &freq)) |
| 36 | max_freq = max(max_freq, freq); | 32 | max_freq = max(max_freq, freq); |
| 37 | } | 33 | } |
| 38 | 34 | ||
| 39 | of_node_put(cpus); | ||
| 40 | |||
| 41 | if (!max_freq) | 35 | if (!max_freq) |
| 42 | return; | 36 | return; |
| 43 | 37 | ||
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 106039d25e2f..b4e994cd3a42 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile | |||
| @@ -113,9 +113,8 @@ core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a | |||
| 113 | # Default target when executing plain make | 113 | # Default target when executing plain make |
| 114 | boot := arch/arm64/boot | 114 | boot := arch/arm64/boot |
| 115 | KBUILD_IMAGE := $(boot)/Image.gz | 115 | KBUILD_IMAGE := $(boot)/Image.gz |
| 116 | KBUILD_DTBS := dtbs | ||
| 117 | 116 | ||
| 118 | all: Image.gz $(KBUILD_DTBS) | 117 | all: Image.gz |
| 119 | 118 | ||
| 120 | 119 | ||
| 121 | Image: vmlinux | 120 | Image: vmlinux |
| @@ -127,17 +126,6 @@ Image.%: Image | |||
| 127 | zinstall install: | 126 | zinstall install: |
| 128 | $(Q)$(MAKE) $(build)=$(boot) $@ | 127 | $(Q)$(MAKE) $(build)=$(boot) $@ |
| 129 | 128 | ||
| 130 | %.dtb: scripts | ||
| 131 | $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@ | ||
| 132 | |||
| 133 | PHONY += dtbs dtbs_install | ||
| 134 | |||
| 135 | dtbs: prepare scripts | ||
| 136 | $(Q)$(MAKE) $(build)=$(boot)/dts | ||
| 137 | |||
| 138 | dtbs_install: | ||
| 139 | $(Q)$(MAKE) $(dtbinst)=$(boot)/dts | ||
| 140 | |||
| 141 | PHONY += vdso_install | 129 | PHONY += vdso_install |
| 142 | vdso_install: | 130 | vdso_install: |
| 143 | $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@ | 131 | $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@ |
| @@ -145,7 +133,6 @@ vdso_install: | |||
| 145 | # We use MRPROPER_FILES and CLEAN_FILES now | 133 | # We use MRPROPER_FILES and CLEAN_FILES now |
| 146 | archclean: | 134 | archclean: |
| 147 | $(Q)$(MAKE) $(clean)=$(boot) | 135 | $(Q)$(MAKE) $(clean)=$(boot) |
| 148 | $(Q)$(MAKE) $(clean)=$(boot)/dts | ||
| 149 | 136 | ||
| 150 | # We need to generate vdso-offsets.h before compiling certain files in kernel/. | 137 | # We need to generate vdso-offsets.h before compiling certain files in kernel/. |
| 151 | # In order to do that, we should use the archprepare target, but we can't since | 138 | # In order to do that, we should use the archprepare target, but we can't since |
| @@ -160,8 +147,6 @@ vdso_prepare: prepare0 | |||
| 160 | define archhelp | 147 | define archhelp |
| 161 | echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)' | 148 | echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)' |
| 162 | echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)' | 149 | echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)' |
| 163 | echo '* dtbs - Build device tree blobs for enabled boards' | ||
| 164 | echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)' | ||
| 165 | echo ' install - Install uncompressed kernel' | 150 | echo ' install - Install uncompressed kernel' |
| 166 | echo ' zinstall - Install compressed kernel' | 151 | echo ' zinstall - Install compressed kernel' |
| 167 | echo ' Install using (your) ~/bin/installkernel or' | 152 | echo ' Install using (your) ~/bin/installkernel or' |
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 25fcd22a4bb2..96b8f2f51ab2 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c | |||
| @@ -602,7 +602,7 @@ static void __init of_parse_and_init_cpus(void) | |||
| 602 | { | 602 | { |
| 603 | struct device_node *dn; | 603 | struct device_node *dn; |
| 604 | 604 | ||
| 605 | for_each_node_by_type(dn, "cpu") { | 605 | for_each_of_cpu_node(dn) { |
| 606 | u64 hwid = of_get_cpu_mpidr(dn); | 606 | u64 hwid = of_get_cpu_mpidr(dn); |
| 607 | 607 | ||
| 608 | if (hwid == INVALID_HWID) | 608 | if (hwid == INVALID_HWID) |
diff --git a/arch/c6x/Makefile b/arch/c6x/Makefile index 3fe8a948e94c..b7aa854f7008 100644 --- a/arch/c6x/Makefile +++ b/arch/c6x/Makefile | |||
| @@ -40,9 +40,7 @@ boot := arch/$(ARCH)/boot | |||
| 40 | DTB:=$(subst dtbImage.,,$(filter dtbImage.%, $(MAKECMDGOALS))) | 40 | DTB:=$(subst dtbImage.,,$(filter dtbImage.%, $(MAKECMDGOALS))) |
| 41 | export DTB | 41 | export DTB |
| 42 | 42 | ||
| 43 | ifneq ($(DTB),) | ||
| 44 | core-y += $(boot)/dts/ | 43 | core-y += $(boot)/dts/ |
| 45 | endif | ||
| 46 | 44 | ||
| 47 | # With make 3.82 we cannot mix normal and wildcard targets | 45 | # With make 3.82 we cannot mix normal and wildcard targets |
| 48 | 46 | ||
diff --git a/arch/c6x/boot/dts/Makefile b/arch/c6x/boot/dts/Makefile index b212d278ebc4..f438285c3640 100644 --- a/arch/c6x/boot/dts/Makefile +++ b/arch/c6x/boot/dts/Makefile | |||
| @@ -5,15 +5,12 @@ | |||
| 5 | 5 | ||
| 6 | DTC_FLAGS ?= -p 1024 | 6 | DTC_FLAGS ?= -p 1024 |
| 7 | 7 | ||
| 8 | dtb-$(CONFIG_SOC_TMS320C6455) += dsk6455.dtb | ||
| 9 | dtb-$(CONFIG_SOC_TMS320C6457) += evmc6457.dtb | ||
| 10 | dtb-$(CONFIG_SOC_TMS320C6472) += evmc6472.dtb | ||
| 11 | dtb-$(CONFIG_SOC_TMS320C6474) += evmc6474.dtb | ||
| 12 | dtb-$(CONFIG_SOC_TMS320C6678) += evmc6678.dtb | ||
| 13 | |||
| 8 | ifneq ($(DTB),) | 14 | ifneq ($(DTB),) |
| 9 | obj-y += linked_dtb.o | 15 | obj-y += $(DTB).dtb.o |
| 10 | endif | 16 | endif |
| 11 | |||
| 12 | quiet_cmd_cp = CP $< $@$2 | ||
| 13 | cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false) | ||
| 14 | |||
| 15 | # Generate builtin.dtb from $(DTB).dtb | ||
| 16 | $(obj)/builtin.dtb: $(obj)/$(DTB).dtb | ||
| 17 | $(call if_changed,cp) | ||
| 18 | |||
| 19 | $(obj)/linked_dtb.o: $(obj)/builtin.dtb | ||
diff --git a/arch/c6x/boot/dts/linked_dtb.S b/arch/c6x/boot/dts/linked_dtb.S deleted file mode 100644 index cf347f1d16ce..000000000000 --- a/arch/c6x/boot/dts/linked_dtb.S +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | .section __fdt_blob,"a" | ||
| 2 | .incbin "arch/c6x/boot/dts/builtin.dtb" | ||
diff --git a/arch/c6x/include/asm/sections.h b/arch/c6x/include/asm/sections.h index d6c591ab5b7e..dc2f15eb3bde 100644 --- a/arch/c6x/include/asm/sections.h +++ b/arch/c6x/include/asm/sections.h | |||
| @@ -8,6 +8,5 @@ extern char _vectors_start[]; | |||
| 8 | extern char _vectors_end[]; | 8 | extern char _vectors_end[]; |
| 9 | 9 | ||
| 10 | extern char _data_lma[]; | 10 | extern char _data_lma[]; |
| 11 | extern char _fdt_start[], _fdt_end[]; | ||
| 12 | 11 | ||
| 13 | #endif /* _ASM_C6X_SECTIONS_H */ | 12 | #endif /* _ASM_C6X_SECTIONS_H */ |
diff --git a/arch/c6x/kernel/setup.c b/arch/c6x/kernel/setup.c index 786e36e2f61d..05d96a9541b5 100644 --- a/arch/c6x/kernel/setup.c +++ b/arch/c6x/kernel/setup.c | |||
| @@ -96,7 +96,7 @@ static void __init get_cpuinfo(void) | |||
| 96 | unsigned long core_khz; | 96 | unsigned long core_khz; |
| 97 | u64 tmp; | 97 | u64 tmp; |
| 98 | struct cpuinfo_c6x *p; | 98 | struct cpuinfo_c6x *p; |
| 99 | struct device_node *node, *np; | 99 | struct device_node *node; |
| 100 | 100 | ||
| 101 | p = &per_cpu(cpu_data, smp_processor_id()); | 101 | p = &per_cpu(cpu_data, smp_processor_id()); |
| 102 | 102 | ||
| @@ -190,13 +190,8 @@ static void __init get_cpuinfo(void) | |||
| 190 | 190 | ||
| 191 | p->core_id = get_coreid(); | 191 | p->core_id = get_coreid(); |
| 192 | 192 | ||
| 193 | node = of_find_node_by_name(NULL, "cpus"); | 193 | for_each_of_cpu_node(node) |
| 194 | if (node) { | 194 | ++c6x_num_cores; |
| 195 | for_each_child_of_node(node, np) | ||
| 196 | if (!strcmp("cpu", np->name)) | ||
| 197 | ++c6x_num_cores; | ||
| 198 | of_node_put(node); | ||
| 199 | } | ||
| 200 | 195 | ||
| 201 | node = of_find_node_by_name(NULL, "soc"); | 196 | node = of_find_node_by_name(NULL, "soc"); |
| 202 | if (node) { | 197 | if (node) { |
| @@ -270,7 +265,7 @@ int __init c6x_add_memory(phys_addr_t start, unsigned long size) | |||
| 270 | notrace void __init machine_init(unsigned long dt_ptr) | 265 | notrace void __init machine_init(unsigned long dt_ptr) |
| 271 | { | 266 | { |
| 272 | void *dtb = __va(dt_ptr); | 267 | void *dtb = __va(dt_ptr); |
| 273 | void *fdt = _fdt_start; | 268 | void *fdt = __dtb_start; |
| 274 | 269 | ||
| 275 | /* interrupts must be masked */ | 270 | /* interrupts must be masked */ |
| 276 | set_creg(IER, 2); | 271 | set_creg(IER, 2); |
| @@ -363,7 +358,7 @@ void __init setup_arch(char **cmdline_p) | |||
| 363 | memory_end >> PAGE_SHIFT); | 358 | memory_end >> PAGE_SHIFT); |
| 364 | memblock_reserve(memory_start, bootmap_size); | 359 | memblock_reserve(memory_start, bootmap_size); |
| 365 | 360 | ||
| 366 | unflatten_device_tree(); | 361 | unflatten_and_copy_device_tree(); |
| 367 | 362 | ||
| 368 | c6x_cache_init(); | 363 | c6x_cache_init(); |
| 369 | 364 | ||
diff --git a/arch/c6x/kernel/vmlinux.lds.S b/arch/c6x/kernel/vmlinux.lds.S index 1fba5b421eee..584bab2bace6 100644 --- a/arch/c6x/kernel/vmlinux.lds.S +++ b/arch/c6x/kernel/vmlinux.lds.S | |||
| @@ -90,16 +90,6 @@ SECTIONS | |||
| 90 | *(.switch) | 90 | *(.switch) |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | . = ALIGN (8) ; | ||
| 94 | __fdt_blob : AT(ADDR(__fdt_blob) - LOAD_OFFSET) | ||
| 95 | { | ||
| 96 | _fdt_start = . ; /* place for fdt blob */ | ||
| 97 | *(__fdt_blob) ; /* Any link-placed DTB */ | ||
| 98 | BYTE(0); /* section always has contents */ | ||
| 99 | . = _fdt_start + 0x4000; /* Pad up to 16kbyte */ | ||
| 100 | _fdt_end = . ; | ||
| 101 | } | ||
| 102 | |||
| 103 | _etext = .; | 93 | _etext = .; |
| 104 | 94 | ||
| 105 | /* | 95 | /* |
diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile index 58634e6bae92..4003ddc616e1 100644 --- a/arch/h8300/Makefile +++ b/arch/h8300/Makefile | |||
| @@ -31,21 +31,12 @@ CROSS_COMPILE := h8300-unknown-linux- | |||
| 31 | endif | 31 | endif |
| 32 | 32 | ||
| 33 | core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/ | 33 | core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/ |
| 34 | ifneq '$(CONFIG_H8300_BUILTIN_DTB)' '""' | 34 | core-y += arch/$(ARCH)/boot/dts/ |
| 35 | core-y += arch/h8300/boot/dts/ | ||
| 36 | endif | ||
| 37 | 35 | ||
| 38 | libs-y += arch/$(ARCH)/lib/ | 36 | libs-y += arch/$(ARCH)/lib/ |
| 39 | 37 | ||
| 40 | boot := arch/h8300/boot | 38 | boot := arch/h8300/boot |
| 41 | 39 | ||
| 42 | %.dtb %.dtb.S %.dtb.o: | scripts | ||
| 43 | $(Q)$(MAKE) $(build)=arch/h8300/boot/dts arch/h8300/boot/dts/$@ | ||
| 44 | |||
| 45 | PHONY += dtbs | ||
| 46 | dtbs: scripts | ||
| 47 | $(Q)$(MAKE) $(build)=arch/h8300/boot/dts | ||
| 48 | |||
| 49 | archmrproper: | 40 | archmrproper: |
| 50 | 41 | ||
| 51 | archclean: | 42 | archclean: |
diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile index 4f3ab5707265..0823d291fbeb 100644 --- a/arch/microblaze/Makefile +++ b/arch/microblaze/Makefile | |||
| @@ -65,9 +65,7 @@ boot := arch/microblaze/boot | |||
| 65 | # Are we making a simpleImage.<boardname> target? If so, crack out the boardname | 65 | # Are we making a simpleImage.<boardname> target? If so, crack out the boardname |
| 66 | DTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS))) | 66 | DTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS))) |
| 67 | 67 | ||
| 68 | ifneq ($(DTB),) | 68 | core-y += $(boot)/dts/ |
| 69 | core-y += $(boot)/dts/ | ||
| 70 | endif | ||
| 71 | 69 | ||
| 72 | # defines filename extension depending memory management type | 70 | # defines filename extension depending memory management type |
| 73 | ifeq ($(CONFIG_MMU),) | 71 | ifeq ($(CONFIG_MMU),) |
diff --git a/arch/microblaze/boot/dts/Makefile b/arch/microblaze/boot/dts/Makefile index 1f77913d404d..c7324e74f9ef 100644 --- a/arch/microblaze/boot/dts/Makefile +++ b/arch/microblaze/boot/dts/Makefile | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | # | 2 | # |
| 3 | 3 | ||
| 4 | dtb-y := system.dtb | ||
| 5 | |||
| 6 | ifneq ($(DTB),) | ||
| 4 | obj-y += linked_dtb.o | 7 | obj-y += linked_dtb.o |
| 5 | 8 | ||
| 6 | # Ensure system.dtb exists | 9 | # Ensure system.dtb exists |
| @@ -11,6 +14,7 @@ ifneq ($(DTB),system) | |||
| 11 | $(obj)/system.dtb: $(obj)/$(DTB).dtb | 14 | $(obj)/system.dtb: $(obj)/$(DTB).dtb |
| 12 | $(call if_changed,cp) | 15 | $(call if_changed,cp) |
| 13 | endif | 16 | endif |
| 17 | endif | ||
| 14 | 18 | ||
| 15 | quiet_cmd_cp = CP $< $@$2 | 19 | quiet_cmd_cp = CP $< $@$2 |
| 16 | cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false) | 20 | cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false) |
diff --git a/arch/microblaze/kernel/cpu/cpuinfo.c b/arch/microblaze/kernel/cpu/cpuinfo.c index 96b3f26d16be..ef2f49471a2a 100644 --- a/arch/microblaze/kernel/cpu/cpuinfo.c +++ b/arch/microblaze/kernel/cpu/cpuinfo.c | |||
| @@ -89,9 +89,9 @@ static struct device_node *cpu; | |||
| 89 | 89 | ||
| 90 | void __init setup_cpuinfo(void) | 90 | void __init setup_cpuinfo(void) |
| 91 | { | 91 | { |
| 92 | cpu = (struct device_node *) of_find_node_by_type(NULL, "cpu"); | 92 | cpu = of_get_cpu_node(0, NULL); |
| 93 | if (!cpu) | 93 | if (!cpu) |
| 94 | pr_err("You don't have cpu!!!\n"); | 94 | pr_err("You don't have cpu or are missing cpu reg property!!!\n"); |
| 95 | 95 | ||
| 96 | pr_info("%s: initialising\n", __func__); | 96 | pr_info("%s: initialising\n", __func__); |
| 97 | 97 | ||
| @@ -117,6 +117,8 @@ void __init setup_cpuinfo(void) | |||
| 117 | if (cpuinfo.mmu_privins) | 117 | if (cpuinfo.mmu_privins) |
| 118 | pr_warn("%s: Stream instructions enabled" | 118 | pr_warn("%s: Stream instructions enabled" |
| 119 | " - USERSPACE CAN LOCK THIS KERNEL!\n", __func__); | 119 | " - USERSPACE CAN LOCK THIS KERNEL!\n", __func__); |
| 120 | |||
| 121 | of_node_put(cpu); | ||
| 120 | } | 122 | } |
| 121 | 123 | ||
| 122 | void __init setup_cpuinfo_clk(void) | 124 | void __init setup_cpuinfo_clk(void) |
diff --git a/arch/mips/Makefile b/arch/mips/Makefile index d74b3742fa5d..d43eeaa6d75b 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile | |||
| @@ -407,18 +407,7 @@ endif | |||
| 407 | CLEAN_FILES += vmlinux.32 vmlinux.64 | 407 | CLEAN_FILES += vmlinux.32 vmlinux.64 |
| 408 | 408 | ||
| 409 | # device-trees | 409 | # device-trees |
| 410 | core-$(CONFIG_BUILTIN_DTB) += arch/mips/boot/dts/ | 410 | core-y += arch/mips/boot/dts/ |
| 411 | |||
| 412 | %.dtb %.dtb.S %.dtb.o: | scripts | ||
| 413 | $(Q)$(MAKE) $(build)=arch/mips/boot/dts arch/mips/boot/dts/$@ | ||
| 414 | |||
| 415 | PHONY += dtbs | ||
| 416 | dtbs: scripts | ||
| 417 | $(Q)$(MAKE) $(build)=arch/mips/boot/dts | ||
| 418 | |||
| 419 | PHONY += dtbs_install | ||
| 420 | dtbs_install: | ||
| 421 | $(Q)$(MAKE) $(dtbinst)=arch/mips/boot/dts | ||
| 422 | 411 | ||
| 423 | archprepare: | 412 | archprepare: |
| 424 | ifdef CONFIG_MIPS32_N32 | 413 | ifdef CONFIG_MIPS32_N32 |
| @@ -461,8 +450,6 @@ define archhelp | |||
| 461 | echo ' uImage.lzma - U-Boot image (lzma)' | 450 | echo ' uImage.lzma - U-Boot image (lzma)' |
| 462 | echo ' uImage.lzo - U-Boot image (lzo)' | 451 | echo ' uImage.lzo - U-Boot image (lzo)' |
| 463 | echo ' uzImage.bin - U-Boot image (self-extracting)' | 452 | echo ' uzImage.bin - U-Boot image (self-extracting)' |
| 464 | echo ' dtbs - Device-tree blobs for enabled boards' | ||
| 465 | echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)' | ||
| 466 | echo | 453 | echo |
| 467 | echo ' These will be default as appropriate for a configured platform.' | 454 | echo ' These will be default as appropriate for a configured platform.' |
| 468 | echo | 455 | echo |
diff --git a/arch/nds32/Makefile b/arch/nds32/Makefile index 3509fac10491..9f525ed70049 100644 --- a/arch/nds32/Makefile +++ b/arch/nds32/Makefile | |||
| @@ -47,7 +47,7 @@ CHECKFLAGS += -D__NDS32_EB__ | |||
| 47 | endif | 47 | endif |
| 48 | 48 | ||
| 49 | boot := arch/nds32/boot | 49 | boot := arch/nds32/boot |
| 50 | core-$(BUILTIN_DTB) += $(boot)/dts/ | 50 | core-y += $(boot)/dts/ |
| 51 | 51 | ||
| 52 | .PHONY: FORCE | 52 | .PHONY: FORCE |
| 53 | 53 | ||
diff --git a/arch/nios2/Makefile b/arch/nios2/Makefile index 8673a79dca9c..52c03e60b114 100644 --- a/arch/nios2/Makefile +++ b/arch/nios2/Makefile | |||
| @@ -49,21 +49,13 @@ BOOT_TARGETS = vmImage zImage | |||
| 49 | PHONY += $(BOOT_TARGETS) install | 49 | PHONY += $(BOOT_TARGETS) install |
| 50 | KBUILD_IMAGE := $(nios2-boot)/vmImage | 50 | KBUILD_IMAGE := $(nios2-boot)/vmImage |
| 51 | 51 | ||
| 52 | ifneq ($(CONFIG_NIOS2_DTB_SOURCE),"") | 52 | core-y += $(nios2-boot)/dts/ |
| 53 | core-y += $(nios2-boot)/ | ||
| 54 | endif | ||
| 55 | 53 | ||
| 56 | all: vmImage | 54 | all: vmImage |
| 57 | 55 | ||
| 58 | archclean: | 56 | archclean: |
| 59 | $(Q)$(MAKE) $(clean)=$(nios2-boot) | 57 | $(Q)$(MAKE) $(clean)=$(nios2-boot) |
| 60 | 58 | ||
| 61 | %.dtb: | scripts | ||
| 62 | $(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@ | ||
| 63 | |||
| 64 | dtbs: | ||
| 65 | $(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@ | ||
| 66 | |||
| 67 | $(BOOT_TARGETS): vmlinux | 59 | $(BOOT_TARGETS): vmlinux |
| 68 | $(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@ | 60 | $(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@ |
| 69 | 61 | ||
| @@ -76,5 +68,4 @@ define archhelp | |||
| 76 | echo ' (your) ~/bin/$(INSTALLKERNEL) or' | 68 | echo ' (your) ~/bin/$(INSTALLKERNEL) or' |
| 77 | echo ' (distribution) /sbin/$(INSTALLKERNEL) or' | 69 | echo ' (distribution) /sbin/$(INSTALLKERNEL) or' |
| 78 | echo ' install to $$(INSTALL_PATH)' | 70 | echo ' install to $$(INSTALL_PATH)' |
| 79 | echo ' dtbs - Build device tree blobs for enabled boards' | ||
| 80 | endef | 71 | endef |
diff --git a/arch/nios2/boot/Makefile b/arch/nios2/boot/Makefile index 2ba23a679732..37dfc7e584bc 100644 --- a/arch/nios2/boot/Makefile +++ b/arch/nios2/boot/Makefile | |||
| @@ -31,27 +31,5 @@ $(obj)/zImage: $(obj)/compressed/vmlinux FORCE | |||
| 31 | $(obj)/compressed/vmlinux: $(obj)/vmlinux.gz FORCE | 31 | $(obj)/compressed/vmlinux: $(obj)/vmlinux.gz FORCE |
| 32 | $(Q)$(MAKE) $(build)=$(obj)/compressed $@ | 32 | $(Q)$(MAKE) $(build)=$(obj)/compressed $@ |
| 33 | 33 | ||
| 34 | # Rule to build device tree blobs | ||
| 35 | DTB_SRC := $(patsubst "%",%,$(CONFIG_NIOS2_DTB_SOURCE)) | ||
| 36 | |||
| 37 | # Make sure the generated dtb gets removed during clean | ||
| 38 | extra-$(CONFIG_NIOS2_DTB_SOURCE_BOOL) += system.dtb | ||
| 39 | |||
| 40 | $(obj)/system.dtb: $(DTB_SRC) FORCE | ||
| 41 | $(call cmd,dtc) | ||
| 42 | |||
| 43 | # Ensure system.dtb exists | ||
| 44 | $(obj)/linked_dtb.o: $(obj)/system.dtb | ||
| 45 | |||
| 46 | obj-$(CONFIG_NIOS2_DTB_SOURCE_BOOL) += linked_dtb.o | ||
| 47 | |||
| 48 | targets += $(dtb-y) | ||
| 49 | |||
| 50 | # Rule to build device tree blobs with make command | ||
| 51 | $(obj)/%.dtb: $(src)/dts/%.dts FORCE | ||
| 52 | $(call if_changed_dep,dtc) | ||
| 53 | |||
| 54 | $(obj)/dtbs: $(addprefix $(obj)/, $(dtb-y)) | ||
| 55 | |||
| 56 | install: | 34 | install: |
| 57 | sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)" | 35 | sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)" |
diff --git a/arch/nios2/boot/dts/Makefile b/arch/nios2/boot/dts/Makefile new file mode 100644 index 000000000000..a91a0b09be63 --- /dev/null +++ b/arch/nios2/boot/dts/Makefile | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 3 | obj-y := $(patsubst "%.dts",%.dtb.o,$(CONFIG_NIOS2_DTB_SOURCE)) | ||
| 4 | |||
| 5 | dtstree := $(srctree)/$(src) | ||
| 6 | dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts)) | ||
diff --git a/arch/nios2/boot/linked_dtb.S b/arch/nios2/boot/linked_dtb.S deleted file mode 100644 index 071f922db338..000000000000 --- a/arch/nios2/boot/linked_dtb.S +++ /dev/null | |||
| @@ -1,19 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2011 Thomas Chou <thomas@wytron.com.tw> | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or | ||
| 7 | * (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 | ||
| 12 | * GNU 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, see <http://www.gnu.org/licenses/>. | ||
| 16 | * | ||
| 17 | */ | ||
| 18 | .section .dtb.init.rodata,"a" | ||
| 19 | .incbin "arch/nios2/boot/system.dtb" | ||
diff --git a/arch/nios2/kernel/cpuinfo.c b/arch/nios2/kernel/cpuinfo.c index 93207718bb22..ccc1d2a15a0a 100644 --- a/arch/nios2/kernel/cpuinfo.c +++ b/arch/nios2/kernel/cpuinfo.c | |||
| @@ -47,7 +47,7 @@ void __init setup_cpuinfo(void) | |||
| 47 | const char *str; | 47 | const char *str; |
| 48 | int len; | 48 | int len; |
| 49 | 49 | ||
| 50 | cpu = of_find_node_by_type(NULL, "cpu"); | 50 | cpu = of_get_cpu_node(0, NULL); |
| 51 | if (!cpu) | 51 | if (!cpu) |
| 52 | panic("%s: No CPU found in devicetree!\n", __func__); | 52 | panic("%s: No CPU found in devicetree!\n", __func__); |
| 53 | 53 | ||
| @@ -120,6 +120,8 @@ void __init setup_cpuinfo(void) | |||
| 120 | cpuinfo.reset_addr = fcpu(cpu, "altr,reset-addr"); | 120 | cpuinfo.reset_addr = fcpu(cpu, "altr,reset-addr"); |
| 121 | cpuinfo.exception_addr = fcpu(cpu, "altr,exception-addr"); | 121 | cpuinfo.exception_addr = fcpu(cpu, "altr,exception-addr"); |
| 122 | cpuinfo.fast_tlb_miss_exc_addr = fcpu(cpu, "altr,fast-tlb-miss-addr"); | 122 | cpuinfo.fast_tlb_miss_exc_addr = fcpu(cpu, "altr,fast-tlb-miss-addr"); |
| 123 | |||
| 124 | of_node_put(cpu); | ||
| 123 | } | 125 | } |
| 124 | 126 | ||
| 125 | #ifdef CONFIG_PROC_FS | 127 | #ifdef CONFIG_PROC_FS |
diff --git a/arch/nios2/kernel/time.c b/arch/nios2/kernel/time.c index ab88b6dd4679..54467d0085a1 100644 --- a/arch/nios2/kernel/time.c +++ b/arch/nios2/kernel/time.c | |||
| @@ -214,12 +214,12 @@ static int __init nios2_timer_get_base_and_freq(struct device_node *np, | |||
| 214 | { | 214 | { |
| 215 | *base = of_iomap(np, 0); | 215 | *base = of_iomap(np, 0); |
| 216 | if (!*base) { | 216 | if (!*base) { |
| 217 | pr_crit("Unable to map reg for %s\n", np->name); | 217 | pr_crit("Unable to map reg for %pOFn\n", np); |
| 218 | return -ENXIO; | 218 | return -ENXIO; |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | if (of_property_read_u32(np, "clock-frequency", freq)) { | 221 | if (of_property_read_u32(np, "clock-frequency", freq)) { |
| 222 | pr_crit("Unable to get %s clock frequency\n", np->name); | 222 | pr_crit("Unable to get %pOFn clock frequency\n", np); |
| 223 | return -EINVAL; | 223 | return -EINVAL; |
| 224 | } | 224 | } |
| 225 | 225 | ||
diff --git a/arch/openrisc/kernel/setup.c b/arch/openrisc/kernel/setup.c index 9d28ab14d139..e17fcd83120f 100644 --- a/arch/openrisc/kernel/setup.c +++ b/arch/openrisc/kernel/setup.c | |||
| @@ -158,9 +158,8 @@ static struct device_node *setup_find_cpu_node(int cpu) | |||
| 158 | { | 158 | { |
| 159 | u32 hwid; | 159 | u32 hwid; |
| 160 | struct device_node *cpun; | 160 | struct device_node *cpun; |
| 161 | struct device_node *cpus = of_find_node_by_path("/cpus"); | ||
| 162 | 161 | ||
| 163 | for_each_available_child_of_node(cpus, cpun) { | 162 | for_each_of_cpu_node(cpun) { |
| 164 | if (of_property_read_u32(cpun, "reg", &hwid)) | 163 | if (of_property_read_u32(cpun, "reg", &hwid)) |
| 165 | continue; | 164 | continue; |
| 166 | if (hwid == cpu) | 165 | if (hwid == cpu) |
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 11a1acba164a..42f225f6ec93 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile | |||
| @@ -293,9 +293,6 @@ $(BOOT_TARGETS2): vmlinux | |||
| 293 | bootwrapper_install: | 293 | bootwrapper_install: |
| 294 | $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@) | 294 | $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@) |
| 295 | 295 | ||
| 296 | %.dtb: scripts | ||
| 297 | $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@) | ||
| 298 | |||
| 299 | # Used to create 'merged defconfigs' | 296 | # Used to create 'merged defconfigs' |
| 300 | # To use it $(call) it with the first argument as the base defconfig | 297 | # To use it $(call) it with the first argument as the base defconfig |
| 301 | # and the second argument as a space separated list of .config files to merge, | 298 | # and the second argument as a space separated list of .config files to merge, |
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index 0fb96c26136f..bca5c23767df 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile | |||
| @@ -304,9 +304,9 @@ image-$(CONFIG_PPC_ADDER875) += cuImage.adder875-uboot \ | |||
| 304 | dtbImage.adder875-redboot | 304 | dtbImage.adder875-redboot |
| 305 | 305 | ||
| 306 | # Board ports in arch/powerpc/platform/52xx/Kconfig | 306 | # Board ports in arch/powerpc/platform/52xx/Kconfig |
| 307 | image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200 lite5200.dtb | 307 | image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200 |
| 308 | image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200b lite5200b.dtb | 308 | image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200b |
| 309 | image-$(CONFIG_PPC_MEDIA5200) += cuImage.media5200 media5200.dtb | 309 | image-$(CONFIG_PPC_MEDIA5200) += cuImage.media5200 |
| 310 | 310 | ||
| 311 | # Board ports in arch/powerpc/platform/82xx/Kconfig | 311 | # Board ports in arch/powerpc/platform/82xx/Kconfig |
| 312 | image-$(CONFIG_MPC8272_ADS) += cuImage.mpc8272ads | 312 | image-$(CONFIG_MPC8272_ADS) += cuImage.mpc8272ads |
| @@ -381,11 +381,11 @@ $(addprefix $(obj)/, $(sort $(filter zImage.%, $(image-y)))): vmlinux $(wrapperb | |||
| 381 | $(call if_changed,wrap,$(subst $(obj)/zImage.,,$@)) | 381 | $(call if_changed,wrap,$(subst $(obj)/zImage.,,$@)) |
| 382 | 382 | ||
| 383 | # dtbImage% - a dtbImage is a zImage with an embedded device tree blob | 383 | # dtbImage% - a dtbImage is a zImage with an embedded device tree blob |
| 384 | $(obj)/dtbImage.initrd.%: vmlinux $(wrapperbits) $(obj)/%.dtb FORCE | 384 | $(obj)/dtbImage.initrd.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE |
| 385 | $(call if_changed,wrap,$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) | 385 | $(call if_changed,wrap,$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) |
| 386 | 386 | ||
| 387 | $(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/%.dtb FORCE | 387 | $(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE |
| 388 | $(call if_changed,wrap,$*,,$(obj)/$*.dtb) | 388 | $(call if_changed,wrap,$*,,$(obj)/dts/$*.dtb) |
| 389 | 389 | ||
| 390 | # This cannot be in the root of $(src) as the zImage rule always adds a $(obj) | 390 | # This cannot be in the root of $(src) as the zImage rule always adds a $(obj) |
| 391 | # prefix | 391 | # prefix |
| @@ -395,36 +395,33 @@ $(obj)/vmlinux.strip: vmlinux | |||
| 395 | $(obj)/uImage: vmlinux $(wrapperbits) FORCE | 395 | $(obj)/uImage: vmlinux $(wrapperbits) FORCE |
| 396 | $(call if_changed,wrap,uboot) | 396 | $(call if_changed,wrap,uboot) |
| 397 | 397 | ||
| 398 | $(obj)/uImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE | 398 | $(obj)/uImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE |
| 399 | $(call if_changed,wrap,uboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) | 399 | $(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) |
| 400 | 400 | ||
| 401 | $(obj)/uImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE | 401 | $(obj)/uImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE |
| 402 | $(call if_changed,wrap,uboot-$*,,$(obj)/$*.dtb) | 402 | $(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb) |
| 403 | 403 | ||
| 404 | $(obj)/cuImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE | 404 | $(obj)/cuImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE |
| 405 | $(call if_changed,wrap,cuboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) | 405 | $(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) |
| 406 | 406 | ||
| 407 | $(obj)/cuImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE | 407 | $(obj)/cuImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE |
| 408 | $(call if_changed,wrap,cuboot-$*,,$(obj)/$*.dtb) | 408 | $(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb) |
| 409 | 409 | ||
| 410 | $(obj)/simpleImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE | 410 | $(obj)/simpleImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE |
| 411 | $(call if_changed,wrap,simpleboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) | 411 | $(call if_changed,wrap,simpleboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) |
| 412 | 412 | ||
| 413 | $(obj)/simpleImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE | 413 | $(obj)/simpleImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE |
| 414 | $(call if_changed,wrap,simpleboot-$*,,$(obj)/$*.dtb) | 414 | $(call if_changed,wrap,simpleboot-$*,,$(obj)/dts/$*.dtb) |
| 415 | 415 | ||
| 416 | $(obj)/treeImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE | 416 | $(obj)/treeImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE |
| 417 | $(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) | 417 | $(call if_changed,wrap,treeboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) |
| 418 | 418 | ||
| 419 | $(obj)/treeImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE | 419 | $(obj)/treeImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE |
| 420 | $(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb) | 420 | $(call if_changed,wrap,treeboot-$*,,$(obj)/dts/$*.dtb) |
| 421 | 421 | ||
| 422 | # Rule to build device tree blobs | 422 | # Needed for the above targets to work with dts/fsl/ files |
| 423 | $(obj)/%.dtb: $(src)/dts/%.dts FORCE | 423 | $(obj)/dts/%.dtb: $(obj)/dts/fsl/%.dtb |
| 424 | $(call if_changed_dep,dtc) | 424 | @cp $< $@ |
| 425 | |||
| 426 | $(obj)/%.dtb: $(src)/dts/fsl/%.dts FORCE | ||
| 427 | $(call if_changed_dep,dtc) | ||
| 428 | 425 | ||
| 429 | # If there isn't a platform selected then just strip the vmlinux. | 426 | # If there isn't a platform selected then just strip the vmlinux. |
| 430 | ifeq (,$(image-y)) | 427 | ifeq (,$(image-y)) |
diff --git a/arch/powerpc/boot/dts/Makefile b/arch/powerpc/boot/dts/Makefile new file mode 100644 index 000000000000..fb335d05aae8 --- /dev/null +++ b/arch/powerpc/boot/dts/Makefile | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 3 | subdir-y += fsl | ||
| 4 | |||
| 5 | dtstree := $(srctree)/$(src) | ||
| 6 | dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts)) | ||
diff --git a/arch/powerpc/boot/dts/fsl/Makefile b/arch/powerpc/boot/dts/fsl/Makefile new file mode 100644 index 000000000000..3bae982641e9 --- /dev/null +++ b/arch/powerpc/boot/dts/fsl/Makefile | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 3 | dtstree := $(srctree)/$(src) | ||
| 4 | dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts)) | ||
diff --git a/arch/powerpc/boot/libfdt_env.h b/arch/powerpc/boot/libfdt_env.h index 2a0c8b1bf147..2abc8e83b95e 100644 --- a/arch/powerpc/boot/libfdt_env.h +++ b/arch/powerpc/boot/libfdt_env.h | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | #include <types.h> | 5 | #include <types.h> |
| 6 | #include <string.h> | 6 | #include <string.h> |
| 7 | 7 | ||
| 8 | #define INT_MAX ((int)(~0U>>1)) | ||
| 9 | |||
| 8 | #include "of.h" | 10 | #include "of.h" |
| 9 | 11 | ||
| 10 | typedef unsigned long uintptr_t; | 12 | typedef unsigned long uintptr_t; |
diff --git a/arch/powerpc/platforms/4xx/soc.c b/arch/powerpc/platforms/4xx/soc.c index 5e36508b2a70..1844bf502fcf 100644 --- a/arch/powerpc/platforms/4xx/soc.c +++ b/arch/powerpc/platforms/4xx/soc.c | |||
| @@ -200,7 +200,7 @@ void ppc4xx_reset_system(char *cmd) | |||
| 200 | u32 reset_type = DBCR0_RST_SYSTEM; | 200 | u32 reset_type = DBCR0_RST_SYSTEM; |
| 201 | const u32 *prop; | 201 | const u32 *prop; |
| 202 | 202 | ||
| 203 | np = of_find_node_by_type(NULL, "cpu"); | 203 | np = of_get_cpu_node(0, NULL); |
| 204 | if (np) { | 204 | if (np) { |
| 205 | prop = of_get_property(np, "reset-type", NULL); | 205 | prop = of_get_property(np, "reset-type", NULL); |
| 206 | 206 | ||
diff --git a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c index 027c42d8966c..f1c805c8adbc 100644 --- a/arch/powerpc/platforms/8xx/m8xx_setup.c +++ b/arch/powerpc/platforms/8xx/m8xx_setup.c | |||
| @@ -66,7 +66,7 @@ static int __init get_freq(char *name, unsigned long *val) | |||
| 66 | int found = 0; | 66 | int found = 0; |
| 67 | 67 | ||
| 68 | /* The cpu node should have timebase and clock frequency properties */ | 68 | /* The cpu node should have timebase and clock frequency properties */ |
| 69 | cpu = of_find_node_by_type(NULL, "cpu"); | 69 | cpu = of_get_cpu_node(0, NULL); |
| 70 | 70 | ||
| 71 | if (cpu) { | 71 | if (cpu) { |
| 72 | fp = of_get_property(cpu, name, NULL); | 72 | fp = of_get_property(cpu, name, NULL); |
| @@ -147,8 +147,9 @@ void __init mpc8xx_calibrate_decr(void) | |||
| 147 | * we have to enable the timebase). The decrementer interrupt | 147 | * we have to enable the timebase). The decrementer interrupt |
| 148 | * is wired into the vector table, nothing to do here for that. | 148 | * is wired into the vector table, nothing to do here for that. |
| 149 | */ | 149 | */ |
| 150 | cpu = of_find_node_by_type(NULL, "cpu"); | 150 | cpu = of_get_cpu_node(0, NULL); |
| 151 | virq= irq_of_parse_and_map(cpu, 0); | 151 | virq= irq_of_parse_and_map(cpu, 0); |
| 152 | of_node_put(cpu); | ||
| 152 | irq = virq_to_hw(virq); | 153 | irq = virq_to_hw(virq); |
| 153 | 154 | ||
| 154 | sys_tmr2 = immr_map(im_sit); | 155 | sys_tmr2 = immr_map(im_sit); |
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c index 4eb8cb38fc69..ed2f54b3f173 100644 --- a/arch/powerpc/platforms/powermac/feature.c +++ b/arch/powerpc/platforms/powermac/feature.c | |||
| @@ -1049,7 +1049,6 @@ core99_reset_cpu(struct device_node *node, long param, long value) | |||
| 1049 | unsigned long flags; | 1049 | unsigned long flags; |
| 1050 | struct macio_chip *macio; | 1050 | struct macio_chip *macio; |
| 1051 | struct device_node *np; | 1051 | struct device_node *np; |
| 1052 | struct device_node *cpus; | ||
| 1053 | const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0, | 1052 | const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0, |
| 1054 | KL_GPIO_RESET_CPU1, | 1053 | KL_GPIO_RESET_CPU1, |
| 1055 | KL_GPIO_RESET_CPU2, | 1054 | KL_GPIO_RESET_CPU2, |
| @@ -1059,10 +1058,7 @@ core99_reset_cpu(struct device_node *node, long param, long value) | |||
| 1059 | if (macio->type != macio_keylargo) | 1058 | if (macio->type != macio_keylargo) |
| 1060 | return -ENODEV; | 1059 | return -ENODEV; |
| 1061 | 1060 | ||
| 1062 | cpus = of_find_node_by_path("/cpus"); | 1061 | for_each_of_cpu_node(np) { |
| 1063 | if (cpus == NULL) | ||
| 1064 | return -ENODEV; | ||
| 1065 | for (np = cpus->child; np != NULL; np = np->sibling) { | ||
| 1066 | const u32 *num = of_get_property(np, "reg", NULL); | 1062 | const u32 *num = of_get_property(np, "reg", NULL); |
| 1067 | const u32 *rst = of_get_property(np, "soft-reset", NULL); | 1063 | const u32 *rst = of_get_property(np, "soft-reset", NULL); |
| 1068 | if (num == NULL || rst == NULL) | 1064 | if (num == NULL || rst == NULL) |
| @@ -1072,7 +1068,6 @@ core99_reset_cpu(struct device_node *node, long param, long value) | |||
| 1072 | break; | 1068 | break; |
| 1073 | } | 1069 | } |
| 1074 | } | 1070 | } |
| 1075 | of_node_put(cpus); | ||
| 1076 | if (np == NULL || reset_io == 0) | 1071 | if (np == NULL || reset_io == 0) |
| 1077 | reset_io = dflt_reset_lines[param]; | 1072 | reset_io = dflt_reset_lines[param]; |
| 1078 | 1073 | ||
| @@ -1504,16 +1499,12 @@ static long g5_reset_cpu(struct device_node *node, long param, long value) | |||
| 1504 | unsigned long flags; | 1499 | unsigned long flags; |
| 1505 | struct macio_chip *macio; | 1500 | struct macio_chip *macio; |
| 1506 | struct device_node *np; | 1501 | struct device_node *np; |
| 1507 | struct device_node *cpus; | ||
| 1508 | 1502 | ||
| 1509 | macio = &macio_chips[0]; | 1503 | macio = &macio_chips[0]; |
| 1510 | if (macio->type != macio_keylargo2 && macio->type != macio_shasta) | 1504 | if (macio->type != macio_keylargo2 && macio->type != macio_shasta) |
| 1511 | return -ENODEV; | 1505 | return -ENODEV; |
| 1512 | 1506 | ||
| 1513 | cpus = of_find_node_by_path("/cpus"); | 1507 | for_each_of_cpu_node(np) { |
| 1514 | if (cpus == NULL) | ||
| 1515 | return -ENODEV; | ||
| 1516 | for (np = cpus->child; np != NULL; np = np->sibling) { | ||
| 1517 | const u32 *num = of_get_property(np, "reg", NULL); | 1508 | const u32 *num = of_get_property(np, "reg", NULL); |
| 1518 | const u32 *rst = of_get_property(np, "soft-reset", NULL); | 1509 | const u32 *rst = of_get_property(np, "soft-reset", NULL); |
| 1519 | if (num == NULL || rst == NULL) | 1510 | if (num == NULL || rst == NULL) |
| @@ -1523,7 +1514,6 @@ static long g5_reset_cpu(struct device_node *node, long param, long value) | |||
| 1523 | break; | 1514 | break; |
| 1524 | } | 1515 | } |
| 1525 | } | 1516 | } |
| 1526 | of_node_put(cpus); | ||
| 1527 | if (np == NULL || reset_io == 0) | 1517 | if (np == NULL || reset_io == 0) |
| 1528 | return -ENODEV; | 1518 | return -ENODEV; |
| 1529 | 1519 | ||
| @@ -2515,31 +2505,26 @@ found: | |||
| 2515 | * supposed to be set when not supported, but I'm not very confident | 2505 | * supposed to be set when not supported, but I'm not very confident |
| 2516 | * that all Apple OF revs did it properly, I do it the paranoid way. | 2506 | * that all Apple OF revs did it properly, I do it the paranoid way. |
| 2517 | */ | 2507 | */ |
| 2518 | while (uninorth_base && uninorth_rev > 3) { | 2508 | if (uninorth_base && uninorth_rev > 3) { |
| 2519 | struct device_node *cpus = of_find_node_by_path("/cpus"); | ||
| 2520 | struct device_node *np; | 2509 | struct device_node *np; |
| 2521 | 2510 | ||
| 2522 | if (!cpus || !cpus->child) { | 2511 | for_each_of_cpu_node(np) { |
| 2523 | printk(KERN_WARNING "Can't find CPU(s) in device tree !\n"); | 2512 | int cpu_count = 1; |
| 2524 | of_node_put(cpus); | 2513 | |
| 2525 | break; | 2514 | /* Nap mode not supported on SMP */ |
| 2526 | } | 2515 | if (of_get_property(np, "flush-on-lock", NULL) || |
| 2527 | np = cpus->child; | 2516 | (cpu_count > 1)) { |
| 2528 | /* Nap mode not supported on SMP */ | 2517 | powersave_nap = 0; |
| 2529 | if (np->sibling) { | 2518 | of_node_put(np); |
| 2530 | of_node_put(cpus); | 2519 | break; |
| 2531 | break; | 2520 | } |
| 2532 | } | 2521 | |
| 2533 | /* Nap mode not supported if flush-on-lock property is present */ | 2522 | cpu_count++; |
| 2534 | if (of_get_property(np, "flush-on-lock", NULL)) { | 2523 | powersave_nap = 1; |
| 2535 | of_node_put(cpus); | ||
| 2536 | break; | ||
| 2537 | } | 2524 | } |
| 2538 | of_node_put(cpus); | ||
| 2539 | powersave_nap = 1; | ||
| 2540 | printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n"); | ||
| 2541 | break; | ||
| 2542 | } | 2525 | } |
| 2526 | if (powersave_nap) | ||
| 2527 | printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n"); | ||
| 2543 | 2528 | ||
| 2544 | /* On CPUs that support it (750FX), lowspeed by default during | 2529 | /* On CPUs that support it (750FX), lowspeed by default during |
| 2545 | * NAP mode | 2530 | * NAP mode |
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c index 3a529fcdae97..2f00e3daafb0 100644 --- a/arch/powerpc/platforms/powermac/setup.c +++ b/arch/powerpc/platforms/powermac/setup.c | |||
| @@ -243,10 +243,9 @@ static void __init l2cr_init(void) | |||
| 243 | { | 243 | { |
| 244 | /* Checks "l2cr-value" property in the registry */ | 244 | /* Checks "l2cr-value" property in the registry */ |
| 245 | if (cpu_has_feature(CPU_FTR_L2CR)) { | 245 | if (cpu_has_feature(CPU_FTR_L2CR)) { |
| 246 | struct device_node *np = of_find_node_by_name(NULL, "cpus"); | 246 | struct device_node *np; |
| 247 | if (!np) | 247 | |
| 248 | np = of_find_node_by_type(NULL, "cpu"); | 248 | for_each_of_cpu_node(np) { |
| 249 | if (np) { | ||
| 250 | const unsigned int *l2cr = | 249 | const unsigned int *l2cr = |
| 251 | of_get_property(np, "l2cr-value", NULL); | 250 | of_get_property(np, "l2cr-value", NULL); |
| 252 | if (l2cr) { | 251 | if (l2cr) { |
| @@ -256,6 +255,7 @@ static void __init l2cr_init(void) | |||
| 256 | _set_L2CR(ppc_override_l2cr_value); | 255 | _set_L2CR(ppc_override_l2cr_value); |
| 257 | } | 256 | } |
| 258 | of_node_put(np); | 257 | of_node_put(np); |
| 258 | break; | ||
| 259 | } | 259 | } |
| 260 | } | 260 | } |
| 261 | 261 | ||
| @@ -279,8 +279,8 @@ static void __init pmac_setup_arch(void) | |||
| 279 | /* Set loops_per_jiffy to a half-way reasonable value, | 279 | /* Set loops_per_jiffy to a half-way reasonable value, |
| 280 | for use until calibrate_delay gets called. */ | 280 | for use until calibrate_delay gets called. */ |
| 281 | loops_per_jiffy = 50000000 / HZ; | 281 | loops_per_jiffy = 50000000 / HZ; |
| 282 | cpu = of_find_node_by_type(NULL, "cpu"); | 282 | |
| 283 | if (cpu != NULL) { | 283 | for_each_of_cpu_node(cpu) { |
| 284 | fp = of_get_property(cpu, "clock-frequency", NULL); | 284 | fp = of_get_property(cpu, "clock-frequency", NULL); |
| 285 | if (fp != NULL) { | 285 | if (fp != NULL) { |
| 286 | if (pvr >= 0x30 && pvr < 0x80) | 286 | if (pvr >= 0x30 && pvr < 0x80) |
| @@ -292,8 +292,9 @@ static void __init pmac_setup_arch(void) | |||
| 292 | else | 292 | else |
| 293 | /* 601, 603, etc. */ | 293 | /* 601, 603, etc. */ |
| 294 | loops_per_jiffy = *fp / (2 * HZ); | 294 | loops_per_jiffy = *fp / (2 * HZ); |
| 295 | of_node_put(cpu); | ||
| 296 | break; | ||
| 295 | } | 297 | } |
| 296 | of_node_put(cpu); | ||
| 297 | } | 298 | } |
| 298 | 299 | ||
| 299 | /* See if newworld or oldworld */ | 300 | /* See if newworld or oldworld */ |
diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c index 26789ad28193..cde370cad4ae 100644 --- a/arch/sh/boards/of-generic.c +++ b/arch/sh/boards/of-generic.c | |||
| @@ -64,7 +64,7 @@ static void sh_of_smp_probe(void) | |||
| 64 | 64 | ||
| 65 | init_cpu_possible(cpumask_of(0)); | 65 | init_cpu_possible(cpumask_of(0)); |
| 66 | 66 | ||
| 67 | for_each_node_by_type(np, "cpu") { | 67 | for_each_of_cpu_node(np) { |
| 68 | const __be32 *cell = of_get_property(np, "reg", NULL); | 68 | const __be32 *cell = of_get_property(np, "reg", NULL); |
| 69 | u64 id = -1; | 69 | u64 id = -1; |
| 70 | if (cell) id = of_read_number(cell, of_n_addr_cells(np)); | 70 | if (cell) id = of_read_number(cell, of_n_addr_cells(np)); |
diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h index d955c8df62d6..1902db27ff4b 100644 --- a/arch/sparc/include/asm/prom.h +++ b/arch/sparc/include/asm/prom.h | |||
| @@ -24,9 +24,6 @@ | |||
| 24 | #include <linux/atomic.h> | 24 | #include <linux/atomic.h> |
| 25 | #include <linux/irqdomain.h> | 25 | #include <linux/irqdomain.h> |
| 26 | 26 | ||
| 27 | #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 | ||
| 28 | #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 | ||
| 29 | |||
| 30 | #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) | 27 | #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) |
| 31 | #define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) | 28 | #define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) |
| 32 | #define of_node_cmp(s1, s2) strcmp((s1), (s2)) | 29 | #define of_node_cmp(s1, s2) strcmp((s1), (s2)) |
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index f39f3a06c26f..7299dcbf8e85 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c | |||
| @@ -140,7 +140,7 @@ static void __init dtb_cpu_setup(void) | |||
| 140 | int ret; | 140 | int ret; |
| 141 | 141 | ||
| 142 | version = GET_APIC_VERSION(apic_read(APIC_LVR)); | 142 | version = GET_APIC_VERSION(apic_read(APIC_LVR)); |
| 143 | for_each_node_by_type(dn, "cpu") { | 143 | for_each_of_cpu_node(dn) { |
| 144 | ret = of_property_read_u32(dn, "reg", &apic_id); | 144 | ret = of_property_read_u32(dn, "reg", &apic_id); |
| 145 | if (ret < 0) { | 145 | if (ret < 0) { |
| 146 | pr_warn("%pOF: missing local APIC ID\n", dn); | 146 | pr_warn("%pOF: missing local APIC ID\n", dn); |
diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile index d67e30faff9c..be060dfb1cc3 100644 --- a/arch/xtensa/Makefile +++ b/arch/xtensa/Makefile | |||
| @@ -80,28 +80,18 @@ LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) | |||
| 80 | head-y := arch/xtensa/kernel/head.o | 80 | head-y := arch/xtensa/kernel/head.o |
| 81 | core-y += arch/xtensa/kernel/ arch/xtensa/mm/ | 81 | core-y += arch/xtensa/kernel/ arch/xtensa/mm/ |
| 82 | core-y += $(buildvar) $(buildplf) | 82 | core-y += $(buildvar) $(buildplf) |
| 83 | core-y += arch/xtensa/boot/dts/ | ||
| 83 | 84 | ||
| 84 | libs-y += arch/xtensa/lib/ $(LIBGCC) | 85 | libs-y += arch/xtensa/lib/ $(LIBGCC) |
| 85 | drivers-$(CONFIG_OPROFILE) += arch/xtensa/oprofile/ | 86 | drivers-$(CONFIG_OPROFILE) += arch/xtensa/oprofile/ |
| 86 | 87 | ||
| 87 | ifneq ($(CONFIG_BUILTIN_DTB),"") | ||
| 88 | core-$(CONFIG_OF) += arch/xtensa/boot/dts/ | ||
| 89 | endif | ||
| 90 | |||
| 91 | boot := arch/xtensa/boot | 88 | boot := arch/xtensa/boot |
| 92 | 89 | ||
| 93 | all Image zImage uImage: vmlinux | 90 | all Image zImage uImage: vmlinux |
| 94 | $(Q)$(MAKE) $(build)=$(boot) $@ | 91 | $(Q)$(MAKE) $(build)=$(boot) $@ |
| 95 | 92 | ||
| 96 | %.dtb: | ||
| 97 | $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@ | ||
| 98 | |||
| 99 | dtbs: scripts | ||
| 100 | $(Q)$(MAKE) $(build)=$(boot)/dts | ||
| 101 | |||
| 102 | define archhelp | 93 | define archhelp |
| 103 | @echo '* Image - Kernel ELF image with reset vector' | 94 | @echo '* Image - Kernel ELF image with reset vector' |
| 104 | @echo '* zImage - Compressed kernel image (arch/xtensa/boot/images/zImage.*)' | 95 | @echo '* zImage - Compressed kernel image (arch/xtensa/boot/images/zImage.*)' |
| 105 | @echo '* uImage - U-Boot wrapped image' | 96 | @echo '* uImage - U-Boot wrapped image' |
| 106 | @echo ' dtbs - Build device tree blobs for enabled boards' | ||
| 107 | endef | 97 | endef |
diff --git a/arch/xtensa/platforms/xtfpga/setup.c b/arch/xtensa/platforms/xtfpga/setup.c index 42285f35d313..820e8738af11 100644 --- a/arch/xtensa/platforms/xtfpga/setup.c +++ b/arch/xtensa/platforms/xtfpga/setup.c | |||
| @@ -94,7 +94,7 @@ static void __init xtfpga_clk_setup(struct device_node *np) | |||
| 94 | u32 freq; | 94 | u32 freq; |
| 95 | 95 | ||
| 96 | if (!base) { | 96 | if (!base) { |
| 97 | pr_err("%s: invalid address\n", np->name); | 97 | pr_err("%pOFn: invalid address\n", np); |
| 98 | return; | 98 | return; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| @@ -103,12 +103,12 @@ static void __init xtfpga_clk_setup(struct device_node *np) | |||
| 103 | clk = clk_register_fixed_rate(NULL, np->name, NULL, 0, freq); | 103 | clk = clk_register_fixed_rate(NULL, np->name, NULL, 0, freq); |
| 104 | 104 | ||
| 105 | if (IS_ERR(clk)) { | 105 | if (IS_ERR(clk)) { |
| 106 | pr_err("%s: clk registration failed\n", np->name); | 106 | pr_err("%pOFn: clk registration failed\n", np); |
| 107 | return; | 107 | return; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | if (of_clk_add_provider(np, of_clk_src_simple_get, clk)) { | 110 | if (of_clk_add_provider(np, of_clk_src_simple_get, clk)) { |
| 111 | pr_err("%s: clk provider registration failed\n", np->name); | 111 | pr_err("%pOFn: clk provider registration failed\n", np); |
| 112 | return; | 112 | return; |
| 113 | } | 113 | } |
| 114 | } | 114 | } |
diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c index 439ba5c23693..f0404c6d1ff4 100644 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c | |||
| @@ -706,8 +706,8 @@ static int parse_mc_ranges(struct device *dev, | |||
| 706 | *ranges_start = of_get_property(mc_node, "ranges", &ranges_len); | 706 | *ranges_start = of_get_property(mc_node, "ranges", &ranges_len); |
| 707 | if (!(*ranges_start) || !ranges_len) { | 707 | if (!(*ranges_start) || !ranges_len) { |
| 708 | dev_warn(dev, | 708 | dev_warn(dev, |
| 709 | "missing or empty ranges property for device tree node '%s'\n", | 709 | "missing or empty ranges property for device tree node '%pOFn'\n", |
| 710 | mc_node->name); | 710 | mc_node); |
| 711 | return 0; | 711 | return 0; |
| 712 | } | 712 | } |
| 713 | 713 | ||
| @@ -730,7 +730,7 @@ static int parse_mc_ranges(struct device *dev, | |||
| 730 | 730 | ||
| 731 | tuple_len = range_tuple_cell_count * sizeof(__be32); | 731 | tuple_len = range_tuple_cell_count * sizeof(__be32); |
| 732 | if (ranges_len % tuple_len != 0) { | 732 | if (ranges_len % tuple_len != 0) { |
| 733 | dev_err(dev, "malformed ranges property '%s'\n", mc_node->name); | 733 | dev_err(dev, "malformed ranges property '%pOFn'\n", mc_node); |
| 734 | return -EINVAL; | 734 | return -EINVAL; |
| 735 | } | 735 | } |
| 736 | 736 | ||
diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c index 70db4d5638a6..5b2a11a88951 100644 --- a/drivers/bus/mvebu-mbus.c +++ b/drivers/bus/mvebu-mbus.c | |||
| @@ -1229,7 +1229,7 @@ mbus_parse_ranges(struct device_node *node, | |||
| 1229 | tuple_len = (*cell_count) * sizeof(__be32); | 1229 | tuple_len = (*cell_count) * sizeof(__be32); |
| 1230 | 1230 | ||
| 1231 | if (ranges_len % tuple_len) { | 1231 | if (ranges_len % tuple_len) { |
| 1232 | pr_warn("malformed ranges entry '%s'\n", node->name); | 1232 | pr_warn("malformed ranges entry '%pOFn'\n", node); |
| 1233 | return -EINVAL; | 1233 | return -EINVAL; |
| 1234 | } | 1234 | } |
| 1235 | return 0; | 1235 | return 0; |
diff --git a/drivers/clk/mvebu/clk-cpu.c b/drivers/clk/mvebu/clk-cpu.c index 072aa38374ce..3045067448fb 100644 --- a/drivers/clk/mvebu/clk-cpu.c +++ b/drivers/clk/mvebu/clk-cpu.c | |||
| @@ -183,7 +183,7 @@ static void __init of_cpu_clk_setup(struct device_node *node) | |||
| 183 | pr_warn("%s: pmu-dfs base register not set, dynamic frequency scaling not available\n", | 183 | pr_warn("%s: pmu-dfs base register not set, dynamic frequency scaling not available\n", |
| 184 | __func__); | 184 | __func__); |
| 185 | 185 | ||
| 186 | for_each_node_by_type(dn, "cpu") | 186 | for_each_of_cpu_node(dn) |
| 187 | ncpus++; | 187 | ncpus++; |
| 188 | 188 | ||
| 189 | cpuclk = kcalloc(ncpus, sizeof(*cpuclk), GFP_KERNEL); | 189 | cpuclk = kcalloc(ncpus, sizeof(*cpuclk), GFP_KERNEL); |
| @@ -194,7 +194,7 @@ static void __init of_cpu_clk_setup(struct device_node *node) | |||
| 194 | if (WARN_ON(!clks)) | 194 | if (WARN_ON(!clks)) |
| 195 | goto clks_out; | 195 | goto clks_out; |
| 196 | 196 | ||
| 197 | for_each_node_by_type(dn, "cpu") { | 197 | for_each_of_cpu_node(dn) { |
| 198 | struct clk_init_data init; | 198 | struct clk_init_data init; |
| 199 | struct clk *clk; | 199 | struct clk *clk; |
| 200 | char *clk_name = kzalloc(5, GFP_KERNEL); | 200 | char *clk_name = kzalloc(5, GFP_KERNEL); |
diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c index 2c98e020df05..3c0881ac9880 100644 --- a/drivers/edac/cpc925_edac.c +++ b/drivers/edac/cpc925_edac.c | |||
| @@ -593,8 +593,7 @@ static void cpc925_mc_check(struct mem_ctl_info *mci) | |||
| 593 | /******************** CPU err device********************************/ | 593 | /******************** CPU err device********************************/ |
| 594 | static u32 cpc925_cpu_mask_disabled(void) | 594 | static u32 cpc925_cpu_mask_disabled(void) |
| 595 | { | 595 | { |
| 596 | struct device_node *cpus; | 596 | struct device_node *cpunode; |
| 597 | struct device_node *cpunode = NULL; | ||
| 598 | static u32 mask = 0; | 597 | static u32 mask = 0; |
| 599 | 598 | ||
| 600 | /* use cached value if available */ | 599 | /* use cached value if available */ |
| @@ -603,20 +602,8 @@ static u32 cpc925_cpu_mask_disabled(void) | |||
| 603 | 602 | ||
| 604 | mask = APIMASK_ADI0 | APIMASK_ADI1; | 603 | mask = APIMASK_ADI0 | APIMASK_ADI1; |
| 605 | 604 | ||
| 606 | cpus = of_find_node_by_path("/cpus"); | 605 | for_each_of_cpu_node(cpunode) { |
| 607 | if (cpus == NULL) { | ||
| 608 | cpc925_printk(KERN_DEBUG, "No /cpus node !\n"); | ||
| 609 | return 0; | ||
| 610 | } | ||
| 611 | |||
| 612 | while ((cpunode = of_get_next_child(cpus, cpunode)) != NULL) { | ||
| 613 | const u32 *reg = of_get_property(cpunode, "reg", NULL); | 606 | const u32 *reg = of_get_property(cpunode, "reg", NULL); |
| 614 | |||
| 615 | if (strcmp(cpunode->type, "cpu")) { | ||
| 616 | cpc925_printk(KERN_ERR, "Not a cpu node in /cpus: %s\n", cpunode->name); | ||
| 617 | continue; | ||
| 618 | } | ||
| 619 | |||
| 620 | if (reg == NULL || *reg > 2) { | 607 | if (reg == NULL || *reg > 2) { |
| 621 | cpc925_printk(KERN_ERR, "Bad reg value at %pOF\n", cpunode); | 608 | cpc925_printk(KERN_ERR, "Bad reg value at %pOF\n", cpunode); |
| 622 | continue; | 609 | continue; |
| @@ -633,9 +620,6 @@ static u32 cpc925_cpu_mask_disabled(void) | |||
| 633 | "Assuming PI id is equal to CPU MPIC id!\n"); | 620 | "Assuming PI id is equal to CPU MPIC id!\n"); |
| 634 | } | 621 | } |
| 635 | 622 | ||
| 636 | of_node_put(cpunode); | ||
| 637 | of_node_put(cpus); | ||
| 638 | |||
| 639 | return mask; | 623 | return mask; |
| 640 | } | 624 | } |
| 641 | 625 | ||
diff --git a/drivers/firmware/scpi_pm_domain.c b/drivers/firmware/scpi_pm_domain.c index f395dec27113..390aa13391e4 100644 --- a/drivers/firmware/scpi_pm_domain.c +++ b/drivers/firmware/scpi_pm_domain.c | |||
| @@ -121,7 +121,7 @@ static int scpi_pm_domain_probe(struct platform_device *pdev) | |||
| 121 | 121 | ||
| 122 | scpi_pd->domain = i; | 122 | scpi_pd->domain = i; |
| 123 | scpi_pd->ops = scpi_ops; | 123 | scpi_pd->ops = scpi_ops; |
| 124 | sprintf(scpi_pd->name, "%s.%d", np->name, i); | 124 | sprintf(scpi_pd->name, "%pOFn.%d", np, i); |
| 125 | scpi_pd->genpd.name = scpi_pd->name; | 125 | scpi_pd->genpd.name = scpi_pd->name; |
| 126 | scpi_pd->genpd.power_off = scpi_pd_power_off; | 126 | scpi_pd->genpd.power_off = scpi_pd_power_off; |
| 127 | scpi_pd->genpd.power_on = scpi_pd_power_on; | 127 | scpi_pd->genpd.power_on = scpi_pd_power_on; |
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c index 2d45d1dd9554..643f5edd68fe 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c | |||
| @@ -1446,8 +1446,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, | |||
| 1446 | } | 1446 | } |
| 1447 | 1447 | ||
| 1448 | /* The CEC module handles HDMI hotplug detection */ | 1448 | /* The CEC module handles HDMI hotplug detection */ |
| 1449 | cec_np = of_find_compatible_node(np->parent, NULL, | 1449 | cec_np = of_get_compatible_child(np->parent, "mediatek,mt8173-cec"); |
| 1450 | "mediatek,mt8173-cec"); | ||
| 1451 | if (!cec_np) { | 1450 | if (!cec_np) { |
| 1452 | dev_err(dev, "Failed to find CEC node\n"); | 1451 | dev_err(dev, "Failed to find CEC node\n"); |
| 1453 | return -EINVAL; | 1452 | return -EINVAL; |
| @@ -1457,8 +1456,10 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, | |||
| 1457 | if (!cec_pdev) { | 1456 | if (!cec_pdev) { |
| 1458 | dev_err(hdmi->dev, "Waiting for CEC device %pOF\n", | 1457 | dev_err(hdmi->dev, "Waiting for CEC device %pOF\n", |
| 1459 | cec_np); | 1458 | cec_np); |
| 1459 | of_node_put(cec_np); | ||
| 1460 | return -EPROBE_DEFER; | 1460 | return -EPROBE_DEFER; |
| 1461 | } | 1461 | } |
| 1462 | of_node_put(cec_np); | ||
| 1462 | hdmi->cec_dev = &cec_pdev->dev; | 1463 | hdmi->cec_dev = &cec_pdev->dev; |
| 1463 | 1464 | ||
| 1464 | /* | 1465 | /* |
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index da1363a0c54d..93d70f4a2154 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c | |||
| @@ -633,8 +633,7 @@ static int adreno_get_legacy_pwrlevels(struct device *dev) | |||
| 633 | struct device_node *child, *node; | 633 | struct device_node *child, *node; |
| 634 | int ret; | 634 | int ret; |
| 635 | 635 | ||
| 636 | node = of_find_compatible_node(dev->of_node, NULL, | 636 | node = of_get_compatible_child(dev->of_node, "qcom,gpu-pwrlevels"); |
| 637 | "qcom,gpu-pwrlevels"); | ||
| 638 | if (!node) { | 637 | if (!node) { |
| 639 | dev_err(dev, "Could not find the GPU powerlevels\n"); | 638 | dev_err(dev, "Could not find the GPU powerlevels\n"); |
| 640 | return -ENXIO; | 639 | return -ENXIO; |
| @@ -655,6 +654,8 @@ static int adreno_get_legacy_pwrlevels(struct device *dev) | |||
| 655 | dev_pm_opp_add(dev, val, 0); | 654 | dev_pm_opp_add(dev, val, 0); |
| 656 | } | 655 | } |
| 657 | 656 | ||
| 657 | of_node_put(node); | ||
| 658 | |||
| 658 | return 0; | 659 | return 0; |
| 659 | } | 660 | } |
| 660 | 661 | ||
diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c index 8540625796a1..1b955aea44dd 100644 --- a/drivers/iommu/fsl_pamu.c +++ b/drivers/iommu/fsl_pamu.c | |||
| @@ -543,7 +543,7 @@ u32 get_stash_id(u32 stash_dest_hint, u32 vcpu) | |||
| 543 | return ~(u32)0; | 543 | return ~(u32)0; |
| 544 | } | 544 | } |
| 545 | 545 | ||
| 546 | for_each_node_by_type(node, "cpu") { | 546 | for_each_of_cpu_node(node) { |
| 547 | prop = of_get_property(node, "reg", &len); | 547 | prop = of_get_property(node, "reg", &len); |
| 548 | for (i = 0; i < len / sizeof(u32); i++) { | 548 | for (i = 0; i < len / sizeof(u32); i++) { |
| 549 | if (be32_to_cpup(&prop[i]) == vcpu) { | 549 | if (be32_to_cpup(&prop[i]) == vcpu) { |
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index 35564a8a48f9..a6cbaca37e94 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c | |||
| @@ -341,7 +341,7 @@ static struct device_node *bcmgenet_mii_of_find_mdio(struct bcmgenet_priv *priv) | |||
| 341 | if (!compat) | 341 | if (!compat) |
| 342 | return NULL; | 342 | return NULL; |
| 343 | 343 | ||
| 344 | priv->mdio_dn = of_find_compatible_node(dn, NULL, compat); | 344 | priv->mdio_dn = of_get_compatible_child(dn, compat); |
| 345 | kfree(compat); | 345 | kfree(compat); |
| 346 | if (!priv->mdio_dn) { | 346 | if (!priv->mdio_dn) { |
| 347 | dev_err(kdev, "unable to find MDIO bus node\n"); | 347 | dev_err(kdev, "unable to find MDIO bus node\n"); |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c index f9a61f90cfbc..0f660af01a4b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | |||
| @@ -714,8 +714,9 @@ static int get_ephy_nodes(struct stmmac_priv *priv) | |||
| 714 | return -ENODEV; | 714 | return -ENODEV; |
| 715 | } | 715 | } |
| 716 | 716 | ||
| 717 | mdio_internal = of_find_compatible_node(mdio_mux, NULL, | 717 | mdio_internal = of_get_compatible_child(mdio_mux, |
| 718 | "allwinner,sun8i-h3-mdio-internal"); | 718 | "allwinner,sun8i-h3-mdio-internal"); |
| 719 | of_node_put(mdio_mux); | ||
| 719 | if (!mdio_internal) { | 720 | if (!mdio_internal) { |
| 720 | dev_err(priv->device, "Cannot get internal_mdio node\n"); | 721 | dev_err(priv->device, "Cannot get internal_mdio node\n"); |
| 721 | return -ENODEV; | 722 | return -ENODEV; |
| @@ -729,13 +730,20 @@ static int get_ephy_nodes(struct stmmac_priv *priv) | |||
| 729 | gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL); | 730 | gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL); |
| 730 | if (IS_ERR(gmac->rst_ephy)) { | 731 | if (IS_ERR(gmac->rst_ephy)) { |
| 731 | ret = PTR_ERR(gmac->rst_ephy); | 732 | ret = PTR_ERR(gmac->rst_ephy); |
| 732 | if (ret == -EPROBE_DEFER) | 733 | if (ret == -EPROBE_DEFER) { |
| 734 | of_node_put(iphynode); | ||
| 735 | of_node_put(mdio_internal); | ||
| 733 | return ret; | 736 | return ret; |
| 737 | } | ||
| 734 | continue; | 738 | continue; |
| 735 | } | 739 | } |
| 736 | dev_info(priv->device, "Found internal PHY node\n"); | 740 | dev_info(priv->device, "Found internal PHY node\n"); |
| 741 | of_node_put(iphynode); | ||
| 742 | of_node_put(mdio_internal); | ||
| 737 | return 0; | 743 | return 0; |
| 738 | } | 744 | } |
| 745 | |||
| 746 | of_node_put(mdio_internal); | ||
| 739 | return -ENODEV; | 747 | return -ENODEV; |
| 740 | } | 748 | } |
| 741 | 749 | ||
diff --git a/drivers/nfc/nfcmrvl/uart.c b/drivers/nfc/nfcmrvl/uart.c index 91162f8e0366..9a22056e8d9e 100644 --- a/drivers/nfc/nfcmrvl/uart.c +++ b/drivers/nfc/nfcmrvl/uart.c | |||
| @@ -73,10 +73,9 @@ static int nfcmrvl_uart_parse_dt(struct device_node *node, | |||
| 73 | struct device_node *matched_node; | 73 | struct device_node *matched_node; |
| 74 | int ret; | 74 | int ret; |
| 75 | 75 | ||
| 76 | matched_node = of_find_compatible_node(node, NULL, "marvell,nfc-uart"); | 76 | matched_node = of_get_compatible_child(node, "marvell,nfc-uart"); |
| 77 | if (!matched_node) { | 77 | if (!matched_node) { |
| 78 | matched_node = of_find_compatible_node(node, NULL, | 78 | matched_node = of_get_compatible_child(node, "mrvl,nfc-uart"); |
| 79 | "mrvl,nfc-uart"); | ||
| 80 | if (!matched_node) | 79 | if (!matched_node) |
| 81 | return -ENODEV; | 80 | return -ENODEV; |
| 82 | } | 81 | } |
diff --git a/drivers/of/base.c b/drivers/of/base.c index 90bf7d9fa17b..13ebb16be64e 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
| @@ -67,6 +67,7 @@ bool of_node_name_eq(const struct device_node *np, const char *name) | |||
| 67 | 67 | ||
| 68 | return (strlen(name) == len) && (strncmp(node_name, name, len) == 0); | 68 | return (strlen(name) == len) && (strncmp(node_name, name, len) == 0); |
| 69 | } | 69 | } |
| 70 | EXPORT_SYMBOL(of_node_name_eq); | ||
| 70 | 71 | ||
| 71 | bool of_node_name_prefix(const struct device_node *np, const char *prefix) | 72 | bool of_node_name_prefix(const struct device_node *np, const char *prefix) |
| 72 | { | 73 | { |
| @@ -75,6 +76,7 @@ bool of_node_name_prefix(const struct device_node *np, const char *prefix) | |||
| 75 | 76 | ||
| 76 | return strncmp(kbasename(np->full_name), prefix, strlen(prefix)) == 0; | 77 | return strncmp(kbasename(np->full_name), prefix, strlen(prefix)) == 0; |
| 77 | } | 78 | } |
| 79 | EXPORT_SYMBOL(of_node_name_prefix); | ||
| 78 | 80 | ||
| 79 | int of_n_addr_cells(struct device_node *np) | 81 | int of_n_addr_cells(struct device_node *np) |
| 80 | { | 82 | { |
| @@ -330,6 +332,8 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun, | |||
| 330 | 332 | ||
| 331 | ac = of_n_addr_cells(cpun); | 333 | ac = of_n_addr_cells(cpun); |
| 332 | cell = of_get_property(cpun, prop_name, &prop_len); | 334 | cell = of_get_property(cpun, prop_name, &prop_len); |
| 335 | if (!cell && !ac && arch_match_cpu_phys_id(cpu, 0)) | ||
| 336 | return true; | ||
| 333 | if (!cell || !ac) | 337 | if (!cell || !ac) |
| 334 | return false; | 338 | return false; |
| 335 | prop_len /= sizeof(*cell) * ac; | 339 | prop_len /= sizeof(*cell) * ac; |
| @@ -390,7 +394,7 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread) | |||
| 390 | { | 394 | { |
| 391 | struct device_node *cpun; | 395 | struct device_node *cpun; |
| 392 | 396 | ||
| 393 | for_each_node_by_type(cpun, "cpu") { | 397 | for_each_of_cpu_node(cpun) { |
| 394 | if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread)) | 398 | if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread)) |
| 395 | return cpun; | 399 | return cpun; |
| 396 | } | 400 | } |
| @@ -745,6 +749,45 @@ struct device_node *of_get_next_available_child(const struct device_node *node, | |||
| 745 | EXPORT_SYMBOL(of_get_next_available_child); | 749 | EXPORT_SYMBOL(of_get_next_available_child); |
| 746 | 750 | ||
| 747 | /** | 751 | /** |
| 752 | * of_get_next_cpu_node - Iterate on cpu nodes | ||
| 753 | * @prev: previous child of the /cpus node, or NULL to get first | ||
| 754 | * | ||
| 755 | * Returns a cpu node pointer with refcount incremented, use of_node_put() | ||
| 756 | * on it when done. Returns NULL when prev is the last child. Decrements | ||
| 757 | * the refcount of prev. | ||
| 758 | */ | ||
| 759 | struct device_node *of_get_next_cpu_node(struct device_node *prev) | ||
| 760 | { | ||
| 761 | struct device_node *next = NULL; | ||
| 762 | unsigned long flags; | ||
| 763 | struct device_node *node; | ||
| 764 | |||
| 765 | if (!prev) | ||
| 766 | node = of_find_node_by_path("/cpus"); | ||
| 767 | |||
| 768 | raw_spin_lock_irqsave(&devtree_lock, flags); | ||
| 769 | if (prev) | ||
| 770 | next = prev->sibling; | ||
| 771 | else if (node) { | ||
| 772 | next = node->child; | ||
| 773 | of_node_put(node); | ||
| 774 | } | ||
| 775 | for (; next; next = next->sibling) { | ||
| 776 | if (!(of_node_name_eq(next, "cpu") || | ||
| 777 | (next->type && !of_node_cmp(next->type, "cpu")))) | ||
| 778 | continue; | ||
| 779 | if (!__of_device_is_available(next)) | ||
| 780 | continue; | ||
| 781 | if (of_node_get(next)) | ||
| 782 | break; | ||
| 783 | } | ||
| 784 | of_node_put(prev); | ||
| 785 | raw_spin_unlock_irqrestore(&devtree_lock, flags); | ||
| 786 | return next; | ||
| 787 | } | ||
| 788 | EXPORT_SYMBOL(of_get_next_cpu_node); | ||
| 789 | |||
| 790 | /** | ||
| 748 | * of_get_compatible_child - Find compatible child node | 791 | * of_get_compatible_child - Find compatible child node |
| 749 | * @parent: parent node | 792 | * @parent: parent node |
| 750 | * @compatible: compatible string | 793 | * @compatible: compatible string |
| @@ -2013,7 +2056,7 @@ struct device_node *of_find_next_cache_node(const struct device_node *np) | |||
| 2013 | /* OF on pmac has nodes instead of properties named "l2-cache" | 2056 | /* OF on pmac has nodes instead of properties named "l2-cache" |
| 2014 | * beneath CPU nodes. | 2057 | * beneath CPU nodes. |
| 2015 | */ | 2058 | */ |
| 2016 | if (!strcmp(np->type, "cpu")) | 2059 | if (IS_ENABLED(CONFIG_PPC_PMAC) && !strcmp(np->type, "cpu")) |
| 2017 | for_each_child_of_node(np, child) | 2060 | for_each_child_of_node(np, child) |
| 2018 | if (!strcmp(child->type, "cache")) | 2061 | if (!strcmp(child->type, "cache")) |
| 2019 | return child; | 2062 | return child; |
diff --git a/drivers/of/device.c b/drivers/of/device.c index c7fa5a9697c9..0f27fad9fe94 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c | |||
| @@ -207,7 +207,8 @@ static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len | |||
| 207 | return -ENODEV; | 207 | return -ENODEV; |
| 208 | 208 | ||
| 209 | /* Name & Type */ | 209 | /* Name & Type */ |
| 210 | csize = snprintf(str, len, "of:N%sT%s", dev->of_node->name, | 210 | /* %p eats all alphanum characters, so %c must be used here */ |
| 211 | csize = snprintf(str, len, "of:N%pOFn%c%s", dev->of_node, 'T', | ||
| 211 | dev->of_node->type); | 212 | dev->of_node->type); |
| 212 | tsize = csize; | 213 | tsize = csize; |
| 213 | len -= csize; | 214 | len -= csize; |
| @@ -286,7 +287,7 @@ void of_device_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
| 286 | if ((!dev) || (!dev->of_node)) | 287 | if ((!dev) || (!dev->of_node)) |
| 287 | return; | 288 | return; |
| 288 | 289 | ||
| 289 | add_uevent_var(env, "OF_NAME=%s", dev->of_node->name); | 290 | add_uevent_var(env, "OF_NAME=%pOFn", dev->of_node); |
| 290 | add_uevent_var(env, "OF_FULLNAME=%pOF", dev->of_node); | 291 | add_uevent_var(env, "OF_FULLNAME=%pOF", dev->of_node); |
| 291 | if (dev->of_node->type && strcmp("<NULL>", dev->of_node->type) != 0) | 292 | if (dev->of_node->type && strcmp("<NULL>", dev->of_node->type) != 0) |
| 292 | add_uevent_var(env, "OF_TYPE=%s", dev->of_node->type); | 293 | add_uevent_var(env, "OF_TYPE=%s", dev->of_node->type); |
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index e92391d6d1bd..5ad1342f5682 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c | |||
| @@ -97,8 +97,8 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, | |||
| 97 | return rc; | 97 | return rc; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | dev_dbg(&mdio->dev, "registered phy %s at address %i\n", | 100 | dev_dbg(&mdio->dev, "registered phy %pOFn at address %i\n", |
| 101 | child->name, addr); | 101 | child, addr); |
| 102 | return 0; | 102 | return 0; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| @@ -127,8 +127,8 @@ static int of_mdiobus_register_device(struct mii_bus *mdio, | |||
| 127 | return rc; | 127 | return rc; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | dev_dbg(&mdio->dev, "registered mdio device %s at address %i\n", | 130 | dev_dbg(&mdio->dev, "registered mdio device %pOFn at address %i\n", |
| 131 | child->name, addr); | 131 | child, addr); |
| 132 | return 0; | 132 | return 0; |
| 133 | } | 133 | } |
| 134 | 134 | ||
| @@ -263,8 +263,8 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) | |||
| 263 | continue; | 263 | continue; |
| 264 | 264 | ||
| 265 | /* be noisy to encourage people to set reg property */ | 265 | /* be noisy to encourage people to set reg property */ |
| 266 | dev_info(&mdio->dev, "scan phy %s at address %i\n", | 266 | dev_info(&mdio->dev, "scan phy %pOFn at address %i\n", |
| 267 | child->name, addr); | 267 | child, addr); |
| 268 | 268 | ||
| 269 | if (of_mdiobus_child_is_phy(child)) { | 269 | if (of_mdiobus_child_is_phy(child)) { |
| 270 | rc = of_mdiobus_register_phy(mdio, child, addr); | 270 | rc = of_mdiobus_register_phy(mdio, child, addr); |
diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c index 27d9b4bba535..35c64a4295e0 100644 --- a/drivers/of/of_numa.c +++ b/drivers/of/of_numa.c | |||
| @@ -24,18 +24,9 @@ static void __init of_numa_parse_cpu_nodes(void) | |||
| 24 | { | 24 | { |
| 25 | u32 nid; | 25 | u32 nid; |
| 26 | int r; | 26 | int r; |
| 27 | struct device_node *cpus; | 27 | struct device_node *np; |
| 28 | struct device_node *np = NULL; | ||
| 29 | |||
| 30 | cpus = of_find_node_by_path("/cpus"); | ||
| 31 | if (!cpus) | ||
| 32 | return; | ||
| 33 | |||
| 34 | for_each_child_of_node(cpus, np) { | ||
| 35 | /* Skip things that are not CPUs */ | ||
| 36 | if (of_node_cmp(np->type, "cpu") != 0) | ||
| 37 | continue; | ||
| 38 | 28 | ||
| 29 | for_each_of_cpu_node(np) { | ||
| 39 | r = of_property_read_u32(np, "numa-node-id", &nid); | 30 | r = of_property_read_u32(np, "numa-node-id", &nid); |
| 40 | if (r) | 31 | if (r) |
| 41 | continue; | 32 | continue; |
| @@ -46,8 +37,6 @@ static void __init of_numa_parse_cpu_nodes(void) | |||
| 46 | else | 37 | else |
| 47 | node_set(nid, numa_nodes_parsed); | 38 | node_set(nid, numa_nodes_parsed); |
| 48 | } | 39 | } |
| 49 | |||
| 50 | of_node_put(cpus); | ||
| 51 | } | 40 | } |
| 52 | 41 | ||
| 53 | static int __init of_numa_parse_memory_nodes(void) | 42 | static int __init of_numa_parse_memory_nodes(void) |
| @@ -163,8 +152,8 @@ int of_node_to_nid(struct device_node *device) | |||
| 163 | np = of_get_next_parent(np); | 152 | np = of_get_next_parent(np); |
| 164 | } | 153 | } |
| 165 | if (np && r) | 154 | if (np && r) |
| 166 | pr_warn("Invalid \"numa-node-id\" property in node %s\n", | 155 | pr_warn("Invalid \"numa-node-id\" property in node %pOFn\n", |
| 167 | np->name); | 156 | np); |
| 168 | of_node_put(np); | 157 | of_node_put(np); |
| 169 | 158 | ||
| 170 | /* | 159 | /* |
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index 216175d11d3d..5d1567025358 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h | |||
| @@ -27,6 +27,14 @@ struct alias_prop { | |||
| 27 | char stem[0]; | 27 | char stem[0]; |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | #if defined(CONFIG_SPARC) | ||
| 31 | #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 | ||
| 32 | #else | ||
| 33 | #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 | ||
| 37 | |||
| 30 | extern struct mutex of_mutex; | 38 | extern struct mutex of_mutex; |
| 31 | extern struct list_head aliases_lookup; | 39 | extern struct list_head aliases_lookup; |
| 32 | extern struct kset *of_kset; | 40 | extern struct kset *of_kset; |
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index eda57ef12fd0..42b1f73ac5f6 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c | |||
| @@ -425,8 +425,8 @@ static int build_changeset_next_level(struct overlay_changeset *ovcs, | |||
| 425 | for_each_child_of_node(overlay_node, child) { | 425 | for_each_child_of_node(overlay_node, child) { |
| 426 | ret = add_changeset_node(ovcs, target_node, child); | 426 | ret = add_changeset_node(ovcs, target_node, child); |
| 427 | if (ret) { | 427 | if (ret) { |
| 428 | pr_debug("Failed to apply node @%pOF/%s, err=%d\n", | 428 | pr_debug("Failed to apply node @%pOF/%pOFn, err=%d\n", |
| 429 | target_node, child->name, ret); | 429 | target_node, child, ret); |
| 430 | of_node_put(child); | 430 | of_node_put(child); |
| 431 | return ret; | 431 | return ret; |
| 432 | } | 432 | } |
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 6c59673933e9..04ad312fd85b 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
| @@ -91,8 +91,8 @@ static void of_device_make_bus_id(struct device *dev) | |||
| 91 | */ | 91 | */ |
| 92 | reg = of_get_property(node, "reg", NULL); | 92 | reg = of_get_property(node, "reg", NULL); |
| 93 | if (reg && (addr = of_translate_address(node, reg)) != OF_BAD_ADDR) { | 93 | if (reg && (addr = of_translate_address(node, reg)) != OF_BAD_ADDR) { |
| 94 | dev_set_name(dev, dev_name(dev) ? "%llx.%s:%s" : "%llx.%s", | 94 | dev_set_name(dev, dev_name(dev) ? "%llx.%pOFn:%s" : "%llx.%pOFn", |
| 95 | (unsigned long long)addr, node->name, | 95 | (unsigned long long)addr, node, |
| 96 | dev_name(dev)); | 96 | dev_name(dev)); |
| 97 | return; | 97 | return; |
| 98 | } | 98 | } |
| @@ -142,8 +142,8 @@ struct platform_device *of_device_alloc(struct device_node *np, | |||
| 142 | WARN_ON(rc); | 142 | WARN_ON(rc); |
| 143 | } | 143 | } |
| 144 | if (of_irq_to_resource_table(np, res, num_irq) != num_irq) | 144 | if (of_irq_to_resource_table(np, res, num_irq) != num_irq) |
| 145 | pr_debug("not all legacy IRQ resources mapped for %s\n", | 145 | pr_debug("not all legacy IRQ resources mapped for %pOFn\n", |
| 146 | np->name); | 146 | np); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | dev->dev.of_node = of_node_get(np); | 149 | dev->dev.of_node = of_node_get(np); |
diff --git a/drivers/of/unittest-data/overlay_15.dts b/drivers/of/unittest-data/overlay_15.dts index b98f2514df4b..5728490474f6 100644 --- a/drivers/of/unittest-data/overlay_15.dts +++ b/drivers/of/unittest-data/overlay_15.dts | |||
| @@ -20,8 +20,8 @@ | |||
| 20 | #size-cells = <0>; | 20 | #size-cells = <0>; |
| 21 | reg = <0>; | 21 | reg = <0>; |
| 22 | 22 | ||
| 23 | test-mux-dev { | 23 | test-mux-dev@20 { |
| 24 | reg = <32>; | 24 | reg = <0x20>; |
| 25 | compatible = "unittest-i2c-dev"; | 25 | compatible = "unittest-i2c-dev"; |
| 26 | status = "okay"; | 26 | status = "okay"; |
| 27 | }; | 27 | }; |
diff --git a/drivers/of/unittest-data/tests-overlay.dtsi b/drivers/of/unittest-data/tests-overlay.dtsi index 25cf397b8f6b..4ea024d908ee 100644 --- a/drivers/of/unittest-data/tests-overlay.dtsi +++ b/drivers/of/unittest-data/tests-overlay.dtsi | |||
| @@ -103,8 +103,8 @@ | |||
| 103 | #size-cells = <0>; | 103 | #size-cells = <0>; |
| 104 | reg = <0>; | 104 | reg = <0>; |
| 105 | 105 | ||
| 106 | test-mux-dev { | 106 | test-mux-dev@20 { |
| 107 | reg = <32>; | 107 | reg = <0x20>; |
| 108 | compatible = "unittest-i2c-dev"; | 108 | compatible = "unittest-i2c-dev"; |
| 109 | status = "okay"; | 109 | status = "okay"; |
| 110 | }; | 110 | }; |
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 41b49716ac75..a3a6866765f2 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c | |||
| @@ -212,8 +212,8 @@ static int __init of_unittest_check_node_linkage(struct device_node *np) | |||
| 212 | 212 | ||
| 213 | for_each_child_of_node(np, child) { | 213 | for_each_child_of_node(np, child) { |
| 214 | if (child->parent != np) { | 214 | if (child->parent != np) { |
| 215 | pr_err("Child node %s links to wrong parent %s\n", | 215 | pr_err("Child node %pOFn links to wrong parent %pOFn\n", |
| 216 | child->name, np->name); | 216 | child, np); |
| 217 | rc = -EINVAL; | 217 | rc = -EINVAL; |
| 218 | goto put_child; | 218 | goto put_child; |
| 219 | } | 219 | } |
| @@ -299,6 +299,10 @@ static void __init of_unittest_printf(void) | |||
| 299 | 299 | ||
| 300 | of_unittest_printf_one(np, "%pOF", full_name); | 300 | of_unittest_printf_one(np, "%pOF", full_name); |
| 301 | of_unittest_printf_one(np, "%pOFf", full_name); | 301 | of_unittest_printf_one(np, "%pOFf", full_name); |
| 302 | of_unittest_printf_one(np, "%pOFn", "dev"); | ||
| 303 | of_unittest_printf_one(np, "%2pOFn", "dev"); | ||
| 304 | of_unittest_printf_one(np, "%5pOFn", " dev"); | ||
| 305 | of_unittest_printf_one(np, "%pOFnc", "dev:test-sub-device"); | ||
| 302 | of_unittest_printf_one(np, "%pOFp", phandle_str); | 306 | of_unittest_printf_one(np, "%pOFp", phandle_str); |
| 303 | of_unittest_printf_one(np, "%pOFP", "dev@100"); | 307 | of_unittest_printf_one(np, "%pOFP", "dev@100"); |
| 304 | of_unittest_printf_one(np, "ABC %pOFP ABC", "ABC dev@100 ABC"); | 308 | of_unittest_printf_one(np, "ABC %pOFP ABC", "ABC dev@100 ABC"); |
| @@ -1046,16 +1050,16 @@ static void __init of_unittest_platform_populate(void) | |||
| 1046 | for_each_child_of_node(np, child) { | 1050 | for_each_child_of_node(np, child) { |
| 1047 | for_each_child_of_node(child, grandchild) | 1051 | for_each_child_of_node(child, grandchild) |
| 1048 | unittest(of_find_device_by_node(grandchild), | 1052 | unittest(of_find_device_by_node(grandchild), |
| 1049 | "Could not create device for node '%s'\n", | 1053 | "Could not create device for node '%pOFn'\n", |
| 1050 | grandchild->name); | 1054 | grandchild); |
| 1051 | } | 1055 | } |
| 1052 | 1056 | ||
| 1053 | of_platform_depopulate(&test_bus->dev); | 1057 | of_platform_depopulate(&test_bus->dev); |
| 1054 | for_each_child_of_node(np, child) { | 1058 | for_each_child_of_node(np, child) { |
| 1055 | for_each_child_of_node(child, grandchild) | 1059 | for_each_child_of_node(child, grandchild) |
| 1056 | unittest(!of_find_device_by_node(grandchild), | 1060 | unittest(!of_find_device_by_node(grandchild), |
| 1057 | "device didn't get destroyed '%s'\n", | 1061 | "device didn't get destroyed '%pOFn'\n", |
| 1058 | grandchild->name); | 1062 | grandchild); |
| 1059 | } | 1063 | } |
| 1060 | 1064 | ||
| 1061 | platform_device_unregister(test_bus); | 1065 | platform_device_unregister(test_bus); |
| @@ -2357,11 +2361,14 @@ static __init void of_unittest_overlay_high_level(void) | |||
| 2357 | } | 2361 | } |
| 2358 | } | 2362 | } |
| 2359 | 2363 | ||
| 2360 | for (np = overlay_base_root->child; np; np = np->sibling) { | 2364 | for_each_child_of_node(overlay_base_root, np) { |
| 2361 | if (of_get_child_by_name(of_root, np->name)) { | 2365 | struct device_node *base_child; |
| 2362 | unittest(0, "illegal node name in overlay_base %s", | 2366 | for_each_child_of_node(of_root, base_child) { |
| 2363 | np->name); | 2367 | if (!strcmp(np->full_name, base_child->full_name)) { |
| 2364 | return; | 2368 | unittest(0, "illegal node name in overlay_base %pOFn", |
| 2369 | np); | ||
| 2370 | return; | ||
| 2371 | } | ||
| 2365 | } | 2372 | } |
| 2366 | } | 2373 | } |
| 2367 | 2374 | ||
diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c index 80582c8f98fa..0e202d4273fb 100644 --- a/drivers/power/supply/twl4030_charger.c +++ b/drivers/power/supply/twl4030_charger.c | |||
| @@ -1022,12 +1022,13 @@ static int twl4030_bci_probe(struct platform_device *pdev) | |||
| 1022 | if (bci->dev->of_node) { | 1022 | if (bci->dev->of_node) { |
| 1023 | struct device_node *phynode; | 1023 | struct device_node *phynode; |
| 1024 | 1024 | ||
| 1025 | phynode = of_find_compatible_node(bci->dev->of_node->parent, | 1025 | phynode = of_get_compatible_child(bci->dev->of_node->parent, |
| 1026 | NULL, "ti,twl4030-usb"); | 1026 | "ti,twl4030-usb"); |
| 1027 | if (phynode) { | 1027 | if (phynode) { |
| 1028 | bci->usb_nb.notifier_call = twl4030_bci_usb_ncb; | 1028 | bci->usb_nb.notifier_call = twl4030_bci_usb_ncb; |
| 1029 | bci->transceiver = devm_usb_get_phy_by_node( | 1029 | bci->transceiver = devm_usb_get_phy_by_node( |
| 1030 | bci->dev, phynode, &bci->usb_nb); | 1030 | bci->dev, phynode, &bci->usb_nb); |
| 1031 | of_node_put(phynode); | ||
| 1031 | if (IS_ERR(bci->transceiver)) { | 1032 | if (IS_ERR(bci->transceiver)) { |
| 1032 | ret = PTR_ERR(bci->transceiver); | 1033 | ret = PTR_ERR(bci->transceiver); |
| 1033 | if (ret == -EPROBE_DEFER) | 1034 | if (ret == -EPROBE_DEFER) |
diff --git a/drivers/soc/dove/pmu.c b/drivers/soc/dove/pmu.c index 5abb08ffb74d..ffc5311c0ed8 100644 --- a/drivers/soc/dove/pmu.c +++ b/drivers/soc/dove/pmu.c | |||
| @@ -383,7 +383,7 @@ int __init dove_init_pmu(void) | |||
| 383 | 383 | ||
| 384 | domains_node = of_get_child_by_name(np_pmu, "domains"); | 384 | domains_node = of_get_child_by_name(np_pmu, "domains"); |
| 385 | if (!domains_node) { | 385 | if (!domains_node) { |
| 386 | pr_err("%s: failed to find domains sub-node\n", np_pmu->name); | 386 | pr_err("%pOFn: failed to find domains sub-node\n", np_pmu); |
| 387 | return 0; | 387 | return 0; |
| 388 | } | 388 | } |
| 389 | 389 | ||
| @@ -396,7 +396,7 @@ int __init dove_init_pmu(void) | |||
| 396 | pmu->pmc_base = of_iomap(pmu->of_node, 0); | 396 | pmu->pmc_base = of_iomap(pmu->of_node, 0); |
| 397 | pmu->pmu_base = of_iomap(pmu->of_node, 1); | 397 | pmu->pmu_base = of_iomap(pmu->of_node, 1); |
| 398 | if (!pmu->pmc_base || !pmu->pmu_base) { | 398 | if (!pmu->pmc_base || !pmu->pmu_base) { |
| 399 | pr_err("%s: failed to map PMU\n", np_pmu->name); | 399 | pr_err("%pOFn: failed to map PMU\n", np_pmu); |
| 400 | iounmap(pmu->pmu_base); | 400 | iounmap(pmu->pmu_base); |
| 401 | iounmap(pmu->pmc_base); | 401 | iounmap(pmu->pmc_base); |
| 402 | kfree(pmu); | 402 | kfree(pmu); |
| @@ -414,7 +414,7 @@ int __init dove_init_pmu(void) | |||
| 414 | break; | 414 | break; |
| 415 | 415 | ||
| 416 | domain->pmu = pmu; | 416 | domain->pmu = pmu; |
| 417 | domain->base.name = kstrdup(np->name, GFP_KERNEL); | 417 | domain->base.name = kasprintf(GFP_KERNEL, "%pOFn", np); |
| 418 | if (!domain->base.name) { | 418 | if (!domain->base.name) { |
| 419 | kfree(domain); | 419 | kfree(domain); |
| 420 | break; | 420 | break; |
| @@ -444,7 +444,7 @@ int __init dove_init_pmu(void) | |||
| 444 | /* Loss of the interrupt controller is not a fatal error. */ | 444 | /* Loss of the interrupt controller is not a fatal error. */ |
| 445 | parent_irq = irq_of_parse_and_map(pmu->of_node, 0); | 445 | parent_irq = irq_of_parse_and_map(pmu->of_node, 0); |
| 446 | if (!parent_irq) { | 446 | if (!parent_irq) { |
| 447 | pr_err("%s: no interrupt specified\n", np_pmu->name); | 447 | pr_err("%pOFn: no interrupt specified\n", np_pmu); |
| 448 | } else { | 448 | } else { |
| 449 | ret = dove_init_pmu_irq(pmu, parent_irq); | 449 | ret = dove_init_pmu_irq(pmu, parent_irq); |
| 450 | if (ret) | 450 | if (ret) |
diff --git a/drivers/soc/fsl/qe/qe_tdm.c b/drivers/soc/fsl/qe/qe_tdm.c index f744c214f680..f78c34647ca2 100644 --- a/drivers/soc/fsl/qe/qe_tdm.c +++ b/drivers/soc/fsl/qe/qe_tdm.c | |||
| @@ -131,7 +131,7 @@ int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm, | |||
| 131 | 131 | ||
| 132 | pdev = of_find_device_by_node(np2); | 132 | pdev = of_find_device_by_node(np2); |
| 133 | if (!pdev) { | 133 | if (!pdev) { |
| 134 | pr_err("%s: failed to lookup pdev\n", np2->name); | 134 | pr_err("%pOFn: failed to lookup pdev\n", np2); |
| 135 | of_node_put(np2); | 135 | of_node_put(np2); |
| 136 | return -EINVAL; | 136 | return -EINVAL; |
| 137 | } | 137 | } |
| @@ -153,7 +153,7 @@ int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm, | |||
| 153 | pdev = of_find_device_by_node(np2); | 153 | pdev = of_find_device_by_node(np2); |
| 154 | if (!pdev) { | 154 | if (!pdev) { |
| 155 | ret = -EINVAL; | 155 | ret = -EINVAL; |
| 156 | pr_err("%s: failed to lookup pdev\n", np2->name); | 156 | pr_err("%pOFn: failed to lookup pdev\n", np2); |
| 157 | of_node_put(np2); | 157 | of_node_put(np2); |
| 158 | goto err_miss_siram_property; | 158 | goto err_miss_siram_property; |
| 159 | } | 159 | } |
diff --git a/drivers/soc/qcom/apr.c b/drivers/soc/qcom/apr.c index 57af8a537332..4bda793ba6ae 100644 --- a/drivers/soc/qcom/apr.c +++ b/drivers/soc/qcom/apr.c | |||
| @@ -219,7 +219,7 @@ static int apr_add_device(struct device *dev, struct device_node *np, | |||
| 219 | adev->domain_id = id->domain_id; | 219 | adev->domain_id = id->domain_id; |
| 220 | adev->version = id->svc_version; | 220 | adev->version = id->svc_version; |
| 221 | if (np) | 221 | if (np) |
| 222 | strncpy(adev->name, np->name, APR_NAME_SIZE); | 222 | snprintf(adev->name, APR_NAME_SIZE, "%pOFn", np); |
| 223 | else | 223 | else |
| 224 | strncpy(adev->name, id->name, APR_NAME_SIZE); | 224 | strncpy(adev->name, id->name, APR_NAME_SIZE); |
| 225 | 225 | ||
diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c index 6dff8682155f..6f86a726bb45 100644 --- a/drivers/soc/rockchip/pm_domains.c +++ b/drivers/soc/rockchip/pm_domains.c | |||
| @@ -392,21 +392,21 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu, | |||
| 392 | error = of_property_read_u32(node, "reg", &id); | 392 | error = of_property_read_u32(node, "reg", &id); |
| 393 | if (error) { | 393 | if (error) { |
| 394 | dev_err(pmu->dev, | 394 | dev_err(pmu->dev, |
| 395 | "%s: failed to retrieve domain id (reg): %d\n", | 395 | "%pOFn: failed to retrieve domain id (reg): %d\n", |
| 396 | node->name, error); | 396 | node, error); |
| 397 | return -EINVAL; | 397 | return -EINVAL; |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | if (id >= pmu->info->num_domains) { | 400 | if (id >= pmu->info->num_domains) { |
| 401 | dev_err(pmu->dev, "%s: invalid domain id %d\n", | 401 | dev_err(pmu->dev, "%pOFn: invalid domain id %d\n", |
| 402 | node->name, id); | 402 | node, id); |
| 403 | return -EINVAL; | 403 | return -EINVAL; |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | pd_info = &pmu->info->domain_info[id]; | 406 | pd_info = &pmu->info->domain_info[id]; |
| 407 | if (!pd_info) { | 407 | if (!pd_info) { |
| 408 | dev_err(pmu->dev, "%s: undefined domain id %d\n", | 408 | dev_err(pmu->dev, "%pOFn: undefined domain id %d\n", |
| 409 | node->name, id); | 409 | node, id); |
| 410 | return -EINVAL; | 410 | return -EINVAL; |
| 411 | } | 411 | } |
| 412 | 412 | ||
| @@ -424,8 +424,8 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu, | |||
| 424 | if (!pd->clks) | 424 | if (!pd->clks) |
| 425 | return -ENOMEM; | 425 | return -ENOMEM; |
| 426 | } else { | 426 | } else { |
| 427 | dev_dbg(pmu->dev, "%s: doesn't have clocks: %d\n", | 427 | dev_dbg(pmu->dev, "%pOFn: doesn't have clocks: %d\n", |
| 428 | node->name, pd->num_clks); | 428 | node, pd->num_clks); |
| 429 | pd->num_clks = 0; | 429 | pd->num_clks = 0; |
| 430 | } | 430 | } |
| 431 | 431 | ||
| @@ -434,8 +434,8 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu, | |||
| 434 | if (IS_ERR(pd->clks[i].clk)) { | 434 | if (IS_ERR(pd->clks[i].clk)) { |
| 435 | error = PTR_ERR(pd->clks[i].clk); | 435 | error = PTR_ERR(pd->clks[i].clk); |
| 436 | dev_err(pmu->dev, | 436 | dev_err(pmu->dev, |
| 437 | "%s: failed to get clk at index %d: %d\n", | 437 | "%pOFn: failed to get clk at index %d: %d\n", |
| 438 | node->name, i, error); | 438 | node, i, error); |
| 439 | return error; | 439 | return error; |
| 440 | } | 440 | } |
| 441 | } | 441 | } |
| @@ -486,8 +486,8 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu, | |||
| 486 | error = rockchip_pd_power(pd, true); | 486 | error = rockchip_pd_power(pd, true); |
| 487 | if (error) { | 487 | if (error) { |
| 488 | dev_err(pmu->dev, | 488 | dev_err(pmu->dev, |
| 489 | "failed to power on domain '%s': %d\n", | 489 | "failed to power on domain '%pOFn': %d\n", |
| 490 | node->name, error); | 490 | node, error); |
| 491 | goto err_unprepare_clocks; | 491 | goto err_unprepare_clocks; |
| 492 | } | 492 | } |
| 493 | 493 | ||
| @@ -575,24 +575,24 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, | |||
| 575 | error = of_property_read_u32(parent, "reg", &idx); | 575 | error = of_property_read_u32(parent, "reg", &idx); |
| 576 | if (error) { | 576 | if (error) { |
| 577 | dev_err(pmu->dev, | 577 | dev_err(pmu->dev, |
| 578 | "%s: failed to retrieve domain id (reg): %d\n", | 578 | "%pOFn: failed to retrieve domain id (reg): %d\n", |
| 579 | parent->name, error); | 579 | parent, error); |
| 580 | goto err_out; | 580 | goto err_out; |
| 581 | } | 581 | } |
| 582 | parent_domain = pmu->genpd_data.domains[idx]; | 582 | parent_domain = pmu->genpd_data.domains[idx]; |
| 583 | 583 | ||
| 584 | error = rockchip_pm_add_one_domain(pmu, np); | 584 | error = rockchip_pm_add_one_domain(pmu, np); |
| 585 | if (error) { | 585 | if (error) { |
| 586 | dev_err(pmu->dev, "failed to handle node %s: %d\n", | 586 | dev_err(pmu->dev, "failed to handle node %pOFn: %d\n", |
| 587 | np->name, error); | 587 | np, error); |
| 588 | goto err_out; | 588 | goto err_out; |
| 589 | } | 589 | } |
| 590 | 590 | ||
| 591 | error = of_property_read_u32(np, "reg", &idx); | 591 | error = of_property_read_u32(np, "reg", &idx); |
| 592 | if (error) { | 592 | if (error) { |
| 593 | dev_err(pmu->dev, | 593 | dev_err(pmu->dev, |
| 594 | "%s: failed to retrieve domain id (reg): %d\n", | 594 | "%pOFn: failed to retrieve domain id (reg): %d\n", |
| 595 | np->name, error); | 595 | np, error); |
| 596 | goto err_out; | 596 | goto err_out; |
| 597 | } | 597 | } |
| 598 | child_domain = pmu->genpd_data.domains[idx]; | 598 | child_domain = pmu->genpd_data.domains[idx]; |
| @@ -683,16 +683,16 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev) | |||
| 683 | for_each_available_child_of_node(np, node) { | 683 | for_each_available_child_of_node(np, node) { |
| 684 | error = rockchip_pm_add_one_domain(pmu, node); | 684 | error = rockchip_pm_add_one_domain(pmu, node); |
| 685 | if (error) { | 685 | if (error) { |
| 686 | dev_err(dev, "failed to handle node %s: %d\n", | 686 | dev_err(dev, "failed to handle node %pOFn: %d\n", |
| 687 | node->name, error); | 687 | node, error); |
| 688 | of_node_put(node); | 688 | of_node_put(node); |
| 689 | goto err_out; | 689 | goto err_out; |
| 690 | } | 690 | } |
| 691 | 691 | ||
| 692 | error = rockchip_pm_add_subdomain(pmu, node); | 692 | error = rockchip_pm_add_subdomain(pmu, node); |
| 693 | if (error < 0) { | 693 | if (error < 0) { |
| 694 | dev_err(dev, "failed to handle subdomain node %s: %d\n", | 694 | dev_err(dev, "failed to handle subdomain node %pOFn: %d\n", |
| 695 | node->name, error); | 695 | node, error); |
| 696 | of_node_put(node); | 696 | of_node_put(node); |
| 697 | goto err_out; | 697 | goto err_out; |
| 698 | } | 698 | } |
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index 2d6f3fcf3211..acbe63e925d5 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c | |||
| @@ -796,7 +796,7 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np) | |||
| 796 | 796 | ||
| 797 | id = tegra_powergate_lookup(pmc, np->name); | 797 | id = tegra_powergate_lookup(pmc, np->name); |
| 798 | if (id < 0) { | 798 | if (id < 0) { |
| 799 | pr_err("powergate lookup failed for %s: %d\n", np->name, id); | 799 | pr_err("powergate lookup failed for %pOFn: %d\n", np, id); |
| 800 | goto free_mem; | 800 | goto free_mem; |
| 801 | } | 801 | } |
| 802 | 802 | ||
| @@ -816,13 +816,13 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np) | |||
| 816 | 816 | ||
| 817 | err = tegra_powergate_of_get_clks(pg, np); | 817 | err = tegra_powergate_of_get_clks(pg, np); |
| 818 | if (err < 0) { | 818 | if (err < 0) { |
| 819 | pr_err("failed to get clocks for %s: %d\n", np->name, err); | 819 | pr_err("failed to get clocks for %pOFn: %d\n", np, err); |
| 820 | goto set_available; | 820 | goto set_available; |
| 821 | } | 821 | } |
| 822 | 822 | ||
| 823 | err = tegra_powergate_of_get_resets(pg, np, off); | 823 | err = tegra_powergate_of_get_resets(pg, np, off); |
| 824 | if (err < 0) { | 824 | if (err < 0) { |
| 825 | pr_err("failed to get resets for %s: %d\n", np->name, err); | 825 | pr_err("failed to get resets for %pOFn: %d\n", np, err); |
| 826 | goto remove_clks; | 826 | goto remove_clks; |
| 827 | } | 827 | } |
| 828 | 828 | ||
| @@ -851,15 +851,15 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np) | |||
| 851 | 851 | ||
| 852 | err = pm_genpd_init(&pg->genpd, NULL, off); | 852 | err = pm_genpd_init(&pg->genpd, NULL, off); |
| 853 | if (err < 0) { | 853 | if (err < 0) { |
| 854 | pr_err("failed to initialise PM domain %s: %d\n", np->name, | 854 | pr_err("failed to initialise PM domain %pOFn: %d\n", np, |
| 855 | err); | 855 | err); |
| 856 | goto remove_resets; | 856 | goto remove_resets; |
| 857 | } | 857 | } |
| 858 | 858 | ||
| 859 | err = of_genpd_add_provider_simple(np, &pg->genpd); | 859 | err = of_genpd_add_provider_simple(np, &pg->genpd); |
| 860 | if (err < 0) { | 860 | if (err < 0) { |
| 861 | pr_err("failed to add PM domain provider for %s: %d\n", | 861 | pr_err("failed to add PM domain provider for %pOFn: %d\n", |
| 862 | np->name, err); | 862 | np, err); |
| 863 | goto remove_genpd; | 863 | goto remove_genpd; |
| 864 | } | 864 | } |
| 865 | 865 | ||
diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c index 224d7ddeeb76..bbd4e5bc8707 100644 --- a/drivers/soc/ti/knav_dma.c +++ b/drivers/soc/ti/knav_dma.c | |||
| @@ -544,15 +544,15 @@ static void __iomem *pktdma_get_regs(struct knav_dma_device *dma, | |||
| 544 | 544 | ||
| 545 | ret = of_address_to_resource(node, index, &res); | 545 | ret = of_address_to_resource(node, index, &res); |
| 546 | if (ret) { | 546 | if (ret) { |
| 547 | dev_err(dev, "Can't translate of node(%s) address for index(%d)\n", | 547 | dev_err(dev, "Can't translate of node(%pOFn) address for index(%d)\n", |
| 548 | node->name, index); | 548 | node, index); |
| 549 | return ERR_PTR(ret); | 549 | return ERR_PTR(ret); |
| 550 | } | 550 | } |
| 551 | 551 | ||
| 552 | regs = devm_ioremap_resource(kdev->dev, &res); | 552 | regs = devm_ioremap_resource(kdev->dev, &res); |
| 553 | if (IS_ERR(regs)) | 553 | if (IS_ERR(regs)) |
| 554 | dev_err(dev, "Failed to map register base for index(%d) node(%s)\n", | 554 | dev_err(dev, "Failed to map register base for index(%d) node(%pOFn)\n", |
| 555 | index, node->name); | 555 | index, node); |
| 556 | if (_size) | 556 | if (_size) |
| 557 | *_size = resource_size(&res); | 557 | *_size = resource_size(&res); |
| 558 | 558 | ||
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c index 6755f2af5619..b5d5673c255c 100644 --- a/drivers/soc/ti/knav_qmss_queue.c +++ b/drivers/soc/ti/knav_qmss_queue.c | |||
| @@ -1382,15 +1382,15 @@ static void __iomem *knav_queue_map_reg(struct knav_device *kdev, | |||
| 1382 | 1382 | ||
| 1383 | ret = of_address_to_resource(node, index, &res); | 1383 | ret = of_address_to_resource(node, index, &res); |
| 1384 | if (ret) { | 1384 | if (ret) { |
| 1385 | dev_err(kdev->dev, "Can't translate of node(%s) address for index(%d)\n", | 1385 | dev_err(kdev->dev, "Can't translate of node(%pOFn) address for index(%d)\n", |
| 1386 | node->name, index); | 1386 | node, index); |
| 1387 | return ERR_PTR(ret); | 1387 | return ERR_PTR(ret); |
| 1388 | } | 1388 | } |
| 1389 | 1389 | ||
| 1390 | regs = devm_ioremap_resource(kdev->dev, &res); | 1390 | regs = devm_ioremap_resource(kdev->dev, &res); |
| 1391 | if (IS_ERR(regs)) | 1391 | if (IS_ERR(regs)) |
| 1392 | dev_err(kdev->dev, "Failed to map register base for index(%d) node(%s)\n", | 1392 | dev_err(kdev->dev, "Failed to map register base for index(%d) node(%pOFn)\n", |
| 1393 | index, node->name); | 1393 | index, node); |
| 1394 | return regs; | 1394 | return regs; |
| 1395 | } | 1395 | } |
| 1396 | 1396 | ||
diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c index bc9eb8afc313..332a56b6811f 100644 --- a/drivers/video/fbdev/fsl-diu-fb.c +++ b/drivers/video/fbdev/fsl-diu-fb.c | |||
| @@ -1925,7 +1925,7 @@ static int __init fsl_diu_init(void) | |||
| 1925 | pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n"); | 1925 | pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n"); |
| 1926 | 1926 | ||
| 1927 | #ifdef CONFIG_NOT_COHERENT_CACHE | 1927 | #ifdef CONFIG_NOT_COHERENT_CACHE |
| 1928 | np = of_find_node_by_type(NULL, "cpu"); | 1928 | np = of_get_cpu_node(0, NULL); |
| 1929 | if (!np) { | 1929 | if (!np) { |
| 1930 | pr_err("fsl-diu-fb: can't find 'cpu' device node\n"); | 1930 | pr_err("fsl-diu-fb: can't find 'cpu' device node\n"); |
| 1931 | return -ENODEV; | 1931 | return -ENODEV; |
diff --git a/include/dt-bindings/clock/exynos3250.h b/include/dt-bindings/clock/exynos3250.h index c796ff02ceeb..fe8214017b46 100644 --- a/include/dt-bindings/clock/exynos3250.h +++ b/include/dt-bindings/clock/exynos3250.h | |||
| @@ -1,11 +1,8 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. | 3 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. |
| 3 | * Author: Tomasz Figa <t.figa@samsung.com> | 4 | * Author: Tomasz Figa <t.figa@samsung.com> |
| 4 | * | 5 | * |
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License version 2 as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * Device Tree binding constants for Samsung Exynos3250 clock controllers. | 6 | * Device Tree binding constants for Samsung Exynos3250 clock controllers. |
| 10 | */ | 7 | */ |
| 11 | 8 | ||
diff --git a/include/dt-bindings/clock/exynos4.h b/include/dt-bindings/clock/exynos4.h index e9f9d400c322..5b1d68512360 100644 --- a/include/dt-bindings/clock/exynos4.h +++ b/include/dt-bindings/clock/exynos4.h | |||
| @@ -1,13 +1,10 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 3 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 3 | * Author: Andrzej Hajda <a.hajda@samsung.com> | 4 | * Author: Andrzej Hajda <a.hajda@samsung.com> |
| 4 | * | 5 | * |
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License version 2 as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * Device Tree binding constants for Exynos4 clock controller. | 6 | * Device Tree binding constants for Exynos4 clock controller. |
| 10 | */ | 7 | */ |
| 11 | 8 | ||
| 12 | #ifndef _DT_BINDINGS_CLOCK_EXYNOS_4_H | 9 | #ifndef _DT_BINDINGS_CLOCK_EXYNOS_4_H |
| 13 | #define _DT_BINDINGS_CLOCK_EXYNOS_4_H | 10 | #define _DT_BINDINGS_CLOCK_EXYNOS_4_H |
diff --git a/include/dt-bindings/clock/exynos5250.h b/include/dt-bindings/clock/exynos5250.h index 15508adcdfde..bc8a3c53a54b 100644 --- a/include/dt-bindings/clock/exynos5250.h +++ b/include/dt-bindings/clock/exynos5250.h | |||
| @@ -1,13 +1,10 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 3 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 3 | * Author: Andrzej Hajda <a.hajda@samsung.com> | 4 | * Author: Andrzej Hajda <a.hajda@samsung.com> |
| 4 | * | 5 | * |
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License version 2 as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * Device Tree binding constants for Exynos5250 clock controller. | 6 | * Device Tree binding constants for Exynos5250 clock controller. |
| 10 | */ | 7 | */ |
| 11 | 8 | ||
| 12 | #ifndef _DT_BINDINGS_CLOCK_EXYNOS_5250_H | 9 | #ifndef _DT_BINDINGS_CLOCK_EXYNOS_5250_H |
| 13 | #define _DT_BINDINGS_CLOCK_EXYNOS_5250_H | 10 | #define _DT_BINDINGS_CLOCK_EXYNOS_5250_H |
diff --git a/include/dt-bindings/clock/exynos5260-clk.h b/include/dt-bindings/clock/exynos5260-clk.h index a4bac9a1764f..98a58cbd81b2 100644 --- a/include/dt-bindings/clock/exynos5260-clk.h +++ b/include/dt-bindings/clock/exynos5260-clk.h | |||
| @@ -1,13 +1,10 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. | 3 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. |
| 3 | * Author: Rahul Sharma <rahul.sharma@samsung.com> | 4 | * Author: Rahul Sharma <rahul.sharma@samsung.com> |
| 4 | * | 5 | * |
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License version 2 as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * Provides Constants for Exynos5260 clocks. | 6 | * Provides Constants for Exynos5260 clocks. |
| 10 | */ | 7 | */ |
| 11 | 8 | ||
| 12 | #ifndef _DT_BINDINGS_CLK_EXYNOS5260_H | 9 | #ifndef _DT_BINDINGS_CLK_EXYNOS5260_H |
| 13 | #define _DT_BINDINGS_CLK_EXYNOS5260_H | 10 | #define _DT_BINDINGS_CLK_EXYNOS5260_H |
diff --git a/include/dt-bindings/clock/exynos5410.h b/include/dt-bindings/clock/exynos5410.h index 6cb4e90f81fc..f179eabbcdb7 100644 --- a/include/dt-bindings/clock/exynos5410.h +++ b/include/dt-bindings/clock/exynos5410.h | |||
| @@ -1,13 +1,10 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. | 3 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. |
| 3 | * Copyright (c) 2016 Krzysztof Kozlowski | 4 | * Copyright (c) 2016 Krzysztof Kozlowski |
| 4 | * | 5 | * |
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License version 2 as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * Device Tree binding constants for Exynos5421 clock controller. | 6 | * Device Tree binding constants for Exynos5421 clock controller. |
| 10 | */ | 7 | */ |
| 11 | 8 | ||
| 12 | #ifndef _DT_BINDINGS_CLOCK_EXYNOS_5410_H | 9 | #ifndef _DT_BINDINGS_CLOCK_EXYNOS_5410_H |
| 13 | #define _DT_BINDINGS_CLOCK_EXYNOS_5410_H | 10 | #define _DT_BINDINGS_CLOCK_EXYNOS_5410_H |
diff --git a/include/dt-bindings/clock/exynos5420.h b/include/dt-bindings/clock/exynos5420.h index 2740ae0424a9..355f469943f1 100644 --- a/include/dt-bindings/clock/exynos5420.h +++ b/include/dt-bindings/clock/exynos5420.h | |||
| @@ -1,13 +1,10 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 3 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 3 | * Author: Andrzej Hajda <a.hajda@samsung.com> | 4 | * Author: Andrzej Hajda <a.hajda@samsung.com> |
| 4 | * | 5 | * |
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License version 2 as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * Device Tree binding constants for Exynos5420 clock controller. | 6 | * Device Tree binding constants for Exynos5420 clock controller. |
| 10 | */ | 7 | */ |
| 11 | 8 | ||
| 12 | #ifndef _DT_BINDINGS_CLOCK_EXYNOS_5420_H | 9 | #ifndef _DT_BINDINGS_CLOCK_EXYNOS_5420_H |
| 13 | #define _DT_BINDINGS_CLOCK_EXYNOS_5420_H | 10 | #define _DT_BINDINGS_CLOCK_EXYNOS_5420_H |
diff --git a/include/dt-bindings/clock/exynos5433.h b/include/dt-bindings/clock/exynos5433.h index be39d23e6a32..98bd85ce1e45 100644 --- a/include/dt-bindings/clock/exynos5433.h +++ b/include/dt-bindings/clock/exynos5433.h | |||
| @@ -1,10 +1,7 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. | 3 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. |
| 3 | * Author: Chanwoo Choi <cw00.choi@samsung.com> | 4 | * Author: Chanwoo Choi <cw00.choi@samsung.com> |
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License version 2 as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | */ | 5 | */ |
| 9 | 6 | ||
| 10 | #ifndef _DT_BINDINGS_CLOCK_EXYNOS5433_H | 7 | #ifndef _DT_BINDINGS_CLOCK_EXYNOS5433_H |
diff --git a/include/dt-bindings/clock/exynos7-clk.h b/include/dt-bindings/clock/exynos7-clk.h index 10c558611085..fce33c7050c8 100644 --- a/include/dt-bindings/clock/exynos7-clk.h +++ b/include/dt-bindings/clock/exynos7-clk.h | |||
| @@ -1,11 +1,8 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. | 3 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. |
| 3 | * Author: Naveen Krishna Ch <naveenkrishna.ch@gmail.com> | 4 | * Author: Naveen Krishna Ch <naveenkrishna.ch@gmail.com> |
| 4 | * | 5 | */ |
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License version 2 as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | */ | ||
| 9 | 6 | ||
| 10 | #ifndef _DT_BINDINGS_CLOCK_EXYNOS7_H | 7 | #ifndef _DT_BINDINGS_CLOCK_EXYNOS7_H |
| 11 | #define _DT_BINDINGS_CLOCK_EXYNOS7_H | 8 | #define _DT_BINDINGS_CLOCK_EXYNOS7_H |
diff --git a/include/dt-bindings/clock/s3c2410.h b/include/dt-bindings/clock/s3c2410.h index 352a7673fc69..0fb65c3f2f59 100644 --- a/include/dt-bindings/clock/s3c2410.h +++ b/include/dt-bindings/clock/s3c2410.h | |||
| @@ -1,10 +1,7 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de> | 3 | * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de> |
| 3 | * | 4 | * |
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License version 2 as | ||
| 6 | * published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * Device Tree binding constants clock controllers of Samsung S3C2410 and later. | 5 | * Device Tree binding constants clock controllers of Samsung S3C2410 and later. |
| 9 | */ | 6 | */ |
| 10 | 7 | ||
diff --git a/include/dt-bindings/clock/s3c2412.h b/include/dt-bindings/clock/s3c2412.h index aac1dcfda81c..b4656156cc0f 100644 --- a/include/dt-bindings/clock/s3c2412.h +++ b/include/dt-bindings/clock/s3c2412.h | |||
| @@ -1,10 +1,7 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de> | 3 | * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de> |
| 3 | * | 4 | * |
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License version 2 as | ||
| 6 | * published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * Device Tree binding constants clock controllers of Samsung S3C2412. | 5 | * Device Tree binding constants clock controllers of Samsung S3C2412. |
| 9 | */ | 6 | */ |
| 10 | 7 | ||
diff --git a/include/dt-bindings/clock/s3c2443.h b/include/dt-bindings/clock/s3c2443.h index f3ba68a25ecb..a9d2f105d536 100644 --- a/include/dt-bindings/clock/s3c2443.h +++ b/include/dt-bindings/clock/s3c2443.h | |||
| @@ -1,10 +1,7 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de> | 3 | * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de> |
| 3 | * | 4 | * |
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License version 2 as | ||
| 6 | * published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * Device Tree binding constants clock controllers of Samsung S3C2443 and later. | 5 | * Device Tree binding constants clock controllers of Samsung S3C2443 and later. |
| 9 | */ | 6 | */ |
| 10 | 7 | ||
diff --git a/include/dt-bindings/interrupt-controller/arm-gic.h b/include/dt-bindings/interrupt-controller/arm-gic.h index 0c85f65c81c7..35b6f69b7db6 100644 --- a/include/dt-bindings/interrupt-controller/arm-gic.h +++ b/include/dt-bindings/interrupt-controller/arm-gic.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | 1 | /* SPDX-License-Identifier: GPL-2.0 OR MIT */ |
| 2 | /* | 2 | /* |
| 3 | * This header provides constants for the ARM GIC. | 3 | * This header provides constants for the ARM GIC. |
| 4 | */ | 4 | */ |
diff --git a/include/dt-bindings/interrupt-controller/irq.h b/include/dt-bindings/interrupt-controller/irq.h index a8b310555f14..9e3d183e1381 100644 --- a/include/dt-bindings/interrupt-controller/irq.h +++ b/include/dt-bindings/interrupt-controller/irq.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | 1 | /* SPDX-License-Identifier: GPL-2.0 OR MIT */ |
| 2 | /* | 2 | /* |
| 3 | * This header provides constants for most IRQ bindings. | 3 | * This header provides constants for most IRQ bindings. |
| 4 | * | 4 | * |
diff --git a/include/dt-bindings/thermal/thermal_exynos.h b/include/dt-bindings/thermal/thermal_exynos.h index 0646500bca69..642e4e7f4084 100644 --- a/include/dt-bindings/thermal/thermal_exynos.h +++ b/include/dt-bindings/thermal/thermal_exynos.h | |||
| @@ -1,19 +1,9 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0+ */ | ||
| 1 | /* | 2 | /* |
| 2 | * thermal_exynos.h - Samsung EXYNOS TMU device tree definitions | 3 | * thermal_exynos.h - Samsung EXYNOS TMU device tree definitions |
| 3 | * | 4 | * |
| 4 | * Copyright (C) 2014 Samsung Electronics | 5 | * Copyright (C) 2014 Samsung Electronics |
| 5 | * Lukasz Majewski <l.majewski@samsung.com> | 6 | * Lukasz Majewski <l.majewski@samsung.com> |
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or | ||
| 10 | * (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 | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | */ | 7 | */ |
| 18 | 8 | ||
| 19 | #ifndef _EXYNOS_THERMAL_TMU_DT_H | 9 | #ifndef _EXYNOS_THERMAL_TMU_DT_H |
diff --git a/include/linux/libfdt_env.h b/include/linux/libfdt_env.h index c6ac1fe7ec68..edb0f0c30904 100644 --- a/include/linux/libfdt_env.h +++ b/include/linux/libfdt_env.h | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #ifndef LIBFDT_ENV_H | 2 | #ifndef LIBFDT_ENV_H |
| 3 | #define LIBFDT_ENV_H | 3 | #define LIBFDT_ENV_H |
| 4 | 4 | ||
| 5 | #include <linux/kernel.h> /* For INT_MAX */ | ||
| 5 | #include <linux/string.h> | 6 | #include <linux/string.h> |
| 6 | 7 | ||
| 7 | #include <asm/byteorder.h> | 8 | #include <asm/byteorder.h> |
diff --git a/include/linux/of.h b/include/linux/of.h index bf577ca3c8e7..ab96025b2382 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
| @@ -247,12 +247,6 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size) | |||
| 247 | #include <asm/prom.h> | 247 | #include <asm/prom.h> |
| 248 | #endif | 248 | #endif |
| 249 | 249 | ||
| 250 | /* Default #address and #size cells. Allow arch asm/prom.h to override */ | ||
| 251 | #if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT) | ||
| 252 | #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 | ||
| 253 | #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 | ||
| 254 | #endif | ||
| 255 | |||
| 256 | #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) | 250 | #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) |
| 257 | #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) | 251 | #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) |
| 258 | 252 | ||
| @@ -353,6 +347,8 @@ extern const void *of_get_property(const struct device_node *node, | |||
| 353 | const char *name, | 347 | const char *name, |
| 354 | int *lenp); | 348 | int *lenp); |
| 355 | extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); | 349 | extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); |
| 350 | extern struct device_node *of_get_next_cpu_node(struct device_node *prev); | ||
| 351 | |||
| 356 | #define for_each_property_of_node(dn, pp) \ | 352 | #define for_each_property_of_node(dn, pp) \ |
| 357 | for (pp = dn->properties; pp != NULL; pp = pp->next) | 353 | for (pp = dn->properties; pp != NULL; pp = pp->next) |
| 358 | 354 | ||
| @@ -758,6 +754,11 @@ static inline struct device_node *of_get_cpu_node(int cpu, | |||
| 758 | return NULL; | 754 | return NULL; |
| 759 | } | 755 | } |
| 760 | 756 | ||
| 757 | static inline struct device_node *of_get_next_cpu_node(struct device_node *prev) | ||
| 758 | { | ||
| 759 | return NULL; | ||
| 760 | } | ||
| 761 | |||
| 761 | static inline int of_n_addr_cells(struct device_node *np) | 762 | static inline int of_n_addr_cells(struct device_node *np) |
| 762 | { | 763 | { |
| 763 | return 0; | 764 | return 0; |
| @@ -1001,7 +1002,7 @@ static inline struct device_node *of_find_matching_node( | |||
| 1001 | 1002 | ||
| 1002 | static inline const char *of_node_get_device_type(const struct device_node *np) | 1003 | static inline const char *of_node_get_device_type(const struct device_node *np) |
| 1003 | { | 1004 | { |
| 1004 | return of_get_property(np, "type", NULL); | 1005 | return of_get_property(np, "device_type", NULL); |
| 1005 | } | 1006 | } |
| 1006 | 1007 | ||
| 1007 | static inline bool of_node_is_type(const struct device_node *np, const char *type) | 1008 | static inline bool of_node_is_type(const struct device_node *np, const char *type) |
| @@ -1228,6 +1229,10 @@ static inline int of_property_read_s32(const struct device_node *np, | |||
| 1228 | for (child = of_get_next_available_child(parent, NULL); child != NULL; \ | 1229 | for (child = of_get_next_available_child(parent, NULL); child != NULL; \ |
| 1229 | child = of_get_next_available_child(parent, child)) | 1230 | child = of_get_next_available_child(parent, child)) |
| 1230 | 1231 | ||
| 1232 | #define for_each_of_cpu_node(cpu) \ | ||
| 1233 | for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \ | ||
| 1234 | cpu = of_get_next_cpu_node(cpu)) | ||
| 1235 | |||
| 1231 | #define for_each_node_with_property(dn, prop_name) \ | 1236 | #define for_each_node_with_property(dn, prop_name) \ |
| 1232 | for (dn = of_find_node_with_property(NULL, prop_name); dn; \ | 1237 | for (dn = of_find_node_with_property(NULL, prop_name); dn; \ |
| 1233 | dn = of_find_node_with_property(dn, prop_name)) | 1238 | dn = of_find_node_with_property(dn, prop_name)) |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index ad4fbe5bc730..37a54a6dd594 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
| @@ -1684,6 +1684,7 @@ char *device_node_string(char *buf, char *end, struct device_node *dn, | |||
| 1684 | fmt = "f"; | 1684 | fmt = "f"; |
| 1685 | 1685 | ||
| 1686 | for (pass = false; strspn(fmt,"fnpPFcC"); fmt++, pass = true) { | 1686 | for (pass = false; strspn(fmt,"fnpPFcC"); fmt++, pass = true) { |
| 1687 | int precision; | ||
| 1687 | if (pass) { | 1688 | if (pass) { |
| 1688 | if (buf < end) | 1689 | if (buf < end) |
| 1689 | *buf = ':'; | 1690 | *buf = ':'; |
| @@ -1695,7 +1696,11 @@ char *device_node_string(char *buf, char *end, struct device_node *dn, | |||
| 1695 | buf = device_node_gen_full_name(dn, buf, end); | 1696 | buf = device_node_gen_full_name(dn, buf, end); |
| 1696 | break; | 1697 | break; |
| 1697 | case 'n': /* name */ | 1698 | case 'n': /* name */ |
| 1698 | buf = string(buf, end, dn->name, str_spec); | 1699 | p = kbasename(of_node_full_name(dn)); |
| 1700 | precision = str_spec.precision; | ||
| 1701 | str_spec.precision = strchrnul(p, '@') - p; | ||
| 1702 | buf = string(buf, end, p, str_spec); | ||
| 1703 | str_spec.precision = precision; | ||
| 1699 | break; | 1704 | break; |
| 1700 | case 'p': /* phandle */ | 1705 | case 'p': /* phandle */ |
| 1701 | buf = number(buf, end, (unsigned int)dn->phandle, num_spec); | 1706 | buf = number(buf, end, (unsigned int)dn->phandle, num_spec); |
diff --git a/scripts/Makefile b/scripts/Makefile index 61affa300d25..ece52ff20171 100644 --- a/scripts/Makefile +++ b/scripts/Makefile | |||
| @@ -39,8 +39,7 @@ build_unifdef: $(obj)/unifdef | |||
| 39 | subdir-$(CONFIG_MODVERSIONS) += genksyms | 39 | subdir-$(CONFIG_MODVERSIONS) += genksyms |
| 40 | subdir-y += mod | 40 | subdir-y += mod |
| 41 | subdir-$(CONFIG_SECURITY_SELINUX) += selinux | 41 | subdir-$(CONFIG_SECURITY_SELINUX) += selinux |
| 42 | subdir-$(CONFIG_DTC) += dtc | ||
| 43 | subdir-$(CONFIG_GDB_SCRIPTS) += gdb | 42 | subdir-$(CONFIG_GDB_SCRIPTS) += gdb |
| 44 | 43 | ||
| 45 | # Let clean descend into subdirs | 44 | # Let clean descend into subdirs |
| 46 | subdir- += basic kconfig package gcc-plugins | 45 | subdir- += basic dtc kconfig package gcc-plugins |
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 61e596650ed3..8fe4468f9bda 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
| @@ -283,7 +283,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE | |||
| 283 | 283 | ||
| 284 | quiet_cmd_dtc = DTC $@ | 284 | quiet_cmd_dtc = DTC $@ |
| 285 | cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ | 285 | cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ |
| 286 | $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ | 286 | $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ |
| 287 | $(DTC) -O dtb -o $@ -b 0 \ | 287 | $(DTC) -O dtb -o $@ -b 0 \ |
| 288 | $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \ | 288 | $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \ |
| 289 | -d $(depfile).dtc.tmp $(dtc-tmp) ; \ | 289 | -d $(depfile).dtc.tmp $(dtc-tmp) ; \ |
diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile index 1c943e03eaf2..056d5da6c477 100644 --- a/scripts/dtc/Makefile +++ b/scripts/dtc/Makefile | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | # scripts/dtc makefile | 2 | # scripts/dtc makefile |
| 3 | 3 | ||
| 4 | hostprogs-y := dtc | 4 | hostprogs-$(CONFIG_DTC) := dtc |
| 5 | always := $(hostprogs-y) | 5 | always := $(hostprogs-y) |
| 6 | 6 | ||
| 7 | dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \ | 7 | dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \ |
| @@ -11,6 +11,13 @@ dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o | |||
| 11 | # Source files need to get at the userspace version of libfdt_env.h to compile | 11 | # Source files need to get at the userspace version of libfdt_env.h to compile |
| 12 | HOST_EXTRACFLAGS := -I$(src)/libfdt | 12 | HOST_EXTRACFLAGS := -I$(src)/libfdt |
| 13 | 13 | ||
| 14 | ifeq ($(wildcard /usr/include/yaml.h),) | ||
| 15 | HOST_EXTRACFLAGS += -DNO_YAML | ||
| 16 | else | ||
| 17 | dtc-objs += yamltree.o | ||
| 18 | HOSTLDLIBS_dtc := -lyaml | ||
| 19 | endif | ||
| 20 | |||
| 14 | # Generated files need one more search path to include headers in source tree | 21 | # Generated files need one more search path to include headers in source tree |
| 15 | HOSTCFLAGS_dtc-lexer.lex.o := -I$(src) | 22 | HOSTCFLAGS_dtc-lexer.lex.o := -I$(src) |
| 16 | HOSTCFLAGS_dtc-parser.tab.o := -I$(src) | 23 | HOSTCFLAGS_dtc-parser.tab.o := -I$(src) |
diff --git a/scripts/dtc/Makefile.dtc b/scripts/dtc/Makefile.dtc index bece49b35535..d4375630a7f7 100644 --- a/scripts/dtc/Makefile.dtc +++ b/scripts/dtc/Makefile.dtc | |||
| @@ -14,5 +14,9 @@ DTC_SRCS = \ | |||
| 14 | treesource.c \ | 14 | treesource.c \ |
| 15 | util.c | 15 | util.c |
| 16 | 16 | ||
| 17 | ifneq ($(NO_YAML),1) | ||
| 18 | DTC_SRCS += yamltree.c | ||
| 19 | endif | ||
| 20 | |||
| 17 | DTC_GEN_SRCS = dtc-lexer.lex.c dtc-parser.tab.c | 21 | DTC_GEN_SRCS = dtc-lexer.lex.c dtc-parser.tab.c |
| 18 | DTC_OBJS = $(DTC_SRCS:%.c=%.o) $(DTC_GEN_SRCS:%.c=%.o) | 22 | DTC_OBJS = $(DTC_SRCS:%.c=%.o) $(DTC_GEN_SRCS:%.c=%.o) |
diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c index a2cc1036c915..9c9b0c328af6 100644 --- a/scripts/dtc/checks.c +++ b/scripts/dtc/checks.c | |||
| @@ -962,6 +962,143 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no | |||
| 962 | } | 962 | } |
| 963 | WARNING(simple_bus_reg, check_simple_bus_reg, NULL, ®_format, &simple_bus_bridge); | 963 | WARNING(simple_bus_reg, check_simple_bus_reg, NULL, ®_format, &simple_bus_bridge); |
| 964 | 964 | ||
| 965 | static const struct bus_type i2c_bus = { | ||
| 966 | .name = "i2c-bus", | ||
| 967 | }; | ||
| 968 | |||
| 969 | static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct node *node) | ||
| 970 | { | ||
| 971 | if (strprefixeq(node->name, node->basenamelen, "i2c-bus") || | ||
| 972 | strprefixeq(node->name, node->basenamelen, "i2c-arb")) { | ||
| 973 | node->bus = &i2c_bus; | ||
| 974 | } else if (strprefixeq(node->name, node->basenamelen, "i2c")) { | ||
| 975 | struct node *child; | ||
| 976 | for_each_child(node, child) { | ||
| 977 | if (strprefixeq(child->name, node->basenamelen, "i2c-bus")) | ||
| 978 | return; | ||
| 979 | } | ||
| 980 | node->bus = &i2c_bus; | ||
| 981 | } else | ||
| 982 | return; | ||
| 983 | |||
| 984 | if (!node->children) | ||
| 985 | return; | ||
| 986 | |||
| 987 | if (node_addr_cells(node) != 1) | ||
| 988 | FAIL(c, dti, node, "incorrect #address-cells for I2C bus"); | ||
| 989 | if (node_size_cells(node) != 0) | ||
| 990 | FAIL(c, dti, node, "incorrect #size-cells for I2C bus"); | ||
| 991 | |||
| 992 | } | ||
| 993 | WARNING(i2c_bus_bridge, check_i2c_bus_bridge, NULL, &addr_size_cells); | ||
| 994 | |||
| 995 | static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node *node) | ||
| 996 | { | ||
| 997 | struct property *prop; | ||
| 998 | const char *unitname = get_unitname(node); | ||
| 999 | char unit_addr[17]; | ||
| 1000 | uint32_t reg = 0; | ||
| 1001 | int len; | ||
| 1002 | cell_t *cells = NULL; | ||
| 1003 | |||
| 1004 | if (!node->parent || (node->parent->bus != &i2c_bus)) | ||
| 1005 | return; | ||
| 1006 | |||
| 1007 | prop = get_property(node, "reg"); | ||
| 1008 | if (prop) | ||
| 1009 | cells = (cell_t *)prop->val.val; | ||
| 1010 | |||
| 1011 | if (!cells) { | ||
| 1012 | FAIL(c, dti, node, "missing or empty reg property"); | ||
| 1013 | return; | ||
| 1014 | } | ||
| 1015 | |||
| 1016 | reg = fdt32_to_cpu(*cells); | ||
| 1017 | snprintf(unit_addr, sizeof(unit_addr), "%x", reg); | ||
| 1018 | if (!streq(unitname, unit_addr)) | ||
| 1019 | FAIL(c, dti, node, "I2C bus unit address format error, expected \"%s\"", | ||
| 1020 | unit_addr); | ||
| 1021 | |||
| 1022 | for (len = prop->val.len; len > 0; len -= 4) { | ||
| 1023 | reg = fdt32_to_cpu(*(cells++)); | ||
| 1024 | if (reg > 0x3ff) | ||
| 1025 | FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"", | ||
| 1026 | reg); | ||
| 1027 | |||
| 1028 | } | ||
| 1029 | } | ||
| 1030 | WARNING(i2c_bus_reg, check_i2c_bus_reg, NULL, ®_format, &i2c_bus_bridge); | ||
| 1031 | |||
| 1032 | static const struct bus_type spi_bus = { | ||
| 1033 | .name = "spi-bus", | ||
| 1034 | }; | ||
| 1035 | |||
| 1036 | static void check_spi_bus_bridge(struct check *c, struct dt_info *dti, struct node *node) | ||
| 1037 | { | ||
| 1038 | |||
| 1039 | if (strprefixeq(node->name, node->basenamelen, "spi")) { | ||
| 1040 | node->bus = &spi_bus; | ||
| 1041 | } else { | ||
| 1042 | /* Try to detect SPI buses which don't have proper node name */ | ||
| 1043 | struct node *child; | ||
| 1044 | |||
| 1045 | if (node_addr_cells(node) != 1 || node_size_cells(node) != 0) | ||
| 1046 | return; | ||
| 1047 | |||
| 1048 | for_each_child(node, child) { | ||
| 1049 | struct property *prop; | ||
| 1050 | for_each_property(child, prop) { | ||
| 1051 | if (strprefixeq(prop->name, 4, "spi-")) { | ||
| 1052 | node->bus = &spi_bus; | ||
| 1053 | break; | ||
| 1054 | } | ||
| 1055 | } | ||
| 1056 | if (node->bus == &spi_bus) | ||
| 1057 | break; | ||
| 1058 | } | ||
| 1059 | |||
| 1060 | if (node->bus == &spi_bus && get_property(node, "reg")) | ||
| 1061 | FAIL(c, dti, node, "node name for SPI buses should be 'spi'"); | ||
| 1062 | } | ||
| 1063 | if (node->bus != &spi_bus || !node->children) | ||
| 1064 | return; | ||
| 1065 | |||
| 1066 | if (node_addr_cells(node) != 1) | ||
| 1067 | FAIL(c, dti, node, "incorrect #address-cells for SPI bus"); | ||
| 1068 | if (node_size_cells(node) != 0) | ||
| 1069 | FAIL(c, dti, node, "incorrect #size-cells for SPI bus"); | ||
| 1070 | |||
| 1071 | } | ||
| 1072 | WARNING(spi_bus_bridge, check_spi_bus_bridge, NULL, &addr_size_cells); | ||
| 1073 | |||
| 1074 | static void check_spi_bus_reg(struct check *c, struct dt_info *dti, struct node *node) | ||
| 1075 | { | ||
| 1076 | struct property *prop; | ||
| 1077 | const char *unitname = get_unitname(node); | ||
| 1078 | char unit_addr[9]; | ||
| 1079 | uint32_t reg = 0; | ||
| 1080 | cell_t *cells = NULL; | ||
| 1081 | |||
| 1082 | if (!node->parent || (node->parent->bus != &spi_bus)) | ||
| 1083 | return; | ||
| 1084 | |||
| 1085 | prop = get_property(node, "reg"); | ||
| 1086 | if (prop) | ||
| 1087 | cells = (cell_t *)prop->val.val; | ||
| 1088 | |||
| 1089 | if (!cells) { | ||
| 1090 | FAIL(c, dti, node, "missing or empty reg property"); | ||
| 1091 | return; | ||
| 1092 | } | ||
| 1093 | |||
| 1094 | reg = fdt32_to_cpu(*cells); | ||
| 1095 | snprintf(unit_addr, sizeof(unit_addr), "%x", reg); | ||
| 1096 | if (!streq(unitname, unit_addr)) | ||
| 1097 | FAIL(c, dti, node, "SPI bus unit address format error, expected \"%s\"", | ||
| 1098 | unit_addr); | ||
| 1099 | } | ||
| 1100 | WARNING(spi_bus_reg, check_spi_bus_reg, NULL, ®_format, &spi_bus_bridge); | ||
| 1101 | |||
| 965 | static void check_unit_address_format(struct check *c, struct dt_info *dti, | 1102 | static void check_unit_address_format(struct check *c, struct dt_info *dti, |
| 966 | struct node *node) | 1103 | struct node *node) |
| 967 | { | 1104 | { |
| @@ -1582,6 +1719,12 @@ static struct check *check_table[] = { | |||
| 1582 | &simple_bus_bridge, | 1719 | &simple_bus_bridge, |
| 1583 | &simple_bus_reg, | 1720 | &simple_bus_reg, |
| 1584 | 1721 | ||
| 1722 | &i2c_bus_bridge, | ||
| 1723 | &i2c_bus_reg, | ||
| 1724 | |||
| 1725 | &spi_bus_bridge, | ||
| 1726 | &spi_bus_reg, | ||
| 1727 | |||
| 1585 | &avoid_default_addr_size, | 1728 | &avoid_default_addr_size, |
| 1586 | &avoid_unnecessary_addr_size, | 1729 | &avoid_unnecessary_addr_size, |
| 1587 | &unique_unit_address, | 1730 | &unique_unit_address, |
diff --git a/scripts/dtc/data.c b/scripts/dtc/data.c index aa37a16c8891..4a204145cc7b 100644 --- a/scripts/dtc/data.c +++ b/scripts/dtc/data.c | |||
| @@ -74,7 +74,8 @@ struct data data_copy_escape_string(const char *s, int len) | |||
| 74 | struct data d; | 74 | struct data d; |
| 75 | char *q; | 75 | char *q; |
| 76 | 76 | ||
| 77 | d = data_grow_for(empty_data, len + 1); | 77 | d = data_add_marker(empty_data, TYPE_STRING, NULL); |
| 78 | d = data_grow_for(d, len + 1); | ||
| 78 | 79 | ||
| 79 | q = d.val; | 80 | q = d.val; |
| 80 | while (i < len) { | 81 | while (i < len) { |
| @@ -94,6 +95,7 @@ struct data data_copy_file(FILE *f, size_t maxlen) | |||
| 94 | { | 95 | { |
| 95 | struct data d = empty_data; | 96 | struct data d = empty_data; |
| 96 | 97 | ||
| 98 | d = data_add_marker(d, TYPE_NONE, NULL); | ||
| 97 | while (!feof(f) && (d.len < maxlen)) { | 99 | while (!feof(f) && (d.len < maxlen)) { |
| 98 | size_t chunksize, ret; | 100 | size_t chunksize, ret; |
| 99 | 101 | ||
diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y index 011a5b25539a..dd70ebf386f4 100644 --- a/scripts/dtc/dtc-parser.y +++ b/scripts/dtc/dtc-parser.y | |||
| @@ -287,6 +287,7 @@ propdata: | |||
| 287 | } | 287 | } |
| 288 | | propdataprefix DT_REF | 288 | | propdataprefix DT_REF |
| 289 | { | 289 | { |
| 290 | $1 = data_add_marker($1, TYPE_STRING, $2); | ||
| 290 | $$ = data_add_marker($1, REF_PATH, $2); | 291 | $$ = data_add_marker($1, REF_PATH, $2); |
| 291 | } | 292 | } |
| 292 | | propdataprefix DT_INCBIN '(' DT_STRING ',' integer_prim ',' integer_prim ')' | 293 | | propdataprefix DT_INCBIN '(' DT_STRING ',' integer_prim ',' integer_prim ')' |
| @@ -340,22 +341,27 @@ arrayprefix: | |||
| 340 | DT_BITS DT_LITERAL '<' | 341 | DT_BITS DT_LITERAL '<' |
| 341 | { | 342 | { |
| 342 | unsigned long long bits; | 343 | unsigned long long bits; |
| 344 | enum markertype type = TYPE_UINT32; | ||
| 343 | 345 | ||
| 344 | bits = $2; | 346 | bits = $2; |
| 345 | 347 | ||
| 346 | if ((bits != 8) && (bits != 16) && | 348 | switch (bits) { |
| 347 | (bits != 32) && (bits != 64)) { | 349 | case 8: type = TYPE_UINT8; break; |
| 350 | case 16: type = TYPE_UINT16; break; | ||
| 351 | case 32: type = TYPE_UINT32; break; | ||
| 352 | case 64: type = TYPE_UINT64; break; | ||
| 353 | default: | ||
| 348 | ERROR(&@2, "Array elements must be" | 354 | ERROR(&@2, "Array elements must be" |
| 349 | " 8, 16, 32 or 64-bits"); | 355 | " 8, 16, 32 or 64-bits"); |
| 350 | bits = 32; | 356 | bits = 32; |
| 351 | } | 357 | } |
| 352 | 358 | ||
| 353 | $$.data = empty_data; | 359 | $$.data = data_add_marker(empty_data, type, NULL); |
| 354 | $$.bits = bits; | 360 | $$.bits = bits; |
| 355 | } | 361 | } |
| 356 | | '<' | 362 | | '<' |
| 357 | { | 363 | { |
| 358 | $$.data = empty_data; | 364 | $$.data = data_add_marker(empty_data, TYPE_UINT32, NULL); |
| 359 | $$.bits = 32; | 365 | $$.bits = 32; |
| 360 | } | 366 | } |
| 361 | | arrayprefix integer_prim | 367 | | arrayprefix integer_prim |
| @@ -499,7 +505,7 @@ integer_unary: | |||
| 499 | bytestring: | 505 | bytestring: |
| 500 | /* empty */ | 506 | /* empty */ |
| 501 | { | 507 | { |
| 502 | $$ = empty_data; | 508 | $$ = data_add_marker(empty_data, TYPE_UINT8, NULL); |
| 503 | } | 509 | } |
| 504 | | bytestring DT_BYTE | 510 | | bytestring DT_BYTE |
| 505 | { | 511 | { |
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c index c36994e6eac5..64134aadb997 100644 --- a/scripts/dtc/dtc.c +++ b/scripts/dtc/dtc.c | |||
| @@ -95,6 +95,9 @@ static const char * const usage_opts_help[] = { | |||
| 95 | "\n\tOutput formats are:\n" | 95 | "\n\tOutput formats are:\n" |
| 96 | "\t\tdts - device tree source text\n" | 96 | "\t\tdts - device tree source text\n" |
| 97 | "\t\tdtb - device tree blob\n" | 97 | "\t\tdtb - device tree blob\n" |
| 98 | #ifndef NO_YAML | ||
| 99 | "\t\tyaml - device tree encoded as YAML\n" | ||
| 100 | #endif | ||
| 98 | "\t\tasm - assembler source", | 101 | "\t\tasm - assembler source", |
| 99 | "\n\tBlob version to produce, defaults to "stringify(DEFAULT_FDT_VERSION)" (for dtb and asm output)", | 102 | "\n\tBlob version to produce, defaults to "stringify(DEFAULT_FDT_VERSION)" (for dtb and asm output)", |
| 100 | "\n\tOutput dependency file", | 103 | "\n\tOutput dependency file", |
| @@ -128,6 +131,8 @@ static const char *guess_type_by_name(const char *fname, const char *fallback) | |||
| 128 | return fallback; | 131 | return fallback; |
| 129 | if (!strcasecmp(s, ".dts")) | 132 | if (!strcasecmp(s, ".dts")) |
| 130 | return "dts"; | 133 | return "dts"; |
| 134 | if (!strcasecmp(s, ".yaml")) | ||
| 135 | return "yaml"; | ||
| 131 | if (!strcasecmp(s, ".dtb")) | 136 | if (!strcasecmp(s, ".dtb")) |
| 132 | return "dtb"; | 137 | return "dtb"; |
| 133 | return fallback; | 138 | return fallback; |
| @@ -350,6 +355,12 @@ int main(int argc, char *argv[]) | |||
| 350 | 355 | ||
| 351 | if (streq(outform, "dts")) { | 356 | if (streq(outform, "dts")) { |
| 352 | dt_to_source(outf, dti); | 357 | dt_to_source(outf, dti); |
| 358 | #ifndef NO_YAML | ||
| 359 | } else if (streq(outform, "yaml")) { | ||
| 360 | if (!streq(inform, "dts")) | ||
| 361 | die("YAML output format requires dts input format\n"); | ||
| 362 | dt_to_yaml(outf, dti); | ||
| 363 | #endif | ||
| 353 | } else if (streq(outform, "dtb")) { | 364 | } else if (streq(outform, "dtb")) { |
| 354 | dt_to_blob(outf, dti, outversion); | 365 | dt_to_blob(outf, dti, outversion); |
| 355 | } else if (streq(outform, "asm")) { | 366 | } else if (streq(outform, "asm")) { |
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h index 6d667701ab6a..cbe541525c2c 100644 --- a/scripts/dtc/dtc.h +++ b/scripts/dtc/dtc.h | |||
| @@ -74,10 +74,17 @@ typedef uint32_t cell_t; | |||
| 74 | 74 | ||
| 75 | /* Data blobs */ | 75 | /* Data blobs */ |
| 76 | enum markertype { | 76 | enum markertype { |
| 77 | TYPE_NONE, | ||
| 77 | REF_PHANDLE, | 78 | REF_PHANDLE, |
| 78 | REF_PATH, | 79 | REF_PATH, |
| 79 | LABEL, | 80 | LABEL, |
| 81 | TYPE_UINT8, | ||
| 82 | TYPE_UINT16, | ||
| 83 | TYPE_UINT32, | ||
| 84 | TYPE_UINT64, | ||
| 85 | TYPE_STRING, | ||
| 80 | }; | 86 | }; |
| 87 | extern const char *markername(enum markertype markertype); | ||
| 81 | 88 | ||
| 82 | struct marker { | 89 | struct marker { |
| 83 | enum markertype type; | 90 | enum markertype type; |
| @@ -101,6 +108,8 @@ struct data { | |||
| 101 | for_each_marker(m) \ | 108 | for_each_marker(m) \ |
| 102 | if ((m)->type == (t)) | 109 | if ((m)->type == (t)) |
| 103 | 110 | ||
| 111 | size_t type_marker_length(struct marker *m); | ||
| 112 | |||
| 104 | void data_free(struct data d); | 113 | void data_free(struct data d); |
| 105 | 114 | ||
| 106 | struct data data_grow_for(struct data d, int xlen); | 115 | struct data data_grow_for(struct data d, int xlen); |
| @@ -290,6 +299,10 @@ struct dt_info *dt_from_blob(const char *fname); | |||
| 290 | void dt_to_source(FILE *f, struct dt_info *dti); | 299 | void dt_to_source(FILE *f, struct dt_info *dti); |
| 291 | struct dt_info *dt_from_source(const char *f); | 300 | struct dt_info *dt_from_source(const char *f); |
| 292 | 301 | ||
| 302 | /* YAML source */ | ||
| 303 | |||
| 304 | void dt_to_yaml(FILE *f, struct dt_info *dti); | ||
| 305 | |||
| 293 | /* FS trees */ | 306 | /* FS trees */ |
| 294 | 307 | ||
| 295 | struct dt_info *dt_from_fs(const char *dirname); | 308 | struct dt_info *dt_from_fs(const char *dirname); |
diff --git a/scripts/dtc/flattree.c b/scripts/dtc/flattree.c index 8d268fb785db..851ea87dbc0f 100644 --- a/scripts/dtc/flattree.c +++ b/scripts/dtc/flattree.c | |||
| @@ -393,7 +393,7 @@ void dt_to_blob(FILE *f, struct dt_info *dti, int version) | |||
| 393 | padlen = 0; | 393 | padlen = 0; |
| 394 | if (quiet < 1) | 394 | if (quiet < 1) |
| 395 | fprintf(stderr, | 395 | fprintf(stderr, |
| 396 | "Warning: blob size %d >= minimum size %d\n", | 396 | "Warning: blob size %"PRIu32" >= minimum size %d\n", |
| 397 | fdt32_to_cpu(fdt.totalsize), minsize); | 397 | fdt32_to_cpu(fdt.totalsize), minsize); |
| 398 | } | 398 | } |
| 399 | } | 399 | } |
diff --git a/scripts/dtc/libfdt/fdt.c b/scripts/dtc/libfdt/fdt.c index 7855a1787763..ae03b1112961 100644 --- a/scripts/dtc/libfdt/fdt.c +++ b/scripts/dtc/libfdt/fdt.c | |||
| @@ -55,7 +55,12 @@ | |||
| 55 | 55 | ||
| 56 | #include "libfdt_internal.h" | 56 | #include "libfdt_internal.h" |
| 57 | 57 | ||
| 58 | int fdt_check_header(const void *fdt) | 58 | /* |
| 59 | * Minimal sanity check for a read-only tree. fdt_ro_probe_() checks | ||
| 60 | * that the given buffer contains what appears to be a flattened | ||
| 61 | * device tree with sane information in its header. | ||
| 62 | */ | ||
| 63 | int fdt_ro_probe_(const void *fdt) | ||
| 59 | { | 64 | { |
| 60 | if (fdt_magic(fdt) == FDT_MAGIC) { | 65 | if (fdt_magic(fdt) == FDT_MAGIC) { |
| 61 | /* Complete tree */ | 66 | /* Complete tree */ |
| @@ -74,6 +79,78 @@ int fdt_check_header(const void *fdt) | |||
| 74 | return 0; | 79 | return 0; |
| 75 | } | 80 | } |
| 76 | 81 | ||
| 82 | static int check_off_(uint32_t hdrsize, uint32_t totalsize, uint32_t off) | ||
| 83 | { | ||
| 84 | return (off >= hdrsize) && (off <= totalsize); | ||
| 85 | } | ||
| 86 | |||
| 87 | static int check_block_(uint32_t hdrsize, uint32_t totalsize, | ||
| 88 | uint32_t base, uint32_t size) | ||
| 89 | { | ||
| 90 | if (!check_off_(hdrsize, totalsize, base)) | ||
| 91 | return 0; /* block start out of bounds */ | ||
| 92 | if ((base + size) < base) | ||
| 93 | return 0; /* overflow */ | ||
| 94 | if (!check_off_(hdrsize, totalsize, base + size)) | ||
| 95 | return 0; /* block end out of bounds */ | ||
| 96 | return 1; | ||
| 97 | } | ||
| 98 | |||
| 99 | size_t fdt_header_size_(uint32_t version) | ||
| 100 | { | ||
| 101 | if (version <= 1) | ||
| 102 | return FDT_V1_SIZE; | ||
| 103 | else if (version <= 2) | ||
| 104 | return FDT_V2_SIZE; | ||
| 105 | else if (version <= 3) | ||
| 106 | return FDT_V3_SIZE; | ||
| 107 | else if (version <= 16) | ||
| 108 | return FDT_V16_SIZE; | ||
| 109 | else | ||
| 110 | return FDT_V17_SIZE; | ||
| 111 | } | ||
| 112 | |||
| 113 | int fdt_check_header(const void *fdt) | ||
| 114 | { | ||
| 115 | size_t hdrsize; | ||
| 116 | |||
| 117 | if (fdt_magic(fdt) != FDT_MAGIC) | ||
| 118 | return -FDT_ERR_BADMAGIC; | ||
| 119 | hdrsize = fdt_header_size(fdt); | ||
| 120 | if ((fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION) | ||
| 121 | || (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION)) | ||
| 122 | return -FDT_ERR_BADVERSION; | ||
| 123 | if (fdt_version(fdt) < fdt_last_comp_version(fdt)) | ||
| 124 | return -FDT_ERR_BADVERSION; | ||
| 125 | |||
| 126 | if ((fdt_totalsize(fdt) < hdrsize) | ||
| 127 | || (fdt_totalsize(fdt) > INT_MAX)) | ||
| 128 | return -FDT_ERR_TRUNCATED; | ||
| 129 | |||
| 130 | /* Bounds check memrsv block */ | ||
| 131 | if (!check_off_(hdrsize, fdt_totalsize(fdt), fdt_off_mem_rsvmap(fdt))) | ||
| 132 | return -FDT_ERR_TRUNCATED; | ||
| 133 | |||
| 134 | /* Bounds check structure block */ | ||
| 135 | if (fdt_version(fdt) < 17) { | ||
| 136 | if (!check_off_(hdrsize, fdt_totalsize(fdt), | ||
| 137 | fdt_off_dt_struct(fdt))) | ||
| 138 | return -FDT_ERR_TRUNCATED; | ||
| 139 | } else { | ||
| 140 | if (!check_block_(hdrsize, fdt_totalsize(fdt), | ||
| 141 | fdt_off_dt_struct(fdt), | ||
| 142 | fdt_size_dt_struct(fdt))) | ||
| 143 | return -FDT_ERR_TRUNCATED; | ||
| 144 | } | ||
| 145 | |||
| 146 | /* Bounds check strings block */ | ||
| 147 | if (!check_block_(hdrsize, fdt_totalsize(fdt), | ||
| 148 | fdt_off_dt_strings(fdt), fdt_size_dt_strings(fdt))) | ||
| 149 | return -FDT_ERR_TRUNCATED; | ||
| 150 | |||
| 151 | return 0; | ||
| 152 | } | ||
| 153 | |||
| 77 | const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) | 154 | const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) |
| 78 | { | 155 | { |
| 79 | unsigned absoffset = offset + fdt_off_dt_struct(fdt); | 156 | unsigned absoffset = offset + fdt_off_dt_struct(fdt); |
| @@ -244,7 +321,7 @@ const char *fdt_find_string_(const char *strtab, int tabsize, const char *s) | |||
| 244 | 321 | ||
| 245 | int fdt_move(const void *fdt, void *buf, int bufsize) | 322 | int fdt_move(const void *fdt, void *buf, int bufsize) |
| 246 | { | 323 | { |
| 247 | FDT_CHECK_HEADER(fdt); | 324 | FDT_RO_PROBE(fdt); |
| 248 | 325 | ||
| 249 | if (fdt_totalsize(fdt) > bufsize) | 326 | if (fdt_totalsize(fdt) > bufsize) |
| 250 | return -FDT_ERR_NOSPACE; | 327 | return -FDT_ERR_NOSPACE; |
diff --git a/scripts/dtc/libfdt/fdt_addresses.c b/scripts/dtc/libfdt/fdt_addresses.c index eff4dbcc729d..49537b578d03 100644 --- a/scripts/dtc/libfdt/fdt_addresses.c +++ b/scripts/dtc/libfdt/fdt_addresses.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * libfdt - Flat Device Tree manipulation | 2 | * libfdt - Flat Device Tree manipulation |
| 3 | * Copyright (C) 2014 David Gibson <david@gibson.dropbear.id.au> | 3 | * Copyright (C) 2014 David Gibson <david@gibson.dropbear.id.au> |
| 4 | * Copyright (C) 2018 embedded brains GmbH | ||
| 4 | * | 5 | * |
| 5 | * libfdt is dual licensed: you can use it either under the terms of | 6 | * libfdt is dual licensed: you can use it either under the terms of |
| 6 | * the GPL, or the BSD license, at your option. | 7 | * the GPL, or the BSD license, at your option. |
| @@ -55,42 +56,32 @@ | |||
| 55 | 56 | ||
| 56 | #include "libfdt_internal.h" | 57 | #include "libfdt_internal.h" |
| 57 | 58 | ||
| 58 | int fdt_address_cells(const void *fdt, int nodeoffset) | 59 | static int fdt_cells(const void *fdt, int nodeoffset, const char *name) |
| 59 | { | 60 | { |
| 60 | const fdt32_t *ac; | 61 | const fdt32_t *c; |
| 61 | int val; | 62 | int val; |
| 62 | int len; | 63 | int len; |
| 63 | 64 | ||
| 64 | ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len); | 65 | c = fdt_getprop(fdt, nodeoffset, name, &len); |
| 65 | if (!ac) | 66 | if (!c) |
| 66 | return 2; | 67 | return 2; |
| 67 | 68 | ||
| 68 | if (len != sizeof(*ac)) | 69 | if (len != sizeof(*c)) |
| 69 | return -FDT_ERR_BADNCELLS; | 70 | return -FDT_ERR_BADNCELLS; |
| 70 | 71 | ||
| 71 | val = fdt32_to_cpu(*ac); | 72 | val = fdt32_to_cpu(*c); |
| 72 | if ((val <= 0) || (val > FDT_MAX_NCELLS)) | 73 | if ((val <= 0) || (val > FDT_MAX_NCELLS)) |
| 73 | return -FDT_ERR_BADNCELLS; | 74 | return -FDT_ERR_BADNCELLS; |
| 74 | 75 | ||
| 75 | return val; | 76 | return val; |
| 76 | } | 77 | } |
| 77 | 78 | ||
| 78 | int fdt_size_cells(const void *fdt, int nodeoffset) | 79 | int fdt_address_cells(const void *fdt, int nodeoffset) |
| 79 | { | 80 | { |
| 80 | const fdt32_t *sc; | 81 | return fdt_cells(fdt, nodeoffset, "#address-cells"); |
| 81 | int val; | 82 | } |
| 82 | int len; | ||
| 83 | |||
| 84 | sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len); | ||
| 85 | if (!sc) | ||
| 86 | return 2; | ||
| 87 | |||
| 88 | if (len != sizeof(*sc)) | ||
| 89 | return -FDT_ERR_BADNCELLS; | ||
| 90 | |||
| 91 | val = fdt32_to_cpu(*sc); | ||
| 92 | if ((val < 0) || (val > FDT_MAX_NCELLS)) | ||
| 93 | return -FDT_ERR_BADNCELLS; | ||
| 94 | 83 | ||
| 95 | return val; | 84 | int fdt_size_cells(const void *fdt, int nodeoffset) |
| 85 | { | ||
| 86 | return fdt_cells(fdt, nodeoffset, "#size-cells"); | ||
| 96 | } | 87 | } |
diff --git a/scripts/dtc/libfdt/fdt_overlay.c b/scripts/dtc/libfdt/fdt_overlay.c index bf75388ec9a2..5fdab6c6371d 100644 --- a/scripts/dtc/libfdt/fdt_overlay.c +++ b/scripts/dtc/libfdt/fdt_overlay.c | |||
| @@ -697,7 +697,7 @@ static int get_path_len(const void *fdt, int nodeoffset) | |||
| 697 | int len = 0, namelen; | 697 | int len = 0, namelen; |
| 698 | const char *name; | 698 | const char *name; |
| 699 | 699 | ||
| 700 | FDT_CHECK_HEADER(fdt); | 700 | FDT_RO_PROBE(fdt); |
| 701 | 701 | ||
| 702 | for (;;) { | 702 | for (;;) { |
| 703 | name = fdt_get_name(fdt, nodeoffset, &namelen); | 703 | name = fdt_get_name(fdt, nodeoffset, &namelen); |
| @@ -866,8 +866,8 @@ int fdt_overlay_apply(void *fdt, void *fdto) | |||
| 866 | uint32_t delta = fdt_get_max_phandle(fdt); | 866 | uint32_t delta = fdt_get_max_phandle(fdt); |
| 867 | int ret; | 867 | int ret; |
| 868 | 868 | ||
| 869 | FDT_CHECK_HEADER(fdt); | 869 | FDT_RO_PROBE(fdt); |
| 870 | FDT_CHECK_HEADER(fdto); | 870 | FDT_RO_PROBE(fdto); |
| 871 | 871 | ||
| 872 | ret = overlay_adjust_local_phandles(fdto, delta); | 872 | ret = overlay_adjust_local_phandles(fdto, delta); |
| 873 | if (ret) | 873 | if (ret) |
diff --git a/scripts/dtc/libfdt/fdt_ro.c b/scripts/dtc/libfdt/fdt_ro.c index dfb3236da388..eafc14282892 100644 --- a/scripts/dtc/libfdt/fdt_ro.c +++ b/scripts/dtc/libfdt/fdt_ro.c | |||
| @@ -76,17 +76,72 @@ static int fdt_nodename_eq_(const void *fdt, int offset, | |||
| 76 | return 0; | 76 | return 0; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | const char *fdt_get_string(const void *fdt, int stroffset, int *lenp) | ||
| 80 | { | ||
| 81 | uint32_t absoffset = stroffset + fdt_off_dt_strings(fdt); | ||
| 82 | size_t len; | ||
| 83 | int err; | ||
| 84 | const char *s, *n; | ||
| 85 | |||
| 86 | err = fdt_ro_probe_(fdt); | ||
| 87 | if (err != 0) | ||
| 88 | goto fail; | ||
| 89 | |||
| 90 | err = -FDT_ERR_BADOFFSET; | ||
| 91 | if (absoffset >= fdt_totalsize(fdt)) | ||
| 92 | goto fail; | ||
| 93 | len = fdt_totalsize(fdt) - absoffset; | ||
| 94 | |||
| 95 | if (fdt_magic(fdt) == FDT_MAGIC) { | ||
| 96 | if (stroffset < 0) | ||
| 97 | goto fail; | ||
| 98 | if (fdt_version(fdt) >= 17) { | ||
| 99 | if (stroffset >= fdt_size_dt_strings(fdt)) | ||
| 100 | goto fail; | ||
| 101 | if ((fdt_size_dt_strings(fdt) - stroffset) < len) | ||
| 102 | len = fdt_size_dt_strings(fdt) - stroffset; | ||
| 103 | } | ||
| 104 | } else if (fdt_magic(fdt) == FDT_SW_MAGIC) { | ||
| 105 | if ((stroffset >= 0) | ||
| 106 | || (stroffset < -fdt_size_dt_strings(fdt))) | ||
| 107 | goto fail; | ||
| 108 | if ((-stroffset) < len) | ||
| 109 | len = -stroffset; | ||
| 110 | } else { | ||
| 111 | err = -FDT_ERR_INTERNAL; | ||
| 112 | goto fail; | ||
| 113 | } | ||
| 114 | |||
| 115 | s = (const char *)fdt + absoffset; | ||
| 116 | n = memchr(s, '\0', len); | ||
| 117 | if (!n) { | ||
| 118 | /* missing terminating NULL */ | ||
| 119 | err = -FDT_ERR_TRUNCATED; | ||
| 120 | goto fail; | ||
| 121 | } | ||
| 122 | |||
| 123 | if (lenp) | ||
| 124 | *lenp = n - s; | ||
| 125 | return s; | ||
| 126 | |||
| 127 | fail: | ||
| 128 | if (lenp) | ||
| 129 | *lenp = err; | ||
| 130 | return NULL; | ||
| 131 | } | ||
| 132 | |||
| 79 | const char *fdt_string(const void *fdt, int stroffset) | 133 | const char *fdt_string(const void *fdt, int stroffset) |
| 80 | { | 134 | { |
| 81 | return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset; | 135 | return fdt_get_string(fdt, stroffset, NULL); |
| 82 | } | 136 | } |
| 83 | 137 | ||
| 84 | static int fdt_string_eq_(const void *fdt, int stroffset, | 138 | static int fdt_string_eq_(const void *fdt, int stroffset, |
| 85 | const char *s, int len) | 139 | const char *s, int len) |
| 86 | { | 140 | { |
| 87 | const char *p = fdt_string(fdt, stroffset); | 141 | int slen; |
| 142 | const char *p = fdt_get_string(fdt, stroffset, &slen); | ||
| 88 | 143 | ||
| 89 | return (strlen(p) == len) && (memcmp(p, s, len) == 0); | 144 | return p && (slen == len) && (memcmp(p, s, len) == 0); |
| 90 | } | 145 | } |
| 91 | 146 | ||
| 92 | uint32_t fdt_get_max_phandle(const void *fdt) | 147 | uint32_t fdt_get_max_phandle(const void *fdt) |
| @@ -115,21 +170,42 @@ uint32_t fdt_get_max_phandle(const void *fdt) | |||
| 115 | return 0; | 170 | return 0; |
| 116 | } | 171 | } |
| 117 | 172 | ||
| 173 | static const struct fdt_reserve_entry *fdt_mem_rsv(const void *fdt, int n) | ||
| 174 | { | ||
| 175 | int offset = n * sizeof(struct fdt_reserve_entry); | ||
| 176 | int absoffset = fdt_off_mem_rsvmap(fdt) + offset; | ||
| 177 | |||
| 178 | if (absoffset < fdt_off_mem_rsvmap(fdt)) | ||
| 179 | return NULL; | ||
| 180 | if (absoffset > fdt_totalsize(fdt) - sizeof(struct fdt_reserve_entry)) | ||
| 181 | return NULL; | ||
| 182 | return fdt_mem_rsv_(fdt, n); | ||
| 183 | } | ||
| 184 | |||
| 118 | int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size) | 185 | int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size) |
| 119 | { | 186 | { |
| 120 | FDT_CHECK_HEADER(fdt); | 187 | const struct fdt_reserve_entry *re; |
| 121 | *address = fdt64_to_cpu(fdt_mem_rsv_(fdt, n)->address); | 188 | |
| 122 | *size = fdt64_to_cpu(fdt_mem_rsv_(fdt, n)->size); | 189 | FDT_RO_PROBE(fdt); |
| 190 | re = fdt_mem_rsv(fdt, n); | ||
| 191 | if (!re) | ||
| 192 | return -FDT_ERR_BADOFFSET; | ||
| 193 | |||
| 194 | *address = fdt64_ld(&re->address); | ||
| 195 | *size = fdt64_ld(&re->size); | ||
| 123 | return 0; | 196 | return 0; |
| 124 | } | 197 | } |
| 125 | 198 | ||
| 126 | int fdt_num_mem_rsv(const void *fdt) | 199 | int fdt_num_mem_rsv(const void *fdt) |
| 127 | { | 200 | { |
| 128 | int i = 0; | 201 | int i; |
| 202 | const struct fdt_reserve_entry *re; | ||
| 129 | 203 | ||
| 130 | while (fdt64_to_cpu(fdt_mem_rsv_(fdt, i)->size) != 0) | 204 | for (i = 0; (re = fdt_mem_rsv(fdt, i)) != NULL; i++) { |
| 131 | i++; | 205 | if (fdt64_ld(&re->size) == 0) |
| 132 | return i; | 206 | return i; |
| 207 | } | ||
| 208 | return -FDT_ERR_TRUNCATED; | ||
| 133 | } | 209 | } |
| 134 | 210 | ||
| 135 | static int nextprop_(const void *fdt, int offset) | 211 | static int nextprop_(const void *fdt, int offset) |
| @@ -161,7 +237,7 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset, | |||
| 161 | { | 237 | { |
| 162 | int depth; | 238 | int depth; |
| 163 | 239 | ||
| 164 | FDT_CHECK_HEADER(fdt); | 240 | FDT_RO_PROBE(fdt); |
| 165 | 241 | ||
| 166 | for (depth = 0; | 242 | for (depth = 0; |
| 167 | (offset >= 0) && (depth >= 0); | 243 | (offset >= 0) && (depth >= 0); |
| @@ -187,7 +263,7 @@ int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen) | |||
| 187 | const char *p = path; | 263 | const char *p = path; |
| 188 | int offset = 0; | 264 | int offset = 0; |
| 189 | 265 | ||
| 190 | FDT_CHECK_HEADER(fdt); | 266 | FDT_RO_PROBE(fdt); |
| 191 | 267 | ||
| 192 | /* see if we have an alias */ | 268 | /* see if we have an alias */ |
| 193 | if (*path != '/') { | 269 | if (*path != '/') { |
| @@ -237,7 +313,7 @@ const char *fdt_get_name(const void *fdt, int nodeoffset, int *len) | |||
| 237 | const char *nameptr; | 313 | const char *nameptr; |
| 238 | int err; | 314 | int err; |
| 239 | 315 | ||
| 240 | if (((err = fdt_check_header(fdt)) != 0) | 316 | if (((err = fdt_ro_probe_(fdt)) != 0) |
| 241 | || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0)) | 317 | || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0)) |
| 242 | goto fail; | 318 | goto fail; |
| 243 | 319 | ||
| @@ -303,7 +379,7 @@ static const struct fdt_property *fdt_get_property_by_offset_(const void *fdt, | |||
| 303 | prop = fdt_offset_ptr_(fdt, offset); | 379 | prop = fdt_offset_ptr_(fdt, offset); |
| 304 | 380 | ||
| 305 | if (lenp) | 381 | if (lenp) |
| 306 | *lenp = fdt32_to_cpu(prop->len); | 382 | *lenp = fdt32_ld(&prop->len); |
| 307 | 383 | ||
| 308 | return prop; | 384 | return prop; |
| 309 | } | 385 | } |
| @@ -340,7 +416,7 @@ static const struct fdt_property *fdt_get_property_namelen_(const void *fdt, | |||
| 340 | offset = -FDT_ERR_INTERNAL; | 416 | offset = -FDT_ERR_INTERNAL; |
| 341 | break; | 417 | break; |
| 342 | } | 418 | } |
| 343 | if (fdt_string_eq_(fdt, fdt32_to_cpu(prop->nameoff), | 419 | if (fdt_string_eq_(fdt, fdt32_ld(&prop->nameoff), |
| 344 | name, namelen)) { | 420 | name, namelen)) { |
| 345 | if (poffset) | 421 | if (poffset) |
| 346 | *poffset = offset; | 422 | *poffset = offset; |
| @@ -393,7 +469,7 @@ const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, | |||
| 393 | 469 | ||
| 394 | /* Handle realignment */ | 470 | /* Handle realignment */ |
| 395 | if (fdt_version(fdt) < 0x10 && (poffset + sizeof(*prop)) % 8 && | 471 | if (fdt_version(fdt) < 0x10 && (poffset + sizeof(*prop)) % 8 && |
| 396 | fdt32_to_cpu(prop->len) >= 8) | 472 | fdt32_ld(&prop->len) >= 8) |
| 397 | return prop->data + 4; | 473 | return prop->data + 4; |
| 398 | return prop->data; | 474 | return prop->data; |
| 399 | } | 475 | } |
| @@ -406,12 +482,22 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset, | |||
| 406 | prop = fdt_get_property_by_offset_(fdt, offset, lenp); | 482 | prop = fdt_get_property_by_offset_(fdt, offset, lenp); |
| 407 | if (!prop) | 483 | if (!prop) |
| 408 | return NULL; | 484 | return NULL; |
| 409 | if (namep) | 485 | if (namep) { |
| 410 | *namep = fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); | 486 | const char *name; |
| 487 | int namelen; | ||
| 488 | name = fdt_get_string(fdt, fdt32_ld(&prop->nameoff), | ||
| 489 | &namelen); | ||
| 490 | if (!name) { | ||
| 491 | if (lenp) | ||
| 492 | *lenp = namelen; | ||
| 493 | return NULL; | ||
| 494 | } | ||
| 495 | *namep = name; | ||
| 496 | } | ||
| 411 | 497 | ||
| 412 | /* Handle realignment */ | 498 | /* Handle realignment */ |
| 413 | if (fdt_version(fdt) < 0x10 && (offset + sizeof(*prop)) % 8 && | 499 | if (fdt_version(fdt) < 0x10 && (offset + sizeof(*prop)) % 8 && |
| 414 | fdt32_to_cpu(prop->len) >= 8) | 500 | fdt32_ld(&prop->len) >= 8) |
| 415 | return prop->data + 4; | 501 | return prop->data + 4; |
| 416 | return prop->data; | 502 | return prop->data; |
| 417 | } | 503 | } |
| @@ -436,7 +522,7 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset) | |||
| 436 | return 0; | 522 | return 0; |
| 437 | } | 523 | } |
| 438 | 524 | ||
| 439 | return fdt32_to_cpu(*php); | 525 | return fdt32_ld(php); |
| 440 | } | 526 | } |
| 441 | 527 | ||
| 442 | const char *fdt_get_alias_namelen(const void *fdt, | 528 | const char *fdt_get_alias_namelen(const void *fdt, |
| @@ -462,7 +548,7 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) | |||
| 462 | int offset, depth, namelen; | 548 | int offset, depth, namelen; |
| 463 | const char *name; | 549 | const char *name; |
| 464 | 550 | ||
| 465 | FDT_CHECK_HEADER(fdt); | 551 | FDT_RO_PROBE(fdt); |
| 466 | 552 | ||
| 467 | if (buflen < 2) | 553 | if (buflen < 2) |
| 468 | return -FDT_ERR_NOSPACE; | 554 | return -FDT_ERR_NOSPACE; |
| @@ -514,7 +600,7 @@ int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset, | |||
| 514 | int offset, depth; | 600 | int offset, depth; |
| 515 | int supernodeoffset = -FDT_ERR_INTERNAL; | 601 | int supernodeoffset = -FDT_ERR_INTERNAL; |
| 516 | 602 | ||
| 517 | FDT_CHECK_HEADER(fdt); | 603 | FDT_RO_PROBE(fdt); |
| 518 | 604 | ||
| 519 | if (supernodedepth < 0) | 605 | if (supernodedepth < 0) |
| 520 | return -FDT_ERR_NOTFOUND; | 606 | return -FDT_ERR_NOTFOUND; |
| @@ -573,7 +659,7 @@ int fdt_node_offset_by_prop_value(const void *fdt, int startoffset, | |||
| 573 | const void *val; | 659 | const void *val; |
| 574 | int len; | 660 | int len; |
| 575 | 661 | ||
| 576 | FDT_CHECK_HEADER(fdt); | 662 | FDT_RO_PROBE(fdt); |
| 577 | 663 | ||
| 578 | /* FIXME: The algorithm here is pretty horrible: we scan each | 664 | /* FIXME: The algorithm here is pretty horrible: we scan each |
| 579 | * property of a node in fdt_getprop(), then if that didn't | 665 | * property of a node in fdt_getprop(), then if that didn't |
| @@ -599,7 +685,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle) | |||
| 599 | if ((phandle == 0) || (phandle == -1)) | 685 | if ((phandle == 0) || (phandle == -1)) |
| 600 | return -FDT_ERR_BADPHANDLE; | 686 | return -FDT_ERR_BADPHANDLE; |
| 601 | 687 | ||
| 602 | FDT_CHECK_HEADER(fdt); | 688 | FDT_RO_PROBE(fdt); |
| 603 | 689 | ||
| 604 | /* FIXME: The algorithm here is pretty horrible: we | 690 | /* FIXME: The algorithm here is pretty horrible: we |
| 605 | * potentially scan each property of a node in | 691 | * potentially scan each property of a node in |
| @@ -752,7 +838,7 @@ int fdt_node_offset_by_compatible(const void *fdt, int startoffset, | |||
| 752 | { | 838 | { |
| 753 | int offset, err; | 839 | int offset, err; |
| 754 | 840 | ||
| 755 | FDT_CHECK_HEADER(fdt); | 841 | FDT_RO_PROBE(fdt); |
| 756 | 842 | ||
| 757 | /* FIXME: The algorithm here is pretty horrible: we scan each | 843 | /* FIXME: The algorithm here is pretty horrible: we scan each |
| 758 | * property of a node in fdt_node_check_compatible(), then if | 844 | * property of a node in fdt_node_check_compatible(), then if |
| @@ -771,3 +857,66 @@ int fdt_node_offset_by_compatible(const void *fdt, int startoffset, | |||
| 771 | 857 | ||
| 772 | return offset; /* error from fdt_next_node() */ | 858 | return offset; /* error from fdt_next_node() */ |
| 773 | } | 859 | } |
| 860 | |||
| 861 | int fdt_check_full(const void *fdt, size_t bufsize) | ||
| 862 | { | ||
| 863 | int err; | ||
| 864 | int num_memrsv; | ||
| 865 | int offset, nextoffset = 0; | ||
| 866 | uint32_t tag; | ||
| 867 | unsigned depth = 0; | ||
| 868 | const void *prop; | ||
| 869 | const char *propname; | ||
| 870 | |||
| 871 | if (bufsize < FDT_V1_SIZE) | ||
| 872 | return -FDT_ERR_TRUNCATED; | ||
| 873 | err = fdt_check_header(fdt); | ||
| 874 | if (err != 0) | ||
| 875 | return err; | ||
| 876 | if (bufsize < fdt_totalsize(fdt)) | ||
| 877 | return -FDT_ERR_TRUNCATED; | ||
| 878 | |||
| 879 | num_memrsv = fdt_num_mem_rsv(fdt); | ||
| 880 | if (num_memrsv < 0) | ||
| 881 | return num_memrsv; | ||
| 882 | |||
| 883 | while (1) { | ||
| 884 | offset = nextoffset; | ||
| 885 | tag = fdt_next_tag(fdt, offset, &nextoffset); | ||
| 886 | |||
| 887 | if (nextoffset < 0) | ||
| 888 | return nextoffset; | ||
| 889 | |||
| 890 | switch (tag) { | ||
| 891 | case FDT_NOP: | ||
| 892 | break; | ||
| 893 | |||
| 894 | case FDT_END: | ||
| 895 | if (depth != 0) | ||
| 896 | return -FDT_ERR_BADSTRUCTURE; | ||
| 897 | return 0; | ||
| 898 | |||
| 899 | case FDT_BEGIN_NODE: | ||
| 900 | depth++; | ||
| 901 | if (depth > INT_MAX) | ||
| 902 | return -FDT_ERR_BADSTRUCTURE; | ||
| 903 | break; | ||
| 904 | |||
| 905 | case FDT_END_NODE: | ||
| 906 | if (depth == 0) | ||
| 907 | return -FDT_ERR_BADSTRUCTURE; | ||
| 908 | depth--; | ||
| 909 | break; | ||
| 910 | |||
| 911 | case FDT_PROP: | ||
| 912 | prop = fdt_getprop_by_offset(fdt, offset, &propname, | ||
| 913 | &err); | ||
| 914 | if (!prop) | ||
| 915 | return err; | ||
| 916 | break; | ||
| 917 | |||
| 918 | default: | ||
| 919 | return -FDT_ERR_INTERNAL; | ||
| 920 | } | ||
| 921 | } | ||
| 922 | } | ||
diff --git a/scripts/dtc/libfdt/fdt_rw.c b/scripts/dtc/libfdt/fdt_rw.c index 9b829051e444..2e49855d7cf8 100644 --- a/scripts/dtc/libfdt/fdt_rw.c +++ b/scripts/dtc/libfdt/fdt_rw.c | |||
| @@ -67,9 +67,9 @@ static int fdt_blocks_misordered_(const void *fdt, | |||
| 67 | (fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt))); | 67 | (fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt))); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | static int fdt_rw_check_header_(void *fdt) | 70 | static int fdt_rw_probe_(void *fdt) |
| 71 | { | 71 | { |
| 72 | FDT_CHECK_HEADER(fdt); | 72 | FDT_RO_PROBE(fdt); |
| 73 | 73 | ||
| 74 | if (fdt_version(fdt) < 17) | 74 | if (fdt_version(fdt) < 17) |
| 75 | return -FDT_ERR_BADVERSION; | 75 | return -FDT_ERR_BADVERSION; |
| @@ -82,10 +82,10 @@ static int fdt_rw_check_header_(void *fdt) | |||
| 82 | return 0; | 82 | return 0; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | #define FDT_RW_CHECK_HEADER(fdt) \ | 85 | #define FDT_RW_PROBE(fdt) \ |
| 86 | { \ | 86 | { \ |
| 87 | int err_; \ | 87 | int err_; \ |
| 88 | if ((err_ = fdt_rw_check_header_(fdt)) != 0) \ | 88 | if ((err_ = fdt_rw_probe_(fdt)) != 0) \ |
| 89 | return err_; \ | 89 | return err_; \ |
| 90 | } | 90 | } |
| 91 | 91 | ||
| @@ -176,7 +176,7 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size) | |||
| 176 | struct fdt_reserve_entry *re; | 176 | struct fdt_reserve_entry *re; |
| 177 | int err; | 177 | int err; |
| 178 | 178 | ||
| 179 | FDT_RW_CHECK_HEADER(fdt); | 179 | FDT_RW_PROBE(fdt); |
| 180 | 180 | ||
| 181 | re = fdt_mem_rsv_w_(fdt, fdt_num_mem_rsv(fdt)); | 181 | re = fdt_mem_rsv_w_(fdt, fdt_num_mem_rsv(fdt)); |
| 182 | err = fdt_splice_mem_rsv_(fdt, re, 0, 1); | 182 | err = fdt_splice_mem_rsv_(fdt, re, 0, 1); |
| @@ -192,7 +192,7 @@ int fdt_del_mem_rsv(void *fdt, int n) | |||
| 192 | { | 192 | { |
| 193 | struct fdt_reserve_entry *re = fdt_mem_rsv_w_(fdt, n); | 193 | struct fdt_reserve_entry *re = fdt_mem_rsv_w_(fdt, n); |
| 194 | 194 | ||
| 195 | FDT_RW_CHECK_HEADER(fdt); | 195 | FDT_RW_PROBE(fdt); |
| 196 | 196 | ||
| 197 | if (n >= fdt_num_mem_rsv(fdt)) | 197 | if (n >= fdt_num_mem_rsv(fdt)) |
| 198 | return -FDT_ERR_NOTFOUND; | 198 | return -FDT_ERR_NOTFOUND; |
| @@ -252,7 +252,7 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name) | |||
| 252 | int oldlen, newlen; | 252 | int oldlen, newlen; |
| 253 | int err; | 253 | int err; |
| 254 | 254 | ||
| 255 | FDT_RW_CHECK_HEADER(fdt); | 255 | FDT_RW_PROBE(fdt); |
| 256 | 256 | ||
| 257 | namep = (char *)(uintptr_t)fdt_get_name(fdt, nodeoffset, &oldlen); | 257 | namep = (char *)(uintptr_t)fdt_get_name(fdt, nodeoffset, &oldlen); |
| 258 | if (!namep) | 258 | if (!namep) |
| @@ -275,7 +275,7 @@ int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name, | |||
| 275 | struct fdt_property *prop; | 275 | struct fdt_property *prop; |
| 276 | int err; | 276 | int err; |
| 277 | 277 | ||
| 278 | FDT_RW_CHECK_HEADER(fdt); | 278 | FDT_RW_PROBE(fdt); |
| 279 | 279 | ||
| 280 | err = fdt_resize_property_(fdt, nodeoffset, name, len, &prop); | 280 | err = fdt_resize_property_(fdt, nodeoffset, name, len, &prop); |
| 281 | if (err == -FDT_ERR_NOTFOUND) | 281 | if (err == -FDT_ERR_NOTFOUND) |
| @@ -308,7 +308,7 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name, | |||
| 308 | struct fdt_property *prop; | 308 | struct fdt_property *prop; |
| 309 | int err, oldlen, newlen; | 309 | int err, oldlen, newlen; |
| 310 | 310 | ||
| 311 | FDT_RW_CHECK_HEADER(fdt); | 311 | FDT_RW_PROBE(fdt); |
| 312 | 312 | ||
| 313 | prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen); | 313 | prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen); |
| 314 | if (prop) { | 314 | if (prop) { |
| @@ -334,7 +334,7 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name) | |||
| 334 | struct fdt_property *prop; | 334 | struct fdt_property *prop; |
| 335 | int len, proplen; | 335 | int len, proplen; |
| 336 | 336 | ||
| 337 | FDT_RW_CHECK_HEADER(fdt); | 337 | FDT_RW_PROBE(fdt); |
| 338 | 338 | ||
| 339 | prop = fdt_get_property_w(fdt, nodeoffset, name, &len); | 339 | prop = fdt_get_property_w(fdt, nodeoffset, name, &len); |
| 340 | if (!prop) | 340 | if (!prop) |
| @@ -354,7 +354,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset, | |||
| 354 | uint32_t tag; | 354 | uint32_t tag; |
| 355 | fdt32_t *endtag; | 355 | fdt32_t *endtag; |
| 356 | 356 | ||
| 357 | FDT_RW_CHECK_HEADER(fdt); | 357 | FDT_RW_PROBE(fdt); |
| 358 | 358 | ||
| 359 | offset = fdt_subnode_offset_namelen(fdt, parentoffset, name, namelen); | 359 | offset = fdt_subnode_offset_namelen(fdt, parentoffset, name, namelen); |
| 360 | if (offset >= 0) | 360 | if (offset >= 0) |
| @@ -394,7 +394,7 @@ int fdt_del_node(void *fdt, int nodeoffset) | |||
| 394 | { | 394 | { |
| 395 | int endoffset; | 395 | int endoffset; |
| 396 | 396 | ||
| 397 | FDT_RW_CHECK_HEADER(fdt); | 397 | FDT_RW_PROBE(fdt); |
| 398 | 398 | ||
| 399 | endoffset = fdt_node_end_offset_(fdt, nodeoffset); | 399 | endoffset = fdt_node_end_offset_(fdt, nodeoffset); |
| 400 | if (endoffset < 0) | 400 | if (endoffset < 0) |
| @@ -435,7 +435,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) | |||
| 435 | const char *fdtend = fdtstart + fdt_totalsize(fdt); | 435 | const char *fdtend = fdtstart + fdt_totalsize(fdt); |
| 436 | char *tmp; | 436 | char *tmp; |
| 437 | 437 | ||
| 438 | FDT_CHECK_HEADER(fdt); | 438 | FDT_RO_PROBE(fdt); |
| 439 | 439 | ||
| 440 | mem_rsv_size = (fdt_num_mem_rsv(fdt)+1) | 440 | mem_rsv_size = (fdt_num_mem_rsv(fdt)+1) |
| 441 | * sizeof(struct fdt_reserve_entry); | 441 | * sizeof(struct fdt_reserve_entry); |
| @@ -494,7 +494,7 @@ int fdt_pack(void *fdt) | |||
| 494 | { | 494 | { |
| 495 | int mem_rsv_size; | 495 | int mem_rsv_size; |
| 496 | 496 | ||
| 497 | FDT_RW_CHECK_HEADER(fdt); | 497 | FDT_RW_PROBE(fdt); |
| 498 | 498 | ||
| 499 | mem_rsv_size = (fdt_num_mem_rsv(fdt)+1) | 499 | mem_rsv_size = (fdt_num_mem_rsv(fdt)+1) |
| 500 | * sizeof(struct fdt_reserve_entry); | 500 | * sizeof(struct fdt_reserve_entry); |
diff --git a/scripts/dtc/libfdt/fdt_sw.c b/scripts/dtc/libfdt/fdt_sw.c index 6d33cc29d022..9fa4a94d83c3 100644 --- a/scripts/dtc/libfdt/fdt_sw.c +++ b/scripts/dtc/libfdt/fdt_sw.c | |||
| @@ -55,21 +55,77 @@ | |||
| 55 | 55 | ||
| 56 | #include "libfdt_internal.h" | 56 | #include "libfdt_internal.h" |
| 57 | 57 | ||
| 58 | static int fdt_sw_check_header_(void *fdt) | 58 | static int fdt_sw_probe_(void *fdt) |
| 59 | { | 59 | { |
| 60 | if (fdt_magic(fdt) != FDT_SW_MAGIC) | 60 | if (fdt_magic(fdt) == FDT_MAGIC) |
| 61 | return -FDT_ERR_BADSTATE; | ||
| 62 | else if (fdt_magic(fdt) != FDT_SW_MAGIC) | ||
| 61 | return -FDT_ERR_BADMAGIC; | 63 | return -FDT_ERR_BADMAGIC; |
| 62 | /* FIXME: should check more details about the header state */ | ||
| 63 | return 0; | 64 | return 0; |
| 64 | } | 65 | } |
| 65 | 66 | ||
| 66 | #define FDT_SW_CHECK_HEADER(fdt) \ | 67 | #define FDT_SW_PROBE(fdt) \ |
| 68 | { \ | ||
| 69 | int err; \ | ||
| 70 | if ((err = fdt_sw_probe_(fdt)) != 0) \ | ||
| 71 | return err; \ | ||
| 72 | } | ||
| 73 | |||
| 74 | /* 'memrsv' state: Initial state after fdt_create() | ||
| 75 | * | ||
| 76 | * Allowed functions: | ||
| 77 | * fdt_add_reservmap_entry() | ||
| 78 | * fdt_finish_reservemap() [moves to 'struct' state] | ||
| 79 | */ | ||
| 80 | static int fdt_sw_probe_memrsv_(void *fdt) | ||
| 81 | { | ||
| 82 | int err = fdt_sw_probe_(fdt); | ||
| 83 | if (err) | ||
| 84 | return err; | ||
| 85 | |||
| 86 | if (fdt_off_dt_strings(fdt) != 0) | ||
| 87 | return -FDT_ERR_BADSTATE; | ||
| 88 | return 0; | ||
| 89 | } | ||
| 90 | |||
| 91 | #define FDT_SW_PROBE_MEMRSV(fdt) \ | ||
| 92 | { \ | ||
| 93 | int err; \ | ||
| 94 | if ((err = fdt_sw_probe_memrsv_(fdt)) != 0) \ | ||
| 95 | return err; \ | ||
| 96 | } | ||
| 97 | |||
| 98 | /* 'struct' state: Enter this state after fdt_finish_reservemap() | ||
| 99 | * | ||
| 100 | * Allowed functions: | ||
| 101 | * fdt_begin_node() | ||
| 102 | * fdt_end_node() | ||
| 103 | * fdt_property*() | ||
| 104 | * fdt_finish() [moves to 'complete' state] | ||
| 105 | */ | ||
| 106 | static int fdt_sw_probe_struct_(void *fdt) | ||
| 107 | { | ||
| 108 | int err = fdt_sw_probe_(fdt); | ||
| 109 | if (err) | ||
| 110 | return err; | ||
| 111 | |||
| 112 | if (fdt_off_dt_strings(fdt) != fdt_totalsize(fdt)) | ||
| 113 | return -FDT_ERR_BADSTATE; | ||
| 114 | return 0; | ||
| 115 | } | ||
| 116 | |||
| 117 | #define FDT_SW_PROBE_STRUCT(fdt) \ | ||
| 67 | { \ | 118 | { \ |
| 68 | int err; \ | 119 | int err; \ |
| 69 | if ((err = fdt_sw_check_header_(fdt)) != 0) \ | 120 | if ((err = fdt_sw_probe_struct_(fdt)) != 0) \ |
| 70 | return err; \ | 121 | return err; \ |
| 71 | } | 122 | } |
| 72 | 123 | ||
| 124 | /* 'complete' state: Enter this state after fdt_finish() | ||
| 125 | * | ||
| 126 | * Allowed functions: none | ||
| 127 | */ | ||
| 128 | |||
| 73 | static void *fdt_grab_space_(void *fdt, size_t len) | 129 | static void *fdt_grab_space_(void *fdt, size_t len) |
| 74 | { | 130 | { |
| 75 | int offset = fdt_size_dt_struct(fdt); | 131 | int offset = fdt_size_dt_struct(fdt); |
| @@ -87,9 +143,11 @@ static void *fdt_grab_space_(void *fdt, size_t len) | |||
| 87 | 143 | ||
| 88 | int fdt_create(void *buf, int bufsize) | 144 | int fdt_create(void *buf, int bufsize) |
| 89 | { | 145 | { |
| 146 | const size_t hdrsize = FDT_ALIGN(sizeof(struct fdt_header), | ||
| 147 | sizeof(struct fdt_reserve_entry)); | ||
| 90 | void *fdt = buf; | 148 | void *fdt = buf; |
| 91 | 149 | ||
| 92 | if (bufsize < sizeof(struct fdt_header)) | 150 | if (bufsize < hdrsize) |
| 93 | return -FDT_ERR_NOSPACE; | 151 | return -FDT_ERR_NOSPACE; |
| 94 | 152 | ||
| 95 | memset(buf, 0, bufsize); | 153 | memset(buf, 0, bufsize); |
| @@ -99,10 +157,9 @@ int fdt_create(void *buf, int bufsize) | |||
| 99 | fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION); | 157 | fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION); |
| 100 | fdt_set_totalsize(fdt, bufsize); | 158 | fdt_set_totalsize(fdt, bufsize); |
| 101 | 159 | ||
| 102 | fdt_set_off_mem_rsvmap(fdt, FDT_ALIGN(sizeof(struct fdt_header), | 160 | fdt_set_off_mem_rsvmap(fdt, hdrsize); |
| 103 | sizeof(struct fdt_reserve_entry))); | ||
| 104 | fdt_set_off_dt_struct(fdt, fdt_off_mem_rsvmap(fdt)); | 161 | fdt_set_off_dt_struct(fdt, fdt_off_mem_rsvmap(fdt)); |
| 105 | fdt_set_off_dt_strings(fdt, bufsize); | 162 | fdt_set_off_dt_strings(fdt, 0); |
| 106 | 163 | ||
| 107 | return 0; | 164 | return 0; |
| 108 | } | 165 | } |
| @@ -112,11 +169,14 @@ int fdt_resize(void *fdt, void *buf, int bufsize) | |||
| 112 | size_t headsize, tailsize; | 169 | size_t headsize, tailsize; |
| 113 | char *oldtail, *newtail; | 170 | char *oldtail, *newtail; |
| 114 | 171 | ||
| 115 | FDT_SW_CHECK_HEADER(fdt); | 172 | FDT_SW_PROBE(fdt); |
| 116 | 173 | ||
| 117 | headsize = fdt_off_dt_struct(fdt); | 174 | headsize = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt); |
| 118 | tailsize = fdt_size_dt_strings(fdt); | 175 | tailsize = fdt_size_dt_strings(fdt); |
| 119 | 176 | ||
| 177 | if ((headsize + tailsize) > fdt_totalsize(fdt)) | ||
| 178 | return -FDT_ERR_INTERNAL; | ||
| 179 | |||
| 120 | if ((headsize + tailsize) > bufsize) | 180 | if ((headsize + tailsize) > bufsize) |
| 121 | return -FDT_ERR_NOSPACE; | 181 | return -FDT_ERR_NOSPACE; |
| 122 | 182 | ||
| @@ -133,8 +193,9 @@ int fdt_resize(void *fdt, void *buf, int bufsize) | |||
| 133 | memmove(buf, fdt, headsize); | 193 | memmove(buf, fdt, headsize); |
| 134 | } | 194 | } |
| 135 | 195 | ||
| 136 | fdt_set_off_dt_strings(buf, bufsize); | ||
| 137 | fdt_set_totalsize(buf, bufsize); | 196 | fdt_set_totalsize(buf, bufsize); |
| 197 | if (fdt_off_dt_strings(buf)) | ||
| 198 | fdt_set_off_dt_strings(buf, bufsize); | ||
| 138 | 199 | ||
| 139 | return 0; | 200 | return 0; |
| 140 | } | 201 | } |
| @@ -144,10 +205,7 @@ int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size) | |||
| 144 | struct fdt_reserve_entry *re; | 205 | struct fdt_reserve_entry *re; |
| 145 | int offset; | 206 | int offset; |
| 146 | 207 | ||
| 147 | FDT_SW_CHECK_HEADER(fdt); | 208 | FDT_SW_PROBE_MEMRSV(fdt); |
| 148 | |||
| 149 | if (fdt_size_dt_struct(fdt)) | ||
| 150 | return -FDT_ERR_BADSTATE; | ||
| 151 | 209 | ||
| 152 | offset = fdt_off_dt_struct(fdt); | 210 | offset = fdt_off_dt_struct(fdt); |
| 153 | if ((offset + sizeof(*re)) > fdt_totalsize(fdt)) | 211 | if ((offset + sizeof(*re)) > fdt_totalsize(fdt)) |
| @@ -164,16 +222,23 @@ int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size) | |||
| 164 | 222 | ||
| 165 | int fdt_finish_reservemap(void *fdt) | 223 | int fdt_finish_reservemap(void *fdt) |
| 166 | { | 224 | { |
| 167 | return fdt_add_reservemap_entry(fdt, 0, 0); | 225 | int err = fdt_add_reservemap_entry(fdt, 0, 0); |
| 226 | |||
| 227 | if (err) | ||
| 228 | return err; | ||
| 229 | |||
| 230 | fdt_set_off_dt_strings(fdt, fdt_totalsize(fdt)); | ||
| 231 | return 0; | ||
| 168 | } | 232 | } |
| 169 | 233 | ||
| 170 | int fdt_begin_node(void *fdt, const char *name) | 234 | int fdt_begin_node(void *fdt, const char *name) |
| 171 | { | 235 | { |
| 172 | struct fdt_node_header *nh; | 236 | struct fdt_node_header *nh; |
| 173 | int namelen = strlen(name) + 1; | 237 | int namelen; |
| 174 | 238 | ||
| 175 | FDT_SW_CHECK_HEADER(fdt); | 239 | FDT_SW_PROBE_STRUCT(fdt); |
| 176 | 240 | ||
| 241 | namelen = strlen(name) + 1; | ||
| 177 | nh = fdt_grab_space_(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen)); | 242 | nh = fdt_grab_space_(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen)); |
| 178 | if (! nh) | 243 | if (! nh) |
| 179 | return -FDT_ERR_NOSPACE; | 244 | return -FDT_ERR_NOSPACE; |
| @@ -187,7 +252,7 @@ int fdt_end_node(void *fdt) | |||
| 187 | { | 252 | { |
| 188 | fdt32_t *en; | 253 | fdt32_t *en; |
| 189 | 254 | ||
| 190 | FDT_SW_CHECK_HEADER(fdt); | 255 | FDT_SW_PROBE_STRUCT(fdt); |
| 191 | 256 | ||
| 192 | en = fdt_grab_space_(fdt, FDT_TAGSIZE); | 257 | en = fdt_grab_space_(fdt, FDT_TAGSIZE); |
| 193 | if (! en) | 258 | if (! en) |
| @@ -225,7 +290,7 @@ int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp) | |||
| 225 | struct fdt_property *prop; | 290 | struct fdt_property *prop; |
| 226 | int nameoff; | 291 | int nameoff; |
| 227 | 292 | ||
| 228 | FDT_SW_CHECK_HEADER(fdt); | 293 | FDT_SW_PROBE_STRUCT(fdt); |
| 229 | 294 | ||
| 230 | nameoff = fdt_find_add_string_(fdt, name); | 295 | nameoff = fdt_find_add_string_(fdt, name); |
| 231 | if (nameoff == 0) | 296 | if (nameoff == 0) |
| @@ -262,7 +327,7 @@ int fdt_finish(void *fdt) | |||
| 262 | uint32_t tag; | 327 | uint32_t tag; |
| 263 | int offset, nextoffset; | 328 | int offset, nextoffset; |
| 264 | 329 | ||
| 265 | FDT_SW_CHECK_HEADER(fdt); | 330 | FDT_SW_PROBE_STRUCT(fdt); |
| 266 | 331 | ||
| 267 | /* Add terminator */ | 332 | /* Add terminator */ |
| 268 | end = fdt_grab_space_(fdt, sizeof(*end)); | 333 | end = fdt_grab_space_(fdt, sizeof(*end)); |
diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h index 1e27780e1185..2bd151dd355f 100644 --- a/scripts/dtc/libfdt/libfdt.h +++ b/scripts/dtc/libfdt/libfdt.h | |||
| @@ -90,8 +90,9 @@ | |||
| 90 | 90 | ||
| 91 | /* Error codes: codes for bad device tree blobs */ | 91 | /* Error codes: codes for bad device tree blobs */ |
| 92 | #define FDT_ERR_TRUNCATED 8 | 92 | #define FDT_ERR_TRUNCATED 8 |
| 93 | /* FDT_ERR_TRUNCATED: Structure block of the given device tree | 93 | /* FDT_ERR_TRUNCATED: FDT or a sub-block is improperly |
| 94 | * ends without an FDT_END tag. */ | 94 | * terminated (overflows, goes outside allowed bounds, or |
| 95 | * isn't properly terminated). */ | ||
| 95 | #define FDT_ERR_BADMAGIC 9 | 96 | #define FDT_ERR_BADMAGIC 9 |
| 96 | /* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a | 97 | /* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a |
| 97 | * device tree at all - it is missing the flattened device | 98 | * device tree at all - it is missing the flattened device |
| @@ -153,6 +154,29 @@ static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) | |||
| 153 | 154 | ||
| 154 | uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset); | 155 | uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset); |
| 155 | 156 | ||
| 157 | /* | ||
| 158 | * Alignment helpers: | ||
| 159 | * These helpers access words from a device tree blob. They're | ||
| 160 | * built to work even with unaligned pointers on platforms (ike | ||
| 161 | * ARM) that don't like unaligned loads and stores | ||
| 162 | */ | ||
| 163 | |||
| 164 | static inline uint32_t fdt32_ld(const fdt32_t *p) | ||
| 165 | { | ||
| 166 | fdt32_t v; | ||
| 167 | |||
| 168 | memcpy(&v, p, sizeof(v)); | ||
| 169 | return fdt32_to_cpu(v); | ||
| 170 | } | ||
| 171 | |||
| 172 | static inline uint64_t fdt64_ld(const fdt64_t *p) | ||
| 173 | { | ||
| 174 | fdt64_t v; | ||
| 175 | |||
| 176 | memcpy(&v, p, sizeof(v)); | ||
| 177 | return fdt64_to_cpu(v); | ||
| 178 | } | ||
| 179 | |||
| 156 | /**********************************************************************/ | 180 | /**********************************************************************/ |
| 157 | /* Traversal functions */ | 181 | /* Traversal functions */ |
| 158 | /**********************************************************************/ | 182 | /**********************************************************************/ |
| @@ -213,7 +237,7 @@ int fdt_next_subnode(const void *fdt, int offset); | |||
| 213 | /* General functions */ | 237 | /* General functions */ |
| 214 | /**********************************************************************/ | 238 | /**********************************************************************/ |
| 215 | #define fdt_get_header(fdt, field) \ | 239 | #define fdt_get_header(fdt, field) \ |
| 216 | (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field)) | 240 | (fdt32_ld(&((const struct fdt_header *)(fdt))->field)) |
| 217 | #define fdt_magic(fdt) (fdt_get_header(fdt, magic)) | 241 | #define fdt_magic(fdt) (fdt_get_header(fdt, magic)) |
| 218 | #define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize)) | 242 | #define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize)) |
| 219 | #define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct)) | 243 | #define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct)) |
| @@ -244,18 +268,31 @@ fdt_set_hdr_(size_dt_struct); | |||
| 244 | #undef fdt_set_hdr_ | 268 | #undef fdt_set_hdr_ |
| 245 | 269 | ||
| 246 | /** | 270 | /** |
| 247 | * fdt_check_header - sanity check a device tree or possible device tree | 271 | * fdt_header_size - return the size of the tree's header |
| 272 | * @fdt: pointer to a flattened device tree | ||
| 273 | */ | ||
| 274 | size_t fdt_header_size_(uint32_t version); | ||
| 275 | static inline size_t fdt_header_size(const void *fdt) | ||
| 276 | { | ||
| 277 | return fdt_header_size_(fdt_version(fdt)); | ||
| 278 | } | ||
| 279 | |||
| 280 | /** | ||
| 281 | * fdt_check_header - sanity check a device tree header | ||
| 282 | |||
| 248 | * @fdt: pointer to data which might be a flattened device tree | 283 | * @fdt: pointer to data which might be a flattened device tree |
| 249 | * | 284 | * |
| 250 | * fdt_check_header() checks that the given buffer contains what | 285 | * fdt_check_header() checks that the given buffer contains what |
| 251 | * appears to be a flattened device tree with sane information in its | 286 | * appears to be a flattened device tree, and that the header contains |
| 252 | * header. | 287 | * valid information (to the extent that can be determined from the |
| 288 | * header alone). | ||
| 253 | * | 289 | * |
| 254 | * returns: | 290 | * returns: |
| 255 | * 0, if the buffer appears to contain a valid device tree | 291 | * 0, if the buffer appears to contain a valid device tree |
| 256 | * -FDT_ERR_BADMAGIC, | 292 | * -FDT_ERR_BADMAGIC, |
| 257 | * -FDT_ERR_BADVERSION, | 293 | * -FDT_ERR_BADVERSION, |
| 258 | * -FDT_ERR_BADSTATE, standard meanings, as above | 294 | * -FDT_ERR_BADSTATE, |
| 295 | * -FDT_ERR_TRUNCATED, standard meanings, as above | ||
| 259 | */ | 296 | */ |
| 260 | int fdt_check_header(const void *fdt); | 297 | int fdt_check_header(const void *fdt); |
| 261 | 298 | ||
| @@ -284,6 +321,24 @@ int fdt_move(const void *fdt, void *buf, int bufsize); | |||
| 284 | /* Read-only functions */ | 321 | /* Read-only functions */ |
| 285 | /**********************************************************************/ | 322 | /**********************************************************************/ |
| 286 | 323 | ||
| 324 | int fdt_check_full(const void *fdt, size_t bufsize); | ||
| 325 | |||
| 326 | /** | ||
| 327 | * fdt_get_string - retrieve a string from the strings block of a device tree | ||
| 328 | * @fdt: pointer to the device tree blob | ||
| 329 | * @stroffset: offset of the string within the strings block (native endian) | ||
| 330 | * @lenp: optional pointer to return the string's length | ||
| 331 | * | ||
| 332 | * fdt_get_string() retrieves a pointer to a single string from the | ||
| 333 | * strings block of the device tree blob at fdt, and optionally also | ||
| 334 | * returns the string's length in *lenp. | ||
| 335 | * | ||
| 336 | * returns: | ||
| 337 | * a pointer to the string, on success | ||
| 338 | * NULL, if stroffset is out of bounds, or doesn't point to a valid string | ||
| 339 | */ | ||
| 340 | const char *fdt_get_string(const void *fdt, int stroffset, int *lenp); | ||
| 341 | |||
| 287 | /** | 342 | /** |
| 288 | * fdt_string - retrieve a string from the strings block of a device tree | 343 | * fdt_string - retrieve a string from the strings block of a device tree |
| 289 | * @fdt: pointer to the device tree blob | 344 | * @fdt: pointer to the device tree blob |
| @@ -294,7 +349,7 @@ int fdt_move(const void *fdt, void *buf, int bufsize); | |||
| 294 | * | 349 | * |
| 295 | * returns: | 350 | * returns: |
| 296 | * a pointer to the string, on success | 351 | * a pointer to the string, on success |
| 297 | * NULL, if stroffset is out of bounds | 352 | * NULL, if stroffset is out of bounds, or doesn't point to a valid string |
| 298 | */ | 353 | */ |
| 299 | const char *fdt_string(const void *fdt, int stroffset); | 354 | const char *fdt_string(const void *fdt, int stroffset); |
| 300 | 355 | ||
| @@ -1090,7 +1145,7 @@ int fdt_address_cells(const void *fdt, int nodeoffset); | |||
| 1090 | * | 1145 | * |
| 1091 | * returns: | 1146 | * returns: |
| 1092 | * 0 <= n < FDT_MAX_NCELLS, on success | 1147 | * 0 <= n < FDT_MAX_NCELLS, on success |
| 1093 | * 2, if the node has no #address-cells property | 1148 | * 2, if the node has no #size-cells property |
| 1094 | * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid | 1149 | * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid |
| 1095 | * #size-cells property | 1150 | * #size-cells property |
| 1096 | * -FDT_ERR_BADMAGIC, | 1151 | * -FDT_ERR_BADMAGIC, |
| @@ -1313,10 +1368,13 @@ static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val) | |||
| 1313 | fdt64_t tmp = cpu_to_fdt64(val); | 1368 | fdt64_t tmp = cpu_to_fdt64(val); |
| 1314 | return fdt_property(fdt, name, &tmp, sizeof(tmp)); | 1369 | return fdt_property(fdt, name, &tmp, sizeof(tmp)); |
| 1315 | } | 1370 | } |
| 1371 | |||
| 1372 | #ifndef SWIG /* Not available in Python */ | ||
| 1316 | static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) | 1373 | static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) |
| 1317 | { | 1374 | { |
| 1318 | return fdt_property_u32(fdt, name, val); | 1375 | return fdt_property_u32(fdt, name, val); |
| 1319 | } | 1376 | } |
| 1377 | #endif | ||
| 1320 | 1378 | ||
| 1321 | /** | 1379 | /** |
| 1322 | * fdt_property_placeholder - add a new property and return a ptr to its value | 1380 | * fdt_property_placeholder - add a new property and return a ptr to its value |
diff --git a/scripts/dtc/libfdt/libfdt_env.h b/scripts/dtc/libfdt/libfdt_env.h index bd2474628775..eb2053845c9c 100644 --- a/scripts/dtc/libfdt/libfdt_env.h +++ b/scripts/dtc/libfdt/libfdt_env.h | |||
| @@ -56,6 +56,7 @@ | |||
| 56 | #include <stdint.h> | 56 | #include <stdint.h> |
| 57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
| 58 | #include <string.h> | 58 | #include <string.h> |
| 59 | #include <limits.h> | ||
| 59 | 60 | ||
| 60 | #ifdef __CHECKER__ | 61 | #ifdef __CHECKER__ |
| 61 | #define FDT_FORCE __attribute__((force)) | 62 | #define FDT_FORCE __attribute__((force)) |
diff --git a/scripts/dtc/libfdt/libfdt_internal.h b/scripts/dtc/libfdt/libfdt_internal.h index 7681e192295b..4109f890ae60 100644 --- a/scripts/dtc/libfdt/libfdt_internal.h +++ b/scripts/dtc/libfdt/libfdt_internal.h | |||
| @@ -55,10 +55,11 @@ | |||
| 55 | #define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) | 55 | #define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) |
| 56 | #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE)) | 56 | #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE)) |
| 57 | 57 | ||
| 58 | #define FDT_CHECK_HEADER(fdt) \ | 58 | int fdt_ro_probe_(const void *fdt); |
| 59 | #define FDT_RO_PROBE(fdt) \ | ||
| 59 | { \ | 60 | { \ |
| 60 | int err_; \ | 61 | int err_; \ |
| 61 | if ((err_ = fdt_check_header(fdt)) != 0) \ | 62 | if ((err_ = fdt_ro_probe_(fdt)) != 0) \ |
| 62 | return err_; \ | 63 | return err_; \ |
| 63 | } | 64 | } |
| 64 | 65 | ||
diff --git a/scripts/dtc/livetree.c b/scripts/dtc/livetree.c index 6e4c367f54b3..4ff0679e0062 100644 --- a/scripts/dtc/livetree.c +++ b/scripts/dtc/livetree.c | |||
| @@ -594,6 +594,7 @@ struct node *get_node_by_ref(struct node *tree, const char *ref) | |||
| 594 | cell_t get_node_phandle(struct node *root, struct node *node) | 594 | cell_t get_node_phandle(struct node *root, struct node *node) |
| 595 | { | 595 | { |
| 596 | static cell_t phandle = 1; /* FIXME: ick, static local */ | 596 | static cell_t phandle = 1; /* FIXME: ick, static local */ |
| 597 | struct data d = empty_data; | ||
| 597 | 598 | ||
| 598 | if ((node->phandle != 0) && (node->phandle != -1)) | 599 | if ((node->phandle != 0) && (node->phandle != -1)) |
| 599 | return node->phandle; | 600 | return node->phandle; |
| @@ -603,17 +604,16 @@ cell_t get_node_phandle(struct node *root, struct node *node) | |||
| 603 | 604 | ||
| 604 | node->phandle = phandle; | 605 | node->phandle = phandle; |
| 605 | 606 | ||
| 607 | d = data_add_marker(d, TYPE_UINT32, NULL); | ||
| 608 | d = data_append_cell(d, phandle); | ||
| 609 | |||
| 606 | if (!get_property(node, "linux,phandle") | 610 | if (!get_property(node, "linux,phandle") |
| 607 | && (phandle_format & PHANDLE_LEGACY)) | 611 | && (phandle_format & PHANDLE_LEGACY)) |
| 608 | add_property(node, | 612 | add_property(node, build_property("linux,phandle", d)); |
| 609 | build_property("linux,phandle", | ||
| 610 | data_append_cell(empty_data, phandle))); | ||
| 611 | 613 | ||
| 612 | if (!get_property(node, "phandle") | 614 | if (!get_property(node, "phandle") |
| 613 | && (phandle_format & PHANDLE_EPAPR)) | 615 | && (phandle_format & PHANDLE_EPAPR)) |
| 614 | add_property(node, | 616 | add_property(node, build_property("phandle", d)); |
| 615 | build_property("phandle", | ||
| 616 | data_append_cell(empty_data, phandle))); | ||
| 617 | 617 | ||
| 618 | /* If the node *does* have a phandle property, we must | 618 | /* If the node *does* have a phandle property, we must |
| 619 | * be dealing with a self-referencing phandle, which will be | 619 | * be dealing with a self-referencing phandle, which will be |
diff --git a/scripts/dtc/treesource.c b/scripts/dtc/treesource.c index 2461a3d068a0..f2874f1d1465 100644 --- a/scripts/dtc/treesource.c +++ b/scripts/dtc/treesource.c | |||
| @@ -61,24 +61,14 @@ static bool isstring(char c) | |||
| 61 | || strchr("\a\b\t\n\v\f\r", c)); | 61 | || strchr("\a\b\t\n\v\f\r", c)); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | static void write_propval_string(FILE *f, struct data val) | 64 | static void write_propval_string(FILE *f, const char *s, size_t len) |
| 65 | { | 65 | { |
| 66 | const char *str = val.val; | 66 | const char *end = s + len - 1; |
| 67 | int i; | 67 | assert(*end == '\0'); |
| 68 | struct marker *m = val.markers; | ||
| 69 | |||
| 70 | assert(str[val.len-1] == '\0'); | ||
| 71 | 68 | ||
| 72 | while (m && (m->offset == 0)) { | ||
| 73 | if (m->type == LABEL) | ||
| 74 | fprintf(f, "%s: ", m->ref); | ||
| 75 | m = m->next; | ||
| 76 | } | ||
| 77 | fprintf(f, "\""); | 69 | fprintf(f, "\""); |
| 78 | 70 | while (s < end) { | |
| 79 | for (i = 0; i < (val.len-1); i++) { | 71 | char c = *s++; |
| 80 | char c = str[i]; | ||
| 81 | |||
| 82 | switch (c) { | 72 | switch (c) { |
| 83 | case '\a': | 73 | case '\a': |
| 84 | fprintf(f, "\\a"); | 74 | fprintf(f, "\\a"); |
| @@ -108,91 +98,78 @@ static void write_propval_string(FILE *f, struct data val) | |||
| 108 | fprintf(f, "\\\""); | 98 | fprintf(f, "\\\""); |
| 109 | break; | 99 | break; |
| 110 | case '\0': | 100 | case '\0': |
| 111 | fprintf(f, "\", "); | 101 | fprintf(f, "\\0"); |
| 112 | while (m && (m->offset <= (i + 1))) { | ||
| 113 | if (m->type == LABEL) { | ||
| 114 | assert(m->offset == (i+1)); | ||
| 115 | fprintf(f, "%s: ", m->ref); | ||
| 116 | } | ||
| 117 | m = m->next; | ||
| 118 | } | ||
| 119 | fprintf(f, "\""); | ||
| 120 | break; | 102 | break; |
| 121 | default: | 103 | default: |
| 122 | if (isprint((unsigned char)c)) | 104 | if (isprint((unsigned char)c)) |
| 123 | fprintf(f, "%c", c); | 105 | fprintf(f, "%c", c); |
| 124 | else | 106 | else |
| 125 | fprintf(f, "\\x%02hhx", c); | 107 | fprintf(f, "\\x%02"PRIx8, c); |
| 126 | } | 108 | } |
| 127 | } | 109 | } |
| 128 | fprintf(f, "\""); | 110 | fprintf(f, "\""); |
| 129 | |||
| 130 | /* Wrap up any labels at the end of the value */ | ||
| 131 | for_each_marker_of_type(m, LABEL) { | ||
| 132 | assert (m->offset == val.len); | ||
| 133 | fprintf(f, " %s:", m->ref); | ||
| 134 | } | ||
| 135 | } | 111 | } |
| 136 | 112 | ||
| 137 | static void write_propval_cells(FILE *f, struct data val) | 113 | static void write_propval_int(FILE *f, const char *p, size_t len, size_t width) |
| 138 | { | 114 | { |
| 139 | void *propend = val.val + val.len; | 115 | const char *end = p + len; |
| 140 | fdt32_t *cp = (fdt32_t *)val.val; | 116 | assert(len % width == 0); |
| 141 | struct marker *m = val.markers; | ||
| 142 | |||
| 143 | fprintf(f, "<"); | ||
| 144 | for (;;) { | ||
| 145 | while (m && (m->offset <= ((char *)cp - val.val))) { | ||
| 146 | if (m->type == LABEL) { | ||
| 147 | assert(m->offset == ((char *)cp - val.val)); | ||
| 148 | fprintf(f, "%s: ", m->ref); | ||
| 149 | } | ||
| 150 | m = m->next; | ||
| 151 | } | ||
| 152 | 117 | ||
| 153 | fprintf(f, "0x%x", fdt32_to_cpu(*cp++)); | 118 | for (; p < end; p += width) { |
| 154 | if ((void *)cp >= propend) | 119 | switch (width) { |
| 120 | case 1: | ||
| 121 | fprintf(f, " %02"PRIx8, *(const uint8_t*)p); | ||
| 122 | break; | ||
| 123 | case 2: | ||
| 124 | fprintf(f, " 0x%02"PRIx16, fdt16_to_cpu(*(const fdt16_t*)p)); | ||
| 125 | break; | ||
| 126 | case 4: | ||
| 127 | fprintf(f, " 0x%02"PRIx32, fdt32_to_cpu(*(const fdt32_t*)p)); | ||
| 128 | break; | ||
| 129 | case 8: | ||
| 130 | fprintf(f, " 0x%02"PRIx64, fdt64_to_cpu(*(const fdt64_t*)p)); | ||
| 155 | break; | 131 | break; |
| 156 | fprintf(f, " "); | 132 | } |
| 157 | } | 133 | } |
| 134 | } | ||
| 158 | 135 | ||
| 159 | /* Wrap up any labels at the end of the value */ | 136 | static bool has_data_type_information(struct marker *m) |
| 160 | for_each_marker_of_type(m, LABEL) { | 137 | { |
| 161 | assert (m->offset == val.len); | 138 | return m->type >= TYPE_UINT8; |
| 162 | fprintf(f, " %s:", m->ref); | ||
| 163 | } | ||
| 164 | fprintf(f, ">"); | ||
| 165 | } | 139 | } |
| 166 | 140 | ||
| 167 | static void write_propval_bytes(FILE *f, struct data val) | 141 | static struct marker *next_type_marker(struct marker *m) |
| 168 | { | 142 | { |
| 169 | void *propend = val.val + val.len; | 143 | while (m && !has_data_type_information(m)) |
| 170 | const char *bp = val.val; | 144 | m = m->next; |
| 171 | struct marker *m = val.markers; | 145 | return m; |
| 172 | 146 | } | |
| 173 | fprintf(f, "["); | ||
| 174 | for (;;) { | ||
| 175 | while (m && (m->offset == (bp-val.val))) { | ||
| 176 | if (m->type == LABEL) | ||
| 177 | fprintf(f, "%s: ", m->ref); | ||
| 178 | m = m->next; | ||
| 179 | } | ||
| 180 | 147 | ||
| 181 | fprintf(f, "%02hhx", (unsigned char)(*bp++)); | 148 | size_t type_marker_length(struct marker *m) |
| 182 | if ((const void *)bp >= propend) | 149 | { |
| 183 | break; | 150 | struct marker *next = next_type_marker(m->next); |
| 184 | fprintf(f, " "); | ||
| 185 | } | ||
| 186 | 151 | ||
| 187 | /* Wrap up any labels at the end of the value */ | 152 | if (next) |
| 188 | for_each_marker_of_type(m, LABEL) { | 153 | return next->offset - m->offset; |
| 189 | assert (m->offset == val.len); | 154 | return 0; |
| 190 | fprintf(f, " %s:", m->ref); | ||
| 191 | } | ||
| 192 | fprintf(f, "]"); | ||
| 193 | } | 155 | } |
| 194 | 156 | ||
| 195 | static void write_propval(FILE *f, struct property *prop) | 157 | static const char *delim_start[] = { |
| 158 | [TYPE_UINT8] = "[", | ||
| 159 | [TYPE_UINT16] = "/bits/ 16 <", | ||
| 160 | [TYPE_UINT32] = "<", | ||
| 161 | [TYPE_UINT64] = "/bits/ 64 <", | ||
| 162 | [TYPE_STRING] = "", | ||
| 163 | }; | ||
| 164 | static const char *delim_end[] = { | ||
| 165 | [TYPE_UINT8] = " ]", | ||
| 166 | [TYPE_UINT16] = " >", | ||
| 167 | [TYPE_UINT32] = " >", | ||
| 168 | [TYPE_UINT64] = " >", | ||
| 169 | [TYPE_STRING] = "", | ||
| 170 | }; | ||
| 171 | |||
| 172 | static enum markertype guess_value_type(struct property *prop) | ||
| 196 | { | 173 | { |
| 197 | int len = prop->val.len; | 174 | int len = prop->val.len; |
| 198 | const char *p = prop->val.val; | 175 | const char *p = prop->val.val; |
| @@ -201,11 +178,6 @@ static void write_propval(FILE *f, struct property *prop) | |||
| 201 | int nnotstringlbl = 0, nnotcelllbl = 0; | 178 | int nnotstringlbl = 0, nnotcelllbl = 0; |
| 202 | int i; | 179 | int i; |
| 203 | 180 | ||
| 204 | if (len == 0) { | ||
| 205 | fprintf(f, ";\n"); | ||
| 206 | return; | ||
| 207 | } | ||
| 208 | |||
| 209 | for (i = 0; i < len; i++) { | 181 | for (i = 0; i < len; i++) { |
| 210 | if (! isstring(p[i])) | 182 | if (! isstring(p[i])) |
| 211 | nnotstring++; | 183 | nnotstring++; |
| @@ -220,17 +192,91 @@ static void write_propval(FILE *f, struct property *prop) | |||
| 220 | nnotcelllbl++; | 192 | nnotcelllbl++; |
| 221 | } | 193 | } |
| 222 | 194 | ||
| 223 | fprintf(f, " = "); | ||
| 224 | if ((p[len-1] == '\0') && (nnotstring == 0) && (nnul < (len-nnul)) | 195 | if ((p[len-1] == '\0') && (nnotstring == 0) && (nnul < (len-nnul)) |
| 225 | && (nnotstringlbl == 0)) { | 196 | && (nnotstringlbl == 0)) { |
| 226 | write_propval_string(f, prop->val); | 197 | return TYPE_STRING; |
| 227 | } else if (((len % sizeof(cell_t)) == 0) && (nnotcelllbl == 0)) { | 198 | } else if (((len % sizeof(cell_t)) == 0) && (nnotcelllbl == 0)) { |
| 228 | write_propval_cells(f, prop->val); | 199 | return TYPE_UINT32; |
| 229 | } else { | ||
| 230 | write_propval_bytes(f, prop->val); | ||
| 231 | } | 200 | } |
| 232 | 201 | ||
| 233 | fprintf(f, ";\n"); | 202 | return TYPE_UINT8; |
| 203 | } | ||
| 204 | |||
| 205 | static void write_propval(FILE *f, struct property *prop) | ||
| 206 | { | ||
| 207 | size_t len = prop->val.len; | ||
| 208 | struct marker *m = prop->val.markers; | ||
| 209 | struct marker dummy_marker; | ||
| 210 | enum markertype emit_type = TYPE_NONE; | ||
| 211 | |||
| 212 | if (len == 0) { | ||
| 213 | fprintf(f, ";\n"); | ||
| 214 | return; | ||
| 215 | } | ||
| 216 | |||
| 217 | fprintf(f, " = "); | ||
| 218 | |||
| 219 | if (!next_type_marker(m)) { | ||
| 220 | /* data type information missing, need to guess */ | ||
| 221 | dummy_marker.type = guess_value_type(prop); | ||
| 222 | dummy_marker.next = prop->val.markers; | ||
| 223 | dummy_marker.offset = 0; | ||
| 224 | dummy_marker.ref = NULL; | ||
| 225 | m = &dummy_marker; | ||
| 226 | } | ||
| 227 | |||
| 228 | struct marker *m_label = prop->val.markers; | ||
| 229 | for_each_marker(m) { | ||
| 230 | size_t chunk_len; | ||
| 231 | const char *p = &prop->val.val[m->offset]; | ||
| 232 | |||
| 233 | if (!has_data_type_information(m)) | ||
| 234 | continue; | ||
| 235 | |||
| 236 | chunk_len = type_marker_length(m); | ||
| 237 | if (!chunk_len) | ||
| 238 | chunk_len = len - m->offset; | ||
| 239 | |||
| 240 | if (emit_type != TYPE_NONE) | ||
| 241 | fprintf(f, "%s, ", delim_end[emit_type]); | ||
| 242 | emit_type = m->type; | ||
| 243 | |||
| 244 | for_each_marker_of_type(m_label, LABEL) { | ||
| 245 | if (m_label->offset > m->offset) | ||
| 246 | break; | ||
| 247 | fprintf(f, "%s: ", m_label->ref); | ||
| 248 | } | ||
| 249 | |||
| 250 | fprintf(f, "%s", delim_start[emit_type]); | ||
| 251 | |||
| 252 | if (chunk_len <= 0) | ||
| 253 | continue; | ||
| 254 | |||
| 255 | switch(emit_type) { | ||
| 256 | case TYPE_UINT16: | ||
| 257 | write_propval_int(f, p, chunk_len, 2); | ||
| 258 | break; | ||
| 259 | case TYPE_UINT32: | ||
| 260 | write_propval_int(f, p, chunk_len, 4); | ||
| 261 | break; | ||
| 262 | case TYPE_UINT64: | ||
| 263 | write_propval_int(f, p, chunk_len, 8); | ||
| 264 | break; | ||
| 265 | case TYPE_STRING: | ||
| 266 | write_propval_string(f, p, chunk_len); | ||
| 267 | break; | ||
| 268 | default: | ||
| 269 | write_propval_int(f, p, chunk_len, 1); | ||
| 270 | } | ||
| 271 | } | ||
| 272 | |||
| 273 | /* Wrap up any labels at the end of the value */ | ||
| 274 | for_each_marker_of_type(m_label, LABEL) { | ||
| 275 | assert (m_label->offset == len); | ||
| 276 | fprintf(f, " %s:", m_label->ref); | ||
| 277 | } | ||
| 278 | |||
| 279 | fprintf(f, "%s;\n", delim_end[emit_type] ? : ""); | ||
| 234 | } | 280 | } |
| 235 | 281 | ||
| 236 | static void write_tree_source_node(FILE *f, struct node *tree, int level) | 282 | static void write_tree_source_node(FILE *f, struct node *tree, int level) |
| @@ -281,4 +327,3 @@ void dt_to_source(FILE *f, struct dt_info *dti) | |||
| 281 | 327 | ||
| 282 | write_tree_source_node(f, dti->dt, 0); | 328 | write_tree_source_node(f, dti->dt, 0); |
| 283 | } | 329 | } |
| 284 | |||
diff --git a/scripts/dtc/update-dtc-source.sh b/scripts/dtc/update-dtc-source.sh index 1a009fd195d0..7dd29a0362b8 100755 --- a/scripts/dtc/update-dtc-source.sh +++ b/scripts/dtc/update-dtc-source.sh | |||
| @@ -32,7 +32,7 @@ DTC_UPSTREAM_PATH=`pwd`/../dtc | |||
| 32 | DTC_LINUX_PATH=`pwd`/scripts/dtc | 32 | DTC_LINUX_PATH=`pwd`/scripts/dtc |
| 33 | 33 | ||
| 34 | DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \ | 34 | DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \ |
| 35 | srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \ | 35 | srcpos.h treesource.c util.c util.h version_gen.h yamltree.c Makefile.dtc \ |
| 36 | dtc-lexer.l dtc-parser.y" | 36 | dtc-lexer.l dtc-parser.y" |
| 37 | LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \ | 37 | LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \ |
| 38 | fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \ | 38 | fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \ |
diff --git a/scripts/dtc/util.c b/scripts/dtc/util.c index 9953c32a0244..a69b7a13463d 100644 --- a/scripts/dtc/util.c +++ b/scripts/dtc/util.c | |||
| @@ -227,11 +227,11 @@ char get_escape_char(const char *s, int *i) | |||
| 227 | return val; | 227 | return val; |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len) | 230 | int utilfdt_read_err(const char *filename, char **buffp, size_t *len) |
| 231 | { | 231 | { |
| 232 | int fd = 0; /* assume stdin */ | 232 | int fd = 0; /* assume stdin */ |
| 233 | char *buf = NULL; | 233 | char *buf = NULL; |
| 234 | off_t bufsize = 1024, offset = 0; | 234 | size_t bufsize = 1024, offset = 0; |
| 235 | int ret = 0; | 235 | int ret = 0; |
| 236 | 236 | ||
| 237 | *buffp = NULL; | 237 | *buffp = NULL; |
| @@ -264,20 +264,15 @@ int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len) | |||
| 264 | free(buf); | 264 | free(buf); |
| 265 | else | 265 | else |
| 266 | *buffp = buf; | 266 | *buffp = buf; |
| 267 | *len = bufsize; | 267 | if (len) |
| 268 | *len = bufsize; | ||
| 268 | return ret; | 269 | return ret; |
| 269 | } | 270 | } |
| 270 | 271 | ||
| 271 | int utilfdt_read_err(const char *filename, char **buffp) | 272 | char *utilfdt_read(const char *filename, size_t *len) |
| 272 | { | ||
| 273 | off_t len; | ||
| 274 | return utilfdt_read_err_len(filename, buffp, &len); | ||
| 275 | } | ||
| 276 | |||
| 277 | char *utilfdt_read_len(const char *filename, off_t *len) | ||
| 278 | { | 273 | { |
| 279 | char *buff; | 274 | char *buff; |
| 280 | int ret = utilfdt_read_err_len(filename, &buff, len); | 275 | int ret = utilfdt_read_err(filename, &buff, len); |
| 281 | 276 | ||
| 282 | if (ret) { | 277 | if (ret) { |
| 283 | fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename, | 278 | fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename, |
| @@ -288,12 +283,6 @@ char *utilfdt_read_len(const char *filename, off_t *len) | |||
| 288 | return buff; | 283 | return buff; |
| 289 | } | 284 | } |
| 290 | 285 | ||
| 291 | char *utilfdt_read(const char *filename) | ||
| 292 | { | ||
| 293 | off_t len; | ||
| 294 | return utilfdt_read_len(filename, &len); | ||
| 295 | } | ||
| 296 | |||
| 297 | int utilfdt_write_err(const char *filename, const void *blob) | 286 | int utilfdt_write_err(const char *filename, const void *blob) |
| 298 | { | 287 | { |
| 299 | int fd = 1; /* assume stdout */ | 288 | int fd = 1; /* assume stdout */ |
diff --git a/scripts/dtc/util.h b/scripts/dtc/util.h index 66fba8ea709b..f6cea8274174 100644 --- a/scripts/dtc/util.h +++ b/scripts/dtc/util.h | |||
| @@ -98,16 +98,10 @@ char get_escape_char(const char *s, int *i); | |||
| 98 | * stderr. | 98 | * stderr. |
| 99 | * | 99 | * |
| 100 | * @param filename The filename to read, or - for stdin | 100 | * @param filename The filename to read, or - for stdin |
| 101 | * @return Pointer to allocated buffer containing fdt, or NULL on error | ||
| 102 | */ | ||
| 103 | char *utilfdt_read(const char *filename); | ||
| 104 | |||
| 105 | /** | ||
| 106 | * Like utilfdt_read(), but also passes back the size of the file read. | ||
| 107 | * | ||
| 108 | * @param len If non-NULL, the amount of data we managed to read | 101 | * @param len If non-NULL, the amount of data we managed to read |
| 102 | * @return Pointer to allocated buffer containing fdt, or NULL on error | ||
| 109 | */ | 103 | */ |
| 110 | char *utilfdt_read_len(const char *filename, off_t *len); | 104 | char *utilfdt_read(const char *filename, size_t *len); |
| 111 | 105 | ||
| 112 | /** | 106 | /** |
| 113 | * Read a device tree file into a buffer. Does not report errors, but only | 107 | * Read a device tree file into a buffer. Does not report errors, but only |
| @@ -116,16 +110,10 @@ char *utilfdt_read_len(const char *filename, off_t *len); | |||
| 116 | * | 110 | * |
| 117 | * @param filename The filename to read, or - for stdin | 111 | * @param filename The filename to read, or - for stdin |
| 118 | * @param buffp Returns pointer to buffer containing fdt | 112 | * @param buffp Returns pointer to buffer containing fdt |
| 119 | * @return 0 if ok, else an errno value representing the error | ||
| 120 | */ | ||
| 121 | int utilfdt_read_err(const char *filename, char **buffp); | ||
| 122 | |||
| 123 | /** | ||
| 124 | * Like utilfdt_read_err(), but also passes back the size of the file read. | ||
| 125 | * | ||
| 126 | * @param len If non-NULL, the amount of data we managed to read | 113 | * @param len If non-NULL, the amount of data we managed to read |
| 114 | * @return 0 if ok, else an errno value representing the error | ||
| 127 | */ | 115 | */ |
| 128 | int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len); | 116 | int utilfdt_read_err(const char *filename, char **buffp, size_t *len); |
| 129 | 117 | ||
| 130 | /** | 118 | /** |
| 131 | * Write a device tree buffer to a file. This will report any errors on | 119 | * Write a device tree buffer to a file. This will report any errors on |
diff --git a/scripts/dtc/version_gen.h b/scripts/dtc/version_gen.h index b00f14ff7a17..6d23fd095f16 100644 --- a/scripts/dtc/version_gen.h +++ b/scripts/dtc/version_gen.h | |||
| @@ -1 +1 @@ | |||
| #define DTC_VERSION "DTC 1.4.6-g84e414b0" | #define DTC_VERSION "DTC 1.4.7-gc86da84d" | ||
diff --git a/scripts/dtc/yamltree.c b/scripts/dtc/yamltree.c new file mode 100644 index 000000000000..a00285a5a9ec --- /dev/null +++ b/scripts/dtc/yamltree.c | |||
| @@ -0,0 +1,247 @@ | |||
| 1 | /* | ||
| 2 | * (C) Copyright Linaro, Ltd. 2018 | ||
| 3 | * (C) Copyright Arm Holdings. 2017 | ||
| 4 | * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public License as | ||
| 8 | * published by the Free Software Foundation; either version 2 of the | ||
| 9 | * License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
| 19 | * USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <stdlib.h> | ||
| 23 | #include <yaml.h> | ||
| 24 | #include "dtc.h" | ||
| 25 | #include "srcpos.h" | ||
| 26 | |||
| 27 | char *yaml_error_name[] = { | ||
| 28 | [YAML_NO_ERROR] = "no error", | ||
| 29 | [YAML_MEMORY_ERROR] = "memory error", | ||
| 30 | [YAML_READER_ERROR] = "reader error", | ||
| 31 | [YAML_SCANNER_ERROR] = "scanner error", | ||
| 32 | [YAML_PARSER_ERROR] = "parser error", | ||
| 33 | [YAML_COMPOSER_ERROR] = "composer error", | ||
| 34 | [YAML_WRITER_ERROR] = "writer error", | ||
| 35 | [YAML_EMITTER_ERROR] = "emitter error", | ||
| 36 | }; | ||
| 37 | |||
| 38 | #define yaml_emitter_emit_or_die(emitter, event) ( \ | ||
| 39 | { \ | ||
| 40 | if (!yaml_emitter_emit(emitter, event)) \ | ||
| 41 | die("yaml '%s': %s in %s, line %i\n", \ | ||
| 42 | yaml_error_name[(emitter)->error], \ | ||
| 43 | (emitter)->problem, __func__, __LINE__); \ | ||
| 44 | }) | ||
| 45 | |||
| 46 | static void yaml_propval_int(yaml_emitter_t *emitter, struct marker *markers, char *data, int len, int width) | ||
| 47 | { | ||
| 48 | yaml_event_t event; | ||
| 49 | void *tag; | ||
| 50 | int off, start_offset = markers->offset; | ||
| 51 | |||
| 52 | switch(width) { | ||
| 53 | case 1: tag = "!u8"; break; | ||
| 54 | case 2: tag = "!u16"; break; | ||
| 55 | case 4: tag = "!u32"; break; | ||
| 56 | case 8: tag = "!u64"; break; | ||
| 57 | default: | ||
| 58 | die("Invalid width %i", width); | ||
| 59 | } | ||
| 60 | assert(len % width == 0); | ||
| 61 | |||
| 62 | yaml_sequence_start_event_initialize(&event, NULL, | ||
| 63 | (yaml_char_t *)tag, width == 4, YAML_FLOW_SEQUENCE_STYLE); | ||
| 64 | yaml_emitter_emit_or_die(emitter, &event); | ||
| 65 | |||
| 66 | for (off = 0; off < len; off += width) { | ||
| 67 | char buf[32]; | ||
| 68 | struct marker *m; | ||
| 69 | bool is_phandle = false; | ||
| 70 | |||
| 71 | switch(width) { | ||
| 72 | case 1: | ||
| 73 | sprintf(buf, "0x%"PRIx8, *(uint8_t*)(data + off)); | ||
| 74 | break; | ||
| 75 | case 2: | ||
| 76 | sprintf(buf, "0x%"PRIx16, fdt16_to_cpu(*(fdt16_t*)(data + off))); | ||
| 77 | break; | ||
| 78 | case 4: | ||
| 79 | sprintf(buf, "0x%"PRIx32, fdt32_to_cpu(*(fdt32_t*)(data + off))); | ||
| 80 | m = markers; | ||
| 81 | is_phandle = false; | ||
| 82 | for_each_marker_of_type(m, REF_PHANDLE) { | ||
| 83 | if (m->offset == (start_offset + off)) { | ||
| 84 | is_phandle = true; | ||
| 85 | break; | ||
| 86 | } | ||
| 87 | } | ||
| 88 | break; | ||
| 89 | case 8: | ||
| 90 | sprintf(buf, "0x%"PRIx64, fdt64_to_cpu(*(fdt64_t*)(data + off))); | ||
| 91 | break; | ||
| 92 | } | ||
| 93 | |||
| 94 | if (is_phandle) | ||
| 95 | yaml_scalar_event_initialize(&event, NULL, | ||
| 96 | (yaml_char_t*)"!phandle", (yaml_char_t *)buf, | ||
| 97 | strlen(buf), 0, 0, YAML_PLAIN_SCALAR_STYLE); | ||
| 98 | else | ||
| 99 | yaml_scalar_event_initialize(&event, NULL, | ||
| 100 | (yaml_char_t*)YAML_INT_TAG, (yaml_char_t *)buf, | ||
| 101 | strlen(buf), 1, 1, YAML_PLAIN_SCALAR_STYLE); | ||
| 102 | yaml_emitter_emit_or_die(emitter, &event); | ||
| 103 | } | ||
| 104 | |||
| 105 | yaml_sequence_end_event_initialize(&event); | ||
| 106 | yaml_emitter_emit_or_die(emitter, &event); | ||
| 107 | } | ||
| 108 | |||
| 109 | static void yaml_propval_string(yaml_emitter_t *emitter, char *str, int len) | ||
| 110 | { | ||
| 111 | yaml_event_t event; | ||
| 112 | int i; | ||
| 113 | |||
| 114 | assert(str[len-1] == '\0'); | ||
| 115 | |||
| 116 | /* Make sure the entire string is in the lower 7-bit ascii range */ | ||
| 117 | for (i = 0; i < len; i++) | ||
| 118 | assert(isascii(str[i])); | ||
| 119 | |||
| 120 | yaml_scalar_event_initialize(&event, NULL, | ||
| 121 | (yaml_char_t *)YAML_STR_TAG, (yaml_char_t*)str, | ||
| 122 | len-1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE); | ||
| 123 | yaml_emitter_emit_or_die(emitter, &event); | ||
| 124 | } | ||
| 125 | |||
| 126 | static void yaml_propval(yaml_emitter_t *emitter, struct property *prop) | ||
| 127 | { | ||
| 128 | yaml_event_t event; | ||
| 129 | int len = prop->val.len; | ||
| 130 | struct marker *m = prop->val.markers; | ||
| 131 | |||
| 132 | /* Emit the property name */ | ||
| 133 | yaml_scalar_event_initialize(&event, NULL, | ||
| 134 | (yaml_char_t *)YAML_STR_TAG, (yaml_char_t*)prop->name, | ||
| 135 | strlen(prop->name), 1, 1, YAML_PLAIN_SCALAR_STYLE); | ||
| 136 | yaml_emitter_emit_or_die(emitter, &event); | ||
| 137 | |||
| 138 | /* Boolean properties are easiest to deal with. Length is zero, so just emit 'true' */ | ||
| 139 | if (len == 0) { | ||
| 140 | yaml_scalar_event_initialize(&event, NULL, | ||
| 141 | (yaml_char_t *)YAML_BOOL_TAG, | ||
| 142 | (yaml_char_t*)"true", | ||
| 143 | strlen("true"), 1, 0, YAML_PLAIN_SCALAR_STYLE); | ||
| 144 | yaml_emitter_emit_or_die(emitter, &event); | ||
| 145 | return; | ||
| 146 | } | ||
| 147 | |||
| 148 | if (!m) | ||
| 149 | die("No markers present in property '%s' value\n", prop->name); | ||
| 150 | |||
| 151 | yaml_sequence_start_event_initialize(&event, NULL, | ||
| 152 | (yaml_char_t *)YAML_SEQ_TAG, 1, YAML_FLOW_SEQUENCE_STYLE); | ||
| 153 | yaml_emitter_emit_or_die(emitter, &event); | ||
| 154 | |||
| 155 | for_each_marker(m) { | ||
| 156 | int chunk_len; | ||
| 157 | char *data = &prop->val.val[m->offset]; | ||
| 158 | |||
| 159 | if (m->type < TYPE_UINT8) | ||
| 160 | continue; | ||
| 161 | |||
| 162 | chunk_len = type_marker_length(m) ? : len; | ||
| 163 | assert(chunk_len > 0); | ||
| 164 | len -= chunk_len; | ||
| 165 | |||
| 166 | switch(m->type) { | ||
| 167 | case TYPE_UINT16: | ||
| 168 | yaml_propval_int(emitter, m, data, chunk_len, 2); | ||
| 169 | break; | ||
| 170 | case TYPE_UINT32: | ||
| 171 | yaml_propval_int(emitter, m, data, chunk_len, 4); | ||
| 172 | break; | ||
| 173 | case TYPE_UINT64: | ||
| 174 | yaml_propval_int(emitter, m, data, chunk_len, 8); | ||
| 175 | break; | ||
| 176 | case TYPE_STRING: | ||
| 177 | yaml_propval_string(emitter, data, chunk_len); | ||
| 178 | break; | ||
| 179 | default: | ||
| 180 | yaml_propval_int(emitter, m, data, chunk_len, 1); | ||
| 181 | break; | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 185 | yaml_sequence_end_event_initialize(&event); | ||
| 186 | yaml_emitter_emit_or_die(emitter, &event); | ||
| 187 | } | ||
| 188 | |||
| 189 | |||
| 190 | static void yaml_tree(struct node *tree, yaml_emitter_t *emitter) | ||
| 191 | { | ||
| 192 | struct property *prop; | ||
| 193 | struct node *child; | ||
| 194 | yaml_event_t event; | ||
| 195 | |||
| 196 | if (tree->deleted) | ||
| 197 | return; | ||
| 198 | |||
| 199 | yaml_mapping_start_event_initialize(&event, NULL, | ||
| 200 | (yaml_char_t *)YAML_MAP_TAG, 1, YAML_ANY_MAPPING_STYLE); | ||
| 201 | yaml_emitter_emit_or_die(emitter, &event); | ||
| 202 | |||
| 203 | for_each_property(tree, prop) | ||
| 204 | yaml_propval(emitter, prop); | ||
| 205 | |||
| 206 | /* Loop over all the children, emitting them into the map */ | ||
| 207 | for_each_child(tree, child) { | ||
| 208 | yaml_scalar_event_initialize(&event, NULL, | ||
| 209 | (yaml_char_t *)YAML_STR_TAG, (yaml_char_t*)child->name, | ||
| 210 | strlen(child->name), 1, 0, YAML_PLAIN_SCALAR_STYLE); | ||
| 211 | yaml_emitter_emit_or_die(emitter, &event); | ||
| 212 | yaml_tree(child, emitter); | ||
| 213 | } | ||
| 214 | |||
| 215 | yaml_mapping_end_event_initialize(&event); | ||
| 216 | yaml_emitter_emit_or_die(emitter, &event); | ||
| 217 | } | ||
| 218 | |||
| 219 | void dt_to_yaml(FILE *f, struct dt_info *dti) | ||
| 220 | { | ||
| 221 | yaml_emitter_t emitter; | ||
| 222 | yaml_event_t event; | ||
| 223 | |||
| 224 | yaml_emitter_initialize(&emitter); | ||
| 225 | yaml_emitter_set_output_file(&emitter, f); | ||
| 226 | yaml_stream_start_event_initialize(&event, YAML_UTF8_ENCODING); | ||
| 227 | yaml_emitter_emit_or_die(&emitter, &event); | ||
| 228 | |||
| 229 | yaml_document_start_event_initialize(&event, NULL, NULL, NULL, 0); | ||
| 230 | yaml_emitter_emit_or_die(&emitter, &event); | ||
| 231 | |||
| 232 | yaml_sequence_start_event_initialize(&event, NULL, (yaml_char_t *)YAML_SEQ_TAG, 1, YAML_ANY_SEQUENCE_STYLE); | ||
| 233 | yaml_emitter_emit_or_die(&emitter, &event); | ||
| 234 | |||
| 235 | yaml_tree(dti->dt, &emitter); | ||
| 236 | |||
| 237 | yaml_sequence_end_event_initialize(&event); | ||
| 238 | yaml_emitter_emit_or_die(&emitter, &event); | ||
| 239 | |||
| 240 | yaml_document_end_event_initialize(&event, 0); | ||
| 241 | yaml_emitter_emit_or_die(&emitter, &event); | ||
| 242 | |||
| 243 | yaml_stream_end_event_initialize(&event); | ||
| 244 | yaml_emitter_emit_or_die(&emitter, &event); | ||
| 245 | |||
| 246 | yaml_emitter_delete(&emitter); | ||
| 247 | } | ||
