Skip to contentSkip to conversation

arm: Introduce Marvell/Cavium OcteonTX/TX2

PATCH New Stefan Roese 2 participants 30 messages Aug 17, 2020 – Aug 22, 2020

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

v2 cover arm: Introduce Marvell/Cavium OcteonTX/TX2

This series will add support for OcteonTX and OcteonTX2 processsor based platforms. The Marvell/Cavium Octeon-TX 64-bit ARM based SoCs include the CN80XX, CN81XX and CN83XX while Octeon-TX2 64-bit ARM based SoCs include support for CN96XX and CN95XX.
These SoC's have peripheral drivers based on PCI ECAM.

Some comments on the individual patches:
[1 -13] Add requied changes to PCI framework
[15 - 16] Add OcteonTX/TX2 platform header files [18 - 23] Add OcteonTX/TX2 drivers
[24 - 25] Add OcteonTX/TX2 board files and configurations

Update from RFC -> v1 (Stefan):
I took over upstreaming the patchset from Suneel. Suneel addressed some of the review comments. I addressed some more.

Some of the drivers originally included in this patchset have already been integrated into mainline (like I2C) and some are part of the MIPS Octeon patchset mentioned above. The reason being, that MIPS Octeon and Octen TX/TX2 share most of the peripherals, so a re-use of the drivers in all Octeon platforms makes much sense.

Thanks,
Stefan

Changes in v2:
- Add Reviewed-by tag from Simon
- New patch
- Add Reviewed-by tag from Simon
- Split changes in board/renesas/rcar-common/common.c into separate patch
- Add Reviewed-by tag from Simon
- Correct patch subject
- Correct patch description in commit text
- Minor spelling update
- Add Reviewed-by tag from Simon
- Add sandbox test
- Add Reviewed-by tag from Simon
- Add Reviewed-by tag from Simon
- Add Reviewed-by tag from Simon
- Add note about adding a Kconfig option for AHCI quirks, once there are multiple quirks
- Add Reviewed-by tag from Simon
- Add comments to enum declaration and "type" declaration
- Return -EINVAL in default case statement for unsupported length
- Add helper function octeontx_bdf_invalid() and return -EPERM in case of an errror
- Use livetree API
- Remove local mmc_power_init() call
- Add Reviewed-by tag from Simon
- Add CORE0_POKE_OFFSET_MASK and calculate poke register address in _probe() instead of repeatedly in _reset()
- Slightly change the Kconfig entry: use "default y", it already depends on "WDT && (ARCH_OCTEONTX || ARCH_OCTEONTX2)"
- Select CONFIG_OF_LIVE
- Select CONFIG_OF_LIVE

Changes in v1:
- Add return value description to function prototype in header
- Changed from using be32_to_cpup() to fdt32_to_cpu()
- New patch
- New patch, replaces increase of MAX_PCI_REGIONS to 10
- Change patch subject
- Change patch subject
- Change patch subject
- Enhance Kconfig help descrition
- Use if() instead of #if
- Change patch subject
- Change patch subject
- Enhance commit text: expanded the abbreviations
- Changed some printf() to debug()
- Changed 0 to '\0' in memset()
- Comments for variables in struct pci_child_platdata added
- Comments for newly introduced functions added in prototype / header
- Change patch subject
- Fixed multi-line comment style
- Moved "feature" into new function which is only called, when CONFIG_PCI_SRIOV is enabled, so that the code is not increased in all cases
- Changed variable declaration to use reverse xmas tree order
- Change patch subject
- Fixed multi-line comment style
- Added CONFIG_PCI_ARID and enabled the new code optionally, so that the code size is not increased in all cases
- New patch
- Change patch subject
- Add small commit text
- Also add clr/setbits_64 (without endianess extension), which is needed for the updated Octeon device drivers
- Change patch subject
- Change patch subject
- Change patch subject
- Use constants from pci_ids.h instead of hardcoded values
- Change patch subject
- Remove inclusion of common.h
- Remove #ifdef's and use driver specific data instead
- Add comments to struct
- Add some helper functions to reduce code size
- Misc coding style changes (blank lines etc)
- Use debug() instead of printf() in some cases
- Change patch subject
- Rebased on latest TOT
- Removed inclusion of common.h
- Fix most checkpatch errors / warnings (use IS_ENABLED etc)
- Change patch subject
- Change patch subject
- Rebased on latest TOT
- Removed inclusion of common.h
- Change patch subject
- Rebased on latest TOT
- Removed inclusion of common.h
- Change patch subject
- Remove inclusion of common.h
- Remove global wdt_dev as its unused
- Remove #ifdef's
- Remove optional fixed register access - only use address passed via DT while probing
- Use dev_remap_addr() instead of dev_read_addr_index()
- Changed patch subject
- Rebased on latest TOT
- Removed inclusion of common.h
- Moved MEMTEST defines to Kconfig
- *.c files checkpatch cleanup
- Changed patch subject
- Rebased on latest TOT
- Removed inclusion of common.h
- Moved MEMTEST defines to Kconfig
- *.c files checkpatch cleanup
- Add go_uboot cmd for U-Boot starting from RAM

Stefan Roese (4):
dm: core: Add API to read PCI bus-range property
pci: pci-uclass: Remove #ifdef CONFIG_NR_DRAM_BANKS as its always set
ARM: renesas: Drop unnecessary function ft_board_setup()
pci: pci-uclass: Dynamically allocate the PCI regions

Suneel Garapati (21):
fdtdec: Add API to read pci bus-range property
pci: pci-uclass: Fix incorrect argument in map_physmem
pci: pci-uclass: Make DT subnode parse optional
pci: pci-uclass: Add multi entry support for memory regions
pci: pci-uclass: Add support for Enhanced Allocation in Bridges
pci: pci-uclass: Add support for Single-Root I/O Virtualization
pci: pci-uclass: Add VF BAR map support for Enhanced Allocation
pci: pci-uclass: Add support for Alternate-RoutingID capability
pci: pci-uclass: Check validity of ofnode
arm: include/asm/io.h: Add 64bit clrbits and setbits helpers
arm: octeontx: Add headers for OcteonTX
arm: octeontx2: Add headers for OcteonTX2
ata: ahci: Add BAR index quirk for Cavium PCI SATA device
pci: Add PCI controller driver for OcteonTX / TX2
mmc: Add MMC controller driver for OcteonTX / TX2
mtd: nand: Add NAND controller driver for OcteonTX
net: Add NIC controller driver for OcteonTX
net: Add NIC controller driver for OcteonTX2
watchdog: Add reset support for OcteonTX / TX2
arm: octeontx: Add support for OcteonTX SoC platforms
arm: octeontx2: Add support for OcteonTX2 SoC platforms

 arch/arm/Kconfig                              |    24 +
 arch/arm/Makefile                             |     2 +
 arch/arm/include/asm/arch-octeontx/board.h    |   123 +
 arch/arm/include/asm/arch-octeontx/clock.h    |    25 +
 .../asm/arch-octeontx/csrs/csrs-mio_emm.h     |  1193 ++
 .../include/asm/arch-octeontx/csrs/csrs-xcv.h |   428 +
 arch/arm/include/asm/arch-octeontx/gpio.h     |     6 +
 arch/arm/include/asm/arch-octeontx/smc.h      |    20 +
 arch/arm/include/asm/arch-octeontx/soc.h      |    33 +
 arch/arm/include/asm/arch-octeontx2/board.h   |   128 +
 arch/arm/include/asm/arch-octeontx2/clock.h   |    24 +
 .../asm/arch-octeontx2/csrs/csrs-cgx.h        |  7851 ++++++++++++
 .../asm/arch-octeontx2/csrs/csrs-lmt.h        |    60 +
 .../asm/arch-octeontx2/csrs/csrs-mio_emm.h    |  1193 ++
 .../asm/arch-octeontx2/csrs/csrs-nix.h        | 10404 ++++++++++++++++
 .../asm/arch-octeontx2/csrs/csrs-npa.h        |  2294 ++++
 .../asm/arch-octeontx2/csrs/csrs-npc.h        |  1629 +++
 .../asm/arch-octeontx2/csrs/csrs-rvu.h        |  2276 ++++
 arch/arm/include/asm/arch-octeontx2/gpio.h    |     6 +
 arch/arm/include/asm/arch-octeontx2/smc-id.h  |    32 +
 arch/arm/include/asm/arch-octeontx2/smc.h     |    18 +
 arch/arm/include/asm/arch-octeontx2/soc.h     |    33 +
 arch/arm/include/asm/io.h                     |    16 +
 arch/arm/mach-octeontx/Kconfig                |    23 +
 arch/arm/mach-octeontx/Makefile               |     9 +
 arch/arm/mach-octeontx/clock.c                |    35 +
 arch/arm/mach-octeontx/cpu.c                  |    76 +
 arch/arm/mach-octeontx/lowlevel_init.S        |    33 +
 arch/arm/mach-octeontx2/Kconfig               |    23 +
 arch/arm/mach-octeontx2/Makefile              |     9 +
 arch/arm/mach-octeontx2/clock.c               |    35 +
 arch/arm/mach-octeontx2/config.mk             |     4 +
 arch/arm/mach-octeontx2/cpu.c                 |    72 +
 arch/arm/mach-octeontx2/lowlevel_init.S       |    33 +
 arch/sandbox/dts/test.dts                     |     5 +-
 board/Marvell/octeontx/Kconfig                |    14 +
 board/Marvell/octeontx/MAINTAINERS            |     8 +
 board/Marvell/octeontx/Makefile               |     9 +
 board/Marvell/octeontx/board-fdt.c            |   311 +
 board/Marvell/octeontx/board.c                |   152 +
 board/Marvell/octeontx/smc.c                  |    25 +
 board/Marvell/octeontx/soc-utils.c            |    50 +
 board/Marvell/octeontx2/Kconfig               |    14 +
 board/Marvell/octeontx2/MAINTAINERS           |     8 +
 board/Marvell/octeontx2/Makefile              |     9 +
 board/Marvell/octeontx2/board-fdt.c           |   221 +
 board/Marvell/octeontx2/board.c               |   247 +
 board/Marvell/octeontx2/smc.c                 |    58 +
 board/Marvell/octeontx2/soc-utils.c           |    49 +
 board/renesas/rcar-common/common.c            |    48 -
 configs/octeontx2_95xx_defconfig              |   105 +
 configs/octeontx2_96xx_defconfig              |   131 +
 configs/octeontx_81xx_defconfig               |   134 +
 configs/octeontx_83xx_defconfig               |   129 +
 configs/sandbox_defconfig                     |     1 +
 drivers/ata/ahci.c                            |    15 +
 drivers/core/read.c                           |    17 +
 drivers/mmc/Kconfig                           |     9 +
 drivers/mmc/Makefile                          |     1 +
 drivers/mmc/octeontx_hsmmc.c                  |  3897 ++++++
 drivers/mmc/octeontx_hsmmc.h                  |   207 +
 drivers/mtd/nand/raw/Kconfig                  |    16 +
 drivers/mtd/nand/raw/Makefile                 |     2 +
 drivers/mtd/nand/raw/octeontx_bch.c           |   426 +
 drivers/mtd/nand/raw/octeontx_bch.h           |   133 +
 drivers/mtd/nand/raw/octeontx_bch_regs.h      |   169 +
 drivers/mtd/nand/raw/octeontx_nand.c          |  2264 ++++
 drivers/net/Kconfig                           |    31 +
 drivers/net/Makefile                          |     4 +
 drivers/net/octeontx/Makefile                 |     9 +
 drivers/net/octeontx/bgx.c                    |  1572 +++
 drivers/net/octeontx/bgx.h                    |   259 +
 drivers/net/octeontx/nic.h                    |   510 +
 drivers/net/octeontx/nic_main.c               |   780 ++
 drivers/net/octeontx/nic_reg.h                |   252 +
 drivers/net/octeontx/nicvf_main.c             |   583 +
 drivers/net/octeontx/nicvf_queues.c           |  1142 ++
 drivers/net/octeontx/nicvf_queues.h           |   355 +
 drivers/net/octeontx/q_struct.h               |   697 ++
 drivers/net/octeontx/smi.c                    |   383 +
 drivers/net/octeontx/xcv.c                    |   129 +
 drivers/net/octeontx2/Makefile                |    11 +
 drivers/net/octeontx2/cgx.c                   |   298 +
 drivers/net/octeontx2/cgx.h                   |   107 +
 drivers/net/octeontx2/cgx_intf.c              |   717 ++
 drivers/net/octeontx2/cgx_intf.h              |   450 +
 drivers/net/octeontx2/lmt.h                   |    51 +
 drivers/net/octeontx2/nix.c                   |   833 ++
 drivers/net/octeontx2/nix.h                   |   355 +
 drivers/net/octeontx2/nix_af.c                |  1104 ++
 drivers/net/octeontx2/npc.h                   |    92 +
 drivers/net/octeontx2/rvu.h                   |   121 +
 drivers/net/octeontx2/rvu_af.c                |   173 +
 drivers/net/octeontx2/rvu_common.c            |    73 +
 drivers/net/octeontx2/rvu_pf.c                |   118 +
 drivers/pci/Kconfig                           |    37 +
 drivers/pci/Makefile                          |     1 +
 drivers/pci/pci-uclass.c                      |   288 +-
 drivers/pci/pci_octeontx.c                    |   364 +
 drivers/watchdog/Kconfig                      |    10 +
 drivers/watchdog/Makefile                     |     1 +
 drivers/watchdog/octeontx_wdt.c               |    66 +
 include/configs/octeontx2_common.h            |    72 +
 include/configs/octeontx_common.h             |    89 +
 include/dm/read.h                             |    12 +
 include/fdtdec.h                              |    13 +
 include/pci.h                                 |    45 +-
 lib/fdtdec.c                                  |    16 +
 test/dm/pci.c                                 |    22 +
 109 files changed, 49204 insertions(+), 95 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-octeontx/board.h
 create mode 100644 arch/arm/include/asm/arch-octeontx/clock.h
 create mode 100644 arch/arm/include/asm/arch-octeontx/csrs/csrs-mio_emm.h
 create mode 100644 arch/arm/include/asm/arch-octeontx/csrs/csrs-xcv.h
 create mode 100644 arch/arm/include/asm/arch-octeontx/gpio.h
 create mode 100644 arch/arm/include/asm/arch-octeontx/smc.h
 create mode 100644 arch/arm/include/asm/arch-octeontx/soc.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/board.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/clock.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-cgx.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-lmt.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-mio_emm.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-nix.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-npa.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-npc.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-rvu.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/gpio.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/smc-id.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/smc.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/soc.h
 create mode 100644 arch/arm/mach-octeontx/Kconfig
 create mode 100644 arch/arm/mach-octeontx/Makefile
 create mode 100644 arch/arm/mach-octeontx/clock.c
 create mode 100644 arch/arm/mach-octeontx/cpu.c
 create mode 100644 arch/arm/mach-octeontx/lowlevel_init.S
 create mode 100644 arch/arm/mach-octeontx2/Kconfig
 create mode 100644 arch/arm/mach-octeontx2/Makefile
 create mode 100644 arch/arm/mach-octeontx2/clock.c
 create mode 100644 arch/arm/mach-octeontx2/config.mk
 create mode 100644 arch/arm/mach-octeontx2/cpu.c
 create mode 100644 arch/arm/mach-octeontx2/lowlevel_init.S
 create mode 100644 board/Marvell/octeontx/Kconfig
 create mode 100644 board/Marvell/octeontx/MAINTAINERS
 create mode 100644 board/Marvell/octeontx/Makefile
 create mode 100644 board/Marvell/octeontx/board-fdt.c
 create mode 100644 board/Marvell/octeontx/board.c
 create mode 100644 board/Marvell/octeontx/smc.c
 create mode 100644 board/Marvell/octeontx/soc-utils.c
 create mode 100644 board/Marvell/octeontx2/Kconfig
 create mode 100644 board/Marvell/octeontx2/MAINTAINERS
 create mode 100644 board/Marvell/octeontx2/Makefile
 create mode 100644 board/Marvell/octeontx2/board-fdt.c
 create mode 100644 board/Marvell/octeontx2/board.c
 create mode 100644 board/Marvell/octeontx2/smc.c
 create mode 100644 board/Marvell/octeontx2/soc-utils.c
 create mode 100644 configs/octeontx2_95xx_defconfig
 create mode 100644 configs/octeontx2_96xx_defconfig
 create mode 100644 configs/octeontx_81xx_defconfig
 create mode 100644 configs/octeontx_83xx_defconfig
 create mode 100644 drivers/mmc/octeontx_hsmmc.c
 create mode 100644 drivers/mmc/octeontx_hsmmc.h
 create mode 100644 drivers/mtd/nand/raw/octeontx_bch.c
 create mode 100644 drivers/mtd/nand/raw/octeontx_bch.h
 create mode 100644 drivers/mtd/nand/raw/octeontx_bch_regs.h
 create mode 100644 drivers/mtd/nand/raw/octeontx_nand.c
 create mode 100644 drivers/net/octeontx/Makefile
 create mode 100644 drivers/net/octeontx/bgx.c
 create mode 100644 drivers/net/octeontx/bgx.h
 create mode 100644 drivers/net/octeontx/nic.h
 create mode 100644 drivers/net/octeontx/nic_main.c
 create mode 100644 drivers/net/octeontx/nic_reg.h
 create mode 100644 drivers/net/octeontx/nicvf_main.c
 create mode 100644 drivers/net/octeontx/nicvf_queues.c
 create mode 100644 drivers/net/octeontx/nicvf_queues.h
 create mode 100644 drivers/net/octeontx/q_struct.h
 create mode 100644 drivers/net/octeontx/smi.c
 create mode 100644 drivers/net/octeontx/xcv.c
 create mode 100644 drivers/net/octeontx2/Makefile
 create mode 100644 drivers/net/octeontx2/cgx.c
 create mode 100644 drivers/net/octeontx2/cgx.h
 create mode 100644 drivers/net/octeontx2/cgx_intf.c
 create mode 100644 drivers/net/octeontx2/cgx_intf.h
 create mode 100644 drivers/net/octeontx2/lmt.h
 create mode 100644 drivers/net/octeontx2/nix.c
 create mode 100644 drivers/net/octeontx2/nix.h
 create mode 100644 drivers/net/octeontx2/nix_af.c
 create mode 100644 drivers/net/octeontx2/npc.h
 create mode 100644 drivers/net/octeontx2/rvu.h
 create mode 100644 drivers/net/octeontx2/rvu_af.c
 create mode 100644 drivers/net/octeontx2/rvu_common.c
 create mode 100644 drivers/net/octeontx2/rvu_pf.c
 create mode 100644 drivers/pci/pci_octeontx.c
 create mode 100644 drivers/watchdog/octeontx_wdt.c
 create mode 100644 include/configs/octeontx2_common.h
 create mode 100644 include/configs/octeontx_common.h
Signature · 1 line
2.28.0
#1 lore raw

PATCH v2 1/25 fdtdec: Add API to read pci bus-range property

From: Suneel Garapati <[email protected]>

Add fdtdec_get_pci_bus_range to read bus-range property values.

---

Changes in v2:
- Add Reviewed-by tag from Simon

Changes in v1:
- Add return value description to function prototype in header
- Changed from using be32_to_cpup() to fdt32_to_cpu()

 include/fdtdec.h | 13 +++++++++++++
 lib/fdtdec.c     | 16 ++++++++++++++++
 2 files changed, 29 insertions(+)
include/fdtdec.h +13 -0
index 760b392bdf..f6759c7f8e 100644
@@ -444,6 +444,19 @@ int fdtdec_get_pci_vendev(const void *blob, int node,
 int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr,
 			 u32 *bar);
 
+/**
+ * Look at the bus range property of a device node and return the pci bus
+ * range for this node.
+ * The property must hold one fdt_pci_addr with a length.
+ * @param blob		FDT blob
+ * @param node		node to examine
+ * @param res		the resource structure to return the bus range
+ * @return 0 if ok, negative on error
+ */
+
+int fdtdec_get_pci_bus_range(const void *blob, int node,
+			     struct fdt_resource *res);
+
 /**
  * Look up a 32-bit integer property in a node and return it. The property
  * must have at least 4 bytes of data. The value of the first cell is
lib/fdtdec.c +16 -0
index 78576b530f..0b40fa374a 100644
@@ -242,6 +242,22 @@ int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr,
 
 	return 0;
 }
+
+int fdtdec_get_pci_bus_range(const void *blob, int node,
+			     struct fdt_resource *res)
+{
+	const u32 *values;
+	int len;
+
+	values = fdt_getprop(blob, node, "bus-range", &len);
+	if (!values || len < sizeof(*values) * 2)
+		return -EINVAL;
+
+	res->start = fdt32_to_cpu(*values++);
+	res->end = fdt32_to_cpu(*values);
+
+	return 0;
+}
 #endif
 
 uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name,
Signature · 1 line
2.28.0
#2 lore raw

PATCH v2 2/25 dm: core: Add API to read PCI bus-range property

In reply to Stefan Roese

Add dev_read_pci_bus_range() to read bus-range property values

---

Changes in v2:
- New patch

 drivers/core/read.c | 17 +++++++++++++++++
 include/dm/read.h   | 12 ++++++++++++
 2 files changed, 29 insertions(+)
drivers/core/read.c +17 -0
index 8bb456bc3f..86f3f88170 100644
@@ -10,6 +10,7 @@
 #include <mapmem.h>
 #include <asm/types.h>
 #include <asm/io.h>
+#include <linux/ioport.h>
 
 int dev_read_u32(const struct udevice *dev, const char *propname, u32 *outp)
 {
@@ -359,3 +360,19 @@ int dev_get_child_count(const struct udevice *dev)
 {
 	return ofnode_get_child_count(dev_ofnode(dev));
 }
+
+int dev_read_pci_bus_range(const struct udevice *dev,
+			   struct resource *res)
+{
+	const u32 *values;
+	int len;
+
+	values = dev_read_prop(dev, "bus-range", &len);
+	if (!values || len < sizeof(*values) * 2)
+		return -EINVAL;
+
+	res->start = *values++;
+	res->end = *values;
+
+	return 0;
+}
include/dm/read.h +12 -0
index 487ec9e9c9..ac7ec5dd79 100644
@@ -680,6 +680,18 @@ int dev_read_alias_highest_id(const char *stem);
  */
 int dev_get_child_count(const struct udevice *dev);
 
+/**
+ * dev_read_pci_bus_range - Read PCI bus-range resource
+ *
+ * Look at the bus range property of a device node and return the pci bus
+ * range for this node.
+ *
+ * @dev: device to examine
+ * @res returns the resource
+ * @return 0 if ok, negative on error
+ */
+int dev_read_pci_bus_range(const struct udevice *dev, struct resource *res);
+
 #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
 
 static inline int dev_read_u32(const struct udevice *dev,
Signature · 1 line
2.28.0
#4 lore raw

PATCH v2 3/25 pci: pci-uclass: Remove #ifdef CONFIG_NR_DRAM_BANKS as its always set

In reply to Stefan Roese

Since the migration to Kconfig, CONFIG_NR_DRAM_BANKS is configured for all boards. Hence we can remove the conditional compilation and the code path that will never get compiled.

---

Changes in v2:
- Add Reviewed-by tag from Simon

Changes in v1:
- New patch

 drivers/pci/pci-uclass.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
drivers/pci/pci-uclass.c +1 -16
index 40cc9f1090..601557a875 100644
@@ -871,6 +871,7 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
 			   ofnode node)
 {
 	int pci_addr_cells, addr_cells, size_cells;
+	struct bd_info *bd = gd->bd;
 	int cells_per_record;
 	const u32 *prop;
 	int len;
@@ -938,9 +939,6 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
 	}
 
 	/* Add a region for our local memory */
-#ifdef CONFIG_NR_DRAM_BANKS
-	struct bd_info *bd = gd->bd;
-
 	if (!bd)
 		return;
 
@@ -958,19 +956,6 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
 				       PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
 		}
 	}
-#else
-	phys_addr_t base = 0, size;
-
-	size = gd->ram_size;
-#ifdef CONFIG_SYS_SDRAM_BASE
-	base = CONFIG_SYS_SDRAM_BASE;
-#endif
-	if (gd->pci_ram_top && gd->pci_ram_top < base + size)
-		size = gd->pci_ram_top - base;
-	if (size)
-		pci_set_region(hose->regions + hose->region_count++, base,
-			base, size, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
-#endif
 
 	return;
 }
Signature · 1 line
2.28.0
#5 lore raw

PATCH v2 4/25 ARM: renesas: Drop unnecessary function ft_board_setup()

In reply to Stefan Roese

Marek explained on IRC, that ft_board_setup() is not used / necessary at all. So its best to just drop it completely, as it interferes with the cleanup of CONFIG_MAX_PCI_REGIONS (completely removed).

---

(no changes since v1)

 board/renesas/rcar-common/common.c | 48 ------------------------------
 1 file changed, 48 deletions(-)
board/renesas/rcar-common/common.c +0 -48
index 83dd288847..777d8c8e0f 100644
@@ -42,51 +42,3 @@ int dram_init_banksize(void)
 
 	return 0;
 }
-
-#if CONFIG_IS_ENABLED(OF_BOARD_SETUP) && CONFIG_IS_ENABLED(PCI)
-int ft_board_setup(void *blob, struct bd_info *bd)
-{
-	struct udevice *dev;
-	struct uclass *uc;
-	fdt_addr_t regs_addr;
-	int i, off, ret;
-
-	ret = uclass_get(UCLASS_PCI, &uc);
-	if (ret)
-		return ret;
-
-	uclass_foreach_dev(dev, uc) {
-		struct pci_controller hose = { 0 };
-
-		for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-			if (hose.region_count == MAX_PCI_REGIONS) {
-				printf("maximum number of regions parsed, aborting\n");
-				break;
-			}
-
-			if (bd->bi_dram[i].size) {
-				pci_set_region(&hose.regions[hose.region_count++],
-					       bd->bi_dram[i].start,
-					       bd->bi_dram[i].start,
-					       bd->bi_dram[i].size,
-					       PCI_REGION_MEM |
-					       PCI_REGION_PREFETCH |
-					       PCI_REGION_SYS_MEMORY);
-			}
-		}
-
-		regs_addr = devfdt_get_addr_index(dev, 0);
-		off = fdt_node_offset_by_compat_reg(blob,
-				"renesas,pcie-rcar-gen3", regs_addr);
-		if (off < 0) {
-			printf("Failed to find PCIe node@%llx\n", regs_addr);
-			return off;
-		}
-
-		fdt_pci_dma_ranges(blob, off, &hose);
-	}
-
-	return 0;
-}
-#endif
-#endif
Signature · 1 line
2.28.0
#6 lore raw

PATCH v2 4/25 ARM: renesas: Drop unnecessary function ft_board_setup()

Quoted 8 lines · Stefan Roese

Marek explained on IRC, that ft_board_setup() is not used / necessary at all. So its best to just drop it completely, as it interferes with the cleanup of CONFIG_MAX_PCI_REGIONS (completely removed).

Quoted 7 lines

---

(no changes since v1)

 board/renesas/rcar-common/common.c | 48 ------------------------------
 1 file changed, 48 deletions(-)
#7 lore raw

PATCH v2 5/25 pci: pci-uclass: Dynamically allocate the PCI regions

In reply to Stefan Roese

Instead of using a fixed length pre-allocated array of regions, this patch moves to dynamically allocating the regions based on the number of available regions plus the necessary regions for DRAM banks.

Since MAX_PCI_REGIONS is not needed any more, its removed completely with this patch.

Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Marek Vasut <[email protected]>

---

Changes in v2:
- Split changes in board/renesas/rcar-common/common.c into separate patch

Changes in v1:
- New patch, replaces increase of MAX_PCI_REGIONS to 10

 drivers/pci/pci-uclass.c | 14 ++++++++------
 include/pci.h            |  4 +---
 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/pci/pci-uclass.c +8 -6
index 601557a875..337ac137d1 100644
@@ -874,6 +874,7 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
 	struct bd_info *bd = gd->bd;
 	int cells_per_record;
 	const u32 *prop;
+	int max_regions;
 	int len;
 	int i;
 
@@ -893,7 +894,13 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
 	hose->region_count = 0;
 	debug("%s: len=%d, cells_per_record=%d\n", __func__, len,
 	      cells_per_record);
-	for (i = 0; i < MAX_PCI_REGIONS; i++, len -= cells_per_record) {
+
+	/* Dynamically allocate the regions array */
+	max_regions = len / cells_per_record + CONFIG_NR_DRAM_BANKS;
+	hose->regions = (struct pci_region *)
+		calloc(1, max_regions * sizeof(struct pci_region));
+
+	for (i = 0; i < max_regions; i++, len -= cells_per_record) {
 		u64 pci_addr, addr, size;
 		int space_code;
 		u32 flags;
@@ -943,11 +950,6 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
 		return;
 
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
-		if (hose->region_count == MAX_PCI_REGIONS) {
-			pr_err("maximum number of regions parsed, aborting\n");
-			break;
-		}
-
 		if (bd->bi_dram[i].size) {
 			pci_set_region(hose->regions + hose->region_count++,
 				       bd->bi_dram[i].start,
include/pci.h +1 -3
index 2089db9f16..da755af852 100644
@@ -590,8 +590,6 @@ extern void pci_cfgfunc_do_nothing(struct pci_controller* hose, pci_dev_t dev,
 extern void pci_cfgfunc_config_device(struct pci_controller* hose, pci_dev_t dev,
 				      struct pci_config_table *);
 
-#define MAX_PCI_REGIONS		7
-
 #define INDIRECT_TYPE_NO_PCIE_LINK	1
 
 /**
@@ -632,7 +630,7 @@ struct pci_controller {
 	 * for PCI controllers and a separate UCLASS (or perhaps
 	 * UCLASS_PCI_GENERIC) is used for bridges.
 	 */
-	struct pci_region regions[MAX_PCI_REGIONS];
+	struct pci_region *regions;
 	int region_count;
 
 	struct pci_config_table *config_table;
Signature · 1 line
2.28.0
#8 lore raw

PATCH v2 5/25 pci: pci-uclass: Dynamically allocate the PCI regions

Quoted 20 lines · Stefan Roese

Instead of using a fixed length pre-allocated array of regions, this patch moves to dynamically allocating the regions based on the number of available regions plus the necessary regions for DRAM banks.

Since MAX_PCI_REGIONS is not needed any more, its removed completely with this patch.

Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Marek Vasut <[email protected]>

---

Changes in v2:
- Split changes in board/renesas/rcar-common/common.c into separate patch

Quoted 6 lines

Changes in v1:
- New patch, replaces increase of MAX_PCI_REGIONS to 10

 drivers/pci/pci-uclass.c | 14 ++++++++------
 include/pci.h            |  4 +---
 2 files changed, 9 insertions(+), 9 deletions(-)
#9 lore raw

PATCH v2 6/25 pci: pci-uclass: Fix incorrect argument in map_physmem

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Fix argument ordering for map_physmem() called in dm_pci_map_ea_bar(). Additinally minor spelling correction.

---

Changes in v2:
- Add Reviewed-by tag from Simon
- Correct patch subject
- Correct patch description in commit text
- Minor spelling update

Changes in v1:
- Change patch subject

 drivers/pci/pci-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pci-uclass.c +2 -2
index 337ac137d1..fde5b83adf 100644
@@ -1424,7 +1424,7 @@ static void *dm_pci_map_ea_bar(struct udevice *dev, int bar, int flags,
 		}
 
 		/* size ignored for now */
-		return map_physmem(addr, flags, 0);
+		return map_physmem(addr, 0, flags);
 	}
 
 	return 0;
@@ -1450,7 +1450,7 @@ void *dm_pci_map_bar(struct udevice *dev, int bar, int flags)
 
 	/*
 	 * Pass "0" as the length argument to pci_bus_to_virt.  The arg
-	 * isn't actualy used on any platform because u-boot assumes a static
+	 * isn't actually used on any platform because U-Boot assumes a static
 	 * linear mapping.  In the future, this could read the BAR size
 	 * and pass that as the size if needed.
 	 */
Signature · 1 line
2.28.0
#10 lore raw

PATCH v2 7/25 pci: pci-uclass: Make DT subnode parse optional

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Parse subnode DT properties only if parent node is valid. Otherwise, assert is triggered on ofnode_valid in ofnode_first_subnode from dev_for_each_subnode.

---

Changes in v2:
- Add Reviewed-by tag from Simon

Changes in v1:
- Change patch subject

 drivers/pci/pci-uclass.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/pci-uclass.c +2 -1
index fde5b83adf..cf1bbccbba 100644
@@ -696,7 +696,8 @@ static int pci_find_and_bind_driver(struct udevice *parent,
 	      find_id->vendor, find_id->device);
 
 	/* Determine optional OF node */
-	pci_dev_find_ofnode(parent, bdf, &node);
+	if (ofnode_valid(dev_ofnode(parent)))
+		pci_dev_find_ofnode(parent, bdf, &node);
 
 	if (ofnode_valid(node) && !ofnode_is_available(node)) {
 		debug("%s: Ignoring disabled device\n", __func__);
Signature · 1 line
2.28.0
#11 lore raw

PATCH v2 8/25 pci: pci-uclass: Add multi entry support for memory regions

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Enable PCI memory regions in ranges property to be of multiple entry. This helps to add support for SoC's like OcteonTX/TX2 where every peripheral is on PCI bus.

---

Changes in v2:
- Add sandbox test

Changes in v1:
- Change patch subject
- Enhance Kconfig help descrition
- Use if() instead of #if

 arch/sandbox/dts/test.dts |  5 +++--
 configs/sandbox_defconfig |  1 +
 drivers/pci/Kconfig       | 10 ++++++++++
 drivers/pci/pci-uclass.c  |  9 ++++++---
 test/dm/pci.c             | 22 ++++++++++++++++++++++
 5 files changed, 42 insertions(+), 5 deletions(-)
arch/sandbox/dts/test.dts +3 -2
index 491893a17d..d3c18eee71 100644
@@ -652,8 +652,9 @@
 		bus-range = <0x00 0xff>;
 		#address-cells = <3>;
 		#size-cells = <2>;
-		ranges = <0x02000000 0 0x30000000 0x30000000 0 0x2000
-				0x01000000 0 0x40000000 0x40000000 0 0x2000>;
+		ranges = <0x02000000 0 0x30000000 0x30000000 0 0x2000 // MEM0
+			  0x02000000 0 0x31000000 0x31000000 0 0x2000 // MEM1
+			  0x01000000 0 0x40000000 0x40000000 0 0x2000>;
 		sandbox,dev-info = <0x08 0x00 0x1234 0x5678
 				    0x0c 0x00 0x1234 0x5678
 				    0x10 0x00 0x1234 0x5678>;
configs/sandbox_defconfig +1 -0
index fe11128904..cc2f8c287c 100644
@@ -180,6 +180,7 @@ CONFIG_NVME=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
+CONFIG_PCI_REGION_MULTI_ENTRY=y
 CONFIG_PCI_SANDBOX=y
 CONFIG_PHY=y
 CONFIG_PHY_SANDBOX=y
drivers/pci/Kconfig +10 -0
index 5e0a39396b..1c47a21101 100644
@@ -43,6 +43,16 @@ config PCI_PNP
 	help
 	  Enable PCI memory and I/O space resource allocation and assignment.
 
+config PCI_REGION_MULTI_ENTRY
+	bool "Enable Multiple entries of region type MEMORY in ranges for PCI"
+	depends on PCI || DM_PCI
+	default n
+	help
+	  Enable PCI memory regions to be of multiple entry. Multiple entry
+	  here refers to allow more than one count of address ranges for MEMORY
+	  region type. This helps to add support for SoC's like OcteonTX/TX2
+	  where every peripheral is on the PCI bus.
+
 config PCIE_ECAM_GENERIC
 	bool "Generic ECAM-based PCI host controller support"
 	default n
drivers/pci/pci-uclass.c +6 -3
index cf1bbccbba..19ea3ae9c1 100644
@@ -936,10 +936,13 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
 		}
 
 		pos = -1;
-		for (i = 0; i < hose->region_count; i++) {
-			if (hose->regions[i].flags == type)
-				pos = i;
+		if (!IS_ENABLED(CONFIG_PCI_REGION_MULTI_ENTRY)) {
+			for (i = 0; i < hose->region_count; i++) {
+				if (hose->regions[i].flags == type)
+					pos = i;
+			}
 		}
+
 		if (pos == -1)
 			pos = hose->region_count++;
 		debug(" - type=%d, pos=%d\n", type, pos);
test/dm/pci.c +22 -0
index fd66ed7899..76490befdf 100644
@@ -354,3 +354,25 @@ static int dm_test_pci_on_bus(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_pci_on_bus, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
+/*
+ * Test support for multiple memory regions enabled via
+ * CONFIG_PCI_REGION_MULTI_ENTRY. When this feature is not enabled,
+ * only the last region of one type is stored. In this test-case,
+ * we have 2 memory regions, the first at 0x3000.0000 and the 2nd
+ * at 0x3100.0000. A correct test results now in BAR1 located at
+ * 0x3000.0000.
+ */
+static int dm_test_pci_region_multi(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+	ulong mem_addr;
+
+	/* Test memory BAR1 on bus#1 */
+	ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x08, 0), &dev));
+	mem_addr = dm_pci_read_bar32(dev, 1);
+	ut_asserteq(mem_addr, 0x30000000);
+
+	return 0;
+}
+DM_TEST(dm_test_pci_region_multi, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
Signature · 1 line
2.28.0
#12 lore raw

PATCH v2 8/25 pci: pci-uclass: Add multi entry support for memory regions

Quoted 22 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

Enable PCI memory regions in ranges property to be of multiple entry. This helps to add support for SoC's like OcteonTX/TX2 where every peripheral is on PCI bus.

---

Changes in v2:
- Add sandbox test

Changes in v1:
- Change patch subject
- Enhance Kconfig help descrition
- Use if() instead of #if

Quoted 6 lines
 arch/sandbox/dts/test.dts |  5 +++--
 configs/sandbox_defconfig |  1 +
 drivers/pci/Kconfig       | 10 ++++++++++
 drivers/pci/pci-uclass.c  |  9 ++++++---
 test/dm/pci.c             | 22 ++++++++++++++++++++++
 5 files changed, 42 insertions(+), 5 deletions(-)
#13 lore raw

PATCH v2 9/25 pci: pci-uclass: Add support for Enhanced Allocation in Bridges

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

If Enhanced Allocation capability is present in bridges, use it to read the fixed sub-ordinate bus number.

---

(no changes since v1)

Changes in v1:
- Change patch subject

 drivers/pci/pci-uclass.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/pci/pci-uclass.c +18 -6
index 19ea3ae9c1..fa6115a105 100644
@@ -620,10 +620,19 @@ int dm_pci_hose_probe_bus(struct udevice *bus)
 {
 	int sub_bus;
 	int ret;
+	int ea_pos;
+	u8 reg;
 
 	debug("%s\n", __func__);
 
-	sub_bus = pci_get_bus_max() + 1;
+	ea_pos = dm_pci_find_capability(bus, PCI_CAP_ID_EA);
+	if (ea_pos) {
+		dm_pci_read_config8(bus, ea_pos + sizeof(u32) + sizeof(u8),
+				    &reg);
+		sub_bus = reg;
+	} else {
+		sub_bus = pci_get_bus_max() + 1;
+	}
 	debug("%s: bus = %d/%s\n", __func__, sub_bus, bus->name);
 	dm_pciauto_prescan_setup_bridge(bus, sub_bus);
 
@@ -633,12 +642,15 @@ int dm_pci_hose_probe_bus(struct udevice *bus)
 		      ret);
 		return ret;
 	}
-	if (sub_bus != bus->seq) {
-		printf("%s: Internal error, bus '%s' got seq %d, expected %d\n",
-		       __func__, bus->name, bus->seq, sub_bus);
-		return -EPIPE;
+
+	if (!ea_pos) {
+		if (sub_bus != bus->seq) {
+			debug("%s: Internal error, bus '%s' got seq %d, expected %d\n",
+			      __func__, bus->name, bus->seq, sub_bus);
+			return -EPIPE;
+		}
+		sub_bus = pci_get_bus_max();
 	}
-	sub_bus = pci_get_bus_max();
 	dm_pciauto_postscan_setup_bridge(bus, sub_bus);
 
 	return sub_bus;
Signature · 1 line
2.28.0
#14 lore raw

PATCH v2 10/25 pci: pci-uclass: Add support for Single-Root I/O Virtualization

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

SR-IOV - Single Root I/O Virtualization
PF - Physical Function VF - Virtual Function

If SR-IOV capability is present, use it to initialize Virtual Function PCI device instances. pci_sriov_init function will read SR-IOV registers to create VF devices under the PF PCI device and also bind driver if available. This function needs to be invoked from Physical function device driver which expects VF device support, creating minimal impact on existing framework.

---

(no changes since v1)

Changes in v1:
- Change patch subject
- Enhance commit text: expanded the abbreviations
- Changed some printf() to debug()
- Changed 0 to '\0' in memset()
- Comments for variables in struct pci_child_platdata added
- Comments for newly introduced functions added in prototype / header

 drivers/pci/Kconfig      |  10 ++++
 drivers/pci/pci-uclass.c | 114 +++++++++++++++++++++++++++++++++++++++
 include/pci.h            |  38 +++++++++++++
 3 files changed, 162 insertions(+)
drivers/pci/Kconfig +10 -0
index 1c47a21101..4635752a95 100644
@@ -53,6 +53,16 @@ config PCI_REGION_MULTI_ENTRY
 	  region type. This helps to add support for SoC's like OcteonTX/TX2
 	  where every peripheral is on the PCI bus.
 
+config PCI_SRIOV
+	bool "Enable Single Root I/O Virtualization support for PCI"
+	depends on PCI || DM_PCI
+	default n
+	help
+	  Say Y here if you want to enable PCI Single Root I/O Virtualization
+	  capability support. This helps to enumerate Virtual Function devices
+	  if available on a PCI Physical Function device and probe for
+	  applicable drivers.
+
 config PCIE_ECAM_GENERIC
 	bool "Generic ECAM-based PCI host controller support"
 	default n
drivers/pci/pci-uclass.c +114 -0

120 lines not on this page · raw message

include/pci.h +38 -0
index da755af852..115d3312a4 100644
@@ -493,6 +493,17 @@
 #define PCI_EXP_SLTCAP		20	/* Slot Capabilities */
 #define  PCI_EXP_SLTCAP_PSN	0xfff80000 /* Physical Slot Number */
 #define PCI_EXP_LNKCTL2		48	/* Link Control 2 */
+/* Single Root I/O Virtualization Registers */
+#define PCI_SRIOV_CAP		0x04	/* SR-IOV Capabilities */
+#define PCI_SRIOV_CTRL		0x08	/* SR-IOV Control */
+#define  PCI_SRIOV_CTRL_VFE	0x01	/* VF Enable */
+#define  PCI_SRIOV_CTRL_MSE	0x08	/* VF Memory Space Enable */
+#define PCI_SRIOV_INITIAL_VF	0x0c	/* Initial VFs */
+#define PCI_SRIOV_TOTAL_VF	0x0e	/* Total VFs */
+#define PCI_SRIOV_NUM_VF	0x10	/* Number of VFs */
+#define PCI_SRIOV_VF_OFFSET	0x14	/* First VF Offset */
+#define PCI_SRIOV_VF_STRIDE	0x16	/* Following VF Stride */
+#define PCI_SRIOV_VF_DID	0x1a	/* VF Device ID */
 
 /* Include the ID list */
 
@@ -890,12 +901,20 @@ struct udevice;
  * @vendor:	PCI vendor ID (see pci_ids.h)
  * @device:	PCI device ID (see pci_ids.h)
  * @class:	PCI class, 3 bytes: (base, sub, prog-if)
+ * @is_virtfn:	True for Virtual Function device
+ * @pfdev:	Handle to Physical Function device
+ * @virtid:	Virtual Function Index
  */
 struct pci_child_platdata {
 	int devfn;
 	unsigned short vendor;
 	unsigned short device;
 	unsigned int class;
+
+	/* Variables for CONFIG_PCI_SRIOV */
+	bool is_virtfn;
+	struct udevice *pfdev;
+	int virtid;
 };
 
 /* PCI bus operations */
@@ -1208,6 +1227,25 @@ int pci_generic_mmap_read_config(
 	ulong *valuep,
 	enum pci_size_t size);
 
+#if defined(CONFIG_PCI_SRIOV)
+/**
+ * pci_sriov_init() - Scan Virtual Function devices
+ *
+ * @pdev:	Physical Function udevice handle
+ * @vf_en:	Number of Virtual Function devices to enable
+ * @return 0 on success, -ve on error
+ */
+int pci_sriov_init(struct udevice *pdev, int vf_en);
+
+/**
+ * pci_sriov_get_totalvfs() - Get total available Virtual Function devices
+ *
+ * @pdev:	Physical Function udevice handle
+ * @return count on success, -ve on error
+ */
+int pci_sriov_get_totalvfs(struct udevice *pdev);
+#endif
+
 #ifdef CONFIG_DM_PCI_COMPAT
 /* Compatibility with old naming */
 static inline int pci_write_config_dword(pci_dev_t pcidev, int offset,
Signature · 1 line
2.28.0
#15 lore raw

PATCH v2 11/25 pci: pci-uclass: Add VF BAR map support for Enhanced Allocation

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Makes dm_pci_map_bar API available to map BAR for Virtual function PCI devices which support Enhanced Allocation.

---

(no changes since v1)

Changes in v1:
- Change patch subject
- Fixed multi-line comment style
- Moved "feature" into new function which is only called, when CONFIG_PCI_SRIOV is enabled, so that the code is not increased in all cases
- Changed variable declaration to use reverse xmas tree order

 drivers/pci/pci-uclass.c | 67 +++++++++++++++++++++++++++++++++++++---
 include/pci.h            |  3 ++
 2 files changed, 65 insertions(+), 5 deletions(-)
drivers/pci/pci-uclass.c +62 -5
index 51871bfe62..23135ebe04 100644
@@ -1409,14 +1409,55 @@ pci_addr_t dm_pci_phys_to_bus(struct udevice *dev, phys_addr_t phys_addr,
 	return bus_addr;
 }
 
+static phys_addr_t dm_pci_map_ea_virt(struct udevice *dev, int ea_off,
+				      struct pci_child_platdata *pdata)
+{
+	phys_addr_t addr = 0;
+
+	/*
+	 * In the case of a Virtual Function device using BAR
+	 * base and size, add offset for VFn BAR(1, 2, 3...n)
+	 */
+	if (pdata->is_virtfn) {
+		size_t sz;
+		u32 ea_entry;
+
+		/* MaxOffset, 1st DW */
+		dm_pci_read_config32(dev, ea_off + 8, &ea_entry);
+		sz = ea_entry & PCI_EA_FIELD_MASK;
+		/* Fill up lower 2 bits */
+		sz |= (~PCI_EA_FIELD_MASK);
+
+		if (ea_entry & PCI_EA_IS_64) {
+			/* MaxOffset 2nd DW */
+			dm_pci_read_config32(dev, ea_off + 16, &ea_entry);
+			sz |= ((u64)ea_entry) << 32;
+		}
+
+		addr = (pdata->virtid - 1) * (sz + 1);
+	}
+
+	return addr;
+}
+
 static void *dm_pci_map_ea_bar(struct udevice *dev, int bar, int flags,
-			       int ea_off)
+			       int ea_off, struct pci_child_platdata *pdata)
 {
 	int ea_cnt, i, entry_size;
 	int bar_id = (bar - PCI_BASE_ADDRESS_0) >> 2;
 	u32 ea_entry;
 	phys_addr_t addr;
 
+	if (IS_ENABLED(CONFIG_PCI_SRIOV)) {
+		/*
+		 * In the case of a Virtual Function device, device is
+		 * Physical function, so pdata will point to required VF
+		 * specific data.
+		 */
+		if (pdata->is_virtfn)
+			bar_id += PCI_EA_BEI_VF_BAR0;
+	}
+
 	/* EA capability structure header */
 	dm_pci_read_config32(dev, ea_off, &ea_entry);
 	ea_cnt = (ea_entry >> 16) & PCI_EA_NUM_ENT_MASK;
@@ -1439,6 +1480,9 @@ static void *dm_pci_map_ea_bar(struct udevice *dev, int bar, int flags,
 			addr |= ((u64)ea_entry) << 32;
 		}
 
+		if (IS_ENABLED(CONFIG_PCI_SRIOV))
+			addr += dm_pci_map_ea_virt(dev, ea_off, pdata);
+
 		/* size ignored for now */
 		return map_physmem(addr, 0, flags);
 	}
@@ -1448,20 +1492,33 @@ static void *dm_pci_map_ea_bar(struct udevice *dev, int bar, int flags,
 
 void *dm_pci_map_bar(struct udevice *dev, int bar, int flags)
 {
+	struct pci_child_platdata *pdata = dev_get_parent_platdata(dev);
+	struct udevice *udev = dev;
 	pci_addr_t pci_bus_addr;
 	u32 bar_response;
 	int ea_off;
 
+	if (IS_ENABLED(CONFIG_PCI_SRIOV)) {
+		/*
+		 * In case of Virtual Function devices, use PF udevice
+		 * as EA capability is defined in Physical Function
+		 */
+		if (pdata->is_virtfn)
+			udev = pdata->pfdev;
+	}
+
 	/*
 	 * if the function supports Enhanced Allocation use that instead of
 	 * BARs
+	 * Incase of virtual functions, pdata will help read VF BEI
+	 * and EA entry size.
 	 */
-	ea_off = dm_pci_find_capability(dev, PCI_CAP_ID_EA);
+	ea_off = dm_pci_find_capability(udev, PCI_CAP_ID_EA);
 	if (ea_off)
-		return dm_pci_map_ea_bar(dev, bar, flags, ea_off);
+		return dm_pci_map_ea_bar(udev, bar, flags, ea_off, pdata);
 
 	/* read BAR address */
-	dm_pci_read_config32(dev, bar, &bar_response);
+	dm_pci_read_config32(udev, bar, &bar_response);
 	pci_bus_addr = (pci_addr_t)(bar_response & ~0xf);
 
 	/*
@@ -1470,7 +1527,7 @@ void *dm_pci_map_bar(struct udevice *dev, int bar, int flags)
 	 * linear mapping.  In the future, this could read the BAR size
 	 * and pass that as the size if needed.
 	 */
-	return dm_pci_bus_to_virt(dev, pci_bus_addr, flags, 0, MAP_NOCACHE);
+	return dm_pci_bus_to_virt(udev, pci_bus_addr, flags, 0, MAP_NOCACHE);
 }
 
 static int _dm_pci_find_next_capability(struct udevice *dev, u8 pos, int cap)
include/pci.h +3 -0
index 115d3312a4..1c5b36617e 100644
@@ -465,6 +465,9 @@
 #define PCI_EA_FIRST_ENT	4	/* First EA Entry in List */
 #define  PCI_EA_ES		0x00000007 /* Entry Size */
 #define  PCI_EA_BEI		0x000000f0 /* BAR Equivalent Indicator */
+/* 9-14 map to VF BARs 0-5 respectively */
+#define  PCI_EA_BEI_VF_BAR0	9
+#define  PCI_EA_BEI_VF_BAR5	14
 /* Base, MaxOffset registers */
 /* bit 0 is reserved */
 #define  PCI_EA_IS_64		0x00000002	/* 64-bit field flag */
Signature · 1 line
2.28.0
#16 lore raw

PATCH v2 12/25 pci: pci-uclass: Add support for Alternate-RoutingID capability

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

If ARI capability is found on device, use it to update next function number in bus scan and also helps to skip unnecessary bdf scans.

---

(no changes since v1)

Changes in v1:
- Change patch subject
- Fixed multi-line comment style
- Added CONFIG_PCI_ARID and enabled the new code optionally, so that the code size is not increased in all cases

 drivers/pci/Kconfig      |  9 +++++++++
 drivers/pci/pci-uclass.c | 26 ++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
drivers/pci/Kconfig +9 -0
index 4635752a95..377806f3b0 100644
@@ -63,6 +63,15 @@ config PCI_SRIOV
 	  if available on a PCI Physical Function device and probe for
 	  applicable drivers.
 
+config PCI_ARID
+        bool "Enable Alternate Routing-ID support for PCI"
+        depends on PCI || DM_PCI
+        default n
+        help
+          Say Y here if you want to enable Alternate Routing-ID capability
+          support on PCI devices. This helps to skip some devices in BDF
+          scan that are not present.
+
 config PCIE_ECAM_GENERIC
 	bool "Generic ECAM-based PCI host controller support"
 	default n
drivers/pci/pci-uclass.c +26 -0
index 23135ebe04..fc60dfe395 100644
@@ -798,6 +798,7 @@ int pci_bind_bus_devices(struct udevice *bus)
 	ulong header_type;
 	pci_dev_t bdf, end;
 	bool found_multi;
+	int ari_off;
 	int ret;
 
 	found_multi = false;
@@ -871,6 +872,31 @@ int pci_bind_bus_devices(struct udevice *bus)
 		pplat->vendor = vendor;
 		pplat->device = device;
 		pplat->class = class;
+
+		if (IS_ENABLED(CONFIG_PCI_ARID)) {
+			ari_off = dm_pci_find_ext_capability(dev,
+							     PCI_EXT_CAP_ID_ARI);
+			if (ari_off) {
+				u16 ari_cap;
+
+				/*
+				 * Read Next Function number in ARI Cap
+				 * Register
+				 */
+				dm_pci_read_config16(dev, ari_off + 4,
+						     &ari_cap);
+				/*
+				 * Update next scan on this function number,
+				 * subtract 1 in BDF to satisfy loop increment.
+				 */
+				if (ari_cap & 0xff00) {
+					bdf = PCI_BDF(PCI_BUS(bdf),
+						      PCI_DEV(ari_cap),
+						      PCI_FUNC(ari_cap));
+					bdf = bdf - 0x100;
+				}
+			}
+		}
 	}
 
 	return 0;
Signature · 1 line
2.28.0
#17 lore raw

PATCH v2 13/25 pci: pci-uclass: Check validity of ofnode

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Add check if the referenced ofnode is valid.

---

Changes in v2:
- Add Reviewed-by tag from Simon

Changes in v1:
- New patch

 drivers/pci/pci-uclass.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/pci/pci-uclass.c +7 -3
index fc60dfe395..d8a6647a1d 100644
@@ -539,7 +539,8 @@ int pci_auto_config_devices(struct udevice *bus)
 		int ret;
 
 		debug("%s: device %s\n", __func__, dev->name);
-		if (dev_read_bool(dev, "pci,no-autoconfig"))
+		if (dev_of_valid(dev) &&
+		    dev_read_bool(dev, "pci,no-autoconfig"))
 			continue;
 		ret = dm_pciauto_config_device(dev);
 		if (ret < 0)
@@ -1025,8 +1026,11 @@ static int pci_uclass_pre_probe(struct udevice *bus)
 	hose->bus = bus;
 	hose->first_busno = bus->seq;
 	hose->last_busno = bus->seq;
-	hose->skip_auto_config_until_reloc =
-		dev_read_bool(bus, "u-boot,skip-auto-config-until-reloc");
+	if (dev_of_valid(bus)) {
+		hose->skip_auto_config_until_reloc =
+			dev_read_bool(bus,
+				      "u-boot,skip-auto-config-until-reloc");
+	}
 
 	return 0;
 }
Signature · 1 line
2.28.0
#18 lore raw

PATCH v2 14/25 arm: include/asm/io.h: Add 64bit clrbits and setbits helpers

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Add 64bit API for clrbits and setbits.

---

(no changes since v1)

Changes in v1:
- Change patch subject
- Add small commit text
- Also add clr/setbits_64 (without endianess extension), which is needed for the updated Octeon device drivers

 arch/arm/include/asm/io.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm/include/asm/io.h +16 -0
index ade1401f3b..df264a170b 100644
@@ -180,16 +180,20 @@ static inline void __raw_readsl(unsigned long addr, void *data, int longlen)
 #define in_le32(a)	in_arch(l,le32,a)
 #define in_le16(a)	in_arch(w,le16,a)
 
+#define out_be64(a,v)	out_arch(l,be64,a,v)
 #define out_be32(a,v)	out_arch(l,be32,a,v)
 #define out_be16(a,v)	out_arch(w,be16,a,v)
 
+#define in_be64(a)	in_arch(l,be64,a)
 #define in_be32(a)	in_arch(l,be32,a)
 #define in_be16(a)	in_arch(w,be16,a)
 
+#define out_64(a,v)	__raw_writeq(v,a)
 #define out_32(a,v)	__raw_writel(v,a)
 #define out_16(a,v)	__raw_writew(v,a)
 #define out_8(a,v)	__raw_writeb(v,a)
 
+#define in_64(a)	__raw_readq(a)
 #define in_32(a)	__raw_readl(a)
 #define in_16(a)	__raw_readw(a)
 #define in_8(a)		__raw_readb(a)
@@ -231,6 +235,18 @@ static inline void __raw_readsl(unsigned long addr, void *data, int longlen)
 #define setbits_8(addr, set) setbits(8, addr, set)
 #define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
 
+#define clrbits_be64(addr, clear) clrbits(be64, addr, clear)
+#define setbits_be64(addr, set) setbits(be64, addr, set)
+#define clrsetbits_be64(addr, clear, set) clrsetbits(be64, addr, clear, set)
+
+#define clrbits_le64(addr, clear) clrbits(le64, addr, clear)
+#define setbits_le64(addr, set) setbits(le64, addr, set)
+#define clrsetbits_le64(addr, clear, set) clrsetbits(le64, addr, clear, set)
+
+#define clrbits_64(addr, clear) clrbits(64, addr, clear)
+#define setbits_64(addr, set) setbits(64, addr, set)
+#define clrsetbits_64(addr, clear, set) clrsetbits(64, addr, clear, set)
+
 /*
  * Now, pick up the machine-defined IO definitions
  */
Signature · 1 line
2.28.0
#19 lore raw

PATCH v2 15/25 arm: octeontx: Add headers for OcteonTX

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

---

Changes in v2:
- Add Reviewed-by tag from Simon

Changes in v1:
- Change patch subject

 arch/arm/include/asm/arch-octeontx/board.h    |  123 ++
 arch/arm/include/asm/arch-octeontx/clock.h    |   25 +
 .../asm/arch-octeontx/csrs/csrs-mio_emm.h     | 1193 +++++++++++++++++
 .../include/asm/arch-octeontx/csrs/csrs-xcv.h |  428 ++++++
 arch/arm/include/asm/arch-octeontx/gpio.h     |    6 +
 arch/arm/include/asm/arch-octeontx/smc.h      |   20 +
 arch/arm/include/asm/arch-octeontx/soc.h      |   33 +
 7 files changed, 1828 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-octeontx/board.h
 create mode 100644 arch/arm/include/asm/arch-octeontx/clock.h
 create mode 100644 arch/arm/include/asm/arch-octeontx/csrs/csrs-mio_emm.h
 create mode 100644 arch/arm/include/asm/arch-octeontx/csrs/csrs-xcv.h
 create mode 100644 arch/arm/include/asm/arch-octeontx/gpio.h
 create mode 100644 arch/arm/include/asm/arch-octeontx/smc.h
 create mode 100644 arch/arm/include/asm/arch-octeontx/soc.h
arch/arm/include/asm/arch-octeontx/board.h new file +123 -0
new file mode 100644
index 0000000000..c9fc3993f8
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier:    GPL-2.0
+ *
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#ifndef __BOARD_H__
+#define __BOARD_H__
+
+#include <asm/arch/soc.h>
+
+#define MAX_LMAC_PER_BGX 4
+#define LMAC_CNT MAX_LMAC_PER_BGX
+
+#if defined(CONFIG_TARGET_OCTEONTX_81XX)
+
+/** Maximum number of BGX interfaces per CPU node */
+#define MAX_BGX_PER_NODE	3
+#define OCTEONTX_XCV	/* RGMII Interface */
+
+#elif defined(CONFIG_TARGET_OCTEONTX_83XX)
+
+/** Maximum number of BGX interfaces per CPU node */
+#define MAX_BGX_PER_NODE	4
+
+#endif
+
+/** Reg offsets */
+#define RST_BOOT	0x87E006001600ULL
+
+/** Structure definitions */
+
+/**
+ * Register (RSL) rst_boot
+ *
+ * RST Boot Register This register is not accessible through ROM scripts;
+ * see SCR_WRITE32_S[ADDR].
+ */
+union rst_boot {
+	u64 u;
+	struct rst_boot_s {
+		u64 rboot_pin                        : 1;
+		u64 rboot                            : 1;
+		u64 reserved_2_32                    : 31;
+		u64 pnr_mul                          : 6;
+		u64 reserved_39                      : 1;
+		u64 c_mul                            : 7;
+		u64 reserved_47_52                   : 6;
+		u64 gpio_ejtag                       : 1;
+		u64 mcp_jtagdis                      : 1;
+		u64 dis_scan                         : 1;
+		u64 dis_huk                          : 1;
+		u64 vrm_err                          : 1;
+		u64 jt_tstmode                       : 1;
+		u64 ckill_ppdis                      : 1;
+		u64 trusted_mode                     : 1;
+		u64 reserved_61_62                   : 2;
+		u64 chipkill                         : 1;
+	} s;
+	struct rst_boot_cn81xx {
+		u64 rboot_pin                        : 1;
+		u64 rboot                            : 1;
+		u64 lboot                            : 10;
+		u64 lboot_ext23                      : 6;
+		u64 lboot_ext45                      : 6;
+		u64 lboot_jtg                        : 1;
+		u64 lboot_ckill                      : 1;
+		u64 reserved_26_29                   : 4;
+		u64 lboot_oci                        : 3;
+		u64 pnr_mul                          : 6;
+		u64 reserved_39                      : 1;
+		u64 c_mul                            : 7;
+		u64 reserved_47_54                   : 8;
+		u64 dis_scan                         : 1;
+		u64 dis_huk                          : 1;
+		u64 vrm_err                          : 1;
+		u64 jt_tstmode                       : 1;
+		u64 ckill_ppdis                      : 1;
+		u64 trusted_mode                     : 1;
+		u64 ejtagdis                         : 1;
+		u64 jtcsrdis                         : 1;
+		u64 chipkill                         : 1;
+	} cn81xx;
+	struct rst_boot_cn83xx {
+		u64 rboot_pin                        : 1;
+		u64 rboot                            : 1;
+		u64 lboot                            : 10;
+		u64 lboot_ext23                      : 6;
+		u64 lboot_ext45                      : 6;
+		u64 lboot_jtg                        : 1;
+		u64 lboot_ckill                      : 1;
+		u64 lboot_pf_flr                     : 4;
+		u64 lboot_oci                        : 3;
+		u64 pnr_mul                          : 6;
+		u64 reserved_39                      : 1;
+		u64 c_mul                            : 7;
+		u64 reserved_47_54                   : 8;
+		u64 dis_scan                         : 1;
+		u64 dis_huk                          : 1;
+		u64 vrm_err                          : 1;
+		u64 jt_tstmode                       : 1;
+		u64 ckill_ppdis                      : 1;
+		u64 trusted_mode                     : 1;
+		u64 ejtagdis                         : 1;
+		u64 jtcsrdis                         : 1;
+		u64 chipkill                         : 1;
+	} cn83xx;
+};
+
+extern unsigned long fdt_base_addr;
+
+/** Function definitions */
+void mem_map_fill(void);
+int octeontx_board_has_pmp(void);
+const char *fdt_get_board_model(void);
+const char *fdt_get_board_serial(void);
+const char *fdt_get_board_revision(void);
+void fdt_parse_phy_info(void);
+void fdt_board_get_ethaddr(int bgx, int lmac, unsigned char *eth);
+void bgx_set_board_info(int bgx_id, int *mdio_bus, int *phy_addr,
+			bool *autoneg_dis, bool *lmac_reg, bool *lmac_enable);
+#endif /* __BOARD_H__ */
arch/arm/include/asm/arch-octeontx/clock.h new file +25 -0
new file mode 100644
index 0000000000..7bf600a1f2
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier:    GPL-2.0
+ *
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#ifndef __CLOCK_H__
+#define __CLOCK_H__
+
+/** System PLL reference clock */
+#define PLL_REF_CLK                     50000000        /* 50 MHz */
+#define NS_PER_REF_CLK_TICK             (1000000000 / PLL_REF_CLK)
+
+/**
+ * Returns the I/O clock speed in Hz
+ */
+u64 octeontx_get_io_clock(void);
+
+/**
+ * Returns the core clock speed in Hz
+ */
+u64 octeontx_get_core_clock(void);
+
+#endif /* __CLOCK_H__ */
arch/arm/include/asm/arch-octeontx/csrs/csrs-mio_emm.h new file +1193 -0

1,193 lines not on this page · raw message

arch/arm/include/asm/arch-octeontx/csrs/csrs-xcv.h new file +428 -0

428 lines not on this page · raw message

arch/arm/include/asm/arch-octeontx/gpio.h new file +6 -0
new file mode 100644
index 0000000000..3943ffd952
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier:    GPL-2.0
+ *
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
arch/arm/include/asm/arch-octeontx/smc.h new file +20 -0
new file mode 100644
index 0000000000..beff4d158f
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier:    GPL-2.0
+ *
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#ifndef __SMC_H__
+#define __SMC_H__
+
+/* OcteonTX Service Calls version numbers */
+#define OCTEONTX_VERSION_MAJOR	0x1
+#define OCTEONTX_VERSION_MINOR	0x0
+
+/* x1 - node number */
+#define OCTEONTX_DRAM_SIZE	0xc2000301
+
+ssize_t smc_dram_size(unsigned int node);
+
+#endif /* __SMC_H__ */
arch/arm/include/asm/arch-octeontx/soc.h new file +33 -0
new file mode 100644
index 0000000000..dc081c70b2
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier:    GPL-2.0
+ *
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#ifndef __SOC_H__
+#define __SOC_H__
+
+/* Product PARTNUM */
+#define CN81XX	0xA2
+#define CN83XX	0xA3
+#define CN96XX	0xB2
+#define CN95XX	0xB3
+
+#define otx_is_altpkg()	read_alt_pkg()
+#define otx_is_soc(soc)	(read_partnum() == (soc))
+#define otx_is_board(model) (!strcmp(read_board_name(), model))
+#define otx_is_platform(platform) (read_platform() == (platform))
+
+enum platform {
+	PLATFORM_HW = 0,
+	PLATFORM_EMULATOR = 1,
+	PLATFORM_ASIM = 3,
+};
+
+int read_platform(void);
+u8 read_partnum(void);
+const char *read_board_name(void);
+bool read_alt_pkg(void);
+
+#endif /* __SOC_H */
Signature · 1 line
2.28.0
#20 lore raw

PATCH v2 16/25 arm: octeontx2: Add headers for OcteonTX2

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

---

(no changes since v1)

Changes in v1:
- Change patch subject

 arch/arm/include/asm/arch-octeontx2/board.h   |   128 +
 arch/arm/include/asm/arch-octeontx2/clock.h   |    24 +
 .../asm/arch-octeontx2/csrs/csrs-cgx.h        |  7851 ++++++++++++
 .../asm/arch-octeontx2/csrs/csrs-lmt.h        |    60 +
 .../asm/arch-octeontx2/csrs/csrs-mio_emm.h    |  1193 ++
 .../asm/arch-octeontx2/csrs/csrs-nix.h        | 10404 ++++++++++++++++
 .../asm/arch-octeontx2/csrs/csrs-npa.h        |  2294 ++++
 .../asm/arch-octeontx2/csrs/csrs-npc.h        |  1629 +++
 .../asm/arch-octeontx2/csrs/csrs-rvu.h        |  2276 ++++
 arch/arm/include/asm/arch-octeontx2/gpio.h    |     6 +
 arch/arm/include/asm/arch-octeontx2/smc-id.h  |    32 +
 arch/arm/include/asm/arch-octeontx2/smc.h     |    18 +
 arch/arm/include/asm/arch-octeontx2/soc.h     |    33 +
 13 files changed, 25948 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-octeontx2/board.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/clock.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-cgx.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-lmt.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-mio_emm.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-nix.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-npa.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-npc.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/csrs/csrs-rvu.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/gpio.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/smc-id.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/smc.h
 create mode 100644 arch/arm/include/asm/arch-octeontx2/soc.h
arch/arm/include/asm/arch-octeontx2/board.h new file +128 -0
new file mode 100644
index 0000000000..1c9ec113ca
@@ -0,0 +1,128 @@
+/* SPDX-License-Identifier:    GPL-2.0
+ *
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#ifndef __BOARD_H__
+#define __BOARD_H__
+
+#include <asm/arch/soc.h>
+
+/** Reg offsets */
+#define RST_BOOT		0x87E006001600ULL
+
+#define CPC_BOOT_OWNERX(a)	0x86D000000160ULL + (8 * (a))
+
+/** Structure definitions */
+/**
+ * Register (NCB32b) cpc_boot_owner#
+ *
+ * CPC Boot Owner Registers These registers control an external arbiter
+ * for the boot device (SPI/eMMC) across multiple external devices. There
+ * is a register for each requester: _ \<0\> - SCP          - reset on
+ * SCP reset _ \<1\> - MCP          - reset on MCP reset _ \<2\> - AP
+ * Secure    - reset on core reset _ \<3\> - AP Nonsecure - reset on core
+ * reset  These register is only writable to the corresponding
+ * requestor(s) permitted with CPC_PERMIT.
+ */
+union cpc_boot_ownerx {
+	u32 u;
+	struct cpc_boot_ownerx_s {
+		u32 boot_req		: 1;
+		u32 reserved_1_7	: 7;
+		u32 boot_wait		: 1;
+		u32 reserved_9_31	: 23;
+	} s;
+};
+
+/**
+ * Register (RSL) rst_boot
+ *
+ * RST Boot Register This register is not accessible through ROM scripts;
+ * see SCR_WRITE32_S[ADDR].
+ */
+union rst_boot {
+	u64 u;
+	struct rst_boot_s {
+		u64 rboot_pin                        : 1;
+		u64 rboot                            : 1;
+		u64 reserved_2_32                    : 31;
+		u64 pnr_mul                          : 6;
+		u64 reserved_39                      : 1;
+		u64 c_mul                            : 7;
+		u64 reserved_47_52                   : 6;
+		u64 gpio_ejtag                       : 1;
+		u64 mcp_jtagdis                      : 1;
+		u64 dis_scan                         : 1;
+		u64 dis_huk                          : 1;
+		u64 vrm_err                          : 1;
+		u64 jt_tstmode                       : 1;
+		u64 ckill_ppdis                      : 1;
+		u64 trusted_mode                     : 1;
+		u64 reserved_61_62                   : 2;
+		u64 chipkill                         : 1;
+	} s;
+	struct rst_boot_cn96xx {
+		u64 rboot_pin                        : 1;
+		u64 rboot                            : 1;
+		u64 reserved_2_23                    : 22;
+		u64 cpt_mul                          : 7;
+		u64 reserved_31_32                   : 2;
+		u64 pnr_mul                          : 6;
+		u64 reserved_39                      : 1;
+		u64 c_mul                            : 7;
+		u64 reserved_47_52                   : 6;
+		u64 gpio_ejtag                       : 1;
+		u64 mcp_jtagdis                      : 1;
+		u64 dis_scan                         : 1;
+		u64 dis_huk                          : 1;
+		u64 vrm_err                          : 1;
+		u64 reserved_58_59                   : 2;
+		u64 trusted_mode                     : 1;
+		u64 scp_jtagdis                      : 1;
+		u64 jtagdis                          : 1;
+		u64 chipkill                         : 1;
+	} cn96xx;
+	struct rst_boot_cnf95xx {
+		u64 rboot_pin                        : 1;
+		u64 rboot                            : 1;
+		u64 reserved_2_7                     : 6;
+		u64 bphy_mul                         : 7;
+		u64 reserved_15                      : 1;
+		u64 dsp_mul                          : 7;
+		u64 reserved_23                      : 1;
+		u64 cpt_mul                          : 7;
+		u64 reserved_31_32                   : 2;
+		u64 pnr_mul                          : 6;
+		u64 reserved_39                      : 1;
+		u64 c_mul                            : 7;
+		u64 reserved_47_52                   : 6;
+		u64 gpio_ejtag                       : 1;
+		u64 mcp_jtagdis                      : 1;
+		u64 dis_scan                         : 1;
+		u64 dis_huk                          : 1;
+		u64 vrm_err                          : 1;
+		u64 reserved_58_59                   : 2;
+		u64 trusted_mode                     : 1;
+		u64 scp_jtagdis                      : 1;
+		u64 jtagdis                          : 1;
+		u64 chipkill                         : 1;
+	} cnf95xx;
+};
+
+extern unsigned long fdt_base_addr;
+
+/** Function definitions */
+void mem_map_fill(void);
+int fdt_get_board_mac_cnt(void);
+u64 fdt_get_board_mac_addr(void);
+const char *fdt_get_board_model(void);
+const char *fdt_get_board_serial(void);
+const char *fdt_get_board_revision(void);
+void octeontx2_board_get_mac_addr(u8 index, u8 *mac_addr);
+void board_acquire_flash_arb(bool acquire);
+void cgx_intf_shutdown(void);
+
+#endif /* __BOARD_H__ */
arch/arm/include/asm/arch-octeontx2/clock.h new file +24 -0
new file mode 100644
index 0000000000..7be8852a55
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier:    GPL-2.0
+ *
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#ifndef __CLOCK_H__
+
+/** System PLL reference clock */
+#define PLL_REF_CLK                     50000000        /* 50 MHz */
+#define NS_PER_REF_CLK_TICK             (1000000000 / PLL_REF_CLK)
+
+/**
+ * Returns the I/O clock speed in Hz
+ */
+u64 octeontx_get_io_clock(void);
+
+/**
+ * Returns the core clock speed in Hz
+ */
+u64 octeontx_get_core_clock(void);
+
+#endif /* __CLOCK_H__ */
arch/arm/include/asm/arch-octeontx2/csrs/csrs-cgx.h new file +7851 -0

2,848 lines not on this page · raw message

arch/arm/include/asm/arch-octeontx2/csrs/csrs-lmt.h new file +60 -0

60 lines not on this page · raw message

arch/arm/include/asm/arch-octeontx2/csrs/csrs-mio_emm.h new file +1193 -0

1,193 lines not on this page · raw message

arch/arm/include/asm/arch-octeontx2/csrs/csrs-nix.h new file +10404 -0

10,404 lines not on this page · raw message

arch/arm/include/asm/arch-octeontx2/csrs/csrs-npa.h new file +2294 -0

2,294 lines not on this page · raw message

arch/arm/include/asm/arch-octeontx2/csrs/csrs-npc.h new file +1629 -0

1,629 lines not on this page · raw message

arch/arm/include/asm/arch-octeontx2/csrs/csrs-rvu.h new file +2276 -0

2,276 lines not on this page · raw message

arch/arm/include/asm/arch-octeontx2/gpio.h new file +6 -0
new file mode 100644
index 0000000000..3943ffd952

Lines of this file are not shown. View the raw message.

arch/arm/include/asm/arch-octeontx2/smc-id.h new file +32 -0
new file mode 100644
index 0000000000..93a81b2954

Lines of this file are not shown. View the raw message.

arch/arm/include/asm/arch-octeontx2/smc.h new file +18 -0
new file mode 100644
index 0000000000..8e719a2aad

Lines of this file are not shown. View the raw message.

arch/arm/include/asm/arch-octeontx2/soc.h new file +33 -0
new file mode 100644
index 0000000000..9cf6628da4

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.28.0

Part of the diff is not shown here. View the raw message.

#21 lore raw

PATCH v2 17/25 ata: ahci: Add BAR index quirk for Cavium PCI SATA device

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

For SATA controller found on OcteonTX SoC's, use non-standard PCI BAR0 instead of BAR5.

---

Changes in v2:
- Add Reviewed-by tag from Simon
- Add note about adding a Kconfig option for AHCI quirks, once there are multiple quirks

Changes in v1:
- Change patch subject
- Use constants from pci_ids.h instead of hardcoded values

 drivers/ata/ahci.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/ata/ahci.c +15 -0
index 47cdea1f58..22bc0d3b10 100644
@@ -1198,10 +1198,25 @@ int ahci_probe_scsi(struct udevice *ahci_dev, ulong base)
 int ahci_probe_scsi_pci(struct udevice *ahci_dev)
 {
 	ulong base;
+	u16 vendor, device;
 
 	base = (ulong)dm_pci_map_bar(ahci_dev, PCI_BASE_ADDRESS_5,
 				     PCI_REGION_MEM);
 
+	/*
+	 * Note:
+	 * Right now, we have only one quirk here, which is not enough to
+	 * introduce a new Kconfig option to select this. Once we have more
+	 * quirks in this AHCI code, we should add a Kconfig option for
+	 * this though.
+	 */
+	dm_pci_read_config16(ahci_dev, PCI_VENDOR_ID, &vendor);
+	dm_pci_read_config16(ahci_dev, PCI_DEVICE_ID, &device);
+
+	if (vendor == PCI_VENDOR_ID_CAVIUM &&
+	    device == PCI_DEVICE_ID_CAVIUM_SATA)
+		base = (uintptr_t)dm_pci_map_bar(ahci_dev, PCI_BASE_ADDRESS_0,
+						 PCI_REGION_MEM);
 	return ahci_probe_scsi(ahci_dev, base);
 }
 #endif
Signature · 1 line
2.28.0
#22 lore raw

PATCH v2 18/25 pci: Add PCI controller driver for OcteonTX / TX2

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Adds support for PCI ECAM/PEM controllers found on OcteonTX or OcteonTX2 SoC platforms.

---

Changes in v2:
- Add Reviewed-by tag from Simon
- Add comments to enum declaration and "type" declaration
- Return -EINVAL in default case statement for unsupported length
- Add helper function octeontx_bdf_invalid() and return -EPERM in case of an errror
- Use livetree API

Changes in v1:
- Change patch subject
- Remove inclusion of common.h
- Remove #ifdef's and use driver specific data instead
- Add comments to struct
- Add some helper functions to reduce code size
- Misc coding style changes (blank lines etc)
- Use debug() instead of printf() in some cases

 drivers/pci/Kconfig        |   8 +
 drivers/pci/Makefile       |   1 +
 drivers/pci/pci_octeontx.c | 364 +++++++++++++++++++++++++++++++++++++
 3 files changed, 373 insertions(+)
 create mode 100644 drivers/pci/pci_octeontx.c
drivers/pci/Kconfig +8 -0
index 377806f3b0..06d39df1d3 100644
@@ -149,6 +149,14 @@ config PCI_TEGRA
 	  with a total of 5 lanes. Some boards require this for Ethernet
 	  support to work (e.g. beaver, jetson-tk1).
 
+config PCI_OCTEONTX
+	bool "OcteonTX PCI support"
+	depends on (ARCH_OCTEONTX || ARCH_OCTEONTX2)
+	help
+	  Enable support for the OcteonTX/TX2 SoC family ECAM/PEM controllers.
+	  These controllers provide PCI configuration access to all on-board
+	  peripherals so it should only be disabled for testing purposes
+
 config PCI_XILINX
 	bool "Xilinx AXI Bridge for PCI Express"
 	depends on DM_PCI
drivers/pci/Makefile +1 -0
index 9db90fb53c..8b4d49a590 100644
@@ -49,3 +49,4 @@ obj-$(CONFIG_PCI_KEYSTONE) += pcie_dw_ti.o
 obj-$(CONFIG_PCIE_MEDIATEK) += pcie_mediatek.o
 obj-$(CONFIG_PCIE_ROCKCHIP) += pcie_rockchip.o
 obj-$(CONFIG_PCI_BRCMSTB) += pcie_brcmstb.o
+obj-$(CONFIG_PCI_OCTEONTX) += pci_octeontx.o
drivers/pci/pci_octeontx.c new file +364 -0

364 lines not on this page · raw message

Signature · 1 line
2.28.0
#23 lore raw

PATCH v2 19/25 mmc: Add MMC controller driver for OcteonTX / TX2

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Adds support for MMC controllers found on OcteonTX or OcteonTX2 SoC platforms.

---

Changes in v2:
- Remove local mmc_power_init() call

Changes in v1:
- Change patch subject
- Rebased on latest TOT
- Removed inclusion of common.h
- Fix most checkpatch errors / warnings (use IS_ENABLED etc)

 drivers/mmc/Kconfig          |    9 +
 drivers/mmc/Makefile         |    1 +
 drivers/mmc/octeontx_hsmmc.c | 3897 ++++++++++++++++++++++++++++++++++
 drivers/mmc/octeontx_hsmmc.h |  207 ++
 4 files changed, 4114 insertions(+)
 create mode 100644 drivers/mmc/octeontx_hsmmc.c
 create mode 100644 drivers/mmc/octeontx_hsmmc.h
drivers/mmc/Kconfig +9 -0
index 556b3ac489..669e40d7b2 100644
@@ -305,6 +305,15 @@ config MMC_PCI
 	  This selects PCI-based MMC controllers.
 	  If you have an MMC controller on a PCI bus, say Y here.
 
+config MMC_OCTEONTX
+	bool "Marvell OcteonTX Multimedia Card Interface support"
+	depends on (ARCH_OCTEONTX || ARCH_OCTEONTX2)
+	depends on DM_MMC
+	help
+	  This selects the OcteonTX Multimedia card Interface.
+	  If you have an OcteonTX/TX2 board with a Multimedia Card slot,
+	  say Y here.
+
 	  If unsure, say N.
 
 config PXA_MMC_GENERIC
drivers/mmc/Makefile +1 -0
index d375669a7b..22266ec8ec 100644
@@ -36,6 +36,7 @@ obj-$(CONFIG_MVEBU_MMC) += mvebu_mmc.o
 obj-$(CONFIG_MMC_OMAP_HS)		+= omap_hsmmc.o
 obj-$(CONFIG_MMC_MXC)			+= mxcmmc.o
 obj-$(CONFIG_MMC_MXS)			+= mxsmmc.o
+obj-$(CONFIG_MMC_OCTEONTX)		+= octeontx_hsmmc.o
 obj-$(CONFIG_MMC_PCI)			+= pci_mmc.o
 obj-$(CONFIG_PXA_MMC_GENERIC) += pxa_mmc_gen.o
 obj-$(CONFIG_$(SPL_TPL_)SUPPORT_EMMC_RPMB) += rpmb.o
drivers/mmc/octeontx_hsmmc.c new file +3897 -0

2,978 lines not on this page · raw message

drivers/mmc/octeontx_hsmmc.h new file +207 -0

207 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.28.0

Part of the diff is not shown here. View the raw message.

#24 lore raw

PATCH v2 20/25 mtd: nand: Add NAND controller driver for OcteonTX

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Adds support for NAND controllers found on OcteonTX or OcteonTX2 SoC platforms. Also includes driver to support Hardware ECC using BCH HW engine found on these platforms.

---

(no changes since v1)

Changes in v1:
- Change patch subject

 drivers/mtd/nand/raw/Kconfig             |   16 +
 drivers/mtd/nand/raw/Makefile            |    2 +
 drivers/mtd/nand/raw/octeontx_bch.c      |  425 ++++
 drivers/mtd/nand/raw/octeontx_bch.h      |  133 ++
 drivers/mtd/nand/raw/octeontx_bch_regs.h |  169 ++
 drivers/mtd/nand/raw/octeontx_nand.c     | 2263 ++++++++++++++++++++++
 6 files changed, 3008 insertions(+)
 create mode 100644 drivers/mtd/nand/raw/octeontx_bch.c
 create mode 100644 drivers/mtd/nand/raw/octeontx_bch.h
 create mode 100644 drivers/mtd/nand/raw/octeontx_bch_regs.h
 create mode 100644 drivers/mtd/nand/raw/octeontx_nand.c
drivers/mtd/nand/raw/Kconfig +16 -0
index 06b2ff972c..5d86fe470d 100644
@@ -291,6 +291,22 @@ config NAND_ZYNQ_USE_BOOTLOADER1_TIMINGS
 	  This flag prevent U-boot reconfigure NAND flash controller and reuse
 	  the NAND timing from 1st stage bootloader.
 
+config NAND_OCTEONTX
+	bool "Support for OcteonTX NAND controller"
+	select SYS_NAND_SELF_INIT
+	imply CMD_NAND
+	help
+	 This enables Nand flash controller hardware found on the OcteonTX
+	 processors.
+
+config NAND_OCTEONTX_HW_ECC
+	bool "Support Hardware ECC for OcteonTX NAND controller"
+	depends on NAND_OCTEONTX
+	default y
+	help
+	 This enables Hardware BCH engine found on the OcteonTX processors to
+	 support ECC for NAND flash controller.
+
 config NAND_STM32_FMC2
 	bool "Support for NAND controller on STM32MP SoCs"
 	depends on ARCH_STM32MP
drivers/mtd/nand/raw/Makefile +2 -0
index 9337f6482e..24c51b6924 100644
@@ -58,6 +58,8 @@ obj-$(CONFIG_NAND_VF610_NFC) += vf610_nfc.o
 obj-$(CONFIG_NAND_MXC) += mxc_nand.o
 obj-$(CONFIG_NAND_MXS) += mxs_nand.o
 obj-$(CONFIG_NAND_MXS_DT) += mxs_nand_dt.o
+obj-$(CONFIG_NAND_OCTEONTX) += octeontx_nand.o
+obj-$(CONFIG_NAND_OCTEONTX_HW_ECC) += octeontx_bch.o
 obj-$(CONFIG_NAND_PXA3XX) += pxa3xx_nand.o
 obj-$(CONFIG_NAND_SPEAR) += spr_nand.o
 obj-$(CONFIG_TEGRA_NAND) += tegra_nand.o
drivers/mtd/nand/raw/octeontx_bch.c new file +425 -0

425 lines not on this page · raw message

drivers/mtd/nand/raw/octeontx_bch.h new file +133 -0

133 lines not on this page · raw message

drivers/mtd/nand/raw/octeontx_bch_regs.h new file +169 -0

169 lines not on this page · raw message

drivers/mtd/nand/raw/octeontx_nand.c new file +2263 -0

2,243 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.28.0

Part of the diff is not shown here. View the raw message.

#25 lore raw

PATCH v2 21/25 net: Add NIC controller driver for OcteonTX

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Adds support for Network Interface controllers found on OcteonTX SoC platforms.

---

(no changes since v1)

Changes in v1:
- Change patch subject
- Rebased on latest TOT
- Removed inclusion of common.h

 drivers/net/Kconfig                 |   14 +
 drivers/net/Makefile                |    2 +
 drivers/net/octeontx/Makefile       |    9 +
 drivers/net/octeontx/bgx.c          | 1572 +++++++++++++++++++++++++++
 drivers/net/octeontx/bgx.h          |  259 +++++
 drivers/net/octeontx/nic.h          |  510 +++++++++
 drivers/net/octeontx/nic_main.c     |  780 +++++++++++++
 drivers/net/octeontx/nic_reg.h      |  252 +++++
 drivers/net/octeontx/nicvf_main.c   |  583 ++++++++++
 drivers/net/octeontx/nicvf_queues.c | 1142 +++++++++++++++++++
 drivers/net/octeontx/nicvf_queues.h |  355 ++++++
 drivers/net/octeontx/q_struct.h     |  697 ++++++++++++
 drivers/net/octeontx/smi.c          |  383 +++++++
 drivers/net/octeontx/xcv.c          |  129 +++
 14 files changed, 6687 insertions(+)
 create mode 100644 drivers/net/octeontx/Makefile
 create mode 100644 drivers/net/octeontx/bgx.c
 create mode 100644 drivers/net/octeontx/bgx.h
 create mode 100644 drivers/net/octeontx/nic.h
 create mode 100644 drivers/net/octeontx/nic_main.c
 create mode 100644 drivers/net/octeontx/nic_reg.h
 create mode 100644 drivers/net/octeontx/nicvf_main.c
 create mode 100644 drivers/net/octeontx/nicvf_queues.c
 create mode 100644 drivers/net/octeontx/nicvf_queues.h
 create mode 100644 drivers/net/octeontx/q_struct.h
 create mode 100644 drivers/net/octeontx/smi.c
 create mode 100644 drivers/net/octeontx/xcv.c
drivers/net/Kconfig +14 -0
index ecd779d979..6f077bad58 100644
@@ -407,6 +407,20 @@ config MT7628_ETH
 	  The MediaTek MT7628 ethernet interface is used on MT7628 and
 	  MT7688 based boards.
 
+config NET_OCTEONTX
+	bool "OcteonTX Ethernet support"
+	depends on ARCH_OCTEONTX
+	depends on PCI_SRIOV
+	help
+	  You must select Y to enable network device support for
+	  OcteonTX SoCs. If unsure, say n
+config OCTEONTX_SMI
+	bool "OcteonTX SMI Device support"
+	depends on ARCH_OCTEONTX || ARCH_OCTEONTX2
+	help
+	  You must select Y to enable SMI controller support for
+	  OcteonTX or OcteonTX2 SoCs. If unsure, say n
+
 config PCH_GBE
 	bool "Intel Platform Controller Hub EG20T GMAC driver"
 	depends on DM_ETH && DM_PCI
drivers/net/Makefile +2 -0
index 1ecdc40b8f..bee9680f76 100644
@@ -65,6 +65,8 @@ obj-$(CONFIG_RENESAS_RAVB) += ravb.o
 obj-$(CONFIG_SMC91111) += smc91111.o
 obj-$(CONFIG_SMC911X) += smc911x.o
 obj-$(CONFIG_TSEC_ENET) += tsec.o fsl_mdio.o
+obj-$(CONFIG_NET_OCTEONTX) += octeontx/
+obj-$(CONFIG_OCTEONTX_SMI) += octeontx/smi.o
 obj-$(CONFIG_FMAN_ENET) += fsl_mdio.o
 obj-$(CONFIG_ULI526X) += uli526x.o
 obj-$(CONFIG_VSC7385_ENET) += vsc7385.o
drivers/net/octeontx/Makefile new file +9 -0
new file mode 100644
index 0000000000..170f1f41cd
@@ -0,0 +1,9 @@
+#/* SPDX-License-Identifier:    GPL-2.0
+# *
+# * Copyright (C) 2018 Marvell International Ltd.
+# *
+# * https://spdx.org/licenses
+# */
+
+obj-$(CONFIG_NET_OCTEONTX) += bgx.o nic_main.o nicvf_queues.o nicvf_main.o \
+				xcv.o
drivers/net/octeontx/bgx.c new file +1572 -0

1,572 lines not on this page · raw message

drivers/net/octeontx/bgx.h new file +259 -0

259 lines not on this page · raw message

drivers/net/octeontx/nic.h new file +510 -0

510 lines not on this page · raw message

drivers/net/octeontx/nic_main.c new file +780 -0

622 lines not on this page · raw message

drivers/net/octeontx/nic_reg.h new file +252 -0

252 lines not on this page · raw message

drivers/net/octeontx/nicvf_main.c new file +583 -0

583 lines not on this page · raw message

drivers/net/octeontx/nicvf_queues.c new file +1142 -0

1,142 lines not on this page · raw message

drivers/net/octeontx/nicvf_queues.h new file +355 -0

355 lines not on this page · raw message

drivers/net/octeontx/q_struct.h new file +697 -0

697 lines not on this page · raw message

drivers/net/octeontx/smi.c new file +383 -0

383 lines not on this page · raw message

drivers/net/octeontx/xcv.c new file +129 -0

129 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.28.0

Part of the diff is not shown here. View the raw message.

#26 lore raw

PATCH v2 22/25 net: Add NIC controller driver for OcteonTX2

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Adds support for Network Interface controllers found on OcteonTX2 SoC platforms.

---

(no changes since v1)

Changes in v1:
- Change patch subject
- Rebased on latest TOT
- Removed inclusion of common.h

 drivers/net/Kconfig                |   17 +
 drivers/net/Makefile               |    2 +
 drivers/net/octeontx2/Makefile     |   11 +
 drivers/net/octeontx2/cgx.c        |  298 ++++++++
 drivers/net/octeontx2/cgx.h        |  107 +++
 drivers/net/octeontx2/cgx_intf.c   |  717 ++++++++++++++++++
 drivers/net/octeontx2/cgx_intf.h   |  450 ++++++++++++
 drivers/net/octeontx2/lmt.h        |   51 ++
 drivers/net/octeontx2/nix.c        |  833 +++++++++++++++++++++
 drivers/net/octeontx2/nix.h        |  355 +++++++++
 drivers/net/octeontx2/nix_af.c     | 1104 ++++++++++++++++++++++++++++
 drivers/net/octeontx2/npc.h        |   92 +++
 drivers/net/octeontx2/rvu.h        |  121 +++
 drivers/net/octeontx2/rvu_af.c     |  173 +++++
 drivers/net/octeontx2/rvu_common.c |   73 ++
 drivers/net/octeontx2/rvu_pf.c     |  118 +++
 16 files changed, 4522 insertions(+)
 create mode 100644 drivers/net/octeontx2/Makefile
 create mode 100644 drivers/net/octeontx2/cgx.c
 create mode 100644 drivers/net/octeontx2/cgx.h
 create mode 100644 drivers/net/octeontx2/cgx_intf.c
 create mode 100644 drivers/net/octeontx2/cgx_intf.h
 create mode 100644 drivers/net/octeontx2/lmt.h
 create mode 100644 drivers/net/octeontx2/nix.c
 create mode 100644 drivers/net/octeontx2/nix.h
 create mode 100644 drivers/net/octeontx2/nix_af.c
 create mode 100644 drivers/net/octeontx2/npc.h
 create mode 100644 drivers/net/octeontx2/rvu.h
 create mode 100644 drivers/net/octeontx2/rvu_af.c
 create mode 100644 drivers/net/octeontx2/rvu_common.c
 create mode 100644 drivers/net/octeontx2/rvu_pf.c
drivers/net/Kconfig +17 -0
index 6f077bad58..84b0910f9b 100644
@@ -414,6 +414,15 @@ config NET_OCTEONTX
 	help
 	  You must select Y to enable network device support for
 	  OcteonTX SoCs. If unsure, say n
+
+config NET_OCTEONTX2
+	bool "OcteonTX2 Ethernet support"
+	depends on ARCH_OCTEONTX2
+	select OCTEONTX2_CGX_INTF
+	help
+	  You must select Y to enable network device support for
+	  OcteonTX2 SoCs. If unsure, say n
+
 config OCTEONTX_SMI
 	bool "OcteonTX SMI Device support"
 	depends on ARCH_OCTEONTX || ARCH_OCTEONTX2
@@ -421,6 +430,14 @@ config OCTEONTX_SMI
 	  You must select Y to enable SMI controller support for
 	  OcteonTX or OcteonTX2 SoCs. If unsure, say n
 
+config OCTEONTX2_CGX_INTF
+	bool "OcteonTX2 CGX ATF interface support"
+	depends on ARCH_OCTEONTX2
+	default y if ARCH_OCTEONTX2
+	help
+	  You must select Y to enable CGX ATF interface support for
+	  OcteonTX2 SoCs. If unsure, say n
+
 config PCH_GBE
 	bool "Intel Platform Controller Hub EG20T GMAC driver"
 	depends on DM_ETH && DM_PCI
drivers/net/Makefile +2 -0
index bee9680f76..c07b5ad698 100644
@@ -66,7 +66,9 @@ obj-$(CONFIG_SMC91111) += smc91111.o
 obj-$(CONFIG_SMC911X) += smc911x.o
 obj-$(CONFIG_TSEC_ENET) += tsec.o fsl_mdio.o
 obj-$(CONFIG_NET_OCTEONTX) += octeontx/
+obj-$(CONFIG_NET_OCTEONTX2) += octeontx2/
 obj-$(CONFIG_OCTEONTX_SMI) += octeontx/smi.o
+obj-$(CONFIG_OCTEONTX2_CGX_INTF) += octeontx2/cgx_intf.o
 obj-$(CONFIG_FMAN_ENET) += fsl_mdio.o
 obj-$(CONFIG_ULI526X) += uli526x.o
 obj-$(CONFIG_VSC7385_ENET) += vsc7385.o
drivers/net/octeontx2/Makefile new file +11 -0
new file mode 100644
index 0000000000..92183ffc3e
@@ -0,0 +1,11 @@
+#/*
+# * Copyright (C) 2018 Marvell International Ltd.
+# *
+# * SPDX-License-Identifier:    GPL-2.0
+# * https://spdx.org/licenses
+# */
+
+
+obj-$(CONFIG_NET_OCTEONTX2) += cgx.o nix_af.o nix.o rvu_pf.o \
+				rvu_af.o rvu_common.o
+
drivers/net/octeontx2/cgx.c new file +298 -0

298 lines not on this page · raw message

drivers/net/octeontx2/cgx.h new file +107 -0

107 lines not on this page · raw message

drivers/net/octeontx2/cgx_intf.c new file +717 -0

717 lines not on this page · raw message

drivers/net/octeontx2/cgx_intf.h new file +450 -0

450 lines not on this page · raw message

drivers/net/octeontx2/lmt.h new file +51 -0

51 lines not on this page · raw message

drivers/net/octeontx2/nix.c new file +833 -0

833 lines not on this page · raw message

drivers/net/octeontx2/nix.h new file +355 -0

355 lines not on this page · raw message

drivers/net/octeontx2/nix_af.c new file +1104 -0

140 lines not on this page · raw message

drivers/net/octeontx2/npc.h new file +92 -0

92 lines not on this page · raw message

drivers/net/octeontx2/rvu.h new file +121 -0

121 lines not on this page · raw message

drivers/net/octeontx2/rvu_af.c new file +173 -0

173 lines not on this page · raw message

drivers/net/octeontx2/rvu_common.c new file +73 -0

73 lines not on this page · raw message

drivers/net/octeontx2/rvu_pf.c new file +118 -0

118 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.28.0

Part of the diff is not shown here. View the raw message.

#27 lore raw

PATCH v2 23/25 watchdog: Add reset support for OcteonTX / TX2

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Adds support for Core 0 watchdog poke on OcteonTX and OcteonTX2 platforms.

---

Changes in v2:
- Add Reviewed-by tag from Simon
- Add CORE0_POKE_OFFSET_MASK and calculate poke register address in _probe() instead of repeatedly in _reset()
- Slightly change the Kconfig entry: use "default y", it already depends on "WDT && (ARCH_OCTEONTX || ARCH_OCTEONTX2)"

Changes in v1:
- Change patch subject
- Remove inclusion of common.h
- Remove global wdt_dev as its unused
- Remove #ifdef's
- Remove optional fixed register access - only use address passed via DT while probing
- Use dev_remap_addr() instead of dev_read_addr_index()

 drivers/watchdog/Kconfig        | 10 +++++
 drivers/watchdog/Makefile       |  1 +
 drivers/watchdog/octeontx_wdt.c | 66 +++++++++++++++++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 drivers/watchdog/octeontx_wdt.c
drivers/watchdog/Kconfig +10 -0
index 0ebf116b12..210d9f8093 100644
@@ -139,6 +139,16 @@ config WDT_MTK
 	  The watchdog timer is stopped when initialized.
 	  It performs full SoC reset.
 
+config WDT_OCTEONTX
+	bool "OcteonTX core watchdog support"
+	depends on WDT && (ARCH_OCTEONTX || ARCH_OCTEONTX2)
+	default y
+	imply WATCHDOG
+	help
+	  This enables OcteonTX watchdog driver, which can be
+	  found on OcteonTX/TX2 chipsets and inline with driver model.
+	  Only supports watchdog reset.
+
 config WDT_OMAP3
 	bool "TI OMAP watchdog timer support"
 	depends on WDT && ARCH_OMAP2PLUS
drivers/watchdog/Makefile +1 -0
index 111e258195..01b8231f2b 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o
 obj-$(CONFIG_WDT_MPC8xx) += mpc8xx_wdt.o
 obj-$(CONFIG_WDT_MT7621) += mt7621_wdt.o
 obj-$(CONFIG_WDT_MTK) += mtk_wdt.o
+obj-$(CONFIG_WDT_OCTEONTX) += octeontx_wdt.o
 obj-$(CONFIG_WDT_OMAP3) += omap_wdt.o
 obj-$(CONFIG_WDT_SBSA) += sbsa_gwdt.o
 obj-$(CONFIG_WDT_K3_RTI) += rti_wdt.o
drivers/watchdog/octeontx_wdt.c new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
2.28.0
#28 lore raw

PATCH v2 24/25 arm: octeontx: Add support for OcteonTX SoC platforms

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

This patch adds support for all OcteonTX 81xx/83xx boards from Marvell.
For 81xx boards, use octeontx_81xx_defconfig and for 83xx boards, use octeontx_83xx_defconfig.

---

Changes in v2:
- Select CONFIG_OF_LIVE

Changes in v1:
- Changed patch subject
- Rebased on latest TOT
- Removed inclusion of common.h
- Moved MEMTEST defines to Kconfig
- *.c files checkpatch cleanup

 arch/arm/Kconfig                       |  10 +
 arch/arm/Makefile                      |   1 +
 arch/arm/mach-octeontx/Kconfig         |  23 ++
 arch/arm/mach-octeontx/Makefile        |   9 +
 arch/arm/mach-octeontx/clock.c         |  35 +++
 arch/arm/mach-octeontx/cpu.c           |  76 ++++++
 arch/arm/mach-octeontx/lowlevel_init.S |  33 +++
 board/Marvell/octeontx/Kconfig         |  14 ++
 board/Marvell/octeontx/MAINTAINERS     |   8 +
 board/Marvell/octeontx/Makefile        |   9 +
 board/Marvell/octeontx/board-fdt.c     | 311 +++++++++++++++++++++++++
 board/Marvell/octeontx/board.c         | 152 ++++++++++++
 board/Marvell/octeontx/smc.c           |  25 ++
 board/Marvell/octeontx/soc-utils.c     |  50 ++++
 configs/octeontx_81xx_defconfig        | 134 +++++++++++
 configs/octeontx_83xx_defconfig        | 129 ++++++++++
 drivers/mtd/nand/raw/octeontx_bch.c    |   7 +-
 drivers/mtd/nand/raw/octeontx_nand.c   |  11 +-
 drivers/net/octeontx/bgx.c             |   2 +-
 drivers/net/octeontx/nic_main.c        |   2 +-
 drivers/net/octeontx/nicvf_main.c      |   2 +-
 drivers/net/octeontx/nicvf_queues.c    |   2 +-
 drivers/net/octeontx/smi.c             |   2 +-
 drivers/net/octeontx/xcv.c             |   2 +-
 include/configs/octeontx_common.h      |  89 +++++++
 25 files changed, 1124 insertions(+), 14 deletions(-)
 create mode 100644 arch/arm/mach-octeontx/Kconfig
 create mode 100644 arch/arm/mach-octeontx/Makefile
 create mode 100644 arch/arm/mach-octeontx/clock.c
 create mode 100644 arch/arm/mach-octeontx/cpu.c
 create mode 100644 arch/arm/mach-octeontx/lowlevel_init.S
 create mode 100644 board/Marvell/octeontx/Kconfig
 create mode 100644 board/Marvell/octeontx/MAINTAINERS
 create mode 100644 board/Marvell/octeontx/Makefile
 create mode 100644 board/Marvell/octeontx/board-fdt.c
 create mode 100644 board/Marvell/octeontx/board.c
 create mode 100644 board/Marvell/octeontx/smc.c
 create mode 100644 board/Marvell/octeontx/soc-utils.c
 create mode 100644 configs/octeontx_81xx_defconfig
 create mode 100644 configs/octeontx_83xx_defconfig
 create mode 100644 include/configs/octeontx_common.h
arch/arm/Kconfig +10 -0
index 8401851666..869d255347 100644
@@ -1725,6 +1725,14 @@ config ARCH_ROCKCHIP
 	imply TPL_SYSRESET
 	imply USB_FUNCTION_FASTBOOT
 
+config ARCH_OCTEONTX
+	bool "Support OcteonTX SoCs"
+	select DM
+	select ARM64
+	select OF_CONTROL
+	select OF_LIVE
+	select BOARD_LATE_INIT
+	select SYS_CACHE_SHIFT_7
 config TARGET_THUNDERX_88XX
 	bool "Support ThunderX 88xx"
 	select ARM64
@@ -1823,6 +1831,7 @@ source "arch/arm/mach-lpc32xx/Kconfig"
 
 source "arch/arm/mach-mvebu/Kconfig"
 
+source "arch/arm/mach-octeontx/Kconfig"
 source "arch/arm/cpu/armv7/ls102xa/Kconfig"
 
 source "arch/arm/mach-imx/mx2/Kconfig"
@@ -1906,6 +1915,7 @@ source "board/bosch/guardian/Kconfig"
 source "board/CarMediaLab/flea3/Kconfig"
 source "board/Marvell/aspenite/Kconfig"
 source "board/Marvell/gplugd/Kconfig"
+source "board/Marvell/octeontx/Kconfig"
 source "board/armadeus/apf27/Kconfig"
 source "board/armltd/vexpress/Kconfig"
 source "board/armltd/vexpress64/Kconfig"
arch/arm/Makefile +1 -0
index bf3890e99b..87b4198312 100644
@@ -80,6 +80,7 @@ machine-$(CONFIG_ARCH_STM32MP)		+= stm32mp
 machine-$(CONFIG_ARCH_SUNXI)		+= sunxi
 machine-$(CONFIG_ARCH_TEGRA)		+= tegra
 machine-$(CONFIG_ARCH_U8500)		+= u8500
+machine-$(CONFIG_ARCH_OCTEONTX)		+= octeontx
 machine-$(CONFIG_ARCH_UNIPHIER)		+= uniphier
 machine-$(CONFIG_ARCH_VERSAL)		+= versal
 machine-$(CONFIG_ARCH_ZYNQ)		+= zynq
arch/arm/mach-octeontx/Kconfig new file +23 -0
new file mode 100644
index 0000000000..28ecf9821f
@@ -0,0 +1,23 @@
+if ARCH_OCTEONTX
+
+choice
+	prompt "OcteonTX board select"
+	optional
+
+config TARGET_OCTEONTX_81XX
+	bool "Marvell OcteonTX CN81XX"
+
+config TARGET_OCTEONTX_83XX
+	bool "Marvell OcteonTX CN83XX"
+
+endchoice
+
+config SYS_SOC
+	string
+	default "octeontx"
+
+config SYS_PCI_64BIT
+	bool
+	default y
+
+endif
arch/arm/mach-octeontx/Makefile new file +9 -0
new file mode 100644
index 0000000000..20cb48ad92
@@ -0,0 +1,9 @@
+#/* SPDX-License-Identifier:    GPL-2.0
+# *
+# * Copyright (C) 2018 Marvell International Ltd.
+# *
+# * https://spdx.org/licenses
+# */
+
+obj-y += lowlevel_init.o clock.o cpu.o
+
arch/arm/mach-octeontx/clock.c new file +35 -0
new file mode 100644
index 0000000000..9da21077ec
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier:    GPL-2.0
+/*
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/board.h>
+#include <asm/arch/clock.h>
+
+/**
+ * Returns the I/O clock speed in Hz
+ */
+u64 octeontx_get_io_clock(void)
+{
+	union rst_boot rst_boot;
+
+	rst_boot.u = readq(RST_BOOT);
+
+	return rst_boot.s.pnr_mul * PLL_REF_CLK;
+}
+
+/**
+ * Returns the core clock speed in Hz
+ */
+u64 octeontx_get_core_clock(void)
+{
+	union rst_boot rst_boot;
+
+	rst_boot.u = readq(RST_BOOT);
+
+	return rst_boot.s.c_mul * PLL_REF_CLK;
+}
arch/arm/mach-octeontx/cpu.c new file +76 -0

76 lines not on this page · raw message

arch/arm/mach-octeontx/lowlevel_init.S new file +33 -0
new file mode 100644
index 0000000000..41a9f08aed
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier:    GPL-2.0
+ *
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+#include <asm/macro.h>
+
+.align 8
+.global fdt_base_addr
+fdt_base_addr:
+	.dword 0x0
+
+.global save_boot_params
+save_boot_params:
+	/* Read FDT base from x1 register passed by ATF */
+	adr	x21, fdt_base_addr
+	str	x1, [x21]
+
+	/* Returns */
+	b	save_boot_params_ret
+
+ENTRY(lowlevel_init)
+	mov	x29, lr			/* Save LR */
+
+	/* any lowlevel init should go here */
+
+	mov	lr, x29			/* Restore LR */
+	ret
+ENDPROC(lowlevel_init)
board/Marvell/octeontx/Kconfig new file +14 -0
new file mode 100644
index 0000000000..45d115916c
@@ -0,0 +1,14 @@
+if TARGET_OCTEONTX_81XX || TARGET_OCTEONTX_83XX
+
+config SYS_VENDOR
+	string
+	default	"Marvell"
+
+config SYS_BOARD
+	string
+	default "octeontx"
+
+config SYS_CONFIG_NAME
+	default "octeontx_common"
+
+endif
board/Marvell/octeontx/MAINTAINERS new file +8 -0
new file mode 100644
index 0000000000..1f3b12b1ab
@@ -0,0 +1,8 @@
+OCTEONTX BOARD
+M:	Aaron Williams <[email protected]>
+S:	Maintained
+F:	board/Marvell/octeontx/
+F:	include/configs/octeontx_81xx.h
+F:	include/configs/octeontx_83xx.h
+F:	configs/octeontx_81xx_defconfig
+F:	configs/octeontx_83xx_defconfig
board/Marvell/octeontx/Makefile new file +9 -0
new file mode 100644
index 0000000000..fbe32ae003
@@ -0,0 +1,9 @@
+#/*
+# * Copyright (C) 2018 Marvell International Ltd.
+# *
+# * SPDX-License-Identifier:    GPL-2.0
+# * https://spdx.org/licenses
+# */
+
+obj-y	:= board.o smc.o soc-utils.o
+obj-$(CONFIG_OF_LIBFDT) += board-fdt.o
board/Marvell/octeontx/board-fdt.c new file +311 -0

311 lines not on this page · raw message

board/Marvell/octeontx/board.c new file +152 -0

152 lines not on this page · raw message

board/Marvell/octeontx/smc.c new file +25 -0
new file mode 100644
index 0000000000..5eeba2358b
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier:    GPL-2.0
+/*
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#include <asm/global_data.h>
+#include <asm/ptrace.h>
+#include <asm/system.h>
+#include <asm/arch/smc.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+ssize_t smc_dram_size(unsigned int node)
+{
+	struct pt_regs regs;
+
+	regs.regs[0] = OCTEONTX_DRAM_SIZE;
+	regs.regs[1] = node;
+	smc_call(&regs);
+
+	return regs.regs[0];
+}
+
board/Marvell/octeontx/soc-utils.c new file +50 -0

50 lines not on this page · raw message

configs/octeontx_81xx_defconfig new file +134 -0

134 lines not on this page · raw message

configs/octeontx_83xx_defconfig new file +129 -0

129 lines not on this page · raw message

drivers/mtd/nand/raw/octeontx_bch.c +4 -3
index c38cbb9526..0ac432a029 100644
@@ -5,16 +5,17 @@
  * https://spdx.org/licenses
  */
 
-#include <common.h>
+#include <dm.h>
+#include <dm/of_access.h>
 #include <malloc.h>
 #include <memalign.h>
 #include <pci.h>
 #include <pci_ids.h>
 #include <nand.h>
-#include <dm.h>
-#include <dm/of_access.h>
+#include <time.h>
 #include <linux/bitfield.h>
 #include <linux/ctype.h>
+#include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <linux/ioport.h>
drivers/mtd/nand/raw/octeontx_nand.c +6 -5
index 847e9f9c58..b2f55f1143 100644
@@ -5,18 +5,19 @@
  * https://spdx.org/licenses
  */
 
-#include <common.h>
-#include <malloc.h>
-#include <memalign.h>
-#include <pci.h>
-#include <nand.h>
 #include <dm.h>
 #include <dm/of_access.h>
 #include <dm/devres.h>
 #include <dm/device-internal.h>
+#include <malloc.h>
+#include <memalign.h>
+#include <pci.h>
+#include <nand.h>
+#include <time.h>
 #include <linux/bitfield.h>
 #include <linux/ctype.h>
 #include <linux/dma-mapping.h>
+#include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <linux/ioport.h>
drivers/net/octeontx/bgx.c +1 -1
index e08ca71058..0fdf9723c2 100644
@@ -6,7 +6,6 @@
  */
 
 #include <config.h>
-#include <common.h>
 #include <errno.h>
 #include <net.h>
 #include <dm.h>
@@ -18,6 +17,7 @@
 #include <miiphy.h>
 #include <asm/io.h>
 #include <asm/arch/board.h>
+#include <linux/delay.h>
 
 #ifdef CONFIG_OF_LIBFDT
  #include <linux/libfdt.h>
drivers/net/octeontx/nic_main.c +1 -1
index 799b4d70e2..faf13126d5 100644
@@ -6,7 +6,6 @@
  */
 
 #include <config.h>
-#include <common.h>
 #include <net.h>
 #include <netdev.h>
 #include <malloc.h>
@@ -16,6 +15,7 @@
 #include <pci.h>
 #include <pci_ids.h>
 #include <asm/io.h>
+#include <linux/delay.h>
 
 #include "nic_reg.h"
 #include "nic.h"
drivers/net/octeontx/nicvf_main.c +1 -1
index 3d90ecc735..e4af9f90ed 100644
@@ -6,7 +6,6 @@
  */
 
 #include <config.h>
-#include <common.h>
 #include <dm.h>
 #include <pci.h>
 #include <pci_ids.h>
@@ -14,6 +13,7 @@
 #include <misc.h>
 #include <malloc.h>
 #include <asm/io.h>
+#include <linux/delay.h>
 
 #include "nic_reg.h"
 #include "nic.h"
drivers/net/octeontx/nicvf_queues.c +1 -1
index 96d9b90d4c..80a94937e7 100644
@@ -6,11 +6,11 @@
  */
 
 #include <config.h>
-#include <common.h>
 #include <cpu_func.h>
 #include <net.h>
 #include <dm/device.h>
 #include <malloc.h>
+#include <linux/delay.h>
 
 #include "nic_reg.h"
 #include "nic.h"
drivers/net/octeontx/smi.c +1 -1
index bf99aca341..59294e25c7 100644
@@ -5,7 +5,6 @@
  * https://spdx.org/licenses
  */
 
-#include <common.h>
 #include <dm.h>
 #include <pci.h>
 #include <pci_ids.h>
@@ -16,6 +15,7 @@
 #include <asm/io.h>
 #include <env.h>
 #include <linux/ctype.h>
+#include <linux/delay.h>
 
 #define PCI_DEVICE_ID_OCTEONTX_SMI 0xA02B
 
drivers/net/octeontx/xcv.c +1 -1
index 1186157485..5c7974f8fd 100644
@@ -6,7 +6,6 @@
  */
 
 #include <config.h>
-#include <common.h>
 #include <errno.h>
 #include <net.h>
 #include <dm.h>
@@ -16,6 +15,7 @@
 #include <malloc.h>
 #include <miiphy.h>
 #include <asm/io.h>
+#include <linux/delay.h>
 
 #ifdef CONFIG_OF_LIBFDT
  #include <linux/libfdt.h>
include/configs/octeontx_common.h new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
2.28.0
#29 lore raw

PATCH v2 25/25 arm: octeontx2: Add support for OcteonTX2 SoC platforms

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

This patch adds support for all OcteonTX2 96xx/95xx boards from Marvell.
For 96xx boards, use octeontx_96xx_defconfig and for 95xx boards, use octeontx_95xx_defconfig.

---

Changes in v2:
- Select CONFIG_OF_LIVE

Changes in v1:
- Changed patch subject
- Rebased on latest TOT
- Removed inclusion of common.h
- Moved MEMTEST defines to Kconfig
- *.c files checkpatch cleanup
- Add go_uboot cmd for U-Boot starting from RAM

 arch/arm/Kconfig                        |  14 ++
 arch/arm/Makefile                       |   1 +
 arch/arm/mach-octeontx2/Kconfig         |  23 +++
 arch/arm/mach-octeontx2/Makefile        |   9 +
 arch/arm/mach-octeontx2/clock.c         |  35 ++++
 arch/arm/mach-octeontx2/config.mk       |   4 +
 arch/arm/mach-octeontx2/cpu.c           |  72 +++++++
 arch/arm/mach-octeontx2/lowlevel_init.S |  33 ++++
 board/Marvell/octeontx2/Kconfig         |  14 ++
 board/Marvell/octeontx2/MAINTAINERS     |   8 +
 board/Marvell/octeontx2/Makefile        |   9 +
 board/Marvell/octeontx2/board-fdt.c     | 221 +++++++++++++++++++++
 board/Marvell/octeontx2/board.c         | 247 ++++++++++++++++++++++++
 board/Marvell/octeontx2/smc.c           |  58 ++++++
 board/Marvell/octeontx2/soc-utils.c     |  49 +++++
 configs/octeontx2_95xx_defconfig        | 105 ++++++++++
 configs/octeontx2_96xx_defconfig        | 131 +++++++++++++
 include/configs/octeontx2_common.h      |  72 +++++++
 18 files changed, 1105 insertions(+)
 create mode 100644 arch/arm/mach-octeontx2/Kconfig
 create mode 100644 arch/arm/mach-octeontx2/Makefile
 create mode 100644 arch/arm/mach-octeontx2/clock.c
 create mode 100644 arch/arm/mach-octeontx2/config.mk
 create mode 100644 arch/arm/mach-octeontx2/cpu.c
 create mode 100644 arch/arm/mach-octeontx2/lowlevel_init.S
 create mode 100644 board/Marvell/octeontx2/Kconfig
 create mode 100644 board/Marvell/octeontx2/MAINTAINERS
 create mode 100644 board/Marvell/octeontx2/Makefile
 create mode 100644 board/Marvell/octeontx2/board-fdt.c
 create mode 100644 board/Marvell/octeontx2/board.c
 create mode 100644 board/Marvell/octeontx2/smc.c
 create mode 100644 board/Marvell/octeontx2/soc-utils.c
 create mode 100644 configs/octeontx2_95xx_defconfig
 create mode 100644 configs/octeontx2_96xx_defconfig
 create mode 100644 include/configs/octeontx2_common.h
arch/arm/Kconfig +14 -0
index 869d255347..bb219a8058 100644
@@ -1733,6 +1733,16 @@ config ARCH_OCTEONTX
 	select OF_LIVE
 	select BOARD_LATE_INIT
 	select SYS_CACHE_SHIFT_7
+
+config ARCH_OCTEONTX2
+	bool "Support OcteonTX2 SoCs"
+	select DM
+	select ARM64
+	select OF_CONTROL
+	select OF_LIVE
+	select BOARD_LATE_INIT
+	select SYS_CACHE_SHIFT_7
+
 config TARGET_THUNDERX_88XX
 	bool "Support ThunderX 88xx"
 	select ARM64
@@ -1832,6 +1842,9 @@ source "arch/arm/mach-lpc32xx/Kconfig"
 source "arch/arm/mach-mvebu/Kconfig"
 
 source "arch/arm/mach-octeontx/Kconfig"
+
+source "arch/arm/mach-octeontx2/Kconfig"
+
 source "arch/arm/cpu/armv7/ls102xa/Kconfig"
 
 source "arch/arm/mach-imx/mx2/Kconfig"
@@ -1916,6 +1929,7 @@ source "board/CarMediaLab/flea3/Kconfig"
 source "board/Marvell/aspenite/Kconfig"
 source "board/Marvell/gplugd/Kconfig"
 source "board/Marvell/octeontx/Kconfig"
+source "board/Marvell/octeontx2/Kconfig"
 source "board/armadeus/apf27/Kconfig"
 source "board/armltd/vexpress/Kconfig"
 source "board/armltd/vexpress64/Kconfig"
arch/arm/Makefile +1 -0
index 87b4198312..28b523b37c 100644
@@ -81,6 +81,7 @@ machine-$(CONFIG_ARCH_SUNXI)		+= sunxi
 machine-$(CONFIG_ARCH_TEGRA)		+= tegra
 machine-$(CONFIG_ARCH_U8500)		+= u8500
 machine-$(CONFIG_ARCH_OCTEONTX)		+= octeontx
+machine-$(CONFIG_ARCH_OCTEONTX2)	+= octeontx2
 machine-$(CONFIG_ARCH_UNIPHIER)		+= uniphier
 machine-$(CONFIG_ARCH_VERSAL)		+= versal
 machine-$(CONFIG_ARCH_ZYNQ)		+= zynq
arch/arm/mach-octeontx2/Kconfig new file +23 -0
new file mode 100644
index 0000000000..8e5cb0f638
@@ -0,0 +1,23 @@
+if ARCH_OCTEONTX2
+
+choice
+	prompt "OcteonTX2 board select"
+	optional
+
+config TARGET_OCTEONTX2_95XX
+	bool "Marvell OcteonTX2 CN95XX"
+
+config TARGET_OCTEONTX2_96XX
+	bool "Marvell OcteonTX2 CN96XX"
+
+endchoice
+
+config SYS_SOC
+	string
+	default "octeontx2"
+
+config SYS_PCI_64BIT
+	bool
+	default y
+
+endif
arch/arm/mach-octeontx2/Makefile new file +9 -0
new file mode 100644
index 0000000000..c3192343dd
@@ -0,0 +1,9 @@
+#/*
+# * Copyright (C) 2018 Marvell International Ltd.
+# *
+# * SPDX-License-Identifier:    GPL-2.0
+# * https://spdx.org/licenses
+# */
+
+obj-y += lowlevel_init.o clock.o cpu.o
+
arch/arm/mach-octeontx2/clock.c new file +35 -0
new file mode 100644
index 0000000000..9da21077ec
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier:    GPL-2.0
+/*
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/board.h>
+#include <asm/arch/clock.h>
+
+/**
+ * Returns the I/O clock speed in Hz
+ */
+u64 octeontx_get_io_clock(void)
+{
+	union rst_boot rst_boot;
+
+	rst_boot.u = readq(RST_BOOT);
+
+	return rst_boot.s.pnr_mul * PLL_REF_CLK;
+}
+
+/**
+ * Returns the core clock speed in Hz
+ */
+u64 octeontx_get_core_clock(void)
+{
+	union rst_boot rst_boot;
+
+	rst_boot.u = readq(RST_BOOT);
+
+	return rst_boot.s.c_mul * PLL_REF_CLK;
+}
arch/arm/mach-octeontx2/config.mk new file +4 -0
new file mode 100644
index 0000000000..9214f6b742
@@ -0,0 +1,4 @@
+ifeq ($(CONFIG_ARCH_OCTEONTX2),y)
+PLATFORM_CPPFLAGS += $(call cc-option,-march=armv8.2-a,)
+PLATFORM_CPPFLAGS += $(call cc-option,-mtune=octeontx2,)
+endif
arch/arm/mach-octeontx2/cpu.c new file +72 -0

72 lines not on this page · raw message

arch/arm/mach-octeontx2/lowlevel_init.S new file +33 -0
new file mode 100644
index 0000000000..41a9f08aed
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier:    GPL-2.0
+ *
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+#include <asm/macro.h>
+
+.align 8
+.global fdt_base_addr
+fdt_base_addr:
+	.dword 0x0
+
+.global save_boot_params
+save_boot_params:
+	/* Read FDT base from x1 register passed by ATF */
+	adr	x21, fdt_base_addr
+	str	x1, [x21]
+
+	/* Returns */
+	b	save_boot_params_ret
+
+ENTRY(lowlevel_init)
+	mov	x29, lr			/* Save LR */
+
+	/* any lowlevel init should go here */
+
+	mov	lr, x29			/* Restore LR */
+	ret
+ENDPROC(lowlevel_init)
board/Marvell/octeontx2/Kconfig new file +14 -0
new file mode 100644
index 0000000000..99291d795b
@@ -0,0 +1,14 @@
+if TARGET_OCTEONTX2_95XX || TARGET_OCTEONTX2_96XX
+
+config SYS_VENDOR
+	string
+	default	"Marvell"
+
+config SYS_BOARD
+	string
+	default "octeontx2"
+
+config SYS_CONFIG_NAME
+	default "octeontx2_common"
+
+endif
board/Marvell/octeontx2/MAINTAINERS new file +8 -0
new file mode 100644
index 0000000000..eec1d77dd1
@@ -0,0 +1,8 @@
+OCTEONTX2 BOARD
+M:	Aaron Williams <[email protected]>
+S:	Maintained
+F:	board/Marvell/octeontx2/
+F:	include/configs/octeontx2_96xx.h
+F:	include/configs/octeontx2_95xx.h
+F:	configs/octeontx2_96xx_defconfig
+F:	configs/octeontx2_95xx_defconfig
board/Marvell/octeontx2/Makefile new file +9 -0
new file mode 100644
index 0000000000..1f763b197b
@@ -0,0 +1,9 @@
+#/* SPDX-License-Identifier:    GPL-2.0
+# *
+# * Copyright (C) 2018 Marvell International Ltd.
+# *
+# * https://spdx.org/licenses
+# */
+
+obj-y	:= board.o smc.o soc-utils.o
+obj-$(CONFIG_OF_LIBFDT) += board-fdt.o
board/Marvell/octeontx2/board-fdt.c new file +221 -0

221 lines not on this page · raw message

board/Marvell/octeontx2/board.c new file +247 -0

247 lines not on this page · raw message

board/Marvell/octeontx2/smc.c new file +58 -0

58 lines not on this page · raw message

board/Marvell/octeontx2/soc-utils.c new file +49 -0

49 lines not on this page · raw message

configs/octeontx2_95xx_defconfig new file +105 -0

105 lines not on this page · raw message

configs/octeontx2_96xx_defconfig new file +131 -0

131 lines not on this page · raw message

include/configs/octeontx2_common.h new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.28.0