Skip to contentSkip to conversation

mips: octeon: Add bootoctlinux command for Octeon Linux kernel booting

PATCH New Stefan Roese 2 participants 12 messages Aug 20, 2020 – Sep 19, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover mips: octeon: Add bootoctlinux command for Octeon Linux kernel booting

This patchset adds the platforms specific bootoctlinux command, which is used to boot the MIPS Octeon Linux kernel (4.9.x). A special command is necessary here, as very platform specific data is passed to the kernel via the bootinfo / bootmem format. This patchset also includes various required infrastructure code for this (octeon-feature, coremask, bootinfo). The code for booting the additional cores is also included in this patchset.

Tested on Octeon 7304 EBB with all 16 cores.

Thanks,
Stefan

Aaron Williams (7):
mips: octeon: Add header cvmx-regs.h
mips: octeon: Add header octeon-feature.h
mips: octeon: Add header cvmx-fuse.h
mips: octeon: Add header cvmx-bootinfo.h
mips: octeon: Add coremask support
mips: octeon: Add bootmem support
mips: octeon: Add bootoctlinux command

Stefan Roese (3):
mips: octeon: octeon-model.h: Enable inclusion from assembler files
mips: octeon: lowlevel_init.S: Add NMI handling code for SMP Linux
booting
mips: octeon: octeon_common.h: Increase CONFIG_SYS_BOOTM_LEN

 arch/mips/mach-octeon/Makefile                |    3 +
 arch/mips/mach-octeon/bootoctlinux.c          |  661 ++++++++
 arch/mips/mach-octeon/cvmx-bootmem.c          | 1460 +++++++++++++++++
 arch/mips/mach-octeon/cvmx-coremask.c         |  366 +++++
 .../mach-octeon/include/mach/bootoct_cmd.h    |   54 +
 .../mach-octeon/include/mach/cvmx-bootinfo.h  |  350 ++++
 .../mach-octeon/include/mach/cvmx-bootmem.h   |  533 ++++++
 .../mach-octeon/include/mach/cvmx-coremask.h  |  752 +++++++++
 .../mips/mach-octeon/include/mach/cvmx-fuse.h |   71 +
 .../mips/mach-octeon/include/mach/cvmx-regs.h |  144 ++
 .../mach-octeon/include/mach/octeon-feature.h |  442 +++++
 .../mach-octeon/include/mach/octeon-model.h   |    4 +
 arch/mips/mach-octeon/lowlevel_init.S         |   76 +
 include/configs/octeon_common.h               |    2 +
 14 files changed, 4918 insertions(+)
 create mode 100644 arch/mips/mach-octeon/bootoctlinux.c
 create mode 100644 arch/mips/mach-octeon/cvmx-bootmem.c
 create mode 100644 arch/mips/mach-octeon/cvmx-coremask.c
 create mode 100644 arch/mips/mach-octeon/include/mach/bootoct_cmd.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-bootinfo.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-bootmem.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-coremask.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-fuse.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-regs.h
 create mode 100644 arch/mips/mach-octeon/include/mach/octeon-feature.h
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/10 mips: octeon: octeon-model.h: Enable inclusion from assembler files

Add the #ifdef __ASSEMBLY__ checks to enable inclusion of this header from assembler files.

---

 arch/mips/mach-octeon/include/mach/octeon-model.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/mips/mach-octeon/include/mach/octeon-model.h +4 -0
index 209e813a2f..c842f894bf 100644
@@ -266,6 +266,8 @@
 		  )));							\
 	})
 
+#ifndef __ASSEMBLY__
+
 #ifndef OCTEON_IS_MODEL
 
 static inline int __octeon_is_model_runtime_internal__(u32 model)
@@ -314,4 +316,6 @@ static inline u32 cvmx_get_octeon_family(void)
 	return (read_c0_prid() & OCTEON_FAMILY_MASK);
 }
 
+#endif /* __ASSEMBLY__ */
+
 #endif /* __OCTEON_MODEL_H__ */
Signature · 1 line
2.28.0
#2 lore raw

PATCH 2/10 mips: octeon: lowlevel_init.S: Add NMI handling code for SMP Linux booting

In reply to Stefan Roese

This patch adds the necessary lowlevel init code, to enable SMP Linux booting. This code will be used with the platform specific Octeon Linux boot command "bootoctlinux", which starts a configurable number of cores into Linux.

Additionally some erratas and lowlevel register initializations are copied from the original Cavium / Marvell U-Boot source code, enabling booting into the Linux kernel.

---

 arch/mips/mach-octeon/lowlevel_init.S | 76 +++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
arch/mips/mach-octeon/lowlevel_init.S +76 -0
index fa87cb4e34..56d1d2261e 100644
@@ -10,10 +10,36 @@
 #include <asm/mipsregs.h>
 #include <asm/addrspace.h>
 #include <asm/asm.h>
+#include <mach/octeon-model.h>
+
+#define COP0_CVMCTL_REG		$9,7	/* Cavium control */
+#define COP0_CVMMEMCTL_REG	$11,7	/* Cavium memory control */
+#define COP0_PROC_ID_REG	$15,0
 
 	.set noreorder
 
 LEAF(lowlevel_init)
+
+	/* Set LMEMSZ in CVMMEMCTL register */
+	dmfc0	a0, COP0_CVMMEMCTL_REG
+	dins	a0, zero, 0, 9
+	mfc0	a4, COP0_PROC_ID_REG
+	li	a5, OCTEON_CN63XX_PASS1_0 /* Octeon cn63xx pass1 chip id */
+	bgt	a5, a4, 2f
+	 ori	 a0, 0x104	/* setup 4 lines of scratch */
+	ori	a6, a5, 8	/* Octeon cn63xx pass2 chip id */
+	bge	a4, a6, 2f
+	 nop
+	li	a6, 4
+	ins	a0, a6, 11, 4	/* Set WBTHRESH=4 as per Core-14752 errata */
+2:
+	dmtc0	a0, COP0_CVMMEMCTL_REG
+
+	/* Set REPUN bit in CVMCTL register */
+	dmfc0	a0, COP0_CVMCTL_REG
+	ori	a0, 1<<14	/* enable fixup of unaligned mem access */
+	dmtc0	a0, COP0_CVMCTL_REG
+
 	jr	ra
 	 nop
 	END(lowlevel_init)
@@ -67,3 +93,53 @@ __dummy:
 	 nop
 
 	END(mips_mach_early_init)
+
+LEAF(nmi_bootvector)
+
+	/*
+	 * From Marvell original bootvector setup
+	 */
+	mfc0	k0, CP0_STATUS
+	/* Enable 64-bit addressing, set ERL (should already be set) */
+	ori	k0, 0x84
+	mtc0	k0, CP0_STATUS
+	/* Core-14345, clear L1 Dcache virtual tags if the core hit an NMI */
+	cache	17, 0($0)
+
+	/*
+	 * Needed for Linux kernel booting, otherwise it hangs while
+	 * zero'ing all of CVMSEG
+	 */
+	dmfc0	a0, COP0_CVMMEMCTL_REG
+	dins	a0, zero, 0, 9
+	ori	a0, 0x104	/* setup 4 lines of scratch */
+	dmtc0	a0, COP0_CVMMEMCTL_REG
+
+	/*
+	 * Load parameters and entry point
+	 */
+	PTR_LA	t9, nmi_handler_para
+	sync
+
+	ld	s0, 0x00(t9)
+	ld	a0, 0x08(t9)
+	ld	a1, 0x10(t9)
+	ld	a2, 0x18(t9)
+	ld	a3, 0x20(t9)
+
+	/* Finally jump to entry point (start kernel etc) */
+	j	s0
+	 nop
+
+	END(nmi_bootvector)
+
+	/*
+	 * Add here some space for the NMI parameters (entry point and args)
+	 */
+	.globl nmi_handler_para
+nmi_handler_para:
+	.dword	0	// entry-point
+	.dword	0	// arg0
+	.dword	0	// arg1
+	.dword	0	// arg2
+	.dword	0	// arg3
Signature · 1 line
2.28.0
#3 lore raw

PATCH 3/10 mips: octeon: Add header cvmx-regs.h

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

This header includes common register defines and accessor functions.

---

 .../mips/mach-octeon/include/mach/cvmx-regs.h | 144 ++++++++++++++++++
 1 file changed, 144 insertions(+)
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-regs.h
arch/mips/mach-octeon/include/mach/cvmx-regs.h new file +144 -0
new file mode 100644
index 0000000000..b84fc9fd57
@@ -0,0 +1,144 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2020 Stefan Roese <[email protected]>
+ */
+
+#ifndef __CVMX_REGS_H__
+#define __CVMX_REGS_H__
+
+#include <linux/bitfield.h>
+#include <linux/bitops.h>
+#include <linux/io.h>
+
+/* General defines */
+#define CVMX_MAX_CORES		48
+/* Maximum # of bits to define core in node */
+#define CVMX_NODE_NO_SHIFT	7
+#define CVMX_NODE_BITS		2	/* Number of bits to define a node */
+#define CVMX_MAX_NODES		(1 << CVMX_NODE_BITS)
+#define CVMX_NODE_MASK		(CVMX_MAX_NODES - 1)
+#define CVMX_NODE_IO_SHIFT	36
+#define CVMX_NODE_MEM_SHIFT	40
+#define CVMX_NODE_IO_MASK	((u64)CVMX_NODE_MASK << CVMX_NODE_IO_SHIFT)
+
+#define CVMX_MIPS_MAX_CORE_BITS	10	/* Maximum # of bits to define cores */
+#define CVMX_MIPS_MAX_CORES	(1 << CVMX_MIPS_MAX_CORE_BITS)
+
+#define MAX_CORE_TADS		8
+
+#define CAST_ULL(v)		((unsigned long long)(v))
+#define CASTPTR(type, v)	((type *)(long)(v))
+
+/* Regs */
+#define CVMX_CIU_PP_RST		0x0001010000000100ULL
+#define CVMX_CIU3_NMI		0x0001010000000160ULL
+#define CVMX_CIU_FUSE		0x00010100000001a0ULL
+#define CVMX_CIU_NMI		0x0001070000000718ULL
+
+#define CVMX_MIO_BOOT_LOC_CFGX(x) (0x0001180000000080ULL + ((x) & 1) * 8)
+#define MIO_BOOT_LOC_CFG_BASE		GENMASK_ULL(27, 3)
+#define MIO_BOOT_LOC_CFG_EN		BIT_ULL(31)
+
+#define CVMX_MIO_BOOT_LOC_ADR	0x0001180000000090ULL
+#define MIO_BOOT_LOC_ADR_ADR		GENMASK_ULL(7, 3)
+
+#define CVMX_MIO_BOOT_LOC_DAT	0x0001180000000098ULL
+
+#define CVMX_MIO_FUS_DAT2	0x0001180000001410ULL
+#define MIO_FUS_DAT2_NOCRYPTO		BIT_ULL(26)
+#define MIO_FUS_DAT2_NOMUL		BIT_ULL(27)
+#define MIO_FUS_DAT2_DORM_CRYPTO	BIT_ULL(34)
+
+#define CVMX_MIO_FUS_RCMD	0x0001180000001500ULL
+#define MIO_FUS_RCMD_ADDR		GENMASK_ULL(7, 0)
+#define MIO_FUS_RCMD_PEND		BIT_ULL(12)
+#define MIO_FUS_RCMD_DAT		GENMASK_ULL(23, 16)
+
+#define CVMX_RNM_CTL_STATUS	0x0001180040000000ULL
+#define RNM_CTL_STATUS_EER_VAL		BIT_ULL(9)
+
+/* turn the variable name into a string */
+#define CVMX_TMP_STR(x)		CVMX_TMP_STR2(x)
+#define CVMX_TMP_STR2(x)	#x
+
+#define CVMX_RDHWRNV(result, regstr)					\
+	asm volatile ("rdhwr %[rt],$" CVMX_TMP_STR(regstr) : [rt] "=d" (result))
+
+#define CVMX_SYNCW					\
+	asm volatile ("syncw\nsyncw\n" : : : "memory")
+
+/* ToDo: Currently only node = 0 supported */
+static inline u64 csr_rd_node(int node, u64 addr)
+{
+	void __iomem *base;
+
+	base = ioremap_nocache(addr, 0x100);
+	return ioread64(base);
+}
+
+static inline u64 csr_rd(u64 addr)
+{
+	return csr_rd_node(0, addr);
+}
+
+static inline void csr_wr_node(int node, u64 addr, u64 val)
+{
+	void __iomem *base;
+
+	base = ioremap_nocache(addr, 0x100);
+	iowrite64(val, base);
+}
+
+static inline void csr_wr(u64 addr, u64 val)
+{
+	csr_wr_node(0, addr, val);
+}
+
+/*
+ * We need to use the volatile access here, otherwise the IO accessor
+ * functions might swap the bytes
+ */
+static inline u64 cvmx_read64_uint64(u64 addr)
+{
+	return *(volatile u64 *)addr;
+}
+
+static inline void cvmx_write64_uint64(u64 addr, u64 val)
+{
+	*(volatile u64 *)addr = val;
+}
+
+static inline u32 cvmx_read64_uint32(u64 addr)
+{
+	return *(volatile u32 *)addr;
+}
+
+static inline void cvmx_write64_uint32(u64 addr, u32 val)
+{
+	*(volatile u32 *)addr = val;
+}
+
+static inline void *cvmx_phys_to_ptr(u64 addr)
+{
+	return (void *)CKSEG0ADDR(addr);
+}
+
+static inline u64 cvmx_ptr_to_phys(void *ptr)
+{
+	return virt_to_phys(ptr);
+}
+
+/**
+ * Number of the Core on which the program is currently running.
+ *
+ * @return core number
+ */
+static inline unsigned int cvmx_get_core_num(void)
+{
+	unsigned int core_num;
+
+	CVMX_RDHWRNV(core_num, 0);
+	return core_num;
+}
+
+#endif /* __CVMX_REGS_H__ */
Signature · 1 line
2.28.0
#4 lore raw

PATCH 4/10 mips: octeon: Add header octeon-feature.h

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

This header includes the Octeon feature detection used in many Octeon drivers.

---

 .../mach-octeon/include/mach/octeon-feature.h | 442 ++++++++++++++++++
 1 file changed, 442 insertions(+)
 create mode 100644 arch/mips/mach-octeon/include/mach/octeon-feature.h
arch/mips/mach-octeon/include/mach/octeon-feature.h new file +442 -0
new file mode 100644
index 0000000000..1202716ba5
@@ -0,0 +1,442 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 Marvell International Ltd.
+ */
+
+#ifndef __OCTEON_FEATURE_H__
+#define __OCTEON_FEATURE_H__
+
+/*
+ * Octeon models are declared after the macros in octeon-model.h with the
+ * suffix _FEATURE. The individual features are declared with the
+ * _FEATURE_ infix.
+ */
+enum octeon_feature {
+	/*
+	 * Checks on the critical path are moved to the top (8 positions)
+	 * so that the compiler generates one less insn than for the rest
+	 * of the checks.
+	 */
+	OCTEON_FEATURE_PKND, /* CN68XX uses port kinds for packet interface */
+	/* CN68XX has different fields in word0 - word2 */
+	OCTEON_FEATURE_CN68XX_WQE,
+
+	/*
+	 * Features
+	 */
+	/*
+	 * Octeon models in the CN5XXX family and higher support atomic
+	 * add instructions to memory (saa/saad)
+	 */
+	OCTEON_FEATURE_SAAD,
+	/* Does this Octeon support the ZIP offload engine? */
+	OCTEON_FEATURE_ZIP,
+	/* Does this Octeon support crypto acceleration using COP2? */
+	OCTEON_FEATURE_CRYPTO,
+	/* Can crypto be enabled by calling cvmx_crypto_dormant_enable()? */
+	OCTEON_FEATURE_DORM_CRYPTO,
+	OCTEON_FEATURE_PCIE,	/* Does this Octeon support PCI express? */
+	OCTEON_FEATURE_SRIO,	/* Does this Octeon support SRIO */
+	OCTEON_FEATURE_ILK,	/* Does this Octeon support Interlaken */
+	/*
+	 * Some Octeon models support internal memory for storing
+	 * cryptographic keys
+	 */
+	OCTEON_FEATURE_KEY_MEMORY,
+	/* Octeon has a LED controller for banks of external LEDs */
+	OCTEON_FEATURE_LED_CONTROLLER,
+	OCTEON_FEATURE_TRA,	/* Octeon has a trace buffer */
+	OCTEON_FEATURE_MGMT_PORT, /* Octeon has a management port */
+	OCTEON_FEATURE_RAID,	/* Octeon has a raid unit */
+	OCTEON_FEATURE_USB,	/* Octeon has a builtin USB */
+	/* Octeon IPD can run without using work queue entries */
+	OCTEON_FEATURE_NO_WPTR,
+	OCTEON_FEATURE_DFA,	/* Octeon has DFA state machines */
+	/*
+	 * Octeon MDIO block supports clause 45 transactions for
+	 * 10 Gig support
+	 */
+	OCTEON_FEATURE_MDIO_CLAUSE_45,
+	/*
+	 * CN52XX and CN56XX used a block named NPEI for PCIe access.
+	 * Newer chips replaced this with SLI+DPI
+	 */
+	OCTEON_FEATURE_NPEI,
+	OCTEON_FEATURE_HFA,	/* Octeon has DFA/HFA */
+	OCTEON_FEATURE_DFM,	/* Octeon has DFM */
+	OCTEON_FEATURE_CIU2,	/* Octeon has CIU2 */
+	/* Octeon has DMA Instruction Completion Interrupt mode */
+	OCTEON_FEATURE_DICI_MODE,
+	/* Octeon has Bit Select Extractor schedulor */
+	OCTEON_FEATURE_BIT_EXTRACTOR,
+	OCTEON_FEATURE_NAND,	/* Octeon has NAND */
+	OCTEON_FEATURE_MMC,	/* Octeon has built-in MMC support */
+	OCTEON_FEATURE_ROM,	/* Octeon has built-in ROM support */
+	OCTEON_FEATURE_AUTHENTIK, /* Octeon has Authentik ROM support */
+	OCTEON_FEATURE_MULTICAST_TIMER, /* Octeon has multi_cast timer */
+	OCTEON_FEATURE_MULTINODE, /* Octeon has node support */
+	OCTEON_FEATURE_CIU3,	/* Octeon has CIU3 */
+	OCTEON_FEATURE_FPA3,	/* Octeon has FPA first seen on 78XX */
+	/* CN78XX has different fields in word0 - word2 */
+	OCTEON_FEATURE_CN78XX_WQE,
+	OCTEON_FEATURE_PKO3,	/* Octeon has enhanced PKO block */
+	OCTEON_FEATURE_SPI,	/* Octeon supports SPI interfaces */
+	OCTEON_FEATURE_ZIP3,	/* Octeon has zip first seen on 78XX */
+	OCTEON_FEATURE_BCH,	/* Octeon supports BCH ECC */
+	OCTEON_FEATURE_PKI,	/* Octeon has PKI block */
+	OCTEON_FEATURE_OCLA,	/* Octeon has OCLA */
+	OCTEON_FEATURE_FAU,	/* Octeon has FAU */
+	OCTEON_FEATURE_BGX,	/* Octeon has BGX */
+	OCTEON_FEATURE_BGX_MIX,	/* On of the BGX is used for MIX */
+	OCTEON_FEATURE_HNA,	/* Octeon has HNA */
+	OCTEON_FEATURE_BGX_XCV,	/* Octeon has BGX XCV RGMII support */
+	OCTEON_FEATURE_TSO,	/* Octeon has tcp segmentation offload */
+	OCTEON_FEATURE_TDM,	/* Octeon has PCM/TDM support */
+	OCTEON_FEATURE_PTP,	/* Octeon has PTP support */
+	OCTEON_MAX_FEATURE
+};
+
+static inline int octeon_has_feature_OCTEON_FEATURE_SAAD(void)
+{
+	return true;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_ZIP(void)
+{
+	if (OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
+	    OCTEON_IS_MODEL(OCTEON_CN70XX) || OCTEON_IS_MODEL(OCTEON_CNF75XX))
+		return 0;
+	else
+		return !cvmx_fuse_read(121);
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_ZIP3(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN73XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_BCH(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN70XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN73XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_CRYPTO(void)
+{
+	/* OCTEON II and later */
+	u64 val;
+
+	val = csr_rd(CVMX_MIO_FUS_DAT2);
+	if (val & MIO_FUS_DAT2_NOCRYPTO || val & MIO_FUS_DAT2_NOMUL)
+		return 0;
+	else if (!(val & MIO_FUS_DAT2_DORM_CRYPTO))
+		return 1;
+
+	val = csr_rd(CVMX_RNM_CTL_STATUS);
+	return val & RNM_CTL_STATUS_EER_VAL;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_DORM_CRYPTO(void)
+{
+	/* OCTEON II and later */
+	u64 val;
+
+	val = csr_rd(CVMX_MIO_FUS_DAT2);
+	return !(val & MIO_FUS_DAT2_NOCRYPTO) && !(val & MIO_FUS_DAT2_NOMUL) &&
+		(val & MIO_FUS_DAT2_DORM_CRYPTO);
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_PCIE(void)
+{
+	/* OCTEON II and later have PCIe */
+	return true;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_SRIO(void)
+{
+	if (OCTEON_IS_MODEL(OCTEON_CNF75XX)) {
+		if (cvmx_fuse_read(1601) == 0)
+			return 0;
+		else
+			return 1;
+	} else {
+		return (OCTEON_IS_MODEL(OCTEON_CN63XX) ||
+			OCTEON_IS_MODEL(OCTEON_CN66XX));
+	}
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_ILK(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN68XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN78XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_KEY_MEMORY(void)
+{
+	/* OCTEON II or later */
+	return true;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_LED_CONTROLLER(void)
+{
+	return false;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_TRA(void)
+{
+	return !OCTEON_IS_OCTEON3();
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_MGMT_PORT(void)
+{
+	/* OCTEON II or later */
+	return true;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_RAID(void)
+{
+	return !OCTEON_IS_MODEL(OCTEON_CNF75XX);
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_USB(void)
+{
+	return true;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_NO_WPTR(void)
+{
+	return true;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_DFA(void)
+{
+	return 0;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_HFA(void)
+{
+	if (OCTEON_IS_MODEL(OCTEON_CNF75XX))
+		return 0;
+	else
+		return !cvmx_fuse_read(90);
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_HNA(void)
+{
+	if (OCTEON_IS_MODEL(OCTEON_CN78XX) || OCTEON_IS_MODEL(OCTEON_CN73XX))
+		return !cvmx_fuse_read(134);
+	else
+		return 0;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_DFM(void)
+{
+	if (!(OCTEON_IS_MODEL(OCTEON_CN63XX) || OCTEON_IS_MODEL(OCTEON_CN66XX)))
+		return 0;
+	else
+		return !cvmx_fuse_read(90);
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_MDIO_CLAUSE_45(void)
+{
+	return true;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_NPEI(void)
+{
+	return false;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_PKND(void)
+{
+	return OCTEON_IS_MODEL(OCTEON_CN68XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN73XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN78XX);
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_CN68XX_WQE(void)
+{
+	return OCTEON_IS_MODEL(OCTEON_CN68XX);
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_CIU2(void)
+{
+	return OCTEON_IS_MODEL(OCTEON_CN68XX);
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_CIU3(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN73XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_FPA3(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN73XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_NAND(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN63XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN66XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN68XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN73XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN70XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_DICI_MODE(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN68XX_PASS2_X) ||
+		OCTEON_IS_MODEL(OCTEON_CN61XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN70XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_BIT_EXTRACTOR(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN68XX_PASS2_X) ||
+		OCTEON_IS_MODEL(OCTEON_CN61XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN70XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_MMC(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN61XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF71XX) || OCTEON_IS_OCTEON3());
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_ROM(void)
+{
+	return OCTEON_IS_MODEL(OCTEON_CN66XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN61XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF71XX);
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_AUTHENTIK(void)
+{
+	if (OCTEON_IS_MODEL(OCTEON_CN66XX) ||
+	    OCTEON_IS_MODEL(OCTEON_CN61XX) ||
+	    OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
+	    OCTEON_IS_MODEL(OCTEON_CN70XX)) {
+		u64 val;
+
+		val = csr_rd(CVMX_MIO_FUS_DAT2);
+		return (val & MIO_FUS_DAT2_NOCRYPTO) &&
+			(val & MIO_FUS_DAT2_DORM_CRYPTO);
+	}
+
+	return 0;
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_MULTICAST_TIMER(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN66XX_PASS1_2) ||
+		OCTEON_IS_MODEL(OCTEON_CN61XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN70XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_MULTINODE(void)
+{
+	return (!OCTEON_IS_MODEL(OCTEON_CN76XX) &&
+		OCTEON_IS_MODEL(OCTEON_CN78XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_CN78XX_WQE(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN73XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_SPI(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN66XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN61XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF71XX) || OCTEON_IS_OCTEON3());
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_PKI(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN73XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_PKO3(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN73XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_OCLA(void)
+{
+	return OCTEON_IS_OCTEON3();
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_FAU(void)
+{
+	return (!OCTEON_IS_MODEL(OCTEON_CN78XX) &&
+		!OCTEON_IS_MODEL(OCTEON_CNF75XX) &&
+		!OCTEON_IS_MODEL(OCTEON_CN73XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_BGX(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN73XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_BGX_MIX(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN73XX));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_BGX_XCV(void)
+{
+	return OCTEON_IS_MODEL(OCTEON_CN73XX);
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_TSO(void)
+{
+	return (OCTEON_IS_MODEL(OCTEON_CN73XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN78XX_PASS2_X));
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_TDM(void)
+{
+	return OCTEON_IS_MODEL(OCTEON_CN61XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN70XX);
+}
+
+static inline int octeon_has_feature_OCTEON_FEATURE_PTP(void)
+{
+	return OCTEON_IS_MODEL(OCTEON_CN6XXX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF7XXX) ||
+		OCTEON_IS_MODEL(OCTEON_CN73XX) ||
+		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
+		OCTEON_IS_MODEL(OCTEON_CN78XX_PASS2_X);
+}
+
+/*
+ * Answer ``Is the bit for feature set in the bitmap?''
+ * @param feature
+ * @return 1 when the feature is present and 0 otherwise, -1 in case of error.
+ */
+#define octeon_has_feature(feature_x) octeon_has_feature_##feature_x()
+
+#endif /* __OCTEON_FEATURE_H__ */
Signature · 1 line
2.28.0
#5 lore raw

PATCH 5/10 mips: octeon: Add header cvmx-fuse.h

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

Add header to handle Octeon fuse access.

---

 .../mips/mach-octeon/include/mach/cvmx-fuse.h | 71 +++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-fuse.h
arch/mips/mach-octeon/include/mach/cvmx-fuse.h new file +71 -0
new file mode 100644
index 0000000000..a06a1326cb
@@ -0,0 +1,71 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 Marvell International Ltd.
+ */
+
+#ifndef __CVMX_FUSE_H__
+#define __CVMX_FUSE_H__
+
+/**
+ * Read a byte of fuse data
+ * @param node		node to read from
+ * @param byte_addr	address to read
+ *
+ * @return fuse value: 0 or 1
+ */
+static inline u8 cvmx_fuse_read_byte_node(u8 node, int byte_addr)
+{
+	u64 val;
+
+	val = FIELD_PREP(MIO_FUS_RCMD_ADDR, byte_addr) | MIO_FUS_RCMD_PEND;
+	csr_wr_node(node, CVMX_MIO_FUS_RCMD, val);
+
+	do {
+		val = csr_rd_node(node, CVMX_MIO_FUS_RCMD);
+	} while (val & MIO_FUS_RCMD_PEND);
+
+	return FIELD_GET(MIO_FUS_RCMD_DAT, val);
+}
+
+/**
+ * Read a byte of fuse data
+ * @param byte_addr   address to read
+ *
+ * @return fuse value: 0 or 1
+ */
+static inline u8 cvmx_fuse_read_byte(int byte_addr)
+{
+	return cvmx_fuse_read_byte_node(0, byte_addr);
+}
+
+/**
+ * Read a single fuse bit
+ *
+ * @param node   Node number
+ * @param fuse   Fuse number (0-1024)
+ *
+ * @return fuse value: 0 or 1
+ */
+static inline int cvmx_fuse_read_node(u8 node, int fuse)
+{
+	return (cvmx_fuse_read_byte_node(node, fuse >> 3) >> (fuse & 0x7)) & 1;
+}
+
+/**
+ * Read a single fuse bit
+ *
+ * @param fuse   Fuse number (0-1024)
+ *
+ * @return fuse value: 0 or 1
+ */
+static inline int cvmx_fuse_read(int fuse)
+{
+	return cvmx_fuse_read_node(0, fuse);
+}
+
+static inline int cvmx_octeon_fuse_locked(void)
+{
+	return cvmx_fuse_read(123);
+}
+
+#endif /* __CVMX_FUSE_H__ */
Signature · 1 line
2.28.0
#6 lore raw

PATCH 6/10 mips: octeon: Add header cvmx-bootinfo.h

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

Add header to handle bootinfo support, needed for Octeon Linux kernel booting.

---

 .../mach-octeon/include/mach/cvmx-bootinfo.h  | 350 ++++++++++++++++++
 1 file changed, 350 insertions(+)
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-bootinfo.h
arch/mips/mach-octeon/include/mach/cvmx-bootinfo.h new file +350 -0
new file mode 100644
index 0000000000..337987178f
@@ -0,0 +1,350 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 Marvell International Ltd.
+ */
+
+/*
+ * Header file containing the ABI with the bootloader.
+ */
+
+#ifndef __CVMX_BOOTINFO_H__
+#define __CVMX_BOOTINFO_H__
+
+#include "cvmx-coremask.h"
+
+/*
+ * Current major and minor versions of the CVMX bootinfo block that is
+ * passed from the bootloader to the application.  This is versioned
+ * so that applications can properly handle multiple bootloader
+ * versions.
+ */
+#define CVMX_BOOTINFO_MAJ_VER 1
+#define CVMX_BOOTINFO_MIN_VER 4
+
+#if (CVMX_BOOTINFO_MAJ_VER == 1)
+#define CVMX_BOOTINFO_OCTEON_SERIAL_LEN 20
+/*
+ * This structure is populated by the bootloader.  For binary
+ * compatibility the only changes that should be made are
+ * adding members to the end of the structure, and the minor
+ * version should be incremented at that time.
+ * If an incompatible change is made, the major version
+ * must be incremented, and the minor version should be reset
+ * to 0.
+ */
+struct cvmx_bootinfo {
+	u32 major_version;
+	u32 minor_version;
+
+	u64 stack_top;
+	u64 heap_base;
+	u64 heap_end;
+	u64 desc_vaddr;
+
+	u32 exception_base_addr;
+	u32 stack_size;
+	u32 flags;
+	u32 core_mask;
+	/* DRAM size in megabytes */
+	u32 dram_size;
+	/* physical address of free memory descriptor block*/
+	u32 phy_mem_desc_addr;
+	/* used to pass flags from app to debugger */
+	u32 debugger_flags_base_addr;
+
+	/* CPU clock speed, in hz */
+	u32 eclock_hz;
+
+	/* DRAM clock speed, in hz */
+	u32 dclock_hz;
+
+	u32 reserved0;
+	u16 board_type;
+	u8 board_rev_major;
+	u8 board_rev_minor;
+	u16 reserved1;
+	u8 reserved2;
+	u8 reserved3;
+	char board_serial_number[CVMX_BOOTINFO_OCTEON_SERIAL_LEN];
+	u8 mac_addr_base[6];
+	u8 mac_addr_count;
+#if (CVMX_BOOTINFO_MIN_VER >= 1)
+	/*
+	 * Several boards support compact flash on the Octeon boot
+	 * bus.	 The CF memory spaces may be mapped to different
+	 * addresses on different boards.  These are the physical
+	 * addresses, so care must be taken to use the correct
+	 * XKPHYS/KSEG0 addressing depending on the application's
+	 * ABI.	 These values will be 0 if CF is not present.
+	 */
+	u64 compact_flash_common_base_addr;
+	u64 compact_flash_attribute_base_addr;
+	/*
+	 * Base address of the LED display (as on EBT3000 board)
+	 * This will be 0 if LED display not present.
+	 */
+	u64 led_display_base_addr;
+#endif
+#if (CVMX_BOOTINFO_MIN_VER >= 2)
+	/* DFA reference clock in hz (if applicable)*/
+	u32 dfa_ref_clock_hz;
+
+	/*
+	 * flags indicating various configuration options.  These
+	 * flags supercede the 'flags' variable and should be used
+	 * instead if available.
+	 */
+	u32 config_flags;
+#endif
+#if (CVMX_BOOTINFO_MIN_VER >= 3)
+	/*
+	 * Address of the OF Flattened Device Tree structure
+	 * describing the board.
+	 */
+	u64 fdt_addr;
+#endif
+#if (CVMX_BOOTINFO_MIN_VER >= 4)
+	/*
+	 * Coremask used for processors with more than 32 cores
+	 * or with OCI.  This replaces core_mask.
+	 */
+	struct cvmx_coremask ext_core_mask;
+#endif
+};
+
+#define CVMX_BOOTINFO_CFG_FLAG_PCI_HOST			(1ull << 0)
+#define CVMX_BOOTINFO_CFG_FLAG_PCI_TARGET		(1ull << 1)
+#define CVMX_BOOTINFO_CFG_FLAG_DEBUG			(1ull << 2)
+#define CVMX_BOOTINFO_CFG_FLAG_NO_MAGIC			(1ull << 3)
+/*
+ * This flag is set if the TLB mappings are not contained in the
+ * 0x10000000 - 0x20000000 boot bus region.
+ */
+#define CVMX_BOOTINFO_CFG_FLAG_OVERSIZE_TLB_MAPPING	(1ull << 4)
+#define CVMX_BOOTINFO_CFG_FLAG_BREAK			(1ull << 5)
+
+#endif /*   (CVMX_BOOTINFO_MAJ_VER == 1) */
+
+/* Type defines for board and chip types */
+enum cvmx_board_types_enum {
+	CVMX_BOARD_TYPE_NULL = 0,
+	CVMX_BOARD_TYPE_SIM = 1,
+	CVMX_BOARD_TYPE_EBT3000 = 2,
+	CVMX_BOARD_TYPE_KODAMA = 3,
+	CVMX_BOARD_TYPE_NIAGARA = 4,
+	CVMX_BOARD_TYPE_NAC38 = 5,	/* formerly NAO38 */
+	CVMX_BOARD_TYPE_THUNDER = 6,
+	CVMX_BOARD_TYPE_TRANTOR = 7,
+	CVMX_BOARD_TYPE_EBH3000 = 8,
+	CVMX_BOARD_TYPE_EBH3100 = 9,
+	CVMX_BOARD_TYPE_HIKARI = 10,
+	CVMX_BOARD_TYPE_CN3010_EVB_HS5 = 11,
+	CVMX_BOARD_TYPE_CN3005_EVB_HS5 = 12,
+	CVMX_BOARD_TYPE_KBP = 13,
+	/* Deprecated, CVMX_BOARD_TYPE_CN3010_EVB_HS5 supports the CN3020 */
+	CVMX_BOARD_TYPE_CN3020_EVB_HS5 = 14,
+	CVMX_BOARD_TYPE_EBT5800 = 15,
+	CVMX_BOARD_TYPE_NICPRO2 = 16,
+	CVMX_BOARD_TYPE_EBH5600 = 17,
+	CVMX_BOARD_TYPE_EBH5601 = 18,
+	CVMX_BOARD_TYPE_EBH5200 = 19,
+	CVMX_BOARD_TYPE_BBGW_REF = 20,
+	CVMX_BOARD_TYPE_NIC_XLE_4G = 21,
+	CVMX_BOARD_TYPE_EBT5600 = 22,
+	CVMX_BOARD_TYPE_EBH5201 = 23,
+	CVMX_BOARD_TYPE_EBT5200 = 24,
+	CVMX_BOARD_TYPE_CB5600	= 25,
+	CVMX_BOARD_TYPE_CB5601	= 26,
+	CVMX_BOARD_TYPE_CB5200	= 27,
+	/* Special 'generic' board type, supports many boards */
+	CVMX_BOARD_TYPE_GENERIC = 28,
+	CVMX_BOARD_TYPE_EBH5610 = 29,
+	CVMX_BOARD_TYPE_LANAI2_A = 30,
+	CVMX_BOARD_TYPE_LANAI2_U = 31,
+	CVMX_BOARD_TYPE_EBB5600 = 32,
+	CVMX_BOARD_TYPE_EBB6300 = 33,
+	CVMX_BOARD_TYPE_NIC_XLE_10G = 34,
+	CVMX_BOARD_TYPE_LANAI2_G = 35,
+	CVMX_BOARD_TYPE_EBT5810 = 36,
+	CVMX_BOARD_TYPE_NIC10E = 37,
+	CVMX_BOARD_TYPE_EP6300C = 38,
+	CVMX_BOARD_TYPE_EBB6800 = 39,
+	CVMX_BOARD_TYPE_NIC4E = 40,
+	CVMX_BOARD_TYPE_NIC2E = 41,
+	CVMX_BOARD_TYPE_EBB6600 = 42,
+	CVMX_BOARD_TYPE_REDWING = 43,
+	CVMX_BOARD_TYPE_NIC68_4 = 44,
+	CVMX_BOARD_TYPE_NIC10E_66 = 45,
+	CVMX_BOARD_TYPE_MAX,
+
+	/*
+	 * The range from CVMX_BOARD_TYPE_MAX to
+	 * CVMX_BOARD_TYPE_CUST_DEFINED_MIN is reserved for future
+	 * SDK use.
+	 */
+
+	/*
+	 * Set aside a range for customer boards.  These numbers are managed
+	 * by Cavium.
+	 */
+	CVMX_BOARD_TYPE_CUST_DEFINED_MIN = 10000,
+	CVMX_BOARD_TYPE_CUST_WSX16 = 10001,
+	CVMX_BOARD_TYPE_CUST_NS0216 = 10002,
+	CVMX_BOARD_TYPE_CUST_NB5 = 10003,
+	CVMX_BOARD_TYPE_CUST_WMR500 = 10004,
+	CVMX_BOARD_TYPE_CUST_ITB101 = 10005,
+	CVMX_BOARD_TYPE_CUST_NTE102 = 10006,
+	CVMX_BOARD_TYPE_CUST_AGS103 = 10007,
+	CVMX_BOARD_TYPE_CUST_GST104 = 10008,
+	CVMX_BOARD_TYPE_CUST_GCT105 = 10009,
+	CVMX_BOARD_TYPE_CUST_AGS106 = 10010,
+	CVMX_BOARD_TYPE_CUST_SGM107 = 10011,
+	CVMX_BOARD_TYPE_CUST_GCT108 = 10012,
+	CVMX_BOARD_TYPE_CUST_AGS109 = 10013,
+	CVMX_BOARD_TYPE_CUST_GCT110 = 10014,
+	CVMX_BOARD_TYPE_CUST_L2_AIR_SENDER = 10015,
+	CVMX_BOARD_TYPE_CUST_L2_AIR_RECEIVER = 10016,
+	CVMX_BOARD_TYPE_CUST_L2_ACCTON2_TX = 10017,
+	CVMX_BOARD_TYPE_CUST_L2_ACCTON2_RX = 10018,
+	CVMX_BOARD_TYPE_CUST_L2_WSTRNSNIC_TX = 10019,
+	CVMX_BOARD_TYPE_CUST_L2_WSTRNSNIC_RX = 10020,
+	CVMX_BOARD_TYPE_CUST_L2_ZINWELL = 10021,
+	CVMX_BOARD_TYPE_CUST_DEFINED_MAX = 20000,
+
+	/*
+	 * Set aside a range for customer private use.	The SDK won't
+	 * use any numbers in this range.
+	 */
+	CVMX_BOARD_TYPE_CUST_PRIVATE_MIN = 20001,
+	CVMX_BOARD_TYPE_UBNT_E100 = 20002,
+	CVMX_BOARD_TYPE_CUST_DSR1000N = 20006,
+	CVMX_BOARD_TYPE_KONTRON_S1901 = 21901,
+	CVMX_BOARD_TYPE_CUST_PRIVATE_MAX = 30000,
+
+	/* The remaining range is reserved for future use. */
+};
+
+enum cvmx_chip_types_enum {
+	CVMX_CHIP_TYPE_NULL = 0,
+	CVMX_CHIP_SIM_TYPE_DEPRECATED = 1,
+	CVMX_CHIP_TYPE_OCTEON_SAMPLE = 2,
+	CVMX_CHIP_TYPE_MAX,
+};
+
+/*
+ * Compatibility alias for NAC38 name change, planned to be removed
+ * from SDK 1.7
+ */
+#define CVMX_BOARD_TYPE_NAO38	CVMX_BOARD_TYPE_NAC38
+
+/* Functions to return string based on type */
+#define ENUM_BRD_TYPE_CASE(x)						\
+	case x:								\
+		return(#x + 16)		/* Skip CVMX_BOARD_TYPE_ */
+
+static inline const char *cvmx_board_type_to_string(enum
+						    cvmx_board_types_enum type)
+{
+	switch (type) {
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NULL);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_SIM);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBT3000);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_KODAMA);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NIAGARA);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NAC38);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_THUNDER);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_TRANTOR);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBH3000);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBH3100);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_HIKARI);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CN3010_EVB_HS5);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CN3005_EVB_HS5);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_KBP);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CN3020_EVB_HS5);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBT5800);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NICPRO2);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBH5600);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBH5601);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBH5200);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_BBGW_REF);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NIC_XLE_4G);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBT5600);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBH5201);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBT5200);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CB5600);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CB5601);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CB5200);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_GENERIC);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBH5610);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_LANAI2_A);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_LANAI2_U);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBB5600);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBB6300);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NIC_XLE_10G);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_LANAI2_G);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBT5810);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NIC10E);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EP6300C);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBB6800);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NIC4E);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NIC2E);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBB6600);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_REDWING);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NIC68_4);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NIC10E_66);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_MAX);
+
+		/* Customer boards listed here */
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DEFINED_MIN);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_WSX16);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_NS0216);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_NB5);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_WMR500);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_ITB101);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_NTE102);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_AGS103);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_GST104);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_GCT105);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_AGS106);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_SGM107);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_GCT108);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_AGS109);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_GCT110);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_L2_AIR_SENDER);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_L2_AIR_RECEIVER);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_L2_ACCTON2_TX);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_L2_ACCTON2_RX);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_L2_WSTRNSNIC_TX);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_L2_WSTRNSNIC_RX);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_L2_ZINWELL);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DEFINED_MAX);
+
+		/* Customer private range */
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MIN);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_UBNT_E100);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DSR1000N);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_KONTRON_S1901);
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MAX);
+	}
+
+	return NULL;
+}
+
+#define ENUM_CHIP_TYPE_CASE(x)						\
+	case x:								\
+		return(#x + 15)		/* Skip CVMX_CHIP_TYPE */
+
+static inline const char *cvmx_chip_type_to_string(enum
+						   cvmx_chip_types_enum type)
+{
+	switch (type) {
+		ENUM_CHIP_TYPE_CASE(CVMX_CHIP_TYPE_NULL);
+		ENUM_CHIP_TYPE_CASE(CVMX_CHIP_SIM_TYPE_DEPRECATED);
+		ENUM_CHIP_TYPE_CASE(CVMX_CHIP_TYPE_OCTEON_SAMPLE);
+		ENUM_CHIP_TYPE_CASE(CVMX_CHIP_TYPE_MAX);
+	}
+
+	return "Unsupported Chip";
+}
+
+#endif /* __CVMX_BOOTINFO_H__ */
Signature · 1 line
2.28.0
#7 lore raw

PATCH 7/10 mips: octeon: Add coremask support

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

This patch adds the coremask handling functions.

---

 arch/mips/mach-octeon/Makefile                |   1 +
 arch/mips/mach-octeon/cvmx-coremask.c         | 366 +++++++++
 .../mach-octeon/include/mach/cvmx-coremask.h  | 752 ++++++++++++++++++
 3 files changed, 1119 insertions(+)
 create mode 100644 arch/mips/mach-octeon/cvmx-coremask.c
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-coremask.h
arch/mips/mach-octeon/Makefile +1 -0
index 2e37ca572c..5155f89a1e 100644
@@ -8,3 +8,4 @@ obj-y += cache.o
 obj-y += clock.o
 obj-y += cpu.o
 obj-y += dram.o
+obj-y += cvmx-coremask.o
arch/mips/mach-octeon/cvmx-coremask.c new file +366 -0

366 lines not on this page · raw message

arch/mips/mach-octeon/include/mach/cvmx-coremask.h new file +752 -0

752 lines not on this page · raw message

Signature · 1 line
2.28.0
#8 lore raw

PATCH 8/10 mips: octeon: Add bootmem support

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

This is needed for Linux booting, as the memory infos need to be passed in this bootmem format to the Linux kernel.

---

 arch/mips/mach-octeon/Makefile                |    1 +
 arch/mips/mach-octeon/cvmx-bootmem.c          | 1460 +++++++++++++++++
 .../mach-octeon/include/mach/cvmx-bootmem.h   |  533 ++++++
 3 files changed, 1994 insertions(+)
 create mode 100644 arch/mips/mach-octeon/cvmx-bootmem.c
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-bootmem.h
arch/mips/mach-octeon/Makefile +1 -0
index 5155f89a1e..e96f0deb1b 100644
@@ -9,3 +9,4 @@ obj-y += clock.o
 obj-y += cpu.o
 obj-y += dram.o
 obj-y += cvmx-coremask.o
+obj-y += cvmx-bootmem.o
arch/mips/mach-octeon/cvmx-bootmem.c new file +1460 -0

1,460 lines not on this page · raw message

arch/mips/mach-octeon/include/mach/cvmx-bootmem.h new file +533 -0

533 lines not on this page · raw message

Signature · 1 line
2.28.0
#9 lore raw

PATCH 9/10 mips: octeon: Add bootoctlinux command

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

Octeon needs a platform specific cmd to boot the Linux kernel, as specific parameters need to be passed and special handling for the multiple cores (SMP) is needed.

---

 arch/mips/mach-octeon/Makefile                |   1 +
 arch/mips/mach-octeon/bootoctlinux.c          | 661 ++++++++++++++++++
 .../mach-octeon/include/mach/bootoct_cmd.h    |  54 ++
 3 files changed, 716 insertions(+)
 create mode 100644 arch/mips/mach-octeon/bootoctlinux.c
 create mode 100644 arch/mips/mach-octeon/include/mach/bootoct_cmd.h
arch/mips/mach-octeon/Makefile +1 -0
index e96f0deb1b..3486aa9d8b 100644
@@ -10,3 +10,4 @@ obj-y += cpu.o
 obj-y += dram.o
 obj-y += cvmx-coremask.o
 obj-y += cvmx-bootmem.o
+obj-y += bootoctlinux.o
arch/mips/mach-octeon/bootoctlinux.c new file +661 -0

661 lines not on this page · raw message

arch/mips/mach-octeon/include/mach/bootoct_cmd.h new file +54 -0

54 lines not on this page · raw message

Signature · 1 line
2.28.0
#10 lore raw

PATCH 10/10 mips: octeon: octeon_common.h: Increase CONFIG_SYS_BOOTM_LEN

In reply to Stefan Roese

Increase CONFIG_SYS_BOOTM_LEN to 64MiB for Linux kernel booting.

---

 include/configs/octeon_common.h | 2 ++
 1 file changed, 2 insertions(+)
include/configs/octeon_common.h +2 -0
index 541b81801e..109ef4064d 100644
@@ -21,4 +21,6 @@
 
 #define CONFIG_SYS_LOAD_ADDR		(CONFIG_SYS_SDRAM_BASE + (1 << 20))
 
+#define CONFIG_SYS_BOOTM_LEN		(64 << 20)	/* 64M */
+
 #endif /* __OCTEON_COMMON_H__ */
Signature · 1 line
2.28.0
#11 lore raw

cover mips: octeon: Add bootoctlinux command for Octeon Linux kernel booting

In reply to Stefan Roese

Am Donnerstag, den 20.08.2020, 07:21 +0200 schrieb Stefan Roese:

Quoted 46 lines

This patchset adds the platforms specific bootoctlinux command, which is used to boot the MIPS Octeon Linux kernel (4.9.x). A special command is necessary here, as very platform specific data is passed to the kernel via the bootinfo / bootmem format. This patchset also includes various required infrastructure code for this (octeon-feature, coremask, bootinfo). The code for booting the additional cores is also included in this patchset.

Tested on Octeon 7304 EBB with all 16 cores.

Thanks,
Stefan

Aaron Williams (7):
mips: octeon: Add header cvmx-regs.h
mips: octeon: Add header octeon-feature.h
mips: octeon: Add header cvmx-fuse.h
mips: octeon: Add header cvmx-bootinfo.h
mips: octeon: Add coremask support
mips: octeon: Add bootmem support
mips: octeon: Add bootoctlinux command

Stefan Roese (3):
mips: octeon: octeon-model.h: Enable inclusion from assembler files
mips: octeon: lowlevel_init.S: Add NMI handling code for SMP Linux
booting
mips: octeon: octeon_common.h: Increase CONFIG_SYS_BOOTM_LEN

 arch/mips/mach-octeon/Makefile                |    3 +
 arch/mips/mach-octeon/bootoctlinux.c          |  661 ++++++++
 arch/mips/mach-octeon/cvmx-bootmem.c          | 1460 +++++++++++++++++
 arch/mips/mach-octeon/cvmx-coremask.c         |  366 +++++
 .../mach-octeon/include/mach/bootoct_cmd.h    |   54 +
 .../mach-octeon/include/mach/cvmx-bootinfo.h  |  350 ++++
 .../mach-octeon/include/mach/cvmx-bootmem.h   |  533 ++++++
 .../mach-octeon/include/mach/cvmx-coremask.h  |  752 +++++++++
 .../mips/mach-octeon/include/mach/cvmx-fuse.h |   71 +
 .../mips/mach-octeon/include/mach/cvmx-regs.h |  144 ++
 .../mach-octeon/include/mach/octeon-feature.h |  442 +++++
 .../mach-octeon/include/mach/octeon-model.h   |    4 +
 arch/mips/mach-octeon/lowlevel_init.S         |   76 +
 include/configs/octeon_common.h               |    2 +
 14 files changed, 4918 insertions(+)
 create mode 100644 arch/mips/mach-octeon/bootoctlinux.c
 create mode 100644 arch/mips/mach-octeon/cvmx-bootmem.c
Quoted 9 lines
 create mode 100644 arch/mips/mach-octeon/cvmx-coremask.c
 create mode 100644 arch/mips/mach-octeon/include/mach/bootoct_cmd.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-bootinfo.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-bootmem.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-coremask.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-fuse.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-regs.h
 create mode 100644 arch/mips/mach-octeon/include/mach/octeon-feature.h

series applied to u-boot-mips/next, thanks.

I've fixed the usage of gd->bd->bi_memstart to gd->ram_base to be compatible with your gd->bd->bi_mem* cleanup series.

Signature · 1 line
- Daniel