Re: [U-Boot] [PATCH 1/9] drivers: net: pfe_eth: LS1012A PFE driver introduction
Hi Joe, > -Original Message- > From: Joe Hershberger [mailto:joe.hershber...@ni.com] > Sent: Wednesday, December 06, 2017 1:44 AM > To: Calvin Johnson <calvin.john...@nxp.com> > Cc: u-boot <u-boot@lists.denx.de>; Joe Hershberger > <joe.hershber...@ni.com>; Anji Jagarlmudi <anji.jagarlm...@nxp.com> > Subject: Re: [U-Boot] [PATCH 1/9] drivers: net: pfe_eth: LS1012A PFE driver > introduction > > On Mon, Oct 9, 2017 at 4:11 AM, Calvin Johnson <calvin.john...@nxp.com> > wrote: > > This patch adds PFE driver into U-Boot. [snip] > > + 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 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 1/9] drivers: net: pfe_eth: LS1012A PFE driver introduction
On Mon, Oct 9, 2017 at 4:11 AM, Calvin Johnsonwrote: > 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. > > Signed-off-by: Calvin Johnson > Signed-off-by: Anjaneyulu Jagarlmudi > --- > 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 > > diff --git a/drivers/net/pfe_eth/Kconfig b/drivers/net/pfe_eth/Kconfig > new file mode 100644 > index 000..b9996df > --- /dev/null > +++ b/drivers/net/pfe_eth/Kconfig > @@ -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 0x0400 > diff --git a/drivers/net/pfe_eth/Makefile b/drivers/net/pfe_eth/Makefile > new file mode 100644 > index 000..e78f1bf > --- /dev/null > +++ b/drivers/net/pfe_eth/Makefile > @@ -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 > diff --git a/drivers/net/pfe_eth/pfe.c b/drivers/net/pfe_eth/pfe.c > new file mode 100644 > index 000..fc6631e > --- /dev/null > +++ b/drivers/net/pfe_eth/pfe.c > @@ -0,0 +1,1161 @@ > +/* > + * Copyright 2015-2016 Freescale Semiconductor, Inc. > + * Copyright 2017 NXP > + * > + * SPDX-License-Identifier:GPL-2.0+ > + */ > +#include > +#include > + > +void *ddr_base_addr; > +unsigned long ddr_phys_base_addr; > +static struct pe_info pe[MAX_PE]; > + > +/* > + * Initializes the PFE library. > + * Must be called before using any of the library functions. > + * > + * @param[in] cbus_baseCBUS 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_baseDDR 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? > +{ > + 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
Re: [U-Boot] [PATCH 1/9] drivers: net: pfe_eth: LS1012A PFE driver introduction
On 10/09/2017 02:09 AM, Calvin Johnson wrote: > 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. > > Signed-off-by: Calvin Johnson> Signed-off-by: Anjaneyulu Jagarlmudi > --- > 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 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [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. Signed-off-by: Calvin JohnsonSigned-off-by: Anjaneyulu Jagarlmudi --- 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 diff --git a/drivers/net/pfe_eth/Kconfig b/drivers/net/pfe_eth/Kconfig new file mode 100644 index 000..b9996df --- /dev/null +++ b/drivers/net/pfe_eth/Kconfig @@ -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 0x0400 diff --git a/drivers/net/pfe_eth/Makefile b/drivers/net/pfe_eth/Makefile new file mode 100644 index 000..e78f1bf --- /dev/null +++ b/drivers/net/pfe_eth/Makefile @@ -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 diff --git a/drivers/net/pfe_eth/pfe.c b/drivers/net/pfe_eth/pfe.c new file mode 100644 index 000..fc6631e --- /dev/null +++ b/drivers/net/pfe_eth/pfe.c @@ -0,0 +1,1161 @@ +/* + * Copyright 2015-2016 Freescale Semiconductor, Inc. + * Copyright 2017 NXP + * + * SPDX-License-Identifier:GPL-2.0+ + */ +#include +#include + +void *ddr_base_addr; +unsigned long ddr_phys_base_addr; +static struct pe_info pe[MAX_PE]; + +/* + * Initializes the PFE library. + * Must be called before using any of the library functions. + * + * @param[in] cbus_baseCBUS 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_baseDDR physical base address (as mapped in + * platform) + */ +void pfe_lib_init(void *ddr_base, unsigned long ddr_phys_base) +{ + 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; +