From 6ce0dd2e7c4bc7a34852d8f86d9ef0ec4d69cb3d Mon Sep 17 00:00:00 2001 From: visa Date: Mon, 24 Apr 2017 13:54:28 +0000 Subject: [PATCH] Add an fdt blob for octeon systems whose firmware does not provide a device-tree. It will be needed later when more device drivers are attached using fdt. OK kettenis@ --- sys/arch/octeon/conf/files.octeon | 3 +- sys/arch/octeon/octeon/cn3xxx.dts | 61 +++++++++ sys/arch/octeon/octeon/cn3xxx_dts.S | 201 ++++++++++++++++++++++++++++ sys/arch/octeon/octeon/machdep.c | 7 +- 4 files changed, 269 insertions(+), 3 deletions(-) create mode 100644 sys/arch/octeon/octeon/cn3xxx.dts create mode 100644 sys/arch/octeon/octeon/cn3xxx_dts.S diff --git a/sys/arch/octeon/conf/files.octeon b/sys/arch/octeon/conf/files.octeon index 38343492099..d940fc4e71d 100644 --- a/sys/arch/octeon/conf/files.octeon +++ b/sys/arch/octeon/conf/files.octeon @@ -1,4 +1,4 @@ -# $OpenBSD: files.octeon,v 1.33 2016/12/21 13:59:57 visa Exp $ +# $OpenBSD: files.octeon,v 1.34 2017/04/24 13:54:28 visa Exp $ # Standard stanzas config(8) can't run without maxpartitions 16 @@ -19,6 +19,7 @@ file arch/octeon/octeon/bus_dma.c file arch/octeon/octeon/conf.c file arch/octeon/octeon/disksubr.c disk file arch/octeon/octeon/machdep.c +file arch/octeon/octeon/cn3xxx_dts.S include "dev/ata/files.ata" include "dev/atapiscsi/files.atapiscsi" diff --git a/sys/arch/octeon/octeon/cn3xxx.dts b/sys/arch/octeon/octeon/cn3xxx.dts new file mode 100644 index 00000000000..0bd2076770b --- /dev/null +++ b/sys/arch/octeon/octeon/cn3xxx.dts @@ -0,0 +1,61 @@ +/* $OpenBSD: cn3xxx.dts,v 1.1 2017/04/24 13:54:28 visa Exp $ */ + +/* + * Copyright (c) 2017 Visa Hankala + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Dummy device-tree for CN3xxx/CN5xxx based systems where the firmware + * does not provide a native one. + */ + +/* + * The file is compiled into an asm file using the Linux device tree compiler. + * + * $ dtc -V 17 -O asm -o cn3xxx_dts.S cn3xxx.dts + * + * To avoid invalid 8-bit relocations in the object file, certain sequences + * of .byte values have to be folded manually into .word values + * in the generated header. + */ + +/dts-v1/; + +/ { + model = "CN3xxx/CN5xxx"; + #address-cells = <2>; + #size-cells = <2>; + + soc@0 { + compatible = "simple-bus"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + ciu@1070000000000 { + compatible = "cavium,octeon-3860-ciu"; + interrupt-controller; + #interrupt-cells = <2>; + reg = <0x10700 0x00000000 0x0 0x7000>; + }; + + mdio@1180000001800 { + compatible = "cavium,octeon-3860-mdio"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x11800 0x00001800 0x0 0x40>; + }; + }; +}; diff --git a/sys/arch/octeon/octeon/cn3xxx_dts.S b/sys/arch/octeon/octeon/cn3xxx_dts.S new file mode 100644 index 00000000000..aec0a3ca1f7 --- /dev/null +++ b/sys/arch/octeon/octeon/cn3xxx_dts.S @@ -0,0 +1,201 @@ +/* autogenerated by dtc, do not edit */ + + .globl dt_blob_start +dt_blob_start: +_dt_blob_start: + .globl dt_header +dt_header: +_dt_header: + /* magic */ + .byte 0xd0; .byte 0x0d; .byte 0xfe; .byte 0xed + /* totalsize */ + .word _dt_blob_abs_end - _dt_blob_start + /* off_dt_struct */ + .word _dt_struct_start - _dt_blob_start + /* off_dt_strings */ + .word _dt_strings_start - _dt_blob_start + /* off_mem_rsvmap */ + .word _dt_reserve_map - _dt_blob_start + /* version */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x11 + /* last_comp_version */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x10 + /* boot_cpuid_phys */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x00 + /* size_dt_strings */ + .word _dt_strings_end - _dt_strings_start + /* size_dt_struct */ + .word _dt_struct_end - _dt_struct_start + .balign 8, 0 + .globl dt_reserve_map +dt_reserve_map: +_dt_reserve_map: +/* Memory reserve map from source file */ + .long 0, 0 + .long 0, 0 + .globl dt_struct_start +dt_struct_start: +_dt_struct_start: + /* FDT_BEGIN_NODE */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x01 + .string "" + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x0e + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x00 + .byte 0x43; .byte 0x4e; .byte 0x33; .byte 0x78 + .byte 0x78; .byte 0x78; .byte 0x2f; .byte 0x43 + .byte 0x4e; .byte 0x35; .byte 0x78; .byte 0x78 + .byte 0x78 + .byte 0x0 + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x04 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x06 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x02 + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x04 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x15 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x02 + .balign 4, 0 + /* FDT_BEGIN_NODE */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x01 + .string "soc@0" + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x0b + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x21 + .byte 0x73; .byte 0x69; .byte 0x6d; .byte 0x70 + .byte 0x6c; .byte 0x65; .byte 0x2d; .byte 0x62 + .byte 0x75 + .byte 0x73 + .byte 0x0 + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x04 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x06 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x02 + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x04 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x15 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x02 + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x00 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x2c + .balign 4, 0 + /* FDT_BEGIN_NODE */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x01 + .string "ciu@1070000000000" + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x17 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x21 + .byte 0x63; .byte 0x61; .byte 0x76; .byte 0x69 + .byte 0x75; .byte 0x6d; .byte 0x2c; .byte 0x6f + .byte 0x63; .byte 0x74; .byte 0x65; .byte 0x6f + .byte 0x6e; .byte 0x2d; .byte 0x33; .byte 0x38 + .byte 0x36; .byte 0x30; .byte 0x2d; .byte 0x63 + .byte 0x69 + .byte 0x75 + .byte 0x0 + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x00 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x33 + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x04 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x48 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x02 + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x10 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x59 + .byte 0x00; .byte 0x01; .byte 0x07; .byte 0x00 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x00 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x00 + .byte 0x00; .byte 0x00; .byte 0x70; .byte 0x00 + .balign 4, 0 + /* FDT_END_NODE */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x02 + /* FDT_BEGIN_NODE */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x01 + .string "mdio@1180000001800" + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x18 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x21 + .byte 0x63; .byte 0x61; .byte 0x76; .byte 0x69 + .byte 0x75; .byte 0x6d; .byte 0x2c; .byte 0x6f + .byte 0x63; .byte 0x74; .byte 0x65; .byte 0x6f + .byte 0x6e; .byte 0x2d; .byte 0x33; .byte 0x38 + .byte 0x36; .byte 0x30; .byte 0x2d; .byte 0x6d + .byte 0x64; .byte 0x69; .byte 0x6f; .byte 0x00 + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x04 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x06 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x01 + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x04 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x15 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x00 + .balign 4, 0 + /* FDT_PROP */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x03 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x10 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x59 + .byte 0x00; .byte 0x01; .byte 0x18; .byte 0x00 + .byte 0x00; .byte 0x00; .byte 0x18; .byte 0x00 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x00 + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x40 + .balign 4, 0 + /* FDT_END_NODE */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x02 + /* FDT_END_NODE */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x02 + /* FDT_END_NODE */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x02 + /* FDT_END */ + .byte 0x00; .byte 0x00; .byte 0x00; .byte 0x09 + .globl dt_struct_end +dt_struct_end: +_dt_struct_end: + .globl dt_strings_start +dt_strings_start: +_dt_strings_start: + .string "model" + .string "#address-cells" + .string "#size-cells" + .string "compatible" + .string "ranges" + .string "interrupt-controller" + .string "#interrupt-cells" + .string "reg" + .globl dt_strings_end +dt_strings_end: +_dt_strings_end: + .globl dt_blob_end +dt_blob_end: +_dt_blob_end: + .globl dt_blob_abs_end +dt_blob_abs_end: +_dt_blob_abs_end: diff --git a/sys/arch/octeon/octeon/machdep.c b/sys/arch/octeon/octeon/machdep.c index 5d5c099a034..925a56df0b8 100644 --- a/sys/arch/octeon/octeon/machdep.c +++ b/sys/arch/octeon/octeon/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.86 2017/04/20 15:42:26 visa Exp $ */ +/* $OpenBSD: machdep.c,v 1.87 2017/04/24 13:54:28 visa Exp $ */ /* * Copyright (c) 2009, 2010 Miodrag Vallat. @@ -96,6 +96,8 @@ struct uvm_constraint_range *uvm_md_constraints[] = { NULL }; vm_map_t exec_map; vm_map_t phys_map; +extern uint8_t dt_blob_start[]; + struct boot_desc *octeon_boot_desc; struct boot_info *octeon_boot_info; @@ -396,7 +398,8 @@ mips_init(__register_t a0, __register_t a1, __register_t a2 __unused, memcpy(octeon_fdt, fdt, fdt_size); fdt_init(octeon_fdt); } - } + } else + fdt_init(dt_blob_start); /* * Get a console, very early but after initial mapping setup. -- 2.20.1