mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-25 05:04:09 +08:00
Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6
* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6: (29 commits) of/flattree: forward declare struct device_node in of_fdt.h ipmi: explicitly include of_address.h and of_irq.h sparc: explicitly cast negative phandle checks to s32 powerpc/405: Fix missing #{address,size}-cells in i2c node powerpc/5200: dts: refactor dts files powerpc/5200: dts: Change combatible strings on localbus powerpc/5200: dts: remove unused properties powerpc/5200: dts: rename nodes to prepare for refactoring dts files of/flattree: Update dtc to current mainline. of/device: Don't register disabled devices powerpc/dts: fix syntax bugs in bluestone.dts of: Fixes for OF probing on little endian systems of: make drivers depend on CONFIG_OF instead of CONFIG_PPC_OF of/flattree: Add of_flat_dt_match() helper function of_serial: explicitly include of_irq.h of/flattree: Refactor unflatten_device_tree and add fdt_unflatten_tree of/flattree: Reorder unflatten_dt_node of/flattree: Refactor unflatten_dt_node of/flattree: Add non-boottime device tree functions of/flattree: Add Kconfig for EARLY_FLATTREE ... Fix up trivial conflict in arch/sparc/prom/tree_32.c as per Grant.
This commit is contained in:
commit
0bd2cbcdfa
@ -1136,6 +1136,21 @@ When kbuild executes, the following steps are followed (roughly):
|
||||
resulting in the target file being recompiled for no
|
||||
obvious reason.
|
||||
|
||||
dtc
|
||||
Create flattend device tree blob object suitable for linking
|
||||
into vmlinux. Device tree blobs linked into vmlinux are placed
|
||||
in an init section in the image. Platform code *must* copy the
|
||||
blob to non-init memory prior to calling unflatten_device_tree().
|
||||
|
||||
Example:
|
||||
#arch/x86/platform/ce4100/Makefile
|
||||
clean-files := *dtb.S
|
||||
|
||||
DTC_FLAGS := -p 1024
|
||||
obj-y += foo.dtb.o
|
||||
|
||||
$(obj)/%.dtb: $(src)/%.dts
|
||||
$(call cmd,dtc)
|
||||
|
||||
--- 6.7 Custom kbuild commands
|
||||
|
||||
|
28
Documentation/powerpc/dts-bindings/eeprom.txt
Normal file
28
Documentation/powerpc/dts-bindings/eeprom.txt
Normal file
@ -0,0 +1,28 @@
|
||||
EEPROMs (I2C)
|
||||
|
||||
Required properties:
|
||||
|
||||
- compatible : should be "<manufacturer>,<type>"
|
||||
If there is no specific driver for <manufacturer>, a generic
|
||||
driver based on <type> is selected. Possible types are:
|
||||
24c00, 24c01, 24c02, 24c04, 24c08, 24c16, 24c32, 24c64,
|
||||
24c128, 24c256, 24c512, 24c1024, spd
|
||||
|
||||
- reg : the I2C address of the EEPROM
|
||||
|
||||
Optional properties:
|
||||
|
||||
- pagesize : the length of the pagesize for writing. Please consult the
|
||||
manual of your device, that value varies a lot. A wrong value
|
||||
may result in data loss! If not specified, a safety value of
|
||||
'1' is used which will be very slow.
|
||||
|
||||
- read-only: this parameterless property disables writes to the eeprom
|
||||
|
||||
Example:
|
||||
|
||||
eeprom@52 {
|
||||
compatible = "atmel,24c32";
|
||||
reg = <0x52>;
|
||||
pagesize = <32>;
|
||||
};
|
@ -14,7 +14,7 @@ config MICROBLAZE
|
||||
select HAVE_DMA_API_DEBUG
|
||||
select TRACING_SUPPORT
|
||||
select OF
|
||||
select OF_FLATTREE
|
||||
select OF_EARLY_FLATTREE
|
||||
|
||||
config SWAP
|
||||
def_bool n
|
||||
|
@ -10,9 +10,6 @@ targets := linux.bin linux.bin.gz simpleImage.%
|
||||
|
||||
OBJCOPYFLAGS := -O binary
|
||||
|
||||
# Where the DTS files live
|
||||
dtstree := $(srctree)/$(src)/dts
|
||||
|
||||
# Ensure system.dtb exists
|
||||
$(obj)/linked_dtb.o: $(obj)/system.dtb
|
||||
|
||||
@ -51,14 +48,11 @@ $(obj)/simpleImage.%: vmlinux FORCE
|
||||
$(call if_changed,strip)
|
||||
@echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
|
||||
|
||||
# Rule to build device tree blobs
|
||||
DTC = $(objtree)/scripts/dtc/dtc
|
||||
|
||||
# Rule to build device tree blobs
|
||||
quiet_cmd_dtc = DTC $@
|
||||
cmd_dtc = $(DTC) -O dtb -o $(obj)/$*.dtb -b 0 -p 1024 $(dtstree)/$*.dts
|
||||
DTC_FLAGS := -p 1024
|
||||
|
||||
$(obj)/%.dtb: $(dtstree)/%.dts FORCE
|
||||
$(call if_changed,dtc)
|
||||
$(obj)/%.dtb: $(src)/dts/%.dts FORCE
|
||||
$(call cmd,dtc)
|
||||
|
||||
clean-files += *.dtb simpleImage.*.unstrip linux.bin.ub
|
||||
|
@ -64,9 +64,6 @@ extern void kdump_move_device_tree(void);
|
||||
/* CPU OF node matching */
|
||||
struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
|
||||
|
||||
/* Get the MAC address */
|
||||
extern const void *of_get_mac_address(struct device_node *np);
|
||||
|
||||
/**
|
||||
* of_irq_map_pci - Resolve the interrupt for a PCI device
|
||||
* @pdev: the device whose interrupt is to be resolved
|
||||
|
@ -110,41 +110,3 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
|
||||
cells = prop ? *(u32 *)prop : of_n_size_cells(dn);
|
||||
*size = of_read_number(dma_window, cells);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the device tree for the best MAC address to use. 'mac-address' is
|
||||
* checked first, because that is supposed to contain to "most recent" MAC
|
||||
* address. If that isn't set, then 'local-mac-address' is checked next,
|
||||
* because that is the default address. If that isn't set, then the obsolete
|
||||
* 'address' is checked, just in case we're using an old device tree.
|
||||
*
|
||||
* Note that the 'address' property is supposed to contain a virtual address of
|
||||
* the register set, but some DTS files have redefined that property to be the
|
||||
* MAC address.
|
||||
*
|
||||
* All-zero MAC addresses are rejected, because those could be properties that
|
||||
* exist in the device tree, but were not set by U-Boot. For example, the
|
||||
* DTS could define 'mac-address' and 'local-mac-address', with zero MAC
|
||||
* addresses. Some older U-Boots only initialized 'local-mac-address'. In
|
||||
* this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
|
||||
* but is all zeros.
|
||||
*/
|
||||
const void *of_get_mac_address(struct device_node *np)
|
||||
{
|
||||
struct property *pp;
|
||||
|
||||
pp = of_find_property(np, "mac-address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
pp = of_find_property(np, "local-mac-address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
pp = of_find_property(np, "address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL(of_get_mac_address);
|
||||
|
@ -2218,7 +2218,7 @@ config SECCOMP
|
||||
config USE_OF
|
||||
bool "Flattened Device Tree support"
|
||||
select OF
|
||||
select OF_FLATTREE
|
||||
select OF_EARLY_FLATTREE
|
||||
help
|
||||
Include support for flattened device tree machine descriptions.
|
||||
|
||||
|
@ -116,7 +116,7 @@ config PPC
|
||||
bool
|
||||
default y
|
||||
select OF
|
||||
select OF_FLATTREE
|
||||
select OF_EARLY_FLATTREE
|
||||
select HAVE_FTRACE_MCOUNT_RECORD
|
||||
select HAVE_DYNAMIC_FTRACE
|
||||
select HAVE_FUNCTION_TRACER
|
||||
|
@ -35,7 +35,7 @@ endif
|
||||
|
||||
BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj)
|
||||
|
||||
DTS_FLAGS ?= -p 1024
|
||||
DTC_FLAGS ?= -p 1024
|
||||
|
||||
$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
|
||||
$(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
|
||||
@ -332,10 +332,8 @@ $(obj)/treeImage.%: vmlinux $(obj)/%.dtb $(wrapperbits)
|
||||
$(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb)
|
||||
|
||||
# Rule to build device tree blobs
|
||||
DTC = $(objtree)/scripts/dtc/dtc
|
||||
|
||||
$(obj)/%.dtb: $(dtstree)/%.dts
|
||||
$(DTC) -O dtb -o $(obj)/$*.dtb -b 0 $(DTS_FLAGS) $(dtstree)/$*.dts
|
||||
$(obj)/%.dtb: $(src)/dts/%.dts
|
||||
$(call cmd,dtc)
|
||||
|
||||
# If there isn't a platform selected then just strip the vmlinux.
|
||||
ifeq (,$(image-y))
|
||||
|
@ -33,7 +33,7 @@
|
||||
aliases {
|
||||
ethernet0 = &EMAC0;
|
||||
serial0 = &UART0;
|
||||
serial1 = &UART1;
|
||||
//serial1 = &UART1; --gcl missing UART1 label
|
||||
};
|
||||
|
||||
cpus {
|
||||
@ -52,7 +52,7 @@
|
||||
d-cache-size = <32768>;
|
||||
dcr-controller;
|
||||
dcr-access-method = "native";
|
||||
next-level-cache = <&L2C0>;
|
||||
//next-level-cache = <&L2C0>; --gcl missing L2C0 label
|
||||
};
|
||||
};
|
||||
|
||||
@ -142,7 +142,7 @@
|
||||
/*RXEOB*/ 0x7 0x4
|
||||
/*SERR*/ 0x3 0x4
|
||||
/*TXDE*/ 0x4 0x4
|
||||
/*RXDE*/ 0x5 0x4
|
||||
/*RXDE*/ 0x5 0x4>;
|
||||
};
|
||||
|
||||
POB0: opb {
|
||||
@ -182,7 +182,7 @@
|
||||
reg = <0x001a0000 0x00060000>;
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
UART0: serial@ef600300 {
|
||||
device_type = "serial";
|
||||
|
@ -10,220 +10,74 @@
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/include/ "mpc5200b.dtsi"
|
||||
|
||||
/ {
|
||||
model = "schindler,cm5200";
|
||||
compatible = "schindler,cm5200";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
interrupt-parent = <&mpc5200_pic>;
|
||||
|
||||
cpus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
PowerPC,5200@0 {
|
||||
device_type = "cpu";
|
||||
reg = <0>;
|
||||
d-cache-line-size = <32>;
|
||||
i-cache-line-size = <32>;
|
||||
d-cache-size = <0x4000>; // L1, 16K
|
||||
i-cache-size = <0x4000>; // L1, 16K
|
||||
timebase-frequency = <0>; // from bootloader
|
||||
bus-frequency = <0>; // from bootloader
|
||||
clock-frequency = <0>; // from bootloader
|
||||
};
|
||||
};
|
||||
|
||||
memory {
|
||||
device_type = "memory";
|
||||
reg = <0x00000000 0x04000000>; // 64MB
|
||||
};
|
||||
|
||||
soc5200@f0000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
compatible = "fsl,mpc5200b-immr";
|
||||
ranges = <0 0xf0000000 0x0000c000>;
|
||||
reg = <0xf0000000 0x00000100>;
|
||||
bus-frequency = <0>; // from bootloader
|
||||
system-frequency = <0>; // from bootloader
|
||||
|
||||
cdm@200 {
|
||||
compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
|
||||
reg = <0x200 0x38>;
|
||||
};
|
||||
|
||||
mpc5200_pic: interrupt-controller@500 {
|
||||
// 5200 interrupts are encoded into two levels;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <3>;
|
||||
compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
|
||||
reg = <0x500 0x80>;
|
||||
};
|
||||
|
||||
timer@600 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x600 0x10>;
|
||||
interrupts = <1 9 0>;
|
||||
fsl,has-wdt;
|
||||
};
|
||||
|
||||
timer@610 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x610 0x10>;
|
||||
interrupts = <1 10 0>;
|
||||
can@900 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer@620 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x620 0x10>;
|
||||
interrupts = <1 11 0>;
|
||||
can@980 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer@630 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x630 0x10>;
|
||||
interrupts = <1 12 0>;
|
||||
};
|
||||
|
||||
timer@640 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x640 0x10>;
|
||||
interrupts = <1 13 0>;
|
||||
};
|
||||
|
||||
timer@650 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x650 0x10>;
|
||||
interrupts = <1 14 0>;
|
||||
};
|
||||
|
||||
timer@660 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x660 0x10>;
|
||||
interrupts = <1 15 0>;
|
||||
};
|
||||
|
||||
timer@670 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x670 0x10>;
|
||||
interrupts = <1 16 0>;
|
||||
};
|
||||
|
||||
rtc@800 { // Real time clock
|
||||
compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
|
||||
reg = <0x800 0x100>;
|
||||
interrupts = <1 5 0 1 6 0>;
|
||||
};
|
||||
|
||||
gpio_simple: gpio@b00 {
|
||||
compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
|
||||
reg = <0xb00 0x40>;
|
||||
interrupts = <1 7 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpio_wkup: gpio@c00 {
|
||||
compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
|
||||
reg = <0xc00 0x40>;
|
||||
interrupts = <1 8 0 0 3 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
spi@f00 {
|
||||
compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
|
||||
reg = <0xf00 0x20>;
|
||||
interrupts = <2 13 0 2 14 0>;
|
||||
};
|
||||
|
||||
usb@1000 {
|
||||
compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
|
||||
reg = <0x1000 0xff>;
|
||||
interrupts = <2 6 0>;
|
||||
};
|
||||
|
||||
dma-controller@1200 {
|
||||
compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
|
||||
reg = <0x1200 0x80>;
|
||||
interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
|
||||
3 4 0 3 5 0 3 6 0 3 7 0
|
||||
3 8 0 3 9 0 3 10 0 3 11 0
|
||||
3 12 0 3 13 0 3 14 0 3 15 0>;
|
||||
};
|
||||
|
||||
xlb@1f00 {
|
||||
compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
|
||||
reg = <0x1f00 0x100>;
|
||||
};
|
||||
|
||||
serial@2000 { // PSC1
|
||||
psc@2000 { // PSC1
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2000 0x100>;
|
||||
interrupts = <2 1 0>;
|
||||
};
|
||||
|
||||
serial@2200 { // PSC2
|
||||
psc@2200 { // PSC2
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2200 0x100>;
|
||||
interrupts = <2 2 0>;
|
||||
};
|
||||
|
||||
serial@2400 { // PSC3
|
||||
psc@2400 { // PSC3
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2400 0x100>;
|
||||
interrupts = <2 3 0>;
|
||||
};
|
||||
|
||||
serial@2c00 { // PSC6
|
||||
psc@2600 { // PSC4
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2800 { // PSC5
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2c00 { // PSC6
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2c00 0x100>;
|
||||
interrupts = <2 4 0>;
|
||||
};
|
||||
|
||||
ethernet@3000 {
|
||||
compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
|
||||
reg = <0x3000 0x400>;
|
||||
local-mac-address = [ 00 00 00 00 00 00 ];
|
||||
interrupts = <2 5 0>;
|
||||
phy-handle = <&phy0>;
|
||||
};
|
||||
|
||||
mdio@3000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
|
||||
reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
|
||||
interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
|
||||
|
||||
phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
i2c@3d40 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d40 0x40>;
|
||||
interrupts = <2 16 0>;
|
||||
ata@3a00 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
sram@8000 {
|
||||
compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
|
||||
reg = <0x8000 0x4000>;
|
||||
i2c@3d00 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
pci@f0000d00 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
localbus {
|
||||
compatible = "fsl,mpc5200b-lpb","simple-bus";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <1>;
|
||||
ranges = <0 0 0xfc000000 0x2000000>;
|
||||
|
||||
// 16-bit flash device at LocalPlus Bus CS0
|
||||
flash@0,0 {
|
||||
compatible = "cfi-flash";
|
||||
|
@ -11,195 +11,68 @@
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/include/ "mpc5200b.dtsi"
|
||||
|
||||
/ {
|
||||
model = "intercontrol,digsy-mtc";
|
||||
compatible = "intercontrol,digsy-mtc";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
interrupt-parent = <&mpc5200_pic>;
|
||||
|
||||
cpus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
PowerPC,5200@0 {
|
||||
device_type = "cpu";
|
||||
reg = <0>;
|
||||
d-cache-line-size = <32>;
|
||||
i-cache-line-size = <32>;
|
||||
d-cache-size = <0x4000>; // L1, 16K
|
||||
i-cache-size = <0x4000>; // L1, 16K
|
||||
timebase-frequency = <0>; // from bootloader
|
||||
bus-frequency = <0>; // from bootloader
|
||||
clock-frequency = <0>; // from bootloader
|
||||
};
|
||||
};
|
||||
|
||||
memory {
|
||||
device_type = "memory";
|
||||
reg = <0x00000000 0x02000000>; // 32MB
|
||||
};
|
||||
|
||||
soc5200@f0000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
compatible = "fsl,mpc5200b-immr";
|
||||
ranges = <0 0xf0000000 0x0000c000>;
|
||||
reg = <0xf0000000 0x00000100>;
|
||||
bus-frequency = <0>; // from bootloader
|
||||
system-frequency = <0>; // from bootloader
|
||||
|
||||
cdm@200 {
|
||||
compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
|
||||
reg = <0x200 0x38>;
|
||||
};
|
||||
|
||||
mpc5200_pic: interrupt-controller@500 {
|
||||
// 5200 interrupts are encoded into two levels;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <3>;
|
||||
compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
|
||||
reg = <0x500 0x80>;
|
||||
};
|
||||
|
||||
timer@600 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x600 0x10>;
|
||||
interrupts = <1 9 0>;
|
||||
fsl,has-wdt;
|
||||
};
|
||||
|
||||
timer@610 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x610 0x10>;
|
||||
interrupts = <1 10 0>;
|
||||
rtc@800 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer@620 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x620 0x10>;
|
||||
interrupts = <1 11 0>;
|
||||
can@900 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer@630 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x630 0x10>;
|
||||
interrupts = <1 12 0>;
|
||||
can@980 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer@640 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x640 0x10>;
|
||||
interrupts = <1 13 0>;
|
||||
psc@2000 { // PSC1
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer@650 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x650 0x10>;
|
||||
interrupts = <1 14 0>;
|
||||
psc@2200 { // PSC2
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer@660 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x660 0x10>;
|
||||
interrupts = <1 15 0>;
|
||||
psc@2400 { // PSC3
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer@670 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x670 0x10>;
|
||||
interrupts = <1 16 0>;
|
||||
};
|
||||
|
||||
gpio_simple: gpio@b00 {
|
||||
compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
|
||||
reg = <0xb00 0x40>;
|
||||
interrupts = <1 7 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpio_wkup: gpio@c00 {
|
||||
compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
|
||||
reg = <0xc00 0x40>;
|
||||
interrupts = <1 8 0 0 3 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
spi@f00 {
|
||||
compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
|
||||
reg = <0xf00 0x20>;
|
||||
interrupts = <2 13 0 2 14 0>;
|
||||
};
|
||||
|
||||
usb@1000 {
|
||||
compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
|
||||
reg = <0x1000 0xff>;
|
||||
interrupts = <2 6 0>;
|
||||
};
|
||||
|
||||
dma-controller@1200 {
|
||||
compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
|
||||
reg = <0x1200 0x80>;
|
||||
interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
|
||||
3 4 0 3 5 0 3 6 0 3 7 0
|
||||
3 8 0 3 9 0 3 10 0 3 11 0
|
||||
3 12 0 3 13 0 3 14 0 3 15 0>;
|
||||
};
|
||||
|
||||
xlb@1f00 {
|
||||
compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
|
||||
reg = <0x1f00 0x100>;
|
||||
};
|
||||
|
||||
serial@2600 { // PSC4
|
||||
psc@2600 { // PSC4
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2600 0x100>;
|
||||
interrupts = <2 11 0>;
|
||||
};
|
||||
|
||||
serial@2800 { // PSC5
|
||||
psc@2800 { // PSC5
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2800 0x100>;
|
||||
interrupts = <2 12 0>;
|
||||
};
|
||||
|
||||
psc@2c00 { // PSC6
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
ethernet@3000 {
|
||||
compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
|
||||
reg = <0x3000 0x400>;
|
||||
local-mac-address = [ 00 00 00 00 00 00 ];
|
||||
interrupts = <2 5 0>;
|
||||
phy-handle = <&phy0>;
|
||||
};
|
||||
|
||||
mdio@3000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
|
||||
reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
|
||||
interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
|
||||
|
||||
phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
ata@3a00 {
|
||||
compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
|
||||
reg = <0x3a00 0x100>;
|
||||
interrupts = <2 7 0>;
|
||||
};
|
||||
|
||||
i2c@3d00 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d00 0x40>;
|
||||
interrupts = <2 15 0>;
|
||||
|
||||
rtc@50 {
|
||||
compatible = "at,24c08";
|
||||
reg = <0x50>;
|
||||
@ -211,16 +84,16 @@
|
||||
};
|
||||
};
|
||||
|
||||
sram@8000 {
|
||||
compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
|
||||
reg = <0x8000 0x4000>;
|
||||
i2c@3d40 {
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
|
||||
lpb {
|
||||
compatible = "fsl,mpc5200b-lpb","simple-bus";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <1>;
|
||||
pci@f0000d00 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
localbus {
|
||||
ranges = <0 0 0xff000000 0x1000000>;
|
||||
|
||||
// 16-bit flash device at LocalPlus Bus CS0
|
||||
|
@ -117,6 +117,8 @@
|
||||
};
|
||||
|
||||
IIC: i2c@ef600500 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "ibm,iic-405ep", "ibm,iic";
|
||||
reg = <0xef600500 0x00000011>;
|
||||
interrupt-parent = <&UIC0>;
|
||||
|
@ -10,256 +10,75 @@
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/include/ "mpc5200b.dtsi"
|
||||
|
||||
/ {
|
||||
model = "fsl,lite5200b";
|
||||
compatible = "fsl,lite5200b";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
interrupt-parent = <&mpc5200_pic>;
|
||||
|
||||
cpus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
PowerPC,5200@0 {
|
||||
device_type = "cpu";
|
||||
reg = <0>;
|
||||
d-cache-line-size = <32>;
|
||||
i-cache-line-size = <32>;
|
||||
d-cache-size = <0x4000>; // L1, 16K
|
||||
i-cache-size = <0x4000>; // L1, 16K
|
||||
timebase-frequency = <0>; // from bootloader
|
||||
bus-frequency = <0>; // from bootloader
|
||||
clock-frequency = <0>; // from bootloader
|
||||
};
|
||||
};
|
||||
|
||||
memory {
|
||||
device_type = "memory";
|
||||
reg = <0x00000000 0x10000000>; // 256MB
|
||||
};
|
||||
|
||||
soc5200@f0000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
compatible = "fsl,mpc5200b-immr";
|
||||
ranges = <0 0xf0000000 0x0000c000>;
|
||||
reg = <0xf0000000 0x00000100>;
|
||||
bus-frequency = <0>; // from bootloader
|
||||
system-frequency = <0>; // from bootloader
|
||||
|
||||
cdm@200 {
|
||||
compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
|
||||
reg = <0x200 0x38>;
|
||||
};
|
||||
|
||||
mpc5200_pic: interrupt-controller@500 {
|
||||
// 5200 interrupts are encoded into two levels;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <3>;
|
||||
compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
|
||||
reg = <0x500 0x80>;
|
||||
};
|
||||
|
||||
timer@600 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x600 0x10>;
|
||||
interrupts = <1 9 0>;
|
||||
fsl,has-wdt;
|
||||
};
|
||||
|
||||
timer@610 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x610 0x10>;
|
||||
interrupts = <1 10 0>;
|
||||
};
|
||||
|
||||
timer@620 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x620 0x10>;
|
||||
interrupts = <1 11 0>;
|
||||
};
|
||||
|
||||
timer@630 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x630 0x10>;
|
||||
interrupts = <1 12 0>;
|
||||
};
|
||||
|
||||
timer@640 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x640 0x10>;
|
||||
interrupts = <1 13 0>;
|
||||
};
|
||||
|
||||
timer@650 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x650 0x10>;
|
||||
interrupts = <1 14 0>;
|
||||
};
|
||||
|
||||
timer@660 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x660 0x10>;
|
||||
interrupts = <1 15 0>;
|
||||
};
|
||||
|
||||
timer@670 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x670 0x10>;
|
||||
interrupts = <1 16 0>;
|
||||
};
|
||||
|
||||
rtc@800 { // Real time clock
|
||||
compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
|
||||
reg = <0x800 0x100>;
|
||||
interrupts = <1 5 0 1 6 0>;
|
||||
};
|
||||
|
||||
can@900 {
|
||||
compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
|
||||
interrupts = <2 17 0>;
|
||||
reg = <0x900 0x80>;
|
||||
};
|
||||
|
||||
can@980 {
|
||||
compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
|
||||
interrupts = <2 18 0>;
|
||||
reg = <0x980 0x80>;
|
||||
};
|
||||
|
||||
gpio_simple: gpio@b00 {
|
||||
compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
|
||||
reg = <0xb00 0x40>;
|
||||
interrupts = <1 7 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpio_wkup: gpio@c00 {
|
||||
compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
|
||||
reg = <0xc00 0x40>;
|
||||
interrupts = <1 8 0 0 3 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
spi@f00 {
|
||||
compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
|
||||
reg = <0xf00 0x20>;
|
||||
interrupts = <2 13 0 2 14 0>;
|
||||
};
|
||||
|
||||
usb@1000 {
|
||||
compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
|
||||
reg = <0x1000 0xff>;
|
||||
interrupts = <2 6 0>;
|
||||
};
|
||||
|
||||
dma-controller@1200 {
|
||||
compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
|
||||
reg = <0x1200 0x80>;
|
||||
interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
|
||||
3 4 0 3 5 0 3 6 0 3 7 0
|
||||
3 8 0 3 9 0 3 10 0 3 11 0
|
||||
3 12 0 3 13 0 3 14 0 3 15 0>;
|
||||
};
|
||||
|
||||
xlb@1f00 {
|
||||
compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
|
||||
reg = <0x1f00 0x100>;
|
||||
};
|
||||
|
||||
serial@2000 { // PSC1
|
||||
psc@2000 { // PSC1
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
cell-index = <0>;
|
||||
reg = <0x2000 0x100>;
|
||||
interrupts = <2 1 0>;
|
||||
};
|
||||
|
||||
psc@2200 { // PSC2
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2400 { // PSC3
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2600 { // PSC4
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2800 { // PSC5
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2c00 { // PSC6
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
// PSC2 in ac97 mode example
|
||||
//ac97@2200 { // PSC2
|
||||
// compatible = "fsl,mpc5200b-psc-ac97","fsl,mpc5200-psc-ac97";
|
||||
// cell-index = <1>;
|
||||
// reg = <0x2200 0x100>;
|
||||
// interrupts = <2 2 0>;
|
||||
//};
|
||||
|
||||
// PSC3 in CODEC mode example
|
||||
//i2s@2400 { // PSC3
|
||||
// compatible = "fsl,mpc5200b-psc-i2s"; //not 5200 compatible
|
||||
// cell-index = <2>;
|
||||
// reg = <0x2400 0x100>;
|
||||
// interrupts = <2 3 0>;
|
||||
//};
|
||||
|
||||
// PSC4 in uart mode example
|
||||
//serial@2600 { // PSC4
|
||||
// compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
// cell-index = <3>;
|
||||
// reg = <0x2600 0x100>;
|
||||
// interrupts = <2 11 0>;
|
||||
//};
|
||||
|
||||
// PSC5 in uart mode example
|
||||
//serial@2800 { // PSC5
|
||||
// compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
// cell-index = <4>;
|
||||
// reg = <0x2800 0x100>;
|
||||
// interrupts = <2 12 0>;
|
||||
//};
|
||||
|
||||
// PSC6 in spi mode example
|
||||
//spi@2c00 { // PSC6
|
||||
// compatible = "fsl,mpc5200b-psc-spi","fsl,mpc5200-psc-spi";
|
||||
// cell-index = <5>;
|
||||
// reg = <0x2c00 0x100>;
|
||||
// interrupts = <2 4 0>;
|
||||
//};
|
||||
|
||||
ethernet@3000 {
|
||||
compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
|
||||
reg = <0x3000 0x400>;
|
||||
local-mac-address = [ 00 00 00 00 00 00 ];
|
||||
interrupts = <2 5 0>;
|
||||
phy-handle = <&phy0>;
|
||||
};
|
||||
|
||||
mdio@3000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
|
||||
reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
|
||||
interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
|
||||
|
||||
phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
ata@3a00 {
|
||||
compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
|
||||
reg = <0x3a00 0x100>;
|
||||
interrupts = <2 7 0>;
|
||||
};
|
||||
|
||||
i2c@3d00 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d00 0x40>;
|
||||
interrupts = <2 15 0>;
|
||||
};
|
||||
|
||||
i2c@3d40 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d40 0x40>;
|
||||
interrupts = <2 16 0>;
|
||||
|
||||
eeprom@50 {
|
||||
compatible = "atmel,24c02";
|
||||
reg = <0x50>;
|
||||
@ -273,12 +92,6 @@
|
||||
};
|
||||
|
||||
pci@f0000d00 {
|
||||
#interrupt-cells = <1>;
|
||||
#size-cells = <2>;
|
||||
#address-cells = <3>;
|
||||
device_type = "pci";
|
||||
compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
|
||||
reg = <0xf0000d00 0x100>;
|
||||
interrupt-map-mask = <0xf800 0 0 7>;
|
||||
interrupt-map = <0xc000 0 0 1 &mpc5200_pic 0 0 3 // 1st slot
|
||||
0xc000 0 0 2 &mpc5200_pic 1 1 3
|
||||
@ -298,11 +111,6 @@
|
||||
};
|
||||
|
||||
localbus {
|
||||
compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus";
|
||||
|
||||
#address-cells = <2>;
|
||||
#size-cells = <1>;
|
||||
|
||||
ranges = <0 0 0xfe000000 0x02000000>;
|
||||
|
||||
flash@0,0 {
|
||||
|
@ -11,14 +11,11 @@
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/include/ "mpc5200b.dtsi"
|
||||
|
||||
/ {
|
||||
model = "fsl,media5200";
|
||||
compatible = "fsl,media5200";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
interrupt-parent = <&mpc5200_pic>;
|
||||
|
||||
aliases {
|
||||
console = &console;
|
||||
@ -30,16 +27,7 @@
|
||||
};
|
||||
|
||||
cpus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
PowerPC,5200@0 {
|
||||
device_type = "cpu";
|
||||
reg = <0>;
|
||||
d-cache-line-size = <32>;
|
||||
i-cache-line-size = <32>;
|
||||
d-cache-size = <0x4000>; // L1, 16K
|
||||
i-cache-size = <0x4000>; // L1, 16K
|
||||
timebase-frequency = <33000000>; // 33 MHz, these were configured by U-Boot
|
||||
bus-frequency = <132000000>; // 132 MHz
|
||||
clock-frequency = <396000000>; // 396 MHz
|
||||
@ -47,205 +35,57 @@
|
||||
};
|
||||
|
||||
memory {
|
||||
device_type = "memory";
|
||||
reg = <0x00000000 0x08000000>; // 128MB RAM
|
||||
};
|
||||
|
||||
soc@f0000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
compatible = "fsl,mpc5200b-immr";
|
||||
ranges = <0 0xf0000000 0x0000c000>;
|
||||
reg = <0xf0000000 0x00000100>;
|
||||
soc5200@f0000000 {
|
||||
bus-frequency = <132000000>;// 132 MHz
|
||||
system-frequency = <0>; // from bootloader
|
||||
|
||||
cdm@200 {
|
||||
compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
|
||||
reg = <0x200 0x38>;
|
||||
};
|
||||
|
||||
mpc5200_pic: interrupt-controller@500 {
|
||||
// 5200 interrupts are encoded into two levels;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <3>;
|
||||
compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
|
||||
reg = <0x500 0x80>;
|
||||
};
|
||||
|
||||
timer@600 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x600 0x10>;
|
||||
interrupts = <1 9 0>;
|
||||
fsl,has-wdt;
|
||||
};
|
||||
|
||||
timer@610 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x610 0x10>;
|
||||
interrupts = <1 10 0>;
|
||||
psc@2000 { // PSC1
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer@620 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x620 0x10>;
|
||||
interrupts = <1 11 0>;
|
||||
psc@2200 { // PSC2
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer@630 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x630 0x10>;
|
||||
interrupts = <1 12 0>;
|
||||
psc@2400 { // PSC3
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer@640 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x640 0x10>;
|
||||
interrupts = <1 13 0>;
|
||||
psc@2600 { // PSC4
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer@650 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x650 0x10>;
|
||||
interrupts = <1 14 0>;
|
||||
};
|
||||
|
||||
timer@660 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x660 0x10>;
|
||||
interrupts = <1 15 0>;
|
||||
};
|
||||
|
||||
timer@670 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x670 0x10>;
|
||||
interrupts = <1 16 0>;
|
||||
};
|
||||
|
||||
rtc@800 { // Real time clock
|
||||
compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
|
||||
reg = <0x800 0x100>;
|
||||
interrupts = <1 5 0 1 6 0>;
|
||||
};
|
||||
|
||||
can@900 {
|
||||
compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
|
||||
interrupts = <2 17 0>;
|
||||
reg = <0x900 0x80>;
|
||||
};
|
||||
|
||||
can@980 {
|
||||
compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
|
||||
interrupts = <2 18 0>;
|
||||
reg = <0x980 0x80>;
|
||||
};
|
||||
|
||||
gpio_simple: gpio@b00 {
|
||||
compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
|
||||
reg = <0xb00 0x40>;
|
||||
interrupts = <1 7 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpio_wkup: gpio@c00 {
|
||||
compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
|
||||
reg = <0xc00 0x40>;
|
||||
interrupts = <1 8 0 0 3 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
spi@f00 {
|
||||
compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
|
||||
reg = <0xf00 0x20>;
|
||||
interrupts = <2 13 0 2 14 0>;
|
||||
};
|
||||
|
||||
usb@1000 {
|
||||
compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
|
||||
reg = <0x1000 0x100>;
|
||||
interrupts = <2 6 0>;
|
||||
};
|
||||
|
||||
dma-controller@1200 {
|
||||
compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
|
||||
reg = <0x1200 0x80>;
|
||||
interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
|
||||
3 4 0 3 5 0 3 6 0 3 7 0
|
||||
3 8 0 3 9 0 3 10 0 3 11 0
|
||||
3 12 0 3 13 0 3 14 0 3 15 0>;
|
||||
};
|
||||
|
||||
xlb@1f00 {
|
||||
compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
|
||||
reg = <0x1f00 0x100>;
|
||||
psc@2800 { // PSC5
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
// PSC6 in uart mode
|
||||
console: serial@2c00 { // PSC6
|
||||
console: psc@2c00 { // PSC6
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
cell-index = <5>;
|
||||
port-number = <0>; // Logical port assignment
|
||||
reg = <0x2c00 0x100>;
|
||||
interrupts = <2 4 0>;
|
||||
};
|
||||
|
||||
eth0: ethernet@3000 {
|
||||
compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
|
||||
reg = <0x3000 0x400>;
|
||||
local-mac-address = [ 00 00 00 00 00 00 ];
|
||||
interrupts = <2 5 0>;
|
||||
ethernet@3000 {
|
||||
phy-handle = <&phy0>;
|
||||
};
|
||||
|
||||
mdio@3000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
|
||||
reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
|
||||
interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
|
||||
|
||||
phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
ata@3a00 {
|
||||
compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
|
||||
reg = <0x3a00 0x100>;
|
||||
interrupts = <2 7 0>;
|
||||
};
|
||||
|
||||
i2c@3d00 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d00 0x40>;
|
||||
interrupts = <2 15 0>;
|
||||
};
|
||||
|
||||
i2c@3d40 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d40 0x40>;
|
||||
interrupts = <2 16 0>;
|
||||
};
|
||||
|
||||
sram@8000 {
|
||||
compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
|
||||
reg = <0x8000 0x4000>;
|
||||
usb@1000 {
|
||||
reg = <0x1000 0x100>;
|
||||
};
|
||||
};
|
||||
|
||||
pci@f0000d00 {
|
||||
#interrupt-cells = <1>;
|
||||
#size-cells = <2>;
|
||||
#address-cells = <3>;
|
||||
device_type = "pci";
|
||||
compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
|
||||
reg = <0xf0000d00 0x100>;
|
||||
interrupt-map-mask = <0xf800 0 0 7>;
|
||||
interrupt-map = <0xc000 0 0 1 &media5200_fpga 0 2 // 1st slot
|
||||
0xc000 0 0 2 &media5200_fpga 0 3
|
||||
@ -262,37 +102,29 @@
|
||||
|
||||
0xe000 0 0 1 &media5200_fpga 0 5 // CoralIP
|
||||
>;
|
||||
clock-frequency = <0>; // From boot loader
|
||||
interrupts = <2 8 0 2 9 0 2 10 0>;
|
||||
interrupt-parent = <&mpc5200_pic>;
|
||||
bus-range = <0 0>;
|
||||
ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
|
||||
0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
|
||||
0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
|
||||
interrupt-parent = <&mpc5200_pic>;
|
||||
};
|
||||
|
||||
localbus {
|
||||
compatible = "fsl,mpc5200b-lpb","simple-bus";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <1>;
|
||||
|
||||
ranges = < 0 0 0xfc000000 0x02000000
|
||||
1 0 0xfe000000 0x02000000
|
||||
2 0 0xf0010000 0x00010000
|
||||
3 0 0xf0020000 0x00010000 >;
|
||||
|
||||
flash@0,0 {
|
||||
compatible = "amd,am29lv28ml", "cfi-flash";
|
||||
reg = <0 0x0 0x2000000>; // 32 MB
|
||||
bank-width = <4>; // Width in bytes of the flash bank
|
||||
device-width = <2>; // Two devices on each bank
|
||||
reg = <0 0x0 0x2000000>; // 32 MB
|
||||
bank-width = <4>; // Width in bytes of the flash bank
|
||||
device-width = <2>; // Two devices on each bank
|
||||
};
|
||||
|
||||
flash@1,0 {
|
||||
compatible = "amd,am29lv28ml", "cfi-flash";
|
||||
reg = <1 0 0x2000000>; // 32 MB
|
||||
bank-width = <4>; // Width in bytes of the flash bank
|
||||
device-width = <2>; // Two devices on each bank
|
||||
reg = <1 0 0x2000000>; // 32 MB
|
||||
bank-width = <4>; // Width in bytes of the flash bank
|
||||
device-width = <2>; // Two devices on each bank
|
||||
};
|
||||
|
||||
media5200_fpga: fpga@2,0 {
|
||||
|
@ -10,219 +10,73 @@
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/include/ "mpc5200b.dtsi"
|
||||
|
||||
/ {
|
||||
model = "promess,motionpro";
|
||||
compatible = "promess,motionpro";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
interrupt-parent = <&mpc5200_pic>;
|
||||
|
||||
cpus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
PowerPC,5200@0 {
|
||||
device_type = "cpu";
|
||||
reg = <0>;
|
||||
d-cache-line-size = <32>;
|
||||
i-cache-line-size = <32>;
|
||||
d-cache-size = <0x4000>; // L1, 16K
|
||||
i-cache-size = <0x4000>; // L1, 16K
|
||||
timebase-frequency = <0>; // from bootloader
|
||||
bus-frequency = <0>; // from bootloader
|
||||
clock-frequency = <0>; // from bootloader
|
||||
};
|
||||
};
|
||||
|
||||
memory {
|
||||
device_type = "memory";
|
||||
reg = <0x00000000 0x04000000>; // 64MB
|
||||
};
|
||||
|
||||
soc5200@f0000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
compatible = "fsl,mpc5200b-immr";
|
||||
ranges = <0 0xf0000000 0x0000c000>;
|
||||
reg = <0xf0000000 0x00000100>;
|
||||
bus-frequency = <0>; // from bootloader
|
||||
system-frequency = <0>; // from bootloader
|
||||
|
||||
cdm@200 {
|
||||
compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
|
||||
reg = <0x200 0x38>;
|
||||
};
|
||||
|
||||
mpc5200_pic: interrupt-controller@500 {
|
||||
// 5200 interrupts are encoded into two levels;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <3>;
|
||||
compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
|
||||
reg = <0x500 0x80>;
|
||||
};
|
||||
|
||||
timer@600 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x600 0x10>;
|
||||
interrupts = <1 9 0>;
|
||||
fsl,has-wdt;
|
||||
};
|
||||
|
||||
timer@610 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x610 0x10>;
|
||||
interrupts = <1 10 0>;
|
||||
};
|
||||
|
||||
timer@620 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x620 0x10>;
|
||||
interrupts = <1 11 0>;
|
||||
};
|
||||
|
||||
timer@630 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x630 0x10>;
|
||||
interrupts = <1 12 0>;
|
||||
};
|
||||
|
||||
timer@640 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x640 0x10>;
|
||||
interrupts = <1 13 0>;
|
||||
};
|
||||
|
||||
timer@650 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x650 0x10>;
|
||||
interrupts = <1 14 0>;
|
||||
};
|
||||
|
||||
motionpro-led@660 { // Motion-PRO status LED
|
||||
timer@660 { // Motion-PRO status LED
|
||||
compatible = "promess,motionpro-led";
|
||||
label = "motionpro-statusled";
|
||||
reg = <0x660 0x10>;
|
||||
interrupts = <1 15 0>;
|
||||
blink-delay = <100>; // 100 msec
|
||||
};
|
||||
|
||||
motionpro-led@670 { // Motion-PRO ready LED
|
||||
timer@670 { // Motion-PRO ready LED
|
||||
compatible = "promess,motionpro-led";
|
||||
label = "motionpro-readyled";
|
||||
reg = <0x670 0x10>;
|
||||
interrupts = <1 16 0>;
|
||||
};
|
||||
|
||||
rtc@800 { // Real time clock
|
||||
compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
|
||||
reg = <0x800 0x100>;
|
||||
interrupts = <1 5 0 1 6 0>;
|
||||
can@900 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
can@980 {
|
||||
compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
|
||||
interrupts = <2 18 0>;
|
||||
reg = <0x980 0x80>;
|
||||
};
|
||||
|
||||
gpio_simple: gpio@b00 {
|
||||
compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
|
||||
reg = <0xb00 0x40>;
|
||||
interrupts = <1 7 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpio_wkup: gpio@c00 {
|
||||
compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
|
||||
reg = <0xc00 0x40>;
|
||||
interrupts = <1 8 0 0 3 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
spi@f00 {
|
||||
compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
|
||||
reg = <0xf00 0x20>;
|
||||
interrupts = <2 13 0 2 14 0>;
|
||||
};
|
||||
|
||||
usb@1000 {
|
||||
compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
|
||||
reg = <0x1000 0xff>;
|
||||
interrupts = <2 6 0>;
|
||||
};
|
||||
|
||||
dma-controller@1200 {
|
||||
compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
|
||||
reg = <0x1200 0x80>;
|
||||
interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
|
||||
3 4 0 3 5 0 3 6 0 3 7 0
|
||||
3 8 0 3 9 0 3 10 0 3 11 0
|
||||
3 12 0 3 13 0 3 14 0 3 15 0>;
|
||||
};
|
||||
|
||||
xlb@1f00 {
|
||||
compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
|
||||
reg = <0x1f00 0x100>;
|
||||
};
|
||||
|
||||
serial@2000 { // PSC1
|
||||
psc@2000 { // PSC1
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2000 0x100>;
|
||||
interrupts = <2 1 0>;
|
||||
};
|
||||
|
||||
// PSC2 in spi master mode
|
||||
spi@2200 { // PSC2
|
||||
psc@2200 { // PSC2
|
||||
compatible = "fsl,mpc5200b-psc-spi","fsl,mpc5200-psc-spi";
|
||||
cell-index = <1>;
|
||||
reg = <0x2200 0x100>;
|
||||
interrupts = <2 2 0>;
|
||||
};
|
||||
|
||||
// PSC5 in uart mode
|
||||
serial@2800 { // PSC5
|
||||
psc@2400 { // PSC3
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2600 { // PSC4
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2800 { // PSC5
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2800 0x100>;
|
||||
interrupts = <2 12 0>;
|
||||
};
|
||||
|
||||
psc@2c00 { // PSC6
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
ethernet@3000 {
|
||||
compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
|
||||
reg = <0x3000 0x400>;
|
||||
local-mac-address = [ 00 00 00 00 00 00 ];
|
||||
interrupts = <2 5 0>;
|
||||
phy-handle = <&phy0>;
|
||||
};
|
||||
|
||||
mdio@3000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
|
||||
reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
|
||||
interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
|
||||
|
||||
phy0: ethernet-phy@2 {
|
||||
reg = <2>;
|
||||
};
|
||||
};
|
||||
|
||||
ata@3a00 {
|
||||
compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
|
||||
reg = <0x3a00 0x100>;
|
||||
interrupts = <2 7 0>;
|
||||
i2c@3d00 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
i2c@3d40 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d40 0x40>;
|
||||
interrupts = <2 16 0>;
|
||||
|
||||
rtc@68 {
|
||||
compatible = "dallas,ds1339";
|
||||
reg = <0x68>;
|
||||
@ -235,10 +89,11 @@
|
||||
};
|
||||
};
|
||||
|
||||
pci@f0000d00 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
localbus {
|
||||
compatible = "fsl,mpc5200b-lpb","simple-bus";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <1>;
|
||||
ranges = <0 0 0xff000000 0x01000000
|
||||
1 0 0x50000000 0x00010000
|
||||
2 0 0x50010000 0x00010000
|
||||
@ -280,5 +135,6 @@
|
||||
#size-cells = <1>;
|
||||
#address-cells = <1>;
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
275
arch/powerpc/boot/dts/mpc5200b.dtsi
Normal file
275
arch/powerpc/boot/dts/mpc5200b.dtsi
Normal file
@ -0,0 +1,275 @@
|
||||
/*
|
||||
* base MPC5200b Device Tree Source
|
||||
*
|
||||
* Copyright (C) 2010 SecretLab
|
||||
* Grant Likely <grant@secretlab.ca>
|
||||
* John Bonesio <bones@secretlab.ca>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
/ {
|
||||
model = "fsl,mpc5200b";
|
||||
compatible = "fsl,mpc5200b";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
interrupt-parent = <&mpc5200_pic>;
|
||||
|
||||
cpus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
powerpc: PowerPC,5200@0 {
|
||||
device_type = "cpu";
|
||||
reg = <0>;
|
||||
d-cache-line-size = <32>;
|
||||
i-cache-line-size = <32>;
|
||||
d-cache-size = <0x4000>; // L1, 16K
|
||||
i-cache-size = <0x4000>; // L1, 16K
|
||||
timebase-frequency = <0>; // from bootloader
|
||||
bus-frequency = <0>; // from bootloader
|
||||
clock-frequency = <0>; // from bootloader
|
||||
};
|
||||
};
|
||||
|
||||
memory: memory {
|
||||
device_type = "memory";
|
||||
reg = <0x00000000 0x04000000>; // 64MB
|
||||
};
|
||||
|
||||
soc: soc5200@f0000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
compatible = "fsl,mpc5200b-immr";
|
||||
ranges = <0 0xf0000000 0x0000c000>;
|
||||
reg = <0xf0000000 0x00000100>;
|
||||
bus-frequency = <0>; // from bootloader
|
||||
system-frequency = <0>; // from bootloader
|
||||
|
||||
cdm@200 {
|
||||
compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
|
||||
reg = <0x200 0x38>;
|
||||
};
|
||||
|
||||
mpc5200_pic: interrupt-controller@500 {
|
||||
// 5200 interrupts are encoded into two levels;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <3>;
|
||||
compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
|
||||
reg = <0x500 0x80>;
|
||||
};
|
||||
|
||||
timer@600 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x600 0x10>;
|
||||
interrupts = <1 9 0>;
|
||||
};
|
||||
|
||||
timer@610 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x610 0x10>;
|
||||
interrupts = <1 10 0>;
|
||||
};
|
||||
|
||||
timer@620 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x620 0x10>;
|
||||
interrupts = <1 11 0>;
|
||||
};
|
||||
|
||||
timer@630 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x630 0x10>;
|
||||
interrupts = <1 12 0>;
|
||||
};
|
||||
|
||||
timer@640 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x640 0x10>;
|
||||
interrupts = <1 13 0>;
|
||||
};
|
||||
|
||||
timer@650 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x650 0x10>;
|
||||
interrupts = <1 14 0>;
|
||||
};
|
||||
|
||||
timer@660 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x660 0x10>;
|
||||
interrupts = <1 15 0>;
|
||||
};
|
||||
|
||||
timer@670 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x670 0x10>;
|
||||
interrupts = <1 16 0>;
|
||||
};
|
||||
|
||||
rtc@800 { // Real time clock
|
||||
compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
|
||||
reg = <0x800 0x100>;
|
||||
interrupts = <1 5 0 1 6 0>;
|
||||
};
|
||||
|
||||
can@900 {
|
||||
compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
|
||||
interrupts = <2 17 0>;
|
||||
reg = <0x900 0x80>;
|
||||
};
|
||||
|
||||
can@980 {
|
||||
compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
|
||||
interrupts = <2 18 0>;
|
||||
reg = <0x980 0x80>;
|
||||
};
|
||||
|
||||
gpio_simple: gpio@b00 {
|
||||
compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
|
||||
reg = <0xb00 0x40>;
|
||||
interrupts = <1 7 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpio_wkup: gpio@c00 {
|
||||
compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
|
||||
reg = <0xc00 0x40>;
|
||||
interrupts = <1 8 0 0 3 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
spi@f00 {
|
||||
compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
|
||||
reg = <0xf00 0x20>;
|
||||
interrupts = <2 13 0 2 14 0>;
|
||||
};
|
||||
|
||||
usb: usb@1000 {
|
||||
compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
|
||||
reg = <0x1000 0xff>;
|
||||
interrupts = <2 6 0>;
|
||||
};
|
||||
|
||||
dma-controller@1200 {
|
||||
compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
|
||||
reg = <0x1200 0x80>;
|
||||
interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
|
||||
3 4 0 3 5 0 3 6 0 3 7 0
|
||||
3 8 0 3 9 0 3 10 0 3 11 0
|
||||
3 12 0 3 13 0 3 14 0 3 15 0>;
|
||||
};
|
||||
|
||||
xlb@1f00 {
|
||||
compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
|
||||
reg = <0x1f00 0x100>;
|
||||
};
|
||||
|
||||
psc1: psc@2000 { // PSC1
|
||||
compatible = "fsl,mpc5200b-psc","fsl,mpc5200-psc";
|
||||
reg = <0x2000 0x100>;
|
||||
interrupts = <2 1 0>;
|
||||
};
|
||||
|
||||
psc2: psc@2200 { // PSC2
|
||||
compatible = "fsl,mpc5200b-psc","fsl,mpc5200-psc";
|
||||
reg = <0x2200 0x100>;
|
||||
interrupts = <2 2 0>;
|
||||
};
|
||||
|
||||
psc3: psc@2400 { // PSC3
|
||||
compatible = "fsl,mpc5200b-psc","fsl,mpc5200-psc";
|
||||
reg = <0x2400 0x100>;
|
||||
interrupts = <2 3 0>;
|
||||
};
|
||||
|
||||
psc4: psc@2600 { // PSC4
|
||||
compatible = "fsl,mpc5200b-psc","fsl,mpc5200-psc";
|
||||
reg = <0x2600 0x100>;
|
||||
interrupts = <2 11 0>;
|
||||
};
|
||||
|
||||
psc5: psc@2800 { // PSC5
|
||||
compatible = "fsl,mpc5200b-psc","fsl,mpc5200-psc";
|
||||
reg = <0x2800 0x100>;
|
||||
interrupts = <2 12 0>;
|
||||
};
|
||||
|
||||
psc6: psc@2c00 { // PSC6
|
||||
compatible = "fsl,mpc5200b-psc","fsl,mpc5200-psc";
|
||||
reg = <0x2c00 0x100>;
|
||||
interrupts = <2 4 0>;
|
||||
};
|
||||
|
||||
eth0: ethernet@3000 {
|
||||
compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
|
||||
reg = <0x3000 0x400>;
|
||||
local-mac-address = [ 00 00 00 00 00 00 ];
|
||||
interrupts = <2 5 0>;
|
||||
};
|
||||
|
||||
mdio@3000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
|
||||
reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
|
||||
interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
|
||||
};
|
||||
|
||||
ata@3a00 {
|
||||
compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
|
||||
reg = <0x3a00 0x100>;
|
||||
interrupts = <2 7 0>;
|
||||
};
|
||||
|
||||
i2c@3d00 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d00 0x40>;
|
||||
interrupts = <2 15 0>;
|
||||
};
|
||||
|
||||
i2c@3d40 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d40 0x40>;
|
||||
interrupts = <2 16 0>;
|
||||
};
|
||||
|
||||
sram@8000 {
|
||||
compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
|
||||
reg = <0x8000 0x4000>;
|
||||
};
|
||||
};
|
||||
|
||||
pci: pci@f0000d00 {
|
||||
#interrupt-cells = <1>;
|
||||
#size-cells = <2>;
|
||||
#address-cells = <3>;
|
||||
device_type = "pci";
|
||||
compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
|
||||
reg = <0xf0000d00 0x100>;
|
||||
// interrupt-map-mask = need to add
|
||||
// interrupt-map = need to add
|
||||
clock-frequency = <0>; // From boot loader
|
||||
interrupts = <2 8 0 2 9 0 2 10 0>;
|
||||
bus-range = <0 0>;
|
||||
// ranges = need to add
|
||||
};
|
||||
|
||||
localbus: localbus {
|
||||
compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <1>;
|
||||
ranges = <0 0 0xfc000000 0x2000000>;
|
||||
};
|
||||
};
|
@ -11,172 +11,109 @@
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/include/ "mpc5200b.dtsi"
|
||||
|
||||
/ {
|
||||
model = "manroland,mucmc52";
|
||||
compatible = "manroland,mucmc52";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
interrupt-parent = <&mpc5200_pic>;
|
||||
|
||||
cpus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
PowerPC,5200@0 {
|
||||
device_type = "cpu";
|
||||
reg = <0>;
|
||||
d-cache-line-size = <32>;
|
||||
i-cache-line-size = <32>;
|
||||
d-cache-size = <0x4000>; // L1, 16K
|
||||
i-cache-size = <0x4000>; // L1, 16K
|
||||
timebase-frequency = <0>; // from bootloader
|
||||
bus-frequency = <0>; // from bootloader
|
||||
clock-frequency = <0>; // from bootloader
|
||||
};
|
||||
};
|
||||
|
||||
memory {
|
||||
device_type = "memory";
|
||||
reg = <0x00000000 0x04000000>; // 64MB
|
||||
};
|
||||
|
||||
soc5200@f0000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
compatible = "fsl,mpc5200b-immr";
|
||||
ranges = <0 0xf0000000 0x0000c000>;
|
||||
reg = <0xf0000000 0x00000100>;
|
||||
bus-frequency = <0>; // from bootloader
|
||||
system-frequency = <0>; // from bootloader
|
||||
|
||||
cdm@200 {
|
||||
compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
|
||||
reg = <0x200 0x38>;
|
||||
};
|
||||
|
||||
mpc5200_pic: interrupt-controller@500 {
|
||||
// 5200 interrupts are encoded into two levels;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <3>;
|
||||
compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
|
||||
reg = <0x500 0x80>;
|
||||
};
|
||||
|
||||
gpt0: timer@600 { // GPT 0 in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x600 0x10>;
|
||||
interrupts = <1 9 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt1: timer@610 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x610 0x10>;
|
||||
interrupts = <1 10 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt2: timer@620 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x620 0x10>;
|
||||
interrupts = <1 11 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt3: timer@630 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x630 0x10>;
|
||||
interrupts = <1 12 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpio_simple: gpio@b00 {
|
||||
compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
|
||||
reg = <0xb00 0x40>;
|
||||
interrupts = <1 7 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
timer@640 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
gpio_wkup: gpio@c00 {
|
||||
compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
|
||||
reg = <0xc00 0x40>;
|
||||
interrupts = <1 8 0 0 3 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
timer@650 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
dma-controller@1200 {
|
||||
compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
|
||||
reg = <0x1200 0x80>;
|
||||
interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
|
||||
3 4 0 3 5 0 3 6 0 3 7 0
|
||||
3 8 0 3 9 0 3 10 0 3 11 0
|
||||
3 12 0 3 13 0 3 14 0 3 15 0>;
|
||||
timer@660 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
xlb@1f00 {
|
||||
compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
|
||||
reg = <0x1f00 0x100>;
|
||||
timer@670 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
serial@2000 { /* PSC1 in UART mode */
|
||||
rtc@800 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
can@900 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
can@980 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
spi@f00 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
usb@1000 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2000 { // PSC1
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2000 0x100>;
|
||||
interrupts = <2 1 0>;
|
||||
};
|
||||
|
||||
serial@2200 { /* PSC2 in UART mode */
|
||||
psc@2200 { // PSC2
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2200 0x100>;
|
||||
interrupts = <2 2 0>;
|
||||
};
|
||||
|
||||
serial@2c00 { /* PSC6 in UART mode */
|
||||
psc@2400 { // PSC3
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2600 { // PSC4
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2800 { // PSC5
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2c00 { // PSC6
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2c00 0x100>;
|
||||
interrupts = <2 4 0>;
|
||||
};
|
||||
|
||||
ethernet@3000 {
|
||||
compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
|
||||
reg = <0x3000 0x400>;
|
||||
local-mac-address = [ 00 00 00 00 00 00 ];
|
||||
interrupts = <2 5 0>;
|
||||
phy-handle = <&phy0>;
|
||||
};
|
||||
|
||||
mdio@3000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
|
||||
reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
|
||||
interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
|
||||
|
||||
phy0: ethernet-phy@0 {
|
||||
compatible = "intel,lxt971";
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
ata@3a00 {
|
||||
compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
|
||||
reg = <0x3a00 0x100>;
|
||||
interrupts = <2 7 0>;
|
||||
i2c@3d00 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
i2c@3d40 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d40 0x40>;
|
||||
interrupts = <2 16 0>;
|
||||
hwmon@2c {
|
||||
compatible = "ad,adm9240";
|
||||
reg = <0x2c>;
|
||||
@ -186,20 +123,9 @@
|
||||
reg = <0x51>;
|
||||
};
|
||||
};
|
||||
|
||||
sram@8000 {
|
||||
compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
|
||||
reg = <0x8000 0x4000>;
|
||||
};
|
||||
};
|
||||
|
||||
pci@f0000d00 {
|
||||
#interrupt-cells = <1>;
|
||||
#size-cells = <2>;
|
||||
#address-cells = <3>;
|
||||
device_type = "pci";
|
||||
compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
|
||||
reg = <0xf0000d00 0x100>;
|
||||
interrupt-map-mask = <0xf800 0 0 7>;
|
||||
interrupt-map = <
|
||||
/* IDSEL 0x10 */
|
||||
@ -208,20 +134,12 @@
|
||||
0x8000 0 0 3 &mpc5200_pic 0 2 3
|
||||
0x8000 0 0 4 &mpc5200_pic 0 1 3
|
||||
>;
|
||||
clock-frequency = <0>; // From boot loader
|
||||
interrupts = <2 8 0 2 9 0 2 10 0>;
|
||||
bus-range = <0 0>;
|
||||
ranges = <0x42000000 0 0x60000000 0x60000000 0 0x10000000
|
||||
0x02000000 0 0x90000000 0x90000000 0 0x10000000
|
||||
0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
|
||||
};
|
||||
|
||||
localbus {
|
||||
compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus";
|
||||
|
||||
#address-cells = <2>;
|
||||
#size-cells = <1>;
|
||||
|
||||
ranges = <0 0 0xff800000 0x00800000
|
||||
1 0 0x80000000 0x00800000
|
||||
3 0 0x80000000 0x00800000>;
|
||||
|
@ -12,246 +12,92 @@
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/include/ "mpc5200b.dtsi"
|
||||
|
||||
/ {
|
||||
model = "phytec,pcm030";
|
||||
compatible = "phytec,pcm030";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
interrupt-parent = <&mpc5200_pic>;
|
||||
|
||||
cpus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
PowerPC,5200@0 {
|
||||
device_type = "cpu";
|
||||
reg = <0>;
|
||||
d-cache-line-size = <32>;
|
||||
i-cache-line-size = <32>;
|
||||
d-cache-size = <0x4000>; // L1, 16K
|
||||
i-cache-size = <0x4000>; // L1, 16K
|
||||
timebase-frequency = <0>; // from bootloader
|
||||
bus-frequency = <0>; // from bootloader
|
||||
clock-frequency = <0>; // from bootloader
|
||||
};
|
||||
};
|
||||
|
||||
memory {
|
||||
device_type = "memory";
|
||||
reg = <0x00000000 0x04000000>; // 64MB
|
||||
};
|
||||
|
||||
soc5200@f0000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
compatible = "fsl,mpc5200b-immr";
|
||||
ranges = <0 0xf0000000 0x0000c000>;
|
||||
bus-frequency = <0>; // from bootloader
|
||||
system-frequency = <0>; // from bootloader
|
||||
|
||||
cdm@200 {
|
||||
compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
|
||||
reg = <0x200 0x38>;
|
||||
};
|
||||
|
||||
mpc5200_pic: interrupt-controller@500 {
|
||||
// 5200 interrupts are encoded into two levels;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <3>;
|
||||
compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
|
||||
reg = <0x500 0x80>;
|
||||
};
|
||||
|
||||
timer@600 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x600 0x10>;
|
||||
interrupts = <1 9 0>;
|
||||
timer@600 { // General Purpose Timer
|
||||
fsl,has-wdt;
|
||||
};
|
||||
|
||||
timer@610 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x610 0x10>;
|
||||
interrupts = <1 10 0>;
|
||||
};
|
||||
|
||||
gpt2: timer@620 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
|
||||
reg = <0x620 0x10>;
|
||||
interrupts = <1 11 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt3: timer@630 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
|
||||
reg = <0x630 0x10>;
|
||||
interrupts = <1 12 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt4: timer@640 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
|
||||
reg = <0x640 0x10>;
|
||||
interrupts = <1 13 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt5: timer@650 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
|
||||
reg = <0x650 0x10>;
|
||||
interrupts = <1 14 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt6: timer@660 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
|
||||
reg = <0x660 0x10>;
|
||||
interrupts = <1 15 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt7: timer@670 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
|
||||
reg = <0x670 0x10>;
|
||||
interrupts = <1 16 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
rtc@800 { // Real time clock
|
||||
compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
|
||||
reg = <0x800 0x100>;
|
||||
interrupts = <1 5 0 1 6 0>;
|
||||
};
|
||||
|
||||
can@900 {
|
||||
compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
|
||||
interrupts = <2 17 0>;
|
||||
reg = <0x900 0x80>;
|
||||
};
|
||||
|
||||
can@980 {
|
||||
compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
|
||||
interrupts = <2 18 0>;
|
||||
reg = <0x980 0x80>;
|
||||
};
|
||||
|
||||
gpio_simple: gpio@b00 {
|
||||
compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
|
||||
reg = <0xb00 0x40>;
|
||||
interrupts = <1 7 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpio_wkup: gpio@c00 {
|
||||
compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
|
||||
reg = <0xc00 0x40>;
|
||||
interrupts = <1 8 0 0 3 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
spi@f00 {
|
||||
compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
|
||||
reg = <0xf00 0x20>;
|
||||
interrupts = <2 13 0 2 14 0>;
|
||||
};
|
||||
|
||||
usb@1000 {
|
||||
compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
|
||||
reg = <0x1000 0xff>;
|
||||
interrupts = <2 6 0>;
|
||||
};
|
||||
|
||||
dma-controller@1200 {
|
||||
compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
|
||||
reg = <0x1200 0x80>;
|
||||
interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
|
||||
3 4 0 3 5 0 3 6 0 3 7 0
|
||||
3 8 0 3 9 0 3 10 0 3 11 0
|
||||
3 12 0 3 13 0 3 14 0 3 15 0>;
|
||||
};
|
||||
|
||||
xlb@1f00 {
|
||||
compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
|
||||
reg = <0x1f00 0x100>;
|
||||
};
|
||||
|
||||
ac97@2000 { /* PSC1 in ac97 mode */
|
||||
psc@2000 { /* PSC1 in ac97 mode */
|
||||
compatible = "mpc5200b-psc-ac97","fsl,mpc5200b-psc-ac97";
|
||||
cell-index = <0>;
|
||||
reg = <0x2000 0x100>;
|
||||
interrupts = <2 1 0>;
|
||||
};
|
||||
|
||||
/* PSC2 port is used by CAN1/2 */
|
||||
psc@2200 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
serial@2400 { /* PSC3 in UART mode */
|
||||
psc@2400 { /* PSC3 in UART mode */
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
cell-index = <2>;
|
||||
reg = <0x2400 0x100>;
|
||||
interrupts = <2 3 0>;
|
||||
};
|
||||
|
||||
/* PSC4 is ??? */
|
||||
psc@2600 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
/* PSC5 is ??? */
|
||||
psc@2800 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
serial@2c00 { /* PSC6 in UART mode */
|
||||
psc@2c00 { /* PSC6 in UART mode */
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
cell-index = <5>;
|
||||
reg = <0x2c00 0x100>;
|
||||
interrupts = <2 4 0>;
|
||||
};
|
||||
|
||||
ethernet@3000 {
|
||||
compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
|
||||
reg = <0x3000 0x400>;
|
||||
local-mac-address = [ 00 00 00 00 00 00 ];
|
||||
interrupts = <2 5 0>;
|
||||
phy-handle = <&phy0>;
|
||||
};
|
||||
|
||||
mdio@3000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
|
||||
reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
|
||||
interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
|
||||
|
||||
phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
ata@3a00 {
|
||||
compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
|
||||
reg = <0x3a00 0x100>;
|
||||
interrupts = <2 7 0>;
|
||||
};
|
||||
|
||||
i2c@3d00 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d00 0x40>;
|
||||
interrupts = <2 15 0>;
|
||||
};
|
||||
|
||||
i2c@3d40 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d40 0x40>;
|
||||
interrupts = <2 16 0>;
|
||||
rtc@51 {
|
||||
compatible = "nxp,pcf8563";
|
||||
reg = <0x51>;
|
||||
@ -259,6 +105,7 @@
|
||||
eeprom@52 {
|
||||
compatible = "catalyst,24c32";
|
||||
reg = <0x52>;
|
||||
pagesize = <32>;
|
||||
};
|
||||
};
|
||||
|
||||
@ -269,12 +116,6 @@
|
||||
};
|
||||
|
||||
pci@f0000d00 {
|
||||
#interrupt-cells = <1>;
|
||||
#size-cells = <2>;
|
||||
#address-cells = <3>;
|
||||
device_type = "pci";
|
||||
compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
|
||||
reg = <0xf0000d00 0x100>;
|
||||
interrupt-map-mask = <0xf800 0 0 7>;
|
||||
interrupt-map = <0xc000 0 0 1 &mpc5200_pic 0 0 3 // 1st slot
|
||||
0xc000 0 0 2 &mpc5200_pic 1 1 3
|
||||
@ -285,11 +126,12 @@
|
||||
0xc800 0 0 2 &mpc5200_pic 1 2 3
|
||||
0xc800 0 0 3 &mpc5200_pic 1 3 3
|
||||
0xc800 0 0 4 &mpc5200_pic 0 0 3>;
|
||||
clock-frequency = <0>; // From boot loader
|
||||
interrupts = <2 8 0 2 9 0 2 10 0>;
|
||||
bus-range = <0 0>;
|
||||
ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
|
||||
0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
|
||||
0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
|
||||
};
|
||||
|
||||
localbus {
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
|
@ -12,99 +12,37 @@
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/include/ "mpc5200b.dtsi"
|
||||
|
||||
/ {
|
||||
model = "phytec,pcm032";
|
||||
compatible = "phytec,pcm032";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
interrupt-parent = <&mpc5200_pic>;
|
||||
|
||||
cpus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
PowerPC,5200@0 {
|
||||
device_type = "cpu";
|
||||
reg = <0>;
|
||||
d-cache-line-size = <32>;
|
||||
i-cache-line-size = <32>;
|
||||
d-cache-size = <0x4000>; // L1, 16K
|
||||
i-cache-size = <0x4000>; // L1, 16K
|
||||
timebase-frequency = <0>; // from bootloader
|
||||
bus-frequency = <0>; // from bootloader
|
||||
clock-frequency = <0>; // from bootloader
|
||||
};
|
||||
};
|
||||
|
||||
memory {
|
||||
device_type = "memory";
|
||||
reg = <0x00000000 0x08000000>; // 128MB
|
||||
};
|
||||
|
||||
soc5200@f0000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
compatible = "fsl,mpc5200b-immr";
|
||||
ranges = <0 0xf0000000 0x0000c000>;
|
||||
bus-frequency = <0>; // from bootloader
|
||||
system-frequency = <0>; // from bootloader
|
||||
|
||||
cdm@200 {
|
||||
compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
|
||||
reg = <0x200 0x38>;
|
||||
};
|
||||
|
||||
mpc5200_pic: interrupt-controller@500 {
|
||||
// 5200 interrupts are encoded into two levels;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <3>;
|
||||
compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
|
||||
reg = <0x500 0x80>;
|
||||
};
|
||||
|
||||
timer@600 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x600 0x10>;
|
||||
interrupts = <1 9 0>;
|
||||
timer@600 { // General Purpose Timer
|
||||
fsl,has-wdt;
|
||||
};
|
||||
|
||||
timer@610 { // General Purpose Timer
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x610 0x10>;
|
||||
interrupts = <1 10 0>;
|
||||
};
|
||||
|
||||
gpt2: timer@620 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x620 0x10>;
|
||||
interrupts = <1 11 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt3: timer@630 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x630 0x10>;
|
||||
interrupts = <1 12 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt4: timer@640 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x640 0x10>;
|
||||
interrupts = <1 13 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt5: timer@650 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x650 0x10>;
|
||||
interrupts = <1 14 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
@ -118,163 +56,62 @@
|
||||
};
|
||||
|
||||
gpt7: timer@670 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x670 0x10>;
|
||||
interrupts = <1 16 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
rtc@800 { // Real time clock
|
||||
compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
|
||||
reg = <0x800 0x100>;
|
||||
interrupts = <1 5 0 1 6 0>;
|
||||
};
|
||||
|
||||
can@900 {
|
||||
compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
|
||||
interrupts = <2 17 0>;
|
||||
reg = <0x900 0x80>;
|
||||
};
|
||||
|
||||
can@980 {
|
||||
compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
|
||||
interrupts = <2 18 0>;
|
||||
reg = <0x980 0x80>;
|
||||
};
|
||||
|
||||
gpio_simple: gpio@b00 {
|
||||
compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
|
||||
reg = <0xb00 0x40>;
|
||||
interrupts = <1 7 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpio_wkup: gpio@c00 {
|
||||
compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
|
||||
reg = <0xc00 0x40>;
|
||||
interrupts = <1 8 0 0 3 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
spi@f00 {
|
||||
compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
|
||||
reg = <0xf00 0x20>;
|
||||
interrupts = <2 13 0 2 14 0>;
|
||||
};
|
||||
|
||||
usb@1000 {
|
||||
compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
|
||||
reg = <0x1000 0xff>;
|
||||
interrupts = <2 6 0>;
|
||||
};
|
||||
|
||||
dma-controller@1200 {
|
||||
compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
|
||||
reg = <0x1200 0x80>;
|
||||
interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
|
||||
3 4 0 3 5 0 3 6 0 3 7 0
|
||||
3 8 0 3 9 0 3 10 0 3 11 0
|
||||
3 12 0 3 13 0 3 14 0 3 15 0>;
|
||||
};
|
||||
|
||||
xlb@1f00 {
|
||||
compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
|
||||
reg = <0x1f00 0x100>;
|
||||
};
|
||||
|
||||
ac97@2000 { /* PSC1 is ac97 */
|
||||
psc@2000 { /* PSC1 is ac97 */
|
||||
compatible = "fsl,mpc5200b-psc-ac97","fsl,mpc5200-psc-ac97";
|
||||
cell-index = <0>;
|
||||
reg = <0x2000 0x100>;
|
||||
interrupts = <2 1 0>;
|
||||
};
|
||||
|
||||
/* PSC2 port is used by CAN1/2 */
|
||||
psc@2200 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
serial@2400 { /* PSC3 in UART mode */
|
||||
psc@2400 { /* PSC3 in UART mode */
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
cell-index = <2>;
|
||||
reg = <0x2400 0x100>;
|
||||
interrupts = <2 3 0>;
|
||||
};
|
||||
|
||||
/* PSC4 is ??? */
|
||||
psc@2600 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
/* PSC5 is ??? */
|
||||
psc@2800 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
serial@2c00 { /* PSC6 in UART mode */
|
||||
psc@2c00 { /* PSC6 in UART mode */
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
cell-index = <5>;
|
||||
reg = <0x2c00 0x100>;
|
||||
interrupts = <2 4 0>;
|
||||
};
|
||||
|
||||
ethernet@3000 {
|
||||
compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
|
||||
reg = <0x3000 0x400>;
|
||||
local-mac-address = [ 00 00 00 00 00 00 ];
|
||||
interrupts = <2 5 0>;
|
||||
phy-handle = <&phy0>;
|
||||
};
|
||||
|
||||
mdio@3000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
|
||||
reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
|
||||
interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
|
||||
|
||||
phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
ata@3a00 {
|
||||
compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
|
||||
reg = <0x3a00 0x100>;
|
||||
interrupts = <2 7 0>;
|
||||
};
|
||||
|
||||
i2c@3d00 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d00 0x40>;
|
||||
interrupts = <2 15 0>;
|
||||
};
|
||||
|
||||
i2c@3d40 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d40 0x40>;
|
||||
interrupts = <2 16 0>;
|
||||
rtc@51 {
|
||||
compatible = "nxp,pcf8563";
|
||||
reg = <0x51>;
|
||||
};
|
||||
eeprom@52 {
|
||||
compatible = "at24,24c32";
|
||||
compatible = "catalyst,24c32";
|
||||
reg = <0x52>;
|
||||
pagesize = <32>;
|
||||
};
|
||||
};
|
||||
|
||||
sram@8000 {
|
||||
compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
|
||||
reg = <0x8000 0x4000>;
|
||||
};
|
||||
};
|
||||
|
||||
pci@f0000d00 {
|
||||
#interrupt-cells = <1>;
|
||||
#size-cells = <2>;
|
||||
#address-cells = <3>;
|
||||
device_type = "pci";
|
||||
compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
|
||||
reg = <0xf0000d00 0x100>;
|
||||
interrupt-map-mask = <0xf800 0 0 7>;
|
||||
interrupt-map = <0xc000 0 0 1 &mpc5200_pic 0 0 3 // 1st slot
|
||||
0xc000 0 0 2 &mpc5200_pic 1 1 3
|
||||
@ -285,20 +122,12 @@
|
||||
0xc800 0 0 2 &mpc5200_pic 1 2 3
|
||||
0xc800 0 0 3 &mpc5200_pic 1 3 3
|
||||
0xc800 0 0 4 &mpc5200_pic 0 0 3>;
|
||||
clock-frequency = <0>; // From boot loader
|
||||
interrupts = <2 8 0 2 9 0 2 10 0>;
|
||||
bus-range = <0 0>;
|
||||
ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
|
||||
0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
|
||||
0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
|
||||
};
|
||||
|
||||
localbus {
|
||||
compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus";
|
||||
|
||||
#address-cells = <2>;
|
||||
#size-cells = <1>;
|
||||
|
||||
ranges = <0 0 0xfe000000 0x02000000
|
||||
1 0 0xfc000000 0x02000000
|
||||
2 0 0xfbe00000 0x00200000
|
||||
@ -351,40 +180,39 @@
|
||||
bank-width = <2>;
|
||||
};
|
||||
|
||||
/*
|
||||
/*
|
||||
* example snippets for FPGA
|
||||
*
|
||||
* fpga@3,0 {
|
||||
* compatible = "fpga_driver";
|
||||
* reg = <3 0 0x02000000>;
|
||||
* bank-width = <4>;
|
||||
* compatible = "fpga_driver";
|
||||
* reg = <3 0 0x02000000>;
|
||||
* bank-width = <4>;
|
||||
* };
|
||||
*
|
||||
* fpga@4,0 {
|
||||
* compatible = "fpga_driver";
|
||||
* reg = <4 0 0x02000000>;
|
||||
* bank-width = <4>;
|
||||
* compatible = "fpga_driver";
|
||||
* reg = <4 0 0x02000000>;
|
||||
* bank-width = <4>;
|
||||
* };
|
||||
*/
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* example snippets for free chipselects
|
||||
*
|
||||
*
|
||||
* device@5,0 {
|
||||
* compatible = "custom_driver";
|
||||
* reg = <5 0 0x02000000>;
|
||||
* compatible = "custom_driver";
|
||||
* reg = <5 0 0x02000000>;
|
||||
* };
|
||||
*
|
||||
*
|
||||
* device@6,0 {
|
||||
* compatible = "custom_driver";
|
||||
* reg = <6 0 0x02000000>;
|
||||
* compatible = "custom_driver";
|
||||
* reg = <6 0 0x02000000>;
|
||||
* };
|
||||
*
|
||||
*
|
||||
* device@7,0 {
|
||||
* compatible = "custom_driver";
|
||||
* reg = <7 0 0x02000000>;
|
||||
* compatible = "custom_driver";
|
||||
* reg = <7 0 0x02000000>;
|
||||
* };
|
||||
*/
|
||||
*/
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -11,79 +11,24 @@
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/include/ "mpc5200b.dtsi"
|
||||
|
||||
/ {
|
||||
model = "manroland,uc101";
|
||||
compatible = "manroland,uc101";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
interrupt-parent = <&mpc5200_pic>;
|
||||
|
||||
cpus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
PowerPC,5200@0 {
|
||||
device_type = "cpu";
|
||||
reg = <0>;
|
||||
d-cache-line-size = <32>;
|
||||
i-cache-line-size = <32>;
|
||||
d-cache-size = <0x4000>; // L1, 16K
|
||||
i-cache-size = <0x4000>; // L1, 16K
|
||||
timebase-frequency = <0>; // from bootloader
|
||||
bus-frequency = <0>; // from bootloader
|
||||
clock-frequency = <0>; // from bootloader
|
||||
};
|
||||
};
|
||||
|
||||
memory {
|
||||
device_type = "memory";
|
||||
reg = <0x00000000 0x04000000>; // 64MB
|
||||
};
|
||||
|
||||
soc5200@f0000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
compatible = "fsl,mpc5200b-immr";
|
||||
ranges = <0 0xf0000000 0x0000c000>;
|
||||
reg = <0xf0000000 0x00000100>;
|
||||
bus-frequency = <0>; // from bootloader
|
||||
system-frequency = <0>; // from bootloader
|
||||
|
||||
cdm@200 {
|
||||
compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
|
||||
reg = <0x200 0x38>;
|
||||
};
|
||||
|
||||
mpc5200_pic: interrupt-controller@500 {
|
||||
// 5200 interrupts are encoded into two levels;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <3>;
|
||||
compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
|
||||
reg = <0x500 0x80>;
|
||||
};
|
||||
|
||||
gpt0: timer@600 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x600 0x10>;
|
||||
interrupts = <1 9 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt1: timer@610 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x610 0x10>;
|
||||
interrupts = <1 10 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt2: timer@620 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x620 0x10>;
|
||||
interrupts = <1 11 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
@ -97,118 +42,85 @@
|
||||
};
|
||||
|
||||
gpt4: timer@640 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x640 0x10>;
|
||||
interrupts = <1 13 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt5: timer@650 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x650 0x10>;
|
||||
interrupts = <1 14 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt6: timer@660 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x660 0x10>;
|
||||
interrupts = <1 15 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpt7: timer@670 { // General Purpose Timer in GPIO mode
|
||||
compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
|
||||
reg = <0x670 0x10>;
|
||||
interrupts = <1 16 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
|
||||
gpio_simple: gpio@b00 {
|
||||
compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
|
||||
reg = <0xb00 0x40>;
|
||||
interrupts = <1 7 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
rtc@800 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
gpio_wkup: gpio@c00 {
|
||||
compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
|
||||
reg = <0xc00 0x40>;
|
||||
interrupts = <1 8 0 0 3 0>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
can@900 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
dma-controller@1200 {
|
||||
compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
|
||||
reg = <0x1200 0x80>;
|
||||
interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
|
||||
3 4 0 3 5 0 3 6 0 3 7 0
|
||||
3 8 0 3 9 0 3 10 0 3 11 0
|
||||
3 12 0 3 13 0 3 14 0 3 15 0>;
|
||||
can@980 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
xlb@1f00 {
|
||||
compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
|
||||
reg = <0x1f00 0x100>;
|
||||
spi@f00 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
serial@2000 { /* PSC1 in UART mode */
|
||||
usb@1000 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2000 { // PSC1
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2000 0x100>;
|
||||
interrupts = <2 1 0>;
|
||||
};
|
||||
|
||||
serial@2200 { /* PSC2 in UART mode */
|
||||
psc@2200 { // PSC2
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2200 0x100>;
|
||||
interrupts = <2 2 0>;
|
||||
};
|
||||
|
||||
serial@2c00 { /* PSC6 in UART mode */
|
||||
psc@2400 { // PSC3
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2600 { // PSC4
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2800 { // PSC5
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
psc@2c00 { // PSC6
|
||||
compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
|
||||
reg = <0x2c00 0x100>;
|
||||
interrupts = <2 4 0>;
|
||||
};
|
||||
|
||||
ethernet@3000 {
|
||||
compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
|
||||
reg = <0x3000 0x400>;
|
||||
local-mac-address = [ 00 00 00 00 00 00 ];
|
||||
interrupts = <2 5 0>;
|
||||
phy-handle = <&phy0>;
|
||||
};
|
||||
|
||||
mdio@3000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
|
||||
reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
|
||||
interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
|
||||
|
||||
phy0: ethernet-phy@0 {
|
||||
compatible = "intel,lxt971";
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
ata@3a00 {
|
||||
compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
|
||||
reg = <0x3a00 0x100>;
|
||||
interrupts = <2 7 0>;
|
||||
i2c@3d00 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
i2c@3d40 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
|
||||
reg = <0x3d40 0x40>;
|
||||
interrupts = <2 16 0>;
|
||||
fsl,preserve-clocking;
|
||||
clock-frequency = <400000>;
|
||||
|
||||
@ -221,19 +133,13 @@
|
||||
reg = <0x51>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
sram@8000 {
|
||||
compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
|
||||
reg = <0x8000 0x4000>;
|
||||
};
|
||||
pci@f0000d00 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
localbus {
|
||||
compatible = "fsl,mpc5200b-lpb","fsl,mpc5200-lpb","simple-bus";
|
||||
|
||||
#address-cells = <2>;
|
||||
#size-cells = <1>;
|
||||
|
||||
ranges = <0 0 0xff800000 0x00800000
|
||||
1 0 0x80000000 0x00800000
|
||||
3 0 0x80000000 0x00800000>;
|
||||
|
@ -42,7 +42,7 @@ extern void pci_create_OF_bus_map(void);
|
||||
|
||||
/* Translate a DMA address from device space to CPU space */
|
||||
extern u64 of_translate_dma_address(struct device_node *dev,
|
||||
const u32 *in_addr);
|
||||
const __be32 *in_addr);
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
extern unsigned long pci_address_to_pio(phys_addr_t address);
|
||||
@ -63,9 +63,6 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
|
||||
/* cache lookup */
|
||||
struct device_node *of_find_next_cache_node(struct device_node *np);
|
||||
|
||||
/* Get the MAC address */
|
||||
extern const void *of_get_mac_address(struct device_node *np);
|
||||
|
||||
#ifdef CONFIG_NUMA
|
||||
extern int of_node_to_nid(struct device_node *device);
|
||||
#else
|
||||
|
@ -117,41 +117,3 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
|
||||
cells = prop ? *(u32 *)prop : of_n_size_cells(dn);
|
||||
*size = of_read_number(dma_window, cells);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the device tree for the best MAC address to use. 'mac-address' is
|
||||
* checked first, because that is supposed to contain to "most recent" MAC
|
||||
* address. If that isn't set, then 'local-mac-address' is checked next,
|
||||
* because that is the default address. If that isn't set, then the obsolete
|
||||
* 'address' is checked, just in case we're using an old device tree.
|
||||
*
|
||||
* Note that the 'address' property is supposed to contain a virtual address of
|
||||
* the register set, but some DTS files have redefined that property to be the
|
||||
* MAC address.
|
||||
*
|
||||
* All-zero MAC addresses are rejected, because those could be properties that
|
||||
* exist in the device tree, but were not set by U-Boot. For example, the
|
||||
* DTS could define 'mac-address' and 'local-mac-address', with zero MAC
|
||||
* addresses. Some older U-Boots only initialized 'local-mac-address'. In
|
||||
* this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
|
||||
* but is all zeros.
|
||||
*/
|
||||
const void *of_get_mac_address(struct device_node *np)
|
||||
{
|
||||
struct property *pp;
|
||||
|
||||
pp = of_find_property(np, "mac-address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
pp = of_find_property(np, "local-mac-address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
pp = of_find_property(np, "address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL(of_get_mac_address);
|
||||
|
@ -50,7 +50,7 @@ machine_device_initcall(ppc40x_simple, ppc40x_device_probe);
|
||||
* Again, if your board needs to do things differently then create a
|
||||
* board.c file for it rather than adding it to this list.
|
||||
*/
|
||||
static char *board[] __initdata = {
|
||||
static const char *board[] __initdata = {
|
||||
"amcc,acadia",
|
||||
"amcc,haleakala",
|
||||
"amcc,kilauea",
|
||||
@ -60,14 +60,9 @@ static char *board[] __initdata = {
|
||||
|
||||
static int __init ppc40x_probe(void)
|
||||
{
|
||||
unsigned long root = of_get_flat_dt_root();
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(board); i++) {
|
||||
if (of_flat_dt_is_compatible(root, board[i])) {
|
||||
ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
|
||||
return 1;
|
||||
}
|
||||
if (of_flat_dt_match(of_get_flat_dt_root(), board)) {
|
||||
ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -26,7 +26,7 @@
|
||||
/*
|
||||
* list of supported boards
|
||||
*/
|
||||
static char *board[] __initdata = {
|
||||
static const char *board[] __initdata = {
|
||||
"prt,prtlvt",
|
||||
NULL
|
||||
};
|
||||
@ -36,16 +36,7 @@ static char *board[] __initdata = {
|
||||
*/
|
||||
static int __init mpc5121_generic_probe(void)
|
||||
{
|
||||
unsigned long node = of_get_flat_dt_root();
|
||||
int i = 0;
|
||||
|
||||
while (board[i]) {
|
||||
if (of_flat_dt_is_compatible(node, board[i]))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
return board[i] != NULL;
|
||||
return of_flat_dt_match(of_get_flat_dt_root(), board);
|
||||
}
|
||||
|
||||
define_machine(mpc5121_generic) {
|
||||
|
@ -172,20 +172,18 @@ static void __init lite5200_setup_arch(void)
|
||||
mpc52xx_setup_pci();
|
||||
}
|
||||
|
||||
static const char *board[] __initdata = {
|
||||
"fsl,lite5200",
|
||||
"fsl,lite5200b",
|
||||
NULL,
|
||||
};
|
||||
|
||||
/*
|
||||
* Called very early, MMU is off, device-tree isn't unflattened
|
||||
*/
|
||||
static int __init lite5200_probe(void)
|
||||
{
|
||||
unsigned long node = of_get_flat_dt_root();
|
||||
const char *model = of_get_flat_dt_prop(node, "model", NULL);
|
||||
|
||||
if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
|
||||
!of_flat_dt_is_compatible(node, "fsl,lite5200b"))
|
||||
return 0;
|
||||
pr_debug("%s board found\n", model ? model : "unknown");
|
||||
|
||||
return 1;
|
||||
return of_flat_dt_match(of_get_flat_dt_root(), board);
|
||||
}
|
||||
|
||||
define_machine(lite5200) {
|
||||
|
@ -239,7 +239,7 @@ static void __init media5200_setup_arch(void)
|
||||
}
|
||||
|
||||
/* list of the supported boards */
|
||||
static char *board[] __initdata = {
|
||||
static const char *board[] __initdata = {
|
||||
"fsl,media5200",
|
||||
NULL
|
||||
};
|
||||
@ -249,16 +249,7 @@ static char *board[] __initdata = {
|
||||
*/
|
||||
static int __init media5200_probe(void)
|
||||
{
|
||||
unsigned long node = of_get_flat_dt_root();
|
||||
int i = 0;
|
||||
|
||||
while (board[i]) {
|
||||
if (of_flat_dt_is_compatible(node, board[i]))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
return (board[i] != NULL);
|
||||
return of_flat_dt_match(of_get_flat_dt_root(), board);
|
||||
}
|
||||
|
||||
define_machine(media5200_platform) {
|
||||
|
@ -49,7 +49,7 @@ static void __init mpc5200_simple_setup_arch(void)
|
||||
}
|
||||
|
||||
/* list of the supported boards */
|
||||
static char *board[] __initdata = {
|
||||
static const char *board[] __initdata = {
|
||||
"intercontrol,digsy-mtc",
|
||||
"manroland,mucmc52",
|
||||
"manroland,uc101",
|
||||
@ -66,16 +66,7 @@ static char *board[] __initdata = {
|
||||
*/
|
||||
static int __init mpc5200_simple_probe(void)
|
||||
{
|
||||
unsigned long node = of_get_flat_dt_root();
|
||||
int i = 0;
|
||||
|
||||
while (board[i]) {
|
||||
if (of_flat_dt_is_compatible(node, board[i]))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
return (board[i] != NULL);
|
||||
return of_flat_dt_match(of_get_flat_dt_root(), board);
|
||||
}
|
||||
|
||||
define_machine(mpc5200_simple_platform) {
|
||||
|
@ -57,16 +57,19 @@ static void __init mpc830x_rdb_init_IRQ(void)
|
||||
ipic_set_default_priority();
|
||||
}
|
||||
|
||||
struct const char *board[] __initdata = {
|
||||
"MPC8308RDB",
|
||||
"fsl,mpc8308rdb",
|
||||
"denx,mpc8308_p1m",
|
||||
NULL
|
||||
}
|
||||
|
||||
/*
|
||||
* Called very early, MMU is off, device-tree isn't unflattened
|
||||
*/
|
||||
static int __init mpc830x_rdb_probe(void)
|
||||
{
|
||||
unsigned long root = of_get_flat_dt_root();
|
||||
|
||||
return of_flat_dt_is_compatible(root, "MPC8308RDB") ||
|
||||
of_flat_dt_is_compatible(root, "fsl,mpc8308rdb") ||
|
||||
of_flat_dt_is_compatible(root, "denx,mpc8308_p1m");
|
||||
return of_flat_dt_match(of_get_flat_dt_root(), board);
|
||||
}
|
||||
|
||||
static struct of_device_id __initdata of_bus_ids[] = {
|
||||
|
@ -60,15 +60,18 @@ static void __init mpc831x_rdb_init_IRQ(void)
|
||||
ipic_set_default_priority();
|
||||
}
|
||||
|
||||
struct const char *board[] __initdata = {
|
||||
"MPC8313ERDB",
|
||||
"fsl,mpc8315erdb",
|
||||
NULL
|
||||
}
|
||||
|
||||
/*
|
||||
* Called very early, MMU is off, device-tree isn't unflattened
|
||||
*/
|
||||
static int __init mpc831x_rdb_probe(void)
|
||||
{
|
||||
unsigned long root = of_get_flat_dt_root();
|
||||
|
||||
return of_flat_dt_is_compatible(root, "MPC8313ERDB") ||
|
||||
of_flat_dt_is_compatible(root, "fsl,mpc8315erdb");
|
||||
return of_flat_dt_match(of_get_flat_dt_root(), board);
|
||||
}
|
||||
|
||||
static struct of_device_id __initdata of_bus_ids[] = {
|
||||
|
@ -101,17 +101,20 @@ static void __init mpc837x_rdb_init_IRQ(void)
|
||||
ipic_set_default_priority();
|
||||
}
|
||||
|
||||
static const char *board[] __initdata = {
|
||||
"fsl,mpc8377rdb",
|
||||
"fsl,mpc8378rdb",
|
||||
"fsl,mpc8379rdb",
|
||||
"fsl,mpc8377wlan",
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* Called very early, MMU is off, device-tree isn't unflattened
|
||||
*/
|
||||
static int __init mpc837x_rdb_probe(void)
|
||||
{
|
||||
unsigned long root = of_get_flat_dt_root();
|
||||
|
||||
return of_flat_dt_is_compatible(root, "fsl,mpc8377rdb") ||
|
||||
of_flat_dt_is_compatible(root, "fsl,mpc8378rdb") ||
|
||||
of_flat_dt_is_compatible(root, "fsl,mpc8379rdb") ||
|
||||
of_flat_dt_is_compatible(root, "fsl,mpc8377wlan");
|
||||
return of_flat_dt_match(of_get_flat_dt_root(), board);
|
||||
}
|
||||
|
||||
define_machine(mpc837x_rdb) {
|
||||
|
@ -186,21 +186,21 @@ static int __init declare_of_platform_devices(void)
|
||||
}
|
||||
machine_device_initcall(tqm85xx, declare_of_platform_devices);
|
||||
|
||||
static const char *board[] __initdata = {
|
||||
"tqc,tqm8540",
|
||||
"tqc,tqm8541",
|
||||
"tqc,tqm8548",
|
||||
"tqc,tqm8555",
|
||||
"tqc,tqm8560",
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* Called very early, device-tree isn't unflattened
|
||||
*/
|
||||
static int __init tqm85xx_probe(void)
|
||||
{
|
||||
unsigned long root = of_get_flat_dt_root();
|
||||
|
||||
if ((of_flat_dt_is_compatible(root, "tqc,tqm8540")) ||
|
||||
(of_flat_dt_is_compatible(root, "tqc,tqm8541")) ||
|
||||
(of_flat_dt_is_compatible(root, "tqc,tqm8548")) ||
|
||||
(of_flat_dt_is_compatible(root, "tqc,tqm8555")) ||
|
||||
(of_flat_dt_is_compatible(root, "tqc,tqm8560")))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return of_flat_dt_match(of_get_flat_dt_root(), board);
|
||||
}
|
||||
|
||||
define_machine(tqm85xx) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <linux/mv643xx.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/of_net.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
|
||||
#include <asm/prom.h>
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/of_net.h>
|
||||
#include <asm/tsi108.h>
|
||||
|
||||
#include <asm/system.h>
|
||||
|
@ -121,7 +121,7 @@ void __init auxio_power_probe(void)
|
||||
node = prom_searchsiblings(node, "obio");
|
||||
node = prom_getchild(node);
|
||||
node = prom_searchsiblings(node, "power");
|
||||
if (node == 0 || node == -1)
|
||||
if (node == 0 || (s32)node == -1)
|
||||
return;
|
||||
|
||||
/* Map the power control register. */
|
||||
|
@ -24,7 +24,7 @@ int this_is_starfire = 0;
|
||||
void check_if_starfire(void)
|
||||
{
|
||||
phandle ssnode = prom_finddevice("/ssp-serial");
|
||||
if (ssnode != 0 && ssnode != -1)
|
||||
if (ssnode != 0 && (s32)ssnode != -1)
|
||||
this_is_starfire = 1;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ void __init prom_init(struct linux_romvec *rp)
|
||||
prom_nodeops = romvec->pv_nodeops;
|
||||
|
||||
prom_root_node = prom_getsibling(0);
|
||||
if((prom_root_node == 0) || (prom_root_node == -1))
|
||||
if ((prom_root_node == 0) || ((s32)prom_root_node == -1))
|
||||
prom_halt();
|
||||
|
||||
if((((unsigned long) prom_nodeops) == 0) ||
|
||||
|
@ -35,13 +35,13 @@ void __init prom_init(void *cif_handler, void *cif_stack)
|
||||
prom_cif_init(cif_handler, cif_stack);
|
||||
|
||||
prom_chosen_node = prom_finddevice(prom_chosen_path);
|
||||
if (!prom_chosen_node || prom_chosen_node == -1)
|
||||
if (!prom_chosen_node || (s32)prom_chosen_node == -1)
|
||||
prom_halt();
|
||||
|
||||
prom_stdout = prom_getint(prom_chosen_node, "stdout");
|
||||
|
||||
node = prom_finddevice("/openprom");
|
||||
if (!node || node == -1)
|
||||
if (!node || (s32)node == -1)
|
||||
prom_halt();
|
||||
|
||||
prom_getstring(node, "version", prom_version, sizeof(prom_version));
|
||||
|
@ -40,11 +40,11 @@ phandle prom_getchild(phandle node)
|
||||
{
|
||||
phandle cnode;
|
||||
|
||||
if (node == -1)
|
||||
if ((s32)node == -1)
|
||||
return 0;
|
||||
|
||||
cnode = __prom_getchild(node);
|
||||
if (cnode == 0 || cnode == -1)
|
||||
if (cnode == 0 || (s32)cnode == -1)
|
||||
return 0;
|
||||
|
||||
return cnode;
|
||||
@ -72,11 +72,11 @@ phandle prom_getsibling(phandle node)
|
||||
{
|
||||
phandle sibnode;
|
||||
|
||||
if (node == -1)
|
||||
if ((s32)node == -1)
|
||||
return 0;
|
||||
|
||||
sibnode = __prom_getsibling(node);
|
||||
if (sibnode == 0 || sibnode == -1)
|
||||
if (sibnode == 0 || (s32)sibnode == -1)
|
||||
return 0;
|
||||
|
||||
return sibnode;
|
||||
@ -219,7 +219,7 @@ static char *__prom_nextprop(phandle node, char * oprop)
|
||||
*/
|
||||
char *prom_nextprop(phandle node, char *oprop, char *buffer)
|
||||
{
|
||||
if (node == 0 || node == -1)
|
||||
if (node == 0 || (s32)node == -1)
|
||||
return "";
|
||||
|
||||
return __prom_nextprop(node, oprop);
|
||||
@ -253,7 +253,7 @@ phandle prom_finddevice(char *name)
|
||||
if (d != s + 3 && (!*d || *d == '/')
|
||||
&& d <= s + 3 + 8) {
|
||||
node2 = node;
|
||||
while (node2 && node2 != -1) {
|
||||
while (node2 && (s32)node2 != -1) {
|
||||
if (prom_getproperty (node2, "reg", (char *)reg, sizeof (reg)) > 0) {
|
||||
if (which_io == reg[0].which_io && phys_addr == reg[0].phys_addr) {
|
||||
node = node2;
|
||||
@ -261,7 +261,7 @@ phandle prom_finddevice(char *name)
|
||||
}
|
||||
}
|
||||
node2 = prom_getsibling(node2);
|
||||
if (!node2 || node2 == -1)
|
||||
if (!node2 || (s32)node2 == -1)
|
||||
break;
|
||||
node2 = prom_searchsiblings(prom_getsibling(node2), nbuf);
|
||||
}
|
||||
@ -303,6 +303,7 @@ phandle prom_inst2pkg(int inst)
|
||||
node = (*romvec->pv_v2devops.v2_inst2pkg)(inst);
|
||||
restore_current();
|
||||
spin_unlock_irqrestore(&prom_lock, flags);
|
||||
if (node == -1) return 0;
|
||||
if ((s32)node == -1)
|
||||
return 0;
|
||||
return node;
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ inline phandle prom_getchild(phandle node)
|
||||
{
|
||||
phandle cnode;
|
||||
|
||||
if (node == -1)
|
||||
if ((s32)node == -1)
|
||||
return 0;
|
||||
cnode = __prom_getchild(node);
|
||||
if (cnode == -1)
|
||||
if ((s32)cnode == -1)
|
||||
return 0;
|
||||
return cnode;
|
||||
}
|
||||
@ -56,10 +56,10 @@ inline phandle prom_getparent(phandle node)
|
||||
{
|
||||
phandle cnode;
|
||||
|
||||
if (node == -1)
|
||||
if ((s32)node == -1)
|
||||
return 0;
|
||||
cnode = prom_node_to_node("parent", node);
|
||||
if (cnode == -1)
|
||||
if ((s32)cnode == -1)
|
||||
return 0;
|
||||
return cnode;
|
||||
}
|
||||
@ -76,10 +76,10 @@ inline phandle prom_getsibling(phandle node)
|
||||
{
|
||||
phandle sibnode;
|
||||
|
||||
if (node == -1)
|
||||
if ((s32)node == -1)
|
||||
return 0;
|
||||
sibnode = __prom_getsibling(node);
|
||||
if (sibnode == -1)
|
||||
if ((s32)sibnode == -1)
|
||||
return 0;
|
||||
|
||||
return sibnode;
|
||||
@ -240,7 +240,7 @@ inline char *prom_firstprop(phandle node, char *buffer)
|
||||
unsigned long args[7];
|
||||
|
||||
*buffer = 0;
|
||||
if (node == -1)
|
||||
if ((s32)node == -1)
|
||||
return buffer;
|
||||
|
||||
args[0] = (unsigned long) prom_nextprop_name;
|
||||
@ -266,7 +266,7 @@ inline char *prom_nextprop(phandle node, const char *oprop, char *buffer)
|
||||
unsigned long args[7];
|
||||
char buf[32];
|
||||
|
||||
if (node == -1) {
|
||||
if ((s32)node == -1) {
|
||||
*buffer = 0;
|
||||
return buffer;
|
||||
}
|
||||
@ -369,7 +369,7 @@ inline phandle prom_inst2pkg(int inst)
|
||||
p1275_cmd_direct(args);
|
||||
|
||||
node = (int) args[4];
|
||||
if (node == -1)
|
||||
if ((s32)node == -1)
|
||||
return 0;
|
||||
return node;
|
||||
}
|
||||
|
@ -69,6 +69,8 @@
|
||||
#ifdef CONFIG_PPC_OF
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/of_irq.h>
|
||||
#endif
|
||||
|
||||
#define PFX "ipmi_si: "
|
||||
@ -2546,7 +2548,7 @@ static int __devinit ipmi_of_probe(struct platform_device *dev,
|
||||
{
|
||||
struct smi_info *info;
|
||||
struct resource resource;
|
||||
const int *regsize, *regspacing, *regshift;
|
||||
const __be32 *regsize, *regspacing, *regshift;
|
||||
struct device_node *np = dev->dev.of_node;
|
||||
int ret;
|
||||
int proplen;
|
||||
@ -2599,9 +2601,9 @@ static int __devinit ipmi_of_probe(struct platform_device *dev,
|
||||
|
||||
info->io.addr_data = resource.start;
|
||||
|
||||
info->io.regsize = regsize ? *regsize : DEFAULT_REGSIZE;
|
||||
info->io.regspacing = regspacing ? *regspacing : DEFAULT_REGSPACING;
|
||||
info->io.regshift = regshift ? *regshift : 0;
|
||||
info->io.regsize = regsize ? be32_to_cpup(regsize) : DEFAULT_REGSIZE;
|
||||
info->io.regspacing = regspacing ? be32_to_cpup(regspacing) : DEFAULT_REGSPACING;
|
||||
info->io.regshift = regshift ? be32_to_cpup(regshift) : 0;
|
||||
|
||||
info->irq = irq_of_parse_and_map(dev->dev.of_node, 0);
|
||||
info->dev = &dev->dev;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <linux/log2.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c/at24.h>
|
||||
|
||||
@ -457,6 +458,27 @@ static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf,
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static void at24_get_ofdata(struct i2c_client *client,
|
||||
struct at24_platform_data *chip)
|
||||
{
|
||||
const __be32 *val;
|
||||
struct device_node *node = client->dev.of_node;
|
||||
|
||||
if (node) {
|
||||
if (of_get_property(node, "read-only", NULL))
|
||||
chip->flags |= AT24_FLAG_READONLY;
|
||||
val = of_get_property(node, "pagesize", NULL);
|
||||
if (val)
|
||||
chip->page_size = be32_to_cpup(val);
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void at24_get_ofdata(struct i2c_client *client,
|
||||
struct at24_platform_data *chip)
|
||||
{ }
|
||||
#endif /* CONFIG_OF */
|
||||
|
||||
static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
{
|
||||
struct at24_platform_data chip;
|
||||
@ -485,6 +507,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
*/
|
||||
chip.page_size = 1;
|
||||
|
||||
/* update chipdata if OF is present */
|
||||
at24_get_ofdata(client, &chip);
|
||||
|
||||
chip.setup = NULL;
|
||||
chip.context = NULL;
|
||||
}
|
||||
@ -492,6 +517,11 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
if (!is_power_of_2(chip.byte_len))
|
||||
dev_warn(&client->dev,
|
||||
"byte_len looks suspicious (no power of 2)!\n");
|
||||
if (!chip.page_size) {
|
||||
dev_err(&client->dev, "page_size must not be 0!\n");
|
||||
err = -EINVAL;
|
||||
goto err_out;
|
||||
}
|
||||
if (!is_power_of_2(chip.page_size))
|
||||
dev_warn(&client->dev,
|
||||
"page_size looks suspicious (no power of 2)!\n");
|
||||
@ -597,19 +627,15 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
|
||||
i2c_set_clientdata(client, at24);
|
||||
|
||||
dev_info(&client->dev, "%zu byte %s EEPROM %s\n",
|
||||
dev_info(&client->dev, "%zu byte %s EEPROM, %s, %u bytes/write\n",
|
||||
at24->bin.size, client->name,
|
||||
writable ? "(writable)" : "(read-only)");
|
||||
writable ? "writable" : "read-only", at24->write_max);
|
||||
if (use_smbus == I2C_SMBUS_WORD_DATA ||
|
||||
use_smbus == I2C_SMBUS_BYTE_DATA) {
|
||||
dev_notice(&client->dev, "Falling back to %s reads, "
|
||||
"performance will suffer\n", use_smbus ==
|
||||
I2C_SMBUS_WORD_DATA ? "word" : "byte");
|
||||
}
|
||||
dev_dbg(&client->dev,
|
||||
"page_size %d, num_addresses %d, write_max %d, use_smbus %d\n",
|
||||
chip.page_size, num_addresses,
|
||||
at24->write_max, use_smbus);
|
||||
|
||||
/* export data to kernel code */
|
||||
if (chip.setup)
|
||||
@ -660,6 +686,11 @@ static struct i2c_driver at24_driver = {
|
||||
|
||||
static int __init at24_init(void)
|
||||
{
|
||||
if (!io_limit) {
|
||||
pr_err("at24: io_limit must not be 0!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
io_limit = rounddown_pow_of_two(io_limit);
|
||||
return i2c_add_driver(&at24_driver);
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ config MMC_RICOH_MMC
|
||||
|
||||
config MMC_SDHCI_OF
|
||||
tristate "SDHCI support on OpenFirmware platforms"
|
||||
depends on MMC_SDHCI && PPC_OF
|
||||
depends on MMC_SDHCI && OF
|
||||
help
|
||||
This selects the OF support for Secure Digital Host Controller
|
||||
Interfaces.
|
||||
@ -93,6 +93,7 @@ config MMC_SDHCI_OF
|
||||
config MMC_SDHCI_OF_ESDHC
|
||||
bool "SDHCI OF support for the Freescale eSDHC controller"
|
||||
depends on MMC_SDHCI_OF
|
||||
depends on PPC_OF
|
||||
select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
|
||||
help
|
||||
This selects the Freescale eSDHC controller support.
|
||||
@ -102,6 +103,7 @@ config MMC_SDHCI_OF_ESDHC
|
||||
config MMC_SDHCI_OF_HLWD
|
||||
bool "SDHCI OF support for the Nintendo Wii SDHCI controllers"
|
||||
depends on MMC_SDHCI_OF
|
||||
depends on PPC_OF
|
||||
select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
|
||||
help
|
||||
This selects the Secure Digital Host Controller Interface (SDHCI)
|
||||
|
@ -122,7 +122,7 @@ static int __devinit sdhci_of_probe(struct platform_device *ofdev,
|
||||
struct sdhci_of_data *sdhci_of_data = match->data;
|
||||
struct sdhci_host *host;
|
||||
struct sdhci_of_host *of_host;
|
||||
const u32 *clk;
|
||||
const __be32 *clk;
|
||||
int size;
|
||||
int ret;
|
||||
|
||||
@ -166,7 +166,7 @@ static int __devinit sdhci_of_probe(struct platform_device *ofdev,
|
||||
|
||||
clk = of_get_property(np, "clock-frequency", &size);
|
||||
if (clk && size == sizeof(*clk) && *clk)
|
||||
of_host->clock = *clk;
|
||||
of_host->clock = be32_to_cpup(clk);
|
||||
|
||||
ret = sdhci_add_host(host);
|
||||
if (ret)
|
||||
|
@ -159,7 +159,7 @@ config MTD_AFS_PARTS
|
||||
|
||||
config MTD_OF_PARTS
|
||||
tristate "Flash partition map based on OF description"
|
||||
depends on (MICROBLAZE || PPC_OF) && MTD_PARTITIONS
|
||||
depends on OF && MTD_PARTITIONS
|
||||
help
|
||||
This provides a partition parsing function which derives
|
||||
the partition map from the children of the flash node,
|
||||
|
@ -72,7 +72,7 @@ config MTD_PHYSMAP_BANKWIDTH
|
||||
|
||||
config MTD_PHYSMAP_OF
|
||||
tristate "Flash device in physical memory map based on OF description"
|
||||
depends on (MICROBLAZE || PPC_OF) && (MTD_CFI || MTD_JEDECPROBE || MTD_ROM)
|
||||
depends on OF && (MTD_CFI || MTD_JEDECPROBE || MTD_ROM)
|
||||
help
|
||||
This provides a 'mapping' driver which allows the NOR Flash and
|
||||
ROM driver code to communicate with chips which are mapped
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <linux/of_mdio.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/of_net.h>
|
||||
|
||||
#include <linux/vmalloc.h>
|
||||
#include <asm/pgtable.h>
|
||||
|
@ -95,6 +95,7 @@
|
||||
#include <linux/phy.h>
|
||||
#include <linux/phy_fixed.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_net.h>
|
||||
|
||||
#include "gianfar.h"
|
||||
#include "fsl_pq_mdio.h"
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <linux/phy.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/of_mdio.h>
|
||||
#include <linux/of_net.h>
|
||||
#include <linux/of_platform.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/of_mdio.h>
|
||||
#include <linux/of_net.h>
|
||||
#include <linux/phy.h>
|
||||
|
||||
#define DRIVER_NAME "xilinx_emaclite"
|
||||
|
@ -19,6 +19,10 @@ config OF_FLATTREE
|
||||
bool
|
||||
select DTC
|
||||
|
||||
config OF_EARLY_FLATTREE
|
||||
bool
|
||||
select OF_FLATTREE
|
||||
|
||||
config OF_PROMTREE
|
||||
bool
|
||||
|
||||
@ -49,6 +53,10 @@ config OF_I2C
|
||||
help
|
||||
OpenFirmware I2C accessors
|
||||
|
||||
config OF_NET
|
||||
depends on NETDEVICES
|
||||
def_bool y
|
||||
|
||||
config OF_SPI
|
||||
def_tristate SPI
|
||||
depends on SPI && !SPARC
|
||||
|
@ -6,5 +6,6 @@ obj-$(CONFIG_OF_IRQ) += irq.o
|
||||
obj-$(CONFIG_OF_DEVICE) += device.o platform.o
|
||||
obj-$(CONFIG_OF_GPIO) += gpio.o
|
||||
obj-$(CONFIG_OF_I2C) += of_i2c.o
|
||||
obj-$(CONFIG_OF_NET) += of_net.o
|
||||
obj-$(CONFIG_OF_SPI) += of_spi.o
|
||||
obj-$(CONFIG_OF_MDIO) += of_mdio.o
|
||||
|
@ -12,13 +12,13 @@
|
||||
(ns) > 0)
|
||||
|
||||
static struct of_bus *of_match_bus(struct device_node *np);
|
||||
static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
|
||||
u64 size, unsigned int flags,
|
||||
static int __of_address_to_resource(struct device_node *dev,
|
||||
const __be32 *addrp, u64 size, unsigned int flags,
|
||||
struct resource *r);
|
||||
|
||||
/* Debug utility */
|
||||
#ifdef DEBUG
|
||||
static void of_dump_addr(const char *s, const u32 *addr, int na)
|
||||
static void of_dump_addr(const char *s, const __be32 *addr, int na)
|
||||
{
|
||||
printk(KERN_DEBUG "%s", s);
|
||||
while (na--)
|
||||
@ -26,7 +26,7 @@ static void of_dump_addr(const char *s, const u32 *addr, int na)
|
||||
printk("\n");
|
||||
}
|
||||
#else
|
||||
static void of_dump_addr(const char *s, const u32 *addr, int na) { }
|
||||
static void of_dump_addr(const char *s, const __be32 *addr, int na) { }
|
||||
#endif
|
||||
|
||||
/* Callbacks for bus specific translators */
|
||||
@ -36,10 +36,10 @@ struct of_bus {
|
||||
int (*match)(struct device_node *parent);
|
||||
void (*count_cells)(struct device_node *child,
|
||||
int *addrc, int *sizec);
|
||||
u64 (*map)(u32 *addr, const u32 *range,
|
||||
u64 (*map)(u32 *addr, const __be32 *range,
|
||||
int na, int ns, int pna);
|
||||
int (*translate)(u32 *addr, u64 offset, int na);
|
||||
unsigned int (*get_flags)(const u32 *addr);
|
||||
unsigned int (*get_flags)(const __be32 *addr);
|
||||
};
|
||||
|
||||
/*
|
||||
@ -55,7 +55,7 @@ static void of_bus_default_count_cells(struct device_node *dev,
|
||||
*sizec = of_n_size_cells(dev);
|
||||
}
|
||||
|
||||
static u64 of_bus_default_map(u32 *addr, const u32 *range,
|
||||
static u64 of_bus_default_map(u32 *addr, const __be32 *range,
|
||||
int na, int ns, int pna)
|
||||
{
|
||||
u64 cp, s, da;
|
||||
@ -85,7 +85,7 @@ static int of_bus_default_translate(u32 *addr, u64 offset, int na)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int of_bus_default_get_flags(const u32 *addr)
|
||||
static unsigned int of_bus_default_get_flags(const __be32 *addr)
|
||||
{
|
||||
return IORESOURCE_MEM;
|
||||
}
|
||||
@ -110,10 +110,10 @@ static void of_bus_pci_count_cells(struct device_node *np,
|
||||
*sizec = 2;
|
||||
}
|
||||
|
||||
static unsigned int of_bus_pci_get_flags(const u32 *addr)
|
||||
static unsigned int of_bus_pci_get_flags(const __be32 *addr)
|
||||
{
|
||||
unsigned int flags = 0;
|
||||
u32 w = addr[0];
|
||||
u32 w = be32_to_cpup(addr);
|
||||
|
||||
switch((w >> 24) & 0x03) {
|
||||
case 0x01:
|
||||
@ -129,7 +129,8 @@ static unsigned int of_bus_pci_get_flags(const u32 *addr)
|
||||
return flags;
|
||||
}
|
||||
|
||||
static u64 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna)
|
||||
static u64 of_bus_pci_map(u32 *addr, const __be32 *range, int na, int ns,
|
||||
int pna)
|
||||
{
|
||||
u64 cp, s, da;
|
||||
unsigned int af, rf;
|
||||
@ -160,7 +161,7 @@ static int of_bus_pci_translate(u32 *addr, u64 offset, int na)
|
||||
return of_bus_default_translate(addr + 1, offset, na - 1);
|
||||
}
|
||||
|
||||
const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
|
||||
const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
|
||||
unsigned int *flags)
|
||||
{
|
||||
const __be32 *prop;
|
||||
@ -207,7 +208,7 @@ EXPORT_SYMBOL(of_get_pci_address);
|
||||
int of_pci_address_to_resource(struct device_node *dev, int bar,
|
||||
struct resource *r)
|
||||
{
|
||||
const u32 *addrp;
|
||||
const __be32 *addrp;
|
||||
u64 size;
|
||||
unsigned int flags;
|
||||
|
||||
@ -237,12 +238,13 @@ static void of_bus_isa_count_cells(struct device_node *child,
|
||||
*sizec = 1;
|
||||
}
|
||||
|
||||
static u64 of_bus_isa_map(u32 *addr, const u32 *range, int na, int ns, int pna)
|
||||
static u64 of_bus_isa_map(u32 *addr, const __be32 *range, int na, int ns,
|
||||
int pna)
|
||||
{
|
||||
u64 cp, s, da;
|
||||
|
||||
/* Check address type match */
|
||||
if ((addr[0] ^ range[0]) & 0x00000001)
|
||||
if ((addr[0] ^ range[0]) & cpu_to_be32(1))
|
||||
return OF_BAD_ADDR;
|
||||
|
||||
/* Read address values, skipping high cell */
|
||||
@ -264,10 +266,10 @@ static int of_bus_isa_translate(u32 *addr, u64 offset, int na)
|
||||
return of_bus_default_translate(addr + 1, offset, na - 1);
|
||||
}
|
||||
|
||||
static unsigned int of_bus_isa_get_flags(const u32 *addr)
|
||||
static unsigned int of_bus_isa_get_flags(const __be32 *addr)
|
||||
{
|
||||
unsigned int flags = 0;
|
||||
u32 w = addr[0];
|
||||
u32 w = be32_to_cpup(addr);
|
||||
|
||||
if (w & 1)
|
||||
flags |= IORESOURCE_IO;
|
||||
@ -330,7 +332,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
|
||||
struct of_bus *pbus, u32 *addr,
|
||||
int na, int ns, int pna, const char *rprop)
|
||||
{
|
||||
const u32 *ranges;
|
||||
const __be32 *ranges;
|
||||
unsigned int rlen;
|
||||
int rone;
|
||||
u64 offset = OF_BAD_ADDR;
|
||||
@ -398,7 +400,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
|
||||
* that can be mapped to a cpu physical address). This is not really specified
|
||||
* that way, but this is traditionally the way IBM at least do things
|
||||
*/
|
||||
u64 __of_translate_address(struct device_node *dev, const u32 *in_addr,
|
||||
u64 __of_translate_address(struct device_node *dev, const __be32 *in_addr,
|
||||
const char *rprop)
|
||||
{
|
||||
struct device_node *parent = NULL;
|
||||
@ -475,22 +477,22 @@ u64 __of_translate_address(struct device_node *dev, const u32 *in_addr,
|
||||
return result;
|
||||
}
|
||||
|
||||
u64 of_translate_address(struct device_node *dev, const u32 *in_addr)
|
||||
u64 of_translate_address(struct device_node *dev, const __be32 *in_addr)
|
||||
{
|
||||
return __of_translate_address(dev, in_addr, "ranges");
|
||||
}
|
||||
EXPORT_SYMBOL(of_translate_address);
|
||||
|
||||
u64 of_translate_dma_address(struct device_node *dev, const u32 *in_addr)
|
||||
u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_addr)
|
||||
{
|
||||
return __of_translate_address(dev, in_addr, "dma-ranges");
|
||||
}
|
||||
EXPORT_SYMBOL(of_translate_dma_address);
|
||||
|
||||
const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
|
||||
const __be32 *of_get_address(struct device_node *dev, int index, u64 *size,
|
||||
unsigned int *flags)
|
||||
{
|
||||
const u32 *prop;
|
||||
const __be32 *prop;
|
||||
unsigned int psize;
|
||||
struct device_node *parent;
|
||||
struct of_bus *bus;
|
||||
@ -525,8 +527,8 @@ const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
|
||||
}
|
||||
EXPORT_SYMBOL(of_get_address);
|
||||
|
||||
static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
|
||||
u64 size, unsigned int flags,
|
||||
static int __of_address_to_resource(struct device_node *dev,
|
||||
const __be32 *addrp, u64 size, unsigned int flags,
|
||||
struct resource *r)
|
||||
{
|
||||
u64 taddr;
|
||||
@ -564,7 +566,7 @@ static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
|
||||
int of_address_to_resource(struct device_node *dev, int index,
|
||||
struct resource *r)
|
||||
{
|
||||
const u32 *addrp;
|
||||
const __be32 *addrp;
|
||||
u64 size;
|
||||
unsigned int flags;
|
||||
|
||||
|
430
drivers/of/fdt.c
430
drivers/of/fdt.c
@ -11,10 +11,12 @@
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/initrd.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_fdt.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#ifdef CONFIG_PPC
|
||||
#include <asm/machdep.h>
|
||||
@ -22,104 +24,19 @@
|
||||
|
||||
#include <asm/page.h>
|
||||
|
||||
int __initdata dt_root_addr_cells;
|
||||
int __initdata dt_root_size_cells;
|
||||
|
||||
struct boot_param_header *initial_boot_params;
|
||||
|
||||
char *find_flat_dt_string(u32 offset)
|
||||
char *of_fdt_get_string(struct boot_param_header *blob, u32 offset)
|
||||
{
|
||||
return ((char *)initial_boot_params) +
|
||||
be32_to_cpu(initial_boot_params->off_dt_strings) + offset;
|
||||
return ((char *)blob) +
|
||||
be32_to_cpu(blob->off_dt_strings) + offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* of_scan_flat_dt - scan flattened tree blob and call callback on each.
|
||||
* @it: callback function
|
||||
* @data: context data pointer
|
||||
*
|
||||
* This function is used to scan the flattened device-tree, it is
|
||||
* used to extract the memory information at boot before we can
|
||||
* unflatten the tree
|
||||
* of_fdt_get_property - Given a node in the given flat blob, return
|
||||
* the property ptr
|
||||
*/
|
||||
int __init of_scan_flat_dt(int (*it)(unsigned long node,
|
||||
const char *uname, int depth,
|
||||
void *data),
|
||||
void *data)
|
||||
{
|
||||
unsigned long p = ((unsigned long)initial_boot_params) +
|
||||
be32_to_cpu(initial_boot_params->off_dt_struct);
|
||||
int rc = 0;
|
||||
int depth = -1;
|
||||
|
||||
do {
|
||||
u32 tag = be32_to_cpup((__be32 *)p);
|
||||
char *pathp;
|
||||
|
||||
p += 4;
|
||||
if (tag == OF_DT_END_NODE) {
|
||||
depth--;
|
||||
continue;
|
||||
}
|
||||
if (tag == OF_DT_NOP)
|
||||
continue;
|
||||
if (tag == OF_DT_END)
|
||||
break;
|
||||
if (tag == OF_DT_PROP) {
|
||||
u32 sz = be32_to_cpup((__be32 *)p);
|
||||
p += 8;
|
||||
if (be32_to_cpu(initial_boot_params->version) < 0x10)
|
||||
p = ALIGN(p, sz >= 8 ? 8 : 4);
|
||||
p += sz;
|
||||
p = ALIGN(p, 4);
|
||||
continue;
|
||||
}
|
||||
if (tag != OF_DT_BEGIN_NODE) {
|
||||
pr_err("Invalid tag %x in flat device tree!\n", tag);
|
||||
return -EINVAL;
|
||||
}
|
||||
depth++;
|
||||
pathp = (char *)p;
|
||||
p = ALIGN(p + strlen(pathp) + 1, 4);
|
||||
if ((*pathp) == '/') {
|
||||
char *lp, *np;
|
||||
for (lp = NULL, np = pathp; *np; np++)
|
||||
if ((*np) == '/')
|
||||
lp = np+1;
|
||||
if (lp != NULL)
|
||||
pathp = lp;
|
||||
}
|
||||
rc = it(p, pathp, depth, data);
|
||||
if (rc != 0)
|
||||
break;
|
||||
} while (1);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* of_get_flat_dt_root - find the root node in the flat blob
|
||||
*/
|
||||
unsigned long __init of_get_flat_dt_root(void)
|
||||
{
|
||||
unsigned long p = ((unsigned long)initial_boot_params) +
|
||||
be32_to_cpu(initial_boot_params->off_dt_struct);
|
||||
|
||||
while (be32_to_cpup((__be32 *)p) == OF_DT_NOP)
|
||||
p += 4;
|
||||
BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE);
|
||||
p += 4;
|
||||
return ALIGN(p + strlen((char *)p) + 1, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr
|
||||
*
|
||||
* This function can be used within scan_flattened_dt callback to get
|
||||
* access to properties
|
||||
*/
|
||||
void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
|
||||
unsigned long *size)
|
||||
void *of_fdt_get_property(struct boot_param_header *blob,
|
||||
unsigned long node, const char *name,
|
||||
unsigned long *size)
|
||||
{
|
||||
unsigned long p = node;
|
||||
|
||||
@ -137,10 +54,10 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
|
||||
sz = be32_to_cpup((__be32 *)p);
|
||||
noff = be32_to_cpup((__be32 *)(p + 4));
|
||||
p += 8;
|
||||
if (be32_to_cpu(initial_boot_params->version) < 0x10)
|
||||
if (be32_to_cpu(blob->version) < 0x10)
|
||||
p = ALIGN(p, sz >= 8 ? 8 : 4);
|
||||
|
||||
nstr = find_flat_dt_string(noff);
|
||||
nstr = of_fdt_get_string(blob, noff);
|
||||
if (nstr == NULL) {
|
||||
pr_warning("Can't find property index name !\n");
|
||||
return NULL;
|
||||
@ -156,21 +73,28 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
|
||||
}
|
||||
|
||||
/**
|
||||
* of_flat_dt_is_compatible - Return true if given node has compat in compatible list
|
||||
* of_fdt_is_compatible - Return true if given node from the given blob has
|
||||
* compat in its compatible list
|
||||
* @blob: A device tree blob
|
||||
* @node: node to test
|
||||
* @compat: compatible string to compare with compatible list.
|
||||
*
|
||||
* On match, returns a non-zero value with smaller values returned for more
|
||||
* specific compatible values.
|
||||
*/
|
||||
int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
|
||||
int of_fdt_is_compatible(struct boot_param_header *blob,
|
||||
unsigned long node, const char *compat)
|
||||
{
|
||||
const char *cp;
|
||||
unsigned long cplen, l;
|
||||
unsigned long cplen, l, score = 0;
|
||||
|
||||
cp = of_get_flat_dt_prop(node, "compatible", &cplen);
|
||||
cp = of_fdt_get_property(blob, node, "compatible", &cplen);
|
||||
if (cp == NULL)
|
||||
return 0;
|
||||
while (cplen > 0) {
|
||||
score++;
|
||||
if (of_compat_cmp(cp, compat, strlen(compat)) == 0)
|
||||
return 1;
|
||||
return score;
|
||||
l = strlen(cp) + 1;
|
||||
cp += l;
|
||||
cplen -= l;
|
||||
@ -179,7 +103,28 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
|
||||
/**
|
||||
* of_fdt_match - Return true if node matches a list of compatible values
|
||||
*/
|
||||
int of_fdt_match(struct boot_param_header *blob, unsigned long node,
|
||||
const char **compat)
|
||||
{
|
||||
unsigned int tmp, score = 0;
|
||||
|
||||
if (!compat)
|
||||
return 0;
|
||||
|
||||
while (*compat) {
|
||||
tmp = of_fdt_is_compatible(blob, node, *compat);
|
||||
if (tmp && (score == 0 || (tmp < score)))
|
||||
score = tmp;
|
||||
compat++;
|
||||
}
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size,
|
||||
unsigned long align)
|
||||
{
|
||||
void *res;
|
||||
@ -193,16 +138,18 @@ static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
|
||||
|
||||
/**
|
||||
* unflatten_dt_node - Alloc and populate a device_node from the flat tree
|
||||
* @blob: The parent device tree blob
|
||||
* @p: pointer to node in flat tree
|
||||
* @dad: Parent struct device_node
|
||||
* @allnextpp: pointer to ->allnext from last allocated device_node
|
||||
* @fpsize: Size of the node path up at the current depth.
|
||||
*/
|
||||
unsigned long __init unflatten_dt_node(unsigned long mem,
|
||||
unsigned long *p,
|
||||
struct device_node *dad,
|
||||
struct device_node ***allnextpp,
|
||||
unsigned long fpsize)
|
||||
unsigned long unflatten_dt_node(struct boot_param_header *blob,
|
||||
unsigned long mem,
|
||||
unsigned long *p,
|
||||
struct device_node *dad,
|
||||
struct device_node ***allnextpp,
|
||||
unsigned long fpsize)
|
||||
{
|
||||
struct device_node *np;
|
||||
struct property *pp, **prev_pp = NULL;
|
||||
@ -298,10 +245,10 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
|
||||
sz = be32_to_cpup((__be32 *)(*p));
|
||||
noff = be32_to_cpup((__be32 *)((*p) + 4));
|
||||
*p += 8;
|
||||
if (be32_to_cpu(initial_boot_params->version) < 0x10)
|
||||
if (be32_to_cpu(blob->version) < 0x10)
|
||||
*p = ALIGN(*p, sz >= 8 ? 8 : 4);
|
||||
|
||||
pname = find_flat_dt_string(noff);
|
||||
pname = of_fdt_get_string(blob, noff);
|
||||
if (pname == NULL) {
|
||||
pr_info("Can't find property name in list !\n");
|
||||
break;
|
||||
@ -380,7 +327,8 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
|
||||
if (tag == OF_DT_NOP)
|
||||
*p += 4;
|
||||
else
|
||||
mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);
|
||||
mem = unflatten_dt_node(blob, mem, p, np, allnextpp,
|
||||
fpsize);
|
||||
tag = be32_to_cpup((__be32 *)(*p));
|
||||
}
|
||||
if (tag != OF_DT_END_NODE) {
|
||||
@ -391,6 +339,211 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
|
||||
return mem;
|
||||
}
|
||||
|
||||
/**
|
||||
* __unflatten_device_tree - create tree of device_nodes from flat blob
|
||||
*
|
||||
* unflattens a device-tree, creating the
|
||||
* tree of struct device_node. It also fills the "name" and "type"
|
||||
* pointers of the nodes so the normal device-tree walking functions
|
||||
* can be used.
|
||||
* @blob: The blob to expand
|
||||
* @mynodes: The device_node tree created by the call
|
||||
* @dt_alloc: An allocator that provides a virtual address to memory
|
||||
* for the resulting tree
|
||||
*/
|
||||
void __unflatten_device_tree(struct boot_param_header *blob,
|
||||
struct device_node **mynodes,
|
||||
void * (*dt_alloc)(u64 size, u64 align))
|
||||
{
|
||||
unsigned long start, mem, size;
|
||||
struct device_node **allnextp = mynodes;
|
||||
|
||||
pr_debug(" -> unflatten_device_tree()\n");
|
||||
|
||||
if (!blob) {
|
||||
pr_debug("No device tree pointer\n");
|
||||
return;
|
||||
}
|
||||
|
||||
pr_debug("Unflattening device tree:\n");
|
||||
pr_debug("magic: %08x\n", be32_to_cpu(blob->magic));
|
||||
pr_debug("size: %08x\n", be32_to_cpu(blob->totalsize));
|
||||
pr_debug("version: %08x\n", be32_to_cpu(blob->version));
|
||||
|
||||
if (be32_to_cpu(blob->magic) != OF_DT_HEADER) {
|
||||
pr_err("Invalid device tree blob header\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* First pass, scan for size */
|
||||
start = ((unsigned long)blob) +
|
||||
be32_to_cpu(blob->off_dt_struct);
|
||||
size = unflatten_dt_node(blob, 0, &start, NULL, NULL, 0);
|
||||
size = (size | 3) + 1;
|
||||
|
||||
pr_debug(" size is %lx, allocating...\n", size);
|
||||
|
||||
/* Allocate memory for the expanded device tree */
|
||||
mem = (unsigned long)
|
||||
dt_alloc(size + 4, __alignof__(struct device_node));
|
||||
|
||||
((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
|
||||
|
||||
pr_debug(" unflattening %lx...\n", mem);
|
||||
|
||||
/* Second pass, do actual unflattening */
|
||||
start = ((unsigned long)blob) +
|
||||
be32_to_cpu(blob->off_dt_struct);
|
||||
unflatten_dt_node(blob, mem, &start, NULL, &allnextp, 0);
|
||||
if (be32_to_cpup((__be32 *)start) != OF_DT_END)
|
||||
pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start));
|
||||
if (be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeef)
|
||||
pr_warning("End of tree marker overwritten: %08x\n",
|
||||
be32_to_cpu(((__be32 *)mem)[size / 4]));
|
||||
*allnextp = NULL;
|
||||
|
||||
pr_debug(" <- unflatten_device_tree()\n");
|
||||
}
|
||||
|
||||
static void *kernel_tree_alloc(u64 size, u64 align)
|
||||
{
|
||||
return kzalloc(size, GFP_KERNEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* of_fdt_unflatten_tree - create tree of device_nodes from flat blob
|
||||
*
|
||||
* unflattens the device-tree passed by the firmware, creating the
|
||||
* tree of struct device_node. It also fills the "name" and "type"
|
||||
* pointers of the nodes so the normal device-tree walking functions
|
||||
* can be used.
|
||||
*/
|
||||
void of_fdt_unflatten_tree(unsigned long *blob,
|
||||
struct device_node **mynodes)
|
||||
{
|
||||
struct boot_param_header *device_tree =
|
||||
(struct boot_param_header *)blob;
|
||||
__unflatten_device_tree(device_tree, mynodes, &kernel_tree_alloc);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree);
|
||||
|
||||
/* Everything below here references initial_boot_params directly. */
|
||||
int __initdata dt_root_addr_cells;
|
||||
int __initdata dt_root_size_cells;
|
||||
|
||||
struct boot_param_header *initial_boot_params;
|
||||
|
||||
#ifdef CONFIG_OF_EARLY_FLATTREE
|
||||
|
||||
/**
|
||||
* of_scan_flat_dt - scan flattened tree blob and call callback on each.
|
||||
* @it: callback function
|
||||
* @data: context data pointer
|
||||
*
|
||||
* This function is used to scan the flattened device-tree, it is
|
||||
* used to extract the memory information at boot before we can
|
||||
* unflatten the tree
|
||||
*/
|
||||
int __init of_scan_flat_dt(int (*it)(unsigned long node,
|
||||
const char *uname, int depth,
|
||||
void *data),
|
||||
void *data)
|
||||
{
|
||||
unsigned long p = ((unsigned long)initial_boot_params) +
|
||||
be32_to_cpu(initial_boot_params->off_dt_struct);
|
||||
int rc = 0;
|
||||
int depth = -1;
|
||||
|
||||
do {
|
||||
u32 tag = be32_to_cpup((__be32 *)p);
|
||||
char *pathp;
|
||||
|
||||
p += 4;
|
||||
if (tag == OF_DT_END_NODE) {
|
||||
depth--;
|
||||
continue;
|
||||
}
|
||||
if (tag == OF_DT_NOP)
|
||||
continue;
|
||||
if (tag == OF_DT_END)
|
||||
break;
|
||||
if (tag == OF_DT_PROP) {
|
||||
u32 sz = be32_to_cpup((__be32 *)p);
|
||||
p += 8;
|
||||
if (be32_to_cpu(initial_boot_params->version) < 0x10)
|
||||
p = ALIGN(p, sz >= 8 ? 8 : 4);
|
||||
p += sz;
|
||||
p = ALIGN(p, 4);
|
||||
continue;
|
||||
}
|
||||
if (tag != OF_DT_BEGIN_NODE) {
|
||||
pr_err("Invalid tag %x in flat device tree!\n", tag);
|
||||
return -EINVAL;
|
||||
}
|
||||
depth++;
|
||||
pathp = (char *)p;
|
||||
p = ALIGN(p + strlen(pathp) + 1, 4);
|
||||
if ((*pathp) == '/') {
|
||||
char *lp, *np;
|
||||
for (lp = NULL, np = pathp; *np; np++)
|
||||
if ((*np) == '/')
|
||||
lp = np+1;
|
||||
if (lp != NULL)
|
||||
pathp = lp;
|
||||
}
|
||||
rc = it(p, pathp, depth, data);
|
||||
if (rc != 0)
|
||||
break;
|
||||
} while (1);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* of_get_flat_dt_root - find the root node in the flat blob
|
||||
*/
|
||||
unsigned long __init of_get_flat_dt_root(void)
|
||||
{
|
||||
unsigned long p = ((unsigned long)initial_boot_params) +
|
||||
be32_to_cpu(initial_boot_params->off_dt_struct);
|
||||
|
||||
while (be32_to_cpup((__be32 *)p) == OF_DT_NOP)
|
||||
p += 4;
|
||||
BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE);
|
||||
p += 4;
|
||||
return ALIGN(p + strlen((char *)p) + 1, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr
|
||||
*
|
||||
* This function can be used within scan_flattened_dt callback to get
|
||||
* access to properties
|
||||
*/
|
||||
void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
|
||||
unsigned long *size)
|
||||
{
|
||||
return of_fdt_get_property(initial_boot_params, node, name, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* of_flat_dt_is_compatible - Return true if given node has compat in compatible list
|
||||
* @node: node to test
|
||||
* @compat: compatible string to compare with compatible list.
|
||||
*/
|
||||
int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
|
||||
{
|
||||
return of_fdt_is_compatible(initial_boot_params, node, compat);
|
||||
}
|
||||
|
||||
/**
|
||||
* of_flat_dt_match - Return true if node matches a list of compatible values
|
||||
*/
|
||||
int __init of_flat_dt_match(unsigned long node, const char **compat)
|
||||
{
|
||||
return of_fdt_match(initial_boot_params, node, compat);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BLK_DEV_INITRD
|
||||
/**
|
||||
* early_init_dt_check_for_initrd - Decode initrd location from flat tree
|
||||
@ -539,6 +692,12 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void *__init early_device_tree_alloc(u64 size, u64 align)
|
||||
{
|
||||
unsigned long mem = early_init_dt_alloc_memory_arch(size, align);
|
||||
return __va(mem);
|
||||
}
|
||||
|
||||
/**
|
||||
* unflatten_device_tree - create tree of device_nodes from flat blob
|
||||
*
|
||||
@ -549,58 +708,13 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
|
||||
*/
|
||||
void __init unflatten_device_tree(void)
|
||||
{
|
||||
unsigned long start, mem, size;
|
||||
struct device_node **allnextp = &allnodes;
|
||||
|
||||
pr_debug(" -> unflatten_device_tree()\n");
|
||||
|
||||
if (!initial_boot_params) {
|
||||
pr_debug("No device tree pointer\n");
|
||||
return;
|
||||
}
|
||||
|
||||
pr_debug("Unflattening device tree:\n");
|
||||
pr_debug("magic: %08x\n", be32_to_cpu(initial_boot_params->magic));
|
||||
pr_debug("size: %08x\n", be32_to_cpu(initial_boot_params->totalsize));
|
||||
pr_debug("version: %08x\n", be32_to_cpu(initial_boot_params->version));
|
||||
|
||||
if (be32_to_cpu(initial_boot_params->magic) != OF_DT_HEADER) {
|
||||
pr_err("Invalid device tree blob header\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* First pass, scan for size */
|
||||
start = ((unsigned long)initial_boot_params) +
|
||||
be32_to_cpu(initial_boot_params->off_dt_struct);
|
||||
size = unflatten_dt_node(0, &start, NULL, NULL, 0);
|
||||
size = (size | 3) + 1;
|
||||
|
||||
pr_debug(" size is %lx, allocating...\n", size);
|
||||
|
||||
/* Allocate memory for the expanded device tree */
|
||||
mem = early_init_dt_alloc_memory_arch(size + 4,
|
||||
__alignof__(struct device_node));
|
||||
mem = (unsigned long) __va(mem);
|
||||
|
||||
((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
|
||||
|
||||
pr_debug(" unflattening %lx...\n", mem);
|
||||
|
||||
/* Second pass, do actual unflattening */
|
||||
start = ((unsigned long)initial_boot_params) +
|
||||
be32_to_cpu(initial_boot_params->off_dt_struct);
|
||||
unflatten_dt_node(mem, &start, NULL, &allnextp, 0);
|
||||
if (be32_to_cpup((__be32 *)start) != OF_DT_END)
|
||||
pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start));
|
||||
if (be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeef)
|
||||
pr_warning("End of tree marker overwritten: %08x\n",
|
||||
be32_to_cpu(((__be32 *)mem)[size / 4]));
|
||||
*allnextp = NULL;
|
||||
__unflatten_device_tree(initial_boot_params, &allnodes,
|
||||
early_device_tree_alloc);
|
||||
|
||||
/* Get pointer to OF "/chosen" node for use everywhere */
|
||||
of_chosen = of_find_node_by_path("/chosen");
|
||||
if (of_chosen == NULL)
|
||||
of_chosen = of_find_node_by_path("/chosen@0");
|
||||
|
||||
pr_debug(" <- unflatten_device_tree()\n");
|
||||
}
|
||||
|
||||
#endif /* CONFIG_OF_EARLY_FLATTREE */
|
||||
|
@ -52,27 +52,35 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
|
||||
|
||||
/* Loop over the child nodes and register a phy_device for each one */
|
||||
for_each_child_of_node(np, child) {
|
||||
const __be32 *addr;
|
||||
const __be32 *paddr;
|
||||
u32 addr;
|
||||
int len;
|
||||
|
||||
/* A PHY must have a reg property in the range [0-31] */
|
||||
addr = of_get_property(child, "reg", &len);
|
||||
if (!addr || len < sizeof(*addr) || *addr >= 32 || *addr < 0) {
|
||||
paddr = of_get_property(child, "reg", &len);
|
||||
if (!paddr || len < sizeof(*paddr)) {
|
||||
dev_err(&mdio->dev, "%s has invalid PHY address\n",
|
||||
child->full_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mdio->irq) {
|
||||
mdio->irq[*addr] = irq_of_parse_and_map(child, 0);
|
||||
if (!mdio->irq[*addr])
|
||||
mdio->irq[*addr] = PHY_POLL;
|
||||
addr = be32_to_cpup(paddr);
|
||||
if (addr >= 32) {
|
||||
dev_err(&mdio->dev, "%s PHY address %i is too large\n",
|
||||
child->full_name, addr);
|
||||
continue;
|
||||
}
|
||||
|
||||
phy = get_phy_device(mdio, be32_to_cpup(addr));
|
||||
if (mdio->irq) {
|
||||
mdio->irq[addr] = irq_of_parse_and_map(child, 0);
|
||||
if (!mdio->irq[addr])
|
||||
mdio->irq[addr] = PHY_POLL;
|
||||
}
|
||||
|
||||
phy = get_phy_device(mdio, addr);
|
||||
if (!phy || IS_ERR(phy)) {
|
||||
dev_err(&mdio->dev, "error probing PHY at address %i\n",
|
||||
*addr);
|
||||
addr);
|
||||
continue;
|
||||
}
|
||||
phy_scan_fixups(phy);
|
||||
@ -91,7 +99,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
|
||||
}
|
||||
|
||||
dev_dbg(&mdio->dev, "registered phy %s at address %i\n",
|
||||
child->name, *addr);
|
||||
child->name, addr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
48
drivers/of/of_net.c
Normal file
48
drivers/of/of_net.c
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* OF helpers for network devices.
|
||||
*
|
||||
* This file is released under the GPLv2
|
||||
*
|
||||
* Initially copied out of arch/powerpc/kernel/prom_parse.c
|
||||
*/
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/of_net.h>
|
||||
|
||||
/**
|
||||
* Search the device tree for the best MAC address to use. 'mac-address' is
|
||||
* checked first, because that is supposed to contain to "most recent" MAC
|
||||
* address. If that isn't set, then 'local-mac-address' is checked next,
|
||||
* because that is the default address. If that isn't set, then the obsolete
|
||||
* 'address' is checked, just in case we're using an old device tree.
|
||||
*
|
||||
* Note that the 'address' property is supposed to contain a virtual address of
|
||||
* the register set, but some DTS files have redefined that property to be the
|
||||
* MAC address.
|
||||
*
|
||||
* All-zero MAC addresses are rejected, because those could be properties that
|
||||
* exist in the device tree, but were not set by U-Boot. For example, the
|
||||
* DTS could define 'mac-address' and 'local-mac-address', with zero MAC
|
||||
* addresses. Some older U-Boots only initialized 'local-mac-address'. In
|
||||
* this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
|
||||
* but is all zeros.
|
||||
*/
|
||||
const void *of_get_mac_address(struct device_node *np)
|
||||
{
|
||||
struct property *pp;
|
||||
|
||||
pp = of_find_property(np, "mac-address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
pp = of_find_property(np, "local-mac-address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
pp = of_find_property(np, "address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL(of_get_mac_address);
|
@ -633,6 +633,9 @@ EXPORT_SYMBOL(of_device_alloc);
|
||||
* @np: pointer to node to create device for
|
||||
* @bus_id: name to assign device
|
||||
* @parent: Linux device model parent device.
|
||||
*
|
||||
* Returns pointer to created platform device, or NULL if a device was not
|
||||
* registered. Unavailable devices will not get registered.
|
||||
*/
|
||||
struct platform_device *of_platform_device_create(struct device_node *np,
|
||||
const char *bus_id,
|
||||
@ -640,6 +643,9 @@ struct platform_device *of_platform_device_create(struct device_node *np,
|
||||
{
|
||||
struct platform_device *dev;
|
||||
|
||||
if (!of_device_is_available(np))
|
||||
return NULL;
|
||||
|
||||
dev = of_device_alloc(np, bus_id, parent);
|
||||
if (!dev)
|
||||
return NULL;
|
||||
@ -683,8 +689,9 @@ static int of_platform_bus_create(const struct device_node *bus,
|
||||
pr_debug(" create child: %s\n", child->full_name);
|
||||
dev = of_platform_device_create(child, NULL, parent);
|
||||
if (dev == NULL)
|
||||
rc = -ENOMEM;
|
||||
else if (!of_match_node(matches, child))
|
||||
continue;
|
||||
|
||||
if (!of_match_node(matches, child))
|
||||
continue;
|
||||
if (rc == 0) {
|
||||
pr_debug(" and sub busses\n");
|
||||
@ -733,10 +740,9 @@ int of_platform_bus_probe(struct device_node *root,
|
||||
if (of_match_node(matches, root)) {
|
||||
pr_debug(" root match, create all sub devices\n");
|
||||
dev = of_platform_device_create(root, NULL, parent);
|
||||
if (dev == NULL) {
|
||||
rc = -ENOMEM;
|
||||
if (dev == NULL)
|
||||
goto bail;
|
||||
}
|
||||
|
||||
pr_debug(" create all sub busses\n");
|
||||
rc = of_platform_bus_create(root, matches, &dev->dev);
|
||||
goto bail;
|
||||
@ -748,9 +754,9 @@ int of_platform_bus_probe(struct device_node *root,
|
||||
pr_debug(" match: %s\n", child->full_name);
|
||||
dev = of_platform_device_create(child, NULL, parent);
|
||||
if (dev == NULL)
|
||||
rc = -ENOMEM;
|
||||
else
|
||||
rc = of_platform_bus_create(child, matches, &dev->dev);
|
||||
continue;
|
||||
|
||||
rc = of_platform_bus_create(child, matches, &dev->dev);
|
||||
if (rc) {
|
||||
of_node_put(child);
|
||||
break;
|
||||
|
@ -467,7 +467,7 @@ static int jsflash_init(void)
|
||||
|
||||
node = prom_getchild(prom_root_node);
|
||||
node = prom_searchsiblings(node, "flash-memory");
|
||||
if (node != 0 && node != -1) {
|
||||
if (node != 0 && (s32)node != -1) {
|
||||
if (prom_getproperty(node, "reg",
|
||||
(char *)®0, sizeof(reg0)) == -1) {
|
||||
printk("jsflash: no \"reg\" property\n");
|
||||
|
@ -1412,7 +1412,7 @@ config SERIAL_NETX_CONSOLE
|
||||
|
||||
config SERIAL_OF_PLATFORM
|
||||
tristate "Serial port on Open Firmware platform bus"
|
||||
depends on PPC_OF || MICROBLAZE
|
||||
depends on OF
|
||||
depends on SERIAL_8250 || SERIAL_OF_PLATFORM_NWPSERIAL
|
||||
help
|
||||
If you have a PowerPC based system that has serial ports
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <linux/serial_core.h>
|
||||
#include <linux/serial_8250.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/nwpserial.h>
|
||||
|
||||
|
@ -67,7 +67,8 @@
|
||||
* Align to a 32 byte boundary equal to the
|
||||
* alignment gcc 4.5 uses for a struct
|
||||
*/
|
||||
#define STRUCT_ALIGN() . = ALIGN(32)
|
||||
#define STRUCT_ALIGNMENT 32
|
||||
#define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT)
|
||||
|
||||
/* The actual configuration determine if the init/exit sections
|
||||
* are handled as text/data or they can be discarded (which
|
||||
@ -146,6 +147,13 @@
|
||||
#define TRACE_SYSCALLS()
|
||||
#endif
|
||||
|
||||
|
||||
#define KERNEL_DTB() \
|
||||
STRUCT_ALIGN(); \
|
||||
VMLINUX_SYMBOL(__dtb_start) = .; \
|
||||
*(.dtb.init.rodata) \
|
||||
VMLINUX_SYMBOL(__dtb_end) = .;
|
||||
|
||||
/* .data section */
|
||||
#define DATA_DATA \
|
||||
*(.data) \
|
||||
@ -468,7 +476,8 @@
|
||||
MCOUNT_REC() \
|
||||
DEV_DISCARD(init.rodata) \
|
||||
CPU_DISCARD(init.rodata) \
|
||||
MEM_DISCARD(init.rodata)
|
||||
MEM_DISCARD(init.rodata) \
|
||||
KERNEL_DTB()
|
||||
|
||||
#define INIT_TEXT \
|
||||
*(.init.text) \
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/of.h>
|
||||
|
||||
extern u64 of_translate_address(struct device_node *np, const u32 *addr);
|
||||
extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
|
||||
extern int of_address_to_resource(struct device_node *dev, int index,
|
||||
struct resource *r);
|
||||
extern void __iomem *of_iomap(struct device_node *device, int index);
|
||||
@ -21,7 +21,7 @@ static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
|
||||
extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
|
||||
u64 *size, unsigned int *flags);
|
||||
extern int of_pci_address_to_resource(struct device_node *dev, int bar,
|
||||
struct resource *r);
|
||||
@ -32,7 +32,7 @@ static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline const u32 *of_get_pci_address(struct device_node *dev,
|
||||
static inline const __be32 *of_get_pci_address(struct device_node *dev,
|
||||
int bar_no, u64 *size, unsigned int *flags)
|
||||
{
|
||||
return NULL;
|
||||
|
@ -58,6 +58,23 @@ struct boot_param_header {
|
||||
};
|
||||
|
||||
#if defined(CONFIG_OF_FLATTREE)
|
||||
|
||||
struct device_node;
|
||||
|
||||
/* For scanning an arbitrary device-tree at any time */
|
||||
extern char *of_fdt_get_string(struct boot_param_header *blob, u32 offset);
|
||||
extern void *of_fdt_get_property(struct boot_param_header *blob,
|
||||
unsigned long node,
|
||||
const char *name,
|
||||
unsigned long *size);
|
||||
extern int of_fdt_is_compatible(struct boot_param_header *blob,
|
||||
unsigned long node,
|
||||
const char *compat);
|
||||
extern int of_fdt_match(struct boot_param_header *blob, unsigned long node,
|
||||
const char **compat);
|
||||
extern void of_fdt_unflatten_tree(unsigned long *blob,
|
||||
struct device_node **mynodes);
|
||||
|
||||
/* TBD: Temporary export of fdt globals - remove when code fully merged */
|
||||
extern int __initdata dt_root_addr_cells;
|
||||
extern int __initdata dt_root_size_cells;
|
||||
@ -71,6 +88,7 @@ extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
|
||||
extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
|
||||
unsigned long *size);
|
||||
extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
|
||||
extern int of_flat_dt_match(unsigned long node, const char **matches);
|
||||
extern unsigned long of_get_flat_dt_root(void);
|
||||
|
||||
extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
|
||||
|
15
include/linux/of_net.h
Normal file
15
include/linux/of_net.h
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* OF helpers for network devices.
|
||||
*
|
||||
* This file is released under the GPLv2
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_OF_NET_H
|
||||
#define __LINUX_OF_NET_H
|
||||
|
||||
#ifdef CONFIG_OF_NET
|
||||
#include <linux/of.h>
|
||||
extern const void *of_get_mac_address(struct device_node *np);
|
||||
#endif
|
||||
|
||||
#endif /* __LINUX_OF_NET_H */
|
@ -200,6 +200,29 @@ quiet_cmd_gzip = GZIP $@
|
||||
cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \
|
||||
(rm -f $@ ; false)
|
||||
|
||||
# DTC
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Generate an assembly file to wrap the output of the device tree compiler
|
||||
quiet_cmd_dt_S_dtb= DTB $@
|
||||
cmd_dt_S_dtb= \
|
||||
( \
|
||||
echo '\#include <asm-generic/vmlinux.lds.h>'; \
|
||||
echo '.section .dtb.init.rodata,"a"'; \
|
||||
echo '.balign STRUCT_ALIGNMENT'; \
|
||||
echo '.global __dtb_$(*F)_begin'; \
|
||||
echo '__dtb_$(*F)_begin:'; \
|
||||
echo '.incbin "$<" '; \
|
||||
echo '__dtb_$(*F)_end:'; \
|
||||
echo '.global __dtb_$(*F)_end'; \
|
||||
echo '.balign STRUCT_ALIGNMENT'; \
|
||||
) > $@
|
||||
|
||||
$(obj)/%.dtb.S: $(obj)/%.dtb
|
||||
$(call cmd,dt_S_dtb)
|
||||
|
||||
quiet_cmd_dtc = DTC $@
|
||||
cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $<
|
||||
|
||||
# Bzip2
|
||||
# ---------------------------------------------------------------------------
|
||||
|
@ -4,7 +4,7 @@ hostprogs-y := dtc
|
||||
always := $(hostprogs-y)
|
||||
|
||||
dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
|
||||
srcpos.o checks.o
|
||||
srcpos.o checks.o util.o
|
||||
dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o
|
||||
|
||||
# Source files need to get at the userspace version of libfdt_env.h to compile
|
||||
@ -19,6 +19,7 @@ HOSTCFLAGS_fstree.o := $(HOSTCFLAGS_DTC)
|
||||
HOSTCFLAGS_livetree.o := $(HOSTCFLAGS_DTC)
|
||||
HOSTCFLAGS_srcpos.o := $(HOSTCFLAGS_DTC)
|
||||
HOSTCFLAGS_treesource.o := $(HOSTCFLAGS_DTC)
|
||||
HOSTCFLAGS_util.o := $(HOSTCFLAGS_DTC)
|
||||
|
||||
HOSTCFLAGS_dtc-lexer.lex.o := $(HOSTCFLAGS_DTC)
|
||||
HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC)
|
||||
|
@ -278,32 +278,112 @@ static void check_property_name_chars(struct check *c, struct node *dt,
|
||||
}
|
||||
PROP_CHECK(property_name_chars, PROPNODECHARS, ERROR);
|
||||
|
||||
static void check_explicit_phandles(struct check *c, struct node *root,
|
||||
struct node *node)
|
||||
#define DESCLABEL_FMT "%s%s%s%s%s"
|
||||
#define DESCLABEL_ARGS(node,prop,mark) \
|
||||
((mark) ? "value of " : ""), \
|
||||
((prop) ? "'" : ""), \
|
||||
((prop) ? (prop)->name : ""), \
|
||||
((prop) ? "' in " : ""), (node)->fullpath
|
||||
|
||||
static void check_duplicate_label(struct check *c, struct node *dt,
|
||||
const char *label, struct node *node,
|
||||
struct property *prop, struct marker *mark)
|
||||
{
|
||||
struct property *prop;
|
||||
struct node *othernode = NULL;
|
||||
struct property *otherprop = NULL;
|
||||
struct marker *othermark = NULL;
|
||||
|
||||
othernode = get_node_by_label(dt, label);
|
||||
|
||||
if (!othernode)
|
||||
otherprop = get_property_by_label(dt, label, &othernode);
|
||||
if (!othernode)
|
||||
othermark = get_marker_label(dt, label, &othernode,
|
||||
&otherprop);
|
||||
|
||||
if (!othernode)
|
||||
return;
|
||||
|
||||
if ((othernode != node) || (otherprop != prop) || (othermark != mark))
|
||||
FAIL(c, "Duplicate label '%s' on " DESCLABEL_FMT
|
||||
" and " DESCLABEL_FMT,
|
||||
label, DESCLABEL_ARGS(node, prop, mark),
|
||||
DESCLABEL_ARGS(othernode, otherprop, othermark));
|
||||
}
|
||||
|
||||
static void check_duplicate_label_node(struct check *c, struct node *dt,
|
||||
struct node *node)
|
||||
{
|
||||
struct label *l;
|
||||
|
||||
for_each_label(node->labels, l)
|
||||
check_duplicate_label(c, dt, l->label, node, NULL, NULL);
|
||||
}
|
||||
static void check_duplicate_label_prop(struct check *c, struct node *dt,
|
||||
struct node *node, struct property *prop)
|
||||
{
|
||||
struct marker *m = prop->val.markers;
|
||||
struct label *l;
|
||||
|
||||
for_each_label(prop->labels, l)
|
||||
check_duplicate_label(c, dt, l->label, node, prop, NULL);
|
||||
|
||||
for_each_marker_of_type(m, LABEL)
|
||||
check_duplicate_label(c, dt, m->ref, node, prop, m);
|
||||
}
|
||||
CHECK(duplicate_label, NULL, check_duplicate_label_node,
|
||||
check_duplicate_label_prop, NULL, ERROR);
|
||||
|
||||
static void check_explicit_phandles(struct check *c, struct node *root,
|
||||
struct node *node, struct property *prop)
|
||||
{
|
||||
struct marker *m;
|
||||
struct node *other;
|
||||
cell_t phandle;
|
||||
|
||||
prop = get_property(node, "linux,phandle");
|
||||
if (! prop)
|
||||
return; /* No phandle, that's fine */
|
||||
if (!streq(prop->name, "phandle")
|
||||
&& !streq(prop->name, "linux,phandle"))
|
||||
return;
|
||||
|
||||
if (prop->val.len != sizeof(cell_t)) {
|
||||
FAIL(c, "%s has bad length (%d) linux,phandle property",
|
||||
node->fullpath, prop->val.len);
|
||||
FAIL(c, "%s has bad length (%d) %s property",
|
||||
node->fullpath, prop->val.len, prop->name);
|
||||
return;
|
||||
}
|
||||
|
||||
m = prop->val.markers;
|
||||
for_each_marker_of_type(m, REF_PHANDLE) {
|
||||
assert(m->offset == 0);
|
||||
if (node != get_node_by_ref(root, m->ref))
|
||||
/* "Set this node's phandle equal to some
|
||||
* other node's phandle". That's nonsensical
|
||||
* by construction. */ {
|
||||
FAIL(c, "%s in %s is a reference to another node",
|
||||
prop->name, node->fullpath);
|
||||
return;
|
||||
}
|
||||
/* But setting this node's phandle equal to its own
|
||||
* phandle is allowed - that means allocate a unique
|
||||
* phandle for this node, even if it's not otherwise
|
||||
* referenced. The value will be filled in later, so
|
||||
* no further checking for now. */
|
||||
return;
|
||||
}
|
||||
|
||||
phandle = propval_cell(prop);
|
||||
|
||||
if ((phandle == 0) || (phandle == -1)) {
|
||||
FAIL(c, "%s has invalid linux,phandle value 0x%x",
|
||||
node->fullpath, phandle);
|
||||
FAIL(c, "%s has bad value (0x%x) in %s property",
|
||||
node->fullpath, phandle, prop->name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (node->phandle && (node->phandle != phandle))
|
||||
FAIL(c, "%s has %s property which replaces existing phandle information",
|
||||
node->fullpath, prop->name);
|
||||
|
||||
other = get_node_by_phandle(root, phandle);
|
||||
if (other) {
|
||||
if (other && (other != node)) {
|
||||
FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)",
|
||||
node->fullpath, phandle, other->fullpath);
|
||||
return;
|
||||
@ -311,7 +391,7 @@ static void check_explicit_phandles(struct check *c, struct node *root,
|
||||
|
||||
node->phandle = phandle;
|
||||
}
|
||||
NODE_CHECK(explicit_phandles, NULL, ERROR);
|
||||
PROP_CHECK(explicit_phandles, NULL, ERROR);
|
||||
|
||||
static void check_name_properties(struct check *c, struct node *root,
|
||||
struct node *node)
|
||||
@ -549,6 +629,9 @@ static struct check *check_table[] = {
|
||||
&duplicate_node_names, &duplicate_property_names,
|
||||
&node_name_chars, &node_name_format, &property_name_chars,
|
||||
&name_is_string, &name_properties,
|
||||
|
||||
&duplicate_label,
|
||||
|
||||
&explicit_phandles,
|
||||
&phandle_references, &path_references,
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
* USA
|
||||
*/
|
||||
|
||||
%option noyywrap noinput nounput yylineno
|
||||
%option noyywrap nounput noinput never-interactive
|
||||
|
||||
%x INCLUDE
|
||||
%x BYTESTRING
|
||||
@ -38,6 +38,13 @@ LINECOMMENT "//".*\n
|
||||
#include "srcpos.h"
|
||||
#include "dtc-parser.tab.h"
|
||||
|
||||
YYLTYPE yylloc;
|
||||
|
||||
/* CAUTION: this will stop working if we ever use yyless() or yyunput() */
|
||||
#define YY_USER_ACTION \
|
||||
{ \
|
||||
srcpos_update(&yylloc, yytext, yyleng); \
|
||||
}
|
||||
|
||||
/*#define LEXDEBUG 1*/
|
||||
|
||||
@ -47,15 +54,10 @@ LINECOMMENT "//".*\n
|
||||
#define DPRINT(fmt, ...) do { } while (0)
|
||||
#endif
|
||||
|
||||
static int dts_version; /* = 0 */
|
||||
static int dts_version = 1;
|
||||
|
||||
#define BEGIN_DEFAULT() if (dts_version == 0) { \
|
||||
DPRINT("<INITIAL>\n"); \
|
||||
BEGIN(INITIAL); \
|
||||
} else { \
|
||||
DPRINT("<V1>\n"); \
|
||||
#define BEGIN_DEFAULT() DPRINT("<V1>\n"); \
|
||||
BEGIN(V1); \
|
||||
}
|
||||
|
||||
static void push_input_file(const char *filename);
|
||||
static int pop_input_file(void);
|
||||
@ -75,18 +77,13 @@ static int pop_input_file(void);
|
||||
}
|
||||
|
||||
<*>{STRING} {
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("String: %s\n", yytext);
|
||||
yylval.data = data_copy_escape_string(yytext+1,
|
||||
yyleng-2);
|
||||
yylloc.first_line = yylineno;
|
||||
return DT_STRING;
|
||||
}
|
||||
|
||||
<*>"/dts-v1/" {
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Keyword: /dts-v1/\n");
|
||||
dts_version = 1;
|
||||
BEGIN_DEFAULT();
|
||||
@ -94,106 +91,57 @@ static int pop_input_file(void);
|
||||
}
|
||||
|
||||
<*>"/memreserve/" {
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Keyword: /memreserve/\n");
|
||||
BEGIN_DEFAULT();
|
||||
return DT_MEMRESERVE;
|
||||
}
|
||||
|
||||
<*>{LABEL}: {
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Label: %s\n", yytext);
|
||||
yylval.labelref = strdup(yytext);
|
||||
yylval.labelref = xstrdup(yytext);
|
||||
yylval.labelref[yyleng-1] = '\0';
|
||||
return DT_LABEL;
|
||||
}
|
||||
|
||||
<INITIAL>[bodh]# {
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
if (*yytext == 'b')
|
||||
yylval.cbase = 2;
|
||||
else if (*yytext == 'o')
|
||||
yylval.cbase = 8;
|
||||
else if (*yytext == 'd')
|
||||
yylval.cbase = 10;
|
||||
else
|
||||
yylval.cbase = 16;
|
||||
DPRINT("Base: %d\n", yylval.cbase);
|
||||
return DT_BASE;
|
||||
}
|
||||
|
||||
<INITIAL>[0-9a-fA-F]+ {
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
yylval.literal = strdup(yytext);
|
||||
DPRINT("Literal: '%s'\n", yylval.literal);
|
||||
return DT_LEGACYLITERAL;
|
||||
}
|
||||
|
||||
<V1>[0-9]+|0[xX][0-9a-fA-F]+ {
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
yylval.literal = strdup(yytext);
|
||||
yylval.literal = xstrdup(yytext);
|
||||
DPRINT("Literal: '%s'\n", yylval.literal);
|
||||
return DT_LITERAL;
|
||||
}
|
||||
|
||||
\&{LABEL} { /* label reference */
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
<*>\&{LABEL} { /* label reference */
|
||||
DPRINT("Ref: %s\n", yytext+1);
|
||||
yylval.labelref = strdup(yytext+1);
|
||||
yylval.labelref = xstrdup(yytext+1);
|
||||
return DT_REF;
|
||||
}
|
||||
|
||||
"&{/"{PATHCHAR}+\} { /* new-style path reference */
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
<*>"&{/"{PATHCHAR}+\} { /* new-style path reference */
|
||||
yytext[yyleng-1] = '\0';
|
||||
DPRINT("Ref: %s\n", yytext+2);
|
||||
yylval.labelref = strdup(yytext+2);
|
||||
return DT_REF;
|
||||
}
|
||||
|
||||
<INITIAL>"&/"{PATHCHAR}+ { /* old-style path reference */
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Ref: %s\n", yytext+1);
|
||||
yylval.labelref = strdup(yytext+1);
|
||||
yylval.labelref = xstrdup(yytext+2);
|
||||
return DT_REF;
|
||||
}
|
||||
|
||||
<BYTESTRING>[0-9a-fA-F]{2} {
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
yylval.byte = strtol(yytext, NULL, 16);
|
||||
DPRINT("Byte: %02x\n", (int)yylval.byte);
|
||||
return DT_BYTE;
|
||||
}
|
||||
|
||||
<BYTESTRING>"]" {
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("/BYTESTRING\n");
|
||||
BEGIN_DEFAULT();
|
||||
return ']';
|
||||
}
|
||||
|
||||
<PROPNODENAME>{PROPNODECHAR}+ {
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("PropNodeName: %s\n", yytext);
|
||||
yylval.propnodename = strdup(yytext);
|
||||
yylval.propnodename = xstrdup(yytext);
|
||||
BEGIN_DEFAULT();
|
||||
return DT_PROPNODENAME;
|
||||
}
|
||||
|
||||
"/incbin/" {
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Binary Include\n");
|
||||
return DT_INCBIN;
|
||||
}
|
||||
@ -203,8 +151,6 @@ static int pop_input_file(void);
|
||||
<*>{LINECOMMENT}+ /* eat C++-style comments */
|
||||
|
||||
<*>. {
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Char: %c (\\x%02x)\n", yytext[0],
|
||||
(unsigned)yytext[0]);
|
||||
if (yytext[0] == '[') {
|
||||
@ -221,100 +167,25 @@ static int pop_input_file(void);
|
||||
|
||||
%%
|
||||
|
||||
|
||||
/*
|
||||
* Stack of nested include file contexts.
|
||||
*/
|
||||
|
||||
struct incl_file {
|
||||
struct dtc_file *file;
|
||||
YY_BUFFER_STATE yy_prev_buf;
|
||||
int yy_prev_lineno;
|
||||
struct incl_file *prev;
|
||||
};
|
||||
|
||||
static struct incl_file *incl_file_stack;
|
||||
|
||||
|
||||
/*
|
||||
* Detect infinite include recursion.
|
||||
*/
|
||||
#define MAX_INCLUDE_DEPTH (100)
|
||||
|
||||
static int incl_depth = 0;
|
||||
|
||||
|
||||
static void push_input_file(const char *filename)
|
||||
{
|
||||
struct incl_file *incl_file;
|
||||
struct dtc_file *newfile;
|
||||
struct search_path search, *searchptr = NULL;
|
||||
|
||||
assert(filename);
|
||||
|
||||
if (incl_depth++ >= MAX_INCLUDE_DEPTH)
|
||||
die("Includes nested too deeply");
|
||||
srcfile_push(filename);
|
||||
|
||||
if (srcpos_file) {
|
||||
search.dir = srcpos_file->dir;
|
||||
search.next = NULL;
|
||||
search.prev = NULL;
|
||||
searchptr = &search;
|
||||
}
|
||||
yyin = current_srcfile->f;
|
||||
|
||||
newfile = dtc_open_file(filename, searchptr);
|
||||
|
||||
incl_file = xmalloc(sizeof(struct incl_file));
|
||||
|
||||
/*
|
||||
* Save current context.
|
||||
*/
|
||||
incl_file->yy_prev_buf = YY_CURRENT_BUFFER;
|
||||
incl_file->yy_prev_lineno = yylineno;
|
||||
incl_file->file = srcpos_file;
|
||||
incl_file->prev = incl_file_stack;
|
||||
|
||||
incl_file_stack = incl_file;
|
||||
|
||||
/*
|
||||
* Establish new context.
|
||||
*/
|
||||
srcpos_file = newfile;
|
||||
yylineno = 1;
|
||||
yyin = newfile->file;
|
||||
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
|
||||
yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE));
|
||||
}
|
||||
|
||||
|
||||
static int pop_input_file(void)
|
||||
{
|
||||
struct incl_file *incl_file;
|
||||
|
||||
if (incl_file_stack == 0)
|
||||
if (srcfile_pop() == 0)
|
||||
return 0;
|
||||
|
||||
dtc_close_file(srcpos_file);
|
||||
|
||||
/*
|
||||
* Pop.
|
||||
*/
|
||||
--incl_depth;
|
||||
incl_file = incl_file_stack;
|
||||
incl_file_stack = incl_file->prev;
|
||||
|
||||
/*
|
||||
* Recover old context.
|
||||
*/
|
||||
yy_delete_buffer(YY_CURRENT_BUFFER);
|
||||
yy_switch_to_buffer(incl_file->yy_prev_buf);
|
||||
yylineno = incl_file->yy_prev_lineno;
|
||||
srcpos_file = incl_file->file;
|
||||
yyin = incl_file->file ? incl_file->file->file : NULL;
|
||||
|
||||
/*
|
||||
* Free old state.
|
||||
*/
|
||||
free(incl_file);
|
||||
yypop_buffer_state();
|
||||
yyin = current_srcfile->f;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -170,20 +170,7 @@ extern FILE *yyin, *yyout;
|
||||
#define EOB_ACT_END_OF_FILE 1
|
||||
#define EOB_ACT_LAST_MATCH 2
|
||||
|
||||
/* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
|
||||
* access to the local variable yy_act. Since yyless() is a macro, it would break
|
||||
* existing scanners that call yyless() from OUTSIDE yylex.
|
||||
* One obvious solution it to make yy_act a global. I tried that, and saw
|
||||
* a 5% performance hit in a non-yylineno scanner, because yy_act is
|
||||
* normally declared as a register variable-- so it is not worth it.
|
||||
*/
|
||||
#define YY_LESS_LINENO(n) \
|
||||
do { \
|
||||
int yyl;\
|
||||
for ( yyl = n; yyl < yyleng; ++yyl )\
|
||||
if ( yytext[yyl] == '\n' )\
|
||||
--yylineno;\
|
||||
}while(0)
|
||||
#define YY_LESS_LINENO(n)
|
||||
|
||||
/* Return all but the first "n" matched characters back to the input stream. */
|
||||
#define yyless(n) \
|
||||
@ -385,8 +372,8 @@ static void yy_fatal_error (yyconst char msg[] );
|
||||
*yy_cp = '\0'; \
|
||||
(yy_c_buf_p) = yy_cp;
|
||||
|
||||
#define YY_NUM_RULES 20
|
||||
#define YY_END_OF_BUFFER 21
|
||||
#define YY_NUM_RULES 17
|
||||
#define YY_END_OF_BUFFER 18
|
||||
/* This struct is not used in this scanner,
|
||||
but its presence is necessary. */
|
||||
struct yy_trans_info
|
||||
@ -394,20 +381,19 @@ struct yy_trans_info
|
||||
flex_int32_t yy_verify;
|
||||
flex_int32_t yy_nxt;
|
||||
};
|
||||
static yyconst flex_int16_t yy_accept[104] =
|
||||
static yyconst flex_int16_t yy_accept[94] =
|
||||
{ 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
21, 19, 16, 16, 19, 19, 19, 7, 7, 19,
|
||||
7, 19, 19, 19, 19, 13, 14, 14, 19, 8,
|
||||
8, 16, 0, 2, 0, 0, 9, 0, 0, 0,
|
||||
0, 0, 0, 7, 7, 5, 0, 6, 0, 12,
|
||||
12, 14, 14, 8, 0, 11, 9, 0, 0, 0,
|
||||
0, 18, 0, 0, 0, 0, 8, 0, 17, 0,
|
||||
0, 0, 0, 0, 10, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 3, 15,
|
||||
18, 16, 13, 13, 16, 16, 16, 16, 16, 16,
|
||||
16, 10, 11, 11, 6, 6, 13, 0, 2, 0,
|
||||
7, 0, 0, 0, 0, 0, 0, 0, 5, 0,
|
||||
9, 9, 11, 11, 6, 0, 7, 0, 0, 0,
|
||||
0, 15, 0, 0, 0, 0, 6, 0, 14, 0,
|
||||
0, 0, 0, 0, 8, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 3, 12,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
|
||||
|
||||
0, 4, 0
|
||||
|
||||
} ;
|
||||
|
||||
static yyconst flex_int32_t yy_ec[256] =
|
||||
@ -416,16 +402,16 @@ static yyconst flex_int32_t yy_ec[256] =
|
||||
2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 2, 1, 4, 5, 1, 1, 6, 1, 1,
|
||||
1, 7, 8, 8, 9, 8, 10, 11, 12, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 14, 1, 1,
|
||||
1, 1, 8, 8, 15, 15, 15, 15, 15, 15,
|
||||
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 17, 16, 16,
|
||||
1, 18, 19, 1, 16, 1, 15, 20, 21, 22,
|
||||
1, 7, 5, 5, 8, 5, 9, 10, 11, 12,
|
||||
12, 12, 12, 12, 12, 12, 12, 13, 1, 1,
|
||||
1, 1, 5, 5, 14, 14, 14, 14, 14, 14,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 16, 15, 15,
|
||||
1, 17, 18, 1, 15, 1, 14, 19, 20, 21,
|
||||
|
||||
23, 15, 16, 24, 25, 16, 16, 26, 27, 28,
|
||||
24, 16, 16, 29, 30, 31, 32, 33, 16, 17,
|
||||
16, 16, 34, 1, 35, 1, 1, 1, 1, 1,
|
||||
22, 14, 15, 15, 23, 15, 15, 24, 25, 26,
|
||||
15, 15, 15, 27, 28, 29, 30, 31, 15, 16,
|
||||
15, 15, 32, 1, 33, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
@ -442,136 +428,114 @@ static yyconst flex_int32_t yy_ec[256] =
|
||||
1, 1, 1, 1, 1
|
||||
} ;
|
||||
|
||||
static yyconst flex_int32_t yy_meta[36] =
|
||||
static yyconst flex_int32_t yy_meta[34] =
|
||||
{ 0,
|
||||
1, 1, 1, 1, 2, 1, 2, 2, 2, 3,
|
||||
4, 4, 4, 5, 6, 7, 7, 1, 1, 6,
|
||||
6, 6, 6, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 8, 1
|
||||
1, 1, 1, 1, 2, 1, 2, 2, 3, 4,
|
||||
4, 4, 5, 6, 7, 7, 1, 1, 6, 6,
|
||||
6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 8, 1
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_base[117] =
|
||||
static yyconst flex_int16_t yy_base[106] =
|
||||
{ 0,
|
||||
0, 0, 30, 0, 44, 0, 67, 0, 97, 105,
|
||||
302, 303, 35, 44, 40, 94, 112, 0, 129, 152,
|
||||
296, 295, 159, 0, 176, 303, 0, 116, 95, 165,
|
||||
49, 46, 102, 303, 296, 0, 0, 288, 290, 293,
|
||||
264, 266, 270, 0, 0, 303, 0, 303, 264, 303,
|
||||
0, 0, 195, 101, 0, 0, 0, 0, 284, 125,
|
||||
277, 265, 225, 230, 216, 218, 0, 202, 224, 221,
|
||||
217, 107, 196, 188, 303, 206, 179, 186, 178, 185,
|
||||
183, 162, 161, 150, 169, 160, 145, 125, 303, 303,
|
||||
137, 109, 190, 103, 203, 167, 108, 197, 303, 123,
|
||||
0, 0, 237, 236, 25, 0, 47, 0, 30, 71,
|
||||
244, 247, 82, 84, 84, 211, 95, 229, 218, 0,
|
||||
111, 247, 0, 84, 83, 95, 106, 86, 247, 237,
|
||||
0, 230, 231, 234, 207, 209, 212, 220, 247, 206,
|
||||
247, 218, 0, 106, 116, 0, 0, 0, 223, 89,
|
||||
226, 219, 199, 206, 200, 204, 0, 190, 213, 212,
|
||||
202, 91, 178, 161, 247, 172, 144, 150, 140, 130,
|
||||
140, 124, 128, 120, 138, 137, 123, 122, 247, 247,
|
||||
134, 114, 132, 86, 135, 125, 90, 136, 247, 97,
|
||||
29, 247, 247, 153, 156, 161, 165, 170, 176, 180,
|
||||
|
||||
29, 303, 303, 215, 221, 226, 229, 234, 240, 246,
|
||||
250, 257, 265, 270, 275, 282
|
||||
187, 195, 200, 205, 212
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_def[117] =
|
||||
static yyconst flex_int16_t yy_def[106] =
|
||||
{ 0,
|
||||
103, 1, 1, 3, 3, 5, 103, 7, 3, 3,
|
||||
103, 103, 103, 103, 104, 105, 103, 106, 103, 19,
|
||||
19, 20, 103, 107, 20, 103, 108, 109, 105, 103,
|
||||
103, 103, 104, 103, 104, 110, 111, 103, 112, 113,
|
||||
103, 103, 103, 106, 19, 103, 20, 103, 103, 103,
|
||||
20, 108, 109, 103, 114, 110, 111, 115, 112, 112,
|
||||
113, 103, 103, 103, 103, 103, 114, 115, 103, 103,
|
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
|
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
|
||||
103, 103, 103, 103, 103, 116, 103, 116, 103, 116,
|
||||
93, 1, 1, 1, 1, 5, 93, 7, 1, 1,
|
||||
93, 93, 93, 93, 94, 95, 93, 96, 17, 97,
|
||||
96, 93, 98, 99, 93, 93, 93, 94, 93, 94,
|
||||
100, 93, 101, 102, 93, 93, 93, 96, 93, 93,
|
||||
93, 96, 98, 99, 93, 103, 100, 104, 101, 101,
|
||||
102, 93, 93, 93, 93, 93, 103, 104, 93, 93,
|
||||
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
|
||||
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
|
||||
93, 93, 93, 93, 93, 105, 93, 105, 93, 105,
|
||||
93, 93, 0, 93, 93, 93, 93, 93, 93, 93,
|
||||
|
||||
103, 103, 0, 103, 103, 103, 103, 103, 103, 103,
|
||||
103, 103, 103, 103, 103, 103
|
||||
93, 93, 93, 93, 93
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_nxt[339] =
|
||||
static yyconst flex_int16_t yy_nxt[281] =
|
||||
{ 0,
|
||||
12, 13, 14, 15, 12, 16, 12, 12, 12, 17,
|
||||
18, 18, 18, 12, 19, 20, 20, 12, 12, 21,
|
||||
19, 21, 19, 22, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 12, 12, 12, 32, 32, 102, 23,
|
||||
12, 12, 12, 34, 20, 32, 32, 32, 32, 20,
|
||||
20, 20, 20, 20, 24, 24, 24, 35, 25, 54,
|
||||
54, 54, 26, 25, 25, 25, 25, 12, 13, 14,
|
||||
15, 27, 12, 27, 27, 27, 23, 27, 27, 27,
|
||||
12, 28, 28, 28, 12, 12, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
12, 13, 14, 15, 12, 16, 12, 12, 17, 12,
|
||||
12, 12, 12, 18, 18, 18, 12, 12, 18, 18,
|
||||
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
|
||||
18, 12, 12, 19, 20, 20, 20, 92, 21, 25,
|
||||
26, 26, 22, 21, 21, 21, 21, 12, 13, 14,
|
||||
15, 23, 16, 23, 23, 19, 23, 23, 23, 12,
|
||||
24, 24, 24, 12, 12, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 12, 12,
|
||||
25, 26, 26, 27, 27, 27, 27, 29, 43, 29,
|
||||
43, 43, 45, 45, 45, 50, 39, 59, 46, 93,
|
||||
|
||||
12, 12, 29, 36, 103, 34, 17, 30, 31, 31,
|
||||
29, 54, 54, 54, 17, 30, 31, 31, 39, 35,
|
||||
52, 40, 52, 52, 52, 103, 78, 38, 38, 46,
|
||||
101, 60, 79, 41, 69, 97, 42, 94, 43, 45,
|
||||
45, 45, 46, 45, 47, 47, 93, 92, 45, 45,
|
||||
45, 45, 47, 47, 47, 47, 47, 47, 47, 47,
|
||||
47, 47, 47, 47, 47, 39, 47, 91, 40, 90,
|
||||
99, 47, 47, 47, 47, 54, 54, 54, 89, 88,
|
||||
41, 55, 87, 49, 100, 43, 51, 51, 51, 86,
|
||||
51, 95, 95, 96, 85, 51, 51, 51, 51, 52,
|
||||
30, 33, 30, 34, 45, 45, 45, 27, 27, 68,
|
||||
43, 91, 43, 43, 69, 35, 87, 36, 39, 37,
|
||||
42, 42, 42, 39, 42, 45, 45, 45, 89, 42,
|
||||
42, 42, 42, 85, 85, 86, 85, 85, 86, 89,
|
||||
84, 90, 83, 82, 81, 80, 79, 78, 77, 76,
|
||||
75, 74, 90, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 31, 31, 31, 38, 38, 38, 38, 41, 73,
|
||||
41, 43, 72, 43, 71, 43, 43, 44, 33, 44,
|
||||
44, 44, 44, 47, 69, 47, 47, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 51, 51, 51, 51, 51,
|
||||
|
||||
99, 52, 52, 52, 95, 95, 96, 84, 46, 83,
|
||||
82, 81, 39, 79, 100, 33, 33, 33, 33, 33,
|
||||
33, 33, 33, 37, 80, 77, 37, 37, 37, 44,
|
||||
40, 44, 50, 76, 50, 52, 75, 52, 74, 52,
|
||||
52, 53, 73, 53, 53, 53, 53, 56, 56, 56,
|
||||
72, 56, 56, 57, 71, 57, 57, 59, 59, 59,
|
||||
59, 59, 59, 59, 59, 61, 61, 61, 61, 61,
|
||||
61, 61, 61, 67, 70, 67, 68, 68, 68, 62,
|
||||
68, 68, 98, 98, 98, 98, 98, 98, 98, 98,
|
||||
60, 66, 65, 64, 63, 62, 60, 58, 103, 48,
|
||||
|
||||
48, 103, 11, 103, 103, 103, 103, 103, 103, 103,
|
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
|
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
|
||||
103, 103, 103, 103, 103, 103, 103, 103
|
||||
51, 51, 51, 57, 70, 57, 58, 58, 58, 67,
|
||||
58, 58, 88, 88, 88, 88, 88, 88, 88, 88,
|
||||
34, 66, 65, 64, 63, 62, 61, 60, 52, 50,
|
||||
39, 56, 39, 55, 54, 53, 52, 50, 48, 93,
|
||||
40, 39, 32, 93, 19, 19, 11, 93, 93, 93,
|
||||
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
|
||||
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
|
||||
93, 93, 93, 93, 93, 93, 93, 93, 93, 93
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_chk[339] =
|
||||
static yyconst flex_int16_t yy_chk[281] =
|
||||
{ 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 3, 13, 13, 101, 3,
|
||||
3, 3, 3, 15, 3, 14, 14, 32, 32, 3,
|
||||
3, 3, 3, 3, 5, 5, 5, 15, 5, 31,
|
||||
31, 31, 5, 5, 5, 5, 5, 7, 7, 7,
|
||||
1, 1, 1, 5, 5, 5, 5, 91, 5, 9,
|
||||
9, 9, 5, 5, 5, 5, 5, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
10, 10, 10, 13, 13, 14, 14, 15, 24, 28,
|
||||
24, 24, 25, 25, 25, 50, 24, 50, 25, 90,
|
||||
|
||||
7, 7, 9, 16, 29, 33, 9, 9, 9, 9,
|
||||
10, 54, 54, 54, 10, 10, 10, 10, 17, 33,
|
||||
28, 17, 28, 28, 28, 100, 72, 16, 29, 28,
|
||||
97, 60, 72, 17, 60, 94, 17, 92, 17, 19,
|
||||
19, 19, 19, 19, 19, 19, 91, 88, 19, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
|
||||
19, 19, 20, 20, 20, 23, 20, 87, 23, 86,
|
||||
96, 20, 20, 20, 20, 30, 30, 30, 85, 84,
|
||||
23, 30, 83, 23, 96, 23, 25, 25, 25, 82,
|
||||
25, 93, 93, 93, 81, 25, 25, 25, 25, 53,
|
||||
15, 17, 28, 17, 26, 26, 26, 27, 27, 62,
|
||||
44, 87, 44, 44, 62, 17, 84, 17, 44, 17,
|
||||
21, 21, 21, 21, 21, 45, 45, 45, 86, 21,
|
||||
21, 21, 21, 83, 83, 83, 85, 85, 85, 88,
|
||||
82, 86, 81, 78, 77, 76, 75, 74, 73, 72,
|
||||
71, 70, 88, 94, 94, 94, 94, 94, 94, 94,
|
||||
94, 95, 95, 95, 96, 96, 96, 96, 97, 69,
|
||||
97, 98, 68, 98, 67, 98, 98, 99, 66, 99,
|
||||
99, 99, 99, 100, 64, 100, 100, 101, 101, 101,
|
||||
101, 101, 101, 101, 101, 102, 102, 102, 102, 102,
|
||||
|
||||
98, 53, 53, 53, 95, 95, 95, 80, 53, 79,
|
||||
78, 77, 76, 74, 98, 104, 104, 104, 104, 104,
|
||||
104, 104, 104, 105, 73, 71, 105, 105, 105, 106,
|
||||
70, 106, 107, 69, 107, 108, 68, 108, 66, 108,
|
||||
108, 109, 65, 109, 109, 109, 109, 110, 110, 110,
|
||||
64, 110, 110, 111, 63, 111, 111, 112, 112, 112,
|
||||
112, 112, 112, 112, 112, 113, 113, 113, 113, 113,
|
||||
113, 113, 113, 114, 62, 114, 115, 115, 115, 61,
|
||||
115, 115, 116, 116, 116, 116, 116, 116, 116, 116,
|
||||
59, 49, 43, 42, 41, 40, 39, 38, 35, 22,
|
||||
|
||||
21, 11, 103, 103, 103, 103, 103, 103, 103, 103,
|
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
|
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
|
||||
103, 103, 103, 103, 103, 103, 103, 103
|
||||
102, 102, 102, 103, 63, 103, 104, 104, 104, 61,
|
||||
104, 104, 105, 105, 105, 105, 105, 105, 105, 105,
|
||||
60, 59, 58, 56, 55, 54, 53, 52, 51, 49,
|
||||
42, 40, 38, 37, 36, 35, 34, 33, 32, 30,
|
||||
19, 18, 16, 11, 4, 3, 93, 93, 93, 93,
|
||||
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
|
||||
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
|
||||
93, 93, 93, 93, 93, 93, 93, 93, 93, 93
|
||||
} ;
|
||||
|
||||
/* Table of booleans, true if rule could match eol. */
|
||||
static yyconst flex_int32_t yy_rule_can_match_eol[21] =
|
||||
{ 0,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0,
|
||||
0, };
|
||||
|
||||
static yy_state_type yy_last_accepting_state;
|
||||
static char *yy_last_accepting_cpos;
|
||||
|
||||
@ -616,6 +580,13 @@ char *yytext;
|
||||
#include "srcpos.h"
|
||||
#include "dtc-parser.tab.h"
|
||||
|
||||
YYLTYPE yylloc;
|
||||
|
||||
/* CAUTION: this will stop working if we ever use yyless() or yyunput() */
|
||||
#define YY_USER_ACTION \
|
||||
{ \
|
||||
srcpos_update(&yylloc, yytext, yyleng); \
|
||||
}
|
||||
|
||||
/*#define LEXDEBUG 1*/
|
||||
|
||||
@ -625,19 +596,14 @@ char *yytext;
|
||||
#define DPRINT(fmt, ...) do { } while (0)
|
||||
#endif
|
||||
|
||||
static int dts_version; /* = 0 */
|
||||
static int dts_version = 1;
|
||||
|
||||
#define BEGIN_DEFAULT() if (dts_version == 0) { \
|
||||
DPRINT("<INITIAL>\n"); \
|
||||
BEGIN(INITIAL); \
|
||||
} else { \
|
||||
DPRINT("<V1>\n"); \
|
||||
#define BEGIN_DEFAULT() DPRINT("<V1>\n"); \
|
||||
BEGIN(V1); \
|
||||
}
|
||||
|
||||
static void push_input_file(const char *filename);
|
||||
static int pop_input_file(void);
|
||||
#line 641 "dtc-lexer.lex.c"
|
||||
#line 607 "dtc-lexer.lex.c"
|
||||
|
||||
#define INITIAL 0
|
||||
#define INCLUDE 1
|
||||
@ -826,9 +792,9 @@ YY_DECL
|
||||
register char *yy_cp, *yy_bp;
|
||||
register int yy_act;
|
||||
|
||||
#line 64 "dtc-lexer.l"
|
||||
#line 66 "dtc-lexer.l"
|
||||
|
||||
#line 832 "dtc-lexer.lex.c"
|
||||
#line 798 "dtc-lexer.lex.c"
|
||||
|
||||
if ( !(yy_init) )
|
||||
{
|
||||
@ -881,35 +847,21 @@ yy_match:
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 104 )
|
||||
if ( yy_current_state >= 94 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
++yy_cp;
|
||||
}
|
||||
while ( yy_base[yy_current_state] != 303 );
|
||||
while ( yy_current_state != 93 );
|
||||
yy_cp = (yy_last_accepting_cpos);
|
||||
yy_current_state = (yy_last_accepting_state);
|
||||
|
||||
yy_find_action:
|
||||
yy_act = yy_accept[yy_current_state];
|
||||
if ( yy_act == 0 )
|
||||
{ /* have to back up */
|
||||
yy_cp = (yy_last_accepting_cpos);
|
||||
yy_current_state = (yy_last_accepting_state);
|
||||
yy_act = yy_accept[yy_current_state];
|
||||
}
|
||||
|
||||
YY_DO_BEFORE_ACTION;
|
||||
|
||||
if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
|
||||
{
|
||||
int yyl;
|
||||
for ( yyl = 0; yyl < yyleng; ++yyl )
|
||||
if ( yytext[yyl] == '\n' )
|
||||
|
||||
yylineno++;
|
||||
;
|
||||
}
|
||||
|
||||
do_action: /* This label is used only to access EOF actions. */
|
||||
|
||||
switch ( yy_act )
|
||||
@ -924,7 +876,7 @@ do_action: /* This label is used only to access EOF actions. */
|
||||
case 1:
|
||||
/* rule 1 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 65 "dtc-lexer.l"
|
||||
#line 67 "dtc-lexer.l"
|
||||
{
|
||||
char *name = strchr(yytext, '\"') + 1;
|
||||
yytext[yyleng-1] = '\0';
|
||||
@ -936,7 +888,7 @@ case YY_STATE_EOF(INCLUDE):
|
||||
case YY_STATE_EOF(BYTESTRING):
|
||||
case YY_STATE_EOF(PROPNODENAME):
|
||||
case YY_STATE_EOF(V1):
|
||||
#line 71 "dtc-lexer.l"
|
||||
#line 73 "dtc-lexer.l"
|
||||
{
|
||||
if (!pop_input_file()) {
|
||||
yyterminate();
|
||||
@ -946,23 +898,18 @@ case YY_STATE_EOF(V1):
|
||||
case 2:
|
||||
/* rule 2 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 77 "dtc-lexer.l"
|
||||
#line 79 "dtc-lexer.l"
|
||||
{
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("String: %s\n", yytext);
|
||||
yylval.data = data_copy_escape_string(yytext+1,
|
||||
yyleng-2);
|
||||
yylloc.first_line = yylineno;
|
||||
return DT_STRING;
|
||||
}
|
||||
YY_BREAK
|
||||
case 3:
|
||||
YY_RULE_SETUP
|
||||
#line 87 "dtc-lexer.l"
|
||||
#line 86 "dtc-lexer.l"
|
||||
{
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Keyword: /dts-v1/\n");
|
||||
dts_version = 1;
|
||||
BEGIN_DEFAULT();
|
||||
@ -971,10 +918,8 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 4:
|
||||
YY_RULE_SETUP
|
||||
#line 96 "dtc-lexer.l"
|
||||
#line 93 "dtc-lexer.l"
|
||||
{
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Keyword: /memreserve/\n");
|
||||
BEGIN_DEFAULT();
|
||||
return DT_MEMRESERVE;
|
||||
@ -982,158 +927,100 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 5:
|
||||
YY_RULE_SETUP
|
||||
#line 104 "dtc-lexer.l"
|
||||
#line 99 "dtc-lexer.l"
|
||||
{
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Label: %s\n", yytext);
|
||||
yylval.labelref = strdup(yytext);
|
||||
yylval.labelref = xstrdup(yytext);
|
||||
yylval.labelref[yyleng-1] = '\0';
|
||||
return DT_LABEL;
|
||||
}
|
||||
YY_BREAK
|
||||
case 6:
|
||||
YY_RULE_SETUP
|
||||
#line 113 "dtc-lexer.l"
|
||||
#line 106 "dtc-lexer.l"
|
||||
{
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
if (*yytext == 'b')
|
||||
yylval.cbase = 2;
|
||||
else if (*yytext == 'o')
|
||||
yylval.cbase = 8;
|
||||
else if (*yytext == 'd')
|
||||
yylval.cbase = 10;
|
||||
else
|
||||
yylval.cbase = 16;
|
||||
DPRINT("Base: %d\n", yylval.cbase);
|
||||
return DT_BASE;
|
||||
}
|
||||
YY_BREAK
|
||||
case 7:
|
||||
YY_RULE_SETUP
|
||||
#line 128 "dtc-lexer.l"
|
||||
{
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
yylval.literal = strdup(yytext);
|
||||
DPRINT("Literal: '%s'\n", yylval.literal);
|
||||
return DT_LEGACYLITERAL;
|
||||
}
|
||||
YY_BREAK
|
||||
case 8:
|
||||
YY_RULE_SETUP
|
||||
#line 136 "dtc-lexer.l"
|
||||
{
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
yylval.literal = strdup(yytext);
|
||||
yylval.literal = xstrdup(yytext);
|
||||
DPRINT("Literal: '%s'\n", yylval.literal);
|
||||
return DT_LITERAL;
|
||||
}
|
||||
YY_BREAK
|
||||
case 9:
|
||||
case 7:
|
||||
YY_RULE_SETUP
|
||||
#line 144 "dtc-lexer.l"
|
||||
#line 112 "dtc-lexer.l"
|
||||
{ /* label reference */
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Ref: %s\n", yytext+1);
|
||||
yylval.labelref = strdup(yytext+1);
|
||||
yylval.labelref = xstrdup(yytext+1);
|
||||
return DT_REF;
|
||||
}
|
||||
YY_BREAK
|
||||
case 10:
|
||||
case 8:
|
||||
YY_RULE_SETUP
|
||||
#line 152 "dtc-lexer.l"
|
||||
#line 118 "dtc-lexer.l"
|
||||
{ /* new-style path reference */
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
yytext[yyleng-1] = '\0';
|
||||
DPRINT("Ref: %s\n", yytext+2);
|
||||
yylval.labelref = strdup(yytext+2);
|
||||
yylval.labelref = xstrdup(yytext+2);
|
||||
return DT_REF;
|
||||
}
|
||||
YY_BREAK
|
||||
case 11:
|
||||
case 9:
|
||||
YY_RULE_SETUP
|
||||
#line 161 "dtc-lexer.l"
|
||||
{ /* old-style path reference */
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Ref: %s\n", yytext+1);
|
||||
yylval.labelref = strdup(yytext+1);
|
||||
return DT_REF;
|
||||
}
|
||||
YY_BREAK
|
||||
case 12:
|
||||
YY_RULE_SETUP
|
||||
#line 169 "dtc-lexer.l"
|
||||
#line 125 "dtc-lexer.l"
|
||||
{
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
yylval.byte = strtol(yytext, NULL, 16);
|
||||
DPRINT("Byte: %02x\n", (int)yylval.byte);
|
||||
return DT_BYTE;
|
||||
}
|
||||
YY_BREAK
|
||||
case 13:
|
||||
case 10:
|
||||
YY_RULE_SETUP
|
||||
#line 177 "dtc-lexer.l"
|
||||
#line 131 "dtc-lexer.l"
|
||||
{
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("/BYTESTRING\n");
|
||||
BEGIN_DEFAULT();
|
||||
return ']';
|
||||
}
|
||||
YY_BREAK
|
||||
case 14:
|
||||
case 11:
|
||||
YY_RULE_SETUP
|
||||
#line 185 "dtc-lexer.l"
|
||||
#line 137 "dtc-lexer.l"
|
||||
{
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("PropNodeName: %s\n", yytext);
|
||||
yylval.propnodename = strdup(yytext);
|
||||
yylval.propnodename = xstrdup(yytext);
|
||||
BEGIN_DEFAULT();
|
||||
return DT_PROPNODENAME;
|
||||
}
|
||||
YY_BREAK
|
||||
case 15:
|
||||
case 12:
|
||||
YY_RULE_SETUP
|
||||
#line 194 "dtc-lexer.l"
|
||||
#line 144 "dtc-lexer.l"
|
||||
{
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Binary Include\n");
|
||||
return DT_INCBIN;
|
||||
}
|
||||
YY_BREAK
|
||||
case 16:
|
||||
/* rule 16 can match eol */
|
||||
case 13:
|
||||
/* rule 13 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 201 "dtc-lexer.l"
|
||||
#line 149 "dtc-lexer.l"
|
||||
/* eat whitespace */
|
||||
YY_BREAK
|
||||
case 17:
|
||||
/* rule 17 can match eol */
|
||||
case 14:
|
||||
/* rule 14 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 202 "dtc-lexer.l"
|
||||
#line 150 "dtc-lexer.l"
|
||||
/* eat C-style comments */
|
||||
YY_BREAK
|
||||
case 18:
|
||||
/* rule 18 can match eol */
|
||||
case 15:
|
||||
/* rule 15 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 203 "dtc-lexer.l"
|
||||
#line 151 "dtc-lexer.l"
|
||||
/* eat C++-style comments */
|
||||
YY_BREAK
|
||||
case 19:
|
||||
case 16:
|
||||
YY_RULE_SETUP
|
||||
#line 205 "dtc-lexer.l"
|
||||
#line 153 "dtc-lexer.l"
|
||||
{
|
||||
yylloc.file = srcpos_file;
|
||||
yylloc.first_line = yylineno;
|
||||
DPRINT("Char: %c (\\x%02x)\n", yytext[0],
|
||||
(unsigned)yytext[0]);
|
||||
if (yytext[0] == '[') {
|
||||
@ -1148,12 +1035,12 @@ YY_RULE_SETUP
|
||||
return yytext[0];
|
||||
}
|
||||
YY_BREAK
|
||||
case 20:
|
||||
case 17:
|
||||
YY_RULE_SETUP
|
||||
#line 222 "dtc-lexer.l"
|
||||
#line 168 "dtc-lexer.l"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 1157 "dtc-lexer.lex.c"
|
||||
#line 1044 "dtc-lexer.lex.c"
|
||||
|
||||
case YY_END_OF_BUFFER:
|
||||
{
|
||||
@ -1218,7 +1105,8 @@ ECHO;
|
||||
|
||||
else
|
||||
{
|
||||
yy_cp = (yy_c_buf_p);
|
||||
yy_cp = (yy_last_accepting_cpos);
|
||||
yy_current_state = (yy_last_accepting_state);
|
||||
goto yy_find_action;
|
||||
}
|
||||
}
|
||||
@ -1443,7 +1331,7 @@ static int yy_get_next_buffer (void)
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 104 )
|
||||
if ( yy_current_state >= 94 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
@ -1471,11 +1359,11 @@ static int yy_get_next_buffer (void)
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 104 )
|
||||
if ( yy_current_state >= 94 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_is_jam = (yy_current_state == 103);
|
||||
yy_is_jam = (yy_current_state == 93);
|
||||
|
||||
return yy_is_jam ? 0 : yy_current_state;
|
||||
}
|
||||
@ -1550,11 +1438,6 @@ static int yy_get_next_buffer (void)
|
||||
*(yy_c_buf_p) = '\0'; /* preserve yytext */
|
||||
(yy_hold_char) = *++(yy_c_buf_p);
|
||||
|
||||
if ( c == '\n' )
|
||||
|
||||
yylineno++;
|
||||
;
|
||||
|
||||
return c;
|
||||
}
|
||||
#endif /* ifndef YY_NO_INPUT */
|
||||
@ -1669,10 +1552,6 @@ static void yy_load_buffer_state (void)
|
||||
yyfree((void *) b );
|
||||
}
|
||||
|
||||
#ifndef __cplusplus
|
||||
extern int isatty (int );
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Initializes or reinitializes a buffer.
|
||||
* This function is sometimes called more than once on the same buffer,
|
||||
* such as during a yyrestart() or at EOF.
|
||||
@ -1696,7 +1575,7 @@ extern int isatty (int );
|
||||
b->yy_bs_column = 0;
|
||||
}
|
||||
|
||||
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
|
||||
b->yy_is_interactive = 0;
|
||||
|
||||
errno = oerrno;
|
||||
}
|
||||
@ -2025,9 +1904,6 @@ static int yy_init_globals (void)
|
||||
* This function is called from yylex_destroy(), so don't allocate here.
|
||||
*/
|
||||
|
||||
/* We do not touch yylineno unless the option is enabled. */
|
||||
yylineno = 1;
|
||||
|
||||
(yy_buffer_stack) = 0;
|
||||
(yy_buffer_stack_top) = 0;
|
||||
(yy_buffer_stack_max) = 0;
|
||||
@ -2120,104 +1996,29 @@ void yyfree (void * ptr )
|
||||
|
||||
#define YYTABLES_NAME "yytables"
|
||||
|
||||
#line 222 "dtc-lexer.l"
|
||||
#line 168 "dtc-lexer.l"
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Stack of nested include file contexts.
|
||||
*/
|
||||
|
||||
struct incl_file {
|
||||
struct dtc_file *file;
|
||||
YY_BUFFER_STATE yy_prev_buf;
|
||||
int yy_prev_lineno;
|
||||
struct incl_file *prev;
|
||||
};
|
||||
|
||||
static struct incl_file *incl_file_stack;
|
||||
|
||||
|
||||
/*
|
||||
* Detect infinite include recursion.
|
||||
*/
|
||||
#define MAX_INCLUDE_DEPTH (100)
|
||||
|
||||
static int incl_depth = 0;
|
||||
|
||||
|
||||
static void push_input_file(const char *filename)
|
||||
{
|
||||
struct incl_file *incl_file;
|
||||
struct dtc_file *newfile;
|
||||
struct search_path search, *searchptr = NULL;
|
||||
|
||||
assert(filename);
|
||||
|
||||
if (incl_depth++ >= MAX_INCLUDE_DEPTH)
|
||||
die("Includes nested too deeply");
|
||||
srcfile_push(filename);
|
||||
|
||||
if (srcpos_file) {
|
||||
search.dir = srcpos_file->dir;
|
||||
search.next = NULL;
|
||||
search.prev = NULL;
|
||||
searchptr = &search;
|
||||
}
|
||||
yyin = current_srcfile->f;
|
||||
|
||||
newfile = dtc_open_file(filename, searchptr);
|
||||
|
||||
incl_file = xmalloc(sizeof(struct incl_file));
|
||||
|
||||
/*
|
||||
* Save current context.
|
||||
*/
|
||||
incl_file->yy_prev_buf = YY_CURRENT_BUFFER;
|
||||
incl_file->yy_prev_lineno = yylineno;
|
||||
incl_file->file = srcpos_file;
|
||||
incl_file->prev = incl_file_stack;
|
||||
|
||||
incl_file_stack = incl_file;
|
||||
|
||||
/*
|
||||
* Establish new context.
|
||||
*/
|
||||
srcpos_file = newfile;
|
||||
yylineno = 1;
|
||||
yyin = newfile->file;
|
||||
yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
|
||||
yypush_buffer_state(yy_create_buffer(yyin,YY_BUF_SIZE));
|
||||
}
|
||||
|
||||
|
||||
static int pop_input_file(void)
|
||||
{
|
||||
struct incl_file *incl_file;
|
||||
|
||||
if (incl_file_stack == 0)
|
||||
if (srcfile_pop() == 0)
|
||||
return 0;
|
||||
|
||||
dtc_close_file(srcpos_file);
|
||||
|
||||
/*
|
||||
* Pop.
|
||||
*/
|
||||
--incl_depth;
|
||||
incl_file = incl_file_stack;
|
||||
incl_file_stack = incl_file->prev;
|
||||
|
||||
/*
|
||||
* Recover old context.
|
||||
*/
|
||||
yy_delete_buffer(YY_CURRENT_BUFFER);
|
||||
yy_switch_to_buffer(incl_file->yy_prev_buf);
|
||||
yylineno = incl_file->yy_prev_lineno;
|
||||
srcpos_file = incl_file->file;
|
||||
yyin = incl_file->file ? incl_file->file->file : NULL;
|
||||
|
||||
/*
|
||||
* Free old state.
|
||||
*/
|
||||
free(incl_file);
|
||||
yypop_buffer_state();
|
||||
yyin = current_srcfile->f;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,24 +1,23 @@
|
||||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
@ -29,10 +28,11 @@
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
@ -43,35 +43,24 @@
|
||||
DT_MEMRESERVE = 259,
|
||||
DT_PROPNODENAME = 260,
|
||||
DT_LITERAL = 261,
|
||||
DT_LEGACYLITERAL = 262,
|
||||
DT_BASE = 263,
|
||||
DT_BYTE = 264,
|
||||
DT_STRING = 265,
|
||||
DT_LABEL = 266,
|
||||
DT_REF = 267,
|
||||
DT_INCBIN = 268
|
||||
DT_BASE = 262,
|
||||
DT_BYTE = 263,
|
||||
DT_STRING = 264,
|
||||
DT_LABEL = 265,
|
||||
DT_REF = 266,
|
||||
DT_INCBIN = 267
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
#define DT_V1 258
|
||||
#define DT_MEMRESERVE 259
|
||||
#define DT_PROPNODENAME 260
|
||||
#define DT_LITERAL 261
|
||||
#define DT_LEGACYLITERAL 262
|
||||
#define DT_BASE 263
|
||||
#define DT_BYTE 264
|
||||
#define DT_STRING 265
|
||||
#define DT_LABEL 266
|
||||
#define DT_REF 267
|
||||
#define DT_INCBIN 268
|
||||
|
||||
|
||||
|
||||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
#line 37 "dtc-parser.y"
|
||||
{
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
#line 39 "dtc-parser.y"
|
||||
|
||||
char *propnodename;
|
||||
char *literal;
|
||||
char *labelref;
|
||||
@ -86,28 +75,17 @@ typedef union YYSTYPE
|
||||
struct node *node;
|
||||
struct node *nodelist;
|
||||
struct reserve_info *re;
|
||||
}
|
||||
/* Line 1489 of yacc.c. */
|
||||
#line 92 "dtc-parser.tab.h"
|
||||
YYSTYPE;
|
||||
|
||||
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
#line 83 "dtc-parser.tab.h"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
|
||||
typedef struct YYLTYPE
|
||||
{
|
||||
int first_line;
|
||||
int first_column;
|
||||
int last_line;
|
||||
int last_column;
|
||||
} YYLTYPE;
|
||||
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYLTYPE_IS_DECLARED 1
|
||||
# define YYLTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
extern YYLTYPE yylloc;
|
||||
|
@ -18,15 +18,17 @@
|
||||
* USA
|
||||
*/
|
||||
|
||||
%locations
|
||||
|
||||
%{
|
||||
#include <stdio.h>
|
||||
|
||||
#include "dtc.h"
|
||||
#include "srcpos.h"
|
||||
|
||||
YYLTYPE yylloc;
|
||||
|
||||
extern int yylex(void);
|
||||
extern void print_error(char const *fmt, ...);
|
||||
extern void yyerror(char const *s);
|
||||
|
||||
extern struct boot_info *the_boot_info;
|
||||
extern int treesource_error;
|
||||
@ -55,7 +57,6 @@ static unsigned long long eval_literal(const char *s, int base, int bits);
|
||||
%token DT_MEMRESERVE
|
||||
%token <propnodename> DT_PROPNODENAME
|
||||
%token <literal> DT_LITERAL
|
||||
%token <literal> DT_LEGACYLITERAL
|
||||
%token <cbase> DT_BASE
|
||||
%token <byte> DT_BYTE
|
||||
%token <data> DT_STRING
|
||||
@ -67,11 +68,8 @@ static unsigned long long eval_literal(const char *s, int base, int bits);
|
||||
%type <data> propdataprefix
|
||||
%type <re> memreserve
|
||||
%type <re> memreserves
|
||||
%type <re> v0_memreserve
|
||||
%type <re> v0_memreserves
|
||||
%type <addr> addr
|
||||
%type <data> celllist
|
||||
%type <cbase> cellbase
|
||||
%type <cell> cellval
|
||||
%type <data> bytestring
|
||||
%type <prop> propdef
|
||||
@ -81,18 +79,14 @@ static unsigned long long eval_literal(const char *s, int base, int bits);
|
||||
%type <node> nodedef
|
||||
%type <node> subnode
|
||||
%type <nodelist> subnodes
|
||||
%type <labelref> label
|
||||
|
||||
%%
|
||||
|
||||
sourcefile:
|
||||
DT_V1 ';' memreserves devicetree
|
||||
{
|
||||
the_boot_info = build_boot_info($3, $4, 0);
|
||||
}
|
||||
| v0_memreserves devicetree
|
||||
{
|
||||
the_boot_info = build_boot_info($1, $2, 0);
|
||||
the_boot_info = build_boot_info($3, $4,
|
||||
guess_boot_cpuid($4));
|
||||
}
|
||||
;
|
||||
|
||||
@ -108,31 +102,14 @@ memreserves:
|
||||
;
|
||||
|
||||
memreserve:
|
||||
label DT_MEMRESERVE addr addr ';'
|
||||
DT_MEMRESERVE addr addr ';'
|
||||
{
|
||||
$$ = build_reserve_entry($3, $4, $1);
|
||||
$$ = build_reserve_entry($2, $3);
|
||||
}
|
||||
;
|
||||
|
||||
v0_memreserves:
|
||||
/* empty */
|
||||
| DT_LABEL memreserve
|
||||
{
|
||||
$$ = NULL;
|
||||
}
|
||||
| v0_memreserve v0_memreserves
|
||||
{
|
||||
$$ = chain_reserve_entry($1, $2);
|
||||
};
|
||||
;
|
||||
|
||||
v0_memreserve:
|
||||
memreserve
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
| label DT_MEMRESERVE addr '-' addr ';'
|
||||
{
|
||||
$$ = build_reserve_entry($3, $5 - $3 + 1, $1);
|
||||
add_label(&$2->labels, $1);
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
@ -141,16 +118,26 @@ addr:
|
||||
{
|
||||
$$ = eval_literal($1, 0, 64);
|
||||
}
|
||||
| DT_LEGACYLITERAL
|
||||
{
|
||||
$$ = eval_literal($1, 16, 64);
|
||||
}
|
||||
;
|
||||
|
||||
devicetree:
|
||||
'/' nodedef
|
||||
{
|
||||
$$ = name_node($2, "", NULL);
|
||||
$$ = name_node($2, "");
|
||||
}
|
||||
| devicetree '/' nodedef
|
||||
{
|
||||
$$ = merge_nodes($1, $3);
|
||||
}
|
||||
| devicetree DT_REF nodedef
|
||||
{
|
||||
struct node *target = get_node_by_ref($1, $2);
|
||||
|
||||
if (target)
|
||||
merge_nodes(target, $3);
|
||||
else
|
||||
print_error("label or path, '%s', not found", $2);
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
@ -173,13 +160,18 @@ proplist:
|
||||
;
|
||||
|
||||
propdef:
|
||||
label DT_PROPNODENAME '=' propdata ';'
|
||||
DT_PROPNODENAME '=' propdata ';'
|
||||
{
|
||||
$$ = build_property($2, $4, $1);
|
||||
$$ = build_property($1, $3);
|
||||
}
|
||||
| label DT_PROPNODENAME ';'
|
||||
| DT_PROPNODENAME ';'
|
||||
{
|
||||
$$ = build_property($2, empty_data, $1);
|
||||
$$ = build_property($1, empty_data);
|
||||
}
|
||||
| DT_LABEL propdef
|
||||
{
|
||||
add_label(&$2->labels, $1);
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
@ -202,31 +194,30 @@ propdata:
|
||||
}
|
||||
| propdataprefix DT_INCBIN '(' DT_STRING ',' addr ',' addr ')'
|
||||
{
|
||||
struct search_path path = { srcpos_file->dir, NULL, NULL };
|
||||
struct dtc_file *file = dtc_open_file($4.val, &path);
|
||||
struct data d = empty_data;
|
||||
FILE *f = srcfile_relative_open($4.val, NULL);
|
||||
struct data d;
|
||||
|
||||
if ($6 != 0)
|
||||
if (fseek(file->file, $6, SEEK_SET) != 0)
|
||||
yyerrorf("Couldn't seek to offset %llu in \"%s\": %s",
|
||||
(unsigned long long)$6,
|
||||
$4.val, strerror(errno));
|
||||
if (fseek(f, $6, SEEK_SET) != 0)
|
||||
print_error("Couldn't seek to offset %llu in \"%s\": %s",
|
||||
(unsigned long long)$6,
|
||||
$4.val,
|
||||
strerror(errno));
|
||||
|
||||
d = data_copy_file(file->file, $8);
|
||||
d = data_copy_file(f, $8);
|
||||
|
||||
$$ = data_merge($1, d);
|
||||
dtc_close_file(file);
|
||||
fclose(f);
|
||||
}
|
||||
| propdataprefix DT_INCBIN '(' DT_STRING ')'
|
||||
{
|
||||
struct search_path path = { srcpos_file->dir, NULL, NULL };
|
||||
struct dtc_file *file = dtc_open_file($4.val, &path);
|
||||
FILE *f = srcfile_relative_open($4.val, NULL);
|
||||
struct data d = empty_data;
|
||||
|
||||
d = data_copy_file(file->file, -1);
|
||||
d = data_copy_file(f, -1);
|
||||
|
||||
$$ = data_merge($1, d);
|
||||
dtc_close_file(file);
|
||||
fclose(f);
|
||||
}
|
||||
| propdata DT_LABEL
|
||||
{
|
||||
@ -269,23 +260,11 @@ celllist:
|
||||
}
|
||||
;
|
||||
|
||||
cellbase:
|
||||
/* empty */
|
||||
{
|
||||
$$ = 16;
|
||||
}
|
||||
| DT_BASE
|
||||
;
|
||||
|
||||
cellval:
|
||||
DT_LITERAL
|
||||
{
|
||||
$$ = eval_literal($1, 0, 32);
|
||||
}
|
||||
| cellbase DT_LEGACYLITERAL
|
||||
{
|
||||
$$ = eval_literal($2, $1, 32);
|
||||
}
|
||||
;
|
||||
|
||||
bytestring:
|
||||
@ -308,57 +287,44 @@ subnodes:
|
||||
{
|
||||
$$ = NULL;
|
||||
}
|
||||
| subnode subnodes
|
||||
| subnode subnodes
|
||||
{
|
||||
$$ = chain_node($1, $2);
|
||||
}
|
||||
| subnode propdef
|
||||
{
|
||||
yyerror("syntax error: properties must precede subnodes");
|
||||
print_error("syntax error: properties must precede subnodes");
|
||||
YYERROR;
|
||||
}
|
||||
;
|
||||
|
||||
subnode:
|
||||
label DT_PROPNODENAME nodedef
|
||||
DT_PROPNODENAME nodedef
|
||||
{
|
||||
$$ = name_node($3, $2, $1);
|
||||
$$ = name_node($2, $1);
|
||||
}
|
||||
;
|
||||
|
||||
label:
|
||||
/* empty */
|
||||
| DT_LABEL subnode
|
||||
{
|
||||
$$ = NULL;
|
||||
}
|
||||
| DT_LABEL
|
||||
{
|
||||
$$ = $1;
|
||||
add_label(&$2->labels, $1);
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
void yyerrorf(char const *s, ...)
|
||||
void print_error(char const *fmt, ...)
|
||||
{
|
||||
const char *fname = srcpos_file ? srcpos_file->name : "<no-file>";
|
||||
va_list va;
|
||||
va_start(va, s);
|
||||
|
||||
if (strcmp(fname, "-") == 0)
|
||||
fname = "stdin";
|
||||
|
||||
fprintf(stderr, "%s:%d ", fname, yylloc.first_line);
|
||||
vfprintf(stderr, s, va);
|
||||
fprintf(stderr, "\n");
|
||||
va_start(va, fmt);
|
||||
srcpos_verror(&yylloc, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
treesource_error = 1;
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void yyerror (char const *s)
|
||||
{
|
||||
yyerrorf("%s", s);
|
||||
void yyerror(char const *s) {
|
||||
print_error("%s", s);
|
||||
}
|
||||
|
||||
static unsigned long long eval_literal(const char *s, int base, int bits)
|
||||
@ -369,11 +335,11 @@ static unsigned long long eval_literal(const char *s, int base, int bits)
|
||||
errno = 0;
|
||||
val = strtoull(s, &e, base);
|
||||
if (*e)
|
||||
yyerror("bad characters in literal");
|
||||
print_error("bad characters in literal");
|
||||
else if ((errno == ERANGE)
|
||||
|| ((bits < 64) && (val >= (1ULL << bits))))
|
||||
yyerror("literal out of range");
|
||||
print_error("literal out of range");
|
||||
else if (errno != 0)
|
||||
yyerror("bad literal");
|
||||
print_error("bad literal");
|
||||
return val;
|
||||
}
|
||||
|
@ -30,30 +30,7 @@ int quiet; /* Level of quietness */
|
||||
int reservenum; /* Number of memory reservation slots */
|
||||
int minsize; /* Minimum blob size */
|
||||
int padsize; /* Additional padding to blob */
|
||||
|
||||
char *join_path(const char *path, const char *name)
|
||||
{
|
||||
int lenp = strlen(path);
|
||||
int lenn = strlen(name);
|
||||
int len;
|
||||
int needslash = 1;
|
||||
char *str;
|
||||
|
||||
len = lenp + lenn + 2;
|
||||
if ((lenp > 0) && (path[lenp-1] == '/')) {
|
||||
needslash = 0;
|
||||
len--;
|
||||
}
|
||||
|
||||
str = xmalloc(len);
|
||||
memcpy(str, path, lenp);
|
||||
if (needslash) {
|
||||
str[lenp] = '/';
|
||||
lenp++;
|
||||
}
|
||||
memcpy(str+lenp, name, lenn+1);
|
||||
return str;
|
||||
}
|
||||
int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */
|
||||
|
||||
static void fill_fullpaths(struct node *tree, const char *prefix)
|
||||
{
|
||||
@ -104,8 +81,15 @@ static void __attribute__ ((noreturn)) usage(void)
|
||||
fprintf(stderr, "\t\tSet the physical boot cpu\n");
|
||||
fprintf(stderr, "\t-f\n");
|
||||
fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n");
|
||||
fprintf(stderr, "\t-s\n");
|
||||
fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n");
|
||||
fprintf(stderr, "\t-v\n");
|
||||
fprintf(stderr, "\t\tPrint DTC version and exit\n");
|
||||
fprintf(stderr, "\t-H <phandle format>\n");
|
||||
fprintf(stderr, "\t\tphandle formats are:\n");
|
||||
fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n");
|
||||
fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n");
|
||||
fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n");
|
||||
exit(3);
|
||||
}
|
||||
|
||||
@ -115,7 +99,7 @@ int main(int argc, char *argv[])
|
||||
const char *inform = "dts";
|
||||
const char *outform = "dts";
|
||||
const char *outname = "-";
|
||||
int force = 0, check = 0;
|
||||
int force = 0, check = 0, sort = 0;
|
||||
const char *arg;
|
||||
int opt;
|
||||
FILE *outf = NULL;
|
||||
@ -127,7 +111,7 @@ int main(int argc, char *argv[])
|
||||
minsize = 0;
|
||||
padsize = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:v")) != EOF) {
|
||||
while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:s")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'I':
|
||||
inform = optarg;
|
||||
@ -165,6 +149,22 @@ int main(int argc, char *argv[])
|
||||
case 'v':
|
||||
printf("Version: %s\n", DTC_VERSION);
|
||||
exit(0);
|
||||
case 'H':
|
||||
if (streq(optarg, "legacy"))
|
||||
phandle_format = PHANDLE_LEGACY;
|
||||
else if (streq(optarg, "epapr"))
|
||||
phandle_format = PHANDLE_EPAPR;
|
||||
else if (streq(optarg, "both"))
|
||||
phandle_format = PHANDLE_BOTH;
|
||||
else
|
||||
die("Invalid argument \"%s\" to -H option\n",
|
||||
optarg);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
sort = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
default:
|
||||
usage();
|
||||
@ -182,6 +182,9 @@ int main(int argc, char *argv[])
|
||||
if (minsize && padsize)
|
||||
die("Can't set both -p and -S\n");
|
||||
|
||||
if (minsize)
|
||||
fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n");
|
||||
|
||||
fprintf(stderr, "DTC: %s->%s on file \"%s\"\n",
|
||||
inform, outform, arg);
|
||||
|
||||
@ -200,6 +203,8 @@ int main(int argc, char *argv[])
|
||||
fill_fullpaths(bi->dt, "");
|
||||
process_checks(force, bi);
|
||||
|
||||
if (sort)
|
||||
sort_tree(bi);
|
||||
|
||||
if (streq(outname, "-")) {
|
||||
outf = stdout;
|
||||
|
@ -34,7 +34,17 @@
|
||||
#include <libfdt_env.h>
|
||||
#include <fdt.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define debug(fmt,args...) printf(fmt, ##args)
|
||||
#else
|
||||
#define debug(fmt,args...)
|
||||
#endif
|
||||
|
||||
|
||||
#define DEFAULT_FDT_VERSION 17
|
||||
|
||||
/*
|
||||
* Command line options
|
||||
*/
|
||||
@ -42,36 +52,11 @@ extern int quiet; /* Level of quietness */
|
||||
extern int reservenum; /* Number of memory reservation slots */
|
||||
extern int minsize; /* Minimum blob size */
|
||||
extern int padsize; /* Additional padding to blob */
|
||||
extern int phandle_format; /* Use linux,phandle or phandle properties */
|
||||
|
||||
static inline void __attribute__((noreturn)) die(char * str, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, str);
|
||||
fprintf(stderr, "FATAL ERROR: ");
|
||||
vfprintf(stderr, str, ap);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static inline void *xmalloc(size_t len)
|
||||
{
|
||||
void *new = malloc(len);
|
||||
|
||||
if (! new)
|
||||
die("malloc() failed\n");
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
static inline void *xrealloc(void *p, size_t len)
|
||||
{
|
||||
void *new = realloc(p, len);
|
||||
|
||||
if (! new)
|
||||
die("realloc() failed (len=%d)\n", len);
|
||||
|
||||
return new;
|
||||
}
|
||||
#define PHANDLE_LEGACY 0x1
|
||||
#define PHANDLE_EPAPR 0x2
|
||||
#define PHANDLE_BOTH 0x3
|
||||
|
||||
typedef uint32_t cell_t;
|
||||
|
||||
@ -140,13 +125,18 @@ int data_is_one_string(struct data d);
|
||||
#define MAX_NODENAME_LEN 31
|
||||
|
||||
/* Live trees */
|
||||
struct label {
|
||||
char *label;
|
||||
struct label *next;
|
||||
};
|
||||
|
||||
struct property {
|
||||
char *name;
|
||||
struct data val;
|
||||
|
||||
struct property *next;
|
||||
|
||||
char *label;
|
||||
struct label *labels;
|
||||
};
|
||||
|
||||
struct node {
|
||||
@ -163,22 +153,28 @@ struct node {
|
||||
cell_t phandle;
|
||||
int addr_cells, size_cells;
|
||||
|
||||
char *label;
|
||||
struct label *labels;
|
||||
};
|
||||
|
||||
#define for_each_label(l0, l) \
|
||||
for ((l) = (l0); (l); (l) = (l)->next)
|
||||
|
||||
#define for_each_property(n, p) \
|
||||
for ((p) = (n)->proplist; (p); (p) = (p)->next)
|
||||
|
||||
#define for_each_child(n, c) \
|
||||
for ((c) = (n)->children; (c); (c) = (c)->next_sibling)
|
||||
|
||||
struct property *build_property(char *name, struct data val, char *label);
|
||||
void add_label(struct label **labels, char *label);
|
||||
|
||||
struct property *build_property(char *name, struct data val);
|
||||
struct property *chain_property(struct property *first, struct property *list);
|
||||
struct property *reverse_properties(struct property *first);
|
||||
|
||||
struct node *build_node(struct property *proplist, struct node *children);
|
||||
struct node *name_node(struct node *node, char *name, char *label);
|
||||
struct node *name_node(struct node *node, char *name);
|
||||
struct node *chain_node(struct node *first, struct node *list);
|
||||
struct node *merge_nodes(struct node *old_node, struct node *new_node);
|
||||
|
||||
void add_property(struct node *node, struct property *prop);
|
||||
void add_child(struct node *parent, struct node *child);
|
||||
@ -186,6 +182,10 @@ void add_child(struct node *parent, struct node *child);
|
||||
const char *get_unitname(struct node *node);
|
||||
struct property *get_property(struct node *node, const char *propname);
|
||||
cell_t propval_cell(struct property *prop);
|
||||
struct property *get_property_by_label(struct node *tree, const char *label,
|
||||
struct node **node);
|
||||
struct marker *get_marker_label(struct node *tree, const char *label,
|
||||
struct node **node, struct property **prop);
|
||||
struct node *get_subnode(struct node *node, const char *nodename);
|
||||
struct node *get_node_by_path(struct node *tree, const char *path);
|
||||
struct node *get_node_by_label(struct node *tree, const char *label);
|
||||
@ -193,6 +193,8 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle);
|
||||
struct node *get_node_by_ref(struct node *tree, const char *ref);
|
||||
cell_t get_node_phandle(struct node *root, struct node *node);
|
||||
|
||||
uint32_t guess_boot_cpuid(struct node *tree);
|
||||
|
||||
/* Boot info (tree plus memreserve information */
|
||||
|
||||
struct reserve_info {
|
||||
@ -200,10 +202,10 @@ struct reserve_info {
|
||||
|
||||
struct reserve_info *next;
|
||||
|
||||
char *label;
|
||||
struct label *labels;
|
||||
};
|
||||
|
||||
struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len, char *label);
|
||||
struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len);
|
||||
struct reserve_info *chain_reserve_entry(struct reserve_info *first,
|
||||
struct reserve_info *list);
|
||||
struct reserve_info *add_reserve_entry(struct reserve_info *list,
|
||||
@ -218,6 +220,7 @@ struct boot_info {
|
||||
|
||||
struct boot_info *build_boot_info(struct reserve_info *reservelist,
|
||||
struct node *tree, uint32_t boot_cpuid_phys);
|
||||
void sort_tree(struct boot_info *bi);
|
||||
|
||||
/* Checks */
|
||||
|
||||
@ -239,8 +242,4 @@ struct boot_info *dt_from_source(const char *f);
|
||||
|
||||
struct boot_info *dt_from_fs(const char *dirname);
|
||||
|
||||
/* misc */
|
||||
|
||||
char *join_path(const char *path, const char *name);
|
||||
|
||||
#endif /* _DTC_H */
|
||||
|
@ -52,9 +52,9 @@ struct emitter {
|
||||
void (*string)(void *, char *, int);
|
||||
void (*align)(void *, int);
|
||||
void (*data)(void *, struct data);
|
||||
void (*beginnode)(void *, const char *);
|
||||
void (*endnode)(void *, const char *);
|
||||
void (*property)(void *, const char *);
|
||||
void (*beginnode)(void *, struct label *labels);
|
||||
void (*endnode)(void *, struct label *labels);
|
||||
void (*property)(void *, struct label *labels);
|
||||
};
|
||||
|
||||
static void bin_emit_cell(void *e, cell_t val)
|
||||
@ -89,17 +89,17 @@ static void bin_emit_data(void *e, struct data d)
|
||||
*dtbuf = data_append_data(*dtbuf, d.val, d.len);
|
||||
}
|
||||
|
||||
static void bin_emit_beginnode(void *e, const char *label)
|
||||
static void bin_emit_beginnode(void *e, struct label *labels)
|
||||
{
|
||||
bin_emit_cell(e, FDT_BEGIN_NODE);
|
||||
}
|
||||
|
||||
static void bin_emit_endnode(void *e, const char *label)
|
||||
static void bin_emit_endnode(void *e, struct label *labels)
|
||||
{
|
||||
bin_emit_cell(e, FDT_END_NODE);
|
||||
}
|
||||
|
||||
static void bin_emit_property(void *e, const char *label)
|
||||
static void bin_emit_property(void *e, struct label *labels)
|
||||
{
|
||||
bin_emit_cell(e, FDT_PROP);
|
||||
}
|
||||
@ -127,11 +127,21 @@ static void emit_offset_label(FILE *f, const char *label, int offset)
|
||||
fprintf(f, "%s\t= . + %d\n", label, offset);
|
||||
}
|
||||
|
||||
#define ASM_EMIT_BELONG(f, fmt, ...) \
|
||||
{ \
|
||||
fprintf((f), "\t.byte\t((" fmt ") >> 24) & 0xff\n", __VA_ARGS__); \
|
||||
fprintf((f), "\t.byte\t((" fmt ") >> 16) & 0xff\n", __VA_ARGS__); \
|
||||
fprintf((f), "\t.byte\t((" fmt ") >> 8) & 0xff\n", __VA_ARGS__); \
|
||||
fprintf((f), "\t.byte\t(" fmt ") & 0xff\n", __VA_ARGS__); \
|
||||
}
|
||||
|
||||
static void asm_emit_cell(void *e, cell_t val)
|
||||
{
|
||||
FILE *f = e;
|
||||
|
||||
fprintf(f, "\t.long\t0x%x\n", val);
|
||||
fprintf(f, "\t.byte 0x%02x; .byte 0x%02x; .byte 0x%02x; .byte 0x%02x\n",
|
||||
(val >> 24) & 0xff, (val >> 16) & 0xff,
|
||||
(val >> 8) & 0xff, val & 0xff);
|
||||
}
|
||||
|
||||
static void asm_emit_string(void *e, char *str, int len)
|
||||
@ -156,7 +166,7 @@ static void asm_emit_align(void *e, int a)
|
||||
{
|
||||
FILE *f = e;
|
||||
|
||||
fprintf(f, "\t.balign\t%d\n", a);
|
||||
fprintf(f, "\t.balign\t%d, 0\n", a);
|
||||
}
|
||||
|
||||
static void asm_emit_data(void *e, struct data d)
|
||||
@ -169,8 +179,7 @@ static void asm_emit_data(void *e, struct data d)
|
||||
emit_offset_label(f, m->ref, m->offset);
|
||||
|
||||
while ((d.len - off) >= sizeof(uint32_t)) {
|
||||
fprintf(f, "\t.long\t0x%x\n",
|
||||
fdt32_to_cpu(*((uint32_t *)(d.val+off))));
|
||||
asm_emit_cell(e, fdt32_to_cpu(*((uint32_t *)(d.val+off))));
|
||||
off += sizeof(uint32_t);
|
||||
}
|
||||
|
||||
@ -182,37 +191,43 @@ static void asm_emit_data(void *e, struct data d)
|
||||
assert(off == d.len);
|
||||
}
|
||||
|
||||
static void asm_emit_beginnode(void *e, const char *label)
|
||||
static void asm_emit_beginnode(void *e, struct label *labels)
|
||||
{
|
||||
FILE *f = e;
|
||||
struct label *l;
|
||||
|
||||
if (label) {
|
||||
fprintf(f, "\t.globl\t%s\n", label);
|
||||
fprintf(f, "%s:\n", label);
|
||||
for_each_label(labels, l) {
|
||||
fprintf(f, "\t.globl\t%s\n", l->label);
|
||||
fprintf(f, "%s:\n", l->label);
|
||||
}
|
||||
fprintf(f, "\t.long\tFDT_BEGIN_NODE\n");
|
||||
fprintf(f, "\t/* FDT_BEGIN_NODE */\n");
|
||||
asm_emit_cell(e, FDT_BEGIN_NODE);
|
||||
}
|
||||
|
||||
static void asm_emit_endnode(void *e, const char *label)
|
||||
static void asm_emit_endnode(void *e, struct label *labels)
|
||||
{
|
||||
FILE *f = e;
|
||||
struct label *l;
|
||||
|
||||
fprintf(f, "\t.long\tFDT_END_NODE\n");
|
||||
if (label) {
|
||||
fprintf(f, "\t.globl\t%s_end\n", label);
|
||||
fprintf(f, "%s_end:\n", label);
|
||||
fprintf(f, "\t/* FDT_END_NODE */\n");
|
||||
asm_emit_cell(e, FDT_END_NODE);
|
||||
for_each_label(labels, l) {
|
||||
fprintf(f, "\t.globl\t%s_end\n", l->label);
|
||||
fprintf(f, "%s_end:\n", l->label);
|
||||
}
|
||||
}
|
||||
|
||||
static void asm_emit_property(void *e, const char *label)
|
||||
static void asm_emit_property(void *e, struct label *labels)
|
||||
{
|
||||
FILE *f = e;
|
||||
struct label *l;
|
||||
|
||||
if (label) {
|
||||
fprintf(f, "\t.globl\t%s\n", label);
|
||||
fprintf(f, "%s:\n", label);
|
||||
for_each_label(labels, l) {
|
||||
fprintf(f, "\t.globl\t%s\n", l->label);
|
||||
fprintf(f, "%s:\n", l->label);
|
||||
}
|
||||
fprintf(f, "\t.long\tFDT_PROP\n");
|
||||
fprintf(f, "\t/* FDT_PROP */\n");
|
||||
asm_emit_cell(e, FDT_PROP);
|
||||
}
|
||||
|
||||
static struct emitter asm_emitter = {
|
||||
@ -248,7 +263,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit,
|
||||
struct node *child;
|
||||
int seen_name_prop = 0;
|
||||
|
||||
emit->beginnode(etarget, tree->label);
|
||||
emit->beginnode(etarget, tree->labels);
|
||||
|
||||
if (vi->flags & FTF_FULLPATH)
|
||||
emit->string(etarget, tree->fullpath, 0);
|
||||
@ -265,7 +280,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit,
|
||||
|
||||
nameoff = stringtable_insert(strbuf, prop->name);
|
||||
|
||||
emit->property(etarget, prop->label);
|
||||
emit->property(etarget, prop->labels);
|
||||
emit->cell(etarget, prop->val.len);
|
||||
emit->cell(etarget, nameoff);
|
||||
|
||||
@ -292,7 +307,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit,
|
||||
flatten_tree(child, emit, etarget, strbuf, vi);
|
||||
}
|
||||
|
||||
emit->endnode(etarget, tree->label);
|
||||
emit->endnode(etarget, tree->labels);
|
||||
}
|
||||
|
||||
static struct data flatten_reserve_list(struct reserve_info *reservelist,
|
||||
@ -413,10 +428,13 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
|
||||
if (padlen > 0)
|
||||
blob = data_append_zeroes(blob, padlen);
|
||||
|
||||
fwrite(blob.val, blob.len, 1, f);
|
||||
|
||||
if (ferror(f))
|
||||
die("Error writing device tree blob: %s\n", strerror(errno));
|
||||
if (fwrite(blob.val, blob.len, 1, f) != 1) {
|
||||
if (ferror(f))
|
||||
die("Error writing device tree blob: %s\n",
|
||||
strerror(errno));
|
||||
else
|
||||
die("Short write on device tree blob\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* data_merge() frees the right-hand element so only the blob
|
||||
@ -455,39 +473,44 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
|
||||
die("Unknown device tree blob version %d\n", version);
|
||||
|
||||
fprintf(f, "/* autogenerated by dtc, do not edit */\n\n");
|
||||
fprintf(f, "#define FDT_MAGIC 0x%x\n", FDT_MAGIC);
|
||||
fprintf(f, "#define FDT_BEGIN_NODE 0x%x\n", FDT_BEGIN_NODE);
|
||||
fprintf(f, "#define FDT_END_NODE 0x%x\n", FDT_END_NODE);
|
||||
fprintf(f, "#define FDT_PROP 0x%x\n", FDT_PROP);
|
||||
fprintf(f, "#define FDT_END 0x%x\n", FDT_END);
|
||||
fprintf(f, "\n");
|
||||
|
||||
emit_label(f, symprefix, "blob_start");
|
||||
emit_label(f, symprefix, "header");
|
||||
fprintf(f, "\t.long\tFDT_MAGIC\t\t\t\t/* magic */\n");
|
||||
fprintf(f, "\t.long\t_%s_blob_abs_end - _%s_blob_start\t/* totalsize */\n",
|
||||
symprefix, symprefix);
|
||||
fprintf(f, "\t.long\t_%s_struct_start - _%s_blob_start\t/* off_dt_struct */\n",
|
||||
symprefix, symprefix);
|
||||
fprintf(f, "\t.long\t_%s_strings_start - _%s_blob_start\t/* off_dt_strings */\n",
|
||||
symprefix, symprefix);
|
||||
fprintf(f, "\t.long\t_%s_reserve_map - _%s_blob_start\t/* off_dt_strings */\n",
|
||||
symprefix, symprefix);
|
||||
fprintf(f, "\t.long\t%d\t\t\t\t\t/* version */\n", vi->version);
|
||||
fprintf(f, "\t.long\t%d\t\t\t\t\t/* last_comp_version */\n",
|
||||
vi->last_comp_version);
|
||||
|
||||
if (vi->flags & FTF_BOOTCPUID)
|
||||
fprintf(f, "\t.long\t%i\t\t\t\t\t/* boot_cpuid_phys */\n",
|
||||
bi->boot_cpuid_phys);
|
||||
|
||||
if (vi->flags & FTF_STRTABSIZE)
|
||||
fprintf(f, "\t.long\t_%s_strings_end - _%s_strings_start\t/* size_dt_strings */\n",
|
||||
fprintf(f, "\t/* magic */\n");
|
||||
asm_emit_cell(f, FDT_MAGIC);
|
||||
fprintf(f, "\t/* totalsize */\n");
|
||||
ASM_EMIT_BELONG(f, "_%s_blob_abs_end - _%s_blob_start",
|
||||
symprefix, symprefix);
|
||||
fprintf(f, "\t/* off_dt_struct */\n");
|
||||
ASM_EMIT_BELONG(f, "_%s_struct_start - _%s_blob_start",
|
||||
symprefix, symprefix);
|
||||
fprintf(f, "\t/* off_dt_strings */\n");
|
||||
ASM_EMIT_BELONG(f, "_%s_strings_start - _%s_blob_start",
|
||||
symprefix, symprefix);
|
||||
fprintf(f, "\t/* off_mem_rsvmap */\n");
|
||||
ASM_EMIT_BELONG(f, "_%s_reserve_map - _%s_blob_start",
|
||||
symprefix, symprefix);
|
||||
fprintf(f, "\t/* version */\n");
|
||||
asm_emit_cell(f, vi->version);
|
||||
fprintf(f, "\t/* last_comp_version */\n");
|
||||
asm_emit_cell(f, vi->last_comp_version);
|
||||
|
||||
if (vi->flags & FTF_STRUCTSIZE)
|
||||
fprintf(f, "\t.long\t_%s_struct_end - _%s_struct_start\t/* size_dt_struct */\n",
|
||||
if (vi->flags & FTF_BOOTCPUID) {
|
||||
fprintf(f, "\t/* boot_cpuid_phys */\n");
|
||||
asm_emit_cell(f, bi->boot_cpuid_phys);
|
||||
}
|
||||
|
||||
if (vi->flags & FTF_STRTABSIZE) {
|
||||
fprintf(f, "\t/* size_dt_strings */\n");
|
||||
ASM_EMIT_BELONG(f, "_%s_strings_end - _%s_strings_start",
|
||||
symprefix, symprefix);
|
||||
}
|
||||
|
||||
if (vi->flags & FTF_STRUCTSIZE) {
|
||||
fprintf(f, "\t/* size_dt_struct */\n");
|
||||
ASM_EMIT_BELONG(f, "_%s_struct_end - _%s_struct_start",
|
||||
symprefix, symprefix);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reserve map entries.
|
||||
@ -505,16 +528,17 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
|
||||
* as it appears .quad isn't available in some assemblers.
|
||||
*/
|
||||
for (re = bi->reservelist; re; re = re->next) {
|
||||
if (re->label) {
|
||||
fprintf(f, "\t.globl\t%s\n", re->label);
|
||||
fprintf(f, "%s:\n", re->label);
|
||||
struct label *l;
|
||||
|
||||
for_each_label(re->labels, l) {
|
||||
fprintf(f, "\t.globl\t%s\n", l->label);
|
||||
fprintf(f, "%s:\n", l->label);
|
||||
}
|
||||
fprintf(f, "\t.long\t0x%08x, 0x%08x\n",
|
||||
(unsigned int)(re->re.address >> 32),
|
||||
(unsigned int)(re->re.address & 0xffffffff));
|
||||
fprintf(f, "\t.long\t0x%08x, 0x%08x\n",
|
||||
(unsigned int)(re->re.size >> 32),
|
||||
(unsigned int)(re->re.size & 0xffffffff));
|
||||
ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.address >> 32));
|
||||
ASM_EMIT_BELONG(f, "0x%08x",
|
||||
(unsigned int)(re->re.address & 0xffffffff));
|
||||
ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size >> 32));
|
||||
ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size & 0xffffffff));
|
||||
}
|
||||
for (i = 0; i < reservenum; i++) {
|
||||
fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
|
||||
@ -524,7 +548,9 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
|
||||
|
||||
emit_label(f, symprefix, "struct_start");
|
||||
flatten_tree(bi->dt, &asm_emitter, f, &strbuf, vi);
|
||||
fprintf(f, "\t.long\tFDT_END\n");
|
||||
|
||||
fprintf(f, "\t/* FDT_END */\n");
|
||||
asm_emit_cell(f, FDT_END);
|
||||
emit_label(f, symprefix, "struct_end");
|
||||
|
||||
emit_label(f, symprefix, "strings_start");
|
||||
@ -601,7 +627,7 @@ static char *flat_read_string(struct inbuf *inb)
|
||||
len++;
|
||||
} while ((*p++) != '\0');
|
||||
|
||||
str = strdup(inb->ptr);
|
||||
str = xstrdup(inb->ptr);
|
||||
|
||||
inb->ptr += len;
|
||||
|
||||
@ -643,7 +669,7 @@ static char *flat_read_stringtable(struct inbuf *inb, int offset)
|
||||
p++;
|
||||
}
|
||||
|
||||
return strdup(inb->base + offset);
|
||||
return xstrdup(inb->base + offset);
|
||||
}
|
||||
|
||||
static struct property *flat_read_property(struct inbuf *dtbuf,
|
||||
@ -663,7 +689,7 @@ static struct property *flat_read_property(struct inbuf *dtbuf,
|
||||
|
||||
val = flat_read_data(dtbuf, proplen);
|
||||
|
||||
return build_property(name, val, NULL);
|
||||
return build_property(name, val);
|
||||
}
|
||||
|
||||
|
||||
@ -688,7 +714,7 @@ static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb)
|
||||
if (re.size == 0)
|
||||
break;
|
||||
|
||||
new = build_reserve_entry(re.address, re.size, NULL);
|
||||
new = build_reserve_entry(re.address, re.size);
|
||||
reservelist = add_reserve_entry(reservelist, new);
|
||||
}
|
||||
|
||||
@ -710,7 +736,7 @@ static char *nodename_from_path(const char *ppath, const char *cpath)
|
||||
if (!streq(ppath, "/"))
|
||||
plen++;
|
||||
|
||||
return strdup(cpath + plen);
|
||||
return xstrdup(cpath + plen);
|
||||
}
|
||||
|
||||
static struct node *unflatten_tree(struct inbuf *dtbuf,
|
||||
@ -776,7 +802,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf,
|
||||
|
||||
struct boot_info *dt_from_blob(const char *fname)
|
||||
{
|
||||
struct dtc_file *dtcf;
|
||||
FILE *f;
|
||||
uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys;
|
||||
uint32_t off_dt, off_str, off_mem_rsvmap;
|
||||
int rc;
|
||||
@ -791,14 +817,14 @@ struct boot_info *dt_from_blob(const char *fname)
|
||||
uint32_t val;
|
||||
int flags = 0;
|
||||
|
||||
dtcf = dtc_open_file(fname, NULL);
|
||||
f = srcfile_relative_open(fname, NULL);
|
||||
|
||||
rc = fread(&magic, sizeof(magic), 1, dtcf->file);
|
||||
if (ferror(dtcf->file))
|
||||
rc = fread(&magic, sizeof(magic), 1, f);
|
||||
if (ferror(f))
|
||||
die("Error reading DT blob magic number: %s\n",
|
||||
strerror(errno));
|
||||
if (rc < 1) {
|
||||
if (feof(dtcf->file))
|
||||
if (feof(f))
|
||||
die("EOF reading DT blob magic number\n");
|
||||
else
|
||||
die("Mysterious short read reading magic number\n");
|
||||
@ -808,11 +834,11 @@ struct boot_info *dt_from_blob(const char *fname)
|
||||
if (magic != FDT_MAGIC)
|
||||
die("Blob has incorrect magic number\n");
|
||||
|
||||
rc = fread(&totalsize, sizeof(totalsize), 1, dtcf->file);
|
||||
if (ferror(dtcf->file))
|
||||
rc = fread(&totalsize, sizeof(totalsize), 1, f);
|
||||
if (ferror(f))
|
||||
die("Error reading DT blob size: %s\n", strerror(errno));
|
||||
if (rc < 1) {
|
||||
if (feof(dtcf->file))
|
||||
if (feof(f))
|
||||
die("EOF reading DT blob size\n");
|
||||
else
|
||||
die("Mysterious short read reading blob size\n");
|
||||
@ -832,12 +858,12 @@ struct boot_info *dt_from_blob(const char *fname)
|
||||
p = blob + sizeof(magic) + sizeof(totalsize);
|
||||
|
||||
while (sizeleft) {
|
||||
if (feof(dtcf->file))
|
||||
if (feof(f))
|
||||
die("EOF before reading %d bytes of DT blob\n",
|
||||
totalsize);
|
||||
|
||||
rc = fread(p, 1, sizeleft, dtcf->file);
|
||||
if (ferror(dtcf->file))
|
||||
rc = fread(p, 1, sizeleft, f);
|
||||
if (ferror(f))
|
||||
die("Error reading DT blob: %s\n",
|
||||
strerror(errno));
|
||||
|
||||
@ -900,7 +926,7 @@ struct boot_info *dt_from_blob(const char *fname)
|
||||
|
||||
free(blob);
|
||||
|
||||
dtc_close_file(dtcf);
|
||||
fclose(f);
|
||||
|
||||
return build_boot_info(reservelist, tree, boot_cpuid_phys);
|
||||
}
|
||||
|
@ -58,10 +58,9 @@ static struct node *read_fstree(const char *dirname)
|
||||
"WARNING: Cannot open %s: %s\n",
|
||||
tmpnam, strerror(errno));
|
||||
} else {
|
||||
prop = build_property(strdup(de->d_name),
|
||||
prop = build_property(xstrdup(de->d_name),
|
||||
data_copy_file(pfile,
|
||||
st.st_size),
|
||||
NULL);
|
||||
st.st_size));
|
||||
add_property(tree, prop);
|
||||
fclose(pfile);
|
||||
}
|
||||
@ -69,8 +68,7 @@ static struct node *read_fstree(const char *dirname)
|
||||
struct node *newchild;
|
||||
|
||||
newchild = read_fstree(tmpnam);
|
||||
newchild = name_node(newchild, strdup(de->d_name),
|
||||
NULL);
|
||||
newchild = name_node(newchild, xstrdup(de->d_name));
|
||||
add_child(tree, newchild);
|
||||
}
|
||||
|
||||
@ -86,8 +84,8 @@ struct boot_info *dt_from_fs(const char *dirname)
|
||||
struct node *tree;
|
||||
|
||||
tree = read_fstree(dirname);
|
||||
tree = name_node(tree, "", NULL);
|
||||
tree = name_node(tree, "");
|
||||
|
||||
return build_boot_info(NULL, tree, 0);
|
||||
return build_boot_info(NULL, tree, guess_boot_cpuid(tree));
|
||||
}
|
||||
|
||||
|
@ -24,17 +24,30 @@
|
||||
* Tree building functions
|
||||
*/
|
||||
|
||||
struct property *build_property(char *name, struct data val, char *label)
|
||||
void add_label(struct label **labels, char *label)
|
||||
{
|
||||
struct label *new;
|
||||
|
||||
/* Make sure the label isn't already there */
|
||||
for_each_label(*labels, new)
|
||||
if (streq(new->label, label))
|
||||
return;
|
||||
|
||||
new = xmalloc(sizeof(*new));
|
||||
new->label = label;
|
||||
new->next = *labels;
|
||||
*labels = new;
|
||||
}
|
||||
|
||||
struct property *build_property(char *name, struct data val)
|
||||
{
|
||||
struct property *new = xmalloc(sizeof(*new));
|
||||
|
||||
memset(new, 0, sizeof(*new));
|
||||
|
||||
new->name = name;
|
||||
new->val = val;
|
||||
|
||||
new->next = NULL;
|
||||
|
||||
new->label = label;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
@ -78,17 +91,82 @@ struct node *build_node(struct property *proplist, struct node *children)
|
||||
return new;
|
||||
}
|
||||
|
||||
struct node *name_node(struct node *node, char *name, char * label)
|
||||
struct node *name_node(struct node *node, char *name)
|
||||
{
|
||||
assert(node->name == NULL);
|
||||
|
||||
node->name = name;
|
||||
|
||||
node->label = label;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
struct node *merge_nodes(struct node *old_node, struct node *new_node)
|
||||
{
|
||||
struct property *new_prop, *old_prop;
|
||||
struct node *new_child, *old_child;
|
||||
struct label *l;
|
||||
|
||||
/* Add new node labels to old node */
|
||||
for_each_label(new_node->labels, l)
|
||||
add_label(&old_node->labels, l->label);
|
||||
|
||||
/* Move properties from the new node to the old node. If there
|
||||
* is a collision, replace the old value with the new */
|
||||
while (new_node->proplist) {
|
||||
/* Pop the property off the list */
|
||||
new_prop = new_node->proplist;
|
||||
new_node->proplist = new_prop->next;
|
||||
new_prop->next = NULL;
|
||||
|
||||
/* Look for a collision, set new value if there is */
|
||||
for_each_property(old_node, old_prop) {
|
||||
if (streq(old_prop->name, new_prop->name)) {
|
||||
/* Add new labels to old property */
|
||||
for_each_label(new_prop->labels, l)
|
||||
add_label(&old_prop->labels, l->label);
|
||||
|
||||
old_prop->val = new_prop->val;
|
||||
free(new_prop);
|
||||
new_prop = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* if no collision occurred, add property to the old node. */
|
||||
if (new_prop)
|
||||
add_property(old_node, new_prop);
|
||||
}
|
||||
|
||||
/* Move the override child nodes into the primary node. If
|
||||
* there is a collision, then merge the nodes. */
|
||||
while (new_node->children) {
|
||||
/* Pop the child node off the list */
|
||||
new_child = new_node->children;
|
||||
new_node->children = new_child->next_sibling;
|
||||
new_child->parent = NULL;
|
||||
new_child->next_sibling = NULL;
|
||||
|
||||
/* Search for a collision. Merge if there is */
|
||||
for_each_child(old_node, old_child) {
|
||||
if (streq(old_child->name, new_child->name)) {
|
||||
merge_nodes(old_child, new_child);
|
||||
new_child = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* if no collision occured, add child to the old node. */
|
||||
if (new_child)
|
||||
add_child(old_node, new_child);
|
||||
}
|
||||
|
||||
/* The new node contents are now merged into the old node. Free
|
||||
* the new node. */
|
||||
free(new_node);
|
||||
|
||||
return old_node;
|
||||
}
|
||||
|
||||
struct node *chain_node(struct node *first, struct node *list)
|
||||
{
|
||||
assert(first->next_sibling == NULL);
|
||||
@ -124,18 +202,15 @@ void add_child(struct node *parent, struct node *child)
|
||||
*p = child;
|
||||
}
|
||||
|
||||
struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size,
|
||||
char *label)
|
||||
struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size)
|
||||
{
|
||||
struct reserve_info *new = xmalloc(sizeof(*new));
|
||||
|
||||
memset(new, 0, sizeof(*new));
|
||||
|
||||
new->re.address = address;
|
||||
new->re.size = size;
|
||||
|
||||
new->next = NULL;
|
||||
|
||||
new->label = label;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
@ -208,6 +283,60 @@ cell_t propval_cell(struct property *prop)
|
||||
return fdt32_to_cpu(*((cell_t *)prop->val.val));
|
||||
}
|
||||
|
||||
struct property *get_property_by_label(struct node *tree, const char *label,
|
||||
struct node **node)
|
||||
{
|
||||
struct property *prop;
|
||||
struct node *c;
|
||||
|
||||
*node = tree;
|
||||
|
||||
for_each_property(tree, prop) {
|
||||
struct label *l;
|
||||
|
||||
for_each_label(prop->labels, l)
|
||||
if (streq(l->label, label))
|
||||
return prop;
|
||||
}
|
||||
|
||||
for_each_child(tree, c) {
|
||||
prop = get_property_by_label(c, label, node);
|
||||
if (prop)
|
||||
return prop;
|
||||
}
|
||||
|
||||
*node = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct marker *get_marker_label(struct node *tree, const char *label,
|
||||
struct node **node, struct property **prop)
|
||||
{
|
||||
struct marker *m;
|
||||
struct property *p;
|
||||
struct node *c;
|
||||
|
||||
*node = tree;
|
||||
|
||||
for_each_property(tree, p) {
|
||||
*prop = p;
|
||||
m = p->val.markers;
|
||||
for_each_marker_of_type(m, LABEL)
|
||||
if (streq(m->ref, label))
|
||||
return m;
|
||||
}
|
||||
|
||||
for_each_child(tree, c) {
|
||||
m = get_marker_label(c, label, node, prop);
|
||||
if (m)
|
||||
return m;
|
||||
}
|
||||
|
||||
*prop = NULL;
|
||||
*node = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct node *get_subnode(struct node *node, const char *nodename)
|
||||
{
|
||||
struct node *child;
|
||||
@ -245,11 +374,13 @@ struct node *get_node_by_path(struct node *tree, const char *path)
|
||||
struct node *get_node_by_label(struct node *tree, const char *label)
|
||||
{
|
||||
struct node *child, *node;
|
||||
struct label *l;
|
||||
|
||||
assert(label && (strlen(label) > 0));
|
||||
|
||||
if (tree->label && streq(tree->label, label))
|
||||
return tree;
|
||||
for_each_label(tree->labels, l)
|
||||
if (streq(l->label, label))
|
||||
return tree;
|
||||
|
||||
for_each_child(tree, child) {
|
||||
node = get_node_by_label(child, label);
|
||||
@ -293,16 +424,186 @@ cell_t get_node_phandle(struct node *root, struct node *node)
|
||||
if ((node->phandle != 0) && (node->phandle != -1))
|
||||
return node->phandle;
|
||||
|
||||
assert(! get_property(node, "linux,phandle"));
|
||||
|
||||
while (get_node_by_phandle(root, phandle))
|
||||
phandle++;
|
||||
|
||||
node->phandle = phandle;
|
||||
add_property(node,
|
||||
build_property("linux,phandle",
|
||||
data_append_cell(empty_data, phandle),
|
||||
NULL));
|
||||
|
||||
if (!get_property(node, "linux,phandle")
|
||||
&& (phandle_format & PHANDLE_LEGACY))
|
||||
add_property(node,
|
||||
build_property("linux,phandle",
|
||||
data_append_cell(empty_data, phandle)));
|
||||
|
||||
if (!get_property(node, "phandle")
|
||||
&& (phandle_format & PHANDLE_EPAPR))
|
||||
add_property(node,
|
||||
build_property("phandle",
|
||||
data_append_cell(empty_data, phandle)));
|
||||
|
||||
/* If the node *does* have a phandle property, we must
|
||||
* be dealing with a self-referencing phandle, which will be
|
||||
* fixed up momentarily in the caller */
|
||||
|
||||
return node->phandle;
|
||||
}
|
||||
|
||||
uint32_t guess_boot_cpuid(struct node *tree)
|
||||
{
|
||||
struct node *cpus, *bootcpu;
|
||||
struct property *reg;
|
||||
|
||||
cpus = get_node_by_path(tree, "/cpus");
|
||||
if (!cpus)
|
||||
return 0;
|
||||
|
||||
|
||||
bootcpu = cpus->children;
|
||||
if (!bootcpu)
|
||||
return 0;
|
||||
|
||||
reg = get_property(bootcpu, "reg");
|
||||
if (!reg || (reg->val.len != sizeof(uint32_t)))
|
||||
return 0;
|
||||
|
||||
/* FIXME: Sanity check node? */
|
||||
|
||||
return propval_cell(reg);
|
||||
}
|
||||
|
||||
static int cmp_reserve_info(const void *ax, const void *bx)
|
||||
{
|
||||
const struct reserve_info *a, *b;
|
||||
|
||||
a = *((const struct reserve_info * const *)ax);
|
||||
b = *((const struct reserve_info * const *)bx);
|
||||
|
||||
if (a->re.address < b->re.address)
|
||||
return -1;
|
||||
else if (a->re.address > b->re.address)
|
||||
return 1;
|
||||
else if (a->re.size < b->re.size)
|
||||
return -1;
|
||||
else if (a->re.size > b->re.size)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sort_reserve_entries(struct boot_info *bi)
|
||||
{
|
||||
struct reserve_info *ri, **tbl;
|
||||
int n = 0, i = 0;
|
||||
|
||||
for (ri = bi->reservelist;
|
||||
ri;
|
||||
ri = ri->next)
|
||||
n++;
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
tbl = xmalloc(n * sizeof(*tbl));
|
||||
|
||||
for (ri = bi->reservelist;
|
||||
ri;
|
||||
ri = ri->next)
|
||||
tbl[i++] = ri;
|
||||
|
||||
qsort(tbl, n, sizeof(*tbl), cmp_reserve_info);
|
||||
|
||||
bi->reservelist = tbl[0];
|
||||
for (i = 0; i < (n-1); i++)
|
||||
tbl[i]->next = tbl[i+1];
|
||||
tbl[n-1]->next = NULL;
|
||||
|
||||
free(tbl);
|
||||
}
|
||||
|
||||
static int cmp_prop(const void *ax, const void *bx)
|
||||
{
|
||||
const struct property *a, *b;
|
||||
|
||||
a = *((const struct property * const *)ax);
|
||||
b = *((const struct property * const *)bx);
|
||||
|
||||
return strcmp(a->name, b->name);
|
||||
}
|
||||
|
||||
static void sort_properties(struct node *node)
|
||||
{
|
||||
int n = 0, i = 0;
|
||||
struct property *prop, **tbl;
|
||||
|
||||
for_each_property(node, prop)
|
||||
n++;
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
tbl = xmalloc(n * sizeof(*tbl));
|
||||
|
||||
for_each_property(node, prop)
|
||||
tbl[i++] = prop;
|
||||
|
||||
qsort(tbl, n, sizeof(*tbl), cmp_prop);
|
||||
|
||||
node->proplist = tbl[0];
|
||||
for (i = 0; i < (n-1); i++)
|
||||
tbl[i]->next = tbl[i+1];
|
||||
tbl[n-1]->next = NULL;
|
||||
|
||||
free(tbl);
|
||||
}
|
||||
|
||||
static int cmp_subnode(const void *ax, const void *bx)
|
||||
{
|
||||
const struct node *a, *b;
|
||||
|
||||
a = *((const struct node * const *)ax);
|
||||
b = *((const struct node * const *)bx);
|
||||
|
||||
return strcmp(a->name, b->name);
|
||||
}
|
||||
|
||||
static void sort_subnodes(struct node *node)
|
||||
{
|
||||
int n = 0, i = 0;
|
||||
struct node *subnode, **tbl;
|
||||
|
||||
for_each_child(node, subnode)
|
||||
n++;
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
tbl = xmalloc(n * sizeof(*tbl));
|
||||
|
||||
for_each_child(node, subnode)
|
||||
tbl[i++] = subnode;
|
||||
|
||||
qsort(tbl, n, sizeof(*tbl), cmp_subnode);
|
||||
|
||||
node->children = tbl[0];
|
||||
for (i = 0; i < (n-1); i++)
|
||||
tbl[i]->next_sibling = tbl[i+1];
|
||||
tbl[n-1]->next_sibling = NULL;
|
||||
|
||||
free(tbl);
|
||||
}
|
||||
|
||||
static void sort_node(struct node *node)
|
||||
{
|
||||
struct node *c;
|
||||
|
||||
sort_properties(node);
|
||||
sort_subnodes(node);
|
||||
for_each_child(node, c)
|
||||
sort_node(c);
|
||||
}
|
||||
|
||||
void sort_tree(struct boot_info *bi)
|
||||
{
|
||||
sort_reserve_entries(bi);
|
||||
sort_node(bi->dt);
|
||||
}
|
||||
|
@ -17,100 +17,232 @@
|
||||
* USA
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "dtc.h"
|
||||
#include "srcpos.h"
|
||||
|
||||
/*
|
||||
* Like yylineno, this is the current open file pos.
|
||||
*/
|
||||
|
||||
struct dtc_file *srcpos_file;
|
||||
|
||||
static int dtc_open_one(struct dtc_file *file,
|
||||
const char *search,
|
||||
const char *fname)
|
||||
static char *dirname(const char *path)
|
||||
{
|
||||
const char *slash = strrchr(path, '/');
|
||||
|
||||
if (slash) {
|
||||
int len = slash - path;
|
||||
char *dir = xmalloc(len + 1);
|
||||
|
||||
memcpy(dir, path, len);
|
||||
dir[len] = '\0';
|
||||
return dir;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct srcfile_state *current_srcfile; /* = NULL */
|
||||
|
||||
/* Detect infinite include recursion. */
|
||||
#define MAX_SRCFILE_DEPTH (100)
|
||||
static int srcfile_depth; /* = 0 */
|
||||
|
||||
FILE *srcfile_relative_open(const char *fname, char **fullnamep)
|
||||
{
|
||||
FILE *f;
|
||||
char *fullname;
|
||||
|
||||
if (search) {
|
||||
fullname = xmalloc(strlen(search) + strlen(fname) + 2);
|
||||
|
||||
strcpy(fullname, search);
|
||||
strcat(fullname, "/");
|
||||
strcat(fullname, fname);
|
||||
} else {
|
||||
fullname = strdup(fname);
|
||||
}
|
||||
|
||||
file->file = fopen(fullname, "r");
|
||||
if (!file->file) {
|
||||
free(fullname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
file->name = fullname;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
struct dtc_file *dtc_open_file(const char *fname,
|
||||
const struct search_path *search)
|
||||
{
|
||||
static const struct search_path default_search = { NULL, NULL, NULL };
|
||||
|
||||
struct dtc_file *file;
|
||||
const char *slash;
|
||||
|
||||
file = xmalloc(sizeof(struct dtc_file));
|
||||
|
||||
slash = strrchr(fname, '/');
|
||||
if (slash) {
|
||||
char *dir = xmalloc(slash - fname + 1);
|
||||
|
||||
memcpy(dir, fname, slash - fname);
|
||||
dir[slash - fname] = 0;
|
||||
file->dir = dir;
|
||||
} else {
|
||||
file->dir = NULL;
|
||||
}
|
||||
|
||||
if (streq(fname, "-")) {
|
||||
file->name = "stdin";
|
||||
file->file = stdin;
|
||||
return file;
|
||||
f = stdin;
|
||||
fullname = xstrdup("<stdin>");
|
||||
} else {
|
||||
if (!current_srcfile || !current_srcfile->dir
|
||||
|| (fname[0] == '/'))
|
||||
fullname = xstrdup(fname);
|
||||
else
|
||||
fullname = join_path(current_srcfile->dir, fname);
|
||||
|
||||
f = fopen(fullname, "r");
|
||||
if (!f)
|
||||
die("Couldn't open \"%s\": %s\n", fname,
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
if (fname[0] == '/') {
|
||||
file->file = fopen(fname, "r");
|
||||
if (!file->file)
|
||||
goto fail;
|
||||
if (fullnamep)
|
||||
*fullnamep = fullname;
|
||||
else
|
||||
free(fullname);
|
||||
|
||||
file->name = strdup(fname);
|
||||
return file;
|
||||
}
|
||||
|
||||
if (!search)
|
||||
search = &default_search;
|
||||
|
||||
while (search) {
|
||||
if (dtc_open_one(file, search->dir, fname))
|
||||
return file;
|
||||
|
||||
if (errno != ENOENT)
|
||||
goto fail;
|
||||
|
||||
search = search->next;
|
||||
}
|
||||
|
||||
fail:
|
||||
die("Couldn't open \"%s\": %s\n", fname, strerror(errno));
|
||||
return f;
|
||||
}
|
||||
|
||||
void dtc_close_file(struct dtc_file *file)
|
||||
void srcfile_push(const char *fname)
|
||||
{
|
||||
if (fclose(file->file))
|
||||
die("Error closing \"%s\": %s\n", file->name, strerror(errno));
|
||||
struct srcfile_state *srcfile;
|
||||
|
||||
free(file->dir);
|
||||
free(file);
|
||||
if (srcfile_depth++ >= MAX_SRCFILE_DEPTH)
|
||||
die("Includes nested too deeply");
|
||||
|
||||
srcfile = xmalloc(sizeof(*srcfile));
|
||||
|
||||
srcfile->f = srcfile_relative_open(fname, &srcfile->name);
|
||||
srcfile->dir = dirname(srcfile->name);
|
||||
srcfile->prev = current_srcfile;
|
||||
|
||||
srcfile->lineno = 1;
|
||||
srcfile->colno = 1;
|
||||
|
||||
current_srcfile = srcfile;
|
||||
}
|
||||
|
||||
int srcfile_pop(void)
|
||||
{
|
||||
struct srcfile_state *srcfile = current_srcfile;
|
||||
|
||||
assert(srcfile);
|
||||
|
||||
current_srcfile = srcfile->prev;
|
||||
|
||||
if (fclose(srcfile->f))
|
||||
die("Error closing \"%s\": %s\n", srcfile->name,
|
||||
strerror(errno));
|
||||
|
||||
/* FIXME: We allow the srcfile_state structure to leak,
|
||||
* because it could still be referenced from a location
|
||||
* variable being carried through the parser somewhere. To
|
||||
* fix this we could either allocate all the files from a
|
||||
* table, or use a pool allocator. */
|
||||
|
||||
return current_srcfile ? 1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The empty source position.
|
||||
*/
|
||||
|
||||
struct srcpos srcpos_empty = {
|
||||
.first_line = 0,
|
||||
.first_column = 0,
|
||||
.last_line = 0,
|
||||
.last_column = 0,
|
||||
.file = NULL,
|
||||
};
|
||||
|
||||
#define TAB_SIZE 8
|
||||
|
||||
void srcpos_update(struct srcpos *pos, const char *text, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
pos->file = current_srcfile;
|
||||
|
||||
pos->first_line = current_srcfile->lineno;
|
||||
pos->first_column = current_srcfile->colno;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
if (text[i] == '\n') {
|
||||
current_srcfile->lineno++;
|
||||
current_srcfile->colno = 1;
|
||||
} else if (text[i] == '\t') {
|
||||
current_srcfile->colno =
|
||||
ALIGN(current_srcfile->colno, TAB_SIZE);
|
||||
} else {
|
||||
current_srcfile->colno++;
|
||||
}
|
||||
|
||||
pos->last_line = current_srcfile->lineno;
|
||||
pos->last_column = current_srcfile->colno;
|
||||
}
|
||||
|
||||
struct srcpos *
|
||||
srcpos_copy(struct srcpos *pos)
|
||||
{
|
||||
struct srcpos *pos_new;
|
||||
|
||||
pos_new = xmalloc(sizeof(struct srcpos));
|
||||
memcpy(pos_new, pos, sizeof(struct srcpos));
|
||||
|
||||
return pos_new;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
srcpos_dump(struct srcpos *pos)
|
||||
{
|
||||
printf("file : \"%s\"\n",
|
||||
pos->file ? (char *) pos->file : "<no file>");
|
||||
printf("first_line : %d\n", pos->first_line);
|
||||
printf("first_column: %d\n", pos->first_column);
|
||||
printf("last_line : %d\n", pos->last_line);
|
||||
printf("last_column : %d\n", pos->last_column);
|
||||
printf("file : %s\n", pos->file->name);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
srcpos_string(struct srcpos *pos)
|
||||
{
|
||||
const char *fname = "<no-file>";
|
||||
char *pos_str;
|
||||
int rc;
|
||||
|
||||
if (pos)
|
||||
fname = pos->file->name;
|
||||
|
||||
|
||||
if (pos->first_line != pos->last_line)
|
||||
rc = asprintf(&pos_str, "%s:%d.%d-%d.%d", fname,
|
||||
pos->first_line, pos->first_column,
|
||||
pos->last_line, pos->last_column);
|
||||
else if (pos->first_column != pos->last_column)
|
||||
rc = asprintf(&pos_str, "%s:%d.%d-%d", fname,
|
||||
pos->first_line, pos->first_column,
|
||||
pos->last_column);
|
||||
else
|
||||
rc = asprintf(&pos_str, "%s:%d.%d", fname,
|
||||
pos->first_line, pos->first_column);
|
||||
|
||||
if (rc == -1)
|
||||
die("Couldn't allocate in srcpos string");
|
||||
|
||||
return pos_str;
|
||||
}
|
||||
|
||||
void
|
||||
srcpos_verror(struct srcpos *pos, char const *fmt, va_list va)
|
||||
{
|
||||
const char *srcstr;
|
||||
|
||||
srcstr = srcpos_string(pos);
|
||||
|
||||
fprintf(stdout, "Error: %s ", srcstr);
|
||||
vfprintf(stdout, fmt, va);
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
srcpos_error(struct srcpos *pos, char const *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
||||
va_start(va, fmt);
|
||||
srcpos_verror(pos, fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
srcpos_warn(struct srcpos *pos, char const *fmt, ...)
|
||||
{
|
||||
const char *srcstr;
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
|
||||
srcstr = srcpos_string(pos);
|
||||
|
||||
fprintf(stderr, "Warning: %s ", srcstr);
|
||||
vfprintf(stderr, fmt, va);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
va_end(va);
|
||||
}
|
||||
|
@ -17,69 +17,70 @@
|
||||
* USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Augment the standard YYLTYPE with a filenum index into an
|
||||
* array of all opened filenames.
|
||||
*/
|
||||
#ifndef _SRCPOS_H_
|
||||
#define _SRCPOS_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
struct dtc_file {
|
||||
struct srcfile_state {
|
||||
FILE *f;
|
||||
char *name;
|
||||
char *dir;
|
||||
const char *name;
|
||||
FILE *file;
|
||||
int lineno, colno;
|
||||
struct srcfile_state *prev;
|
||||
};
|
||||
|
||||
#if ! defined(YYLTYPE) && ! defined(YYLTYPE_IS_DECLARED)
|
||||
typedef struct YYLTYPE {
|
||||
extern struct srcfile_state *current_srcfile; /* = NULL */
|
||||
|
||||
FILE *srcfile_relative_open(const char *fname, char **fullnamep);
|
||||
void srcfile_push(const char *fname);
|
||||
int srcfile_pop(void);
|
||||
|
||||
struct srcpos {
|
||||
int first_line;
|
||||
int first_column;
|
||||
int last_line;
|
||||
int last_column;
|
||||
struct dtc_file *file;
|
||||
} YYLTYPE;
|
||||
|
||||
#define YYLTYPE_IS_DECLARED 1
|
||||
#define YYLTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
/* Cater to old parser templates. */
|
||||
#ifndef YYID
|
||||
#define YYID(n) (n)
|
||||
#endif
|
||||
|
||||
#define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
do \
|
||||
if (YYID (N)) \
|
||||
{ \
|
||||
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
||||
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
||||
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
||||
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
||||
(Current).file = YYRHSLOC (Rhs, N).file; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(Current).first_line = (Current).last_line = \
|
||||
YYRHSLOC (Rhs, 0).last_line; \
|
||||
(Current).first_column = (Current).last_column = \
|
||||
YYRHSLOC (Rhs, 0).last_column; \
|
||||
(Current).file = YYRHSLOC (Rhs, 0).file; \
|
||||
} \
|
||||
while (YYID (0))
|
||||
|
||||
|
||||
|
||||
extern void yyerror(char const *);
|
||||
extern void yyerrorf(char const *, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
extern struct dtc_file *srcpos_file;
|
||||
|
||||
struct search_path {
|
||||
const char *dir; /* NULL for current directory */
|
||||
struct search_path *prev, *next;
|
||||
struct srcfile_state *file;
|
||||
};
|
||||
|
||||
extern struct dtc_file *dtc_open_file(const char *fname,
|
||||
const struct search_path *search);
|
||||
extern void dtc_close_file(struct dtc_file *file);
|
||||
#define YYLTYPE struct srcpos
|
||||
|
||||
#define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
do { \
|
||||
if (N) { \
|
||||
(Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
|
||||
(Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
|
||||
(Current).last_line = YYRHSLOC(Rhs, N).last_line; \
|
||||
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
||||
(Current).file = YYRHSLOC(Rhs, N).file; \
|
||||
} else { \
|
||||
(Current).first_line = (Current).last_line = \
|
||||
YYRHSLOC(Rhs, 0).last_line; \
|
||||
(Current).first_column = (Current).last_column = \
|
||||
YYRHSLOC(Rhs, 0).last_column; \
|
||||
(Current).file = YYRHSLOC (Rhs, 0).file; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* Fictional source position used for IR nodes that are
|
||||
* created without otherwise knowing a true source position.
|
||||
* For example,constant definitions from the command line.
|
||||
*/
|
||||
extern struct srcpos srcpos_empty;
|
||||
|
||||
extern void srcpos_update(struct srcpos *pos, const char *text, int len);
|
||||
extern struct srcpos *srcpos_copy(struct srcpos *pos);
|
||||
extern char *srcpos_string(struct srcpos *pos);
|
||||
extern void srcpos_dump(struct srcpos *pos);
|
||||
|
||||
extern void srcpos_verror(struct srcpos *pos, char const *, va_list va)
|
||||
__attribute__((format(printf, 2, 0)));
|
||||
extern void srcpos_error(struct srcpos *pos, char const *, ...)
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
extern void srcpos_warn(struct srcpos *pos, char const *, ...)
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
|
||||
#endif /* _SRCPOS_H_ */
|
||||
|
@ -32,8 +32,8 @@ struct boot_info *dt_from_source(const char *fname)
|
||||
the_boot_info = NULL;
|
||||
treesource_error = 0;
|
||||
|
||||
srcpos_file = dtc_open_file(fname, NULL);
|
||||
yyin = srcpos_file->file;
|
||||
srcfile_push(fname);
|
||||
yyin = current_srcfile->f;
|
||||
|
||||
if (yyparse() != 0)
|
||||
die("Unable to parse input tree\n");
|
||||
@ -63,26 +63,20 @@ static void write_propval_string(FILE *f, struct data val)
|
||||
{
|
||||
const char *str = val.val;
|
||||
int i;
|
||||
int newchunk = 1;
|
||||
struct marker *m = val.markers;
|
||||
|
||||
assert(str[val.len-1] == '\0');
|
||||
|
||||
while (m && (m->offset == 0)) {
|
||||
if (m->type == LABEL)
|
||||
fprintf(f, "%s: ", m->ref);
|
||||
m = m->next;
|
||||
}
|
||||
fprintf(f, "\"");
|
||||
|
||||
for (i = 0; i < (val.len-1); i++) {
|
||||
char c = str[i];
|
||||
|
||||
if (newchunk) {
|
||||
while (m && (m->offset <= i)) {
|
||||
if (m->type == LABEL) {
|
||||
assert(m->offset == i);
|
||||
fprintf(f, "%s: ", m->ref);
|
||||
}
|
||||
m = m->next;
|
||||
}
|
||||
fprintf(f, "\"");
|
||||
newchunk = 0;
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case '\a':
|
||||
fprintf(f, "\\a");
|
||||
@ -113,7 +107,14 @@ static void write_propval_string(FILE *f, struct data val)
|
||||
break;
|
||||
case '\0':
|
||||
fprintf(f, "\", ");
|
||||
newchunk = 1;
|
||||
while (m && (m->offset < i)) {
|
||||
if (m->type == LABEL) {
|
||||
assert(m->offset == (i+1));
|
||||
fprintf(f, "%s: ", m->ref);
|
||||
}
|
||||
m = m->next;
|
||||
}
|
||||
fprintf(f, "\"");
|
||||
break;
|
||||
default:
|
||||
if (isprint(c))
|
||||
@ -234,10 +235,11 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level)
|
||||
{
|
||||
struct property *prop;
|
||||
struct node *child;
|
||||
struct label *l;
|
||||
|
||||
write_prefix(f, level);
|
||||
if (tree->label)
|
||||
fprintf(f, "%s: ", tree->label);
|
||||
for_each_label(tree->labels, l)
|
||||
fprintf(f, "%s: ", l->label);
|
||||
if (tree->name && (*tree->name))
|
||||
fprintf(f, "%s {\n", tree->name);
|
||||
else
|
||||
@ -245,8 +247,8 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level)
|
||||
|
||||
for_each_property(tree, prop) {
|
||||
write_prefix(f, level+1);
|
||||
if (prop->label)
|
||||
fprintf(f, "%s: ", prop->label);
|
||||
for_each_label(prop->labels, l)
|
||||
fprintf(f, "%s: ", l->label);
|
||||
fprintf(f, "%s", prop->name);
|
||||
write_propval(f, prop);
|
||||
}
|
||||
@ -266,8 +268,10 @@ void dt_to_source(FILE *f, struct boot_info *bi)
|
||||
fprintf(f, "/dts-v1/;\n\n");
|
||||
|
||||
for (re = bi->reservelist; re; re = re->next) {
|
||||
if (re->label)
|
||||
fprintf(f, "%s: ", re->label);
|
||||
struct label *l;
|
||||
|
||||
for_each_label(re->labels, l)
|
||||
fprintf(f, "%s: ", l->label);
|
||||
fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n",
|
||||
(unsigned long long)re->re.address,
|
||||
(unsigned long long)re->re.size);
|
||||
|
59
scripts/dtc/util.c
Normal file
59
scripts/dtc/util.c
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
char *xstrdup(const char *s)
|
||||
{
|
||||
int len = strlen(s) + 1;
|
||||
char *dup = xmalloc(len);
|
||||
|
||||
memcpy(dup, s, len);
|
||||
|
||||
return dup;
|
||||
}
|
||||
|
||||
char *join_path(const char *path, const char *name)
|
||||
{
|
||||
int lenp = strlen(path);
|
||||
int lenn = strlen(name);
|
||||
int len;
|
||||
int needslash = 1;
|
||||
char *str;
|
||||
|
||||
len = lenp + lenn + 2;
|
||||
if ((lenp > 0) && (path[lenp-1] == '/')) {
|
||||
needslash = 0;
|
||||
len--;
|
||||
}
|
||||
|
||||
str = xmalloc(len);
|
||||
memcpy(str, path, lenp);
|
||||
if (needslash) {
|
||||
str[lenp] = '/';
|
||||
lenp++;
|
||||
}
|
||||
memcpy(str+lenp, name, lenn+1);
|
||||
return str;
|
||||
}
|
56
scripts/dtc/util.h
Normal file
56
scripts/dtc/util.h
Normal file
@ -0,0 +1,56 @@
|
||||
#ifndef _UTIL_H
|
||||
#define _UTIL_H
|
||||
|
||||
/*
|
||||
* Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
static inline void __attribute__((noreturn)) die(char * str, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, str);
|
||||
fprintf(stderr, "FATAL ERROR: ");
|
||||
vfprintf(stderr, str, ap);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static inline void *xmalloc(size_t len)
|
||||
{
|
||||
void *new = malloc(len);
|
||||
|
||||
if (!new)
|
||||
die("malloc() failed\n");
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
static inline void *xrealloc(void *p, size_t len)
|
||||
{
|
||||
void *new = realloc(p, len);
|
||||
|
||||
if (!new)
|
||||
die("realloc() failed (len=%d)\n", len);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
extern char *xstrdup(const char *s);
|
||||
extern char *join_path(const char *path, const char *name);
|
||||
|
||||
#endif /* _UTIL_H */
|
@ -1 +1 @@
|
||||
#define DTC_VERSION "DTC 1.2.0"
|
||||
#define DTC_VERSION "DTC 1.2.0-g37c0b6a0"
|
||||
|
Loading…
Reference in New Issue
Block a user