Skip to contentSkip to conversation

MIPS: add support for Microsemi MIPS SoCs

PATCH Superseded Alexandre Belloni 3 participants 10 messages Mar 2, 2018 – Mar 6, 2018

Subsystems (4)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
author maintainer
#3 lore raw

PATCH v4 3/6 MIPS: mscc: add ocelot dtsi

In reply to Alexandre Belloni

Add a device tree include file for the Microsemi Ocelot SoC.

---
 arch/mips/boot/dts/Makefile         |   1 +
 arch/mips/boot/dts/mscc/Makefile    |   1 +
 arch/mips/boot/dts/mscc/ocelot.dtsi | 110 ++++++++++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+)
 create mode 100644 arch/mips/boot/dts/mscc/Makefile
 create mode 100644 arch/mips/boot/dts/mscc/ocelot.dtsi
arch/mips/boot/dts/Makefile +1 -0
index e2c6f131c8eb..1e79cab8e269 100644
@@ -4,6 +4,7 @@ subdir-y	+= cavium-octeon
 subdir-y	+= img
 subdir-y	+= ingenic
 subdir-y	+= lantiq
+subdir-y	+= mscc
 subdir-y	+= mti
 subdir-y	+= netlogic
 subdir-y	+= ni
arch/mips/boot/dts/mscc/Makefile new file +1 -0
new file mode 100644
index 000000000000..dd08e63a10ba
@@ -0,0 +1 @@
+obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
arch/mips/boot/dts/mscc/ocelot.dtsi new file +110 -0

110 lines not on this page · raw message

Signature · 1 line
2.16.2
author maintainer
#4 lore raw

PATCH v4 4/6 MIPS: mscc: add ocelot PCB123 device tree

In reply to Alexandre Belloni

Add a device tree for the Microsemi Ocelot PCB123 evaluation board.

---
 arch/mips/boot/dts/mscc/Makefile          |  2 ++
 arch/mips/boot/dts/mscc/ocelot_pcb123.dts | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 arch/mips/boot/dts/mscc/ocelot_pcb123.dts
arch/mips/boot/dts/mscc/Makefile +2 -0
index dd08e63a10ba..c51164537c02 100644
@@ -1 +1,3 @@
+dtb-$(CONFIG_LEGACY_BOARD_OCELOT)	+= ocelot_pcb123.dtb
+
 obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
arch/mips/boot/dts/mscc/ocelot_pcb123.dts new file +27 -0
new file mode 100644
index 000000000000..42bd404471f6
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
+/* Copyright (c) 2017 Microsemi Corporation */
+
+/dts-v1/;
+
+#include "ocelot.dtsi"
+
+/ {
+	compatible = "mscc,ocelot-pcb123", "mscc,ocelot";
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x0 0x0e000000>;
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&uart2 {
+	status = "okay";
+};
Signature · 1 line
2.16.2
author maintainer
#2 lore raw

PATCH v4 2/6 dt-bindings: mips: Add bindings for Microsemi SoCs

In reply to Alexandre Belloni

Add bindings for Microsemi SoCs. Currently only Ocelot is supported.

---
 Documentation/devicetree/bindings/mips/mscc.txt | 44 +++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mips/mscc.txt
Documentation/devicetree/bindings/mips/mscc.txt new file +44 -0
new file mode 100644
index 000000000000..f4514c274510
@@ -0,0 +1,44 @@
+* Microsemi MIPS CPUs
+
+Boards with a SoC of the Microsemi MIPS family shall have the following
+properties:
+
+Required properties:
+- compatible: "mscc,ocelot"
+- mips-hpt-frequency: CPU counter frequency.
+
+
+* Other peripherals:
+
+o CPU chip regs:
+
+The SoC has a few registers (DEVCPU_GCB:CHIP_REGS) handling miscellaneous
+functionalities: chip ID, general purpose register for software use, reset
+controller, hardware status and configuration, efuses.
+
+Required properties:
+- compatible: Should be "mscc,ocelot-chip-regs", "simple-mfd", "syscon"
+- reg : Should contain registers location and length
+
+Example:
+	syscon@71070000 {
+		compatible = "mscc,ocelot-chip-regs", "simple-mfd", "syscon";
+		reg = <0x71070000 0x1c>;
+	};
+
+
+o CPU system control:
+
+The SoC has a few registers (ICPU_CFG:CPU_SYSTEM_CTRL) handling configuration of
+the CPU: 8 general purpose registers, reset control, CPU en/disabling, CPU
+endianness, CPU bus control, CPU status.
+
+Required properties:
+- compatible: Should be "mscc,ocelot-cpu-syscon", "syscon"
+- reg : Should contain registers location and length
+
+Example:
+	syscon@70000000 {
+		compatible = "mscc,ocelot-cpu-syscon", "syscon";
+		reg = <0x70000000 0x2c>;
+	};
Signature · 1 line
2.16.2
author maintainer
#1 lore raw

PATCH v4 1/6 dt-bindings: Add vendor prefix for Microsemi Corporation

In reply to Alexandre Belloni

Microsemi Corporation provides semiconductor and system solutions for aerospace & defense, communications, data center and industrial markets.

---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index ae850d6c0ad3..ffc959ef53e9 100644
@@ -224,6 +224,7 @@ motorola	Motorola, Inc.
 moxa	Moxa Inc.
 mpl	MPL AG
 mqmaker	mqmaker Inc.
+mscc	Microsemi Corporation
 msi	Micro-Star International Co. Ltd.
 mti	Imagination Technologies Ltd. (formerly MIPS Technologies Inc.)
 multi-inno	Multi-Inno Technology Co.,Ltd
Signature · 1 line
2.16.2

Alexandre Belloni

author maintainer
#0 lore raw

v4 cover MIPS: add support for Microsemi MIPS SoCs

Hi,

This patch series adds initial support for the Microsemi MIPS SoCs. It is currently focusing on the Microsemi Ocelot (VSC7513, VSC7514).

Changes in v4:
- dropped the reset driver as it has already been taken
- Updated the MAINTAINERS entry (new files, changed email address)
- moved to the MIPS generic infrastructure
- corrected the cpu compatible in ocelot.dtsi

Alexandre Belloni (6):
dt-bindings: Add vendor prefix for Microsemi Corporation
dt-bindings: mips: Add bindings for Microsemi SoCs
MIPS: mscc: add ocelot dtsi
MIPS: mscc: add ocelot PCB123 device tree
MIPS: generic: Add support for Microsemi Ocelot
MAINTAINERS: Add entry for Microsemi MIPS SoCs

 Documentation/devicetree/bindings/mips/mscc.txt    |  44 +++++++++
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 MAINTAINERS                                        |   9 ++
 arch/mips/Makefile                                 |   4 +
 arch/mips/boot/dts/Makefile                        |   1 +
 arch/mips/boot/dts/mscc/Makefile                   |   3 +
 arch/mips/boot/dts/mscc/ocelot.dtsi                | 110 +++++++++++++++++++++
 arch/mips/boot/dts/mscc/ocelot_pcb123.dts          |  27 +++++
 arch/mips/configs/generic/board-ocelot.config      |  40 ++++++++
 arch/mips/generic/Kconfig                          |  17 ++++
 arch/mips/generic/Makefile                         |   1 +
 arch/mips/generic/board-ocelot.c                   |  83 ++++++++++++++++
 12 files changed, 340 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mips/mscc.txt
 create mode 100644 arch/mips/boot/dts/mscc/Makefile
 create mode 100644 arch/mips/boot/dts/mscc/ocelot.dtsi
 create mode 100644 arch/mips/boot/dts/mscc/ocelot_pcb123.dts
 create mode 100644 arch/mips/configs/generic/board-ocelot.config
 create mode 100644 arch/mips/generic/board-ocelot.c
Signature · 1 line
2.16.2
author maintainer
#9 lore raw

PATCH v4 6/6 MAINTAINERS: Add entry for Microsemi MIPS SoCs

Add myself as a maintainer for the Microsemi MIPS SoCs.

---
 MAINTAINERS | 9 +++++++++
 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
index 3bdc260e36b7..14ce8b290fea 100644
@@ -9156,6 +9156,15 @@ S:	Maintained
 F:	drivers/usb/misc/usb251xb.c
 F:	Documentation/devicetree/bindings/usb/usb251xb.txt
 
+MICROSEMI MIPS SOCS
+M:	Alexandre Belloni <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	arch/mips/generic/board-ocelot.c
+F:	arch/mips/configs/generic/board-ocelot.config
+F:	arch/mips/boot/dts/mscc/
+F:	Documentation/devicetree/bindings/mips/mscc.txt
+
 MICROSEMI SMART ARRAY SMARTPQI DRIVER (smartpqi)
 M:	Don Brace <[email protected]>
 L:	[email protected]
Signature · 1 line
2.16.2
author maintainer
#6 lore raw

PATCH v4 5/6 MIPS: generic: Add support for Microsemi Ocelot

In reply to Alexandre Belloni

Introduce support for the MIPS based Microsemi Ocelot SoCs.

---
 arch/mips/Makefile                            |  4 ++
 arch/mips/configs/generic/board-ocelot.config | 40 +++++++++++++
 arch/mips/generic/Kconfig                     | 17 ++++++
 arch/mips/generic/Makefile                    |  1 +
 arch/mips/generic/board-ocelot.c              | 83 +++++++++++++++++++++++++++
 5 files changed, 145 insertions(+)
 create mode 100644 arch/mips/configs/generic/board-ocelot.config
 create mode 100644 arch/mips/generic/board-ocelot.c
arch/mips/Makefile +4 -0
index d1ca839c3981..d2882244cf1f 100644
@@ -543,6 +543,10 @@ generic_defconfig:
 # now that the boards have been converted to use the generic kernel they are
 # wrappers around the generic rules above.
 #
+.PHONY: ocelot_defconfig
+ocelot_defconfig:
+	$(Q)$(MAKE) -f $(srctree)/Makefile 32r2el_defconfig BOARDS=ocelot
+
 .PHONY: sead3_defconfig
 sead3_defconfig:
 	$(Q)$(MAKE) -f $(srctree)/Makefile 32r2el_defconfig BOARDS=sead-3
arch/mips/configs/generic/board-ocelot.config new file +40 -0
new file mode 100644
index 000000000000..7f9e1eaccc34
@@ -0,0 +1,40 @@
+# require CONFIG_32BIT=y
+
+CONFIG_LEGACY_BOARD_OCELOT=y
+
+CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER=y
+
+CONFIG_MTD=y
+CONFIG_MTD_CMDLINE_PARTS=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_M25P80=y
+CONFIG_MTD_NAND=y
+CONFIG_MTD_NAND_PLATFORM=y
+CONFIG_MTD_SPI_NOR=y
+CONFIG_MTD_UBI=y
+
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_RAM=y
+
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_OF_PLATFORM=y
+
+CONFIG_GPIO_SYSFS=y
+
+CONFIG_I2C=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_MUX=y
+
+CONFIG_SPI=y
+CONFIG_SPI_BITBANG=y
+CONFIG_SPI_DESIGNWARE=y
+CONFIG_SPI_SPIDEV=y
+
+CONFIG_POWER_RESET=y
+
+CONFIG_SQUASHFS=y
+CONFIG_SQUASHFS_XZ=y
+
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1
arch/mips/generic/Kconfig +17 -0
index 2ff3b17bfab1..04b8d2262f9d 100644
@@ -27,6 +27,23 @@ config LEGACY_BOARD_SEAD3
 	  Enable this to include support for booting on MIPS SEAD-3 FPGA-based
 	  development boards, which boot using a legacy boot protocol.
 
+comment "MSCC Ocelot doesn't work with SEAD3 enabled"
+       depends on LEGACY_BOARD_SEAD3
+
+config LEGACY_BOARD_OCELOT
+	bool "Support MSCC Ocelot boards"
+	depends on LEGACY_BOARD_SEAD3=n
+	select LEGACY_BOARDS
+	select MSCC_OCELOT
+
+config MSCC_OCELOT
+	bool
+	select DMA_NONCOHERENT
+	select GPIOLIB
+	select MSCC_OCELOT_IRQ
+	select SYS_HAS_EARLY_PRINTK
+	select USE_GENERIC_EARLY_PRINTK_8250
+
 comment "FIT/UHI Boards"
 
 config FIT_IMAGE_FDT_BOSTON
arch/mips/generic/Makefile +1 -0
index 5c31e0c4697d..d03a36f869a4 100644
@@ -14,5 +14,6 @@ obj-y += proc.o
 
 obj-$(CONFIG_YAMON_DT_SHIM)		+= yamon-dt.o
 obj-$(CONFIG_LEGACY_BOARD_SEAD3)	+= board-sead3.o
+obj-$(CONFIG_LEGACY_BOARD_OCELOT)	+= board-ocelot.o
 obj-$(CONFIG_KEXEC)			+= kexec.o
 obj-$(CONFIG_VIRT_BOARD_RANCHU)		+= board-ranchu.o
arch/mips/generic/board-ocelot.c new file +83 -0

83 lines not on this page · raw message

Signature · 1 line
2.16.2
#7 lore raw

Re: [PATCH v4 5/6] MIPS: generic: Add support for Microsemi Ocelot

Quoted 12 lines · Alexandre Belloni

Introduce support for the MIPS based Microsemi Ocelot SoCs.

---
 arch/mips/Makefile                            |  4 ++
 arch/mips/configs/generic/board-ocelot.config | 40 +++++++++++++
 arch/mips/generic/Kconfig                     | 17 ++++++
 arch/mips/generic/Makefile                    |  1 +
 arch/mips/generic/board-ocelot.c              | 83 +++++++++++++++++++++++++++
 5 files changed, 145 insertions(+)
 create mode 100644 arch/mips/configs/generic/board-ocelot.config
 create mode 100644 arch/mips/generic/board-ocelot.c

very nice :-)

arch/mips/configs/generic/board-ocelot.config line 1

Quoted 7 lines
arch/mips/configs/generic/board-ocelot.config new file +1 -0
new file mode 100644
index 000000000000..7f9e1eaccc34
@@ -0,0 +1,40 @@
+# require CONFIG_32BIT=y

If this has a 24KEc, does it make sense to use:

# require CONFIG_CPU_MIPS32_R2=y
like ni169445 and xilfpga do. There doesn't seem to be any point
enabling support in 32r6 generic kernels for example.

Similarly if the platform is little endian only, you could also add:

# require CONFIG_CPU_LITTLE_ENDIAN=y

arch/mips/configs/generic/board-ocelot.config line 5

Quoted 4 lines
arch/mips/configs/generic/board-ocelot.config new file +4 -0
+
+CONFIG_LEGACY_BOARD_OCELOT=y
+
+CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER=y

Hmm, can this break any other generic platforms that already make the DTB command line override the arcs_cmdline? Paul?

I.e. In arch_mem_init() the condition of copying arcs_cmdline to boot_command_line would switch from !boot_command_line[0] to arcs_cmdline[0]. I suppose arcs_cmdline[] may not have been written in those cases. If its safe then it should probably be a standard thing selected by MIPS_GENERIC instead of a board specific thing.

arch/mips/configs/generic/board-ocelot.config line 39

Quoted 1 line
arch/mips/configs/generic/board-ocelot.config new file +1 -0
+CONFIG_MAGIC_SYSRQ=y

Perhaps its worth adding this to the base generic_defconfig if its useful to have.

arch/mips/configs/generic/board-ocelot.config line 40

Quoted 1 line
arch/mips/configs/generic/board-ocelot.config new file +1 -0
+CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1

That is already the default, though I wonder if we should set it to 0 for safety, which still retains the functionality, but just may require writing to /proc/sys/kernel/sysrq or passing sysrq_always_enabled as a kernel parameter to use sysrq from keyboard / uart.

arch/mips/generic/Kconfig config LEGACY_BOARD_SEAD3 · line 31

Quoted 10 lines
arch/mips/generic/Kconfig +2 -0
index 2ff3b17bfab1..04b8d2262f9d 100644
@@ -27,6 +27,23 @@ config LEGACY_BOARD_SEAD3
 	  Enable this to include support for booting on MIPS SEAD-3 FPGA-based
 	  development boards, which boot using a legacy boot protocol.
 
+comment "MSCC Ocelot doesn't work with SEAD3 enabled"
+       depends on LEGACY_BOARD_SEAD3

broken indentation. Tab please.

arch/mips/generic/Kconfig config LEGACY_BOARD_SEAD3 · line 41

Quoted 10 lines
arch/mips/generic/Kconfig +10 -0
+
+config LEGACY_BOARD_OCELOT
+	bool "Support MSCC Ocelot boards"
+	depends on LEGACY_BOARD_SEAD3=n
+	select LEGACY_BOARDS
+	select MSCC_OCELOT
+
+config MSCC_OCELOT
+	bool
+	select DMA_NONCOHERENT

MIPS_GENERIC already selects DMA_PERFDEV_COHERENT, which should already treat devices as non-coherent unless they have the dma-coherent DT property.

Quoted 36 lines
arch/mips/generic/Kconfig +5 -0
+	select GPIOLIB
+	select MSCC_OCELOT_IRQ
+	select SYS_HAS_EARLY_PRINTK
+	select USE_GENERIC_EARLY_PRINTK_8250
+
 comment "FIT/UHI Boards"
 
 config FIT_IMAGE_FDT_BOSTON
arch/mips/generic/Makefile +1 -0
index 5c31e0c4697d..d03a36f869a4 100644
@@ -14,5 +14,6 @@ obj-y += proc.o
 
 obj-$(CONFIG_YAMON_DT_SHIM)		+= yamon-dt.o
 obj-$(CONFIG_LEGACY_BOARD_SEAD3)	+= board-sead3.o
+obj-$(CONFIG_LEGACY_BOARD_OCELOT)	+= board-ocelot.o
 obj-$(CONFIG_KEXEC)			+= kexec.o
 obj-$(CONFIG_VIRT_BOARD_RANCHU)		+= board-ranchu.o
arch/mips/generic/board-ocelot.c new file +11 -0
new file mode 100644
index 000000000000..752c6edbe1d5
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Microsemi MIPS SoC support
+ *
+ * Copyright (c) 2017 Microsemi Corporation
+ */
+#include <asm/machine.h>
+#include <asm/prom.h>
+
+#define DEVCPU_GCB_CHIP_REGS_CHIP_ID	0x71070000
+#define CHIP_ID_PART_ID			GENMASK(27, 12)

arch/mips/generic/board-ocelot.c line 21

Quoted 10 lines
arch/mips/generic/board-ocelot.c new file +10 -0
+
+#define OCELOT_PART_ID			(0x7514 << 12)
+
+#define UART_UART			0x70100000
+
+static __init bool ocelot_detect(void)
+{
+	u32 rev;
+
+	rev = __raw_readl((void *)DEVCPU_GCB_CHIP_REGS_CHIP_ID);

Isn't that an address in the user segment, i.e. TLB mapped virtual memory? Does the bootloader set up a wired mapping for it or something?

The address looks similar to UART_UART which is given to ioremap so must be a physical address. Perhaps the mapping you're using is 1:1 virtual:physical address?

If its using a TLB mapping, then:
1) That isn't safe this early to run on other platforms, as it'll give a TLB refill exception. It should be quite possible to detect such a mapping to make it safer though.
2) If yamon initialises the TLB to a known state, then that may well be a hacky but workable way to distinguish yamon (sead3) from redboot (mscc) in future.

Quoted 21 lines
arch/mips/generic/board-ocelot.c new file +21 -0
+
+	if ((rev & CHIP_ID_PART_ID) != OCELOT_PART_ID)
+		return 0;
+
+	/* Copy command line from bootloader early for Initrd detection */
+	if (fw_arg0 < 10 && (fw_arg1 & 0xFFF00000) == 0x80000000) {
+		unsigned int prom_argc = fw_arg0;
+		const char **prom_argv = (const char **)fw_arg1;
+
+		if (prom_argc > 1 && strlen(prom_argv[1]) > 0)
+			/* ignore all built-in args if any f/w args given */
+			strcpy(arcs_cmdline, prom_argv[1]);
+	}
+
+	return 1;
+}
+
+static __init unsigned int ocelot_measure_hpt_freq(void)
+{
+	struct device_node *np;
+	u32 freq;

arch/mips/generic/board-ocelot.c line 52

Quoted 10 lines
arch/mips/generic/board-ocelot.c new file +10 -0
+
+	np = of_find_node_by_name(NULL, "cpus");
+	if (!np)
+		panic("missing 'cpus' DT node");
+	if (of_property_read_u32(np, "mips-hpt-frequency", &freq) < 0)
+		panic("missing 'mips-hpt-frequency' property");
+	of_node_put(np);
+
+	return freq;
+}

Is it too late to change this to use the generic mips_hpt_frequency calculation in plat_time_init()? The DT would have to provide e.g. a fixed-clock and link to it from the CPU node.

See arch/mips/boot/dts/ni/169445.dts for an example of how it could look.

That would allow you to eliminate this machine callback altogether, as well as being more flexible if you ever needed the frequency to be calculated more dynamically based on platform registers.

Thanks!
James

#5 lore raw

Re: [PATCH v4 4/6] MIPS: mscc: add ocelot PCB123 device tree

In reply to Alexandre Belloni

Hello!

Quoted 5 lines · Alexandre Belloni

Add a device tree for the Microsemi Ocelot PCB123 evaluation board.

[...]

Quoted 11 lines
arch/mips/boot/dts/mscc/ocelot_pcb123.dts new file +5 -0
new file mode 100644
index 000000000000..42bd404471f6
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
+/* Copyright (c) 2017 Microsemi Corporation */
+
+/dts-v1/;
+

arch/mips/boot/dts/mscc/ocelot_pcb123.dts line 15

Quoted 10 lines
arch/mips/boot/dts/mscc/ocelot_pcb123.dts new file +10 -0
+#include "ocelot.dtsi"
+
+/ {
+	compatible = "mscc,ocelot-pcb123", "mscc,ocelot";
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	memory {

Needs to be "memory@0" as you have the "regs" prop.

arch/mips/boot/dts/mscc/ocelot_pcb123.dts line 19

Quoted 4 lines
arch/mips/boot/dts/mscc/ocelot_pcb123.dts new file +4 -0
+		device_type = "memory";
+		reg = <0x0 0x0e000000>;
+	};
+};

[...]

MBR, Sergei

author maintainer
#8 lore raw

Re: [PATCH v4 5/6] MIPS: generic: Add support for Microsemi Ocelot

In reply to James Hogan
Quoted 3 lines · James Hogan

Similarly if the platform is little endian only, you could also add:

# require CONFIG_CPU_LITTLE_ENDIAN=y

It supports big endian.

Quoted 8 lines

arch/mips/configs/generic/board-ocelot.config line 5

Quoted 4 lines
arch/mips/configs/generic/board-ocelot.config new file +4 -0
+
+CONFIG_LEGACY_BOARD_OCELOT=y
+
+CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER=y

Hmm, can this break any other generic platforms that already make the DTB command line override the arcs_cmdline? Paul?

Quoted 6 lines

I.e. In arch_mem_init() the condition of copying arcs_cmdline to boot_command_line would switch from !boot_command_line[0] to arcs_cmdline[0]. I suppose arcs_cmdline[] may not have been written in those cases. If its safe then it should probably be a standard thing selected by MIPS_GENERIC instead of a board specific thing.

Actually, this is not needed so I'm removing it.

Quoted 5 lines
Quoted 1 line

+CONFIG_MAGIC_SYSRQ=y

Perhaps its worth adding this to the base generic_defconfig if its useful to have.

Our test automation tool is using it to reboot the platform but I don't know if this is useful for anybody else.

Quoted 13 lines

arch/mips/generic/board-ocelot.c line 21

Quoted 5 lines
arch/mips/generic/board-ocelot.c new file +5 -0
+static __init bool ocelot_detect(void)
+{
+	u32 rev;
+
+	rev = __raw_readl((void *)DEVCPU_GCB_CHIP_REGS_CHIP_ID);

Isn't that an address in the user segment, i.e. TLB mapped virtual memory? Does the bootloader set up a wired mapping for it or something?

The address looks similar to UART_UART which is given to ioremap so must be a physical address. Perhaps the mapping you're using is 1:1 virtual:physical address?

Quoted 8 lines

If its using a TLB mapping, then:
1) That isn't safe this early to run on other platforms, as it'll give a TLB refill exception. It should be quite possible to detect such a mapping to make it safer though.
2) If yamon initialises the TLB to a known state, then that may well be a hacky but workable way to distinguish yamon (sead3) from redboot (mscc) in future.

Yes, this is an identity mapping that is installed by redboot because all the peripherals are in the user segment.

Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com