Skip to contentSkip to conversation

LS1012A PFE driver patch series

PATCH Superseded Calvin Johnson 5 participants 21 messages Oct 9, 2017 – Jan 26, 2018

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover LS1012A PFE driver patch series

Hi,

This patch series introduces U-Boot support for NXP's LS1012A Packet Forwarding Engine (pfe_eth). LS1012A uses hardware packet forwarding engine to provide high performance Ethernet interfaces. The device includes two Ethernet ports.

Depends on https://patchwork.ozlabs.org/patch/704305

Regards
Calvin

Calvin Johnson (9):
drivers: net: pfe_eth: LS1012A PFE driver introduction
drivers: net: pfe_eth: provide pfe commands
drivers: net: pfe_eth: LS1012A PFE headers
board: freescale: ls1012a: enable network support on ls1012a platforms
armv8: fsl-lsch2: initialize pfe gemac
armv8: fsl-lsch2: add pfe macros and update ccsr_scfg structure
armv8: fsl-lsch2: configure pfe's scfg & dcfg registers
fsl: csu: enable ns access for PFE
configs: ls1012a: add pfe configuration for LS1012A

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c            |    8 +
 arch/arm/cpu/armv8/fsl-layerscape/soc.c            |   18 +
 .../include/asm/arch-fsl-layerscape/immap_lsch2.h  |   38 +-
 .../include/asm/arch-fsl-layerscape/ns_access.h    |    2 +
 arch/arm/include/asm/arch-fsl-layerscape/soc.h     |    3 +
 board/freescale/ls1012afrdm/Makefile               |    1 +
 board/freescale/ls1012afrdm/eth.c                  |   86 ++
 board/freescale/ls1012afrdm/ls1012afrdm.c          |    5 -
 board/freescale/ls1012aqds/Makefile                |    1 +
 board/freescale/ls1012aqds/eth.c                   |  263 +++++
 board/freescale/ls1012aqds/ls1012aqds.c            |   97 +-
 board/freescale/ls1012aqds/ls1012aqds_pfe.h        |   48 +
 board/freescale/ls1012aqds/ls1012aqds_qixis.h      |    2 +-
 board/freescale/ls1012ardb/Makefile                |    1 +
 board/freescale/ls1012ardb/eth.c                   |   70 ++
 board/freescale/ls1012ardb/ls1012ardb.c            |    4 -
 configs/ls1012afrdm_qspi_defconfig                 |    1 +
 configs/ls1012aqds_qspi_defconfig                  |    1 +
 configs/ls1012ardb_qspi_defconfig                  |    1 +
 drivers/net/Kconfig                                |    1 +
 drivers/net/Makefile                               |    1 +
 drivers/net/pfe_eth/Kconfig                        |   29 +
 drivers/net/pfe_eth/Makefile                       |   11 +
 drivers/net/pfe_eth/pfe.c                          | 1161 ++++++++++++++++++++
 drivers/net/pfe_eth/pfe_cmd.c                      |  537 +++++++++
 drivers/net/pfe_eth/pfe_driver.c                   |  626 +++++++++++
 drivers/net/pfe_eth/pfe_eth.c                      |  545 +++++++++
 drivers/net/pfe_eth/pfe_firmware.c                 |  230 ++++
 include/configs/ls1012a_common.h                   |    6 +-
 include/configs/ls1012afrdm.h                      |    7 +
 include/configs/ls1012aqds.h                       |   14 +
 include/configs/ls1012ardb.h                       |   13 +
 include/pfe_eth/pfe/cbus.h                         |   75 ++
 include/pfe_eth/pfe/cbus/bmu.h                     |   40 +
 include/pfe_eth/pfe/cbus/class_csr.h               |  181 +++
 include/pfe_eth/pfe/cbus/emac.h                    |  150 +++
 include/pfe_eth/pfe/cbus/gpi.h                     |   62 ++
 include/pfe_eth/pfe/cbus/hif.h                     |   68 ++
 include/pfe_eth/pfe/cbus/hif_nocpy.h               |   40 +
 include/pfe_eth/pfe/cbus/tmu_csr.h                 |  148 +++
 include/pfe_eth/pfe/cbus/util_csr.h                |   47 +
 include/pfe_eth/pfe/pfe.h                          |  178 +++
 include/pfe_eth/pfe_driver.h                       |   55 +
 include/pfe_eth/pfe_eth.h                          |  111 ++
 include/pfe_eth/pfe_firmware.h                     |   17 +
 45 files changed, 4983 insertions(+), 20 deletions(-)
 create mode 100644 board/freescale/ls1012afrdm/eth.c
 create mode 100644 board/freescale/ls1012aqds/eth.c
 create mode 100644 board/freescale/ls1012aqds/ls1012aqds_pfe.h
 create mode 100644 board/freescale/ls1012ardb/eth.c
 create mode 100644 drivers/net/pfe_eth/Kconfig
 create mode 100644 drivers/net/pfe_eth/Makefile
 create mode 100644 drivers/net/pfe_eth/pfe.c
 create mode 100644 drivers/net/pfe_eth/pfe_cmd.c
 create mode 100644 drivers/net/pfe_eth/pfe_driver.c
 create mode 100644 drivers/net/pfe_eth/pfe_eth.c
 create mode 100644 drivers/net/pfe_eth/pfe_firmware.c
 create mode 100644 include/pfe_eth/pfe/cbus.h
 create mode 100644 include/pfe_eth/pfe/cbus/bmu.h
 create mode 100644 include/pfe_eth/pfe/cbus/class_csr.h
 create mode 100644 include/pfe_eth/pfe/cbus/emac.h
 create mode 100644 include/pfe_eth/pfe/cbus/gpi.h
 create mode 100644 include/pfe_eth/pfe/cbus/hif.h
 create mode 100644 include/pfe_eth/pfe/cbus/hif_nocpy.h
 create mode 100644 include/pfe_eth/pfe/cbus/tmu_csr.h
 create mode 100644 include/pfe_eth/pfe/cbus/util_csr.h
 create mode 100644 include/pfe_eth/pfe/pfe.h
 create mode 100644 include/pfe_eth/pfe_driver.h
 create mode 100644 include/pfe_eth/pfe_eth.h
 create mode 100644 include/pfe_eth/pfe_firmware.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/9 drivers: net: pfe_eth: LS1012A PFE driver introduction

This patch adds PFE driver into U-Boot.

Following are the main driver files:-
pfe.c: provides low level helper functions to initialize PFE internal processor engines and other hardware blocks.
pfe_driver.c: provides probe functions, initialization functions and packet send and receive functions.
pfe_eth.c: provides high level gemac, phy and mdio initialization functions.
pfe_firmware.c: provides functions to load firmware into PFE internal processor engines.

---
 drivers/net/pfe_eth/Kconfig        |    8 +
 drivers/net/pfe_eth/Makefile       |   10 +
 drivers/net/pfe_eth/pfe.c          | 1161 ++++++++++++++++++++++++++++++++++++
 drivers/net/pfe_eth/pfe_driver.c   |  626 +++++++++++++++++++
 drivers/net/pfe_eth/pfe_eth.c      |  545 +++++++++++++++++
 drivers/net/pfe_eth/pfe_firmware.c |  230 +++++++
 6 files changed, 2580 insertions(+)
 create mode 100644 drivers/net/pfe_eth/Kconfig
 create mode 100644 drivers/net/pfe_eth/Makefile
 create mode 100644 drivers/net/pfe_eth/pfe.c
 create mode 100644 drivers/net/pfe_eth/pfe_driver.c
 create mode 100644 drivers/net/pfe_eth/pfe_eth.c
 create mode 100644 drivers/net/pfe_eth/pfe_firmware.c
drivers/net/pfe_eth/Kconfig new file +8 -0
new file mode 100644
index 0000000..b9996df
@@ -0,0 +1,8 @@
+config UTIL_PE_DISABLED
+	bool
+	help
+	  Disable UTIL processor engine of PFE
+
+config SYS_FSL_PPFE_ADDR
+	hex "PFE base address"
+	default 0x04000000
drivers/net/pfe_eth/Makefile new file +10 -0
new file mode 100644
index 0000000..e78f1bf
@@ -0,0 +1,10 @@
+# Copyright 2015-2016 Freescale Semiconductor, Inc.
+# Copyright 2017 NXP
+#
+# SPDX-License-Identifier:GPL-2.0+
+
+# Layerscape PFE driver
+obj-y += pfe.o		\
+	 pfe_driver.o	\
+	 pfe_eth.o	\
+	 pfe_firmware.o
drivers/net/pfe_eth/pfe.c new file +1161 -0

1,161 lines not on this page · raw message

drivers/net/pfe_eth/pfe_driver.c new file +626 -0

626 lines not on this page · raw message

drivers/net/pfe_eth/pfe_eth.c new file +545 -0

545 lines not on this page · raw message

drivers/net/pfe_eth/pfe_firmware.c new file +230 -0

230 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/9 drivers: net: pfe_eth: LS1012A PFE driver introduction

Quoted 14 lines · Calvin Johnson

This patch adds PFE driver into U-Boot.

Following are the main driver files:-
pfe.c: provides low level helper functions to initialize PFE internal processor engines and other hardware blocks.
pfe_driver.c: provides probe functions, initialization functions and packet send and receive functions.
pfe_eth.c: provides high level gemac, phy and mdio initialization functions.
pfe_firmware.c: provides functions to load firmware into PFE internal processor engines.

Quoted 15 lines
---
 drivers/net/pfe_eth/Kconfig        |    8 +
 drivers/net/pfe_eth/Makefile       |   10 +
 drivers/net/pfe_eth/pfe.c          | 1161 ++++++++++++++++++++++++++++++++++++
 drivers/net/pfe_eth/pfe_driver.c   |  626 +++++++++++++++++++
 drivers/net/pfe_eth/pfe_eth.c      |  545 +++++++++++++++++
 drivers/net/pfe_eth/pfe_firmware.c |  230 +++++++
 6 files changed, 2580 insertions(+)
 create mode 100644 drivers/net/pfe_eth/Kconfig
 create mode 100644 drivers/net/pfe_eth/Makefile
 create mode 100644 drivers/net/pfe_eth/pfe.c
 create mode 100644 drivers/net/pfe_eth/pfe_driver.c
 create mode 100644 drivers/net/pfe_eth/pfe_eth.c
 create mode 100644 drivers/net/pfe_eth/pfe_firmware.c

Joe,

Did you get a chance to review this set?

York

#3 lore raw

PATCH 1/9 drivers: net: pfe_eth: LS1012A PFE driver introduction

In reply to Calvin Johnson
Quoted 80 lines · Calvin Johnson

This patch adds PFE driver into U-Boot.

Following are the main driver files:-
pfe.c: provides low level helper functions to initialize PFE internal processor engines and other hardware blocks.
pfe_driver.c: provides probe functions, initialization functions and packet send and receive functions.
pfe_eth.c: provides high level gemac, phy and mdio initialization functions.
pfe_firmware.c: provides functions to load firmware into PFE internal processor engines.

---
 drivers/net/pfe_eth/Kconfig        |    8 +
 drivers/net/pfe_eth/Makefile       |   10 +
 drivers/net/pfe_eth/pfe.c          | 1161 ++++++++++++++++++++++++++++++++++++
 drivers/net/pfe_eth/pfe_driver.c   |  626 +++++++++++++++++++
 drivers/net/pfe_eth/pfe_eth.c      |  545 +++++++++++++++++
 drivers/net/pfe_eth/pfe_firmware.c |  230 +++++++
 6 files changed, 2580 insertions(+)
 create mode 100644 drivers/net/pfe_eth/Kconfig
 create mode 100644 drivers/net/pfe_eth/Makefile
 create mode 100644 drivers/net/pfe_eth/pfe.c
 create mode 100644 drivers/net/pfe_eth/pfe_driver.c
 create mode 100644 drivers/net/pfe_eth/pfe_eth.c
 create mode 100644 drivers/net/pfe_eth/pfe_firmware.c
drivers/net/pfe_eth/Kconfig new file +8 -0
new file mode 100644
index 0000000..b9996df
@@ -0,0 +1,8 @@
+config UTIL_PE_DISABLED
+       bool
+       help
+         Disable UTIL processor engine of PFE
+
+config SYS_FSL_PPFE_ADDR
+       hex "PFE base address"
+       default 0x04000000
drivers/net/pfe_eth/Makefile new file +10 -0
new file mode 100644
index 0000000..e78f1bf
@@ -0,0 +1,10 @@
+# Copyright 2015-2016 Freescale Semiconductor, Inc.
+# Copyright 2017 NXP
+#
+# SPDX-License-Identifier:GPL-2.0+
+
+# Layerscape PFE driver
+obj-y += pfe.o         \
+        pfe_driver.o   \
+        pfe_eth.o      \
+        pfe_firmware.o
drivers/net/pfe_eth/pfe.c new file +15 -0
new file mode 100644
index 0000000..fc6631e
@@ -0,0 +1,1161 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#include <pfe_eth/pfe_eth.h>
+#include <pfe_eth/pfe/pfe.h>
+
+void *ddr_base_addr;
+unsigned long ddr_phys_base_addr;
+static struct pe_info pe[MAX_PE];
+
+/*
+ * Initializes the PFE library.

drivers/net/pfe_eth/pfe.c line 25

Quoted 10 lines
drivers/net/pfe_eth/pfe.c new file +10 -0
+ * Must be called before using any of the library functions.
+ *
+ * @param[in] cbus_base                CBUS virtual base address (as mapped in
+ *                             the host CPU address space)
+ * @param[in] ddr_base         DDR virtual base address (as mapped in
+ *                             the host CPU address space)
+ * @param[in] ddr_phys_base    DDR physical base address (as mapped in
+ *                             platform)
+ */
+void pfe_lib_init(void *ddr_base, unsigned long ddr_phys_base)

Could you use some loops here to consolidate this code some?

Quoted 74 lines
drivers/net/pfe_eth/pfe.c new file +74 -0
+{
+       ddr_base_addr = ddr_base;
+       ddr_phys_base_addr = ddr_phys_base;
+
+       pe[CLASS0_ID].dmem_base_addr = (u32)CLASS_DMEM_BASE_ADDR(0);
+       pe[CLASS0_ID].pmem_base_addr = (u32)CLASS_IMEM_BASE_ADDR(0);
+       pe[CLASS0_ID].pmem_size = (u32)CLASS_IMEM_SIZE;
+       pe[CLASS0_ID].mem_access_wdata = (void *)CLASS_MEM_ACCESS_WDATA;
+       pe[CLASS0_ID].mem_access_addr = (void *)CLASS_MEM_ACCESS_ADDR;
+       pe[CLASS0_ID].mem_access_rdata = (void *)CLASS_MEM_ACCESS_RDATA;
+
+       pe[CLASS1_ID].dmem_base_addr = (u32)CLASS_DMEM_BASE_ADDR(1);
+       pe[CLASS1_ID].pmem_base_addr = (u32)CLASS_IMEM_BASE_ADDR(1);
+       pe[CLASS1_ID].pmem_size = (u32)CLASS_IMEM_SIZE;
+       pe[CLASS1_ID].mem_access_wdata = (void *)CLASS_MEM_ACCESS_WDATA;
+       pe[CLASS1_ID].mem_access_addr = (void *)CLASS_MEM_ACCESS_ADDR;
+       pe[CLASS1_ID].mem_access_rdata = (void *)CLASS_MEM_ACCESS_RDATA;
+
+       pe[CLASS2_ID].dmem_base_addr = (u32)CLASS_DMEM_BASE_ADDR(2);
+       pe[CLASS2_ID].pmem_base_addr = (u32)CLASS_IMEM_BASE_ADDR(2);
+       pe[CLASS2_ID].pmem_size = (u32)CLASS_IMEM_SIZE;
+       pe[CLASS2_ID].mem_access_wdata = (void *)CLASS_MEM_ACCESS_WDATA;
+       pe[CLASS2_ID].mem_access_addr = (void *)CLASS_MEM_ACCESS_ADDR;
+       pe[CLASS2_ID].mem_access_rdata = (void *)CLASS_MEM_ACCESS_RDATA;
+
+       pe[CLASS3_ID].dmem_base_addr = (u32)CLASS_DMEM_BASE_ADDR(3);
+       pe[CLASS3_ID].pmem_base_addr = (u32)CLASS_IMEM_BASE_ADDR(3);
+       pe[CLASS3_ID].pmem_size = (u32)CLASS_IMEM_SIZE;
+       pe[CLASS3_ID].mem_access_wdata = (void *)CLASS_MEM_ACCESS_WDATA;
+       pe[CLASS3_ID].mem_access_addr = (void *)CLASS_MEM_ACCESS_ADDR;
+       pe[CLASS3_ID].mem_access_rdata = (void *)CLASS_MEM_ACCESS_RDATA;
+
+       pe[CLASS4_ID].dmem_base_addr = (u32)CLASS_DMEM_BASE_ADDR(4);
+       pe[CLASS4_ID].pmem_base_addr = (u32)CLASS_IMEM_BASE_ADDR(4);
+       pe[CLASS4_ID].pmem_size = (u32)CLASS_IMEM_SIZE;
+       pe[CLASS4_ID].mem_access_wdata = (void *)CLASS_MEM_ACCESS_WDATA;
+       pe[CLASS4_ID].mem_access_addr = (void *)CLASS_MEM_ACCESS_ADDR;
+       pe[CLASS4_ID].mem_access_rdata = (void *)CLASS_MEM_ACCESS_RDATA;
+
+       pe[CLASS5_ID].dmem_base_addr = (u32)CLASS_DMEM_BASE_ADDR(5);
+       pe[CLASS5_ID].pmem_base_addr = (u32)CLASS_IMEM_BASE_ADDR(5);
+       pe[CLASS5_ID].pmem_size = (u32)CLASS_IMEM_SIZE;
+       pe[CLASS5_ID].mem_access_wdata = (void *)CLASS_MEM_ACCESS_WDATA;
+       pe[CLASS5_ID].mem_access_addr = (void *)CLASS_MEM_ACCESS_ADDR;
+       pe[CLASS5_ID].mem_access_rdata = (void *)CLASS_MEM_ACCESS_RDATA;
+
+       pe[TMU0_ID].dmem_base_addr = (u32)TMU_DMEM_BASE_ADDR(0);
+       pe[TMU0_ID].pmem_base_addr = (u32)TMU_IMEM_BASE_ADDR(0);
+       pe[TMU0_ID].pmem_size = (u32)TMU_IMEM_SIZE;
+       pe[TMU0_ID].mem_access_wdata = (void *)TMU_MEM_ACCESS_WDATA;
+       pe[TMU0_ID].mem_access_addr = (void *)TMU_MEM_ACCESS_ADDR;
+       pe[TMU0_ID].mem_access_rdata = (void *)TMU_MEM_ACCESS_RDATA;
+
+       pe[TMU1_ID].dmem_base_addr = (u32)TMU_DMEM_BASE_ADDR(1);
+       pe[TMU1_ID].pmem_base_addr = (u32)TMU_IMEM_BASE_ADDR(1);
+       pe[TMU1_ID].pmem_size = (u32)TMU_IMEM_SIZE;
+       pe[TMU1_ID].mem_access_wdata = (void *)TMU_MEM_ACCESS_WDATA;
+       pe[TMU1_ID].mem_access_addr = (void *)TMU_MEM_ACCESS_ADDR;
+       pe[TMU1_ID].mem_access_rdata = (void *)TMU_MEM_ACCESS_RDATA;
+
+       pe[TMU3_ID].dmem_base_addr = (u32)TMU_DMEM_BASE_ADDR(3);
+       pe[TMU3_ID].pmem_base_addr = (u32)TMU_IMEM_BASE_ADDR(3);
+       pe[TMU3_ID].pmem_size = (u32)TMU_IMEM_SIZE;
+       pe[TMU3_ID].mem_access_wdata = (void *)TMU_MEM_ACCESS_WDATA;
+       pe[TMU3_ID].mem_access_addr = (void *)TMU_MEM_ACCESS_ADDR;
+       pe[TMU3_ID].mem_access_rdata = (void *)TMU_MEM_ACCESS_RDATA;
+
+#if !defined(CONFIG_UTIL_PE_DISABLED)
+       pe[UTIL_ID].dmem_base_addr = (u32)UTIL_DMEM_BASE_ADDR;
+       pe[UTIL_ID].mem_access_wdata = (void *)UTIL_MEM_ACCESS_WDATA;
+       pe[UTIL_ID].mem_access_addr = (void *)UTIL_MEM_ACCESS_ADDR;
+       pe[UTIL_ID].mem_access_rdata = (void *)UTIL_MEM_ACCESS_RDATA;
+#endif
+}

[ ... ]

Quoted 42 lines
drivers/net/pfe_eth/pfe_driver.c new file +36 -0
new file mode 100644
index 0000000..5336ba7
@@ -0,0 +1,626 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <pfe_eth/pfe_eth.h>
+#include <pfe_eth/pfe_firmware.h>
+
+static struct tx_desc_s *g_tx_desc;
+static struct rx_desc_s *g_rx_desc;
+
+/*
+ * HIF Rx interface function
+ * Reads the rx descriptor from the current location (rx_to_read).
+ * - If the descriptor has a valid data/pkt, then get the data pointer
+ * - check for the input rx phy number
+ * - increments the rx data pointer by pkt_head_room_size
+ * - decrements the data length by pkt_head_room_size
+ * - handover the packet to caller.
+ *
+ * @param[out] pkt_ptr Pointer to store rx packet pointer
+ * @param[out] phy_port Pointer to store recv phy port
+ *
+ * @return     -1 if no packet, else returns length of packet.
+ */
+int pfe_recv(unsigned int *pkt_ptr, int *phy_port)
+{
+       struct rx_desc_s *rx_desc = g_rx_desc;
+       struct buf_desc *bd;
+       int len = -1;
+
+       struct hif_header_s *hif_header;
+
+       bd = rx_desc->rx_base + rx_desc->rx_to_read;

drivers/net/pfe_eth/pfe_driver.c line 46

Quoted 10 lines
drivers/net/pfe_eth/pfe_driver.c new file +10 -0
+
+       if (bd->ctrl & BD_CTRL_DESC_EN)
+               return len; /* No pending Rx packet */
+
+       /* this len include hif_header(8bytes) */
+       len = bd->ctrl & 0xFFFF;
+
+       hif_header = (struct hif_header_s *)DDR_PFE_TO_VIRT(bd->data);
+
+       /* Get the recive port info from the packet */

Typo: receive

Quoted 39 lines
drivers/net/pfe_eth/pfe_driver.c new file +39 -0
+       debug(
+               "Pkt recv'd: Pkt ptr(%p), len(%d), gemac_port(%d) status(%08x)\n",
+               hif_header, len, hif_header->port_no, bd->status);
+
+#ifdef DEBUG
+       {
+               int i;
+               unsigned char *p = (unsigned char *)hif_header;
+
+               for (i = 0; i < len; i++) {
+                       if (!(i % 16))
+                               printf("\n");
+                       printf(" %02x", p[i]);
+               }
+               printf("\n");
+       }
+#endif
+
+       *pkt_ptr = (unsigned long)(hif_header + 1);
+       *phy_port = hif_header->port_no;
+       len -= sizeof(struct hif_header_s);
+
+       rx_desc->rx_to_read = (rx_desc->rx_to_read + 1)
+                              & (rx_desc->rx_ring_size - 1);
+
+       /* reset bd control field */
+       bd->ctrl = (MAX_FRAME_SIZE | BD_CTRL_LIFM | BD_CTRL_DESC_EN
+                   | BD_CTRL_DIR);
+       bd->status = 0;
+
+       /* Give START_STROBE to BDP to fetch the descriptor __NOW__,
+        * BDP need not to wait for rx_poll_cycle time to fetch the descriptor,
+        * In idle state (ie., no rx pkt), BDP will not fetch
+        * the descriptor even if strobe is given(I think)
+        */
+       writel((readl(HIF_RX_CTRL) | HIF_CTRL_BDP_CH_START_WSTB), HIF_RX_CTRL);
+
+       return len;
+}

[ ... ]

Quoted 118 lines
drivers/net/pfe_eth/pfe_eth.c new file +112 -0
new file mode 100644
index 0000000..8d8de40
@@ -0,0 +1,545 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <pfe_eth/pfe_eth.h>
+
+struct gemac_s gem_info[] = {
+       /* PORT_0 configuration */ {
+               /* GEMAC config */
+               .gemac_mode = GMII,
+               .gemac_speed = SPEED_1000M,
+               .gemac_duplex = DUPLEX_FULL,
+
+               /* phy iface */
+               .phy_address = EMAC1_PHY_ADDR,
+               .phy_mode = PHY_INTERFACE_MODE_SGMII,
+       },
+       /* PORT_1 configuration */ {
+               /* GEMAC config */
+               .gemac_mode = GMII,
+               .gemac_speed = SPEED_1000M,
+               .gemac_duplex = DUPLEX_FULL,
+
+               /* phy iface */
+               .phy_address = EMAC2_PHY_ADDR,
+               .phy_mode = PHY_INTERFACE_MODE_RGMII,
+       },
+};
+
+#define MAX_GEMACS      2
+
+static struct ls1012a_eth_dev *gemac_list[MAX_GEMACS];
+
+#define MDIO_TIMEOUT    5000
+
+static inline void ls1012a_gemac_enable(void *gemac_base)
+{
+       writel(readl(gemac_base + EMAC_ECNTRL_REG) |
+               EMAC_ECNTRL_ETHER_EN, gemac_base + EMAC_ECNTRL_REG);
+}
+
+static inline void ls1012a_gemac_disable(void *gemac_base)
+{
+       writel(readl(gemac_base + EMAC_ECNTRL_REG) &
+               ~EMAC_ECNTRL_ETHER_EN, gemac_base + EMAC_ECNTRL_REG);
+}
+
+static inline void ls1012a_gemac_set_speed(void *gemac_base, u32 speed)
+{
+       struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
+       u32 ecr = readl(gemac_base + EMAC_ECNTRL_REG) & ~EMAC_ECNTRL_SPEED;
+       u32 rcr = readl(gemac_base + EMAC_RCNTRL_REG) & ~EMAC_RCNTRL_RMII_10T;
+       u32 rgmii_pcr = in_be32(&scfg->rgmiipcr) &
+                       ~(SCFG_RGMIIPCR_SETSP_1000M|SCFG_RGMIIPCR_SETSP_10M);
+
+       if (speed == _1000BASET) {
+               ecr |= EMAC_ECNTRL_SPEED;
+               rgmii_pcr |= SCFG_RGMIIPCR_SETSP_1000M;
+       } else if (speed != _100BASET) {
+               rcr |= EMAC_RCNTRL_RMII_10T;
+               rgmii_pcr |= SCFG_RGMIIPCR_SETSP_10M;
+       }
+
+       writel(ecr, gemac_base + EMAC_ECNTRL_REG);
+       out_be32(&scfg->rgmiipcr, rgmii_pcr | SCFG_RGMIIPCR_SETFD);
+
+       /* remove loop back */
+       rcr &= ~EMAC_RCNTRL_LOOP;
+       /* enable flow control */
+       rcr |= EMAC_RCNTRL_FCE;
+
+       /* Enable MII mode */
+       rcr |= EMAC_RCNTRL_MII_MODE;
+
+       writel(rcr, gemac_base + EMAC_RCNTRL_REG);
+
+       /* Enable Tx full duplex */
+       writel(readl(gemac_base + EMAC_TCNTRL_REG) | EMAC_TCNTRL_FDEN,
+              gemac_base + EMAC_TCNTRL_REG);
+}
+
+static inline void ls1012a_gemac_set_ethaddr(void *gemac_base, uchar *mac)
+{
+       writel((mac[0] << 24) + (mac[1] << 16) + (mac[2] << 8) + mac[3],
+              gemac_base + EMAC_PHY_ADDR_LOW);
+       writel((mac[4] << 24) + (mac[5] << 16) + 0x8808, gemac_base +
+              EMAC_PHY_ADDR_HIGH);
+}
+
+/** Stops or Disables GEMAC pointing to this eth iface.
+ *
+ * @param[in]   edev    Pointer to eth device structure.
+ *
+ * @return      none
+ */
+static inline void ls1012a_eth_halt(struct eth_device *edev)
+{
+       struct ls1012a_eth_dev *priv = (struct ls1012a_eth_dev *)edev->priv;
+
+       ls1012a_gemac_disable(priv->gem->gemac_base);
+
+       gpi_disable(priv->gem->egpi_base);
+}
+
+static int ls1012a_eth_init(struct eth_device *dev, bd_t *bd)
+{
+       struct ls1012a_eth_dev *priv = (struct ls1012a_eth_dev *)dev->priv;
+       struct gemac_s *gem = priv->gem;

drivers/net/pfe_eth/pfe_eth.c line 122

Quoted 10 lines
drivers/net/pfe_eth/pfe_eth.c new file +10 -0
+       int speed;
+
+       /* set ethernet mac address */
+       ls1012a_gemac_set_ethaddr(gem->gemac_base, dev->enetaddr);
+
+       writel(0x00000004, gem->gemac_base + EMAC_TFWR_STR_FWD);
+       writel(0x00000005, gem->gemac_base + EMAC_RX_SECTIOM_FULL);
+       writel(0x00003fff, gem->gemac_base + EMAC_TRUNC_FL);
+       writel(0x00000030, gem->gemac_base + EMAC_TX_SECTION_EMPTY);
+       writel(0x00000000, gem->gemac_base + EMAC_MIB_CTRL_STS_REG);

Why all the magic numbers?

Quoted 67 lines
drivers/net/pfe_eth/pfe_eth.c new file +67 -0
+
+#ifdef CONFIG_PHYLIB
+       /* Start up the PHY */
+       if (phy_startup(priv->phydev)) {
+               printf("Could not initialize PHY %s\n",
+                      priv->phydev->dev->name);
+               return -1;
+       }
+       speed = priv->phydev->speed;
+       printf("Speed detected %x\n", speed);
+       if (priv->phydev->duplex == DUPLEX_HALF) {
+               printf("Half duplex not supported\n");
+               return -1;
+       }
+#endif
+
+       ls1012a_gemac_set_speed(gem->gemac_base, speed);
+
+       /* Enable GPI */
+       gpi_enable(gem->egpi_base);
+
+       /* Enable GEMAC */
+       ls1012a_gemac_enable(gem->gemac_base);
+
+       return 0;
+}
+
+static int ls1012a_eth_send(struct eth_device *dev, void *data, int length)
+{
+       struct ls1012a_eth_dev *priv = (struct ls1012a_eth_dev *)dev->priv;
+
+       int rc;
+       int i = 0;
+
+       rc = pfe_send(priv->gemac_port, data, length);
+
+       if (rc < 0) {
+               printf("Tx Q full\n");
+               return 0;
+       }
+
+       while (1) {
+               rc = pfe_tx_done();
+               if (rc == 0)
+                       break;
+
+                       udelay(100);
+                       i++;
+                       if (i == 30000)
+                               printf("Tx timeout, send failed\n");
+                       break;
+       }
+
+       return 0;
+}
+
+static int ls1012a_eth_recv(struct eth_device *dev)
+{
+       struct ls1012a_eth_dev *priv = (struct ls1012a_eth_dev *)dev->priv;
+       u32 pkt_buf;
+       int len;
+       int phy_port;
+
+       len = pfe_recv(&pkt_buf, &phy_port);
+
+       if (len < 0)
+               return 0; /* no packet in rx */

drivers/net/pfe_eth/pfe_eth.c line 199

Quoted 10 lines
drivers/net/pfe_eth/pfe_eth.c new file +10 -0
+
+       debug("Rx pkt: pkt_buf(%08x), phy_port(%d), len(%d)\n", pkt_buf,
+             phy_port, len);
+       if (phy_port != priv->gemac_port)  {
+               printf("Rx pkt not on expected port\n");
+               return 0;
+       }
+
+       /* Pass the packet up to the protocol layers. */
+       net_process_received_packet((void *)(long int)pkt_buf, len);

Please don't call this directly. The layer above will call it for you if you return the size of the packet that is valid (assuming driver model, see below).

Quoted 280 lines
drivers/net/pfe_eth/pfe_eth.c new file +280 -0
+       return 0;
+}
+
+#if defined(CONFIG_PHYLIB)
+
+#define MDIO_TIMEOUT    5000
+static int ls1012a_write_addr(struct mii_dev *bus, int phy_addr, int dev_addr,
+                             int reg_addr)
+{
+       void *reg_base = bus->priv;
+       u32 devadr;
+       u32 phy;
+       u32 reg_data;
+       int timeout = MDIO_TIMEOUT;
+
+       devadr = ((dev_addr & EMAC_MII_DATA_RA_MASK) << EMAC_MII_DATA_RA_SHIFT);
+       phy = ((phy_addr & EMAC_MII_DATA_PA_MASK) << EMAC_MII_DATA_PA_SHIFT);
+
+       reg_data = (EMAC_MII_DATA_TA | phy | devadr | reg_addr);
+
+
+       writel(reg_data, reg_base + EMAC_MII_DATA_REG);
+
+       /*
+        * wait for the MII interrupt
+        */
+       while (!(readl(reg_base + EMAC_IEVENT_REG) & EMAC_IEVENT_MII)) {
+               if (timeout-- <= 0) {
+                       printf("Phy MDIO read/write timeout\n");
+                       return -1;
+               }
+       }
+
+       /*
+        * clear MII interrupt
+        */
+       writel(EMAC_IEVENT_MII, reg_base + EMAC_IEVENT_REG);
+
+
+       return 0;
+}
+
+static int ls1012a_phy_read(struct mii_dev *bus, int phy_addr, int dev_addr, int
+                               reg_addr)
+{
+       void *reg_base = bus->priv;
+       u32 reg;
+       u32 phy;
+       u32 reg_data;
+       u16 val;
+       int timeout = MDIO_TIMEOUT;
+
+       if (dev_addr == MDIO_DEVAD_NONE) {
+                       reg = ((reg_addr & EMAC_MII_DATA_RA_MASK) <<
+                      EMAC_MII_DATA_RA_SHIFT);
+       } else {
+               ls1012a_write_addr(bus, phy_addr, dev_addr, reg_addr);
+               reg = ((dev_addr & EMAC_MII_DATA_RA_MASK) <<
+                      EMAC_MII_DATA_RA_SHIFT);
+       }
+
+       phy = ((phy_addr & EMAC_MII_DATA_PA_MASK) << EMAC_MII_DATA_PA_SHIFT);
+
+       if (dev_addr == MDIO_DEVAD_NONE)
+               reg_data = (EMAC_MII_DATA_ST | EMAC_MII_DATA_OP_RD |
+                           EMAC_MII_DATA_TA | phy | reg);
+       else
+               reg_data = (EMAC_MII_DATA_OP_CL45_RD | EMAC_MII_DATA_TA |
+                           phy | reg);
+
+       writel(reg_data, reg_base + EMAC_MII_DATA_REG);
+
+       /*
+        * wait for the MII interrupt
+        */
+       while (!(readl(reg_base + EMAC_IEVENT_REG) & EMAC_IEVENT_MII)) {
+               if (timeout-- <= 0) {
+                       printf("Phy MDIO read/write timeout\n");
+                       return -1;
+               }
+       }
+
+       /*
+        * clear MII interrupt
+        */
+       writel(EMAC_IEVENT_MII, reg_base + EMAC_IEVENT_REG);
+
+       /*
+        * it's now safe to read the PHY's register
+        */
+       val = (u16)readl(reg_base + EMAC_MII_DATA_REG);
+       debug("%s: %p phy: 0x%x reg:0x%08x val:%#x\n", __func__, reg_base,
+             phy_addr, reg_addr, val);
+
+       return val;
+}
+
+static int ls1012a_phy_write(struct mii_dev *bus, int phy_addr, int dev_addr,
+                               int reg_addr, u16 data)
+{
+       void *reg_base = bus->priv;
+       u32 reg;
+       u32 phy;
+       u32 reg_data;
+       int timeout = MDIO_TIMEOUT;
+       int val;
+
+       if (dev_addr == MDIO_DEVAD_NONE) {
+               reg = ((reg_addr & EMAC_MII_DATA_RA_MASK) <<
+                      EMAC_MII_DATA_RA_SHIFT);
+       } else {
+               ls1012a_write_addr(bus, phy_addr, dev_addr, reg_addr);
+               reg = ((dev_addr & EMAC_MII_DATA_RA_MASK) <<
+                      EMAC_MII_DATA_RA_SHIFT);
+       }
+
+       phy = ((phy_addr & EMAC_MII_DATA_PA_MASK) << EMAC_MII_DATA_PA_SHIFT);
+
+       if (dev_addr == MDIO_DEVAD_NONE)
+               reg_data = (EMAC_MII_DATA_ST | EMAC_MII_DATA_OP_WR |
+                           EMAC_MII_DATA_TA | phy | reg | data);
+       else
+               reg_data = (EMAC_MII_DATA_OP_CL45_WR | EMAC_MII_DATA_TA |
+                           phy | reg | data);
+
+       writel(reg_data, reg_base + EMAC_MII_DATA_REG);
+
+       /*
+        * wait for the MII interrupt
+        */
+       while (!(readl(reg_base + EMAC_IEVENT_REG) & EMAC_IEVENT_MII)) {
+               if (timeout-- <= 0) {
+                       printf("Phy MDIO read/write timeout\n");
+                       return -1;
+               }
+       }
+
+       /*
+        * clear MII interrupt
+        */
+       writel(EMAC_IEVENT_MII, reg_base + EMAC_IEVENT_REG);
+
+       debug("%s: phy: %02x reg:%02x val:%#x\n", __func__, phy_addr,
+             reg_addr, data);
+
+       return val;
+}
+
+struct mii_dev *ls1012a_mdio_init(struct mdio_info *mdio_info)
+{
+       struct mii_dev *bus;
+       int ret;
+       u32 mdio_speed;
+       u32 pclk = 250000000;
+
+       bus = mdio_alloc();
+       if (!bus) {
+               printf("mdio_alloc failed\n");
+               return NULL;
+       }
+       bus->read = ls1012a_phy_read;
+       bus->write = ls1012a_phy_write;
+       /* MAC1 MDIO used to communicate with external PHYS */
+       bus->priv = mdio_info->reg_base;
+       sprintf(bus->name, mdio_info->name);
+
+       /* configure mdio speed */
+       mdio_speed = (DIV_ROUND_UP(pclk, 4000000) << EMAC_MII_SPEED_SHIFT);
+       mdio_speed |= EMAC_HOLDTIME(0x5);
+       writel(mdio_speed, mdio_info->reg_base + EMAC_MII_CTRL_REG);
+
+       ret = mdio_register(bus);
+       if (ret) {
+               printf("mdio_register failed\n");
+               free(bus);
+               return NULL;
+       }
+       return bus;
+}
+
+static void ls1012a_configure_serdes(struct ls1012a_eth_dev *priv)
+{
+       struct mii_dev bus;
+       int value, sgmii_2500 = 0;
+       struct gemac_s *gem = priv->gem;
+
+       if (gem->phy_mode == PHY_INTERFACE_MODE_SGMII_2500)
+               sgmii_2500 = 1;
+
+       printf("%s %d\n", __func__, priv->gemac_port);
+
+       /* PCS configuration done with corresponding GEMAC */
+       bus.priv = gem_info[priv->gemac_port].gemac_base;
+
+       ls1012a_phy_read(&bus, 0, MDIO_DEVAD_NONE, 0x0);
+       ls1012a_phy_read(&bus, 0, MDIO_DEVAD_NONE, 0x1);
+       ls1012a_phy_read(&bus, 0, MDIO_DEVAD_NONE, 0x2);
+       ls1012a_phy_read(&bus, 0, MDIO_DEVAD_NONE, 0x3);
+
+       /* Reset serdes */
+       ls1012a_phy_write(&bus, 0, MDIO_DEVAD_NONE, 0x0, 0x8000);
+
+       /* SGMII IF mode + AN enable only for 1G SGMII, not for 2.5G */
+       value = PHY_SGMII_IF_MODE_SGMII;
+       if (!sgmii_2500)
+               value |= PHY_SGMII_IF_MODE_AN;
+       else
+               value |= PHY_SGMII_IF_MODE_SGMII_GBT;
+
+       ls1012a_phy_write(&bus, 0, MDIO_DEVAD_NONE, 0x14, value);
+
+       /* Dev ability according to SGMII specification */
+       value = PHY_SGMII_DEV_ABILITY_SGMII;
+       ls1012a_phy_write(&bus, 0, MDIO_DEVAD_NONE, 0x4, value);
+
+       /* These values taken from validation team */
+       if (!sgmii_2500) {
+               ls1012a_phy_write(&bus, 0, MDIO_DEVAD_NONE, 0x13, 0x0);
+               ls1012a_phy_write(&bus, 0, MDIO_DEVAD_NONE, 0x12, 0x400);
+       } else {
+               ls1012a_phy_write(&bus, 0, MDIO_DEVAD_NONE, 0x13, 0x7);
+               ls1012a_phy_write(&bus, 0, MDIO_DEVAD_NONE, 0x12, 0xa120);
+       }
+
+       /* Restart AN */
+       value = PHY_SGMII_CR_DEF_VAL;
+       if (!sgmii_2500)
+               value |= PHY_SGMII_CR_RESET_AN;
+       ls1012a_phy_write(&bus, 0, MDIO_DEVAD_NONE, 0, value);
+}
+
+void ls1012a_set_mdio(int dev_id, struct mii_dev *bus)
+{
+       gem_info[dev_id].bus = bus;
+}
+
+void ls1012a_set_phy_address_mode(int dev_id, int phy_id, int phy_mode)
+{
+       gem_info[dev_id].phy_address = phy_id;
+       gem_info[dev_id].phy_mode  = phy_mode;
+}
+
+int ls1012a_phy_configure(struct ls1012a_eth_dev *priv, int dev_id, int phy_id)
+{
+       struct phy_device *phydev = NULL;
+       struct eth_device *dev = priv->dev;
+       struct gemac_s *gem = priv->gem;
+       struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
+
+       /* Configure SGMII  PCS */
+       if (gem->phy_mode == PHY_INTERFACE_MODE_SGMII ||
+           gem->phy_mode == PHY_INTERFACE_MODE_SGMII_2500) {
+               out_be32(&scfg->mdioselcr, 0x00000000);
+               ls1012a_configure_serdes(priv);
+       }
+
+       /* By this time on-chip SGMII initialization is done
+        * we can switch mdio interface to external PHYs
+        */
+       out_be32(&scfg->mdioselcr, 0x80000000);
+
+       if (!gem->bus)
+               return -1;
+       phydev = phy_connect(gem->bus, phy_id, dev, gem->phy_mode);
+       if (!phydev) {
+               printf("phy_connect failed\n");
+               return -1;
+       }
+
+       phy_config(phydev);
+
+       priv->phydev = phydev;
+
+       return 0;
+}
+#endif
+
+int gemac_initialize(bd_t *bis, int dev_id, char *devname)
+{
+       struct eth_device *dev;

drivers/net/pfe_eth/pfe_eth.c line 490

Quoted 10 lines
drivers/net/pfe_eth/pfe_eth.c new file +10 -0
+       struct ls1012a_eth_dev *priv;
+       struct pfe *pfe;
+       int i;
+
+       if (dev_id > 1) {
+               printf("Invalid port\n");
+               return -1;
+       }
+
+       dev = (struct eth_device *)malloc(sizeof(struct eth_device));

Please don't add a new driver that uses the legacy API. Make this a driver model driver.

Quoted 55 lines
drivers/net/pfe_eth/pfe_eth.c new file +55 -0
+       if (!dev)
+               return -1;
+
+       memset(dev, 0, sizeof(struct eth_device));
+
+       priv = (struct ls1012a_eth_dev *)malloc(sizeof(struct ls1012a_eth_dev));
+       if (!priv)
+               return -1;
+
+       gemac_list[dev_id] = priv;
+       priv->gemac_port = dev_id;
+       priv->gem = &gem_info[priv->gemac_port];
+       priv->dev = dev;
+
+       pfe = &priv->pfe;
+
+       pfe->cbus_baseaddr = (void *)CONFIG_SYS_FSL_PFE_ADDR;
+       pfe->ddr_baseaddr = (void *)CONFIG_DDR_PFE_BASEADDR;
+       pfe->ddr_phys_baseaddr = (unsigned long)CONFIG_DDR_PFE_PHYS_BASEADDR;
+
+       sprintf(dev->name, devname);
+       dev->priv = priv;
+       dev->init = ls1012a_eth_init;
+       dev->halt = ls1012a_eth_halt;
+       dev->send = ls1012a_eth_send;
+       dev->recv = ls1012a_eth_recv;
+
+       /* Tell u-boot to get the addr from the env */
+       for (i = 0; i < 6; i++)
+               dev->enetaddr[i] = 0;
+
+       pfe_probe(pfe);
+
+       switch (priv->gemac_port)  {
+       case EMAC_PORT_0:
+       default:
+               priv->gem->gemac_base = EMAC1_BASE_ADDR;
+               priv->gem->egpi_base = EGPI1_BASE_ADDR;
+               break;
+       case EMAC_PORT_1:
+               priv->gem->gemac_base = EMAC2_BASE_ADDR;
+               priv->gem->egpi_base = EGPI2_BASE_ADDR;
+               break;
+       }
+
+#if defined(CONFIG_PHYLIB)
+       if (ls1012a_phy_configure(priv, dev_id,
+                                 gem_info[priv->gemac_port].phy_address))
+               return -1;
+#endif
+
+       eth_register(dev);
+
+       return 0;
+}

[ ... ]

#4 lore raw

PATCH 1/9 drivers: net: pfe_eth: LS1012A PFE driver introduction

Hi Joe,

Quoted 12 lines

-----Original Message-----
From: Joe Hershberger [mailto:joe.hershberger at ni.com]
Sent: Wednesday, December 06, 2017 1:44 AM
To: Calvin Johnson <[email protected]>
Cc: u-boot <[email protected]>; Joe Hershberger <[email protected]>; Anji Jagarlmudi <[email protected]>
Subject: Re: [U-Boot] [PATCH 1/9] drivers: net: pfe_eth: LS1012A PFE driver introduction

Quoted 1 line · Calvin Johnson

This patch adds PFE driver into U-Boot.

[snip]

Quoted 9 lines

drivers/net/pfe_eth/pfe_eth.c line 490

Quoted 6 lines
drivers/net/pfe_eth/pfe_eth.c new file +6 -0
+       if (dev_id > 1) {
+               printf("Invalid port\n");
+               return -1;
+       }
+
+       dev = (struct eth_device *)malloc(sizeof(struct eth_device));

Please don't add a new driver that uses the legacy API. Make this a driver model driver.

PFE IP has two MACs.
In the legacy driver model, we were registering two ethernet devices/interfaces, pfe_eth0 and pfe_eth1.

With the new driver model, I'm wondering whether we can do the same.
IIUC, U_BOOT_DEVICE corresponds to PFE IP on the LS1012A platform and struct eth_pdata corresponds to each MAC. Is this correct?

If yes, how can we register two interfaces, pfe_eth0 and pfe_eth1? Please advice.

Thanks
Calvin

#5 lore raw

PATCH 2/9 drivers: net: pfe_eth: provide pfe commands

In reply to Calvin Johnson

pfe_command provides command line support for several features that support pfe like starting or stopping the pfe, checking the health of the processor engines and checking status of different unit inside pfe.

---
 drivers/net/pfe_eth/Makefile  |   1 +
 drivers/net/pfe_eth/pfe_cmd.c | 537 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 538 insertions(+)
 create mode 100644 drivers/net/pfe_eth/pfe_cmd.c
drivers/net/pfe_eth/Makefile +1 -0
index e78f1bf..3e88e53 100644
@@ -5,6 +5,7 @@
 
 # Layerscape PFE driver
 obj-y += pfe.o		\
+	 pfe_cmd.o	\
 	 pfe_driver.o	\
 	 pfe_eth.o	\
 	 pfe_firmware.o
drivers/net/pfe_eth/pfe_cmd.c new file +537 -0

537 lines not on this page · raw message

Signature · 1 line
2.7.4
#7 lore raw

PATCH 3/9 drivers: net: pfe_eth: LS1012A PFE headers

In reply to Calvin Johnson

Contains all the pfe header files.

---
 include/pfe_eth/pfe/cbus.h           |  75 +++++++++++++++
 include/pfe_eth/pfe/cbus/bmu.h       |  40 ++++++++
 include/pfe_eth/pfe/cbus/class_csr.h | 181 +++++++++++++++++++++++++++++++++++
 include/pfe_eth/pfe/cbus/emac.h      | 150 +++++++++++++++++++++++++++++
 include/pfe_eth/pfe/cbus/gpi.h       |  62 ++++++++++++
 include/pfe_eth/pfe/cbus/hif.h       |  68 +++++++++++++
 include/pfe_eth/pfe/cbus/hif_nocpy.h |  40 ++++++++
 include/pfe_eth/pfe/cbus/tmu_csr.h   | 148 ++++++++++++++++++++++++++++
 include/pfe_eth/pfe/cbus/util_csr.h  |  47 +++++++++
 include/pfe_eth/pfe/pfe.h            | 178 ++++++++++++++++++++++++++++++++++
 include/pfe_eth/pfe_driver.h         |  55 +++++++++++
 include/pfe_eth/pfe_eth.h            | 111 +++++++++++++++++++++
 include/pfe_eth/pfe_firmware.h       |  17 ++++
 13 files changed, 1172 insertions(+)
 create mode 100644 include/pfe_eth/pfe/cbus.h
 create mode 100644 include/pfe_eth/pfe/cbus/bmu.h
 create mode 100644 include/pfe_eth/pfe/cbus/class_csr.h
 create mode 100644 include/pfe_eth/pfe/cbus/emac.h
 create mode 100644 include/pfe_eth/pfe/cbus/gpi.h
 create mode 100644 include/pfe_eth/pfe/cbus/hif.h
 create mode 100644 include/pfe_eth/pfe/cbus/hif_nocpy.h
 create mode 100644 include/pfe_eth/pfe/cbus/tmu_csr.h
 create mode 100644 include/pfe_eth/pfe/cbus/util_csr.h
 create mode 100644 include/pfe_eth/pfe/pfe.h
 create mode 100644 include/pfe_eth/pfe_driver.h
 create mode 100644 include/pfe_eth/pfe_eth.h
 create mode 100644 include/pfe_eth/pfe_firmware.h
include/pfe_eth/pfe/cbus.h new file +75 -0
new file mode 100644
index 0000000..ec31481
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _CBUS_H_
+#define _CBUS_H_
+
+#include "cbus/emac.h"
+#include "cbus/gpi.h"
+#include "cbus/bmu.h"
+#include "cbus/hif.h"
+#include "cbus/tmu_csr.h"
+#include "cbus/class_csr.h"
+#include "cbus/hif_nocpy.h"
+#include "cbus/util_csr.h"
+
+#define CBUS_BASE_ADDR		((void *)CONFIG_SYS_FSL_PFE_ADDR)
+
+/* PFE Control and Status Register Desciption */
+#define EMAC1_BASE_ADDR		(CBUS_BASE_ADDR + 0x200000)
+#define EGPI1_BASE_ADDR		(CBUS_BASE_ADDR + 0x210000)
+#define EMAC2_BASE_ADDR		(CBUS_BASE_ADDR + 0x220000)
+#define EGPI2_BASE_ADDR		(CBUS_BASE_ADDR + 0x230000)
+#define BMU1_BASE_ADDR		(CBUS_BASE_ADDR + 0x240000)
+#define BMU2_BASE_ADDR		(CBUS_BASE_ADDR + 0x250000)
+#define ARB_BASE_ADDR		(CBUS_BASE_ADDR + 0x260000)
+#define DDR_CONFIG_BASE_ADDR	(CBUS_BASE_ADDR + 0x270000)
+#define HIF_BASE_ADDR		(CBUS_BASE_ADDR + 0x280000)
+#define HGPI_BASE_ADDR		(CBUS_BASE_ADDR + 0x290000)
+#define LMEM_BASE_ADDR		(CBUS_BASE_ADDR + 0x300000)
+#define LMEM_SIZE		0x10000
+#define LMEM_END		(LMEM_BASE_ADDR + LMEM_SIZE)
+#define TMU_CSR_BASE_ADDR	(CBUS_BASE_ADDR + 0x310000)
+#define CLASS_CSR_BASE_ADDR	(CBUS_BASE_ADDR + 0x320000)
+#define HIF_NOCPY_BASE_ADDR	(CBUS_BASE_ADDR + 0x350000)
+#define UTIL_CSR_BASE_ADDR	(CBUS_BASE_ADDR + 0x360000)
+#define CBUS_GPT_BASE_ADDR	(CBUS_BASE_ADDR + 0x370000)
+
+/*
+ * defgroup XXX_MEM_ACCESS_ADDR PE memory access through CSR
+ * XXX_MEM_ACCESS_ADDR register bit definitions.
+ */
+/* Internal Memory Write. */
+#define PE_MEM_ACCESS_WRITE		(1<<31)
+/* Internal Memory Read. */
+#define PE_MEM_ACCESS_READ		(0<<31)
+
+#define PE_MEM_ACCESS_IMEM		(1<<15)
+#define PE_MEM_ACCESS_DMEM		(1<<16)
+/* Byte Enables of the Internal memory access. These are interpred in BE */
+#define PE_MEM_ACCESS_BYTE_ENABLE(offset, size)	(((((1 << (size)) - 1) << (4 \
+							- (offset) - (size)))\
+							& 0xf) << 24)
+/* PFE cores states */
+#define CORE_DISABLE	0x00000000
+#define CORE_ENABLE	0x00000001
+#define CORE_SW_RESET	0x00000002
+
+/* LMEM defines */
+#define LMEM_HDR_SIZE		0x0010
+#define LMEM_BUF_SIZE_LN2	0x7
+#define LMEM_BUF_SIZE		(1 << LMEM_BUF_SIZE_LN2)
+
+/* DDR defines */
+#define DDR_HDR_SIZE		0x0100
+#define DDR_BUF_SIZE_LN2	0xb
+#define DDR_BUF_SIZE		(1 << DDR_BUF_SIZE_LN2)
+
+/* Clock generation through PLL */
+#define PLL_CLK_EN	1
+
+#endif /* _CBUS_H_ */
include/pfe_eth/pfe/cbus/bmu.h new file +40 -0
new file mode 100644
index 0000000..f707cc3
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _BMU_H_
+#define _BMU_H_
+
+#define BMU_VERSION		0x000
+#define BMU_CTRL		0x004
+#define BMU_UCAST_CONFIG	0x008
+#define BMU_UCAST_BASE_ADDR	0x00c
+#define BMU_BUF_SIZE		0x010
+#define BMU_BUF_CNT		0x014
+#define BMU_THRES		0x018
+#define BMU_INT_SRC		0x020
+#define BMU_INT_ENABLE		0x024
+#define BMU_ALLOC_CTRL		0x030
+#define BMU_FREE_CTRL		0x034
+#define BMU_FREE_ERR_ADDR	0x038
+#define BMU_CURR_BUF_CNT	0x03c
+#define BMU_MCAST_CNT		0x040
+#define BMU_MCAST_ALLOC_CTRL	0x044
+#define BMU_REM_BUF_CNT		0x048
+#define BMU_LOW_WATERMARK	0x050
+#define BMU_HIGH_WATERMARK	0x054
+#define BMU_INT_MEM_ACCESS	0x100
+
+struct bmu_cfg {
+	u32 baseaddr;
+	u32 count;
+	u32 size;
+};
+
+#define BMU1_BUF_SIZE	LMEM_BUF_SIZE_LN2
+#define BMU2_BUF_SIZE	DDR_BUF_SIZE_LN2
+
+#endif /* _BMU_H_ */
include/pfe_eth/pfe/cbus/class_csr.h new file +181 -0

181 lines not on this page · raw message

include/pfe_eth/pfe/cbus/emac.h new file +150 -0

150 lines not on this page · raw message

include/pfe_eth/pfe/cbus/gpi.h new file +62 -0

62 lines not on this page · raw message

include/pfe_eth/pfe/cbus/hif.h new file +68 -0

68 lines not on this page · raw message

include/pfe_eth/pfe/cbus/hif_nocpy.h new file +40 -0
new file mode 100644
index 0000000..c2d6f6d
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _HIF_NOCPY_H_
+#define _HIF_NOCPY_H_
+
+#define HIF_NOCPY_VERSION		(HIF_NOCPY_BASE_ADDR + 0x00)
+#define HIF_NOCPY_TX_CTRL		(HIF_NOCPY_BASE_ADDR + 0x04)
+#define HIF_NOCPY_TX_CURR_BD_ADDR	(HIF_NOCPY_BASE_ADDR + 0x08)
+#define HIF_NOCPY_TX_ALLOC		(HIF_NOCPY_BASE_ADDR + 0x0c)
+#define HIF_NOCPY_TX_BDP_ADDR		(HIF_NOCPY_BASE_ADDR + 0x10)
+#define HIF_NOCPY_TX_STATUS		(HIF_NOCPY_BASE_ADDR + 0x14)
+#define HIF_NOCPY_RX_CTRL		(HIF_NOCPY_BASE_ADDR + 0x20)
+#define HIF_NOCPY_RX_BDP_ADDR		(HIF_NOCPY_BASE_ADDR + 0x24)
+#define HIF_NOCPY_RX_STATUS		(HIF_NOCPY_BASE_ADDR + 0x30)
+#define HIF_NOCPY_INT_SRC		(HIF_NOCPY_BASE_ADDR + 0x34)
+#define HIF_NOCPY_INT_ENABLE		(HIF_NOCPY_BASE_ADDR + 0x38)
+#define HIF_NOCPY_POLL_CTRL		(HIF_NOCPY_BASE_ADDR + 0x3c)
+#define HIF_NOCPY_RX_CURR_BD_ADDR	(HIF_NOCPY_BASE_ADDR + 0x40)
+#define HIF_NOCPY_RX_ALLOC		(HIF_NOCPY_BASE_ADDR + 0x44)
+#define HIF_NOCPY_TX_DMA_STATUS		(HIF_NOCPY_BASE_ADDR + 0x48)
+#define HIF_NOCPY_RX_DMA_STATUS		(HIF_NOCPY_BASE_ADDR + 0x4c)
+#define HIF_NOCPY_RX_INQ0_PKTPTR	(HIF_NOCPY_BASE_ADDR + 0x50)
+#define HIF_NOCPY_RX_INQ1_PKTPTR	(HIF_NOCPY_BASE_ADDR + 0x54)
+#define HIF_NOCPY_TX_PORT_NO		(HIF_NOCPY_BASE_ADDR + 0x60)
+#define HIF_NOCPY_LMEM_ALLOC_ADDR	(HIF_NOCPY_BASE_ADDR + 0x64)
+#define HIF_NOCPY_CLASS_ADDR		(HIF_NOCPY_BASE_ADDR + 0x68)
+#define HIF_NOCPY_TMU_PORT0_ADDR	(HIF_NOCPY_BASE_ADDR + 0x70)
+#define HIF_NOCPY_TMU_PORT1_ADDR	(HIF_NOCPY_BASE_ADDR + 0x74)
+#define HIF_NOCPY_TMU_PORT2_ADDR	(HIF_NOCPY_BASE_ADDR + 0x7c)
+#define HIF_NOCPY_TMU_PORT3_ADDR	(HIF_NOCPY_BASE_ADDR + 0x80)
+#define HIF_NOCPY_TMU_PORT4_ADDR	(HIF_NOCPY_BASE_ADDR + 0x84)
+#define HIF_NOCPY_INT_COAL		(HIF_NOCPY_BASE_ADDR + 0x90)
+#define HIF_NOCPY_AXI_CTRL		(HIF_NOCPY_BASE_ADDR + 0x94)
+
+#endif /* _HIF_NOCPY_H_ */
include/pfe_eth/pfe/cbus/tmu_csr.h new file +148 -0

148 lines not on this page · raw message

include/pfe_eth/pfe/cbus/util_csr.h new file +47 -0

47 lines not on this page · raw message

include/pfe_eth/pfe/pfe.h new file +178 -0

178 lines not on this page · raw message

include/pfe_eth/pfe_driver.h new file +55 -0

55 lines not on this page · raw message

include/pfe_eth/pfe_eth.h new file +111 -0

111 lines not on this page · raw message

include/pfe_eth/pfe_firmware.h new file +17 -0
new file mode 100644
index 0000000..588b2ae
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/** @file
+ *  Contains all the defines to handle parsing and loading of PE firmware files.
+ */
+#ifndef __PFE_FIRMWARE_H__
+#define __PFE_FIRMWARE_H__
+
+int pfe_firmware_init(void);
+void pfe_firmware_exit(void);
+
+#endif
Signature · 1 line
2.7.4
#8 lore raw

PATCH 3/9 drivers: net: pfe_eth: LS1012A PFE headers

Quoted 81 lines · Calvin Johnson

Contains all the pfe header files.

---
 include/pfe_eth/pfe/cbus.h           |  75 +++++++++++++++
 include/pfe_eth/pfe/cbus/bmu.h       |  40 ++++++++
 include/pfe_eth/pfe/cbus/class_csr.h | 181 +++++++++++++++++++++++++++++++++++
 include/pfe_eth/pfe/cbus/emac.h      | 150 +++++++++++++++++++++++++++++
 include/pfe_eth/pfe/cbus/gpi.h       |  62 ++++++++++++
 include/pfe_eth/pfe/cbus/hif.h       |  68 +++++++++++++
 include/pfe_eth/pfe/cbus/hif_nocpy.h |  40 ++++++++
 include/pfe_eth/pfe/cbus/tmu_csr.h   | 148 ++++++++++++++++++++++++++++
 include/pfe_eth/pfe/cbus/util_csr.h  |  47 +++++++++
 include/pfe_eth/pfe/pfe.h            | 178 ++++++++++++++++++++++++++++++++++
 include/pfe_eth/pfe_driver.h         |  55 +++++++++++
 include/pfe_eth/pfe_eth.h            | 111 +++++++++++++++++++++
 include/pfe_eth/pfe_firmware.h       |  17 ++++
 13 files changed, 1172 insertions(+)
 create mode 100644 include/pfe_eth/pfe/cbus.h
 create mode 100644 include/pfe_eth/pfe/cbus/bmu.h
 create mode 100644 include/pfe_eth/pfe/cbus/class_csr.h
 create mode 100644 include/pfe_eth/pfe/cbus/emac.h
 create mode 100644 include/pfe_eth/pfe/cbus/gpi.h
 create mode 100644 include/pfe_eth/pfe/cbus/hif.h
 create mode 100644 include/pfe_eth/pfe/cbus/hif_nocpy.h
 create mode 100644 include/pfe_eth/pfe/cbus/tmu_csr.h
 create mode 100644 include/pfe_eth/pfe/cbus/util_csr.h
 create mode 100644 include/pfe_eth/pfe/pfe.h
 create mode 100644 include/pfe_eth/pfe_driver.h
 create mode 100644 include/pfe_eth/pfe_eth.h
 create mode 100644 include/pfe_eth/pfe_firmware.h
include/pfe_eth/pfe/cbus.h new file +42 -0
new file mode 100644
index 0000000..ec31481
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _CBUS_H_
+#define _CBUS_H_
+
+#include "cbus/emac.h"
+#include "cbus/gpi.h"
+#include "cbus/bmu.h"
+#include "cbus/hif.h"
+#include "cbus/tmu_csr.h"
+#include "cbus/class_csr.h"
+#include "cbus/hif_nocpy.h"
+#include "cbus/util_csr.h"
+
+#define CBUS_BASE_ADDR         ((void *)CONFIG_SYS_FSL_PFE_ADDR)
+
+/* PFE Control and Status Register Desciption */
+#define EMAC1_BASE_ADDR                (CBUS_BASE_ADDR + 0x200000)
+#define EGPI1_BASE_ADDR                (CBUS_BASE_ADDR + 0x210000)
+#define EMAC2_BASE_ADDR                (CBUS_BASE_ADDR + 0x220000)
+#define EGPI2_BASE_ADDR                (CBUS_BASE_ADDR + 0x230000)
+#define BMU1_BASE_ADDR         (CBUS_BASE_ADDR + 0x240000)
+#define BMU2_BASE_ADDR         (CBUS_BASE_ADDR + 0x250000)
+#define ARB_BASE_ADDR          (CBUS_BASE_ADDR + 0x260000)
+#define DDR_CONFIG_BASE_ADDR   (CBUS_BASE_ADDR + 0x270000)
+#define HIF_BASE_ADDR          (CBUS_BASE_ADDR + 0x280000)
+#define HGPI_BASE_ADDR         (CBUS_BASE_ADDR + 0x290000)
+#define LMEM_BASE_ADDR         (CBUS_BASE_ADDR + 0x300000)
+#define LMEM_SIZE              0x10000
+#define LMEM_END               (LMEM_BASE_ADDR + LMEM_SIZE)
+#define TMU_CSR_BASE_ADDR      (CBUS_BASE_ADDR + 0x310000)
+#define CLASS_CSR_BASE_ADDR    (CBUS_BASE_ADDR + 0x320000)
+#define HIF_NOCPY_BASE_ADDR    (CBUS_BASE_ADDR + 0x350000)
+#define UTIL_CSR_BASE_ADDR     (CBUS_BASE_ADDR + 0x360000)
+#define CBUS_GPT_BASE_ADDR     (CBUS_BASE_ADDR + 0x370000)
+
+/*

include/pfe_eth/pfe/cbus.h line 52

Quoted 10 lines
include/pfe_eth/pfe/cbus.h new file +10 -0
+ * defgroup XXX_MEM_ACCESS_ADDR PE memory access through CSR
+ * XXX_MEM_ACCESS_ADDR register bit definitions.
+ */
+/* Internal Memory Write. */
+#define PE_MEM_ACCESS_WRITE            (1<<31)
+/* Internal Memory Read. */
+#define PE_MEM_ACCESS_READ             (0<<31)
+
+#define PE_MEM_ACCESS_IMEM             (1<<15)
+#define PE_MEM_ACCESS_DMEM             (1<<16)

Please use the BIT() macro for this sort of define.

include/pfe_eth/pfe/cbus.h line 56

Quoted 4 lines
include/pfe_eth/pfe/cbus.h new file +4 -0
+/* Byte Enables of the Internal memory access. These are interpred in BE */
+#define PE_MEM_ACCESS_BYTE_ENABLE(offset, size)        (((((1 << (size)) - 1) << (4 \
+                                                       - (offset) - (size)))\
+                                                       & 0xf) << 24)

This is pretty unreadable. If you can improve it, please do.

Quoted 230 lines
include/pfe_eth/pfe/cbus.h new file +19 -0
+/* PFE cores states */
+#define CORE_DISABLE   0x00000000
+#define CORE_ENABLE    0x00000001
+#define CORE_SW_RESET  0x00000002
+
+/* LMEM defines */
+#define LMEM_HDR_SIZE          0x0010
+#define LMEM_BUF_SIZE_LN2      0x7
+#define LMEM_BUF_SIZE          (1 << LMEM_BUF_SIZE_LN2)
+
+/* DDR defines */
+#define DDR_HDR_SIZE           0x0100
+#define DDR_BUF_SIZE_LN2       0xb
+#define DDR_BUF_SIZE           (1 << DDR_BUF_SIZE_LN2)
+
+/* Clock generation through PLL */
+#define PLL_CLK_EN     1
+
+#endif /* _CBUS_H_ */
include/pfe_eth/pfe/cbus/bmu.h new file +40 -0
new file mode 100644
index 0000000..f707cc3
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _BMU_H_
+#define _BMU_H_
+
+#define BMU_VERSION            0x000
+#define BMU_CTRL               0x004
+#define BMU_UCAST_CONFIG       0x008
+#define BMU_UCAST_BASE_ADDR    0x00c
+#define BMU_BUF_SIZE           0x010
+#define BMU_BUF_CNT            0x014
+#define BMU_THRES              0x018
+#define BMU_INT_SRC            0x020
+#define BMU_INT_ENABLE         0x024
+#define BMU_ALLOC_CTRL         0x030
+#define BMU_FREE_CTRL          0x034
+#define BMU_FREE_ERR_ADDR      0x038
+#define BMU_CURR_BUF_CNT       0x03c
+#define BMU_MCAST_CNT          0x040
+#define BMU_MCAST_ALLOC_CTRL   0x044
+#define BMU_REM_BUF_CNT                0x048
+#define BMU_LOW_WATERMARK      0x050
+#define BMU_HIGH_WATERMARK     0x054
+#define BMU_INT_MEM_ACCESS     0x100
+
+struct bmu_cfg {
+       u32 baseaddr;
+       u32 count;
+       u32 size;
+};
+
+#define BMU1_BUF_SIZE  LMEM_BUF_SIZE_LN2
+#define BMU2_BUF_SIZE  DDR_BUF_SIZE_LN2
+
+#endif /* _BMU_H_ */
include/pfe_eth/pfe/cbus/class_csr.h new file +159 -0
new file mode 100644
index 0000000..413707f
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _CLASS_CSR_H_
+#define _CLASS_CSR_H_
+
+/*
+ * @file class_csr.h.
+ * class_csr - block containing all the classifier control and status register.
+ * Mapped on CBUS and accessible from all PE's and ARM.
+ */
+#define CLASS_VERSION                  (CLASS_CSR_BASE_ADDR + 0x000)
+#define CLASS_TX_CTRL                  (CLASS_CSR_BASE_ADDR + 0x004)
+#define CLASS_INQ_PKTPTR               (CLASS_CSR_BASE_ADDR + 0x010)
+/* (ddr_hdr_size[24:16], lmem_hdr_size[5:0]) */
+#define CLASS_HDR_SIZE                 (CLASS_CSR_BASE_ADDR + 0x014)
+/* LMEM header size for the Classifier block.
+ * Data in the LMEM is written from this offset.
+ */
+#define CLASS_HDR_SIZE_LMEM(off)       ((off) & 0x3f)
+/* DDR header size for the Classifier block.
+ * Data in the DDR is written from this offset.
+ */
+#define CLASS_HDR_SIZE_DDR(off)                (((off) & 0x1ff) << 16)
+
+/* DMEM address of first [15:0] and second [31:16] buffers on QB side. */
+#define CLASS_PE0_QB_DM_ADDR0          (CLASS_CSR_BASE_ADDR + 0x020)
+/* DMEM address of third [15:0] and fourth [31:16] buffers on QB side. */
+#define CLASS_PE0_QB_DM_ADDR1          (CLASS_CSR_BASE_ADDR + 0x024)
+
+/* DMEM address of first [15:0] and second [31:16] buffers on RO side. */
+#define CLASS_PE0_RO_DM_ADDR0          (CLASS_CSR_BASE_ADDR + 0x060)
+/* DMEM address of third [15:0] and fourth [31:16] buffers on RO side. */
+#define CLASS_PE0_RO_DM_ADDR1          (CLASS_CSR_BASE_ADDR + 0x064)
+
+/*
+ * @name Class PE memory access. Allows external PE's and HOST to
+ * read/write PMEM/DMEM memory ranges for each classifier PE.
+ */
+#define CLASS_MEM_ACCESS_ADDR          (CLASS_CSR_BASE_ADDR + 0x100)
+/* Internal Memory Access Write Data [31:0] */
+#define CLASS_MEM_ACCESS_WDATA         (CLASS_CSR_BASE_ADDR + 0x104)
+/* Internal Memory Access Read Data [31:0] */
+#define CLASS_MEM_ACCESS_RDATA         (CLASS_CSR_BASE_ADDR + 0x108)
+#define CLASS_TM_INQ_ADDR              (CLASS_CSR_BASE_ADDR + 0x114)
+#define CLASS_PE_STATUS                        (CLASS_CSR_BASE_ADDR + 0x118)
+
+#define CLASS_PE_SYS_CLK_RATIO         (CLASS_CSR_BASE_ADDR + 0x200)
+#define CLASS_AFULL_THRES              (CLASS_CSR_BASE_ADDR + 0x204)
+#define CLASS_GAP_BETWEEN_READS                (CLASS_CSR_BASE_ADDR + 0x208)
+#define CLASS_MAX_BUF_CNT              (CLASS_CSR_BASE_ADDR + 0x20c)
+#define CLASS_TSQ_FIFO_THRES           (CLASS_CSR_BASE_ADDR + 0x210)
+#define CLASS_TSQ_MAX_CNT              (CLASS_CSR_BASE_ADDR + 0x214)
+#define CLASS_IRAM_DATA_0              (CLASS_CSR_BASE_ADDR + 0x218)
+#define CLASS_IRAM_DATA_1              (CLASS_CSR_BASE_ADDR + 0x21c)
+#define CLASS_IRAM_DATA_2              (CLASS_CSR_BASE_ADDR + 0x220)
+#define CLASS_IRAM_DATA_3              (CLASS_CSR_BASE_ADDR + 0x224)
+
+#define CLASS_BUS_ACCESS_ADDR          (CLASS_CSR_BASE_ADDR + 0x228)
+/* bit 23:0 of PE peripheral address are stored in CLASS_BUS_ACCESS_ADDR */
+#define CLASS_BUS_ACCESS_ADDR_MASK     (0x0001FFFF)
+
+#define CLASS_BUS_ACCESS_WDATA         (CLASS_CSR_BASE_ADDR + 0x22c)
+#define CLASS_BUS_ACCESS_RDATA         (CLASS_CSR_BASE_ADDR + 0x230)
+
+/*
+ * (route_entry_size[9:0], route_hash_size[23:16]
+ * (this is actually ln2(size)))
+ */
+#define CLASS_ROUTE_HASH_ENTRY_SIZE    (CLASS_CSR_BASE_ADDR + 0x234)
+#define CLASS_ROUTE_ENTRY_SIZE(size)    ((size) & 0x1ff)
+#define CLASS_ROUTE_HASH_SIZE(hash_bits) (((hash_bits) & 0xff) << 16)
+
+#define CLASS_ROUTE_TABLE_BASE         (CLASS_CSR_BASE_ADDR + 0x238)
+#define CLASS_ROUTE_MULTI              (CLASS_CSR_BASE_ADDR + 0x23c)
+#define CLASS_SMEM_OFFSET              (CLASS_CSR_BASE_ADDR + 0x240)
+#define CLASS_LMEM_BUF_SIZE            (CLASS_CSR_BASE_ADDR + 0x244)
+#define CLASS_VLAN_ID                  (CLASS_CSR_BASE_ADDR + 0x248)
+#define CLASS_BMU1_BUF_FREE            (CLASS_CSR_BASE_ADDR + 0x24c)
+#define CLASS_USE_TMU_INQ              (CLASS_CSR_BASE_ADDR + 0x250)
+#define CLASS_VLAN_ID1                 (CLASS_CSR_BASE_ADDR + 0x254)
+
+#define CLASS_BUS_ACCESS_BASE          (CLASS_CSR_BASE_ADDR + 0x258)
+/* bit 31:24 of PE peripheral address are stored in CLASS_BUS_ACCESS_BASE */
+#define CLASS_BUS_ACCESS_BASE_MASK     (0xFF000000)
+
+#define CLASS_HIF_PARSE                        (CLASS_CSR_BASE_ADDR + 0x25c)
+
+#define CLASS_HOST_PE0_GP              (CLASS_CSR_BASE_ADDR + 0x260)
+#define CLASS_PE0_GP                   (CLASS_CSR_BASE_ADDR + 0x264)
+#define CLASS_HOST_PE1_GP              (CLASS_CSR_BASE_ADDR + 0x268)
+#define CLASS_PE1_GP                   (CLASS_CSR_BASE_ADDR + 0x26c)
+#define CLASS_HOST_PE2_GP              (CLASS_CSR_BASE_ADDR + 0x270)
+#define CLASS_PE2_GP                   (CLASS_CSR_BASE_ADDR + 0x274)
+#define CLASS_HOST_PE3_GP              (CLASS_CSR_BASE_ADDR + 0x278)
+#define CLASS_PE3_GP                   (CLASS_CSR_BASE_ADDR + 0x27c)
+#define CLASS_HOST_PE4_GP              (CLASS_CSR_BASE_ADDR + 0x280)
+#define CLASS_PE4_GP                   (CLASS_CSR_BASE_ADDR + 0x284)
+#define CLASS_HOST_PE5_GP              (CLASS_CSR_BASE_ADDR + 0x288)
+#define CLASS_PE5_GP                   (CLASS_CSR_BASE_ADDR + 0x28c)
+
+#define CLASS_PE_INT_SRC               (CLASS_CSR_BASE_ADDR + 0x290)
+#define CLASS_PE_INT_ENABLE            (CLASS_CSR_BASE_ADDR + 0x294)
+
+#define CLASS_TPID0_TPID1              (CLASS_CSR_BASE_ADDR + 0x298)
+#define CLASS_TPID2                    (CLASS_CSR_BASE_ADDR + 0x29c)
+
+#define CLASS_L4_CHKSUM_ADDR           (CLASS_CSR_BASE_ADDR + 0x2a0)
+
+#define CLASS_PE0_DEBUG                        (CLASS_CSR_BASE_ADDR + 0x2a4)
+#define CLASS_PE1_DEBUG                        (CLASS_CSR_BASE_ADDR + 0x2a8)
+#define CLASS_PE2_DEBUG                        (CLASS_CSR_BASE_ADDR + 0x2ac)
+#define CLASS_PE3_DEBUG                        (CLASS_CSR_BASE_ADDR + 0x2b0)
+#define CLASS_PE4_DEBUG                        (CLASS_CSR_BASE_ADDR + 0x2b4)
+#define CLASS_PE5_DEBUG                        (CLASS_CSR_BASE_ADDR + 0x2b8)
+
+#define CLASS_STATE                    (CLASS_CSR_BASE_ADDR + 0x2bc)
+#define CLASS_AXI_CTRL                 (CLASS_CSR_BASE_ADDR + 0x2d0)
+
+/* CLASS defines */
+#define CLASS_PBUF_SIZE                        0x100   /* Fixed by hardware */
+#define CLASS_PBUF_HEADER_OFFSET       0x80    /* Can be configured */
+
+#define CLASS_PBUF0_BASE_ADDR          0x000   /* Can be configured */
+/* Can be configured */
+#define CLASS_PBUF1_BASE_ADDR  (CLASS_PBUF0_BASE_ADDR + CLASS_PBUF_SIZE)
+/* Can be configured */
+#define CLASS_PBUF2_BASE_ADDR  (CLASS_PBUF1_BASE_ADDR + CLASS_PBUF_SIZE)
+/* Can be configured */
+#define CLASS_PBUF3_BASE_ADDR  (CLASS_PBUF2_BASE_ADDR + CLASS_PBUF_SIZE)
+
+#define CLASS_PBUF0_HEADER_BASE_ADDR   (CLASS_PBUF0_BASE_ADDR +\
+                                               CLASS_PBUF_HEADER_OFFSET)
+#define CLASS_PBUF1_HEADER_BASE_ADDR   (CLASS_PBUF1_BASE_ADDR +\
+                                               CLASS_PBUF_HEADER_OFFSET)
+#define CLASS_PBUF2_HEADER_BASE_ADDR   (CLASS_PBUF2_BASE_ADDR +\
+                                               CLASS_PBUF_HEADER_OFFSET)
+#define CLASS_PBUF3_HEADER_BASE_ADDR   (CLASS_PBUF3_BASE_ADDR +\
+                                               CLASS_PBUF_HEADER_OFFSET)
+
+#define CLASS_PE0_RO_DM_ADDR0_VAL      ((CLASS_PBUF1_BASE_ADDR << 16) |\
+                                               CLASS_PBUF0_BASE_ADDR)
+#define CLASS_PE0_RO_DM_ADDR1_VAL      ((CLASS_PBUF3_BASE_ADDR << 16) |\
+                                               CLASS_PBUF2_BASE_ADDR)
+
+#define CLASS_PE0_QB_DM_ADDR0_VAL      ((CLASS_PBUF1_HEADER_BASE_ADDR << 16)\
+                                               | CLASS_PBUF0_HEADER_BASE_ADDR)
+#define CLASS_PE0_QB_DM_ADDR1_VAL      ((CLASS_PBUF3_HEADER_BASE_ADDR << 16)\
+                                               | CLASS_PBUF2_HEADER_BASE_ADDR)
+
+#define CLASS_ROUTE_SIZE               128
+#define CLASS_ROUTE_HASH_BITS          20
+#define CLASS_ROUTE_HASH_MASK          ((1 << CLASS_ROUTE_HASH_BITS) - 1)
+
+#define TWO_LEVEL_ROUTE                (1 << 0)

include/pfe_eth/pfe/cbus/class_csr.h line 169

Quoted 10 lines
include/pfe_eth/pfe/cbus/class_csr.h new file +10 -0
+#define PHYNO_IN_HASH          (1 << 1)
+#define HW_ROUTE_FETCH         (1 << 3)
+#define HW_BRIDGE_FETCH                (1 << 5)
+#define IP_ALIGNED             (1 << 6)
+#define ARC_HIT_CHECK_EN       (1 << 7)
+#define CLASS_TOE              (1 << 11)
+#define HASH_NORMAL            (0 << 12)
+#define HASH_CRC_PORT          (1 << 12)
+#define HASH_CRC_IP            (2 << 12)
+#define HASH_CRC_PORT_IP       (3 << 12)

You can use the GENMASK() macro for this type of define.

Quoted 111 lines
include/pfe_eth/pfe/cbus/class_csr.h new file +12 -0
+#define QB2BUS_LE              (1 << 15)
+
+#define        TCP_CHKSUM_DROP         (1 << 0)
+#define        UDP_CHKSUM_DROP         (1 << 1)
+#define        IPV4_CHKSUM_DROP        (1 << 9)
+
+struct class_cfg {
+       u32 route_table_baseaddr;
+       u32 route_table_hash_bits;
+};
+
+#endif /* _CLASS_CSR_H_ */
include/pfe_eth/pfe/cbus/emac.h new file +93 -0
new file mode 100644
index 0000000..3cfcd99
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _EMAC_H_
+#define _EMAC_H_
+
+#define EMAC_IEVENT_REG                0x004
+#define EMAC_IMASK_REG         0x008
+#define EMAC_R_DES_ACTIVE_REG  0x010
+#define EMAC_X_DES_ACTIVE_REG  0x014
+#define EMAC_ECNTRL_REG                0x024
+#define EMAC_MII_DATA_REG      0x040
+#define EMAC_MII_CTRL_REG      0x044
+#define EMAC_MIB_CTRL_STS_REG  0x064
+#define EMAC_RCNTRL_REG                0x084
+#define EMAC_TCNTRL_REG                0x0C4
+#define EMAC_PHY_ADDR_LOW      0x0E4
+#define EMAC_PHY_ADDR_HIGH     0x0E8
+#define EMAC_TFWR_STR_FWD      0x144
+#define EMAC_RX_SECTIOM_FULL   0x190
+#define EMAC_TX_SECTION_EMPTY  0x1A0
+#define EMAC_TRUNC_FL          0x1B0
+
+/* GEMAC definitions and settings */
+#define EMAC_PORT_0                    0
+#define EMAC_PORT_1                    1
+
+/* GEMAC Bit definitions */
+#define EMAC_IEVENT_HBERR                0x80000000
+#define EMAC_IEVENT_BABR                 0x40000000
+#define EMAC_IEVENT_BABT                 0x20000000
+#define EMAC_IEVENT_GRA                  0x10000000
+#define EMAC_IEVENT_TXF                  0x08000000
+#define EMAC_IEVENT_TXB                  0x04000000
+#define EMAC_IEVENT_RXF                  0x02000000
+#define EMAC_IEVENT_RXB                  0x01000000
+#define EMAC_IEVENT_MII                  0x00800000
+#define EMAC_IEVENT_EBERR                0x00400000
+#define EMAC_IEVENT_LC                   0x00200000
+#define EMAC_IEVENT_RL                   0x00100000
+#define EMAC_IEVENT_UN                   0x00080000
+
+#define EMAC_IMASK_HBERR                 0x80000000
+#define EMAC_IMASK_BABR                  0x40000000
+#define EMAC_IMASKT_BABT                 0x20000000
+#define EMAC_IMASK_GRA                   0x10000000
+#define EMAC_IMASKT_TXF                  0x08000000
+#define EMAC_IMASK_TXB                   0x04000000
+#define EMAC_IMASKT_RXF                  0x02000000
+#define EMAC_IMASK_RXB                   0x01000000
+#define EMAC_IMASK_MII                   0x00800000
+#define EMAC_IMASK_EBERR                 0x00400000
+#define EMAC_IMASK_LC                    0x00200000
+#define EMAC_IMASKT_RL                   0x00100000
+#define EMAC_IMASK_UN                    0x00080000
+
+#define EMAC_RCNTRL_MAX_FL_SHIFT         16
+#define EMAC_RCNTRL_LOOP                 0x00000001
+#define EMAC_RCNTRL_DRT                  0x00000002
+#define EMAC_RCNTRL_MII_MODE             0x00000004
+#define EMAC_RCNTRL_PROM                 0x00000008
+#define EMAC_RCNTRL_BC_REJ               0x00000010
+#define EMAC_RCNTRL_FCE                  0x00000020
+#define EMAC_RCNTRL_RGMII                0x00000040
+#define EMAC_RCNTRL_SGMII                0x00000080
+#define EMAC_RCNTRL_RMII                 0x00000100
+#define EMAC_RCNTRL_RMII_10T             0x00000200
+#define EMAC_RCNTRL_CRC_FWD             0x00004000
+
+#define EMAC_TCNTRL_GTS                  0x00000001
+#define EMAC_TCNTRL_HBC                  0x00000002
+#define EMAC_TCNTRL_FDEN                 0x00000004
+#define EMAC_TCNTRL_TFC_PAUSE            0x00000008
+#define EMAC_TCNTRL_RFC_PAUSE            0x00000010
+
+#define EMAC_ECNTRL_RESET                0x00000001      /* reset the EMAC */
+#define EMAC_ECNTRL_ETHER_EN             0x00000002      /* enable the EMAC */
+#define EMAC_ECNTRL_SPEED                0x00000020
+#define EMAC_ECNTRL_DBSWAP               0x00000100
+
+#define EMAC_X_WMRK_STRFWD               0x00000100
+
+#define EMAC_X_DES_ACTIVE_TDAR           0x01000000
+#define EMAC_R_DES_ACTIVE_RDAR           0x01000000
+
+/*
+ * The possible operating speeds of the MAC, currently supporting 10, 100 and
+ * 1000Mb modes.
+ */

include/pfe_eth/pfe/cbus/emac.h line 103

Quoted 10 lines
include/pfe_eth/pfe/cbus/emac.h new file +10 -0
+enum mac_speed {SPEED_10M, SPEED_100M, SPEED_1000M, SPEED_1000M_PCS};
+
+#define GMII   1
+#define MII    2
+#define RMII   3
+#define RGMII  4
+#define SGMII  5
+
+#define DUPLEX_HALF    0x00
+#define DUPLEX_FULL    0x01

These seem very generic and will pollute the namespace. Please prefix or remove or reuse common header.

Quoted 834 lines
include/pfe_eth/pfe/cbus/emac.h new file +47 -0
+
+/* Default configuration */
+#define EMAC0_DEFAULT_DUPLEX_MODE      FULLDUPLEX
+#define EMAC0_DEFAULT_EMAC_MODE                RGMII
+#define EMAC0_DEFAULT_EMAC_SPEED       SPEED_1000M
+
+#define EMAC1_DEFAULT_DUPLEX_MODE      FULLDUPLEX
+#define EMAC1_DEFAULT_EMAC_MODE                SGMII
+#define EMAC1_DEFAULT_EMAC_SPEED       SPEED_1000M
+
+/* MII-related definitios */
+#define EMAC_MII_DATA_ST         0x40000000      /* Start of frame delimiter */
+#define EMAC_MII_DATA_OP_RD      0x20000000      /* Perform a read operation */
+#define EMAC_MII_DATA_OP_CL45_RD 0x30000000      /* Perform a read operation */
+#define EMAC_MII_DATA_OP_WR      0x10000000      /* Perform a write operation */
+#define EMAC_MII_DATA_OP_CL45_WR 0x10000000      /* Perform a write operation */
+#define EMAC_MII_DATA_PA_MSK     0x0f800000      /* PHY Address field mask */
+#define EMAC_MII_DATA_RA_MSK     0x007c0000      /* PHY Register field mask */
+#define EMAC_MII_DATA_TA         0x00020000      /* Turnaround */
+#define EMAC_MII_DATA_DATAMSK    0x0000ffff      /* PHY data field */
+
+#define EMAC_MII_DATA_RA_SHIFT   18      /* MII Register address bits */
+#define EMAC_MII_DATA_RA_MASK   0x1F      /* MII Register address mask */
+#define EMAC_MII_DATA_PA_SHIFT   23      /* MII PHY address bits */
+#define EMAC_MII_DATA_PA_MASK    0x1F      /* MII PHY address mask */
+
+#define EMAC_MII_DATA_RA(v) ((v & EMAC_MII_DATA_RA_MASK) <<\
+                               EMAC_MII_DATA_RA_SHIFT)
+#define EMAC_MII_DATA_PA(v) ((v & EMAC_MII_DATA_RA_MASK) <<\
+                               EMAC_MII_DATA_PA_SHIFT)
+#define EMAC_MII_DATA(v)    (v & 0xffff)
+
+#define EMAC_MII_SPEED_SHIFT   1
+#define EMAC_HOLDTIME_SHIFT    8
+#define EMAC_HOLDTIME_MASK     0x7
+#define EMAC_HOLDTIME(v)    ((v & EMAC_HOLDTIME_MASK) << EMAC_HOLDTIME_SHIFT)
+
+/* Internal PHY Registers - SGMII */
+#define PHY_SGMII_CR_PHY_RESET      0x8000
+#define PHY_SGMII_CR_RESET_AN       0x0200
+#define PHY_SGMII_CR_DEF_VAL        0x1140
+#define PHY_SGMII_DEV_ABILITY_SGMII 0x4001
+#define PHY_SGMII_IF_MODE_AN        0x0002
+#define PHY_SGMII_IF_MODE_SGMII     0x0001
+#define PHY_SGMII_IF_MODE_SGMII_GBT 0x0008
+
+#endif /* _EMAC_H_ */
include/pfe_eth/pfe/cbus/gpi.h new file +62 -0
new file mode 100644
index 0000000..f86f3f9
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _GPI_H_
+#define _GPI_H_
+
+#define GPI_VERSION                    0x00
+#define GPI_CTRL                       0x04
+#define GPI_RX_CONFIG                  0x08
+#define GPI_HDR_SIZE                   0x0c
+#define GPI_BUF_SIZE                   0x10
+#define GPI_LMEM_ALLOC_ADDR            0x14
+#define GPI_LMEM_FREE_ADDR             0x18
+#define GPI_DDR_ALLOC_ADDR             0x1c
+#define GPI_DDR_FREE_ADDR              0x20
+#define GPI_CLASS_ADDR                 0x24
+#define GPI_DRX_FIFO                   0x28
+#define GPI_TRX_FIFO                   0x2c
+#define GPI_INQ_PKTPTR                 0x30
+#define GPI_DDR_DATA_OFFSET            0x34
+#define GPI_LMEM_DATA_OFFSET           0x38
+#define GPI_TMLF_TX                    0x4c
+#define GPI_DTX_ASEQ                   0x50
+#define GPI_FIFO_STATUS                        0x54
+#define GPI_FIFO_DEBUG                 0x58
+#define GPI_TX_PAUSE_TIME              0x5c
+#define GPI_LMEM_SEC_BUF_DATA_OFFSET   0x60
+#define GPI_DDR_SEC_BUF_DATA_OFFSET    0x64
+#define GPI_TOE_CHKSUM_EN              0x68
+#define GPI_OVERRUN_DROPCNT            0x6c
+#define GPI_AXI_CTRL                   0x70
+
+struct gpi_cfg {
+       u32 lmem_rtry_cnt;
+       u32 tmlf_txthres;
+       u32 aseq_len;
+};
+
+/* GPI commons defines */
+#define GPI_LMEM_BUF_EN                0x1
+#define GPI_DDR_BUF_EN         0x1
+
+/* EGPI 1 defines */
+#define EGPI1_LMEM_RTRY_CNT    0x40
+#define EGPI1_TMLF_TXTHRES     0xBC
+#define EGPI1_ASEQ_LEN         0x50
+
+/* EGPI 2 defines */
+#define EGPI2_LMEM_RTRY_CNT    0x40
+#define EGPI2_TMLF_TXTHRES     0xBC
+#define EGPI2_ASEQ_LEN         0x40
+
+/* HGPI defines */
+#define HGPI_LMEM_RTRY_CNT     0x40
+#define HGPI_TMLF_TXTHRES      0xBC
+#define HGPI_ASEQ_LEN          0x40
+
+#endif /* _GPI_H_ */
include/pfe_eth/pfe/cbus/hif.h new file +68 -0
new file mode 100644
index 0000000..f602b58
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _HIF_H_
+#define _HIF_H_
+
+/*
+ * @file hif.h.
+ * hif - PFE hif block control and status register.
+ * Mapped on CBUS and accessible from all PE's and ARM.
+ */
+#define HIF_VERSION            (HIF_BASE_ADDR + 0x00)
+#define HIF_TX_CTRL            (HIF_BASE_ADDR + 0x04)
+#define HIF_TX_CURR_BD_ADDR    (HIF_BASE_ADDR + 0x08)
+#define HIF_TX_ALLOC           (HIF_BASE_ADDR + 0x0c)
+#define HIF_TX_BDP_ADDR                (HIF_BASE_ADDR + 0x10)
+#define HIF_TX_STATUS          (HIF_BASE_ADDR + 0x14)
+#define HIF_RX_CTRL            (HIF_BASE_ADDR + 0x20)
+#define HIF_RX_BDP_ADDR                (HIF_BASE_ADDR + 0x24)
+#define HIF_RX_STATUS          (HIF_BASE_ADDR + 0x30)
+#define HIF_INT_SRC            (HIF_BASE_ADDR + 0x34)
+#define HIF_INT_ENABLE         (HIF_BASE_ADDR + 0x38)
+#define HIF_POLL_CTRL          (HIF_BASE_ADDR + 0x3c)
+#define HIF_RX_CURR_BD_ADDR    (HIF_BASE_ADDR + 0x40)
+#define HIF_RX_ALLOC           (HIF_BASE_ADDR + 0x44)
+#define HIF_TX_DMA_STATUS      (HIF_BASE_ADDR + 0x48)
+#define HIF_RX_DMA_STATUS      (HIF_BASE_ADDR + 0x4c)
+#define HIF_INT_COAL           (HIF_BASE_ADDR + 0x50)
+#define HIF_AXI_CTRL           (HIF_BASE_ADDR + 0x54)
+
+/* HIF_TX_CTRL bits */
+#define HIF_CTRL_DMA_EN                        (1<<0)
+#define HIF_CTRL_BDP_POLL_CTRL_EN      (1<<1)
+#define HIF_CTRL_BDP_CH_START_WSTB     (1<<2)
+
+/* HIF_RX_STATUS bits */
+#define BDP_CSR_RX_DMA_ACTV    (1<<16)
+
+/* HIF_INT_ENABLE bits */
+#define HIF_INT_EN             (1 << 0)
+#define HIF_RXBD_INT_EN                (1 << 1)
+#define HIF_RXPKT_INT_EN       (1 << 2)
+#define HIF_TXBD_INT_EN                (1 << 3)
+#define HIF_TXPKT_INT_EN       (1 << 4)
+
+/* HIF_POLL_CTRL bits*/
+#define HIF_RX_POLL_CTRL_CYCLE 0x0400
+#define HIF_TX_POLL_CTRL_CYCLE 0x0400
+
+/* Buffer descriptor control bits */
+#define BD_CTRL_BUFLEN_MASK    (0xffff)
+#define BD_BUF_LEN(x)  (x & BD_CTRL_BUFLEN_MASK)
+#define BD_CTRL_CBD_INT_EN     (1 << 16)
+#define BD_CTRL_PKT_INT_EN     (1 << 17)
+#define BD_CTRL_LIFM           (1 << 18)
+#define BD_CTRL_LAST_BD                (1 << 19)
+#define BD_CTRL_DIR            (1 << 20)
+#define BD_CTRL_PKT_XFER       (1 << 24)
+#define BD_CTRL_DESC_EN                (1 << 31)
+#define BD_CTRL_PARSE_DISABLE  (1 << 25)
+#define BD_CTRL_BRFETCH_DISABLE        (1 << 26)
+#define BD_CTRL_RTFETCH_DISABLE        (1 << 27)
+
+#endif /* _HIF_H_ */
include/pfe_eth/pfe/cbus/hif_nocpy.h new file +40 -0
new file mode 100644
index 0000000..c2d6f6d
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _HIF_NOCPY_H_
+#define _HIF_NOCPY_H_
+
+#define HIF_NOCPY_VERSION              (HIF_NOCPY_BASE_ADDR + 0x00)
+#define HIF_NOCPY_TX_CTRL              (HIF_NOCPY_BASE_ADDR + 0x04)
+#define HIF_NOCPY_TX_CURR_BD_ADDR      (HIF_NOCPY_BASE_ADDR + 0x08)
+#define HIF_NOCPY_TX_ALLOC             (HIF_NOCPY_BASE_ADDR + 0x0c)
+#define HIF_NOCPY_TX_BDP_ADDR          (HIF_NOCPY_BASE_ADDR + 0x10)
+#define HIF_NOCPY_TX_STATUS            (HIF_NOCPY_BASE_ADDR + 0x14)
+#define HIF_NOCPY_RX_CTRL              (HIF_NOCPY_BASE_ADDR + 0x20)
+#define HIF_NOCPY_RX_BDP_ADDR          (HIF_NOCPY_BASE_ADDR + 0x24)
+#define HIF_NOCPY_RX_STATUS            (HIF_NOCPY_BASE_ADDR + 0x30)
+#define HIF_NOCPY_INT_SRC              (HIF_NOCPY_BASE_ADDR + 0x34)
+#define HIF_NOCPY_INT_ENABLE           (HIF_NOCPY_BASE_ADDR + 0x38)
+#define HIF_NOCPY_POLL_CTRL            (HIF_NOCPY_BASE_ADDR + 0x3c)
+#define HIF_NOCPY_RX_CURR_BD_ADDR      (HIF_NOCPY_BASE_ADDR + 0x40)
+#define HIF_NOCPY_RX_ALLOC             (HIF_NOCPY_BASE_ADDR + 0x44)
+#define HIF_NOCPY_TX_DMA_STATUS                (HIF_NOCPY_BASE_ADDR + 0x48)
+#define HIF_NOCPY_RX_DMA_STATUS                (HIF_NOCPY_BASE_ADDR + 0x4c)
+#define HIF_NOCPY_RX_INQ0_PKTPTR       (HIF_NOCPY_BASE_ADDR + 0x50)
+#define HIF_NOCPY_RX_INQ1_PKTPTR       (HIF_NOCPY_BASE_ADDR + 0x54)
+#define HIF_NOCPY_TX_PORT_NO           (HIF_NOCPY_BASE_ADDR + 0x60)
+#define HIF_NOCPY_LMEM_ALLOC_ADDR      (HIF_NOCPY_BASE_ADDR + 0x64)
+#define HIF_NOCPY_CLASS_ADDR           (HIF_NOCPY_BASE_ADDR + 0x68)
+#define HIF_NOCPY_TMU_PORT0_ADDR       (HIF_NOCPY_BASE_ADDR + 0x70)
+#define HIF_NOCPY_TMU_PORT1_ADDR       (HIF_NOCPY_BASE_ADDR + 0x74)
+#define HIF_NOCPY_TMU_PORT2_ADDR       (HIF_NOCPY_BASE_ADDR + 0x7c)
+#define HIF_NOCPY_TMU_PORT3_ADDR       (HIF_NOCPY_BASE_ADDR + 0x80)
+#define HIF_NOCPY_TMU_PORT4_ADDR       (HIF_NOCPY_BASE_ADDR + 0x84)
+#define HIF_NOCPY_INT_COAL             (HIF_NOCPY_BASE_ADDR + 0x90)
+#define HIF_NOCPY_AXI_CTRL             (HIF_NOCPY_BASE_ADDR + 0x94)
+
+#endif /* _HIF_NOCPY_H_ */
include/pfe_eth/pfe/cbus/tmu_csr.h new file +148 -0
new file mode 100644
index 0000000..2fc8dbe
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _TMU_CSR_H_
+#define _TMU_CSR_H_
+
+#define TMU_VERSION                    (TMU_CSR_BASE_ADDR + 0x000)
+#define TMU_INQ_WATERMARK              (TMU_CSR_BASE_ADDR + 0x004)
+#define TMU_PHY_INQ_PKTPTR             (TMU_CSR_BASE_ADDR + 0x008)
+#define TMU_PHY_INQ_PKTINFO            (TMU_CSR_BASE_ADDR + 0x00c)
+#define TMU_PHY_INQ_FIFO_CNT           (TMU_CSR_BASE_ADDR + 0x010)
+#define TMU_SYS_GENERIC_CONTROL                (TMU_CSR_BASE_ADDR + 0x014)
+#define TMU_SYS_GENERIC_STATUS         (TMU_CSR_BASE_ADDR + 0x018)
+#define TMU_SYS_GEN_CON0               (TMU_CSR_BASE_ADDR + 0x01c)
+#define TMU_SYS_GEN_CON1               (TMU_CSR_BASE_ADDR + 0x020)
+#define TMU_SYS_GEN_CON2               (TMU_CSR_BASE_ADDR + 0x024)
+#define TMU_SYS_GEN_CON3               (TMU_CSR_BASE_ADDR + 0x028)
+#define TMU_SYS_GEN_CON4               (TMU_CSR_BASE_ADDR + 0x02c)
+#define TMU_TEQ_DISABLE_DROPCHK                (TMU_CSR_BASE_ADDR + 0x030)
+#define TMU_TEQ_CTRL                   (TMU_CSR_BASE_ADDR + 0x034)
+#define TMU_TEQ_QCFG                   (TMU_CSR_BASE_ADDR + 0x038)
+#define TMU_TEQ_DROP_STAT              (TMU_CSR_BASE_ADDR + 0x03c)
+#define TMU_TEQ_QAVG                   (TMU_CSR_BASE_ADDR + 0x040)
+#define TMU_TEQ_WREG_PROB              (TMU_CSR_BASE_ADDR + 0x044)
+#define TMU_TEQ_TRANS_STAT             (TMU_CSR_BASE_ADDR + 0x048)
+#define TMU_TEQ_HW_PROB_CFG0           (TMU_CSR_BASE_ADDR + 0x04c)
+#define TMU_TEQ_HW_PROB_CFG1           (TMU_CSR_BASE_ADDR + 0x050)
+#define TMU_TEQ_HW_PROB_CFG2           (TMU_CSR_BASE_ADDR + 0x054)
+#define TMU_TEQ_HW_PROB_CFG3           (TMU_CSR_BASE_ADDR + 0x058)
+#define TMU_TEQ_HW_PROB_CFG4           (TMU_CSR_BASE_ADDR + 0x05c)
+#define TMU_TEQ_HW_PROB_CFG5           (TMU_CSR_BASE_ADDR + 0x060)
+#define TMU_TEQ_HW_PROB_CFG6           (TMU_CSR_BASE_ADDR + 0x064)
+#define TMU_TEQ_HW_PROB_CFG7           (TMU_CSR_BASE_ADDR + 0x068)
+#define TMU_TEQ_HW_PROB_CFG8           (TMU_CSR_BASE_ADDR + 0x06c)
+#define TMU_TEQ_HW_PROB_CFG9           (TMU_CSR_BASE_ADDR + 0x070)
+#define TMU_TEQ_HW_PROB_CFG10          (TMU_CSR_BASE_ADDR + 0x074)
+#define TMU_TEQ_HW_PROB_CFG11          (TMU_CSR_BASE_ADDR + 0x078)
+#define TMU_TEQ_HW_PROB_CFG12          (TMU_CSR_BASE_ADDR + 0x07c)
+#define TMU_TEQ_HW_PROB_CFG13          (TMU_CSR_BASE_ADDR + 0x080)
+#define TMU_TEQ_HW_PROB_CFG14          (TMU_CSR_BASE_ADDR + 0x084)
+#define TMU_TEQ_HW_PROB_CFG15          (TMU_CSR_BASE_ADDR + 0x088)
+#define TMU_TEQ_HW_PROB_CFG16          (TMU_CSR_BASE_ADDR + 0x08c)
+#define TMU_TEQ_HW_PROB_CFG17          (TMU_CSR_BASE_ADDR + 0x090)
+#define TMU_TEQ_HW_PROB_CFG18          (TMU_CSR_BASE_ADDR + 0x094)
+#define TMU_TEQ_HW_PROB_CFG19          (TMU_CSR_BASE_ADDR + 0x098)
+#define TMU_TEQ_HW_PROB_CFG20          (TMU_CSR_BASE_ADDR + 0x09c)
+#define TMU_TEQ_HW_PROB_CFG21          (TMU_CSR_BASE_ADDR + 0x0a0)
+#define TMU_TEQ_HW_PROB_CFG22          (TMU_CSR_BASE_ADDR + 0x0a4)
+#define TMU_TEQ_HW_PROB_CFG23          (TMU_CSR_BASE_ADDR + 0x0a8)
+#define TMU_TEQ_HW_PROB_CFG24          (TMU_CSR_BASE_ADDR + 0x0ac)
+#define TMU_TEQ_HW_PROB_CFG25          (TMU_CSR_BASE_ADDR + 0x0b0)
+#define TMU_TDQ_IIFG_CFG               (TMU_CSR_BASE_ADDR + 0x0b4)
+/* [9:0] Scheduler Enable for each of the scheduler in the TDQ.
+ * This is a global Enable for all schedulers in PHY0
+ */
+#define TMU_TDQ0_SCH_CTRL              (TMU_CSR_BASE_ADDR + 0x0b8)
+#define TMU_LLM_CTRL                   (TMU_CSR_BASE_ADDR + 0x0bc)
+#define TMU_LLM_BASE_ADDR              (TMU_CSR_BASE_ADDR + 0x0c0)
+#define TMU_LLM_QUE_LEN                        (TMU_CSR_BASE_ADDR + 0x0c4)
+#define TMU_LLM_QUE_HEADPTR            (TMU_CSR_BASE_ADDR + 0x0c8)
+#define TMU_LLM_QUE_TAILPTR            (TMU_CSR_BASE_ADDR + 0x0cc)
+#define TMU_LLM_QUE_DROPCNT            (TMU_CSR_BASE_ADDR + 0x0d0)
+#define TMU_INT_EN                     (TMU_CSR_BASE_ADDR + 0x0d4)
+#define TMU_INT_SRC                    (TMU_CSR_BASE_ADDR + 0x0d8)
+#define TMU_INQ_STAT                   (TMU_CSR_BASE_ADDR + 0x0dc)
+#define TMU_CTRL                       (TMU_CSR_BASE_ADDR + 0x0e0)
+
+/* [31] Mem Access Command. 0 = Internal Memory Read, 1 = Internal
+ * memory Write [27:24] Byte Enables of the Internal memory access [23:0]
+ * Address of the internal memory. This address is used to access both the
+ * PM and DM of all the PE's
+ */
+#define TMU_MEM_ACCESS_ADDR            (TMU_CSR_BASE_ADDR + 0x0e4)
+
+/* Internal Memory Access Write Data */
+#define TMU_MEM_ACCESS_WDATA           (TMU_CSR_BASE_ADDR + 0x0e8)
+/* Internal Memory Access Read Data. The commands are blocked at the
+ * mem_access only
+ */
+#define TMU_MEM_ACCESS_RDATA           (TMU_CSR_BASE_ADDR + 0x0ec)
+
+/* [31:0] PHY0 in queue address (must be initialized with one of the
+ * xxx_INQ_PKTPTR cbus addresses)
+ */
+#define TMU_PHY0_INQ_ADDR              (TMU_CSR_BASE_ADDR + 0x0f0)
+/* [31:0] PHY1 in queue address (must be initialized with one of the
+ * xxx_INQ_PKTPTR cbus addresses)
+ */
+#define TMU_PHY1_INQ_ADDR              (TMU_CSR_BASE_ADDR + 0x0f4)
+/* [31:0] PHY3 in queue address (must be initialized with one of the
+ * xxx_INQ_PKTPTR cbus addresses)
+ */
+#define TMU_PHY3_INQ_ADDR              (TMU_CSR_BASE_ADDR + 0x0fc)
+#define TMU_BMU_INQ_ADDR               (TMU_CSR_BASE_ADDR + 0x100)
+#define TMU_TX_CTRL                    (TMU_CSR_BASE_ADDR + 0x104)
+
+#define TMU_PE_SYS_CLK_RATIO           (TMU_CSR_BASE_ADDR + 0x114)
+#define TMU_PE_STATUS                  (TMU_CSR_BASE_ADDR + 0x118)
+#define TMU_TEQ_MAX_THRESHOLD          (TMU_CSR_BASE_ADDR + 0x11c)
+
+/* [31:0] PHY4 in queue address (must be initialized with one of the
+ * xxx_INQ_PKTPTR cbus addresses)
+ */
+#define TMU_PHY4_INQ_ADDR              (TMU_CSR_BASE_ADDR + 0x134)
+
+/* [9:0] Scheduler Enable for each of the scheduler in the TDQ. This
+ * is a global Enable for all schedulers in PHY1
+ */
+#define TMU_TDQ1_SCH_CTRL              (TMU_CSR_BASE_ADDR + 0x138)
+/* [9:0] Scheduler Enable for each of the scheduler in the TDQ. This
+ * is a global Enable for all schedulers in PHY3
+ */
+#define TMU_TDQ3_SCH_CTRL              (TMU_CSR_BASE_ADDR + 0x140)
+
+#define TMU_BMU_BUF_SIZE               (TMU_CSR_BASE_ADDR + 0x144)
+/* [31:0] PHY5 in queue address (must be initialized with one of the
+ * xxx_INQ_PKTPTR cbus addresses)
+ */
+#define TMU_PHY5_INQ_ADDR              (TMU_CSR_BASE_ADDR + 0x148)
+
+#define TMU_AXI_CTRL                   (TMU_CSR_BASE_ADDR + 0x17c)
+
+#define SW_RESET               (1 << 0) /* Global software reset */
+#define INQ_RESET              (1 << 2)
+#define TEQ_RESET              (1 << 3)
+#define TDQ_RESET              (1 << 4)
+#define PE_RESET               (1 << 5)
+#define MEM_INIT               (1 << 6)
+#define MEM_INIT_DONE          (1 << 7)
+#define LLM_INIT               (1 << 8)
+#define LLM_INIT_DONE          (1 << 9)
+#define ECC_MEM_INIT_DONE      (1<<10)
+
+struct tmu_cfg {
+       u32 llm_base_addr;
+       u32 llm_queue_len;
+};
+
+/* Not HW related for pfe_ctrl/pfe common defines */
+#define DEFAULT_MAX_QDEPTH     80
+#define DEFAULT_Q0_QDEPTH      511 /* We keep 1 large queue for host tx qos */
+#define DEFAULT_TMU3_QDEPTH    127
+
+#endif /* _TMU_CSR_H_ */
include/pfe_eth/pfe/cbus/util_csr.h new file +47 -0
new file mode 100644
index 0000000..bac4114
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _UTIL_CSR_H_
+#define _UTIL_CSR_H_
+
+#define UTIL_VERSION                   (UTIL_CSR_BASE_ADDR + 0x000)
+#define UTIL_TX_CTRL                   (UTIL_CSR_BASE_ADDR + 0x004)
+#define UTIL_INQ_PKTPTR                        (UTIL_CSR_BASE_ADDR + 0x010)
+
+#define UTIL_HDR_SIZE                  (UTIL_CSR_BASE_ADDR + 0x014)
+
+#define UTIL_PE0_QB_DM_ADDR0           (UTIL_CSR_BASE_ADDR + 0x020)
+#define UTIL_PE0_QB_DM_ADDR1           (UTIL_CSR_BASE_ADDR + 0x024)
+#define UTIL_PE0_RO_DM_ADDR0           (UTIL_CSR_BASE_ADDR + 0x060)
+#define UTIL_PE0_RO_DM_ADDR1           (UTIL_CSR_BASE_ADDR + 0x064)
+
+#define UTIL_MEM_ACCESS_ADDR           (UTIL_CSR_BASE_ADDR + 0x100)
+#define UTIL_MEM_ACCESS_WDATA          (UTIL_CSR_BASE_ADDR + 0x104)
+#define UTIL_MEM_ACCESS_RDATA          (UTIL_CSR_BASE_ADDR + 0x108)
+
+#define UTIL_TM_INQ_ADDR               (UTIL_CSR_BASE_ADDR + 0x114)
+#define UTIL_PE_STATUS                 (UTIL_CSR_BASE_ADDR + 0x118)
+
+#define UTIL_PE_SYS_CLK_RATIO          (UTIL_CSR_BASE_ADDR + 0x200)
+#define UTIL_AFULL_THRES               (UTIL_CSR_BASE_ADDR + 0x204)
+#define UTIL_GAP_BETWEEN_READS         (UTIL_CSR_BASE_ADDR + 0x208)
+#define UTIL_MAX_BUF_CNT               (UTIL_CSR_BASE_ADDR + 0x20c)
+#define UTIL_TSQ_FIFO_THRES            (UTIL_CSR_BASE_ADDR + 0x210)
+#define UTIL_TSQ_MAX_CNT               (UTIL_CSR_BASE_ADDR + 0x214)
+#define UTIL_IRAM_DATA_0               (UTIL_CSR_BASE_ADDR + 0x218)
+#define UTIL_IRAM_DATA_1               (UTIL_CSR_BASE_ADDR + 0x21c)
+#define UTIL_IRAM_DATA_2               (UTIL_CSR_BASE_ADDR + 0x220)
+#define UTIL_IRAM_DATA_3               (UTIL_CSR_BASE_ADDR + 0x224)
+
+#define UTIL_BUS_ACCESS_ADDR           (UTIL_CSR_BASE_ADDR + 0x228)
+#define UTIL_BUS_ACCESS_WDATA          (UTIL_CSR_BASE_ADDR + 0x22c)
+#define UTIL_BUS_ACCESS_RDATA          (UTIL_CSR_BASE_ADDR + 0x230)
+
+#define UTIL_INQ_AFULL_THRES           (UTIL_CSR_BASE_ADDR + 0x234)
+#define UTIL_AXI_CTRL                  (UTIL_CSR_BASE_ADDR + 0x240)
+
+#endif /* _UTIL_CSR_H_ */
include/pfe_eth/pfe/pfe.h new file +178 -0
new file mode 100644
index 0000000..1c73a95
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _PFE_H_
+#define _PFE_H_
+
+#include <elf.h>
+#include "cbus.h"
+
+#define PFE_LS1012A_RESET_WA
+#define CONFIG_UTIL_PE_DISABLED
+
+#define CLASS_DMEM_BASE_ADDR(i)        (0x00000000 | ((i) << 20))
+/* Only valid for mem access register interface */
+#define CLASS_IMEM_BASE_ADDR(i)        (0x00000000 | ((i) << 20))
+#define CLASS_DMEM_SIZE                0x00002000
+#define CLASS_IMEM_SIZE                0x00008000
+
+#define TMU_DMEM_BASE_ADDR(i)  (0x00000000 + ((i) << 20))
+/* Only valid for mem access register interface */
+#define TMU_IMEM_BASE_ADDR(i)  (0x00000000 + ((i) << 20))
+#define TMU_DMEM_SIZE          0x00000800
+#define TMU_IMEM_SIZE          0x00002000
+
+#define UTIL_DMEM_BASE_ADDR    0x00000000
+#define UTIL_DMEM_SIZE         0x00002000
+
+#define PE_LMEM_BASE_ADDR      0xc3010000
+#define PE_LMEM_SIZE           0x8000
+#define PE_LMEM_END            (PE_LMEM_BASE_ADDR + PE_LMEM_SIZE)
+
+#define DMEM_BASE_ADDR         0x00000000
+#define DMEM_SIZE              0x2000          /* TMU has less... */
+#define DMEM_END               (DMEM_BASE_ADDR + DMEM_SIZE)
+
+#define PMEM_BASE_ADDR         0x00010000
+#define PMEM_SIZE              0x8000          /* TMU has less... */
+#define PMEM_END               (PMEM_BASE_ADDR + PMEM_SIZE)
+
+/* Memory ranges check from PE point of view/memory map */
+#define IS_DMEM(addr, len)     (((unsigned long)(addr) >= DMEM_BASE_ADDR) &&\
+                                       (((unsigned long)(addr) +\
+                                       (len)) <= DMEM_END))
+#define IS_PMEM(addr, len)     (((unsigned long)(addr) >= PMEM_BASE_ADDR) &&\
+                                       (((unsigned long)(addr) +\
+                                       (len)) <= PMEM_END))
+#define IS_PE_LMEM(addr, len)  (((unsigned long)(addr) >= PE_LMEM_BASE_ADDR\
+                                       ) && (((unsigned long)(addr)\
+                                       + (len)) <= PE_LMEM_END))
+
+#define IS_PFE_LMEM(addr, len) (((unsigned long)(addr) >=\
+                                       CBUS_VIRT_TO_PFE(LMEM_BASE_ADDR)) &&\
+                                       (((unsigned long)(addr) + (len)) <=\
+                                       CBUS_VIRT_TO_PFE(LMEM_END)))
+#define IS_PHYS_DDR(addr, len) (((unsigned long)(addr) >=\
+                                       PFE_DDR_PHYS_BASE_ADDR) &&\
+                                       (((unsigned long)(addr) + (len)) <=\
+                                       PFE_DDR_PHYS_END))
+
+/* Host View Address */
+extern void *ddr_base_addr;
+
+#define DDR_BASE_ADDR          ddr_base_addr
+
+/* PFE View Address */
+/* DDR physical base address as seen by PE's. */
+#define PFE_DDR_PHYS_BASE_ADDR 0x03800000
+#define PFE_DDR_PHYS_SIZE      0xC000000
+#define PFE_DDR_PHYS_END       (PFE_DDR_PHYS_BASE_ADDR + PFE_DDR_PHYS_SIZE)
+/* CBUS physical base address as seen by PE's. */
+#define PFE_CBUS_PHYS_BASE_ADDR        0xc0000000
+
+/* Host<->PFE Mapping */
+#define DDR_PFE_TO_VIRT(p)     ((unsigned long int)((p) + 0x80000000))
+#define CBUS_VIRT_TO_PFE(v)    (((v) - CBUS_BASE_ADDR) +\
+                                       PFE_CBUS_PHYS_BASE_ADDR)
+#define CBUS_PFE_TO_VIRT(p)    (((p) - PFE_CBUS_PHYS_BASE_ADDR) +\
+                                       CBUS_BASE_ADDR)
+
+enum {
+       CLASS0_ID = 0,
+       CLASS1_ID,
+       CLASS2_ID,
+       CLASS3_ID,
+       CLASS4_ID,
+       CLASS5_ID,
+
+       TMU0_ID,
+       TMU1_ID,
+       TMU2_ID,
+       TMU3_ID,
+#if !defined(CONFIG_UTIL_PE_DISABLED)
+       UTIL_ID,
+#endif
+       MAX_PE
+};
+
+#define CLASS_MASK     ((1 << CLASS0_ID) | (1 << CLASS1_ID) | (1 << CLASS2_ID)\
+                               | (1 << CLASS3_ID) | (1 << CLASS4_ID) |\
+                               (1 << CLASS5_ID))
+#define CLASS_MAX_ID   CLASS5_ID
+
+#define TMU_MASK       ((1 << TMU0_ID) | (1 << TMU1_ID) | (1 << TMU3_ID))
+#define TMU_MAX_ID     TMU3_ID
+
+#if !defined(CONFIG_UTIL_PE_DISABLED)
+#define UTIL_MASK      (1 << UTIL_ID)
+#endif
+
+/*
+ * PE information.
+ * Structure containing PE's specific information. It is used to create
+ * generic C functions common to all PE's.
+ * Before using the library functions this structure needs to be
+ * initialized with the different registers virtual addresses
+ * (according to the ARM MMU mmaping). The default initialization supports a
+ * virtual == physical mapping.
+ *
+ */
+struct pe_info {
+       u32 dmem_base_addr;             /* PE's dmem base address */
+       u32 pmem_base_addr;             /* PE's pmem base address */
+       u32 pmem_size;                  /* PE's pmem size */
+
+       void *mem_access_wdata;        /* PE's _MEM_ACCESS_WDATA
+                                       * register address
+                                       */
+       void *mem_access_addr;         /* PE's _MEM_ACCESS_ADDR
+                                       * register address
+                                       */
+       void *mem_access_rdata;        /* PE's _MEM_ACCESS_RDATA
+                                       * register address
+                                       */
+};
+
+void pe_lmem_read(u32 *dst, u32 len, u32 offset);
+void pe_lmem_write(u32 *src, u32 len, u32 offset);
+
+void pe_dmem_memcpy_to32(int id, u32 dst, const void *src, unsigned int len);
+void pe_pmem_memcpy_to32(int id, u32 dst, const void *src, unsigned int len);
+
+u32 pe_pmem_read(int id, u32 addr, u8 size);
+void pe_dmem_write(int id, u32 val, u32 addr, u8 size);
+u32 pe_dmem_read(int id, u32 addr, u8 size);
+void class_bus_write(u32 val, u32 addr, u8 size);
+u32 class_bus_read(u32 addr, u8 size);
+
+int pe_load_elf_section(int id, const void *data, Elf32_Shdr *shdr);
+
+void pfe_lib_init(void *ddr_base, unsigned long ddr_phys_base);
+
+void bmu_init(void *base, struct bmu_cfg *cfg);
+void bmu_enable(void *base);
+
+void gpi_init(void *base, struct gpi_cfg *cfg);
+void gpi_enable(void *base);
+void gpi_disable(void *base);
+
+void class_init(struct class_cfg *cfg);
+void class_enable(void);
+void class_disable(void);
+
+void tmu_init(struct tmu_cfg *cfg);
+void tmu_enable(u32 pe_mask);
+void tmu_disable(u32 pe_mask);
+
+void hif_init(void);
+void hif_tx_enable(void);
+void hif_tx_disable(void);
+void hif_rx_enable(void);
+void hif_rx_disable(void);
+void hif_rx_desc_disable(void);
+
+#endif /* _PFE_H_ */
include/pfe_eth/pfe_driver.h new file +55 -0
new file mode 100644
index 0000000..28997b4
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __PFE_DRIVER_H__
+#define __PFE_DRIVER_H__
+
+#include "pfe/pfe.h"
+
+#define HIF_RX_DESC_NT         64
+#define        HIF_TX_DESC_NT          64
+
+#define RX_BD_BASEADDR         (HIF_DESC_BASEADDR)
+#define TX_BD_BASEADDR         (HIF_DESC_BASEADDR + HIF_TX_DESC_SIZE)
+
+#define MIN_PKT_SIZE           56
+#define MAX_FRAME_SIZE         2048
+
+struct __packed hif_header_s {
+       u8      port_no; /* Carries input port no for host rx packets and
+                         * output port no for tx pkts
+                         */
+       u8 reserved0;
+       u32 reserved2;
+};
+
+struct __packed buf_desc {
+       u32 ctrl;
+       u32 status;
+       u32 data;
+       u32 next;
+};
+
+struct rx_desc_s {
+       struct buf_desc *rx_base;
+       unsigned int rx_base_pa;
+       int rx_to_read;
+       int rx_ring_size;
+};
+
+struct tx_desc_s {
+       struct buf_desc *tx_base;
+       unsigned int tx_base_pa;
+       int tx_to_send;
+       int tx_ring_size;
+};
+
+int pfe_send(int phy_port, void *data, int length);
+int pfe_recv(unsigned int *pkt_ptr, int *phy_port);
+int pfe_tx_done(void);
+
+#endif
include/pfe_eth/pfe_eth.h new file +111 -0
new file mode 100644
index 0000000..8b4bc67
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _LS1012a_ETH_H_
+#define _LS1012a_ETH_H_
+
+#include <linux/sizes.h>
+#include <asm/io.h>
+#include <miiphy.h>
+#include <malloc.h>
+#include "pfe_driver.h"
+
+#define BMU2_DDR_BASEADDR      0
+#define BMU2_BUF_COUNT         (3 * SZ_1K)
+#define BMU2_DDR_SIZE          (DDR_BUF_SIZE * BMU2_BUF_COUNT)
+
+#define HIF_RX_PKT_DDR_BASEADDR (BMU2_DDR_BASEADDR + BMU2_DDR_SIZE)
+#define HIF_RX_PKT_DDR_SIZE     (HIF_RX_DESC_NT * DDR_BUF_SIZE)
+#define HIF_TX_PKT_DDR_BASEADDR (HIF_RX_PKT_DDR_BASEADDR + HIF_RX_PKT_DDR_SIZE)
+#define HIF_TX_PKT_DDR_SIZE     (HIF_TX_DESC_NT * DDR_BUF_SIZE)
+
+#define HIF_DESC_BASEADDR       (HIF_TX_PKT_DDR_BASEADDR + HIF_TX_PKT_DDR_SIZE)
+#define HIF_RX_DESC_SIZE        (16 * HIF_RX_DESC_NT)
+#define HIF_TX_DESC_SIZE        (16 * HIF_TX_DESC_NT)
+
+#define UTIL_CODE_BASEADDR     0x780000
+#define UTIL_CODE_SIZE         (128 * SZ_1K)
+
+#define UTIL_DDR_DATA_BASEADDR (UTIL_CODE_BASEADDR + UTIL_CODE_SIZE)
+#define UTIL_DDR_DATA_SIZE     (64 * SZ_1K)
+
+#define CLASS_DDR_DATA_BASEADDR        (UTIL_DDR_DATA_BASEADDR + UTIL_DDR_DATA_SIZE)
+#define CLASS_DDR_DATA_SIZE    (32 * SZ_1K)
+
+#define TMU_DDR_DATA_BASEADDR  (CLASS_DDR_DATA_BASEADDR + CLASS_DDR_DATA_SIZE)
+#define TMU_DDR_DATA_SIZE      (32 * SZ_1K)
+
+#define TMU_LLM_BASEADDR       (TMU_DDR_DATA_BASEADDR + TMU_DDR_DATA_SIZE)
+#define TMU_LLM_QUEUE_LEN      (16 * 256)
+       /* Must be power of two and at least 16 * 8 = 128 bytes */
+#define TMU_LLM_SIZE           (4 * 16 * TMU_LLM_QUEUE_LEN)
+       /* (4 TMU's x 16 queues x queue_len) */
+
+#define ROUTE_TABLE_BASEADDR   0x800000
+#define ROUTE_TABLE_HASH_BITS_MAX      15 /* 32K entries */
+#define ROUTE_TABLE_HASH_BITS          8  /* 256 entries */
+#define ROUTE_TABLE_SIZE       ((1 << ROUTE_TABLE_HASH_BITS_MAX) \
+                               * CLASS_ROUTE_SIZE)
+
+#define        PFE_TOTAL_DATA_SIZE     (ROUTE_TABLE_BASEADDR + ROUTE_TABLE_SIZE)
+
+#if PFE_TOTAL_DATA_SIZE > (12 * SZ_1M)
+#error DDR mapping above 12MiB
+#endif
+
+/* LMEM Mapping */
+#define BMU1_LMEM_BASEADDR     0
+#define BMU1_BUF_COUNT         256
+#define BMU1_LMEM_SIZE         (LMEM_BUF_SIZE * BMU1_BUF_COUNT)
+
+struct gemac_s {
+       void *gemac_base;
+       void *egpi_base;
+
+       /* GEMAC config */
+       int gemac_mode;
+       int gemac_speed;
+       int gemac_duplex;
+       int flags;
+       /* phy iface */
+       int phy_address;
+       int phy_mode;
+       struct mii_dev *bus;
+
+};
+
+struct mdio_info {
+       void *reg_base;
+       char *name;
+};
+
+struct pfe {
+       unsigned long ddr_phys_baseaddr;
+       void *ddr_baseaddr;
+       void *cbus_baseaddr;
+};
+
+struct ls1012a_eth_dev {
+       int gemac_port;
+
+       struct gemac_s *gem;
+       struct pfe      pfe;
+
+       struct eth_device *dev;
+#ifdef CONFIG_PHYLIB
+       struct phy_device *phydev;
+#endif
+};
+
+int pfe_probe(struct pfe *pfe);
+int pfe_remove(struct pfe *pfe);
+struct mii_dev *ls1012a_mdio_init(struct mdio_info *mdio_info);
+void ls1012a_set_mdio(int dev_id, struct mii_dev *bus);
+void ls1012a_set_phy_address_mode(int dev_id, int phy_id, int phy_mode);
+int gemac_initialize(bd_t *bis, int dev_id, char *devname);
+
+#endif /*_LS1012a_ETH_H_ */
include/pfe_eth/pfe_firmware.h new file +17 -1
new file mode 100644
index 0000000..588b2ae
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/** @file
+ *  Contains all the defines to handle parsing and loading of PE firmware files.
+ */
+#ifndef __PFE_FIRMWARE_H__
+#define __PFE_FIRMWARE_H__
+
+int pfe_firmware_init(void);
+void pfe_firmware_exit(void);
+
+#endif
--

2.7.4

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#9 lore raw

PATCH 4/9 board: freescale: ls1012a: enable network support on ls1012a platforms

In reply to Calvin Johnson

Ethernet support on all three LS1012A platforms(FRDM, QDS and RDB) is enabled with this patch.

eth.c files for all 3 platforms contain board ethernet initialization function and also function to reset phy.

---
 board/freescale/ls1012afrdm/Makefile          |   1 +
 board/freescale/ls1012afrdm/eth.c             |  86 +++++++++
 board/freescale/ls1012afrdm/ls1012afrdm.c     |   5 -
 board/freescale/ls1012aqds/Makefile           |   1 +
 board/freescale/ls1012aqds/eth.c              | 263 ++++++++++++++++++++++++++
 board/freescale/ls1012aqds/ls1012aqds.c       |  97 +++++++++-
 board/freescale/ls1012aqds/ls1012aqds_pfe.h   |  48 +++++
 board/freescale/ls1012aqds/ls1012aqds_qixis.h |   2 +-
 board/freescale/ls1012ardb/Makefile           |   1 +
 board/freescale/ls1012ardb/eth.c              |  70 +++++++
 board/freescale/ls1012ardb/ls1012ardb.c       |   4 -
 include/configs/ls1012ardb.h                  |   5 +
 12 files changed, 568 insertions(+), 15 deletions(-)
 create mode 100644 board/freescale/ls1012afrdm/eth.c
 create mode 100644 board/freescale/ls1012aqds/eth.c
 create mode 100644 board/freescale/ls1012aqds/ls1012aqds_pfe.h
 create mode 100644 board/freescale/ls1012ardb/eth.c
board/freescale/ls1012afrdm/Makefile +1 -0
index dbfa2ce..1364f22 100644
@@ -5,3 +5,4 @@
 #
 
 obj-y += ls1012afrdm.o
+obj-y += eth.o
board/freescale/ls1012afrdm/eth.c new file +86 -0

86 lines not on this page · raw message

board/freescale/ls1012afrdm/ls1012afrdm.c +0 -5
index 9afd1c4..0145886 100644
@@ -57,11 +57,6 @@ int dram_init(void)
 	return 0;
 }
 
-int board_eth_init(bd_t *bis)
-{
-	return pci_eth_init(bis);
-}
-
 int board_early_init_f(void)
 {
 	fsl_lsch2_early_init_f();
board/freescale/ls1012aqds/Makefile +1 -0
index 0b813f9..b18494a 100644
@@ -5,3 +5,4 @@
 #
 
 obj-y += ls1012aqds.o
+obj-y += eth.o
board/freescale/ls1012aqds/eth.c new file +263 -0

263 lines not on this page · raw message

board/freescale/ls1012aqds/ls1012aqds.c +92 -5

121 lines not on this page · raw message

board/freescale/ls1012aqds/ls1012aqds_pfe.h new file +48 -0

48 lines not on this page · raw message

board/freescale/ls1012aqds/ls1012aqds_qixis.h +1 -1
index 584f604..7a1ba3d 100644
@@ -11,7 +11,7 @@
 
 /* BRDCFG4[4:7] select EC1 and EC2 as a pair */
 #define BRDCFG4_EMISEL_MASK		0xe0
-#define BRDCFG4_EMISEL_SHIFT		5
+#define BRDCFG4_EMISEL_SHIFT		6
 
 /* SYSCLK */
 #define QIXIS_SYSCLK_66			0x0
board/freescale/ls1012ardb/Makefile +1 -0
index 05fa9d9..bd80ce5 100644
@@ -5,3 +5,4 @@
 #
 
 obj-y += ls1012ardb.o
+obj-y += eth.o
board/freescale/ls1012ardb/eth.c new file +70 -0

70 lines not on this page · raw message

board/freescale/ls1012ardb/ls1012ardb.c +0 -4
index c6c1c71..41283db 100644
@@ -90,10 +90,6 @@ int dram_init(void)
 	return 0;
 }
 
-int board_eth_init(bd_t *bis)
-{
-	return pci_eth_init(bis);
-}
 
 int board_early_init_f(void)
 {
include/configs/ls1012ardb.h +5 -0
index 5fe3218..e47bb7c 100644
@@ -42,6 +42,11 @@
 #define __SW_REV_A		0xF8
 #define __SW_REV_B		0xF0
 
+#define I2C_MUX_IO2_ADDR		0x25
+#define __PHY_MASK			0xF9
+#define __PHY_ETH2_MASK		0xFB
+#define __PHY_ETH1_MASK		0xFD
+
 /*  MMC  */
 #ifdef CONFIG_MMC
 #define CONFIG_FSL_ESDHC
Signature · 1 line
2.7.4
#10 lore raw

PATCH 4/9 board: freescale: ls1012a: enable network support on ls1012a platforms

Quoted 18 lines · Calvin Johnson

Ethernet support on all three LS1012A platforms(FRDM, QDS and RDB) is enabled with this patch.

eth.c files for all 3 platforms contain board ethernet initialization function and also function to reset phy.

---
 board/freescale/ls1012afrdm/Makefile          |   1 +
 board/freescale/ls1012afrdm/eth.c             |  86 +++++++++
 board/freescale/ls1012afrdm/ls1012afrdm.c     |   5 -
 board/freescale/ls1012aqds/Makefile           |   1 +
 board/freescale/ls1012aqds/eth.c              | 263 ++++++++++++++++++++++++++
 board/freescale/ls1012aqds/ls1012aqds.c       |  97 +++++++++-
 board/freescale/ls1012aqds/ls1012aqds_pfe.h   |  48 +++++
 board/freescale/ls1012aqds/ls1012aqds_qixis.h |   2 +-
 board/freescale/ls1012ardb/Makefile           |   1 +
Quoted 8 lines
 board/freescale/ls1012ardb/eth.c              |  70 +++++++
 board/freescale/ls1012ardb/ls1012ardb.c       |   4 -
 include/configs/ls1012ardb.h                  |   5 +
 12 files changed, 568 insertions(+), 15 deletions(-)
 create mode 100644 board/freescale/ls1012afrdm/eth.c
 create mode 100644 board/freescale/ls1012aqds/eth.c
 create mode 100644 board/freescale/ls1012aqds/ls1012aqds_pfe.h
 create mode 100644 board/freescale/ls1012ardb/eth.c

It seems reasonable to add support for each platform in individual patches.

-Joe

#11 lore raw

PATCH 5/9 armv8: fsl-lsch2: initialize pfe gemac

In reply to Calvin Johnson

Call gemac_initialize to initialize both gemacs of pfe.

---
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +8 -0
index ef3e300..25cd8d7 100644
@@ -21,6 +21,9 @@
 #include <efi_loader.h>
 #include <fm_eth.h>
 #include <fsl-mc/fsl_mc.h>
+#ifdef CONFIG_FSL_PFE
+#include <pfe_eth/pfe_eth.h>
+#endif
 #ifdef CONFIG_FSL_ESDHC
 #include <fsl_esdhc.h>
 #endif
@@ -476,6 +479,11 @@ int cpu_eth_init(bd_t *bis)
 {
 	int error = 0;
 
+#if defined(CONFIG_FSL_PFE)
+	gemac_initialize(bis, 0 , "pfe_eth0");
+	gemac_initialize(bis, 1 , "pfe_eth1");
+#endif
+
 #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
 	error = fsl_mc_ldpaa_init(bis);
 #endif
Signature · 1 line
2.7.4
#12 lore raw

PATCH 6/9 armv8: fsl-lsch2: add pfe macros and update ccsr_scfg structure

In reply to Calvin Johnson

SoC specific PFE macros are defined and structure ccsr_scfg is updated with members defined for PFE.

---
 .../include/asm/arch-fsl-layerscape/immap_lsch2.h  | 38 ++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h +36 -2
index 0f43832..a395a2f 100644
@@ -398,6 +398,21 @@ struct ccsr_gur {
 #define SCFG_SNPCNFGCR_SATARDSNP	0x00800000
 #define SCFG_SNPCNFGCR_SATAWRSNP	0x00400000
 
+/* RGMIIPCR bit definitions*/
+#define SCFG_RGMIIPCR_EN_AUTO		(0x00000008)
+#define SCFG_RGMIIPCR_SETSP_1000M	(0x00000004)
+#define SCFG_RGMIIPCR_SETSP_100M	(0x00000000)
+#define SCFG_RGMIIPCR_SETSP_10M		(0x00000002)
+#define SCFG_RGMIIPCR_SETFD		(0x00000001)
+
+/*PFEASBCR bit definitions */
+#define SCFG_PFEASBCR_ARCACHE0		(0x80000000)
+#define SCFG_PFEASBCR_AWCACHE0		(0x40000000)
+#define SCFG_PFEASBCR_ARCACHE1		(0x20000000)
+#define SCFG_PFEASBCR_AWCACHE1		(0x10000000)
+#define SCFG_PFEASBCR_ARSNP		(0x08000000)
+#define SCFG_PFEASBCR_AWSNP		(0x04000000)
+
 /* Supplemental Configuration Unit */
 struct ccsr_scfg {
 	u8 res_000[0x100-0x000];
@@ -415,7 +430,12 @@ struct ccsr_scfg {
 	u8 res_140[0x158-0x140];
 	u32 altcbar;
 	u32 qspi_cfg;
-	u8 res_160[0x180-0x160];
+	u8 res_160[0x164-0x160];
+	u32 wr_qos1;
+	u32 wr_qos2;
+	u32 rd_qos1;
+	u32 rd_qos2;
+	u8 res_174[0x180-0x174];
 	u32 dmamcr;
 	u8 res_184[0x188-0x184];
 	u32 gic_align;
@@ -446,7 +466,21 @@ struct ccsr_scfg {
 	u32 usb_refclk_selcr1;
 	u32 usb_refclk_selcr2;
 	u32 usb_refclk_selcr3;
-	u8 res_424[0x600-0x424];
+	u8 res_424[0x434-0x424];
+	u32 rgmiipcr;
+	u32 res_438;
+	u32 rgmiipsr;
+	u32 pfepfcssr1;
+	u32 pfeintencr1;
+	u32 pfepfcssr2;
+	u32 pfeintencr2;
+	u32 pfeerrcr;
+	u32 pfeeerrintencr;
+	u32 pfeasbcr;
+	u32 pfebsbcr;
+	u8 res_460[0x484-0x460];
+	u32 mdioselcr;
+	u8 res_468[0x600-0x488];
 	u32 scratchrw[4];
 	u8 res_610[0x680-0x610];
 	u32 corebcr;
Signature · 1 line
2.7.4
#13 lore raw

PATCH 7/9 armv8: fsl-lsch2: configure pfe's scfg & dcfg registers

In reply to Calvin Johnson

Define init_pfe_scfg_dcfg_regs to configure scfg and dcfg registers of pfe.

---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c        | 18 ++++++++++++++++++
 arch/arm/include/asm/arch-fsl-layerscape/soc.h |  3 +++
 2 files changed, 21 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/soc.c +18 -0
index 5c429d4..c6815f3 100644
@@ -577,6 +577,24 @@ int setup_chip_volt(void)
 	return 0;
 }
 
+#ifdef CONFIG_FSL_PFE
+void init_pfe_scfg_dcfg_regs(void)
+{
+	struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
+
+	out_be32(&scfg->pfeasbcr,
+		 in_be32(&scfg->pfeasbcr) | SCFG_PFEASBCR_AWCACHE0);
+	out_be32(&scfg->pfebsbcr,
+		 in_be32(&scfg->pfebsbcr) | SCFG_PFEASBCR_AWCACHE0);
+
+	/* CCI-400 QoS settings for PFE */
+	out_be32(&scfg->wr_qos1, 0x0ff00000);
+	out_be32(&scfg->rd_qos1, 0x0ff00000);
+
+	out_be32((void *)CONFIG_SYS_DCSR_DCFG_ADDR + 0x524, 0x2000);
+}
+#endif
+
 void fsl_lsch2_early_init_f(void)
 {
 	struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR +
arch/arm/include/asm/arch-fsl-layerscape/soc.h +3 -0
index 697f072..08a42b9 100644
@@ -120,6 +120,9 @@ void fsl_lsch2_early_init_f(void);
 int setup_chip_volt(void);
 /* Setup core vdd in unit mV */
 int board_setup_core_volt(u32 vdd);
+#ifdef CONFIG_FSL_PFE
+void init_pfe_scfg_dcfg_regs(void);
+#endif
 #endif
 void ddr_enable_0v9_volt(bool en);
 
Signature · 1 line
2.7.4
#14 lore raw

PATCH 7/9 armv8: fsl-lsch2: configure pfe's scfg & dcfg registers

Hello Calvin

Please find few comments inline.

Regards
Poonam

Quoted 8 lines

-----Original Message-----
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Calvin Johnson
Sent: Monday, October 09, 2017 2:42 PM
To: u-boot at lists.denx.de
Cc: joe.hershberger at ni.com; Anji Jagarlmudi <[email protected]>
Subject: [U-Boot] [PATCH 7/9] armv8: fsl-lsch2: configure pfe's scfg & dcfg registers

Reword: configure Qos, cacheable...attributes for PFE by programming SCFG and DFCG registers

Quoted 2 lines

Define init_pfe_scfg_dcfg_regs to configure scfg and dcfg registers of pfe.

Consider to reword for more explanation
Configure "xyz cacheable attributes, via scfg
PFE QoS settings configured as .... via scfg
dcfg ??

Quoted 19 lines
---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c        | 18 ++++++++++++++++++
 arch/arm/include/asm/arch-fsl-layerscape/soc.h |  3 +++
 2 files changed, 21 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
index 5c429d4..c6815f3 100644
@@ -577,6 +577,24 @@ int setup_chip_volt(void)
 	return 0;
 }
 
+#ifdef CONFIG_FSL_PFE
+void init_pfe_scfg_dcfg_regs(void)

arch/arm/cpu/armv8/fsl-layerscape/soc.c int setup_chip_volt(void) · line 591

Quoted 10 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +9 -0
+{
+	struct ccsr_scfg *scfg = (struct ccsr_scfg
 *)CONFIG_SYS_FSL_SCFG_ADDR;
+
+	out_be32(&scfg->pfeasbcr,
+		 in_be32(&scfg->pfeasbcr) | SCFG_PFEASBCR_AWCACHE0);
+	out_be32(&scfg->pfebsbcr,
+		 in_be32(&scfg->pfebsbcr) | SCFG_PFEASBCR_AWCACHE0);
+
+	/* CCI-400 QoS settings for PFE */

This is incomplete sentence, we should also tell what settings are being done.

arch/arm/cpu/armv8/fsl-layerscape/soc.c int setup_chip_volt(void) · line 592

Quoted 2 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
+	out_be32(&scfg->wr_qos1, 0x0ff00000);
+	out_be32(&scfg->rd_qos1, 0x0ff00000);

Avoid hardcoding/magic numbers

arch/arm/cpu/armv8/fsl-layerscape/soc.c int setup_chip_volt(void) · line 595

Quoted 2 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
+
+	out_be32((void *)CONFIG_SYS_DCSR_DCFG_ADDR + 0x524, 0x2000);

Should remove hardcoded values , 0x524, 0x2000.
0x524 does not show up in the LS1012A RM (Rev 0). Please check once. Also adding one liner telling what the above settings mean will help .

Quoted 27 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -1
 #endif
+
 void fsl_lsch2_early_init_f(void)
 {
 	struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR + diff
--git a/arch/arm/include/asm/arch-fsl-layerscape/soc.h

b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
index 697f072..08a42b9 100644

arch/arm/include/asm/arch-fsl-layerscape/soc.h +3 -1
@@ -120,6 +120,9 @@ void fsl_lsch2_early_init_f(void);  int
 setup_chip_volt(void);
 /* Setup core vdd in unit mV */
 int board_setup_core_volt(u32 vdd);
+#ifdef CONFIG_FSL_PFE
+void init_pfe_scfg_dcfg_regs(void);
+#endif
 #endif
 void ddr_enable_0v9_volt(bool en);
 
--

2.7.4

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#15 lore raw

PATCH 7/9 armv8: fsl-lsch2: configure pfe's scfg & dcfg registers

Hi Poonam,

Quoted 62 lines

-----Original Message-----
From: Poonam Aggrwal
Sent: Friday, November 24, 2017 11:25 AM
To: Calvin Johnson <[email protected]>; u-boot at lists.denx.de
Cc: joe.hershberger at ni.com; Anji Jagarlmudi <[email protected]>
Subject: RE: [U-Boot] [PATCH 7/9] armv8: fsl-lsch2: configure pfe's scfg & dcfg registers

Hello Calvin

Please find few comments inline.

Regards
Poonam

Quoted 8 lines

-----Original Message-----
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Calvin Johnson
Sent: Monday, October 09, 2017 2:42 PM
To: u-boot at lists.denx.de
Cc: joe.hershberger at ni.com; Anji Jagarlmudi <[email protected]>
Subject: [U-Boot] [PATCH 7/9] armv8: fsl-lsch2: configure pfe's scfg & dcfg registers

Reword: configure Qos, cacheable...attributes for PFE by programming SCFG and DFCG registers

Quoted 2 lines

Define init_pfe_scfg_dcfg_regs to configure scfg and dcfg registers of pfe.

Consider to reword for more explanation
Configure "xyz cacheable attributes, via scfg
PFE QoS settings configured as .... via scfg
dcfg ??

Quoted 19 lines
---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c        | 18 ++++++++++++++++++
 arch/arm/include/asm/arch-fsl-layerscape/soc.h |  3 +++
 2 files changed, 21 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
index 5c429d4..c6815f3 100644
@@ -577,6 +577,24 @@ int setup_chip_volt(void)
 	return 0;
 }
 
+#ifdef CONFIG_FSL_PFE
+void init_pfe_scfg_dcfg_regs(void)

arch/arm/cpu/armv8/fsl-layerscape/soc.c int setup_chip_volt(void) · line 591

Quoted 10 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +9 -0
+{
+	struct ccsr_scfg *scfg = (struct ccsr_scfg
 *)CONFIG_SYS_FSL_SCFG_ADDR;
+
+	out_be32(&scfg->pfeasbcr,
+		 in_be32(&scfg->pfeasbcr) | SCFG_PFEASBCR_AWCACHE0);
+	out_be32(&scfg->pfebsbcr,
+		 in_be32(&scfg->pfebsbcr) | SCFG_PFEASBCR_AWCACHE0);
+
+	/* CCI-400 QoS settings for PFE */

This is incomplete sentence, we should also tell what settings are being done.

Quoted 8 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c int setup_chip_volt(void) · line 592

Quoted 2 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
+	out_be32(&scfg->wr_qos1, 0x0ff00000);
+	out_be32(&scfg->rd_qos1, 0x0ff00000);

Avoid hardcoding/magic numbers

arch/arm/cpu/armv8/fsl-layerscape/soc.c int setup_chip_volt(void) · line 595

Quoted 2 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
+
+	out_be32((void *)CONFIG_SYS_DCSR_DCFG_ADDR + 0x524, 0x2000);

Should remove hardcoded values , 0x524, 0x2000.
0x524 does not show up in the LS1012A RM (Rev 0). Please check once. Also adding one liner telling what the above settings mean will help .

Thanks for your comments. Will take care of them in v2 of the series.

Regards
Calvin

#16 lore raw

PATCH 8/9 fsl: csu: enable ns access for PFE

In reply to Calvin Johnson

Enable non-secure access for PFE block.

---
 arch/arm/include/asm/arch-fsl-layerscape/ns_access.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/include/asm/arch-fsl-layerscape/ns_access.h +2 -0
index f46f1d8..fe97a93 100644
@@ -26,6 +26,7 @@ enum csu_cslx_ind {
 	CSU_CSLX_PCIE3_IO,
 	CSU_CSLX_USB3 = 20,
 	CSU_CSLX_USB2,
+	CSU_CSLX_PFE = 23,
 	CSU_CSLX_SERDES = 32,
 	CSU_CSLX_QDMA,
 	CSU_CSLX_LPUART2,
@@ -105,6 +106,7 @@ static struct csu_ns_dev ns_dev[] = {
 	 {CSU_CSLX_PCIE3_IO, CSU_ALL_RW},
 	 {CSU_CSLX_USB3, CSU_ALL_RW},
 	 {CSU_CSLX_USB2, CSU_ALL_RW},
+	 {CSU_CSLX_PFE, CSU_ALL_RW},
 	 {CSU_CSLX_SERDES, CSU_ALL_RW},
 	 {CSU_CSLX_QDMA, CSU_ALL_RW},
 	 {CSU_CSLX_LPUART2, CSU_ALL_RW},
Signature · 1 line
2.7.4
#17 lore raw

PATCH 8/9 fsl: csu: enable ns access for PFE

Hello Calvin,
Minor comments below.

Regards
Poonam

Quoted 7 lines

-----Original Message-----
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Calvin Johnson
Sent: Monday, October 09, 2017 2:42 PM
To: u-boot at lists.denx.de
Cc: joe.hershberger at ni.com; Anji Jagarlmudi <[email protected]>
Subject: [U-Boot] [PATCH 8/9] fsl: csu: enable ns access for PFE

Can be reworded.
nxp: arch/fsl-layerscape:

Quoted 2 lines

Enable non-secure access for PFE block.

may want to reword:
Enable accesses to PFE registers for Non Secure masters by CSU programming

Quoted 35 lines
---
 arch/arm/include/asm/arch-fsl-layerscape/ns_access.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/include/asm/arch-fsl-layerscape/ns_access.h +2 -1
index f46f1d8..fe97a93 100644
@@ -26,6 +26,7 @@ enum csu_cslx_ind {
 	CSU_CSLX_PCIE3_IO,
 	CSU_CSLX_USB3 = 20,
 	CSU_CSLX_USB2,
+	CSU_CSLX_PFE = 23,
 	CSU_CSLX_SERDES = 32,
 	CSU_CSLX_QDMA,
 	CSU_CSLX_LPUART2,
@@ -105,6 +106,7 @@ static struct csu_ns_dev ns_dev[] = {
 	 {CSU_CSLX_PCIE3_IO, CSU_ALL_RW},
 	 {CSU_CSLX_USB3, CSU_ALL_RW},
 	 {CSU_CSLX_USB2, CSU_ALL_RW},
+	 {CSU_CSLX_PFE, CSU_ALL_RW},
 	 {CSU_CSLX_SERDES, CSU_ALL_RW},
 	 {CSU_CSLX_QDMA, CSU_ALL_RW},
 	 {CSU_CSLX_LPUART2, CSU_ALL_RW},
--

2.7.4

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#18 lore raw

PATCH 9/9 configs: ls1012a: add pfe configuration for LS1012A

In reply to Calvin Johnson
---
 configs/ls1012afrdm_qspi_defconfig |  1 +
 configs/ls1012aqds_qspi_defconfig  |  1 +
 configs/ls1012ardb_qspi_defconfig  |  1 +
 drivers/net/Kconfig                |  1 +
 drivers/net/Makefile               |  1 +
 drivers/net/pfe_eth/Kconfig        | 23 ++++++++++++++++++++++-
 include/configs/ls1012a_common.h   |  6 +++---
 include/configs/ls1012afrdm.h      |  7 +++++++
 include/configs/ls1012aqds.h       | 14 ++++++++++++++
 include/configs/ls1012ardb.h       |  8 ++++++++
 10 files changed, 59 insertions(+), 4 deletions(-)
configs/ls1012afrdm_qspi_defconfig +1 -0
index 84b5577..7db7a18 100644
@@ -32,6 +32,7 @@ CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_NETDEVICES=y
 CONFIG_E1000=y
+CONFIG_FSL_PFE=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
configs/ls1012aqds_qspi_defconfig +1 -0
index 2124273..4b9fdf5 100644
@@ -37,6 +37,7 @@ CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_NETDEVICES=y
 CONFIG_E1000=y
+CONFIG_FSL_PFE=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
configs/ls1012ardb_qspi_defconfig +1 -0
index 40349ce..d63e736 100644
@@ -35,6 +35,7 @@ CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_NETDEVICES=y
 CONFIG_E1000=y
+CONFIG_FSL_PFE=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
drivers/net/Kconfig +1 -0
index 736aab2..c82c63b 100644
@@ -304,4 +304,5 @@ config FEC2_PHY_NORXERR
 	  The PHY does not have a RXERR line (RMII only).
 	  (so program the FEC to ignore it).
 
+source "drivers/net/pfe_eth/Kconfig"
 endif # NETDEVICES
drivers/net/Makefile +1 -0
index 94a4fd8..0572cde 100644
@@ -75,3 +75,4 @@ obj-$(CONFIG_FSL_MEMAC) += fm/memac_phy.o
 obj-$(CONFIG_VSC9953) += vsc9953.o
 obj-$(CONFIG_PIC32_ETH) += pic32_mdio.o pic32_eth.o
 obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o
+obj-$(CONFIG_FSL_PFE) += pfe_eth/
drivers/net/pfe_eth/Kconfig +22 -1
index b9996df..c05aeda 100644
@@ -1,8 +1,29 @@
+menuconfig FSL_PFE
+	bool "Freescale PFE driver"
+	help
+	  This driver provides support for Freescale PFE.
+
+if FSL_PFE
+
 config UTIL_PE_DISABLED
 	bool
 	help
 	  Disable UTIL processor engine of PFE
 
-config SYS_FSL_PPFE_ADDR
+config SYS_FSL_PFE_ADDR
 	hex "PFE base address"
 	default 0x04000000
+
+config SYS_LS_PFE_FW_ADDR
+	hex "Flash address of PFE firmware"
+	default 0x40a00000
+
+config DDR_PFE_PHYS_BASEADDR
+	hex "PFE DDR physical base address"
+	default 0x03800000
+
+config DDR_PFE_BASEADDR
+	hex "PFE DDR base address"
+	default 0x83800000
+
+endif
include/configs/ls1012a_common.h +3 -3
index 52c2c3a..3df5586 100644
@@ -113,9 +113,9 @@
 #define CONFIG_BOOTARGS		"console=ttyS0,115200 root=/dev/ram0 " \
 				"earlycon=uart8250,mmio,0x21c0500 quiet lpj=250000"
 #undef CONFIG_BOOTCOMMAND
-#define CONFIG_BOOTCOMMAND		"sf probe 0:0; sf read $kernel_load "\
-					"$kernel_start $kernel_size && "\
-					"bootm $kernel_load"
+#define CONFIG_BOOTCOMMAND	"pfe stop; sf probe 0:0; sf read $kernel_load "\
+				"$kernel_start $kernel_size && "\
+				"bootm $kernel_load"
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		512	/* Console I/O Buffer Size */
include/configs/ls1012afrdm.h +7 -0
index 544dea0..a3f8824 100644
@@ -9,6 +9,13 @@
 
 #include "ls1012a_common.h"
 
+#ifdef CONFIG_FSL_PFE
+#define EMAC1_PHY_ADDR          0x2
+#define EMAC2_PHY_ADDR          0x1
+#define CONFIG_PHYLIB
+#define CONFIG_PHY_REALTEK
+#endif
+
 /* DDR */
 #define CONFIG_DIMM_SLOTS_PER_CTLR	1
 #define CONFIG_CHIP_SELECTS_PER_CTRL	1
include/configs/ls1012aqds.h +14 -0
index 16714bb..9873339 100644
@@ -9,6 +9,20 @@
 
 #include "ls1012a_common.h"
 
+/* PFE Ethernet */
+#ifdef CONFIG_FSL_PFE
+#define EMAC1_PHY_ADDR          0x1e
+#define EMAC2_PHY_ADDR          0x1
+#define	SGMII_2500_PHY1_ADDR	0x1
+#define	SGMII_2500_PHY2_ADDR	0x2
+#define CONFIG_PHYLIB
+#define CONFIG_PHY_VITESSE
+#define CONFIG_PHY_REALTEK
+#define	CONFIG_PHY_AQUANTIA
+#define	CONFIG_PHYLIB_10G
+#define RGMII_RESET_WA
+#endif
+
 /* DDR */
 #define CONFIG_DIMM_SLOTS_PER_CTLR	1
 #define CONFIG_CHIP_SELECTS_PER_CTRL	1
include/configs/ls1012ardb.h +8 -0
index e47bb7c..e8f42e4 100644
@@ -9,6 +9,14 @@
 
 #include "ls1012a_common.h"
 
+/* PFE Ethernet */
+#ifdef CONFIG_FSL_PFE
+#define EMAC1_PHY_ADDR          0x2
+#define EMAC2_PHY_ADDR          0x1
+#define CONFIG_PHYLIB
+#define CONFIG_PHY_REALTEK
+#endif
+
 /* DDR */
 #define CONFIG_DIMM_SLOTS_PER_CTLR	1
 #define CONFIG_CHIP_SELECTS_PER_CTRL	1
Signature · 1 line
2.7.4
#19 lore raw

PATCH 9/9 configs: ls1012a: add pfe configuration for LS1012A

Quoted 99 lines

-----Original Message-----
From: Calvin Johnson [mailto:calvin.johnson at nxp.com]
Sent: Monday, October 09, 2017 2:42 PM
To: u-boot at lists.denx.de
Cc: Prabhakar Kushwaha <[email protected]>; York Sun <[email protected]>; joe.hershberger at ni.com; Calvin Johnson <[email protected]>; Anji Jagarlmudi <[email protected]>
Subject: [PATCH 9/9] configs: ls1012a: add pfe configuration for LS1012A

---
 configs/ls1012afrdm_qspi_defconfig |  1 +
 configs/ls1012aqds_qspi_defconfig  |  1 +
 configs/ls1012ardb_qspi_defconfig  |  1 +
 drivers/net/Kconfig                |  1 +
 drivers/net/Makefile               |  1 +
 drivers/net/pfe_eth/Kconfig        | 23 ++++++++++++++++++++++-
 include/configs/ls1012a_common.h   |  6 +++---
 include/configs/ls1012afrdm.h      |  7 +++++++
 include/configs/ls1012aqds.h       | 14 ++++++++++++++
 include/configs/ls1012ardb.h       |  8 ++++++++
 10 files changed, 59 insertions(+), 4 deletions(-)
configs/ls1012afrdm_qspi_defconfig +1 -0
index 84b5577..7db7a18 100644
@@ -32,6 +32,7 @@ CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_NETDEVICES=y
 CONFIG_E1000=y
+CONFIG_FSL_PFE=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
configs/ls1012aqds_qspi_defconfig +1 -0
index 2124273..4b9fdf5 100644
@@ -37,6 +37,7 @@ CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_NETDEVICES=y
 CONFIG_E1000=y
+CONFIG_FSL_PFE=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
configs/ls1012ardb_qspi_defconfig +1 -0
index 40349ce..d63e736 100644
@@ -35,6 +35,7 @@ CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_NETDEVICES=y
 CONFIG_E1000=y
+CONFIG_FSL_PFE=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
drivers/net/Kconfig +1 -0
index 736aab2..c82c63b 100644
@@ -304,4 +304,5 @@ config FEC2_PHY_NORXERR
 	  The PHY does not have a RXERR line (RMII only).
 	  (so program the FEC to ignore it).
 
+source "drivers/net/pfe_eth/Kconfig"
 endif # NETDEVICES
drivers/net/Makefile +1 -0
index 94a4fd8..0572cde 100644
@@ -75,3 +75,4 @@ obj-$(CONFIG_FSL_MEMAC) += fm/memac_phy.o
 obj-$(CONFIG_VSC9953) += vsc9953.o
 obj-$(CONFIG_PIC32_ETH) += pic32_mdio.o pic32_eth.o
 obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o
+obj-$(CONFIG_FSL_PFE) += pfe_eth/
drivers/net/pfe_eth/Kconfig +7 -0
index b9996df..c05aeda 100644
@@ -1,8 +1,29 @@
+menuconfig FSL_PFE
+	bool "Freescale PFE driver"
+	help
+	  This driver provides support for Freescale PFE.
+
+if FSL_PFE
+
 config UTIL_PE_DISABLED
 	bool
 	help
 	  Disable UTIL processor engine of PFE

drivers/net/pfe_eth/Kconfig line 20

Quoted 10 lines
drivers/net/pfe_eth/Kconfig +6 -1
 
-config SYS_FSL_PPFE_ADDR
+config SYS_FSL_PFE_ADDR
 	hex "PFE base address"
 	default 0x04000000
+
+config SYS_LS_PFE_FW_ADDR
+	hex "Flash address of PFE firmware"
+	default 0x40a00000
+

Why this parameter in Kconfig.
This address is hard-coded per platform as defined in standard LSDK flash layout.

--pk

#20 lore raw

cover LS1012A PFE driver patch series

In reply to Calvin Johnson
Quoted 11 lines · Calvin Johnson

Hi,

This patch series introduces U-Boot support for NXP's LS1012A Packet Forwarding Engine (pfe_eth). LS1012A uses hardware packet forwarding engine to provide high performance Ethernet interfaces. The device includes two Ethernet ports.

Depends on https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.ozlabs.org%2Fpatch%2F704305&data=01%7C01%7Cyork.sun%40nxp.com%7C78639ec10c954f60768a08d50ef573c5%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=cEXazXptrFnPf30yXCrwOvb%2B3DDekH4BZNmW1JavzO8%3D&reserved=0

Regards
Calvin

Quoted 10 lines

Calvin Johnson (9):
drivers: net: pfe_eth: LS1012A PFE driver introduction
drivers: net: pfe_eth: provide pfe commands
drivers: net: pfe_eth: LS1012A PFE headers
board: freescale: ls1012a: enable network support on ls1012a platforms
armv8: fsl-lsch2: initialize pfe gemac
armv8: fsl-lsch2: add pfe macros and update ccsr_scfg structure
armv8: fsl-lsch2: configure pfe's scfg & dcfg registers
fsl: csu: enable ns access for PFE
configs: ls1012a: add pfe configuration for LS1012A

Joe,

Please review the new net driver proposed when you have a chance. Thanks.

York