Skip to contentSkip to conversation

arm: Introduce Marvell/Cavium OcteonTX/TX2

PATCH Superseded Stefan Roese 3 participants 67 messages Jul 24, 2020 – Aug 25, 2020

Subsystems (12)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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.

Patches
[1 -11] Add requied changes to PCI framework
- [6] Add support for multi-memory region range
- [7] EA in bridges
- [8] SR-IOV
[12 - 14] Add OcteonTX/TX2 platform header files
[15] AHCI changes
[16 - 22] Add OcteonTX/TX2 drivers
[23 - 24] 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. This patchset is based on top of mainline plus the latest MIPS Octeon patchset:

[PATCH v2 00/10] mips: octeon: Misc Octeon drivers, DT and Kconfig /
defconfig updates

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 v1:
- Added 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
- 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 (2):
pci: pci-uclass: Remove #ifdef CONFIG_NR_DRAM_BANKS as its always set
pci: pci-uclass: Dynamically allocate the PCI regions

Suneel Garapati (22):
fdtdec: Add API to read pci bus-range property
pci: pci-uclass: Fix incorrect argument in map_sysmem
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: Remove static qualifier on mmc_power_init
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                              |    22 +
 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 +
 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            |    10 +-
 configs/octeontx2_95xx_defconfig              |   105 +
 configs/octeontx2_96xx_defconfig              |   131 +
 configs/octeontx_81xx_defconfig               |   134 +
 configs/octeontx_83xx_defconfig               |   129 +
 drivers/ata/ahci.c                            |     8 +
 drivers/mmc/Kconfig                           |     9 +
 drivers/mmc/Makefile                          |     1 +
 drivers/mmc/mmc.c                             |     2 +-
 drivers/mmc/octeontx_hsmmc.c                  |  3904 ++++++
 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                      |   289 +-
 drivers/pci/pci_octeontx.c                    |   344 +
 drivers/watchdog/Kconfig                      |    10 +
 drivers/watchdog/Makefile                     |     1 +
 drivers/watchdog/octeontx_wdt.c               |    57 +
 include/configs/octeontx2_common.h            |    72 +
 include/configs/octeontx_common.h             |    89 +
 include/fdtdec.h                              |    13 +
 include/mmc.h                                 |     1 +
 include/pci.h                                 |    45 +-
 lib/fdtdec.c                                  |    16 +
 106 files changed, 49126 insertions(+), 51 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.27.0
#1 lore raw

PATCH 1/24 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 v1:
- Added 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.27.0
#2 lore raw

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

Quoted 12 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

Add fdtdec_get_pci_bus_range to read bus-range property values.

---

Quoted 7 lines

Changes in v1:
- Added 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(+)

Is the address always 32-bit?

Quoted 55 lines
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 -1
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,
--

2.27.0

#3 lore raw

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

Hi Simon,

Quoted 17 lines · Simon Glass
Quoted 16 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

Add fdtdec_get_pci_bus_range to read bus-range property values.

---

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

Quoted 7 lines
Quoted 3 lines
  include/fdtdec.h | 13 +++++++++++++
  lib/fdtdec.c     | 16 ++++++++++++++++
  2 files changed, 29 insertions(+)

Is the address always 32-bit?

Yes, I think so. Its done in a similar way in the Linux kernel.

Thanks,
Stefan

Quoted 52 lines
Quoted 52 lines
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
 
Quoted 4 lines
Quoted 4 lines
lib/fdtdec.c +0 -1
  uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name,
--

2.27.0

Viele Gr??e,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
#4 lore raw

PATCH 2/24 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.

Cc Tom Rini <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>

---

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 834526c5a4..69fb46d3f4 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.27.0
#5 lore raw

PATCH 2/24 pci: pci-uclass: Remove #ifdef CONFIG_NR_DRAM_BANKS as its always set

Hi Stefan,

Quoted 10 lines · 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.

Cc Tom Rini <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
Quoted 8 lines

---

Changes in v1:
- New patch

 drivers/pci/pci-uclass.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
#6 lore raw

PATCH 3/24 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 v1:
- New patch, replaces increase of MAX_PCI_REGIONS to 10

 board/renesas/rcar-common/common.c | 10 +++++-----
 drivers/pci/pci-uclass.c           | 14 ++++++++------
 include/pci.h                      |  4 +---
 3 files changed, 14 insertions(+), 14 deletions(-)
board/renesas/rcar-common/common.c +5 -5
index 83dd288847..83440c11ef 100644
@@ -58,12 +58,12 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 	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;
-			}
+		/* Dynamically allocate the regions array */
+		hose.regions = (struct pci_region *)
+			calloc(1, CONFIG_NR_DRAM_BANKS *
+			       sizeof(struct pci_region));
 
+		for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
 			if (bd->bi_dram[i].size) {
 				pci_set_region(&hose.regions[hose.region_count++],
 					       bd->bi_dram[i].start,
drivers/pci/pci-uclass.c +8 -6
index 69fb46d3f4..0fbbef70c8 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 281f353916..53f1386fd4 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.27.0
#7 lore raw

PATCH 3/24 pci: pci-uclass: Dynamically allocate the PCI regions

Hi Stefan,

Quoted 16 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]>

---

Quoted 8 lines

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

 board/renesas/rcar-common/common.c | 10 +++++-----
 drivers/pci/pci-uclass.c           | 14 ++++++++------
 include/pci.h                      |  4 +---
 3 files changed, 14 insertions(+), 14 deletions(-)

Can you please split out the generic PCI changes into a separate patch?

Quoted 5 lines
board/renesas/rcar-common/common.c +0 -0
index 83dd288847..83440c11ef 100644

board/renesas/rcar-common/common.c int ft_board_setup(void *blob, struct bd_info *bd) · line 61

Quoted 9 lines
board/renesas/rcar-common/common.c +1 -5
@@ -58,12 +58,12 @@ int ft_board_setup(void *blob, struct bd_info *bd)
        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;
-                       }
+               /* Dynamically allocate the regions array */

Why is the driver allocating this? Shouldn't it happen in pci-uclass.c ?

Quoted 72 lines
board/renesas/rcar-common/common.c +4 -0
+               hose.regions = (struct pci_region *)
+                       calloc(1, CONFIG_NR_DRAM_BANKS *
+                              sizeof(struct pci_region));
 
+               for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
                        if (bd->bi_dram[i].size) {
                                pci_set_region(&hose.regions[hose.region_count++],
                                               bd->bi_dram[i].start,
drivers/pci/pci-uclass.c +8 -6
index 69fb46d3f4..0fbbef70c8 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 -4
index 281f353916..53f1386fd4 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;
--

2.27.0

#8 lore raw

PATCH 3/24 pci: pci-uclass: Dynamically allocate the PCI regions

Hi Simon,

Quoted 22 lines · Simon Glass

Hi Stefan,

Quoted 19 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 v1:
- New patch, replaces increase of MAX_PCI_REGIONS to 10

Quoted 7 lines
Quoted 5 lines
  board/renesas/rcar-common/common.c | 10 +++++-----
  drivers/pci/pci-uclass.c           | 14 ++++++++------
  include/pci.h                      |  4 +---
  3 files changed, 14 insertions(+), 14 deletions(-)

Can you please split out the generic PCI changes into a separate patch?

Okay, will do.

Quoted 8 lines
Quoted 8 lines
board/renesas/rcar-common/common.c +0 -0
index 83dd288847..83440c11ef 100644
@@ -58,12 +58,12 @@ int ft_board_setup(void *blob, struct bd_info *bd)
         uclass_foreach_dev(dev, uc) {
                 struct pci_controller hose = { 0 };
 
Quoted 8 lines

board/renesas/rcar-common/common.c int ft_board_setup(void *blob, struct bd_info *bd) · line 61

Quoted 6 lines
board/renesas/rcar-common/common.c +1 -5
-               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;
-                       }
+               /* Dynamically allocate the regions array */

Why is the driver allocating this? Shouldn't it happen in pci-uclass.c ?

I'm not sure, if the PCI init code has been run before this function is called in all cases. Marek, do you have an answer on this?

Thanks,
Stefan

Quoted 69 lines
Quoted 69 lines
board/renesas/rcar-common/common.c +4 -0
+               hose.regions = (struct pci_region *)
+                       calloc(1, CONFIG_NR_DRAM_BANKS *
+                              sizeof(struct pci_region));
 
+               for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
                         if (bd->bi_dram[i].size) {
                                 pci_set_region(&hose.regions[hose.region_count++],
                                                bd->bi_dram[i].start,
drivers/pci/pci-uclass.c +8 -6
index 69fb46d3f4..0fbbef70c8 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 281f353916..53f1386fd4 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;
 
Quoted 4 lines
Quoted 4 lines
include/pci.h +0 -1
         struct pci_config_table *config_table;
--

2.27.0

Viele Gr??e,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
#9 lore raw

PATCH 3/24 pci: pci-uclass: Dynamically allocate the PCI regions

Hi Marek,

Quoted 54 lines · Stefan Roese

Hi Simon,

Quoted 22 lines · Simon Glass

Hi Stefan,

Quoted 19 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 v1:
- New patch, replaces increase of MAX_PCI_REGIONS to 10

Quoted 7 lines
Quoted 5 lines
? board/renesas/rcar-common/common.c | 10 +++++-----
? drivers/pci/pci-uclass.c?????????? | 14 ++++++++------
? include/pci.h????????????????????? |? 4 +---

? 3 files changed, 14 insertions(+), 14 deletions(-)

Can you please split out the generic PCI changes into a separate patch?

Okay, will do.

Quoted 9 lines
Quoted 9 lines
board/renesas/rcar-common/common.c +0 -0
index 83dd288847..83440c11ef 100644
@@ -58,12 +58,12 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 ???????? uclass_foreach_dev(dev, uc) {
 ???????????????? struct pci_controller hose = { 0 };
 
Quoted 9 lines

board/renesas/rcar-common/common.c int ft_board_setup(void *blob, struct bd_info *bd) · line 62

Quoted 7 lines
board/renesas/rcar-common/common.c +1 -5
-?????????????? 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;
-?????????????????????? }
+?????????????? /* Dynamically allocate the regions array */

Why is the driver allocating this? Shouldn't it happen in pci-uclass.c ?

Quoted 2 lines

I'm not sure, if the PCI init code has been run before this function is called in all cases. Marek, do you have an answer on this?

Marek, again could you please take a look and let us know, why this code is necessary here? And if it is okay to allocate the structs here as well then?

Thanks,
Stefan

Quoted 81 lines

Thanks,
Stefan

Quoted 77 lines
Quoted 77 lines
board/renesas/rcar-common/common.c +4 -0
+?????????????? hose.regions = (struct pci_region *)
+?????????????????????? calloc(1, CONFIG_NR_DRAM_BANKS *
+????????????????????????????? sizeof(struct pci_region));
 
+?????????????? for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
 ???????????????????????? if (bd->bi_dram[i].size) {
 

pci_set_region(&hose.regions[hose.region_count++], ??????????????????????????????????????????????? bd->bi_dram[i].start,

drivers/pci/pci-uclass.c +8 -1
index 69fb46d3f4..0fbbef70c8 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;

drivers/pci/pci-uclass.c +0 -5
@@ -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 +0 -2
index 281f353916..53f1386fd4 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

? /**

include/pci.h +0 -0
@@ -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;

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines

???????? struct pci_config_table *config_table;

Signature · 1 line
2.27.0

Viele Gr??e,
Stefan

Viele Gr??e,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
#10 lore raw

PATCH 4/24 pci: pci-uclass: Fix incorrect argument in map_sysmem

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

Minor spelling correction.

---

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 0fbbef70c8..207302cfc4 100644
@@ -1382,7 +1382,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;
@@ -1408,7 +1408,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.27.0
#11 lore raw

PATCH 4/24 pci: pci-uclass: Fix incorrect argument in map_sysmem

Quoted 4 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

Minor spelling correction.

Need to update this

Quoted 5 lines
Quoted 8 lines

---

Changes in v1:
- Change patch subject

 drivers/pci/pci-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 15 lines
drivers/pci/pci-uclass.c +1 -1
index 0fbbef70c8..207302cfc4 100644
@@ -1382,7 +1382,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;

drivers/pci/pci-uclass.c void *dm_pci_map_bar(struct udevice *dev, int bar, int flags) · line 1411

Quoted 5 lines
drivers/pci/pci-uclass.c +1 -1
@@ -1408,7 +1408,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

U-Boot

Quoted 6 lines
drivers/pci/pci-uclass.c +0 -1
         * linear mapping.  In the future, this could read the BAR size
         * and pass that as the size if needed.
         */
--

2.27.0

#12 lore raw

PATCH 5/24 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 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 207302cfc4..fa2436a0ef 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.27.0
#13 lore raw

PATCH 5/24 pci: pci-uclass: Make DT subnode parse optional

Quoted 11 lines · 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.

Quoted 8 lines

---

Changes in v1:
- Change patch subject

 drivers/pci/pci-uclass.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
#14 lore raw

PATCH 6/24 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 v1:
- Change patch subject
- Enhance Kconfig help descrition
- Use if() instead of #if

 drivers/pci/Kconfig      | 10 ++++++++++
 drivers/pci/pci-uclass.c |  9 ++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)
drivers/pci/Kconfig +10 -0
index ff974e5d74..14c96dd108 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 fa2436a0ef..061ac4e943 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);
Signature · 1 line
2.27.0
#15 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Hi Stefan,

Quoted 14 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.

---

Quoted 8 lines

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

 drivers/pci/Kconfig      | 10 ++++++++++
 drivers/pci/pci-uclass.c |  9 ++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

#16 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Hi Simon,

Quoted 22 lines · Simon Glass

Hi Stefan,

Quoted 19 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 v1:
- Change patch subject
- Enhance Kconfig help descrition
- Use if() instead of #if

Quoted 5 lines
Quoted 3 lines
  drivers/pci/Kconfig      | 10 ++++++++++
  drivers/pci/pci-uclass.c |  9 ++++++---
  2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

Okay. But how should I handle all these defconfig changes with regard to the other patches in this series, introducing multiple new PCI related Kconfig options. With 3 new Kconfig options, all permutations would lead to 8 (2 ^ 3) different defconfig files. This does not scale.

I might be missing something here though - perhaps this is easier to achieve.

Thanks,
Stefan

#17 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Hi Stefan,

Quoted 32 lines · Stefan Roese

Hi Simon,

Quoted 22 lines · Simon Glass

Hi Stefan,

Quoted 19 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 v1:
- Change patch subject
- Enhance Kconfig help descrition
- Use if() instead of #if

Quoted 5 lines
Quoted 3 lines
  drivers/pci/Kconfig      | 10 ++++++++++
  drivers/pci/pci-uclass.c |  9 ++++++---
  2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

Quoted 8 lines

Okay. But how should I handle all these defconfig changes with regard to the other patches in this series, introducing multiple new PCI related Kconfig options. With 3 new Kconfig options, all permutations would lead to 8 (2 ^ 3) different defconfig files. This does not scale.

I might be missing something here though - perhaps this is easier to achieve.

For sandbox, turn on all options and then add a new PCI bus that uses this functionality. If there are lots of combinations you could add 8 new buses, but I'm hoping that isn't necessary?

Regards,
Simon

#18 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Hi Simon,

Quoted 41 lines · Simon Glass

Hi Stefan,

Quoted 38 lines · Stefan Roese

Hi Simon,

Quoted 22 lines · Simon Glass

Hi Stefan,

Quoted 19 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 v1:
- Change patch subject
- Enhance Kconfig help descrition
- Use if() instead of #if

Quoted 5 lines
Quoted 3 lines
   drivers/pci/Kconfig      | 10 ++++++++++
   drivers/pci/pci-uclass.c |  9 ++++++---
   2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

Okay. But how should I handle all these defconfig changes with regard to the other patches in this series, introducing multiple new PCI related Kconfig options. With 3 new Kconfig options, all permutations would lead to 8 (2 ^ 3) different defconfig files. This does not scale.

Quoted 6 lines
Quoted 2 lines

I might be missing something here though - perhaps this is easier to achieve.

For sandbox, turn on all options and then add a new PCI bus that uses this functionality. If there are lots of combinations you could add 8 new buses, but I'm hoping that isn't necessary?

If I turn on all new options, sandbox will run with these new options enabled. I don't know with with implications, as it usually runs with the "normal" PCI related Kconfig options. Also the "normal" PCI defconfig (e.g. CONFIG_PCI_REGION_MULTI_ENTRY etc disabled) will not be tested any more via the sandbox tests. So you get either a test for the new Kconfig option enabled or disabled this way.

Do you really want me to do this?

Thanks,
Stefan

#19 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Hi Stefan,

Quoted 52 lines · Stefan Roese

Hi Simon,

Quoted 41 lines · Simon Glass

Hi Stefan,

Quoted 38 lines · Stefan Roese

Hi Simon,

Quoted 22 lines · Simon Glass

Hi Stefan,

Quoted 19 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 v1:
- Change patch subject
- Enhance Kconfig help descrition
- Use if() instead of #if

Quoted 5 lines
Quoted 3 lines
   drivers/pci/Kconfig      | 10 ++++++++++
   drivers/pci/pci-uclass.c |  9 ++++++---
   2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

Okay. But how should I handle all these defconfig changes with regard to the other patches in this series, introducing multiple new PCI related Kconfig options. With 3 new Kconfig options, all permutations would lead to 8 (2 ^ 3) different defconfig files. This does not scale.

Quoted 6 lines
Quoted 2 lines

I might be missing something here though - perhaps this is easier to achieve.

For sandbox, turn on all options and then add a new PCI bus that uses this functionality. If there are lots of combinations you could add 8 new buses, but I'm hoping that isn't necessary?

Quoted 8 lines

If I turn on all new options, sandbox will run with these new options enabled. I don't know with with implications, as it usually runs with the "normal" PCI related Kconfig options. Also the "normal" PCI defconfig (e.g. CONFIG_PCI_REGION_MULTI_ENTRY etc disabled) will not be tested any more via the sandbox tests. So you get either a test for the new Kconfig option enabled or disabled this way.

Do you really want me to do this?

So the Kconfig completely changes the implementation of PCI? That doesn't make it very testable, as you say.

Instead, I think the Kconfig should enable the option, then use one of three ways to select the option:

- a device tree property (on sandbox particularly)
- compatible string (where the property is not appropriate
- setting a flag in PCI bus (where a driver requires the option be selected)

That way you can write a test for the new feature in sandbox, without deleting all the other tests.

Regards,
SImon

#20 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Hi Simon,

On 04.08.20 17:05, Simon Glass wrote:

<snip>

Quoted 39 lines
Quoted 24 lines
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 8 lines

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

    drivers/pci/Kconfig      | 10 ++++++++++
    drivers/pci/pci-uclass.c |  9 ++++++---
    2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

Okay. But how should I handle all these defconfig changes with regard to the other patches in this series, introducing multiple new PCI related Kconfig options. With 3 new Kconfig options, all permutations would lead to 8 (2 ^ 3) different defconfig files. This does not scale.

Quoted 6 lines
Quoted 2 lines

I might be missing something here though - perhaps this is easier to achieve.

For sandbox, turn on all options and then add a new PCI bus that uses this functionality. If there are lots of combinations you could add 8 new buses, but I'm hoping that isn't necessary?

Quoted 8 lines

If I turn on all new options, sandbox will run with these new options enabled. I don't know with with implications, as it usually runs with the "normal" PCI related Kconfig options. Also the "normal" PCI defconfig (e.g. CONFIG_PCI_REGION_MULTI_ENTRY etc disabled) will not be tested any more via the sandbox tests. So you get either a test for the new Kconfig option enabled or disabled this way.

Do you really want me to do this?

So the Kconfig completely changes the implementation of PCI? That doesn't make it very testable, as you say.

Instead, I think the Kconfig should enable the option, then use one of three ways to select the option:

Quoted 6 lines

- a device tree property (on sandbox particularly)
- compatible string (where the property is not appropriate
- setting a flag in PCI bus (where a driver requires the option be selected)

That way you can write a test for the new feature in sandbox, without deleting all the other tests.

Coming back to this issue after some time - sorry for the delay.

I'm not sure, if I understand this correctly. Do you suggest that the driver code (in this case pci-uclass.c) should be extended to support this (sandbox) testing support?

If yes, I really think that this is counterproductive. As we added (at least some of) the Kconfig options explicitly, to not add code to pci-uclass.c in the "normal case". So adding code to e.g. check a device tree property or a compatible string would increase the code size again.

If not, I'm still unsure how you would like to test the "normal case", e.g. with CONFIG_PCI_REGION_MULTI_ENTRY disabled, and with it enabled without adding more sandbox build targets, with all the Kconfig options permutations. As the extra code (in pci-uclass) is either included or not in the sandbox binary.

But after adding one test for the first of these pci-uclass related patches, I do have a general comment on this. I find it quite complex and time consuming to add these tests. Don't get me wrong, I agree in general, that having tests in U-Boot is very good. But enforcing tests for each and every new feature addition in drivers (layers) like PCI seems a bit too much to me. For example new features like the "pci:
pci-uclass: Add support for Single-Root I/O Virtualization" would mean AFAIU, that I need to write some emulation code for such a PCI device and also some testing driver matching such a device, since we have no real hardware like this in sandbox. This would result in much more complex code for this test & emulation compared to the driver change / extension.

To sum it up, I'm asking if you still think that adding tests for all those PCI driver extensions is really necessary for upstream acceptance? What's your opinion on this? Do you understand my position on this?

Thanks,
Stefan

#21 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Hi Stefan,

Quoted 50 lines · Stefan Roese

Hi Simon,

On 04.08.20 17:05, Simon Glass wrote:

<snip>

Quoted 43 lines
Quoted 24 lines
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 8 lines

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

    drivers/pci/Kconfig      | 10 ++++++++++
    drivers/pci/pci-uclass.c |  9 ++++++---
    2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

Okay. But how should I handle all these defconfig changes with regard to the other patches in this series, introducing multiple new PCI related Kconfig options. With 3 new Kconfig options, all permutations would lead to 8 (2 ^ 3) different defconfig files. This does not scale.

Quoted 6 lines
Quoted 2 lines

I might be missing something here though - perhaps this is easier to achieve.

For sandbox, turn on all options and then add a new PCI bus that uses this functionality. If there are lots of combinations you could add 8 new buses, but I'm hoping that isn't necessary?

Quoted 8 lines

If I turn on all new options, sandbox will run with these new options enabled. I don't know with with implications, as it usually runs with the "normal" PCI related Kconfig options. Also the "normal" PCI defconfig (e.g. CONFIG_PCI_REGION_MULTI_ENTRY etc disabled) will not be tested any more via the sandbox tests. So you get either a test for the new Kconfig option enabled or disabled this way.

Do you really want me to do this?

So the Kconfig completely changes the implementation of PCI? That doesn't make it very testable, as you say.

Instead, I think the Kconfig should enable the option, then use one of three ways to select the option:

- a device tree property (on sandbox particularly)
- compatible string (where the property is not appropriate
- setting a flag in PCI bus (where a driver requires the option be selected)

Quoted 8 lines
Quoted 2 lines

That way you can write a test for the new feature in sandbox, without deleting all the other tests.

Coming back to this issue after some time - sorry for the delay.

I'm not sure, if I understand this correctly. Do you suggest that the driver code (in this case pci-uclass.c) should be extended to support this (sandbox) testing support?

Not really. I see these things as features that drivers can enable / disable depending on their needs. If that is correct, then sandbox is no different form other drivers, except that perhaps it might support all combinations rather than just one.

Quoted 5 lines

If yes, I really think that this is counterproductive. As we added (at least some of) the Kconfig options explicitly, to not add code to pci-uclass.c in the "normal case". So adding code to e.g. check a device tree property or a compatible string would increase the code size again.

How about some flags in struct pci_controller?

Quoted 6 lines

If not, I'm still unsure how you would like to test the "normal case", e.g. with CONFIG_PCI_REGION_MULTI_ENTRY disabled, and with it enabled without adding more sandbox build targets, with all the Kconfig options permutations. As the extra code (in pci-uclass) is either included or not in the sandbox binary.

Kconfig enables and disables the feature by adding the code. But we can still have a flag to determine whether it is used by a particular driver. That way we can keep our test coverage.

Quoted 13 lines

But after adding one test for the first of these pci-uclass related patches, I do have a general comment on this. I find it quite complex and time consuming to add these tests. Don't get me wrong, I agree in general, that having tests in U-Boot is very good. But enforcing tests for each and every new feature addition in drivers (layers) like PCI seems a bit too much to me. For example new features like the "pci:
pci-uclass: Add support for Single-Root I/O Virtualization" would mean AFAIU, that I need to write some emulation code for such a PCI device and also some testing driver matching such a device, since we have no real hardware like this in sandbox. This would result in much more complex code for this test & emulation compared to the driver change / extension.

Yes but it is not that hard. There are a few PCI emulation devices in U-Boot and these form the basis of existing tests. Before this, we really had no tests for PCI and even the behaviour was largely undefined. Your ability to convert the regions[] array to a dynamically allocated array is partly thanks to these tets.

Quoted 4 lines

To sum it up, I'm asking if you still think that adding tests for all those PCI driver extensions is really necessary for upstream acceptance? What's your opinion on this? Do you understand my position on this?

I don't want to be silly about it, but in general if we add new features, particularly to core features, I think there should be tests. Apart from correctness, they also define the behaviour of the code, in many cases. The test you added in one patch looks good, and doesn't look too complicated. Of course it is more than zero work. But so much of the refactoring we do in U-Boot these days would be much harder and error-prone without these tests.

+Tom Rini who might want to weigh in.

Regards,
SImon

#22 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Hi Simon,
Hi Tom,

Quoted 107 lines · Simon Glass

Hi Stefan,

Quoted 50 lines · Stefan Roese

Hi Simon,

On 04.08.20 17:05, Simon Glass wrote:

<snip>

Quoted 43 lines
Quoted 24 lines
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 8 lines

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

     drivers/pci/Kconfig      | 10 ++++++++++
     drivers/pci/pci-uclass.c |  9 ++++++---
     2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

Okay. But how should I handle all these defconfig changes with regard to the other patches in this series, introducing multiple new PCI related Kconfig options. With 3 new Kconfig options, all permutations would lead to 8 (2 ^ 3) different defconfig files. This does not scale.

Quoted 6 lines
Quoted 2 lines

I might be missing something here though - perhaps this is easier to achieve.

For sandbox, turn on all options and then add a new PCI bus that uses this functionality. If there are lots of combinations you could add 8 new buses, but I'm hoping that isn't necessary?

Quoted 8 lines

If I turn on all new options, sandbox will run with these new options enabled. I don't know with with implications, as it usually runs with the "normal" PCI related Kconfig options. Also the "normal" PCI defconfig (e.g. CONFIG_PCI_REGION_MULTI_ENTRY etc disabled) will not be tested any more via the sandbox tests. So you get either a test for the new Kconfig option enabled or disabled this way.

Do you really want me to do this?

So the Kconfig completely changes the implementation of PCI? That doesn't make it very testable, as you say.

Instead, I think the Kconfig should enable the option, then use one of three ways to select the option:

- a device tree property (on sandbox particularly)
- compatible string (where the property is not appropriate
- setting a flag in PCI bus (where a driver requires the option be selected)

Quoted 8 lines
Quoted 2 lines

That way you can write a test for the new feature in sandbox, without deleting all the other tests.

Coming back to this issue after some time - sorry for the delay.

I'm not sure, if I understand this correctly. Do you suggest that the driver code (in this case pci-uclass.c) should be extended to support this (sandbox) testing support?

Not really. I see these things as features that drivers can enable / disable depending on their needs. If that is correct, then sandbox is no different form other drivers, except that perhaps it might support all combinations rather than just one.

Quoted 5 lines

If yes, I really think that this is counterproductive. As we added (at least some of) the Kconfig options explicitly, to not add code to pci-uclass.c in the "normal case". So adding code to e.g. check a device tree property or a compatible string would increase the code size again.

How about some flags in struct pci_controller?

Quoted 6 lines

If not, I'm still unsure how you would like to test the "normal case", e.g. with CONFIG_PCI_REGION_MULTI_ENTRY disabled, and with it enabled without adding more sandbox build targets, with all the Kconfig options permutations. As the extra code (in pci-uclass) is either included or not in the sandbox binary.

Kconfig enables and disables the feature by adding the code. But we can still have a flag to determine whether it is used by a particular driver. That way we can keep our test coverage.

Quoted 13 lines

But after adding one test for the first of these pci-uclass related patches, I do have a general comment on this. I find it quite complex and time consuming to add these tests. Don't get me wrong, I agree in general, that having tests in U-Boot is very good. But enforcing tests for each and every new feature addition in drivers (layers) like PCI seems a bit too much to me. For example new features like the "pci:
pci-uclass: Add support for Single-Root I/O Virtualization" would mean AFAIU, that I need to write some emulation code for such a PCI device and also some testing driver matching such a device, since we have no real hardware like this in sandbox. This would result in much more complex code for this test & emulation compared to the driver change / extension.

Yes but it is not that hard. There are a few PCI emulation devices in U-Boot and these form the basis of existing tests. Before this, we really had no tests for PCI and even the behaviour was largely undefined. Your ability to convert the regions[] array to a dynamically allocated array is partly thanks to these tets.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

To sum it up, I'm asking if you still think that adding tests for all those PCI driver extensions is really necessary for upstream acceptance? What's your opinion on this? Do you understand my position on this?

I don't want to be silly about it, but in general if we add new features, particularly to core features, I think there should be tests.

As mentioned before, I agree in general. But we should be not too strict here IMHO, to enforce new tests for each and every U-Boot addition. It's probably not easy to draw the line here to decide, when and when not to enforce tests. Perhaps this should reflect the complexitiy of the test code and also the user count of the new U-Boot code / features (here its solely Octeon TX/TX2).

Quoted 3 lines

Apart from correctness, they also define the behaviour of the code, in many cases. The test you added in one patch looks good, and doesn't look too complicated.

Yes, that one was quite simple. But emulating special PCI device capabilities to enable such virtual testings will be much more complex, AFAICT. If it would be "easy", I would not argue with you on this and just implement these tests and be done with it. ;) But frankly, I have no real idea (without digging much deeper into this) on how to add these emulation codes and tests in a way, that they completely test all the feature additions. Please note that I'm not the original author of these additions.

Quoted 5 lines

Of course it is more than zero work. But
so much of the refactoring we do in U-Boot these days would be much harder and error-prone without these tests.

+Tom Rini who might want to weigh in.

Tom, are you okay with going forward with these PCIe related patches, without adding test cases for all PCI feature additions? Which would mean to add very special PCI device emulation and test drivers for such devices? The PCI extensions are not that intrusive and AFAICT Simon is okay with all of them in general, only would like to have tests for all driver extensions.

Thanks,
Stefan

#23 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Quoted 143 lines · Stefan Roese

Hi Simon,
Hi Tom,

Quoted 107 lines · Simon Glass

Hi Stefan,

Quoted 50 lines · Stefan Roese

Hi Simon,

On 04.08.20 17:05, Simon Glass wrote:

<snip>

Quoted 43 lines
Quoted 24 lines
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 8 lines

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

     drivers/pci/Kconfig      | 10 ++++++++++
     drivers/pci/pci-uclass.c |  9 ++++++---
     2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

Okay. But how should I handle all these defconfig changes with regard to the other patches in this series, introducing multiple new PCI related Kconfig options. With 3 new Kconfig options, all permutations would lead to 8 (2 ^ 3) different defconfig files. This does not scale.

Quoted 6 lines
Quoted 2 lines

I might be missing something here though - perhaps this is easier to achieve.

For sandbox, turn on all options and then add a new PCI bus that uses this functionality. If there are lots of combinations you could add 8 new buses, but I'm hoping that isn't necessary?

Quoted 8 lines

If I turn on all new options, sandbox will run with these new options enabled. I don't know with with implications, as it usually runs with the "normal" PCI related Kconfig options. Also the "normal" PCI defconfig (e.g. CONFIG_PCI_REGION_MULTI_ENTRY etc disabled) will not be tested any more via the sandbox tests. So you get either a test for the new Kconfig option enabled or disabled this way.

Do you really want me to do this?

So the Kconfig completely changes the implementation of PCI? That doesn't make it very testable, as you say.

Instead, I think the Kconfig should enable the option, then use one of three ways to select the option:

- a device tree property (on sandbox particularly)
- compatible string (where the property is not appropriate
- setting a flag in PCI bus (where a driver requires the option be selected)

Quoted 8 lines
Quoted 2 lines

That way you can write a test for the new feature in sandbox, without deleting all the other tests.

Coming back to this issue after some time - sorry for the delay.

I'm not sure, if I understand this correctly. Do you suggest that the driver code (in this case pci-uclass.c) should be extended to support this (sandbox) testing support?

Not really. I see these things as features that drivers can enable / disable depending on their needs. If that is correct, then sandbox is no different form other drivers, except that perhaps it might support all combinations rather than just one.

Quoted 5 lines

If yes, I really think that this is counterproductive. As we added (at least some of) the Kconfig options explicitly, to not add code to pci-uclass.c in the "normal case". So adding code to e.g. check a device tree property or a compatible string would increase the code size again.

How about some flags in struct pci_controller?

Quoted 6 lines

If not, I'm still unsure how you would like to test the "normal case", e.g. with CONFIG_PCI_REGION_MULTI_ENTRY disabled, and with it enabled without adding more sandbox build targets, with all the Kconfig options permutations. As the extra code (in pci-uclass) is either included or not in the sandbox binary.

Kconfig enables and disables the feature by adding the code. But we can still have a flag to determine whether it is used by a particular driver. That way we can keep our test coverage.

Quoted 13 lines

But after adding one test for the first of these pci-uclass related patches, I do have a general comment on this. I find it quite complex and time consuming to add these tests. Don't get me wrong, I agree in general, that having tests in U-Boot is very good. But enforcing tests for each and every new feature addition in drivers (layers) like PCI seems a bit too much to me. For example new features like the "pci:
pci-uclass: Add support for Single-Root I/O Virtualization" would mean AFAIU, that I need to write some emulation code for such a PCI device and also some testing driver matching such a device, since we have no real hardware like this in sandbox. This would result in much more complex code for this test & emulation compared to the driver change / extension.

Yes but it is not that hard. There are a few PCI emulation devices in U-Boot and these form the basis of existing tests. Before this, we really had no tests for PCI and even the behaviour was largely undefined. Your ability to convert the regions[] array to a dynamically allocated array is partly thanks to these tets.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

To sum it up, I'm asking if you still think that adding tests for all those PCI driver extensions is really necessary for upstream acceptance? What's your opinion on this? Do you understand my position on this?

I don't want to be silly about it, but in general if we add new features, particularly to core features, I think there should be tests.

As mentioned before, I agree in general. But we should be not too strict here IMHO, to enforce new tests for each and every U-Boot addition. It's probably not easy to draw the line here to decide, when and when not to enforce tests. Perhaps this should reflect the complexitiy of the test code and also the user count of the new U-Boot code / features (here its solely Octeon TX/TX2).

Quoted 3 lines

Apart from correctness, they also define the behaviour of the code, in many cases. The test you added in one patch looks good, and doesn't look too complicated.

Yes, that one was quite simple. But emulating special PCI device capabilities to enable such virtual testings will be much more complex, AFAICT. If it would be "easy", I would not argue with you on this and just implement these tests and be done with it. ;) But frankly, I have no real idea (without digging much deeper into this) on how to add these emulation codes and tests in a way, that they completely test all the feature additions. Please note that I'm not the original author of these additions.

Quoted 4 lines

Of course it is more than zero work. But
so much of the refactoring we do in U-Boot these days would be much harder and error-prone without these tests.

Quoted 8 lines
Quoted 1 line

+Tom Rini who might want to weigh in.

Tom, are you okay with going forward with these PCIe related patches, without adding test cases for all PCI feature additions? Which would mean to add very special PCI device emulation and test drivers for such devices? The PCI extensions are not that intrusive and AFAICT Simon is okay with all of them in general, only would like to have tests for all driver extensions.

For complex hardware specific things like this and testing I think we'll have the most luck by, when possible and I'm not sure we do enough today, enable features and tests on qemu* machines and get it that way, rather than writing new emulators for sandbox.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200823/47dc3f9a/attachment.sig>
#24 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Hi Tom,

Quoted 153 lines · Tom Rini
Quoted 143 lines · Stefan Roese

Hi Simon,
Hi Tom,

Quoted 107 lines · Simon Glass

Hi Stefan,

Quoted 50 lines · Stefan Roese

Hi Simon,

On 04.08.20 17:05, Simon Glass wrote:

<snip>

Quoted 43 lines
Quoted 24 lines
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 8 lines

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

      drivers/pci/Kconfig      | 10 ++++++++++
      drivers/pci/pci-uclass.c |  9 ++++++---
      2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

Okay. But how should I handle all these defconfig changes with regard to the other patches in this series, introducing multiple new PCI related Kconfig options. With 3 new Kconfig options, all permutations would lead to 8 (2 ^ 3) different defconfig files. This does not scale.

Quoted 6 lines
Quoted 2 lines

I might be missing something here though - perhaps this is easier to achieve.

For sandbox, turn on all options and then add a new PCI bus that uses this functionality. If there are lots of combinations you could add 8 new buses, but I'm hoping that isn't necessary?

Quoted 8 lines

If I turn on all new options, sandbox will run with these new options enabled. I don't know with with implications, as it usually runs with the "normal" PCI related Kconfig options. Also the "normal" PCI defconfig (e.g. CONFIG_PCI_REGION_MULTI_ENTRY etc disabled) will not be tested any more via the sandbox tests. So you get either a test for the new Kconfig option enabled or disabled this way.

Do you really want me to do this?

So the Kconfig completely changes the implementation of PCI? That doesn't make it very testable, as you say.

Instead, I think the Kconfig should enable the option, then use one of three ways to select the option:

- a device tree property (on sandbox particularly)
- compatible string (where the property is not appropriate
- setting a flag in PCI bus (where a driver requires the option be selected)

Quoted 8 lines
Quoted 2 lines

That way you can write a test for the new feature in sandbox, without deleting all the other tests.

Coming back to this issue after some time - sorry for the delay.

I'm not sure, if I understand this correctly. Do you suggest that the driver code (in this case pci-uclass.c) should be extended to support this (sandbox) testing support?

Not really. I see these things as features that drivers can enable / disable depending on their needs. If that is correct, then sandbox is no different form other drivers, except that perhaps it might support all combinations rather than just one.

Quoted 5 lines

If yes, I really think that this is counterproductive. As we added (at least some of) the Kconfig options explicitly, to not add code to pci-uclass.c in the "normal case". So adding code to e.g. check a device tree property or a compatible string would increase the code size again.

How about some flags in struct pci_controller?

Quoted 6 lines

If not, I'm still unsure how you would like to test the "normal case", e.g. with CONFIG_PCI_REGION_MULTI_ENTRY disabled, and with it enabled without adding more sandbox build targets, with all the Kconfig options permutations. As the extra code (in pci-uclass) is either included or not in the sandbox binary.

Kconfig enables and disables the feature by adding the code. But we can still have a flag to determine whether it is used by a particular driver. That way we can keep our test coverage.

Quoted 13 lines

But after adding one test for the first of these pci-uclass related patches, I do have a general comment on this. I find it quite complex and time consuming to add these tests. Don't get me wrong, I agree in general, that having tests in U-Boot is very good. But enforcing tests for each and every new feature addition in drivers (layers) like PCI seems a bit too much to me. For example new features like the "pci:
pci-uclass: Add support for Single-Root I/O Virtualization" would mean AFAIU, that I need to write some emulation code for such a PCI device and also some testing driver matching such a device, since we have no real hardware like this in sandbox. This would result in much more complex code for this test & emulation compared to the driver change / extension.

Yes but it is not that hard. There are a few PCI emulation devices in U-Boot and these form the basis of existing tests. Before this, we really had no tests for PCI and even the behaviour was largely undefined. Your ability to convert the regions[] array to a dynamically allocated array is partly thanks to these tets.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

To sum it up, I'm asking if you still think that adding tests for all those PCI driver extensions is really necessary for upstream acceptance? What's your opinion on this? Do you understand my position on this?

I don't want to be silly about it, but in general if we add new features, particularly to core features, I think there should be tests.

As mentioned before, I agree in general. But we should be not too strict here IMHO, to enforce new tests for each and every U-Boot addition. It's probably not easy to draw the line here to decide, when and when not to enforce tests. Perhaps this should reflect the complexitiy of the test code and also the user count of the new U-Boot code / features (here its solely Octeon TX/TX2).

Quoted 3 lines

Apart from correctness, they also define the behaviour of the code, in many cases. The test you added in one patch looks good, and doesn't look too complicated.

Yes, that one was quite simple. But emulating special PCI device capabilities to enable such virtual testings will be much more complex, AFAICT. If it would be "easy", I would not argue with you on this and just implement these tests and be done with it. ;) But frankly, I have no real idea (without digging much deeper into this) on how to add these emulation codes and tests in a way, that they completely test all the feature additions. Please note that I'm not the original author of these additions.

Quoted 4 lines

Of course it is more than zero work. But
so much of the refactoring we do in U-Boot these days would be much harder and error-prone without these tests.

Quoted 8 lines
Quoted 1 line

+Tom Rini who might want to weigh in.

Tom, are you okay with going forward with these PCIe related patches, without adding test cases for all PCI feature additions? Which would mean to add very special PCI device emulation and test drivers for such devices? The PCI extensions are not that intrusive and AFAICT Simon is okay with all of them in general, only would like to have tests for all driver extensions.

Quoted 4 lines

For complex hardware specific things like this and testing I think we'll have the most luck by, when possible and I'm not sure we do enough today, enable features and tests on qemu* machines and get it that way, rather than writing new emulators for sandbox.

I agree. As was proved by the QEMU Nokia test a few days ago with the bi_memstart (etc) cleanup, I'm working on. I also had the idea that such an QEMU machine emulation would be much better. Let me check, if any such machine emulation is possible for Octeon TX/TX2. I'll get back to this, once I have more informations here.

In the meantime, how do we proceeed with this current Octeon TX/TX2 patchset? I would really like to get at least some of it included into mainline soon. The first RFC version has been posted to the list by Suneel end of October last year, so more than 3/4 of a year ago. My proposal would be (if nobody objects), to push the PCI patches and Octeon TX/TX2 base port into mainline, dropping the really big drivers (nand & ethernet) for now, which need a bit more review IMHO.

Should I continue this way?

Thanks,
Stefan

#25 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Quoted 175 lines · Stefan Roese

Hi Tom,

Quoted 153 lines · Tom Rini
Quoted 143 lines · Stefan Roese

Hi Simon,
Hi Tom,

Quoted 107 lines · Simon Glass

Hi Stefan,

Quoted 50 lines · Stefan Roese

Hi Simon,

On 04.08.20 17:05, Simon Glass wrote:

<snip>

Quoted 43 lines
Quoted 24 lines
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 8 lines

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

      drivers/pci/Kconfig      | 10 ++++++++++
      drivers/pci/pci-uclass.c |  9 ++++++---
      2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

Okay. But how should I handle all these defconfig changes with regard to the other patches in this series, introducing multiple new PCI related Kconfig options. With 3 new Kconfig options, all permutations would lead to 8 (2 ^ 3) different defconfig files. This does not scale.

Quoted 6 lines
Quoted 2 lines

I might be missing something here though - perhaps this is easier to achieve.

For sandbox, turn on all options and then add a new PCI bus that uses this functionality. If there are lots of combinations you could add 8 new buses, but I'm hoping that isn't necessary?

Quoted 8 lines

If I turn on all new options, sandbox will run with these new options enabled. I don't know with with implications, as it usually runs with the "normal" PCI related Kconfig options. Also the "normal" PCI defconfig (e.g. CONFIG_PCI_REGION_MULTI_ENTRY etc disabled) will not be tested any more via the sandbox tests. So you get either a test for the new Kconfig option enabled or disabled this way.

Do you really want me to do this?

So the Kconfig completely changes the implementation of PCI? That doesn't make it very testable, as you say.

Instead, I think the Kconfig should enable the option, then use one of three ways to select the option:

- a device tree property (on sandbox particularly)
- compatible string (where the property is not appropriate
- setting a flag in PCI bus (where a driver requires the option be selected)

Quoted 8 lines
Quoted 2 lines

That way you can write a test for the new feature in sandbox, without deleting all the other tests.

Coming back to this issue after some time - sorry for the delay.

I'm not sure, if I understand this correctly. Do you suggest that the driver code (in this case pci-uclass.c) should be extended to support this (sandbox) testing support?

Not really. I see these things as features that drivers can enable / disable depending on their needs. If that is correct, then sandbox is no different form other drivers, except that perhaps it might support all combinations rather than just one.

Quoted 5 lines

If yes, I really think that this is counterproductive. As we added (at least some of) the Kconfig options explicitly, to not add code to pci-uclass.c in the "normal case". So adding code to e.g. check a device tree property or a compatible string would increase the code size again.

How about some flags in struct pci_controller?

Quoted 6 lines

If not, I'm still unsure how you would like to test the "normal case", e.g. with CONFIG_PCI_REGION_MULTI_ENTRY disabled, and with it enabled without adding more sandbox build targets, with all the Kconfig options permutations. As the extra code (in pci-uclass) is either included or not in the sandbox binary.

Kconfig enables and disables the feature by adding the code. But we can still have a flag to determine whether it is used by a particular driver. That way we can keep our test coverage.

Quoted 13 lines

But after adding one test for the first of these pci-uclass related patches, I do have a general comment on this. I find it quite complex and time consuming to add these tests. Don't get me wrong, I agree in general, that having tests in U-Boot is very good. But enforcing tests for each and every new feature addition in drivers (layers) like PCI seems a bit too much to me. For example new features like the "pci:
pci-uclass: Add support for Single-Root I/O Virtualization" would mean AFAIU, that I need to write some emulation code for such a PCI device and also some testing driver matching such a device, since we have no real hardware like this in sandbox. This would result in much more complex code for this test & emulation compared to the driver change / extension.

Yes but it is not that hard. There are a few PCI emulation devices in U-Boot and these form the basis of existing tests. Before this, we really had no tests for PCI and even the behaviour was largely undefined. Your ability to convert the regions[] array to a dynamically allocated array is partly thanks to these tets.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

To sum it up, I'm asking if you still think that adding tests for all those PCI driver extensions is really necessary for upstream acceptance? What's your opinion on this? Do you understand my position on this?

I don't want to be silly about it, but in general if we add new features, particularly to core features, I think there should be tests.

As mentioned before, I agree in general. But we should be not too strict here IMHO, to enforce new tests for each and every U-Boot addition. It's probably not easy to draw the line here to decide, when and when not to enforce tests. Perhaps this should reflect the complexitiy of the test code and also the user count of the new U-Boot code / features (here its solely Octeon TX/TX2).

Quoted 3 lines

Apart from correctness, they also define the behaviour of the code, in many cases. The test you added in one patch looks good, and doesn't look too complicated.

Yes, that one was quite simple. But emulating special PCI device capabilities to enable such virtual testings will be much more complex, AFAICT. If it would be "easy", I would not argue with you on this and just implement these tests and be done with it. ;) But frankly, I have no real idea (without digging much deeper into this) on how to add these emulation codes and tests in a way, that they completely test all the feature additions. Please note that I'm not the original author of these additions.

Quoted 4 lines

Of course it is more than zero work. But
so much of the refactoring we do in U-Boot these days would be much harder and error-prone without these tests.

Quoted 8 lines
Quoted 1 line

+Tom Rini who might want to weigh in.

Tom, are you okay with going forward with these PCIe related patches, without adding test cases for all PCI feature additions? Which would mean to add very special PCI device emulation and test drivers for such devices? The PCI extensions are not that intrusive and AFAICT Simon is okay with all of them in general, only would like to have tests for all driver extensions.

Quoted 4 lines

For complex hardware specific things like this and testing I think we'll have the most luck by, when possible and I'm not sure we do enough today, enable features and tests on qemu* machines and get it that way, rather than writing new emulators for sandbox.

I agree. As was proved by the QEMU Nokia test a few days ago with the bi_memstart (etc) cleanup, I'm working on. I also had the idea that such an QEMU machine emulation would be much better. Let me check, if any such machine emulation is possible for Octeon TX/TX2. I'll get back to this, once I have more informations here.

In the meantime, how do we proceeed with this current Octeon TX/TX2 patchset? I would really like to get at least some of it included into mainline soon. The first RFC version has been posted to the list by Suneel end of October last year, so more than 3/4 of a year ago. My proposal would be (if nobody objects), to push the PCI patches and Octeon TX/TX2 base port into mainline, dropping the really big drivers (nand & ethernet) for now, which need a bit more review IMHO.

Quoted 1 line

Should I continue this way?

I think that's reasonable, yes.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200824/bae25aa1/attachment.sig>
#26 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Hi,

Quoted 177 lines · Tom Rini
Quoted 175 lines · Stefan Roese

Hi Tom,

Quoted 153 lines · Tom Rini
Quoted 143 lines · Stefan Roese

Hi Simon,
Hi Tom,

Quoted 107 lines · Simon Glass

Hi Stefan,

Quoted 50 lines · Stefan Roese

Hi Simon,

On 04.08.20 17:05, Simon Glass wrote:

<snip>

Quoted 43 lines
Quoted 24 lines
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 8 lines

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

      drivers/pci/Kconfig      | 10 ++++++++++
      drivers/pci/pci-uclass.c |  9 ++++++---
      2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

Okay. But how should I handle all these defconfig changes with regard to the other patches in this series, introducing multiple new PCI related Kconfig options. With 3 new Kconfig options, all permutations would lead to 8 (2 ^ 3) different defconfig files. This does not scale.

Quoted 6 lines
Quoted 2 lines

I might be missing something here though - perhaps this is easier to achieve.

For sandbox, turn on all options and then add a new PCI bus that uses this functionality. If there are lots of combinations you could add 8 new buses, but I'm hoping that isn't necessary?

Quoted 8 lines

If I turn on all new options, sandbox will run with these new options enabled. I don't know with with implications, as it usually runs with the "normal" PCI related Kconfig options. Also the "normal" PCI defconfig (e.g. CONFIG_PCI_REGION_MULTI_ENTRY etc disabled) will not be tested any more via the sandbox tests. So you get either a test for the new Kconfig option enabled or disabled this way.

Do you really want me to do this?

So the Kconfig completely changes the implementation of PCI? That doesn't make it very testable, as you say.

Instead, I think the Kconfig should enable the option, then use one of three ways to select the option:

- a device tree property (on sandbox particularly)
- compatible string (where the property is not appropriate
- setting a flag in PCI bus (where a driver requires the option be selected)

Quoted 8 lines
Quoted 2 lines

That way you can write a test for the new feature in sandbox, without deleting all the other tests.

Coming back to this issue after some time - sorry for the delay.

I'm not sure, if I understand this correctly. Do you suggest that the driver code (in this case pci-uclass.c) should be extended to support this (sandbox) testing support?

Not really. I see these things as features that drivers can enable / disable depending on their needs. If that is correct, then sandbox is no different form other drivers, except that perhaps it might support all combinations rather than just one.

Quoted 5 lines

If yes, I really think that this is counterproductive. As we added (at least some of) the Kconfig options explicitly, to not add code to pci-uclass.c in the "normal case". So adding code to e.g. check a device tree property or a compatible string would increase the code size again.

How about some flags in struct pci_controller?

Quoted 6 lines

If not, I'm still unsure how you would like to test the "normal case", e.g. with CONFIG_PCI_REGION_MULTI_ENTRY disabled, and with it enabled without adding more sandbox build targets, with all the Kconfig options permutations. As the extra code (in pci-uclass) is either included or not in the sandbox binary.

Kconfig enables and disables the feature by adding the code. But we can still have a flag to determine whether it is used by a particular driver. That way we can keep our test coverage.

Quoted 13 lines

But after adding one test for the first of these pci-uclass related patches, I do have a general comment on this. I find it quite complex and time consuming to add these tests. Don't get me wrong, I agree in general, that having tests in U-Boot is very good. But enforcing tests for each and every new feature addition in drivers (layers) like PCI seems a bit too much to me. For example new features like the "pci:
pci-uclass: Add support for Single-Root I/O Virtualization" would mean AFAIU, that I need to write some emulation code for such a PCI device and also some testing driver matching such a device, since we have no real hardware like this in sandbox. This would result in much more complex code for this test & emulation compared to the driver change / extension.

Yes but it is not that hard. There are a few PCI emulation devices in U-Boot and these form the basis of existing tests. Before this, we really had no tests for PCI and even the behaviour was largely undefined. Your ability to convert the regions[] array to a dynamically allocated array is partly thanks to these tets.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

To sum it up, I'm asking if you still think that adding tests for all those PCI driver extensions is really necessary for upstream acceptance? What's your opinion on this? Do you understand my position on this?

I don't want to be silly about it, but in general if we add new features, particularly to core features, I think there should be tests.

As mentioned before, I agree in general. But we should be not too strict here IMHO, to enforce new tests for each and every U-Boot addition. It's probably not easy to draw the line here to decide, when and when not to enforce tests. Perhaps this should reflect the complexitiy of the test code and also the user count of the new U-Boot code / features (here its solely Octeon TX/TX2).

Quoted 3 lines

Apart from correctness, they also define the behaviour of the code, in many cases. The test you added in one patch looks good, and doesn't look too complicated.

Yes, that one was quite simple. But emulating special PCI device capabilities to enable such virtual testings will be much more complex, AFAICT. If it would be "easy", I would not argue with you on this and just implement these tests and be done with it. ;) But frankly, I have no real idea (without digging much deeper into this) on how to add these emulation codes and tests in a way, that they completely test all the feature additions. Please note that I'm not the original author of these additions.

Quoted 4 lines

Of course it is more than zero work. But
so much of the refactoring we do in U-Boot these days would be much harder and error-prone without these tests.

Quoted 8 lines
Quoted 1 line

+Tom Rini who might want to weigh in.

Tom, are you okay with going forward with these PCIe related patches, without adding test cases for all PCI feature additions? Which would mean to add very special PCI device emulation and test drivers for such devices? The PCI extensions are not that intrusive and AFAICT Simon is okay with all of them in general, only would like to have tests for all driver extensions.

Quoted 4 lines

For complex hardware specific things like this and testing I think we'll have the most luck by, when possible and I'm not sure we do enough today, enable features and tests on qemu* machines and get it that way, rather than writing new emulators for sandbox.

I agree. As was proved by the QEMU Nokia test a few days ago with the bi_memstart (etc) cleanup, I'm working on. I also had the idea that such an QEMU machine emulation would be much better. Let me check, if any such machine emulation is possible for Octeon TX/TX2. I'll get back to this, once I have more informations here.

In the meantime, how do we proceeed with this current Octeon TX/TX2 patchset? I would really like to get at least some of it included into mainline soon. The first RFC version has been posted to the list by Suneel end of October last year, so more than 3/4 of a year ago. My proposal would be (if nobody objects), to push the PCI patches and Octeon TX/TX2 base port into mainline, dropping the really big drivers (nand & ethernet) for now, which need a bit more review IMHO.

Quoted 3 lines
Quoted 1 line

Should I continue this way?

I think that's reasonable, yes.

That sounds fine, particularly as these are arch-specific and therefore not enabled on any other board. What happens when they are not?

It would be interesting to hear if qemu supports this. Having said that, sandbox has the advantage that it can quickly test all the features at once and it is easy for someone to debug and fix (vs. qemu). IMO it is often worth the investment.

Regards,
Simon

#27 lore raw

PATCH 6/24 pci: pci-uclass: Add multi entry support for memory regions

Quoted 184 lines · Simon Glass

Hi,

Quoted 177 lines · Tom Rini
Quoted 175 lines · Stefan Roese

Hi Tom,

Quoted 153 lines · Tom Rini
Quoted 143 lines · Stefan Roese

Hi Simon,
Hi Tom,

Quoted 107 lines · Simon Glass

Hi Stefan,

Quoted 50 lines · Stefan Roese

Hi Simon,

On 04.08.20 17:05, Simon Glass wrote:

<snip>

Quoted 43 lines
Quoted 24 lines
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 8 lines

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

drivers/pci/Kconfig | 10 ++++++++++
drivers/pci/pci-uclass.c | 9 ++++++---
2 files changed, 16 insertions(+), 3 deletions(-)

This needs an update to a sandbox test to handle this behaviour.

Okay. But how should I handle all these defconfig changes with regard to the other patches in this series, introducing multiple new PCI related Kconfig options. With 3 new Kconfig options, all permutations would lead to 8 (2 ^ 3) different defconfig files. This does not scale.

Quoted 6 lines
Quoted 2 lines

I might be missing something here though - perhaps this is easier to achieve.

For sandbox, turn on all options and then add a new PCI bus that uses this functionality. If there are lots of combinations you could add 8 new buses, but I'm hoping that isn't necessary?

Quoted 8 lines

If I turn on all new options, sandbox will run with these new options enabled. I don't know with with implications, as it usually runs with the "normal" PCI related Kconfig options. Also the "normal" PCI defconfig (e.g. CONFIG_PCI_REGION_MULTI_ENTRY etc disabled) will not be tested any more via the sandbox tests. So you get either a test for the new Kconfig option enabled or disabled this way.

Do you really want me to do this?

So the Kconfig completely changes the implementation of PCI? That doesn't make it very testable, as you say.

Instead, I think the Kconfig should enable the option, then use one of three ways to select the option:

- a device tree property (on sandbox particularly)
- compatible string (where the property is not appropriate
- setting a flag in PCI bus (where a driver requires the option be selected)

Quoted 8 lines
Quoted 2 lines

That way you can write a test for the new feature in sandbox, without deleting all the other tests.

Coming back to this issue after some time - sorry for the delay.

I'm not sure, if I understand this correctly. Do you suggest that the driver code (in this case pci-uclass.c) should be extended to support this (sandbox) testing support?

Not really. I see these things as features that drivers can enable / disable depending on their needs. If that is correct, then sandbox is no different form other drivers, except that perhaps it might support all combinations rather than just one.

Quoted 5 lines

If yes, I really think that this is counterproductive. As we added (at least some of) the Kconfig options explicitly, to not add code to pci-uclass.c in the "normal case". So adding code to e.g. check a device tree property or a compatible string would increase the code size again.

How about some flags in struct pci_controller?

Quoted 6 lines

If not, I'm still unsure how you would like to test the "normal case", e.g. with CONFIG_PCI_REGION_MULTI_ENTRY disabled, and with it enabled without adding more sandbox build targets, with all the Kconfig options permutations. As the extra code (in pci-uclass) is either included or not in the sandbox binary.

Kconfig enables and disables the feature by adding the code. But we can still have a flag to determine whether it is used by a particular driver. That way we can keep our test coverage.

Quoted 13 lines

But after adding one test for the first of these pci-uclass related patches, I do have a general comment on this. I find it quite complex and time consuming to add these tests. Don't get me wrong, I agree in general, that having tests in U-Boot is very good. But enforcing tests for each and every new feature addition in drivers (layers) like PCI seems a bit too much to me. For example new features like the "pci:
pci-uclass: Add support for Single-Root I/O Virtualization" would mean AFAIU, that I need to write some emulation code for such a PCI device and also some testing driver matching such a device, since we have no real hardware like this in sandbox. This would result in much more complex code for this test & emulation compared to the driver change / extension.

Yes but it is not that hard. There are a few PCI emulation devices in U-Boot and these form the basis of existing tests. Before this, we really had no tests for PCI and even the behaviour was largely undefined. Your ability to convert the regions[] array to a dynamically allocated array is partly thanks to these tets.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

To sum it up, I'm asking if you still think that adding tests for all those PCI driver extensions is really necessary for upstream acceptance? What's your opinion on this? Do you understand my position on this?

I don't want to be silly about it, but in general if we add new features, particularly to core features, I think there should be tests.

As mentioned before, I agree in general. But we should be not too strict here IMHO, to enforce new tests for each and every U-Boot addition. It's probably not easy to draw the line here to decide, when and when not to enforce tests. Perhaps this should reflect the complexitiy of the test code and also the user count of the new U-Boot code / features (here its solely Octeon TX/TX2).

Quoted 3 lines

Apart from correctness, they also define the behaviour of the code, in many cases. The test you added in one patch looks good, and doesn't look too complicated.

Yes, that one was quite simple. But emulating special PCI device capabilities to enable such virtual testings will be much more complex, AFAICT. If it would be "easy", I would not argue with you on this and just implement these tests and be done with it. ;) But frankly, I have no real idea (without digging much deeper into this) on how to add these emulation codes and tests in a way, that they completely test all the feature additions. Please note that I'm not the original author of these additions.

Quoted 4 lines

Of course it is more than zero work. But
so much of the refactoring we do in U-Boot these days would be much harder and error-prone without these tests.

Quoted 8 lines
Quoted 1 line

+Tom Rini who might want to weigh in.

Tom, are you okay with going forward with these PCIe related patches, without adding test cases for all PCI feature additions? Which would mean to add very special PCI device emulation and test drivers for such devices? The PCI extensions are not that intrusive and AFAICT Simon is okay with all of them in general, only would like to have tests for all driver extensions.

Quoted 4 lines

For complex hardware specific things like this and testing I think we'll have the most luck by, when possible and I'm not sure we do enough today, enable features and tests on qemu* machines and get it that way, rather than writing new emulators for sandbox.

I agree. As was proved by the QEMU Nokia test a few days ago with the bi_memstart (etc) cleanup, I'm working on. I also had the idea that such an QEMU machine emulation would be much better. Let me check, if any such machine emulation is possible for Octeon TX/TX2. I'll get back to this, once I have more informations here.

In the meantime, how do we proceeed with this current Octeon TX/TX2 patchset? I would really like to get at least some of it included into mainline soon. The first RFC version has been posted to the list by Suneel end of October last year, so more than 3/4 of a year ago. My proposal would be (if nobody objects), to push the PCI patches and Octeon TX/TX2 base port into mainline, dropping the really big drivers (nand & ethernet) for now, which need a bit more review IMHO.

Quoted 3 lines
Quoted 1 line

Should I continue this way?

I think that's reasonable, yes.

Quoted 8 lines

That sounds fine, particularly as these are arch-specific and therefore not enabled on any other board. What happens when they are not?

It would be interesting to hear if qemu supports this. Having said that, sandbox has the advantage that it can quickly test all the features at once and it is easy for someone to debug and fix (vs. qemu). IMO it is often worth the investment.

There are trade-offs in sandbox vs qemu. There's a lot of stuff I love sandbox for. But when we get in to "emulate some hardware" there's a big community for qemu and just us for sandbox. If we can't test it in qemu, and it's fairly complex, testing it on hardware only is the final stop. So yes, get tests, but if they're only able to be run when we have the hardware, that's fine so long as someone is writing the test and running it on hardware, at least as part of submission. More automated hardware testing is great.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200825/69c4b44e/attachment.sig>
#28 lore raw

PATCH 7/24 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.

---

Changes in v1:
- Change patch subject

 drivers/pci/pci-uclass.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/pci/pci-uclass.c +19 -6
index 061ac4e943..9985f3dda1 100644
@@ -620,10 +620,20 @@ 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 +643,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.27.0
#29 lore raw

PATCH 7/24 pci: pci-uclass: Add support for Enhanced Allocation in Bridges

Quoted 10 lines · 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.

Quoted 8 lines

---

Changes in v1:
- Change patch subject

 drivers/pci/pci-uclass.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

Needs a sandbox test.

#30 lore raw

PATCH 8/24 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.

---

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 14c96dd108..3676fa85db 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 53f1386fd4..4f4b11df4a 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.27.0
#31 lore raw

PATCH 8/24 pci: pci-uclass: Add support for Single-Root I/O Virtualization

Hi Stefan,

Quoted 28 lines · 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.

---

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

Quoted 4 lines
 drivers/pci/Kconfig      |  10 ++++
 drivers/pci/pci-uclass.c | 114 +++++++++++++++++++++++++++++++++++++++
 include/pci.h            |  38 +++++++++++++
 3 files changed, 162 insertions(+)

This looks OK but all of these patches need updates to the sandbox tests to cover the new functionality.

Regards,
SImon

#32 lore raw

PATCH 9/24 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.

---

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 b0f2b5b77e..5e68a2e306 100644
@@ -1368,14 +1368,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;
@@ -1398,6 +1439,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);
 	}
@@ -1407,20 +1451,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);
 
 	/*
@@ -1429,7 +1486,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 4f4b11df4a..3be642a3ef 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.27.0
#33 lore raw

PATCH 9/24 pci: pci-uclass: Add VF BAR map support for Enhanced Allocation

Quoted 21 lines · 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.

---

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

Quoted 3 lines
 drivers/pci/pci-uclass.c | 67 +++++++++++++++++++++++++++++++++++++---
 include/pci.h            |  3 ++
 2 files changed, 65 insertions(+), 5 deletions(-)

Again this needs a test...

- Simon

#34 lore raw

PATCH 10/24 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.

---

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 3676fa85db..bc77c23f89 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 5e68a2e306..be685f9143 100644
@@ -799,6 +799,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;
@@ -872,6 +873,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.27.0
#35 lore raw

PATCH 11/24 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 v1:
- New patch

 drivers/pci/pci-uclass.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/pci/pci-uclass.c +7 -3
index be685f9143..77ac2e0f2b 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)
@@ -1026,8 +1027,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.27.0
#36 lore raw

PATCH 11/24 pci: pci-uclass: Check validity of ofnode

Quoted 9 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

Add check if the referenced ofnode is valid.

Quoted 9 lines

---

Changes in v1:
- New patch

 drivers/pci/pci-uclass.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
#37 lore raw

PATCH 12/24 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.

---

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 8959749ad6..1969851c7d 100644
@@ -176,16 +176,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)
@@ -227,6 +231,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.27.0
#38 lore raw

PATCH 13/24 arm: octeontx: Add headers for OcteonTX

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

---

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.27.0
#39 lore raw

PATCH 13/24 arm: octeontx: Add headers for OcteonTX

Hi Stefan,

Quoted 11 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

---

Changes in v1:
- Change patch subject

Quoted 15 lines
 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

Generic thoughts to consider:
- drop extra brackets around constants - e.g. MIO_EMM_BAR_E_MIO_EMM_PF_BAR4
- use #define or enum instead of inline functions, e.g. MIO_EMM_DMA
- lower-case hex

I don't normally see bitfields in U-Boot. Is that a good idea?

Regards,
Simon

#40 lore raw

PATCH 13/24 arm: octeontx: Add headers for OcteonTX

Hi Simon,

Quoted 30 lines · Simon Glass

Hi Stefan,

Quoted 19 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

---

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(+)
Quoted 7 lines

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

Quoted 6 lines

Generic thoughts to consider:
- drop extra brackets around constants - e.g. MIO_EMM_BAR_E_MIO_EMM_PF_BAR4
- use #define or enum instead of inline functions, e.g. MIO_EMM_DMA
- lower-case hex

Yes, thanks. I agree. Let me check, if I can find some time to clean this up a bit more.

Quoted 1 line

I don't normally see bitfields in U-Boot. Is that a good idea?

It is not, I agree. I've been bitten by those bitfields in the other Octeon drivers before (I2C, SPI etc). Bitfields make portable driver code quite hard. You need to add separate bitfield definitions for big- endian and little-endian support. So I switched on the common drivers, and with common I mean drivers supporting MIPS Octeon and ARM Octeon TX/TX2, from using bitfields to BIT_ULL() / GENMASK_ULL etc. This works just fine with big- and little-endian systems.

But, as you probably have guessed, these header are auto-generated and changing this to BIT_ULL etc is really painful (time consuming) and also potentially error prone. So I really would like to stay with the bitfields for those structs / variables, that are solely used by the Octeon TX/TX2 (little-endian) platforms.

I hope this is okay.

Thanks,
Stefan

#41 lore raw

PATCH 13/24 arm: octeontx: Add headers for OcteonTX

HI Stefan,

Quoted 54 lines · Stefan Roese

Hi Simon,

Quoted 30 lines · Simon Glass

Hi Stefan,

Quoted 19 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

---

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(+)
Quoted 7 lines

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

Quoted 6 lines

Generic thoughts to consider:
- drop extra brackets around constants - e.g. MIO_EMM_BAR_E_MIO_EMM_PF_BAR4
- use #define or enum instead of inline functions, e.g. MIO_EMM_DMA
- lower-case hex

Yes, thanks. I agree. Let me check, if I can find some time to clean this up a bit more.

Quoted 1 line

I don't normally see bitfields in U-Boot. Is that a good idea?

It is not, I agree. I've been bitten by those bitfields in the other Octeon drivers before (I2C, SPI etc). Bitfields make portable driver code quite hard. You need to add separate bitfield definitions for big- endian and little-endian support. So I switched on the common drivers, and with common I mean drivers supporting MIPS Octeon and ARM Octeon TX/TX2, from using bitfields to BIT_ULL() / GENMASK_ULL etc. This works just fine with big- and little-endian systems.

Quoted 8 lines

But, as you probably have guessed, these header are auto-generated and changing this to BIT_ULL etc is really painful (time consuming) and also potentially error prone. So I really would like to stay with the bitfields for those structs / variables, that are solely used by the Octeon TX/TX2 (little-endian) platforms.

I hope this is okay.

Seems OK to me.

Regards,
Simon

#42 lore raw

PATCH 14/24 arm: octeontx2: Add headers for OcteonTX2

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

---

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.27.0

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

#43 lore raw

PATCH 14/24 arm: octeontx2: Add headers for OcteonTX2

Hi Stefan,

Quoted 30 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

---

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
Quoted 8 lines
 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

Same comments as the previous patch.

Also, how much of this ~20K lines of code is actually used in U-Boot?

Regards,
Simon

#44 lore raw

PATCH 14/24 arm: octeontx2: Add headers for OcteonTX2

Hi Simon,

Quoted 42 lines · Simon Glass

Hi Stefan,

Quoted 25 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

---

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(+)
Quoted 13 lines

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

Quoted 1 line

Same comments as the previous patch.

Yes. And the same comments from my side on this.

Quoted 1 line

Also, how much of this ~20K lines of code is actually used in U-Boot?

I could try to skim though the headers and try to find some unused parts. Perhaps I'll find some time next week to work on this.

Thanks,
Stefan

#45 lore raw

PATCH 15/24 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 v1:
- Change patch subject
- Use constants from pci_ids.h instead of hardcoded values

 drivers/ata/ahci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/ata/ahci.c +8 -0
index 47cdea1f58..28161b5e62 100644
@@ -1198,10 +1198,18 @@ 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);
 
+	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.27.0
#46 lore raw

PATCH 15/24 ata: ahci: Add BAR index quirk for Cavium PCI SATA device

Hi Stefan,

Quoted 10 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

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

Quoted 8 lines

---

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

 drivers/ata/ahci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
Quoted 11 lines
drivers/ata/ahci.c +1 -0
index 47cdea1f58..28161b5e62 100644
@@ -1198,10 +1198,18 @@ int ahci_probe_scsi(struct udevice *ahci_dev, ulong base)
 int ahci_probe_scsi_pci(struct udevice *ahci_dev)
 {
        ulong base;
+       u16 vendor, device;
 

drivers/ata/ahci.c int ahci_probe_scsi(struct udevice *ahci_dev, ulong base) · line 1212

Quoted 10 lines
drivers/ata/ahci.c +7 -0
        base = (ulong)dm_pci_map_bar(ahci_dev, PCI_BASE_ADDRESS_5,
                                     PCI_REGION_MEM);
 
+       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);

How should we handle this in general? Should we have a Kconfig to enable quirks in ahci?

Quoted 6 lines
drivers/ata/ahci.c +0 -1
        return ahci_probe_scsi(ahci_dev, base);
 }
 #endif
--

2.27.0

Regards,
Simon

#47 lore raw

PATCH 15/24 ata: ahci: Add BAR index quirk for Cavium PCI SATA device

Hi Simon,

Quoted 38 lines · Simon Glass

Hi Stefan,

Quoted 10 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

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

Quoted 8 lines

---

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

  drivers/ata/ahci.c | 8 ++++++++
  1 file changed, 8 insertions(+)
Quoted 14 lines
drivers/ata/ahci.c +1 -0
index 47cdea1f58..28161b5e62 100644
@@ -1198,10 +1198,18 @@ 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);
 
Quoted 10 lines

drivers/ata/ahci.c int ahci_probe_scsi(struct udevice *ahci_dev, ulong base) · line 1212

Quoted 7 lines
drivers/ata/ahci.c +7 -0
+       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);

How should we handle this in general? Should we have a Kconfig to enable quirks in ahci?

Perhaps we should wait a bit until, other "quirks" for AHCI get posted. Only then we can see, where and how these can be grouped and can "extract" them into Kconfig option(s). One quirk is the overhead of the additional Kconfig option / handling not worth, IMHO.

What do you think?

Thanks,
Stefan

#48 lore raw

PATCH 15/24 ata: ahci: Add BAR index quirk for Cavium PCI SATA device

Hi Stefan,

Quoted 53 lines · Stefan Roese

Hi Simon,

Quoted 38 lines · Simon Glass

Hi Stefan,

Quoted 10 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

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

Quoted 8 lines

---

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

  drivers/ata/ahci.c | 8 ++++++++
  1 file changed, 8 insertions(+)
Quoted 14 lines
drivers/ata/ahci.c +1 -0
index 47cdea1f58..28161b5e62 100644
@@ -1198,10 +1198,18 @@ 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);
 
Quoted 10 lines

drivers/ata/ahci.c int ahci_probe_scsi(struct udevice *ahci_dev, ulong base) · line 1212

Quoted 7 lines
drivers/ata/ahci.c +7 -0
+       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);

How should we handle this in general? Should we have a Kconfig to enable quirks in ahci?

Quoted 6 lines

Perhaps we should wait a bit until, other "quirks" for AHCI get posted. Only then we can see, where and how these can be grouped and can "extract" them into Kconfig option(s). One quirk is the overhead of the additional Kconfig option / handling not worth, IMHO.

What do you think?

Sounds OK to me. You could add a note about it perhaps.

Regards,
SImon

#49 lore raw

PATCH 15/24 ata: ahci: Add BAR index quirk for Cavium PCI SATA device

Hi Simon,

Quoted 56 lines · Simon Glass

Hi Stefan,

Quoted 53 lines · Stefan Roese

Hi Simon,

Quoted 48 lines · Simon Glass

Hi Stefan,

Quoted 10 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

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

Quoted 8 lines

---

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

   drivers/ata/ahci.c | 8 ++++++++
   1 file changed, 8 insertions(+)
Quoted 11 lines
drivers/ata/ahci.c +1 -0
index 47cdea1f58..28161b5e62 100644
@@ -1198,10 +1198,18 @@ int ahci_probe_scsi(struct udevice *ahci_dev, ulong base)
   int ahci_probe_scsi_pci(struct udevice *ahci_dev)
   {
          ulong base;
+       u16 vendor, device;
 

drivers/ata/ahci.c int ahci_probe_scsi(struct udevice *ahci_dev, ulong base) · line 1212

Quoted 10 lines
drivers/ata/ahci.c +7 -0
          base = (ulong)dm_pci_map_bar(ahci_dev, PCI_BASE_ADDRESS_5,
                                       PCI_REGION_MEM);
 
+       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);

How should we handle this in general? Should we have a Kconfig to enable quirks in ahci?

Quoted 8 lines
Quoted 6 lines

Perhaps we should wait a bit until, other "quirks" for AHCI get posted. Only then we can see, where and how these can be grouped and can "extract" them into Kconfig option(s). One quirk is the overhead of the additional Kconfig option / handling not worth, IMHO.

What do you think?

Sounds OK to me. You could add a note about it perhaps.

Okay, will do.

Thanks,
Stefan

#50 lore raw

PATCH 16/24 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 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 | 344 +++++++++++++++++++++++++++++++++++++
 3 files changed, 353 insertions(+)
 create mode 100644 drivers/pci/pci_octeontx.c
drivers/pci/Kconfig +8 -0
index bc77c23f89..89cca6ffb3 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 6378821aaf..0529cceee7 100644
@@ -45,3 +45,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 +344 -0

344 lines not on this page · raw message

Signature · 1 line
2.27.0
#51 lore raw

PATCH 16/24 pci: Add PCI controller driver for OcteonTX / TX2

Hi Stefan,

Quoted 22 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

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

---

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

Quoted 5 lines
 drivers/pci/Kconfig        |   8 +
 drivers/pci/Makefile       |   1 +
 drivers/pci/pci_octeontx.c | 344 +++++++++++++++++++++++++++++++++++++
 3 files changed, 353 insertions(+)
 create mode 100644 drivers/pci/pci_octeontx.c
Quoted 44 lines
drivers/pci/Kconfig +8 -0
index bc77c23f89..89cca6ffb3 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 6378821aaf..0529cceee7 100644
@@ -45,3 +45,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 +9 -0
new file mode 100644
index 0000000000..5c6a6f05f2
@@ -0,0 +1,344 @@
+// SPDX-License-Identifier:    GPL-2.0
+/*
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#include <dm.h>
+#include <errno.h>

drivers/pci/pci_octeontx.c line 19

Quoted 10 lines
drivers/pci/pci_octeontx.c new file +10 -0
+#include <fdtdec.h>
+#include <log.h>
+#include <malloc.h>
+#include <pci.h>
+
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+enum {

comment?

drivers/pci/pci_octeontx.c line 32

Quoted 13 lines
drivers/pci/pci_octeontx.c new file +13 -0
+       OTX_ECAM,
+       OTX_PEM,
+       OTX2_PEM,
+};
+
+/**
+ * struct octeontx_pci - Driver private data
+ * @type:      Device type matched via compatible
+ * @cfg:       Config resource
+ * @bus:       Bus resource
+ */
+struct octeontx_pci {
+       unsigned int type;

Is this the enum above?

Quoted 30 lines
drivers/pci/pci_octeontx.c new file +30 -0
+
+       struct fdt_resource cfg;
+       struct fdt_resource bus;
+};
+
+static uintptr_t octeontx_cfg_addr(struct octeontx_pci *pcie,
+                                  int bus_offs, int shift_offs,
+                                  pci_dev_t bdf, uint offset)
+{
+       u32 bus, dev, func;
+       uintptr_t address;
+
+       bus = PCI_BUS(bdf) + bus_offs;
+       dev = PCI_DEV(bdf);
+       func = PCI_FUNC(bdf);
+
+       address = (bus << (20 + shift_offs)) |
+               (dev << (15 + shift_offs)) |
+               (func << (12 + shift_offs)) | offset;
+       address += pcie->cfg.start;
+
+       return address;
+}
+
+static ulong readl_size(uintptr_t addr, enum pci_size_t size)
+{
+       ulong val;
+
+       switch (size) {
+       case PCI_SIZE_8:

drivers/pci/pci_octeontx.c line 72

Quoted 10 lines
drivers/pci/pci_octeontx.c new file +10 -0
+               val = readb(addr);
+               break;
+       case PCI_SIZE_16:
+               val = readw(addr);
+               break;
+       case PCI_SIZE_32:
+               val = readl(addr);
+               break;
+       default:
+               printf("Invalid size\n");

return -EINVAL perhaps? Otherwise val is unset.

Quoted 66 lines
drivers/pci/pci_octeontx.c new file +66 -0
+       };
+
+       return val;
+}
+
+static void writel_size(uintptr_t addr, enum pci_size_t size, ulong valuep)
+{
+       switch (size) {
+       case PCI_SIZE_8:
+               writeb(valuep, addr);
+               break;
+       case PCI_SIZE_16:
+               writew(valuep, addr);
+               break;
+       case PCI_SIZE_32:
+               writel(valuep, addr);
+               break;
+       default:
+               printf("Invalid size\n");
+       };
+}
+
+static int octeontx_ecam_read_config(const struct udevice *bus, pci_dev_t bdf,
+                                    uint offset, ulong *valuep,
+                                    enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
+       uintptr_t address;
+
+       address = octeontx_cfg_addr(pcie, pcie->bus.start - hose->first_busno,
+                                   0, bdf, offset);
+       *valuep = readl_size(address, size);
+
+       debug("%02x.%02x.%02x: u%d %x -> %lx\n",
+             PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), size, offset, *valuep);
+
+       return 0;
+}
+
+static int octeontx_ecam_write_config(struct udevice *bus, pci_dev_t bdf,
+                                     uint offset, ulong value,
+                                     enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
+       uintptr_t address;
+
+       address = octeontx_cfg_addr(pcie, pcie->bus.start - hose->first_busno,
+                                   0, bdf, offset);
+       writel_size(address, size, value);
+
+       debug("%02x.%02x.%02x: u%d %x <- %lx\n",
+             PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), size, offset, value);
+
+       return 0;
+}
+
+static int octeontx_pem_read_config(const struct udevice *bus, pci_dev_t bdf,
+                                   uint offset, ulong *valuep,
+                                   enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
+       uintptr_t address;
+       u8 hdrtype;

drivers/pci/pci_octeontx.c line 148

Quoted 10 lines
drivers/pci/pci_octeontx.c new file +10 -0
+       u8 pri_bus = pcie->bus.start + 1 - hose->first_busno;
+       u32 bus_offs = (pri_bus << 16) | (pri_bus << 8) | (pri_bus << 0);
+
+       address = octeontx_cfg_addr(pcie, 1 - hose->first_busno, 4,
+                                   bdf, 0);
+
+       *valuep = pci_conv_32_to_size(~0UL, offset, size);
+
+       if (PCI_BUS(bdf) == 1 && PCI_DEV(bdf) > 0)
+               return 0;

Can you put this check in a function? It seems to appear everywhere. Also, shouldn't you return -EPERM, or similar?

Quoted 147 lines
drivers/pci/pci_octeontx.c new file +147 -0
+
+       *valuep = readl_size(address + offset, size);
+
+       hdrtype = readb(address + PCI_HEADER_TYPE);
+       if (hdrtype == PCI_HEADER_TYPE_BRIDGE &&
+           offset >= PCI_PRIMARY_BUS &&
+           offset <= PCI_SUBORDINATE_BUS &&
+           *valuep != pci_conv_32_to_size(~0UL, offset, size))
+               *valuep -= pci_conv_32_to_size(bus_offs, offset, size);
+
+       return 0;
+}
+
+static int octeontx_pem_write_config(struct udevice *bus, pci_dev_t bdf,
+                                    uint offset, ulong value,
+                                    enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
+       uintptr_t address;
+       u8 hdrtype;
+       u8 pri_bus = pcie->bus.start + 1 - hose->first_busno;
+       u32 bus_offs = (pri_bus << 16) | (pri_bus << 8) | (pri_bus << 0);
+
+       address = octeontx_cfg_addr(pcie, 1 - hose->first_busno, 4, bdf, 0);
+
+       hdrtype = readb(address + PCI_HEADER_TYPE);
+       if (hdrtype == PCI_HEADER_TYPE_BRIDGE &&
+           offset >= PCI_PRIMARY_BUS &&
+           offset <= PCI_SUBORDINATE_BUS &&
+           value != pci_conv_32_to_size(~0UL, offset, size))
+               value +=  pci_conv_32_to_size(bus_offs, offset, size);
+
+       if (PCI_BUS(bdf) == 1 && PCI_DEV(bdf) > 0)
+               return 0;
+
+       writel_size(address + offset, size, value);
+
+       debug("%02x.%02x.%02x: u%d %x (%lx) <- %lx\n",
+             PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), size, offset,
+             address, value);
+
+       return 0;
+}
+
+static int octeontx2_pem_read_config(const struct udevice *bus, pci_dev_t bdf,
+                                    uint offset, ulong *valuep,
+                                    enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
+       uintptr_t address;
+
+       address = octeontx_cfg_addr(pcie, 1 - hose->first_busno, 0,
+                                   bdf, 0);
+
+       *valuep = pci_conv_32_to_size(~0UL, offset, size);
+
+       if (PCI_BUS(bdf) == 1 && PCI_DEV(bdf) > 0)
+               return 0;
+
+       *valuep = readl_size(address + offset, size);
+
+       debug("%02x.%02x.%02x: u%d %x (%lx) -> %lx\n",
+             PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), size, offset,
+             address, *valuep);
+
+       return 0;
+}
+
+static int octeontx2_pem_write_config(struct udevice *bus, pci_dev_t bdf,
+                                     uint offset, ulong value,
+                                     enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
+       uintptr_t address;
+
+       address = octeontx_cfg_addr(pcie, 1 - hose->first_busno, 0,
+                                   bdf, 0);
+
+       if (PCI_BUS(bdf) == 1 && PCI_DEV(bdf) > 0)
+               return 0;
+
+       writel_size(address + offset, size, value);
+
+       debug("%02x.%02x.%02x: u%d %x (%lx) <- %lx\n",
+             PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), size, offset,
+             address, value);
+
+       return 0;
+}
+
+int pci_octeontx_read_config(const struct udevice *bus, pci_dev_t bdf,
+                            uint offset, ulong *valuep,
+                            enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       int ret = -EIO;
+
+       switch (pcie->type) {
+       case OTX_ECAM:
+               ret = octeontx_ecam_read_config(bus, bdf, offset, valuep,
+                                               size);
+               break;
+       case OTX_PEM:
+               ret = octeontx_pem_read_config(bus, bdf, offset, valuep,
+                                              size);
+               break;
+       case OTX2_PEM:
+               ret = octeontx2_pem_read_config(bus, bdf, offset, valuep,
+                                               size);
+               break;
+       }
+
+       return ret;
+}
+
+int pci_octeontx_write_config(struct udevice *bus, pci_dev_t bdf,
+                             uint offset, ulong value,
+                             enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       int ret = -EIO;
+
+       switch (pcie->type) {
+       case OTX_ECAM:
+               ret = octeontx_ecam_write_config(bus, bdf, offset, value,
+                                                size);
+               break;
+       case OTX_PEM:
+               ret = octeontx_pem_write_config(bus, bdf, offset, value,
+                                               size);
+               break;
+       case OTX2_PEM:
+               ret = octeontx2_pem_write_config(bus, bdf, offset, value,
+                                                size);
+               break;
+       }
+
+       return ret;
+}
+
+static int pci_octeontx_ofdata_to_platdata(struct udevice *dev)
+{
+       return 0;
+}

drivers/pci/pci_octeontx.c line 305

Quoted 10 lines
drivers/pci/pci_octeontx.c new file +10 -0
+
+static int pci_octeontx_probe(struct udevice *dev)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(dev);
+       int err;
+
+       pcie->type = dev_get_driver_data(dev);
+
+       err = fdt_get_resource(gd->fdt_blob, dev->node.of_offset, "reg", 0,
+                              &pcie->cfg);

We really should have a livetree API for this.

drivers/pci/pci_octeontx.c line 312

Quoted 7 lines
drivers/pci/pci_octeontx.c new file +7 -0
+       if (err) {
+               debug("Error reading resource: %s\n", fdt_strerror(err));
+               return err;
+       }
+
+       err = fdtdec_get_pci_bus_range(gd->fdt_blob, dev->node.of_offset,
+                                      &pcie->bus);

and this...

Quoted 33 lines
drivers/pci/pci_octeontx.c new file +32 -1
+       if (err) {
+               debug("Error reading resource: %s\n", fdt_strerror(err));
+               return err;
+       }
+
+       return 0;
+}
+
+static const struct dm_pci_ops pci_octeontx_ops = {
+       .read_config    = pci_octeontx_read_config,
+       .write_config   = pci_octeontx_write_config,
+};
+
+static const struct udevice_id pci_octeontx_ids[] = {
+       { .compatible = "cavium,pci-host-thunder-ecam", .data = OTX_ECAM },
+       { .compatible = "cavium,pci-host-octeontx-ecam", .data = OTX_ECAM },
+       { .compatible = "pci-host-ecam-generic", .data = OTX_ECAM },
+       { .compatible = "cavium,pci-host-thunder-pem", .data = OTX_PEM },
+       { .compatible = "marvell,pci-host-octeontx2-pem", .data = OTX2_PEM },
+       { }
+};
+
+U_BOOT_DRIVER(pci_octeontx) = {
+       .name   = "pci_octeontx",
+       .id     = UCLASS_PCI,
+       .of_match = pci_octeontx_ids,
+       .ops    = &pci_octeontx_ops,
+       .ofdata_to_platdata = pci_octeontx_ofdata_to_platdata,
+       .probe  = pci_octeontx_probe,
+       .priv_auto_alloc_size = sizeof(struct octeontx_pci),
+       .flags = DM_FLAG_PRE_RELOC,
+};
--
Quoted 2 lines

2.27.0

Regards,
Simon

#52 lore raw

PATCH 16/24 pci: Add PCI controller driver for OcteonTX / TX2

Hi Simon,

Quoted 81 lines · Simon Glass

Hi Stefan,

Quoted 22 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

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

---

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

Quoted 5 lines
  drivers/pci/Kconfig        |   8 +
  drivers/pci/Makefile       |   1 +
  drivers/pci/pci_octeontx.c | 344 +++++++++++++++++++++++++++++++++++++
  3 files changed, 353 insertions(+)

create mode 100644 drivers/pci/pci_octeontx.c

Quoted 48 lines
drivers/pci/Kconfig +8 -0
index bc77c23f89..89cca6ffb3 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 6378821aaf..0529cceee7 100644
@@ -45,3 +45,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 +13 -0
new file mode 100644
index 0000000000..5c6a6f05f2
@@ -0,0 +1,344 @@
+// SPDX-License-Identifier:    GPL-2.0
+/*
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#include <dm.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <log.h>
+#include <malloc.h>
+#include <pci.h>
Quoted 8 lines

drivers/pci/pci_octeontx.c line 19

Quoted 6 lines
drivers/pci/pci_octeontx.c new file +6 -0
+
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+enum {

comment?

Will add in next version.

Quoted 7 lines
Quoted 7 lines
drivers/pci/pci_octeontx.c new file +7 -0
+       OTX_ECAM,
+       OTX_PEM,
+       OTX2_PEM,
+};
+
+/**
+ * struct octeontx_pci - Driver private data
Quoted 8 lines

drivers/pci/pci_octeontx.c line 32

Quoted 6 lines
drivers/pci/pci_octeontx.c new file +6 -0
+ * @type:      Device type matched via compatible
+ * @cfg:       Config resource
+ * @bus:       Bus resource
+ */
+struct octeontx_pci {
+       unsigned int type;

Is this the enum above?

Yes. Will add some comment here.

Quoted 34 lines
Quoted 34 lines
drivers/pci/pci_octeontx.c new file +34 -0
+
+       struct fdt_resource cfg;
+       struct fdt_resource bus;
+};
+
+static uintptr_t octeontx_cfg_addr(struct octeontx_pci *pcie,
+                                  int bus_offs, int shift_offs,
+                                  pci_dev_t bdf, uint offset)
+{
+       u32 bus, dev, func;
+       uintptr_t address;
+
+       bus = PCI_BUS(bdf) + bus_offs;
+       dev = PCI_DEV(bdf);
+       func = PCI_FUNC(bdf);
+
+       address = (bus << (20 + shift_offs)) |
+               (dev << (15 + shift_offs)) |
+               (func << (12 + shift_offs)) | offset;
+       address += pcie->cfg.start;
+
+       return address;
+}
+
+static ulong readl_size(uintptr_t addr, enum pci_size_t size)
+{
+       ulong val;
+
+       switch (size) {
+       case PCI_SIZE_8:
+               val = readb(addr);
+               break;
+       case PCI_SIZE_16:
+               val = readw(addr);
Quoted 8 lines

drivers/pci/pci_octeontx.c line 72

Quoted 6 lines
drivers/pci/pci_octeontx.c new file +6 -0
+               break;
+       case PCI_SIZE_32:
+               val = readl(addr);
+               break;
+       default:
+               printf("Invalid size\n");

return -EINVAL perhaps? Otherwise val is unset.

Good idea. Will update.

Quoted 71 lines
Quoted 71 lines
drivers/pci/pci_octeontx.c new file +71 -0
+       };
+
+       return val;
+}
+
+static void writel_size(uintptr_t addr, enum pci_size_t size, ulong valuep)
+{
+       switch (size) {
+       case PCI_SIZE_8:
+               writeb(valuep, addr);
+               break;
+       case PCI_SIZE_16:
+               writew(valuep, addr);
+               break;
+       case PCI_SIZE_32:
+               writel(valuep, addr);
+               break;
+       default:
+               printf("Invalid size\n");
+       };
+}
+
+static int octeontx_ecam_read_config(const struct udevice *bus, pci_dev_t bdf,
+                                    uint offset, ulong *valuep,
+                                    enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
+       uintptr_t address;
+
+       address = octeontx_cfg_addr(pcie, pcie->bus.start - hose->first_busno,
+                                   0, bdf, offset);
+       *valuep = readl_size(address, size);
+
+       debug("%02x.%02x.%02x: u%d %x -> %lx\n",
+             PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), size, offset, *valuep);
+
+       return 0;
+}
+
+static int octeontx_ecam_write_config(struct udevice *bus, pci_dev_t bdf,
+                                     uint offset, ulong value,
+                                     enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
+       uintptr_t address;
+
+       address = octeontx_cfg_addr(pcie, pcie->bus.start - hose->first_busno,
+                                   0, bdf, offset);
+       writel_size(address, size, value);
+
+       debug("%02x.%02x.%02x: u%d %x <- %lx\n",
+             PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), size, offset, value);
+
+       return 0;
+}
+
+static int octeontx_pem_read_config(const struct udevice *bus, pci_dev_t bdf,
+                                   uint offset, ulong *valuep,
+                                   enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
+       uintptr_t address;
+       u8 hdrtype;
+       u8 pri_bus = pcie->bus.start + 1 - hose->first_busno;
+       u32 bus_offs = (pri_bus << 16) | (pri_bus << 8) | (pri_bus << 0);
+
+       address = octeontx_cfg_addr(pcie, 1 - hose->first_busno, 4,
+                                   bdf, 0);
Quoted 8 lines

drivers/pci/pci_octeontx.c line 148

Quoted 5 lines
drivers/pci/pci_octeontx.c new file +5 -0
+
+       *valuep = pci_conv_32_to_size(~0UL, offset, size);
+
+       if (PCI_BUS(bdf) == 1 && PCI_DEV(bdf) > 0)
+               return 0;

Can you put this check in a function? It seems to appear everywhere. Also, shouldn't you return -EPERM, or similar?

Will change in next version.

Quoted 151 lines
Quoted 151 lines
drivers/pci/pci_octeontx.c new file +151 -0
+
+       *valuep = readl_size(address + offset, size);
+
+       hdrtype = readb(address + PCI_HEADER_TYPE);
+       if (hdrtype == PCI_HEADER_TYPE_BRIDGE &&
+           offset >= PCI_PRIMARY_BUS &&
+           offset <= PCI_SUBORDINATE_BUS &&
+           *valuep != pci_conv_32_to_size(~0UL, offset, size))
+               *valuep -= pci_conv_32_to_size(bus_offs, offset, size);
+
+       return 0;
+}
+
+static int octeontx_pem_write_config(struct udevice *bus, pci_dev_t bdf,
+                                    uint offset, ulong value,
+                                    enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
+       uintptr_t address;
+       u8 hdrtype;
+       u8 pri_bus = pcie->bus.start + 1 - hose->first_busno;
+       u32 bus_offs = (pri_bus << 16) | (pri_bus << 8) | (pri_bus << 0);
+
+       address = octeontx_cfg_addr(pcie, 1 - hose->first_busno, 4, bdf, 0);
+
+       hdrtype = readb(address + PCI_HEADER_TYPE);
+       if (hdrtype == PCI_HEADER_TYPE_BRIDGE &&
+           offset >= PCI_PRIMARY_BUS &&
+           offset <= PCI_SUBORDINATE_BUS &&
+           value != pci_conv_32_to_size(~0UL, offset, size))
+               value +=  pci_conv_32_to_size(bus_offs, offset, size);
+
+       if (PCI_BUS(bdf) == 1 && PCI_DEV(bdf) > 0)
+               return 0;
+
+       writel_size(address + offset, size, value);
+
+       debug("%02x.%02x.%02x: u%d %x (%lx) <- %lx\n",
+             PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), size, offset,
+             address, value);
+
+       return 0;
+}
+
+static int octeontx2_pem_read_config(const struct udevice *bus, pci_dev_t bdf,
+                                    uint offset, ulong *valuep,
+                                    enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
+       uintptr_t address;
+
+       address = octeontx_cfg_addr(pcie, 1 - hose->first_busno, 0,
+                                   bdf, 0);
+
+       *valuep = pci_conv_32_to_size(~0UL, offset, size);
+
+       if (PCI_BUS(bdf) == 1 && PCI_DEV(bdf) > 0)
+               return 0;
+
+       *valuep = readl_size(address + offset, size);
+
+       debug("%02x.%02x.%02x: u%d %x (%lx) -> %lx\n",
+             PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), size, offset,
+             address, *valuep);
+
+       return 0;
+}
+
+static int octeontx2_pem_write_config(struct udevice *bus, pci_dev_t bdf,
+                                     uint offset, ulong value,
+                                     enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
+       uintptr_t address;
+
+       address = octeontx_cfg_addr(pcie, 1 - hose->first_busno, 0,
+                                   bdf, 0);
+
+       if (PCI_BUS(bdf) == 1 && PCI_DEV(bdf) > 0)
+               return 0;
+
+       writel_size(address + offset, size, value);
+
+       debug("%02x.%02x.%02x: u%d %x (%lx) <- %lx\n",
+             PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), size, offset,
+             address, value);
+
+       return 0;
+}
+
+int pci_octeontx_read_config(const struct udevice *bus, pci_dev_t bdf,
+                            uint offset, ulong *valuep,
+                            enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       int ret = -EIO;
+
+       switch (pcie->type) {
+       case OTX_ECAM:
+               ret = octeontx_ecam_read_config(bus, bdf, offset, valuep,
+                                               size);
+               break;
+       case OTX_PEM:
+               ret = octeontx_pem_read_config(bus, bdf, offset, valuep,
+                                              size);
+               break;
+       case OTX2_PEM:
+               ret = octeontx2_pem_read_config(bus, bdf, offset, valuep,
+                                               size);
+               break;
+       }
+
+       return ret;
+}
+
+int pci_octeontx_write_config(struct udevice *bus, pci_dev_t bdf,
+                             uint offset, ulong value,
+                             enum pci_size_t size)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(bus);
+       int ret = -EIO;
+
+       switch (pcie->type) {
+       case OTX_ECAM:
+               ret = octeontx_ecam_write_config(bus, bdf, offset, value,
+                                                size);
+               break;
+       case OTX_PEM:
+               ret = octeontx_pem_write_config(bus, bdf, offset, value,
+                                               size);
+               break;
+       case OTX2_PEM:
+               ret = octeontx2_pem_write_config(bus, bdf, offset, value,
+                                                size);
+               break;
+       }
+
+       return ret;
+}
+
+static int pci_octeontx_ofdata_to_platdata(struct udevice *dev)
+{
+       return 0;
+}
+
+static int pci_octeontx_probe(struct udevice *dev)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(dev);
Quoted 8 lines

drivers/pci/pci_octeontx.c line 305

Quoted 6 lines
drivers/pci/pci_octeontx.c new file +6 -0
+       int err;
+
+       pcie->type = dev_get_driver_data(dev);
+
+       err = fdt_get_resource(gd->fdt_blob, dev->node.of_offset, "reg", 0,
+                              &pcie->cfg);

We really should have a livetree API for this.

Is this mandatory for this patch to get accepted? Or can I add this to my list and post this later and port this driver to using these livetree functions then?

BTW: Do you have an example for a similar function added to livetree, so that I can choose the "correct" naming?

Thanks,
Stefan

Quoted 40 lines

drivers/pci/pci_octeontx.c line 312

Quoted 7 lines
drivers/pci/pci_octeontx.c new file +7 -0
+       if (err) {
+               debug("Error reading resource: %s\n", fdt_strerror(err));
+               return err;
+       }
+
+       err = fdtdec_get_pci_bus_range(gd->fdt_blob, dev->node.of_offset,
+                                      &pcie->bus);

and this...

Quoted 30 lines
drivers/pci/pci_octeontx.c new file +30 -0
+       if (err) {
+               debug("Error reading resource: %s\n", fdt_strerror(err));
+               return err;
+       }
+
+       return 0;
+}
+
+static const struct dm_pci_ops pci_octeontx_ops = {
+       .read_config    = pci_octeontx_read_config,
+       .write_config   = pci_octeontx_write_config,
+};
+
+static const struct udevice_id pci_octeontx_ids[] = {
+       { .compatible = "cavium,pci-host-thunder-ecam", .data = OTX_ECAM },
+       { .compatible = "cavium,pci-host-octeontx-ecam", .data = OTX_ECAM },
+       { .compatible = "pci-host-ecam-generic", .data = OTX_ECAM },
+       { .compatible = "cavium,pci-host-thunder-pem", .data = OTX_PEM },
+       { .compatible = "marvell,pci-host-octeontx2-pem", .data = OTX2_PEM },
+       { }
+};
+
+U_BOOT_DRIVER(pci_octeontx) = {
+       .name   = "pci_octeontx",
+       .id     = UCLASS_PCI,
+       .of_match = pci_octeontx_ids,
+       .ops    = &pci_octeontx_ops,
+       .ofdata_to_platdata = pci_octeontx_ofdata_to_platdata,
+       .probe  = pci_octeontx_probe,
+       .priv_auto_alloc_size = sizeof(struct octeontx_pci),
Quoted 9 lines
Quoted 5 lines
drivers/pci/pci_octeontx.c new file +2 -1
+       .flags = DM_FLAG_PRE_RELOC,
+};
--

2.27.0

Regards,
Simon

Viele Gr??e,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
#53 lore raw

PATCH 16/24 pci: Add PCI controller driver for OcteonTX / TX2

Hi Stefan,

Quoted 38 lines · Stefan Roese

Hi Simon,

Quoted 34 lines · Simon Glass

Hi Stefan,

Quoted 22 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

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

---

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

Quoted 5 lines
  drivers/pci/Kconfig        |   8 +
  drivers/pci/Makefile       |   1 +
  drivers/pci/pci_octeontx.c | 344 +++++++++++++++++++++++++++++++++++++
  3 files changed, 353 insertions(+)

create mode 100644 drivers/pci/pci_octeontx.c

Quoted 1 line

[,,]

Quoted 12 lines
Quoted 11 lines

drivers/pci/pci_octeontx.c line 305

Quoted 9 lines
drivers/pci/pci_octeontx.c new file +9 -0
+static int pci_octeontx_probe(struct udevice *dev)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(dev);
+       int err;
+
+       pcie->type = dev_get_driver_data(dev);
+
+       err = fdt_get_resource(gd->fdt_blob, dev->node.of_offset, "reg", 0,
+                              &pcie->cfg);

We really should have a livetree API for this.

Quoted 3 lines

Is this mandatory for this patch to get accepted? Or can I add this to my list and post this later and port this driver to using these livetree functions then?

No, you have my review tag and later is fine.

Quoted 3 lines

BTW: Do you have an example for a similar function added to livetree, so that I can choose the "correct" naming?

Well we have dev_read_resource() so I'm hoping that they are not too far away from what you need.

Regards,
Simon

#54 lore raw

PATCH 16/24 pci: Add PCI controller driver for OcteonTX / TX2

Hi Simon,

Quoted 56 lines · Simon Glass

Hi Stefan,

Quoted 38 lines · Stefan Roese

Hi Simon,

Quoted 34 lines · Simon Glass

Hi Stefan,

Quoted 22 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

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

---

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

Quoted 5 lines
   drivers/pci/Kconfig        |   8 +
   drivers/pci/Makefile       |   1 +
   drivers/pci/pci_octeontx.c | 344 +++++++++++++++++++++++++++++++++++++
   3 files changed, 353 insertions(+)

create mode 100644 drivers/pci/pci_octeontx.c

Quoted 1 line

[,,]

Quoted 12 lines
Quoted 11 lines

drivers/pci/pci_octeontx.c line 305

Quoted 9 lines
drivers/pci/pci_octeontx.c new file +9 -0
+static int pci_octeontx_probe(struct udevice *dev)
+{
+       struct octeontx_pci *pcie = (struct octeontx_pci *)dev_get_priv(dev);
+       int err;
+
+       pcie->type = dev_get_driver_data(dev);
+
+       err = fdt_get_resource(gd->fdt_blob, dev->node.of_offset, "reg", 0,
+                              &pcie->cfg);

We really should have a livetree API for this.

Quoted 5 lines
Quoted 3 lines

Is this mandatory for this patch to get accepted? Or can I add this to my list and post this later and port this driver to using these livetree functions then?

No, you have my review tag and later is fine.

Okay.

Quoted 6 lines
Quoted 3 lines

BTW: Do you have an example for a similar function added to livetree, so that I can choose the "correct" naming?

Well we have dev_read_resource() so I'm hoping that they are not too far away from what you need.

I've now added dev_read_pci_bus_range() in the next patchset version and selected OF_LIVE for both new platforms (Octeon TX & TX2).

Thanks,
Stefan

#55 lore raw

PATCH 17/24 mmc: Remove static qualifier on mmc_power_init

In reply to Stefan Roese

From: Suneel Garapati <[email protected]>

For platforms with multiple slot support like OcteonTX, this is invoked per slot.

---

Changes in v1:
- Change patch subject

 drivers/mmc/mmc.c | 2 +-
 include/mmc.h     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/mmc.c +1 -1
index f36d11ddc8..b26df59b91 100644
@@ -2683,7 +2683,7 @@ __weak void board_mmc_power_init(void)
 }
 #endif
 
-static int mmc_power_init(struct mmc *mmc)
+int mmc_power_init(struct mmc *mmc)
 {
 #if CONFIG_IS_ENABLED(DM_MMC)
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
include/mmc.h +1 -0
index 82562193cc..e05c59713c 100644
@@ -747,6 +747,7 @@ int mmc_unbind(struct udevice *dev);
 int mmc_initialize(struct bd_info *bis);
 int mmc_init_device(int num);
 int mmc_init(struct mmc *mmc);
+int mmc_power_init(struct mmc *mmc);
 int mmc_send_tuning(struct mmc *mmc, u32 opcode, int *cmd_error);
 
 #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \
Signature · 1 line
2.27.0
#56 lore raw

PATCH 17/24 mmc: Remove static qualifier on mmc_power_init

Hi Stefan,

Quoted 24 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

For platforms with multiple slot support like OcteonTX, this is invoked per slot.

---

Changes in v1:
- Change patch subject

 drivers/mmc/mmc.c | 2 +-
 include/mmc.h     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/mmc.c +0 -0
index f36d11ddc8..b26df59b91 100644

drivers/mmc/mmc.c __weak void board_mmc_power_init(void) · line 2686

Quoted 5 lines
drivers/mmc/mmc.c +1 -1
@@ -2683,7 +2683,7 @@ __weak void board_mmc_power_init(void)
 }
 #endif
 
-static int mmc_power_init(struct mmc *mmc)
+int mmc_power_init(struct mmc *mmc)

Shouldn't multi-slot be a core MMC featuren then?

include/mmc.h int mmc_unbind(struct udevice *dev); · line 750

Quoted 12 lines
drivers/mmc/mmc.c +0 -0
 {
 #if CONFIG_IS_ENABLED(DM_MMC)
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
include/mmc.h +1 -0
index 82562193cc..e05c59713c 100644
@@ -747,6 +747,7 @@ int mmc_unbind(struct udevice *dev);
 int mmc_initialize(struct bd_info *bis);
 int mmc_init_device(int num);
 int mmc_init(struct mmc *mmc);
+int mmc_power_init(struct mmc *mmc);

This badly needs a comment to explain what it is for and when to call it.

Quoted 6 lines
include/mmc.h +0 -1
 int mmc_send_tuning(struct mmc *mmc, u32 opcode, int *cmd_error);
 
 #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \
--

2.27.0

Regards,
Simon

#57 lore raw

PATCH 18/24 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 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 | 3904 ++++++++++++++++++++++++++++++++++
 drivers/mmc/octeontx_hsmmc.h |  207 ++
 4 files changed, 4121 insertions(+)
 create mode 100644 drivers/mmc/octeontx_hsmmc.c
 create mode 100644 drivers/mmc/octeontx_hsmmc.h
drivers/mmc/Kconfig +9 -0
index ad86c232c4..ce68e68680 100644
@@ -297,6 +297,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 e84c792999..e71297f725 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 +3904 -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.27.0

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

#58 lore raw

PATCH 19/24 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.

---

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.27.0

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

#59 lore raw

PATCH 20/24 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.

---

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 ec3fb49832..4e746c8156 100644
@@ -386,6 +386,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.27.0

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

#60 lore raw

PATCH 21/24 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.

---

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 4e746c8156..fdc94a50f0 100644
@@ -393,6 +393,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
@@ -400,6 +409,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.27.0

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

#61 lore raw

PATCH 22/24 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 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 | 57 +++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)
 create mode 100644 drivers/watchdog/octeontx_wdt.c
drivers/watchdog/Kconfig +10 -0
index bf06180cdd..981b33355d 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 if WDT && ARCH_OCTEONTX || ARCH_OCTEONTX2
+	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 519bbd3a40..fbba0ca386 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_SP805) += sp805_wdt.o
 obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o
drivers/watchdog/octeontx_wdt.c new file +57 -0

57 lines not on this page · raw message

Signature · 1 line
2.27.0
#62 lore raw

PATCH 22/24 watchdog: Add reset support for OcteonTX / TX2

Quoted 20 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

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

---

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()

Quoted 5 lines
 drivers/watchdog/Kconfig        | 10 ++++++
 drivers/watchdog/Makefile       |  1 +
 drivers/watchdog/octeontx_wdt.c | 57 +++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)
 create mode 100644 drivers/watchdog/octeontx_wdt.c
Quoted 55 lines
drivers/watchdog/Kconfig +10 -0
index bf06180cdd..981b33355d 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 if WDT && ARCH_OCTEONTX || ARCH_OCTEONTX2
+       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 519bbd3a40..fbba0ca386 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_SP805) += sp805_wdt.o
 obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o
drivers/watchdog/octeontx_wdt.c new file +15 -0
new file mode 100644
index 0000000000..a9c29ef26a
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#include <dm.h>
+#include <errno.h>
+#include <wdt.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define CORE0_POKE_OFFSET 0x50000

drivers/watchdog/octeontx_wdt.c line 25

Quoted 10 lines
drivers/watchdog/octeontx_wdt.c new file +10 -0
+
+struct octeontx_wdt {
+       void __iomem *reg;
+};
+
+static int octeontx_wdt_reset(struct udevice *dev)
+{
+       struct octeontx_wdt *priv = dev_get_priv(dev);
+
+       writeq(~0ULL, ((u64)priv->reg & ~0xfffffULL) | CORE0_POKE_OFFSET);

Do you actually need the mask? It seems odd that ->reg is part-way through the register set.

Quoted 35 lines
drivers/watchdog/octeontx_wdt.c new file +32 -1
+
+       return 0;
+}
+
+static int octeontx_wdt_probe(struct udevice *dev)
+{
+       struct octeontx_wdt *priv = dev_get_priv(dev);
+
+       priv->reg = dev_remap_addr(dev);
+       if (!priv->reg)
+               return -EINVAL;
+
+       return 0;
+}
+
+static const struct wdt_ops octeontx_wdt_ops = {
+       .reset = octeontx_wdt_reset,
+};
+
+static const struct udevice_id octeontx_wdt_ids[] = {
+       { .compatible = "arm,sbsa-gwdt" },
+       {}
+};
+
+U_BOOT_DRIVER(wdt_octeontx) = {
+       .name = "wdt_octeontx",
+       .id = UCLASS_WDT,
+       .of_match = octeontx_wdt_ids,
+       .ops = &octeontx_wdt_ops,
+       .priv_auto_alloc_size = sizeof(struct octeontx_wdt),
+       .probe = octeontx_wdt_probe,
+};
--

2.27.0

#63 lore raw

PATCH 22/24 watchdog: Add reset support for OcteonTX / TX2

Hi Simon,

Quoted 89 lines · Simon Glass
Quoted 20 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

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

---

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()

Quoted 5 lines
  drivers/watchdog/Kconfig        | 10 ++++++
  drivers/watchdog/Makefile       |  1 +
  drivers/watchdog/octeontx_wdt.c | 57 +++++++++++++++++++++++++++++++++
  3 files changed, 68 insertions(+)

create mode 100644 drivers/watchdog/octeontx_wdt.c

Quoted 60 lines
drivers/watchdog/Kconfig +10 -0
index bf06180cdd..981b33355d 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 if WDT && ARCH_OCTEONTX || ARCH_OCTEONTX2
+       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 519bbd3a40..fbba0ca386 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_SP805) += sp805_wdt.o
  obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o
drivers/watchdog/octeontx_wdt.c new file +20 -0
new file mode 100644
index 0000000000..a9c29ef26a
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#include <dm.h>
+#include <errno.h>
+#include <wdt.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define CORE0_POKE_OFFSET 0x50000
+
+struct octeontx_wdt {
+       void __iomem *reg;
+};
+
Quoted 8 lines

drivers/watchdog/octeontx_wdt.c line 25

Quoted 5 lines
drivers/watchdog/octeontx_wdt.c new file +5 -0
+static int octeontx_wdt_reset(struct udevice *dev)
+{
+       struct octeontx_wdt *priv = dev_get_priv(dev);
+
+       writeq(~0ULL, ((u64)priv->reg & ~0xfffffULL) | CORE0_POKE_OFFSET);

Do you actually need the mask? It seems odd that ->reg is part-way through the register set.

Frankly, I was wondering the same thing. I will double-check before submitting the next patchset version.

Thanks,
Stefan

#64 lore raw

PATCH 22/24 watchdog: Add reset support for OcteonTX / TX2

Hi Simon,

Quoted 103 lines · Stefan Roese

Hi Simon,

Quoted 91 lines · Simon Glass
Quoted 20 lines · Stefan Roese

From: Suneel Garapati <[email protected]>

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

---

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()

Quoted 5 lines
? drivers/watchdog/Kconfig??????? | 10 ++++++
? drivers/watchdog/Makefile?????? |? 1 +
? drivers/watchdog/octeontx_wdt.c | 57 +++++++++++++++++++++++++++++++++

? 3 files changed, 68 insertions(+)
? create mode 100644 drivers/watchdog/octeontx_wdt.c

Quoted 62 lines
drivers/watchdog/Kconfig +0 -0
index bf06180cdd..981b33355d 100644
@@ -139,6 +139,16 @@ config WDT_MTK

?????????? The watchdog timer is stopped when initialized. ?????????? It performs full SoC reset.

drivers/watchdog/Kconfig +10 -0
+config WDT_OCTEONTX
+?????? bool "OcteonTX core watchdog support"
+?????? depends on WDT && (ARCH_OCTEONTX || ARCH_OCTEONTX2)
+?????? default y if WDT && ARCH_OCTEONTX || ARCH_OCTEONTX2
+?????? 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 +0 -0
index 519bbd3a40..fbba0ca386 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_SP805) += sp805_wdt.o
? obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o

drivers/watchdog/octeontx_wdt.c new file +21 -0
new file mode 100644
index 0000000000..a9c29ef26a
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Marvell International Ltd.
+ *
+ * https://spdx.org/licenses
+ */
+
+#include <dm.h>
+#include <errno.h>
+#include <wdt.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define CORE0_POKE_OFFSET 0x50000
+
+struct octeontx_wdt {
+?????? void __iomem *reg;
+};
+
+static int octeontx_wdt_reset(struct udevice *dev)
Quoted 8 lines
Quoted 5 lines
drivers/watchdog/octeontx_wdt.c new file +4 -0
+{
+?????? struct octeontx_wdt *priv = dev_get_priv(dev);
+
+?????? writeq(~0ULL, ((u64)priv->reg & ~0xfffffULL) | 

CORE0_POKE_OFFSET);

Do you actually need the mask? It seems odd that ->reg is part-way through the register set.

Quoted 2 lines

Frankly, I was wondering the same thing. I will double-check before submitting the next patchset version.

The register address really needs some "tweaking" in these lower bits so that it matches the one mentioned in the manual. I've changed the code slightly, so that the poke register is calculated and stored in probe() instead of doing it in each _reset() call.

Thanks,
Stefan

#65 lore raw

PATCH 23/24 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 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                       |   9 +
 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, 1123 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 +9 -0
index e16fe03887..886c387ac5 100644
@@ -1715,6 +1715,13 @@ 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 BOARD_LATE_INIT
+	select SYS_CACHE_SHIFT_7
 config TARGET_THUNDERX_88XX
 	bool "Support ThunderX 88xx"
 	select ARM64
@@ -1803,6 +1810,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"
@@ -1884,6 +1892,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 94eb50bf72..2976a3920b 100644
@@ -78,6 +78,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.27.0
#66 lore raw

PATCH 24/24 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 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                        |  13 ++
 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, 1104 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 +13 -0
index 886c387ac5..869d1c462b 100644
@@ -1722,6 +1722,15 @@ config ARCH_OCTEONTX
 	select OF_CONTROL
 	select BOARD_LATE_INIT
 	select SYS_CACHE_SHIFT_7
+
+config ARCH_OCTEONTX2
+	bool "Support OcteonTX2 SoCs"
+	select DM
+	select ARM64
+	select OF_CONTROL
+	select BOARD_LATE_INIT
+	select SYS_CACHE_SHIFT_7
+
 config TARGET_THUNDERX_88XX
 	bool "Support ThunderX 88xx"
 	select ARM64
@@ -1811,6 +1820,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"
@@ -1893,6 +1905,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 2976a3920b..5e910e12cb 100644
@@ -79,6 +79,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.27.0