[U-Boot] [PATCH 3/3] configs: sama5d27_som1_ek: Add defconfig for ENV/boot from uSD
This adds a defconfig for sama5d27_som1_ek board to get environment from uSD. The defconfig is made from sama5d27_som1_ek_mmc_defconfig, with 'bootcmd' and 'bootargs' changed to kernel, device-tree and rootfs from uSD. The environment is expected to be found in uSD's FAT partition. Signed-off-by: Codrin Ciubotariu --- configs/sama5d27_som1_ek_mmc1_defconfig | 91 + include/configs/sama5d27_som1_ek.h | 4 +- 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 configs/sama5d27_som1_ek_mmc1_defconfig diff --git a/configs/sama5d27_som1_ek_mmc1_defconfig b/configs/sama5d27_som1_ek_mmc1_defconfig new file mode 100644 index 000..0ac2445887d --- /dev/null +++ b/configs/sama5d27_som1_ek_mmc1_defconfig @@ -0,0 +1,91 @@ +CONFIG_ARM=y +CONFIG_ARCH_AT91=y +CONFIG_SYS_TEXT_BASE=0x23f0 +CONFIG_TARGET_SAMA5D27_SOM1_EK=y +CONFIG_SPL_GPIO_SUPPORT=y +CONFIG_SPL_LIBCOMMON_SUPPORT=y +CONFIG_SPL_LIBGENERIC_SUPPORT=y +CONFIG_SYS_MALLOC_F_LEN=0x2000 +CONFIG_SPL_MMC_SUPPORT=y +CONFIG_SPL_SERIAL_SUPPORT=y +CONFIG_SPL_DRIVERS_MISC_SUPPORT=y +CONFIG_SPL=y +CONFIG_DEBUG_UART_BOARD_INIT=y +CONFIG_DEBUG_UART_BASE=0xf802 +CONFIG_DEBUG_UART_CLOCK=8200 +CONFIG_SPL_FAT_SUPPORT=y +CONFIG_SPL_LIBDISK_SUPPORT=y +CONFIG_DEFAULT_DEVICE_TREE="at91-sama5d27_som1_ek" +CONFIG_DEBUG_UART=y +CONFIG_ENV_VARS_UBOOT_CONFIG=y +CONFIG_FIT=y +CONFIG_SYS_EXTRA_OPTIONS="SAMA5D2" +CONFIG_SD_BOOT=y +CONFIG_BOOTDELAY=3 +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 earlyprintk root=/dev/mmcblk1p2 rw rootwait" +# CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_SPL_SEPARATE_BSS=y +CONFIG_HUSH_PARSER=y +CONFIG_CMD_BOOTZ=y +# CONFIG_CMD_IMI is not set +# CONFIG_CMD_FLASH is not set +CONFIG_CMD_I2C=y +# CONFIG_CMD_LOADS is not set +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_USB=y +CONFIG_CMD_DHCP=y +CONFIG_CMD_PING=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_FAT=y +CONFIG_OF_CONTROL=y +CONFIG_SPL_OF_CONTROL=y +CONFIG_OF_SPL_REMOVE_PROPS="interrupts interrupt-parent dmas dma-names" +CONFIG_ENV_IS_IN_FAT=y +CONFIG_ENV_FAT_DEVICE_AND_PART="1" +CONFIG_DM=y +CONFIG_SPL_DM=y +CONFIG_SPL_DM_SEQ_ALIAS=y +CONFIG_CLK=y +CONFIG_SPL_CLK=y +CONFIG_CLK_AT91=y +CONFIG_AT91_UTMI=y +CONFIG_AT91_H32MX=y +CONFIG_AT91_GENERIC_CLK=y +CONFIG_DM_GPIO=y +CONFIG_ATMEL_PIO4=y +CONFIG_DM_I2C=y +CONFIG_SYS_I2C_AT91=y +CONFIG_I2C_EEPROM=y +CONFIG_DM_MMC=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_ATMEL=y +CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH=y +CONFIG_SPI_FLASH_ATMEL=y +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_SPI_FLASH_STMICRO=y +CONFIG_SPI_FLASH_SST=y +CONFIG_DM_ETH=y +CONFIG_MACB=y +CONFIG_PINCTRL=y +CONFIG_SPL_PINCTRL=y +CONFIG_PINCTRL_AT91PIO4=y +CONFIG_DM_SERIAL=y +CONFIG_DEBUG_UART_ATMEL=y +CONFIG_DEBUG_UART_ANNOUNCE=y +CONFIG_ATMEL_USART=y +CONFIG_SPI=y +CONFIG_DM_SPI=y +CONFIG_TIMER=y +CONFIG_SPL_TIMER=y +CONFIG_ATMEL_PIT_TIMER=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_STORAGE=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_ATMEL_USBA=y +CONFIG_DM_VIDEO=y +CONFIG_ATMEL_HLCD=y diff --git a/include/configs/sama5d27_som1_ek.h b/include/configs/sama5d27_som1_ek.h index 5b1f77ba24c..6af4fb51855 100644 --- a/include/configs/sama5d27_som1_ek.h +++ b/include/configs/sama5d27_som1_ek.h @@ -41,8 +41,8 @@ /* u-boot env in sd/mmc card */ #define CONFIG_ENV_SIZE0x4000 /* bootstrap + u-boot + env in sd card */ -#define CONFIG_BOOTCOMMAND "fatload mmc 0:1 0x2100 at91-sama5d27_som1_ek.dtb; " \ - "fatload mmc 0:1 0x2200 zImage; " \ +#define CONFIG_BOOTCOMMAND "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x2100 at91-sama5d27_som1_ek.dtb; " \ + "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x2200 zImage; " \ "bootz 0x2200 - 0x2100" #endif -- 2.17.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH 2/3] configs: sama5d27_som1_ek: Set CONFIG_BOOTARGS using Kconfig
CONFIG_BOOTARGS can be set using Kconfig, so we no longer need it in the config files. Signed-off-by: Codrin Ciubotariu --- configs/sama5d27_som1_ek_mmc_defconfig | 2 ++ include/configs/sama5d27_som1_ek.h | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/configs/sama5d27_som1_ek_mmc_defconfig b/configs/sama5d27_som1_ek_mmc_defconfig index 53d4b7ce0ca..8e50cef8dbc 100644 --- a/configs/sama5d27_som1_ek_mmc_defconfig +++ b/configs/sama5d27_som1_ek_mmc_defconfig @@ -22,6 +22,8 @@ CONFIG_FIT=y CONFIG_SYS_EXTRA_OPTIONS="SAMA5D2" CONFIG_SD_BOOT=y CONFIG_BOOTDELAY=3 +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rw rootwait" # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_SPL_SEPARATE_BSS=y CONFIG_HUSH_PARSER=y diff --git a/include/configs/sama5d27_som1_ek.h b/include/configs/sama5d27_som1_ek.h index 5e2249711de..5b1f77ba24c 100644 --- a/include/configs/sama5d27_som1_ek.h +++ b/include/configs/sama5d27_som1_ek.h @@ -44,9 +44,6 @@ #define CONFIG_BOOTCOMMAND "fatload mmc 0:1 0x2100 at91-sama5d27_som1_ek.dtb; " \ "fatload mmc 0:1 0x2200 zImage; " \ "bootz 0x2200 - 0x2100" -#undef CONFIG_BOOTARGS -#define CONFIG_BOOTARGS \ - "console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rw rootwait" #endif #ifdef CONFIG_QSPI_BOOT -- 2.17.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH 1/3] configs: sama5d27_som1_ek: Remove unnecessary FAT_ENV_xxx macros
FAT_ENV_xxx options can now be set using Kconfig, so we no longer need them in the config files. Signed-off-by: Codrin Ciubotariu --- include/configs/sama5d27_som1_ek.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/configs/sama5d27_som1_ek.h b/include/configs/sama5d27_som1_ek.h index 0cae301da26..5e2249711de 100644 --- a/include/configs/sama5d27_som1_ek.h +++ b/include/configs/sama5d27_som1_ek.h @@ -39,9 +39,6 @@ #undef CONFIG_BOOTCOMMAND #ifdef CONFIG_SD_BOOT /* u-boot env in sd/mmc card */ -#define FAT_ENV_INTERFACE "mmc" -#define FAT_ENV_DEVICE_AND_PART"0" -#define FAT_ENV_FILE "uboot.env" #define CONFIG_ENV_SIZE0x4000 /* bootstrap + u-boot + env in sd card */ #define CONFIG_BOOTCOMMAND "fatload mmc 0:1 0x2100 at91-sama5d27_som1_ek.dtb; " \ -- 2.17.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH 0/3] configs: sama5d27_som1_ek: Cleanup and new
This series basically adds a new defconfig for sama5d27_som1_ek board to boot from uSD. Also needed to cleanup the board's config header. Codrin Ciubotariu (3): configs: sama5d27_som1_ek: Remove unnecessary FAT_ENV_xxx macros configs: sama5d27_som1_ek: Set CONFIG_BOOTARGS using Kconfig configs: sama5d27_som1_ek: Add defconfig for ENV/boot from uSD configs/sama5d27_som1_ek_mmc1_defconfig | 91 + configs/sama5d27_som1_ek_mmc_defconfig | 2 + include/configs/sama5d27_som1_ek.h | 10 +-- 3 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 configs/sama5d27_som1_ek_mmc1_defconfig -- 2.17.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH] configs: sama5d2_xplained: Add defconfig for ENV/boot from eMMC
This adds a defconfig for sama5d2_xplained board to get environment from eMMC. The defconfig is made from sama5d2_xplained_mmc_defconfig, with 'bootcmd' and 'bootargs' changed to kernel, device-tree and rootfs from eMMC. The environment is expected to be found in eMMC's FAT partition. Signed-off-by: Codrin Ciubotariu --- configs/sama5d2_xplained_emmc_defconfig | 88 + include/configs/sama5d2_xplained.h | 4 +- 2 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 configs/sama5d2_xplained_emmc_defconfig diff --git a/configs/sama5d2_xplained_emmc_defconfig b/configs/sama5d2_xplained_emmc_defconfig new file mode 100644 index 000..ca5d4f42212 --- /dev/null +++ b/configs/sama5d2_xplained_emmc_defconfig @@ -0,0 +1,88 @@ +CONFIG_ARM=y +CONFIG_ARCH_AT91=y +CONFIG_SYS_TEXT_BASE=0x26f0 +CONFIG_TARGET_SAMA5D2_XPLAINED=y +CONFIG_SPL_GPIO_SUPPORT=y +CONFIG_SPL_LIBCOMMON_SUPPORT=y +CONFIG_SPL_LIBGENERIC_SUPPORT=y +CONFIG_SYS_MALLOC_F_LEN=0x2000 +CONFIG_SPL_MMC_SUPPORT=y +CONFIG_SPL_SERIAL_SUPPORT=y +CONFIG_SPL_DRIVERS_MISC_SUPPORT=y +CONFIG_SPL=y +CONFIG_DEBUG_UART_BOARD_INIT=y +CONFIG_DEBUG_UART_BASE=0xf802 +CONFIG_DEBUG_UART_CLOCK=8300 +CONFIG_SPL_FAT_SUPPORT=y +CONFIG_SPL_LIBDISK_SUPPORT=y +CONFIG_DEFAULT_DEVICE_TREE="at91-sama5d2_xplained" +CONFIG_DEBUG_UART=y +CONFIG_ENV_VARS_UBOOT_CONFIG=y +CONFIG_FIT=y +CONFIG_SYS_EXTRA_OPTIONS="SAMA5D2,SYS_USE_MMC" +CONFIG_SD_BOOT=y +CONFIG_BOOTDELAY=3 +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rw rootwait" +# CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_SPL_SEPARATE_BSS=y +CONFIG_HUSH_PARSER=y +CONFIG_CMD_BOOTZ=y +# CONFIG_CMD_IMI is not set +# CONFIG_CMD_FLASH is not set +CONFIG_CMD_I2C=y +# CONFIG_CMD_LOADS is not set +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_USB=y +CONFIG_CMD_DHCP=y +CONFIG_CMD_PING=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_FAT=y +CONFIG_OF_CONTROL=y +CONFIG_SPL_OF_CONTROL=y +CONFIG_OF_SPL_REMOVE_PROPS="interrupts interrupt-parent dmas dma-names" +CONFIG_ENV_IS_IN_FAT=y +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" +CONFIG_DM=y +CONFIG_SPL_DM=y +CONFIG_SPL_DM_SEQ_ALIAS=y +CONFIG_CLK=y +CONFIG_SPL_CLK=y +CONFIG_CLK_AT91=y +CONFIG_AT91_UTMI=y +CONFIG_AT91_H32MX=y +CONFIG_AT91_GENERIC_CLK=y +CONFIG_DM_GPIO=y +CONFIG_ATMEL_PIO4=y +CONFIG_DM_I2C=y +CONFIG_SYS_I2C_AT91=y +CONFIG_I2C_EEPROM=y +CONFIG_DM_MMC=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_ATMEL=y +CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH=y +CONFIG_SPI_FLASH_ATMEL=y +CONFIG_DM_ETH=y +CONFIG_MACB=y +CONFIG_PINCTRL=y +CONFIG_SPL_PINCTRL=y +CONFIG_PINCTRL_AT91PIO4=y +CONFIG_DM_SERIAL=y +CONFIG_DEBUG_UART_ATMEL=y +CONFIG_DEBUG_UART_ANNOUNCE=y +CONFIG_ATMEL_USART=y +CONFIG_SPI=y +CONFIG_DM_SPI=y +CONFIG_TIMER=y +CONFIG_SPL_TIMER=y +CONFIG_ATMEL_PIT_TIMER=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_STORAGE=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_ATMEL_USBA=y +CONFIG_DM_VIDEO=y +CONFIG_ATMEL_HLCD=y diff --git a/include/configs/sama5d2_xplained.h b/include/configs/sama5d2_xplained.h index b205d8d6045..72bea8cdcf0 100644 --- a/include/configs/sama5d2_xplained.h +++ b/include/configs/sama5d2_xplained.h @@ -39,8 +39,8 @@ /* bootstrap + u-boot + env in sd card */ #undef CONFIG_BOOTCOMMAND -#define CONFIG_BOOTCOMMAND "fatload mmc 1:1 0x2100 at91-sama5d2_xplained.dtb; " \ - "fatload mmc 1:1 0x2200 zImage; " \ +#define CONFIG_BOOTCOMMAND "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x2100 at91-sama5d2_xplained.dtb; " \ + "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x2200 zImage; " \ "bootz 0x2200 - 0x2100" #elif CONFIG_SPI_BOOT -- 2.17.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH] drivers: net: vsc9953: Fix bug when PVID is shown for disabled ports only
Signed-off-by: Codrin Ciubotariu <codrin.ciubota...@nxp.com> --- drivers/net/vsc9953.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 44afe14..ef1435f 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -335,7 +335,7 @@ static int vsc9953_port_vlan_pvid_get(int port_nr, int *pvid) struct vsc9953_analyzer *l2ana_reg; /* Administrative down */ - if (vsc9953_l2sw.port[port_nr].enabled) { + if (!vsc9953_l2sw.port[port_nr].enabled) { printf("Port %d is administrative down\n", port_nr); return -1; } -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] powerpc: t1040qds: Use generic ethsw commands
The commands for the VSC9953 l2 switch from T1040 became generic in patch https://patchwork.ozlabs.org/patch/499748/ and the define was renamed. Signed-off-by: Codrin Ciubotariu <codrin.ciubota...@nxp.com> --- include/configs/T1040QDS.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/T1040QDS.h b/include/configs/T1040QDS.h index 2e7892f..15ae390 100644 --- a/include/configs/T1040QDS.h +++ b/include/configs/T1040QDS.h @@ -686,7 +686,7 @@ unsigned long get_board_ddr_clk(void); /* Enable VSC9953 L2 Switch driver */ #define CONFIG_VSC9953 -#define CONFIG_VSC9953_CMD +#define CONFIG_CMD_ETHSW #define CONFIG_SYS_FM1_QSGMII11_PHY_ADDR 0x14 #define CONFIG_SYS_FM1_QSGMII21_PHY_ADDR 0x18 -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] drivers: net: vsc9953: Do not configure disabled ports
Some SerDes protocols might not enable all l2switch ports. In this case, these ports should not be configured to perform Rx/Tx operations. This also fixes an issue when flooded frames were also switched to disabled ports and frames start to accumulate, consuming memory and eventually causing head-of-line blocking for other frames. Signed-off-by: Codrin Ciubotariu <codrin.ciubota...@nxp.com> --- drivers/net/vsc9953.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index ef1435f..2388438 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -2525,6 +2525,9 @@ void vsc9953_init(bd_t *bis) if (vsc9953_port_init(i)) printf("Failed to initialize l2switch port %d\n", i); + if (!vsc9953_l2sw.port[i].enabled) + continue; + /* Enable VSC9953 GMII Ports Port ID 0 - 7 */ if (VSC9953_INTERNAL_PORT_CHECK(i)) { out_le32(_reg->pfc[i].pfc_cfg, @@ -2537,6 +2540,11 @@ void vsc9953_init(bd_t *bis) out_le32(_reg->pause_cfg.mac_fc_cfg[i], VSC9953_MAC_FC_CFG); } + + l2dev_gmii_reg = (struct vsc9953_dev_gmii *) +(VSC9953_OFFSET + VSC9953_DEV_GMII_OFFSET + +T1040_SWITCH_GMII_DEV_OFFSET * i); + out_le32(_gmii_reg->port_mode.clock_cfg, VSC9953_CLOCK_CFG); out_le32(_gmii_reg->mac_cfg_status.mac_ena_cfg, @@ -2559,10 +2567,6 @@ void vsc9953_init(bd_t *bis) /* WAIT FOR 2 us*/ udelay(2); - l2dev_gmii_reg = (struct vsc9953_dev_gmii *)( - (char *)l2dev_gmii_reg - + T1040_SWITCH_GMII_DEV_OFFSET); - /* Initialize Lynx PHY Wrappers */ phy_addr = 0; if (vsc9953_l2sw.port[i].enet_if == -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 3/5] doc: t1040-l2switch: Update README
The driver for VSC9953 L2 switch IP supports many features and the documentation needs to be updated. Signed-off-by: Codrin Ciubotariu <codrin.ciubota...@freescale.com> --- doc/README.t1040-l2switch | 27 --- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/doc/README.t1040-l2switch b/doc/README.t1040-l2switch index 14dbf31..4e0f418 100644 --- a/doc/README.t1040-l2switch +++ b/doc/README.t1040-l2switch @@ -24,16 +24,29 @@ Switch interfaces: Commands Overview: = Commands supported - - enable/disable a port - - check a port's link speed, duplexity and status. + - enable/disable a port or show its configuration (speed, duplexity, status, etc.) + - port statistics + - MAC learning + - add/remove FDB entries + - Port-based VLAN + - Private/Shared VLAN learning + - VLAN ingress filtering Commands syntax - ethsw port enable|disable - enable/disable an l2 switch port - ethsw port show - show an l2 switch port's configuration +ethsw [port ] { enable | disable | show } - enable/disable a port; show a port's configuration +ethsw [port ] statistics { [help] | [clear] } - show an l2 switch port's statistics +ethsw [port ] learning { [help] | show | auto | disable } - enable/disable/show learning configuration on a port +ethsw [port ] [vlan ] fdb { [help] | show | flush | { add | del } } - add/delete a mac entry in FDB; use show to see FDB entries; + if [vlan ] is missing, VID 1 will be used +ethsw [port ] pvid { [help] | show | } - set/show PVID (ingress and egress VLAN tagging) for a port +ethsw [port ] vlan { [help] | show | add | del } - add a VLAN to a port (VLAN members) +ethsw [port ] untagged { [help] | show | all | none | pvid } - set egress tagging mode for a port +ethsw [port ] egress tag { [help] | show | pvid | classified } - configure VID source for egress tag. + Tag's VID could be the frame's classified VID or the PVID of the port +ethsw vlan fdb { [help] | show | shared | private } - make VLAN learning shared or private +ethsw [port ] ingress filtering { [help] | show | enable | disable } - enable/disable VLAN ingress filtering on port - port_nr=0..9; use "all" for all ports - -=> ethsw port all show +=> ethsw show Port Status LinkSpeed Duplex 0 enabled down 10 half 1 enabled down 10 half -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 0/5] vsc9953: fixes, cleanups and LAG support
The first two patches of this set fix an issue with the register map definition and with the aging time of the L2 switch. The next two paches fix some typos and update the documentation for VSC9952. The last patch adds LAG support. I made a set with all these patches mainly to assure that they are applied in the right order and no merge conflicts appear. Codrin Ciubotariu (5): drivers: net: vsc9953: Fix number of reserved registers drivers: net: vsc9953: Fix FDB aging time doc: t1040-l2switch: Update README common: cmd_ethsw: Spelling fixes drivers: net: vsc9953: Add LAG support common/cmd_ethsw.c| 78 +- doc/README.t1040-l2switch | 29 +++- drivers/net/vsc9953.c | 354 +- include/ethsw.h | 6 + include/vsc9953.h | 24 +++- 5 files changed, 480 insertions(+), 11 deletions(-) -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 2/5] drivers: net: vsc9953: Fix FDB aging time
By default, the aging period is set to 0, so the dynamic FDB entries are never removed. This patch sets the aging time to 300 seconds. Signed-off-by: Codrin Ciubotariu <codrin.ciubota...@freescale.com> --- drivers/net/vsc9953.c | 23 +++ include/vsc9953.h | 4 2 files changed, 27 insertions(+) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 7595db1..160f478 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -593,6 +593,25 @@ static void vsc9953_port_all_vlan_egress_untagged_set( vsc9953_port_vlan_egr_untag_set(i, mode); } +static int vsc9953_autoage_time_set(int age_period) +{ + u32 autoage; + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + if (age_period < 0 || age_period > VSC9953_AUTOAGE_PERIOD_MASK) + return -EINVAL; + + autoage = bitfield_replace_by_mask(in_le32(_reg->ana.auto_age), + VSC9953_AUTOAGE_PERIOD_MASK, + age_period); + out_le32(_reg->ana.auto_age, autoage); + + return 0; +} + #ifdef CONFIG_CMD_ETHSW /* Enable/disable status of a VSC9953 port */ @@ -2107,6 +2126,10 @@ void vsc9953_default_configuration(void) { int i; + if (vsc9953_autoage_time_set(VSC9953_DEFAULT_AGE_TIME)) + debug("VSC9953: failed to set AGE time to %d\n", + VSC9953_DEFAULT_AGE_TIME); + for (i = 0; i < VSC9953_MAX_VLAN; i++) vsc9953_vlan_table_membership_all_set(i, 0); vsc9953_port_all_vlan_aware_set(1); diff --git a/include/vsc9953.h b/include/vsc9953.h index 00aa222..35fcbb5 100644 --- a/include/vsc9953.h +++ b/include/vsc9953.h @@ -136,6 +136,9 @@ /* Macros for vsc9953_ana_ana.adv_learn register */ #define VSC9953_VLAN_CHK 0x0400 +/* Macros for vsc9953_ana_ana.auto_age register */ +#define VSC9953_AUTOAGE_PERIOD_MASK0x001e + /* Macros for vsc9953_rew_port.port_tag_cfg register */ #define VSC9953_TAG_CFG_MASK 0x0180 #define VSC9953_TAG_CFG_NONE 0x @@ -164,6 +167,7 @@ #define VSC9953_MAX_VLAN 4096 #define VSC9953_VLAN_CHECK(vid)\ (((vid) < 0 || (vid) >= VSC9953_MAX_VLAN) ? 0 : 1) +#define VSC9953_DEFAULT_AGE_TIME 300 #define DEFAULT_VSC9953_MDIO_NAME "VSC9953_MDIO0" -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 5/5] drivers: net: vsc9953: Add LAG support
You can now configure LAG on VSC9953's ports using the command: ethsw [port ] aggr {[help] | show | } A port must belong to a single LAG. By default, a port belongs to a LAG equal to the port's number. For each frame, a hash will be calculated based on Source/Destination MAC addresses, Source/Destination IP(v4/v6) addresses, Source/Destination ports. This hash will be used to select a single egress port from LAG. This also assures that frames from the same flow will always have the same egress port. Signed-off-by: Codrin Ciubotariu <codrin.ciubota...@freescale.com> --- common/cmd_ethsw.c| 74 +++ doc/README.t1040-l2switch | 2 + drivers/net/vsc9953.c | 331 +- include/ethsw.h | 6 + include/vsc9953.h | 18 +++ 5 files changed, 430 insertions(+), 1 deletion(-) diff --git a/common/cmd_ethsw.c b/common/cmd_ethsw.c index a5ed555..491cb8e 100644 --- a/common/cmd_ethsw.c +++ b/common/cmd_ethsw.c @@ -114,6 +114,17 @@ static int ethsw_ingr_fltr_help_key_func(struct ethsw_command_def *parsed_cmd) return CMD_RET_SUCCESS; } +#define ETHSW_PORT_AGGR_HELP "ethsw [port ] aggr" \ +" { [help] | show | } " \ +"- get/set LAG group for a port" + +static int ethsw_port_aggr_help_key_func(struct ethsw_command_def *parsed_cmd) +{ + printf(ETHSW_PORT_AGGR_HELP"\n"); + + return CMD_RET_SUCCESS; +} + static struct keywords_to_function { enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS]; int cmd_func_offset; @@ -532,6 +543,39 @@ static struct keywords_to_function { .cmd_func_offset = offsetof(struct ethsw_command_func, port_ingr_filt_set), .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_aggr, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = _port_aggr_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_aggr, + ethsw_id_help, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = _port_aggr_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_aggr, + ethsw_id_show, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_aggr_show), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_aggr, + ethsw_id_aggr_no, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_aggr_set), + .keyword_function = NULL, }, }; @@ -576,6 +620,9 @@ static int keyword_match_pvid(enum ethsw_keyword_id key_id, int argc, static int keyword_match_mac_addr(enum ethsw_keyword_id key_id, int argc, char *const argv[], int *argc_nr, struct ethsw_command_def *parsed_cmd); +static int keyword_match_aggr(enum ethsw_keyword_id key_id, int argc, + char *const argv[], int *argc_nr, + struct ethsw_command_def *parsed_cmd); /* * Define properties for each keyword; @@ -661,6 +708,9 @@ struct keyword_def { }, { .keyword_name = "filtering", .match = _match_gen, + }, { + .keyword_name = "aggr", + .match = _match_aggr, }, }; @@ -826,6 +876,28 @@ static int keyword_match_mac_addr(enum ethsw_keyword_id key_id, int argc, return 1; } +/* Function used to match the command's aggregation number */ +static int keyword_match_aggr(enum ethsw_keyword_id key_id, int argc, + char *const argv[], int *argc_nr, + struct ethsw_command_def *parsed_cmd) +{ + unsigned long val; + + if (!keyword_match_gen(key_id, argc, argv, argc_nr, parsed_cmd)) + return 0; + + if (*argc_nr + 1 >= argc) + return
[U-Boot] [PATCH 1/5] drivers: net: vsc9953: Fix number of reserved registers
There are only 21 registers reserved between ana_ana and ana_pgid register groups. Signed-off-by: Codrin Ciubotariu <codrin.ciubota...@freescale.com> --- include/vsc9953.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/vsc9953.h b/include/vsc9953.h index cd5cfc7..00aa222 100644 --- a/include/vsc9953.h +++ b/include/vsc9953.h @@ -269,7 +269,7 @@ struct vsc9953_analyzer { struct vsc9953_ana_ana_tables ana_tables; u32 reserved2[14]; struct vsc9953_ana_ana ana; - u32 reserved3[22]; + u32 reserved3[21]; struct vsc9953_ana_pgid port_id_tbl; u32 reserved4[549]; struct vsc9953_ana_pfc pfc[10]; -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 4/5] common: cmd_ethsw: Spelling fixes
Signed-off-by: Codrin Ciubotariu <codrin.ciubota...@freescale.com> --- common/cmd_ethsw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/cmd_ethsw.c b/common/cmd_ethsw.c index 8e452e9..a5ed555 100644 --- a/common/cmd_ethsw.c +++ b/common/cmd_ethsw.c @@ -71,7 +71,7 @@ static int ethsw_vlan_help_key_func(struct ethsw_command_def *parsed_cmd) #define ETHSW_PORT_UNTAG_HELP "ethsw [port ] untagged " \ "{ [help] | show | all | none | pvid } " \ -" - set egress tagging mod for a port" +" - set egress tagging mode for a port" static int ethsw_port_untag_help_key_func(struct ethsw_command_def *parsed_cmd) { @@ -1010,7 +1010,7 @@ static int do_ethsw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #define ETHSW_PORT_CONF_HELP "[port ] { enable | disable | show } " \ -"- enable/disable a port; show shows a port's configuration" +"- enable/disable a port; show a port's configuration" U_BOOT_CMD(ethsw, ETHSW_MAX_CMD_PARAMS, 0, do_ethsw, "Ethernet l2 switch commands", -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] T104xD4RDB: Fix PHY address for PHY connected to FM1@DTSEC3
On T1040D4RDB board, u-boot fails to connect port FM1@DTSEC3 to the Ethernet PHY because the wrong PHY address is used. Also, T1040D4RDB supports SGMII on one port only. Signed-off-by: Codrin Ciubotariu <codrin.ciubota...@freescale.com> --- include/configs/T104xRDB.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/configs/T104xRDB.h b/include/configs/T104xRDB.h index 5b61b56..e872507 100644 --- a/include/configs/T104xRDB.h +++ b/include/configs/T104xRDB.h @@ -742,7 +742,9 @@ $(SRCTREE)/board/freescale/t104xrdb/t1042d4_rcw.cfg #ifdef CONFIG_FMAN_ENET #if defined(CONFIG_T1040RDB) || defined(CONFIG_T1042RDB) #define CONFIG_SYS_SGMII1_PHY_ADDR 0x03 -#elif defined(CONFIG_T1040D4RDB) || defined(CONFIG_T1042D4RDB) +#elif defined(CONFIG_T1040D4RDB) +#define CONFIG_SYS_SGMII1_PHY_ADDR 0x01 +#elif defined(CONFIG_T1042D4RDB) #define CONFIG_SYS_SGMII1_PHY_ADDR 0x02 #define CONFIG_SYS_SGMII2_PHY_ADDR 0x03 #define CONFIG_SYS_SGMII3_PHY_ADDR 0x01 -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 12/16] drivers/net/vsc9953: Add commands to manipulate the FDB for VSC9953
The new command: ethsw [port ] [vlan ] fdb { [help] | show | flush | { add | del } } Can be used to add and delete FDB entries. Also, the command can be used to show entries from the FDB tables. When used with [port ] and [vlan ], only the matching the FDB entries can be seen or flushed. The command has also been added to the generic ethsw parser from cmd_ethsw.c. Signed-off-by: Johnson Leung <johnson.le...@freescale.com> Signed-off-by: Codrin Ciubotariu <codrin.ciubota...@freescale.com> --- Changes for v2: - removed Change-id field; Changes for v3: - replaced values returned by functions called by the parser with CMD_RET_* macros; - removed "CONFIG_" from macros added in vsc9953.h; - each variabled is declared on a separate line, with one space instead of tab(s); - vsc9953_mac_table_poll_idle() returns -EBUSY if the table is not idle; - the array used to hold the MAC address (mac_addr) has been renamed to ethaddr and is allocated statically instead of dynamically; - reformulate definition of VSC9953_FDB_HELP macro; - used the function added by previous patch to check if a string has the format of a MAC address; Changes for v4: - eth_validate_ethaddr_str() is now declared in include/env_flags.h instead of include/net.h so we have to include net.h instead of env_flags.h; common/cmd_ethsw.c| 178 +++ drivers/net/vsc9953.c | 472 ++ include/ethsw.h | 15 ++ include/vsc9953.h | 28 +++ 4 files changed, 693 insertions(+) diff --git a/common/cmd_ethsw.c b/common/cmd_ethsw.c index 0344da8..d33c78d 100644 --- a/common/cmd_ethsw.c +++ b/common/cmd_ethsw.c @@ -9,6 +9,7 @@ #include #include #include +#include #include static const char *ethsw_name; @@ -34,6 +35,18 @@ static int ethsw_learn_help_key_func(struct ethsw_command_def *parsed_cmd) return CMD_RET_SUCCESS; } +#define ETHSW_FDB_HELP "ethsw [port ] [vlan ] fdb " \ +"{ [help] | show | flush | { add | del } } " \ +"- Add/delete a mac entry in FDB; use show to see FDB entries; " \ +"if vlan is missing, VID 1 will be used" + +static int ethsw_fdb_help_key_func(struct ethsw_command_def *parsed_cmd) +{ + printf(ETHSW_FDB_HELP"\n"); + + return CMD_RET_SUCCESS; +} + static struct keywords_to_function { enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS]; int cmd_func_offset; @@ -130,6 +143,59 @@ static struct keywords_to_function { .cmd_func_offset = offsetof(struct ethsw_command_func, port_learn), .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_fdb, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = _fdb_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_fdb, + ethsw_id_help, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = _fdb_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_fdb, + ethsw_id_show, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + fdb_show), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_fdb, + ethsw_id_flush, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + fdb_flush), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_fdb, + ethsw_id_add, + ethsw_id_add_del_mac, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + fdb_entry_add), + .keyword_function = NULL, + }, { +
[U-Boot] [PATCH v4 11/16] common/env_flags.c: Add function to validate a MAC address
The code that checks if a string has the format of a MAC address has been moved to a separate function called eth_validate_ethaddr_str(). This has been done to allow other components (such as vsc9953 driver) to validate a MAC address. Signed-off-by: Codrin Ciubotariu <codrin.ciubota...@freescale.com> --- Changes for v3: - none, new patch; Changes for v4: - function eth_validate_ethaddr_str() has been moved to common/env_flags.c and its header to include/env_flags.h; - patch desription updated; common/env_flags.c | 40 +++- include/env_flags.h | 7 +++ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/common/env_flags.c b/common/env_flags.c index 5189f5b..e682d85 100644 --- a/common/env_flags.c +++ b/common/env_flags.c @@ -187,6 +187,31 @@ static void skip_num(int hex, const char *value, const char **end, *end = value; } +#ifdef CONFIG_CMD_NET +int eth_validate_ethaddr_str(const char *addr) +{ + const char *end; + const char *cur; + int i; + + cur = addr; + for (i = 0; i < 6; i++) { + skip_num(1, cur, , 2); + if (cur == end) + return -1; + if (cur + 2 == end && is_hex_prefix(cur)) + return -1; + if (i != 5 && *end != ':') + return -1; + if (i == 5 && *end != '\0') + return -1; + cur = end + 1; + } + + return 0; +} +#endif + /* * Based on the declared type enum, validate that the value string complies * with that format @@ -239,19 +264,8 @@ static int _env_flags_validate_type(const char *value, } break; case env_flags_vartype_macaddr: - cur = value; - for (i = 0; i < 6; i++) { - skip_num(1, cur, , 2); - if (cur == end) - return -1; - if (cur + 2 == end && is_hex_prefix(cur)) - return -1; - if (i != 5 && *end != ':') - return -1; - if (i == 5 && *end != '\0') - return -1; - cur = end + 1; - } + if (eth_validate_ethaddr_str(value)) + return -1; break; #endif case env_flags_vartype_end: diff --git a/include/env_flags.h b/include/env_flags.h index 2d2de88..8823fb9 100644 --- a/include/env_flags.h +++ b/include/env_flags.h @@ -109,6 +109,13 @@ enum env_flags_varaccess env_flags_parse_varaccess(const char *flags); */ enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags); +#ifdef CONFIG_CMD_NET +/* + * Check if a string has the format of an Ethernet MAC address + */ +int eth_validate_ethaddr_str(const char *addr); +#endif + #ifdef USE_HOSTCC /* * Look up the type of a variable directly from the .flags var. -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 02/16] drivers/net/vsc9953: Cleanup patch
This patch groups some macros defined for registers and replaces some magic numbers from vsc9953 with macros. Also, port and port_nr words are replaced with port_no, puts each variable declaration on a line and removes unnecessary tabs. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; Changes for v3: - each variable is declared on a separate line, without using tabs - some functions return macros from errno.h insted of 1 or -1 - removed duplicate of macro CONFIG_VSC9953_PAUSE_CFG - code that fixed a small bug was moved in a new patch; drivers/net/vsc9953.c | 144 +- include/vsc9953.h | 121 ++ 2 files changed, 147 insertions(+), 118 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 068ab86..524b979 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -10,6 +10,8 @@ #include asm/fsl_serdes.h #include fm_eth.h #include fsl_memac.h +#include errno.h +#include malloc.h #include vsc9953.h static struct vsc9953_info vsc9953_l2sw = { @@ -25,50 +27,50 @@ static struct vsc9953_info vsc9953_l2sw = { .port[9] = VSC9953_PORT_INFO_INITIALIZER(9), }; -void vsc9953_port_info_set_mdio(int port, struct mii_dev *bus) +void vsc9953_port_info_set_mdio(int port_no, struct mii_dev *bus) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].bus = bus; + vsc9953_l2sw.port[port_no].bus = bus; } -void vsc9953_port_info_set_phy_address(int port, int address) +void vsc9953_port_info_set_phy_address(int port_no, int address) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].phyaddr = address; + vsc9953_l2sw.port[port_no].phyaddr = address; } -void vsc9953_port_info_set_phy_int(int port, phy_interface_t phy_int) +void vsc9953_port_info_set_phy_int(int port_no, phy_interface_t phy_int) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enet_if = phy_int; + vsc9953_l2sw.port[port_no].enet_if = phy_int; } -void vsc9953_port_enable(int port) +void vsc9953_port_enable(int port_no) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enabled = 1; + vsc9953_l2sw.port[port_no].enabled = 1; } -void vsc9953_port_disable(int port) +void vsc9953_port_disable(int port_no) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enabled = 0; + vsc9953_l2sw.port[port_no].enabled = 0; } static void vsc9953_mdio_write(struct vsc9953_mii_mng *phyregs, int port_addr, int regnum, int value) { - int timeout = 5; + int timeout = 5; out_le32(phyregs-miimcmd, (0x1 31) | ((port_addr 0x1f) 25) | ((regnum 0x1f) 20) | ((value 0x) 4) | @@ -85,8 +87,8 @@ static void vsc9953_mdio_write(struct vsc9953_mii_mng *phyregs, int port_addr, static int vsc9953_mdio_read(struct vsc9953_mii_mng *phyregs, int port_addr, int regnum) { - int value = 0x; - int timeout = 5; + int value = 0x; + int timeout = 5; while ((in_le32(phyregs-miimstatus) MIIMIND_OPR_PEND) --timeout) udelay(1); @@ -120,8 +122,8 @@ static int vsc9953_mdio_read(struct vsc9953_mii_mng *phyregs, int port_addr, static int init_phy(struct eth_device *dev) { - struct vsc9953_port_info*l2sw_port = dev-priv; - struct phy_device *phydev = NULL; + struct vsc9953_port_info *l2sw_port = dev-priv; + struct phy_device *phydev = NULL; #ifdef CONFIG_PHYLIB if (!l2sw_port-bus) @@ -148,21 +150,21 @@ static int init_phy(struct eth_device *dev) return 0; } -static int vsc9953_port_init(int port) +static int vsc9953_port_init(int port_no) { - struct eth_device *dev; + struct eth_device *dev; /* Internal ports never have a PHY */ - if (VSC9953_INTERNAL_PORT_CHECK(port)) + if (VSC9953_INTERNAL_PORT_CHECK(port_no)) return 0; /* alloc eth device */ dev = (struct eth_device *)calloc(1, sizeof(struct eth_device)); if (!dev) - return 1; + return -ENOMEM; - sprintf(dev-name, SW@PORT%d, port); - dev-priv = vsc9953_l2sw.port[port]; + sprintf(dev-name, SW@PORT%d, port_no); + dev-priv = vsc9953_l2sw.port[port_no]; dev-init = NULL; dev-halt
[U-Boot] [PATCH v3 01/16] drivers/net/vsc9953: Remove 'CONFIG_' from macros' name
Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v3: - none; new patch; drivers/net/vsc9953.c | 38 +++--- include/vsc9953.h | 46 +++--- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index fed7358..068ab86 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -202,26 +202,26 @@ void vsc9953_init(bd_t *bis) VSC9953_DEVCPU_GCB); out_le32(l2dev_gcb-chip_regs.soft_rst, -CONFIG_VSC9953_SOFT_SWC_RST_ENA); +VSC9953_SOFT_SWC_RST_ENA); timeout = 5; while ((in_le32(l2dev_gcb-chip_regs.soft_rst) - CONFIG_VSC9953_SOFT_SWC_RST_ENA) --timeout) + VSC9953_SOFT_SWC_RST_ENA) --timeout) udelay(1); /* busy wait for vsc9953 soft reset */ if (timeout == 0) debug(Timeout waiting for VSC9953 to reset\n); - out_le32(l2sys_reg-sys.reset_cfg, CONFIG_VSC9953_MEM_ENABLE | -CONFIG_VSC9953_MEM_INIT); + out_le32(l2sys_reg-sys.reset_cfg, VSC9953_MEM_ENABLE | +VSC9953_MEM_INIT); timeout = 5; while ((in_le32(l2sys_reg-sys.reset_cfg) - CONFIG_VSC9953_MEM_INIT) --timeout) + VSC9953_MEM_INIT) --timeout) udelay(1); /* busy wait for vsc9953 memory init */ if (timeout == 0) debug(Timeout waiting for VSC9953 memory to initialize\n); out_le32(l2sys_reg-sys.reset_cfg, (in_le32(l2sys_reg-sys.reset_cfg) - | CONFIG_VSC9953_CORE_ENABLE)); + | VSC9953_CORE_ENABLE)); /* VSC9953 Setting to be done once only */ out_le32(l2qsys_reg-sys.ext_cpu_cfg, 0x0b00); @@ -233,34 +233,34 @@ void vsc9953_init(bd_t *bis) /* Enable VSC9953 GMII Ports Port ID 0 - 7 */ if (VSC9953_INTERNAL_PORT_CHECK(i)) { out_le32(l2ana_reg-pfc[i].pfc_cfg, -CONFIG_VSC9953_PFC_FC_QSGMII); +VSC9953_PFC_FC_QSGMII); out_le32(l2sys_reg-pause_cfg.mac_fc_cfg[i], -CONFIG_VSC9953_MAC_FC_CFG_QSGMII); +VSC9953_MAC_FC_CFG_QSGMII); } else { out_le32(l2ana_reg-pfc[i].pfc_cfg, -CONFIG_VSC9953_PFC_FC); +VSC9953_PFC_FC); out_le32(l2sys_reg-pause_cfg.mac_fc_cfg[i], -CONFIG_VSC9953_MAC_FC_CFG); +VSC9953_MAC_FC_CFG); } out_le32(l2dev_gmii_reg-port_mode.clock_cfg, -CONFIG_VSC9953_CLOCK_CFG); +VSC9953_CLOCK_CFG); out_le32(l2dev_gmii_reg-mac_cfg_status.mac_ena_cfg, -CONFIG_VSC9953_MAC_ENA_CFG); +VSC9953_MAC_ENA_CFG); out_le32(l2dev_gmii_reg-mac_cfg_status.mac_mode_cfg, -CONFIG_VSC9953_MAC_MODE_CFG); +VSC9953_MAC_MODE_CFG); out_le32(l2dev_gmii_reg-mac_cfg_status.mac_ifg_cfg, -CONFIG_VSC9953_MAC_IFG_CFG); +VSC9953_MAC_IFG_CFG); /* mac_hdx_cfg varies with port id*/ - hdx_cfg = (CONFIG_VSC9953_MAC_HDX_CFG | (i 16)); + hdx_cfg = VSC9953_MAC_HDX_CFG | (i 16); out_le32(l2dev_gmii_reg-mac_cfg_status.mac_hdx_cfg, hdx_cfg); out_le32(l2sys_reg-sys.front_port_mode[i], -CONFIG_VSC9953_FRONT_PORT_MODE); +VSC9953_FRONT_PORT_MODE); out_le32(l2qsys_reg-sys.switch_port_mode[i], -CONFIG_VSC9953_PORT_ENA); +VSC9953_PORT_ENA); out_le32(l2dev_gmii_reg-mac_cfg_status.mac_maxlen_cfg, -CONFIG_VSC9953_MAC_MAX_LEN); +VSC9953_MAC_MAX_LEN); out_le32(l2sys_reg-pause_cfg.pause_cfg[i], -CONFIG_VSC9953_PAUSE_CFG); +VSC9953_PAUSE_CFG); /* WAIT FOR 2 us*/ udelay(2); diff --git a/include/vsc9953.h b/include/vsc9953.h index 3d11b87..3f14dad 100644 --- a/include/vsc9953.h +++ b/include/vsc9953.h @@ -33,29 +33,29 @@ #define T1040_SWITCH_GMII_DEV_OFFSET 0x01 #define VSC9953_PHY_REGS_OFFST 0xAC -#define CONFIG_VSC9953_SOFT_SWC_RST_ENA0x0001 -#define CONFIG_VSC9953_CORE_ENABLE 0x80 -#define CONFIG_VSC9953_MEM_ENABLE 0x40 -#define CONFIG_VSC9953_MEM_INIT0x20 - -#define CONFIG_VSC9953_PORT_ENA0x3a00
[U-Boot] [PATCH] include/bitfield.h: Assure new bitfield value doesn't touch unwanted bits
The new bitfield value must not be higher than its mask. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- include/bitfield.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bitfield.h b/include/bitfield.h index cffaf7a..a59f3c2 100644 --- a/include/bitfield.h +++ b/include/bitfield.h @@ -60,7 +60,7 @@ static inline uint bitfield_replace(uint reg_val, uint shift, uint width, { uint mask = bitfield_mask(shift, width); - return (reg_val ~mask) | (bitfield_val shift); + return (reg_val ~mask) | ((bitfield_val shift) mask); } /* Produces a shift of the bitfield given a mask */ -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 03/16] drivers/net/vsc9953: Fix bug when enabling a port
When a port is enabled at init time, the initializing function touches more bits than necessary to enable a port (also touches reserved bits and default bit values). This patch fixes this issue by changing the value of the define used to enable the port and assures that no other bits are changes by replacing out_le32() with setbits_le32(). Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Dhanges for v3: - none; new patch; drivers/net/vsc9953.c | 4 ++-- include/vsc9953.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 524b979..2e8eec4 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -259,8 +259,8 @@ void vsc9953_init(bd_t *bis) out_le32(l2dev_gmii_reg-mac_cfg_status.mac_hdx_cfg, hdx_cfg); out_le32(l2sys_reg-sys.front_port_mode[i], VSC9953_FRONT_PORT_MODE); - out_le32(l2qsys_reg-sys.switch_port_mode[i], -VSC9953_PORT_ENA); + setbits_le32(l2qsys_reg-sys.switch_port_mode[i], +VSC9953_PORT_ENA); out_le32(l2dev_gmii_reg-mac_cfg_status.mac_maxlen_cfg, VSC9953_MAC_MAX_LEN); out_le32(l2sys_reg-pause_cfg.pause_cfg[i], diff --git a/include/vsc9953.h b/include/vsc9953.h index 6ebe141..6ae5fec 100644 --- a/include/vsc9953.h +++ b/include/vsc9953.h @@ -81,7 +81,7 @@ #define VSC9953_VCAP_UPDATE_CTRL 0x0104 /* Macros for vsc9953_qsys_sys.switch_port_mode register */ -#define VSC9953_PORT_ENA 0x3a00 +#define VSC9953_PORT_ENA 0x2000 #define VSC9953_MAX_PORTS 10 #define VSC9953_PORT_CHECK(port) \ -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 05/16] include/bitfield: Add new bitfield operations
These new operations allow manipulation of bitfields within a word by using a mask instead of width and shift values to extract/replace the bitfields. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v3: - none; new patch; include/bitfield.h | 32 1 file changed, 32 insertions(+) diff --git a/include/bitfield.h b/include/bitfield.h index ec4815c..cffaf7a 100644 --- a/include/bitfield.h +++ b/include/bitfield.h @@ -27,6 +27,12 @@ * old = bitfield_extract(old_reg_val, 10, 5); * new_reg_val = bitfield_replace(old_reg_val, 10, 5, new); * + * or + * + * mask = bitfield_mask(10, 5); + * old = bitfield_extract_by_mask(old_reg_val, mask); + * new_reg_val = bitfield_replace_by_mask(old_reg_val, mask, new); + * * The numbers 10 and 5 could for example come from data * tables which describe all bitfields in all registers. */ @@ -56,3 +62,29 @@ static inline uint bitfield_replace(uint reg_val, uint shift, uint width, return (reg_val ~mask) | (bitfield_val shift); } + +/* Produces a shift of the bitfield given a mask */ +static inline uint bitfield_shift(uint mask) +{ + return mask ? ffs(mask) - 1 : 0; +} + +/* Extract the value of a bitfield found within a given register value */ +static inline uint bitfield_extract_by_mask(uint reg_val, uint mask) +{ + uint shift = bitfield_shift(mask); + + return (reg_val mask) shift; +} + +/* + * Replace the value of a bitfield found within a given register value + * Returns the newly modified uint value with the replaced field. + */ +static inline uint bitfield_replace_by_mask(uint reg_val, uint mask, + uint bitfield_val) +{ + uint shift = bitfield_shift(mask); + + return (reg_val ~mask) | ((bitfield_val shift) mask); +} -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 04/16] drivers/net/vsc9953: Fix missing reserved register
The VSC9953 DS reserves a register between vlan_mask and anag_efil registers. Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; Changes for v3: - added signature; include/vsc9953.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/vsc9953.h b/include/vsc9953.h index 6ae5fec..8ff02c1 100644 --- a/include/vsc9953.h +++ b/include/vsc9953.h @@ -143,6 +143,7 @@ struct vsc9953_ana_ana_tables { struct vsc9953_ana_ana { u32 adv_learn; u32 vlan_mask; + u32 reserved; u32 anag_efil; u32 an_events; u32 storm_limit_burst; -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 09/16] drivers/net/vsc9953: Add command to show/clear port counters
The new added command: ethsw [port port_no] statistics { [help] | [clear] } will print counters like the number of Rx/Tx frames, number of Rx/Tx bytes, number of Rx/Tx unicast frames, etc. This patch also adds this commnd in the genereric ethsw parser from cmd_ethsw.c Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; Changes for v3: - moved each variable declaration on a separate line, with one space only; - replaced magic numbers on functions called by the parser with CMD_RET_* macros; common/cmd_ethsw.c| 42 + drivers/net/vsc9953.c | 256 ++ include/ethsw.h | 4 + include/vsc9953.h | 116 ++- 4 files changed, 415 insertions(+), 3 deletions(-) diff --git a/common/cmd_ethsw.c b/common/cmd_ethsw.c index ebeaae0..57df603 100644 --- a/common/cmd_ethsw.c +++ b/common/cmd_ethsw.c @@ -13,6 +13,16 @@ static const char *ethsw_name; +#define ETHSW_PORT_STATS_HELP ethsw [port port_no] statistics \ +{ [help] | [clear] } - show an l2 switch port's statistics + +static int ethsw_port_stats_help_key_func(struct ethsw_command_def *parsed_cmd) +{ + printf(ETHSW_PORT_STATS_HELP\n); + + return CMD_RET_SUCCESS; +} + static struct keywords_to_function { enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS]; int cmd_func_offset; @@ -42,6 +52,31 @@ static struct keywords_to_function { .cmd_func_offset = offsetof(struct ethsw_command_func, port_show), .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_statistics, + ethsw_id_help, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = ethsw_port_stats_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_statistics, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_stats), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_statistics, + ethsw_id_clear, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_stats_clear), + .keyword_function = NULL, }, }; @@ -88,6 +123,12 @@ struct keyword_def { }, { .keyword_name = disable, .match = keyword_match_gen, + }, { + .keyword_name = statistics, + .match = keyword_match_gen, + }, { + .keyword_name = clear, + .match = keyword_match_gen, }, }; @@ -343,4 +384,5 @@ static int do_ethsw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) U_BOOT_CMD(ethsw, ETHSW_MAX_CMD_PARAMS, 0, do_ethsw, Ethernet l2 switch commands, ETHSW_PORT_CONF_HELP\n + ETHSW_PORT_STATS_HELP\n ); diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index bf53535..1dddb44 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -500,6 +500,223 @@ static void vsc9953_port_config_show(int port_no) printf(%8s\n, duplex == DUPLEX_FULL ? full : half); } +/* Show VSC9953 ports' statistics */ +static void vsc9953_port_statistics_show(int port_no) +{ + u32 rx_val; + u32 tx_val; + struct vsc9953_system_reg *l2sys_reg; + + /* Administrative down */ + if (!vsc9953_l2sw.port[port_no].enabled) { + printf(Port %d is administrative down\n, port_no); + return; + } + + l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET + + VSC9953_SYS_OFFSET); + + printf(Statistics for L2 Switch port %d:\n, port_no); + + /* Set counter view for our port */ + out_le32(l2sys_reg-sys.stat_cfg, port_no); + +#define VSC9953_STATS_PRINTF %-15s %10u + + /* Get number of Rx and Tx frames */ + rx_val = in_le32(l2sys_reg-stat.rx_cntrs.c_rx_short) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_frag) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_jabber) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_long
[U-Boot] [PATCH v3 07/16] common/cmd_ethsw: Add generic commands for Ethernet Switches
This patch creates a flexible parser for Ethernet Switch configurations that should support complex commands. The parser searches for predefined keywords in the command and calls the proper function when a match is found. Also, the parser allows for optional keywords, such as port, to apply the command on a port or on all ports. For now, the defined commands are: ethsw [port port_no] { enable | disable | show } Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v3: - parser removed from previous patch: drivers/net/vsc9953: Refractor the parser for VSC9953 commands; - removed member err from struct command_def; - using CMD_RET_* macros instead of magic numbers; - moved each variable declaration on a separate line, with a single space; - the code from functions cmd_keywords*_check() should be more clear now; - removed unused function command_def_cleanup(); common/Makefile| 1 + common/cmd_ethsw.c | 346 + include/ethsw.h| 48 3 files changed, 395 insertions(+) create mode 100644 common/cmd_ethsw.c create mode 100644 include/ethsw.h diff --git a/common/Makefile b/common/Makefile index d6c1d48..f0b4eec 100644 --- a/common/Makefile +++ b/common/Makefile @@ -211,6 +211,7 @@ obj-$(CONFIG_UPDATE_TFTP) += update.o obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o obj-$(CONFIG_CMD_DFU) += cmd_dfu.o obj-$(CONFIG_CMD_GPT) += cmd_gpt.o +obj-$(CONFIG_CMD_ETHSW) += cmd_ethsw.o # Power obj-$(CONFIG_CMD_PMIC) += cmd_pmic.o diff --git a/common/cmd_ethsw.c b/common/cmd_ethsw.c new file mode 100644 index 000..ebeaae0 --- /dev/null +++ b/common/cmd_ethsw.c @@ -0,0 +1,346 @@ +/* + * Copyright 2015 Freescale Semiconductor, Inc. + * + * SPDX-License-Identifier: GPL-2.0+ + * + * Ethernet Switch commands + */ + +#include common.h +#include command.h +#include errno.h +#include ethsw.h + +static const char *ethsw_name; + +static struct keywords_to_function { + enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS]; + int cmd_func_offset; + int (*keyword_function)(struct ethsw_command_def *parsed_cmd); +} ethsw_cmd_def[] = { + { + .cmd_keyword = { + ethsw_id_enable, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_enable), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_disable, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_disable), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_show, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_show), + .keyword_function = NULL, + }, +}; + +struct keywords_optional { + int cmd_keyword[ETHSW_MAX_CMD_PARAMS]; +} cmd_opt_def[] = { + { + .cmd_keyword = { + ethsw_id_port, + ethsw_id_port_no, + ethsw_id_key_end, + }, + }, +}; + +static int keyword_match_gen(enum ethsw_keyword_id key_id, int argc, char +*const argv[], int *argc_nr, +struct ethsw_command_def *parsed_cmd); +static int keyword_match_port(enum ethsw_keyword_id key_id, int argc, + char *const argv[], int *argc_nr, + struct ethsw_command_def *parsed_cmd); + +/* + * Define properties for each keyword; + * keep the order synced with enum ethsw_keyword_id + */ +struct keyword_def { + const char *keyword_name; + int (*match)(enum ethsw_keyword_id key_id, int argc, char *const argv[], +int *argc_nr, struct ethsw_command_def *parsed_cmd); +} keyword[] = { + { + .keyword_name = help, + .match = keyword_match_gen, + }, { + .keyword_name = show, + .match = keyword_match_gen, + }, { + .keyword_name = port, + .match = keyword_match_port
[U-Boot] [PATCH v3 06/16] drivers/net/vsc9953: Add default configuration for VSC9953 L2 Switch
At startup, the default configuration should be: - enable HW learning on all ports (HW default); - all ports are VLAN aware; - all ports are members of VLAN 1; - all ports have Port-based VLAN 1; - on all ports, the switch is allowed to remove maximum one VLAN tag, - on egress, the switch should add a VLAN tag if the frame is classified to a different VLAN than the port's Port-based VLAN; Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; Changes for v3: - moved the copyright update in the last patch; - return -EBUSY if the VLAN table is not ready; - each variable is declared on a new line, without tabs; - renamed variable set to set_member; - removed unnecessary brackets; - renamed some VSC9953_TAG_CFG_* macros; - removed field_set() and field_get() macros; - removed CONFIG_ from some macros' name; - removed port_' from members of struct vsc9953_rew_port; - modified a comment describing struct vsc9953_rew_reg; drivers/net/vsc9953.c | 253 ++ include/vsc9953.h | 56 +++ 2 files changed, 309 insertions(+) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 2e8eec4..59e0fab 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -10,6 +10,7 @@ #include asm/fsl_serdes.h #include fm_eth.h #include fsl_memac.h +#include bitfield.h #include errno.h #include malloc.h #include vsc9953.h @@ -178,6 +179,256 @@ static int vsc9953_port_init(int port_no) return 0; } +static int vsc9953_vlan_table_poll_idle(void) +{ + struct vsc9953_analyzer *l2ana_reg; + int timeout; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + timeout = 5; + while (((in_le32(l2ana_reg-ana_tables.vlan_access) +VSC9953_VLAN_CMD_MASK) != VSC9953_VLAN_CMD_IDLE) --timeout) + udelay(1); + + return timeout ? 0 : -EBUSY; +} + +/* vlan table set/clear all membership of vid */ +static void vsc9953_vlan_table_membership_all_set(int vid, int set_member) +{ + uint val; + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + if (vsc9953_vlan_table_poll_idle() 0) { + debug(VLAN table timeout\n); + return; + } + + /* read current vlan configuration */ + val = in_le32(l2ana_reg-ana_tables.vlan_tidx); + out_le32(l2ana_reg-ana_tables.vlan_tidx, +bitfield_replace_by_mask(val, VSC9953_ANA_TBL_VID_MASK, vid)); + + clrsetbits_le32(l2ana_reg-ana_tables.vlan_access, + VSC9953_VLAN_CMD_MASK, VSC9953_VLAN_CMD_READ); + + if (vsc9953_vlan_table_poll_idle() 0) { + debug(VLAN table timeout\n); + return; + } + + val = in_le32(l2ana_reg-ana_tables.vlan_tidx); + out_le32(l2ana_reg-ana_tables.vlan_tidx, +bitfield_replace_by_mask(val, VSC9953_ANA_TBL_VID_MASK, vid)); + + clrsetbits_le32(l2ana_reg-ana_tables.vlan_access, + VSC9953_VLAN_PORT_MASK | VSC9953_VLAN_CMD_MASK, + VSC9953_VLAN_CMD_WRITE | + (set_member ? VSC9953_VLAN_PORT_MASK : 0)); +} + +/* Set PVID for a VSC9953 port */ +static void vsc9953_port_vlan_pvid_set(int port_no, int pvid) +{ + uint val; + struct vsc9953_analyzer *l2ana_reg; + struct vsc9953_rew_reg *l2rew_reg; + + /* Administrative down */ + if (!vsc9953_l2sw.port[port_no].enabled) { + printf(Port %d is administrative down\n, port_no); + return; + } + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + l2rew_reg = (struct vsc9953_rew_reg *)(VSC9953_OFFSET + + VSC9953_REW_OFFSET); + + /* Set PVID on ingress */ + val = in_le32(l2ana_reg-port[port_no].vlan_cfg); + val = bitfield_replace_by_mask(val, VSC9953_VLAN_CFG_VID_MASK, pvid); + out_le32(l2ana_reg-port[port_no].vlan_cfg, val); + + /* Set PVID on egress */ + val = in_le32(l2rew_reg-port[port_no].port_vlan_cfg); + val = bitfield_replace_by_mask(val, VSC9953_PORT_VLAN_CFG_VID_MASK, + pvid); + out_le32(l2rew_reg-port[port_no].port_vlan_cfg, val); +} + +static void vsc9953_port_all_vlan_pvid_set(int pvid) +{ + int i; + + for (i = 0; i VSC9953_MAX_PORTS; i++) + vsc9953_port_vlan_pvid_set(i, pvid); +} + +/* Enable/disable vlan aware of a VSC9953 port */ +static void vsc9953_port_vlan_aware_set(int port_no, int enabled) +{ + struct vsc9953_analyzer
[U-Boot] [PATCH v3 08/16] drivers/net/vsc9953: Use the generic Ethernet Switch parser
This patch replaces the parser used by VSC9953 L2 Switch driver with the generic one. Also, the config macro that enables the VSC9953 commands has been replaced in all the platforms that use this driver with the config macro that corresponds to the generic parser. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v3: - this patch was extracted from previous patch: drivers/net/vsc9953: Refractor the parser for VSC9953 commands; - used CMD_RET_* macros instead of magic numbers; - each variable is declared on a new line, with one space only; drivers/net/vsc9953.c | 349 + include/configs/T104xRDB.h | 2 +- 2 files changed, 166 insertions(+), 185 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 59e0fab..bf53535 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -14,6 +14,7 @@ #include errno.h #include malloc.h #include vsc9953.h +#include ethsw.h static struct vsc9953_info vsc9953_l2sw = { .port[0] = VSC9953_PORT_INFO_INITIALIZER(0), @@ -405,6 +406,165 @@ static void vsc9953_port_all_vlan_egress_untagged_set( vsc9953_port_vlan_egr_untag_set(i, mode); } +#ifdef CONFIG_CMD_ETHSW + +/* Enable/disable status of a VSC9953 port */ +static void vsc9953_port_status_set(int port_no, u8 enabled) +{ + struct vsc9953_qsys_reg *l2qsys_reg; + + /* Administrative down */ + if (!vsc9953_l2sw.port[port_no].enabled) + return; + + l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET + + VSC9953_QSYS_OFFSET); + + if (enabled) + setbits_le32(l2qsys_reg-sys.switch_port_mode[port_no], +VSC9953_PORT_ENA); + else + clrbits_le32(l2qsys_reg-sys.switch_port_mode[port_no], +VSC9953_PORT_ENA); +} + +/* Start autonegotiation for a VSC9953 PHY */ +static void vsc9953_phy_autoneg(int port_no) +{ + if (!vsc9953_l2sw.port[port_no].phydev) + return; + + if (vsc9953_l2sw.port[port_no].phydev-drv-startup( + vsc9953_l2sw.port[port_no].phydev)) + printf(Failed to start PHY for port %d\n, port_no); +} + +/* Print a VSC9953 port's configuration */ +static void vsc9953_port_config_show(int port_no) +{ + int speed; + int duplex; + int link; + u8 enabled; + u32 val; + struct vsc9953_qsys_reg *l2qsys_reg; + + l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET + + VSC9953_QSYS_OFFSET); + + val = in_le32(l2qsys_reg-sys.switch_port_mode[port_no]); + enabled = vsc9953_l2sw.port[port_no].enabled + (val VSC9953_PORT_ENA); + + /* internal ports (8 and 9) are fixed */ + if (VSC9953_INTERNAL_PORT_CHECK(port_no)) { + link = 1; + speed = SPEED_2500; + duplex = DUPLEX_FULL; + } else { + if (vsc9953_l2sw.port[port_no].phydev) { + link = vsc9953_l2sw.port[port_no].phydev-link; + speed = vsc9953_l2sw.port[port_no].phydev-speed; + duplex = vsc9953_l2sw.port[port_no].phydev-duplex; + } else { + link = -1; + speed = -1; + duplex = -1; + } + } + + printf(%8d , port_no); + printf(%8s , enabled == 1 ? enabled : disabled); + printf(%8s , link == 1 ? up : down); + + switch (speed) { + case SPEED_10: + printf(%8d , 10); + break; + case SPEED_100: + printf(%8d , 100); + break; + case SPEED_1000: + printf(%8d , 1000); + break; + case SPEED_2500: + printf(%8d , 2500); + break; + case SPEED_1: + printf(%8d , 1); + break; + default: + printf(%8s , -); + } + + printf(%8s\n, duplex == DUPLEX_FULL ? full : half); +} + +static int vsc9953_port_status_key_func(struct ethsw_command_def *parsed_cmd) +{ + int i; + u8 enabled; + + /* Last keyword should tell us if we should enable/disable the port */ + if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == + ethsw_id_enable) + enabled = 1; + else if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == +ethsw_id_disable) + enabled = 0; + else + return CMD_RET_USAGE; + + if (parsed_cmd-port != ETHSW_CMD_PORT_ALL) { + if (!VSC9953_PORT_CHECK(parsed_cmd-port)) { + printf(Invalid port number: %d\n, parsed_cmd-port); + return CMD_RET_FAILURE
[U-Boot] [PATCH v3 13/16] drivers/net/vsc9953: Add VLAN commands for VSC9953
The new added commands can be used to configure VLANs for a port on both ingress and egress. The new commands are: ethsw [port port_no] pvid { [help] | show | pvid } - set/show PVID (ingress and egress VLAN tagging) for a port; ethsw [port port_no] vlan { [help] | show | add vid | del vid } - add a VLAN to a port (VLAN members); ethsw [port port_no] untagged { [help] | show | all | none | pvid } - set egress tagging mod for a port ethsw [port port_no] egress tag { [help] | show | pvid | classified } - Configure VID source for egress tag. Tag's VID could be the frame's classified VID or the PVID of the port These commands have also been added to the ethsw generic parser from common/cmd_ethsw.c Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; Changes for v3: - replaced values returned by functions called by the parser with CMD_RET_* macros; - removed CONFIG_ from macros added in vsc9953.h; - each variabled is declared on a separate line, with one space instead of tab(s); - removed unecessary brackets; - typo fix in comment: Shiw; common/cmd_ethsw.c| 270 drivers/net/vsc9953.c | 478 ++ include/ethsw.h | 16 ++ include/vsc9953.h | 3 + 4 files changed, 767 insertions(+) diff --git a/common/cmd_ethsw.c b/common/cmd_ethsw.c index 0bf852b..8ba202b 100644 --- a/common/cmd_ethsw.c +++ b/common/cmd_ethsw.c @@ -46,6 +46,51 @@ static int ethsw_fdb_help_key_func(struct ethsw_command_def *parsed_cmd) return CMD_RET_SUCCESS; } +#define ETHSW_PVID_HELP ethsw [port port_no] \ +pvid { [help] | show | pvid } \ +- set/show PVID (ingress and egress VLAN tagging) for a port + +static int ethsw_pvid_help_key_func(struct ethsw_command_def *parsed_cmd) +{ + printf(ETHSW_PVID_HELP\n); + + return CMD_RET_SUCCESS; +} + +#define ETHSW_VLAN_HELP ethsw [port port_no] vlan \ +{ [help] | show | add vid | del vid } \ +- add a VLAN to a port (VLAN members) + +static int ethsw_vlan_help_key_func(struct ethsw_command_def *parsed_cmd) +{ + printf(ETHSW_VLAN_HELP\n); + + return CMD_RET_SUCCESS; +} + +#define ETHSW_PORT_UNTAG_HELP ethsw [port port_no] untagged \ +{ [help] | show | all | none | pvid } \ + - set egress tagging mod for a port + +static int ethsw_port_untag_help_key_func(struct ethsw_command_def *parsed_cmd) +{ + printf(ETHSW_PORT_UNTAG_HELP\n); + + return CMD_RET_SUCCESS; +} + +#define ETHSW_EGR_VLAN_TAG_HELP ethsw [port port_no] egress tag \ +{ [help] | show | pvid | classified } \ +- Configure VID source for egress tag. \ +Tag's VID could be the frame's classified VID or the PVID of the port + +static int ethsw_egr_tag_help_key_func(struct ethsw_command_def *parsed_cmd) +{ + printf(ETHSW_EGR_VLAN_TAG_HELP\n); + + return CMD_RET_SUCCESS; +} + static struct keywords_to_function { enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS]; int cmd_func_offset; @@ -195,6 +240,181 @@ static struct keywords_to_function { .cmd_func_offset = offsetof(struct ethsw_command_func, fdb_entry_del), .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_pvid, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = ethsw_pvid_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_pvid, + ethsw_id_help, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = ethsw_pvid_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_pvid, + ethsw_id_show, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + pvid_show), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_pvid, + ethsw_id_pvid_no, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + pvid_set), + .keyword_function = NULL
[U-Boot] [PATCH v3 12/16] drivers/net/vsc9953: Add commands to manipulate the FDB for VSC9953
The new command: ethsw [port port_no] [vlan vid] fdb { [help] | show | flush | { add | del } mac } Can be used to add and delete FDB entries. Also, the command can be used to show entries from the FDB tables. When used with [port port_no] and [vlan vid], only the matching the FDB entries can be seen or flushed. The command has also been added to the generic ethsw parser from cmd_ethsw.c. Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; Changes for v3: - replaced values returned by functions called by the parser with CMD_RET_* macros; - removed CONFIG_ from macros added in vsc9953.h; - each variabled is declared on a separate line, with one space instead of tab(s); - vsc9953_mac_table_poll_idle() returns -EBUSY if the table is not idle; - the array used to hold the MAC address (mac_addr) has been renamed to ethaddr and is allocated statically instead of dynamically; - reformulate definition of VSC9953_FDB_HELP macro; - used the function added by previous patch to check if a string has the format of a MAC address; common/cmd_ethsw.c| 177 +++ drivers/net/vsc9953.c | 473 ++ include/ethsw.h | 15 ++ include/vsc9953.h | 28 +++ 4 files changed, 693 insertions(+) diff --git a/common/cmd_ethsw.c b/common/cmd_ethsw.c index 0344da8..0bf852b 100644 --- a/common/cmd_ethsw.c +++ b/common/cmd_ethsw.c @@ -34,6 +34,18 @@ static int ethsw_learn_help_key_func(struct ethsw_command_def *parsed_cmd) return CMD_RET_SUCCESS; } +#define ETHSW_FDB_HELP ethsw [port port_no] [vlan vid] fdb \ +{ [help] | show | flush | { add | del } mac } \ +- Add/delete a mac entry in FDB; use show to see FDB entries; \ +if vlan vid is missing, VID 1 will be used + +static int ethsw_fdb_help_key_func(struct ethsw_command_def *parsed_cmd) +{ + printf(ETHSW_FDB_HELP\n); + + return CMD_RET_SUCCESS; +} + static struct keywords_to_function { enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS]; int cmd_func_offset; @@ -130,6 +142,59 @@ static struct keywords_to_function { .cmd_func_offset = offsetof(struct ethsw_command_func, port_learn), .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_fdb, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = ethsw_fdb_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_fdb, + ethsw_id_help, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = ethsw_fdb_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_fdb, + ethsw_id_show, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + fdb_show), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_fdb, + ethsw_id_flush, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + fdb_flush), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_fdb, + ethsw_id_add, + ethsw_id_add_del_mac, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + fdb_entry_add), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_fdb, + ethsw_id_del, + ethsw_id_add_del_mac, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func
[U-Boot] [PATCH v3 10/16] drivers/net/vsc9953: Add commands to enable/disable HW learning
The command: ethsw [port port_no] learning { [help] | show | auto | disable } can be used to enable/disable HW learning on a port. This patch also adds this command to the generic ethsw parser from cmd_ethsw. Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; Changes for v3: - replaced values returned by functions called by the parser with CMD_RET_* macros; - removed CONFIG_ from macros added in vsc9953.h; - each variabled is declared on a separate line, with one space instead of tab(s); common/cmd_ethsw.c| 60 + drivers/net/vsc9953.c | 141 ++ include/ethsw.h | 4 ++ include/vsc9953.h | 6 +++ 4 files changed, 211 insertions(+) diff --git a/common/cmd_ethsw.c b/common/cmd_ethsw.c index 57df603..0344da8 100644 --- a/common/cmd_ethsw.c +++ b/common/cmd_ethsw.c @@ -23,6 +23,17 @@ static int ethsw_port_stats_help_key_func(struct ethsw_command_def *parsed_cmd) return CMD_RET_SUCCESS; } +#define ETHSW_LEARN_HELP ethsw [port port_no] learning \ +{ [help] | show | auto | disable } \ +- enable/disable/show learning configuration on a port + +static int ethsw_learn_help_key_func(struct ethsw_command_def *parsed_cmd) +{ + printf(ETHSW_LEARN_HELP\n); + + return CMD_RET_SUCCESS; +} + static struct keywords_to_function { enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS]; int cmd_func_offset; @@ -77,6 +88,48 @@ static struct keywords_to_function { .cmd_func_offset = offsetof(struct ethsw_command_func, port_stats_clear), .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_learning, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = ethsw_learn_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_learning, + ethsw_id_help, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = ethsw_learn_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_learning, + ethsw_id_show, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_learn_show), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_learning, + ethsw_id_auto, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_learn), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_learning, + ethsw_id_disable, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_learn), + .keyword_function = NULL, }, }; @@ -129,6 +182,12 @@ struct keyword_def { }, { .keyword_name = clear, .match = keyword_match_gen, + }, { + .keyword_name = learning, + .match = keyword_match_gen, + }, { + .keyword_name = auto, + .match = keyword_match_gen, }, }; @@ -385,4 +444,5 @@ U_BOOT_CMD(ethsw, ETHSW_MAX_CMD_PARAMS, 0, do_ethsw, Ethernet l2 switch commands, ETHSW_PORT_CONF_HELP\n ETHSW_PORT_STATS_HELP\n + ETHSW_LEARN_HELP\n ); diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 1dddb44..21b14e6 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -717,6 +717,72 @@ static void vsc9953_port_statistics_clear(int port_no) VSC9953_STAT_CLEAR_DR); } +enum port_learn_mode { + PORT_LEARN_NONE, + PORT_LEARN_AUTO +}; + +/* Set
[U-Boot] [PATCH v3 14/16] drivers/net/vsc9953: Add command for shared/private VLAN learning
The command: ethsw vlan fdb { [help] | show | shared | private } - make VLAN learning shared or private configures the FDB to share the FDB entries learned on multiple VLANs or to keep them separated. By default, the FBD uses private VLAN learning. This command has also been added to the ethsw generic parser from common/cmd_ethsw.c Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; Changes for v3: - replaced values returned by functions called by the parser with CMD_RET_* macros; - removed CONFIG_ from macros added in vsc9953.h; - each variabled is declared on a separate line, with one space instead of tab(s); common/cmd_ethsw.c| 65 +++ drivers/net/vsc9953.c | 95 +++ include/ethsw.h | 4 +++ include/vsc9953.h | 3 ++ 4 files changed, 167 insertions(+) diff --git a/common/cmd_ethsw.c b/common/cmd_ethsw.c index 8ba202b..44a7f01 100644 --- a/common/cmd_ethsw.c +++ b/common/cmd_ethsw.c @@ -91,6 +91,17 @@ static int ethsw_egr_tag_help_key_func(struct ethsw_command_def *parsed_cmd) return CMD_RET_SUCCESS; } +#define ETHSW_VLAN_FDB_HELP ethsw vlan fdb \ +{ [help] | show | shared | private } \ +- make VLAN learning shared or private + +static int ethsw_vlan_learn_help_key_func(struct ethsw_command_def *parsed_cmd) +{ + printf(ETHSW_VLAN_FDB_HELP\n); + + return CMD_RET_SUCCESS; +} + static struct keywords_to_function { enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS]; int cmd_func_offset; @@ -415,6 +426,53 @@ static struct keywords_to_function { .cmd_func_offset = offsetof(struct ethsw_command_func, port_egr_vlan_set), .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_vlan, + ethsw_id_fdb, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = ethsw_vlan_learn_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_vlan, + ethsw_id_fdb, + ethsw_id_help, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = ethsw_vlan_learn_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_vlan, + ethsw_id_fdb, + ethsw_id_show, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + vlan_learn_show), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_vlan, + ethsw_id_fdb, + ethsw_id_shared, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + vlan_learn_set), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_vlan, + ethsw_id_fdb, + ethsw_id_private, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + vlan_learn_set), + .keyword_function = NULL, }, }; @@ -532,6 +590,12 @@ struct keyword_def { }, { .keyword_name = classified, .match = keyword_match_gen, + }, { + .keyword_name = shared, + .match = keyword_match_gen, + }, { + .keyword_name = private, + .match = keyword_match_gen, }, }; @@ -892,4 +956,5 @@ U_BOOT_CMD(ethsw, ETHSW_MAX_CMD_PARAMS, 0, do_ethsw, ETHSW_VLAN_HELP\n ETHSW_PORT_UNTAG_HELP\n
[U-Boot] [PATCH v3 16/16] drivers/net/vsc9953: Add GPL-2.0+ SPDX-License-Identifier
Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; Changes for v3: - this patch also includes the Copyright year updates for the modified values; drivers/net/vsc9953.c | 2 +- include/vsc9953.h | 11 +++ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 97c7fa0..f7b865b 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -1,5 +1,5 @@ /* - * Copyright 2014 Freescale Semiconductor, Inc. + * Copyright 2014 - 2015 Freescale Semiconductor, Inc. * * SPDX-License-Identifier: GPL-2.0+ * diff --git a/include/vsc9953.h b/include/vsc9953.h index 24a22a3..cd5cfc7 100644 --- a/include/vsc9953.h +++ b/include/vsc9953.h @@ -1,14 +1,9 @@ /* - * vsc9953.h + * Copyright 2013, 2015 Freescale Semiconductor, Inc. * - * Driver for the Vitesse VSC9953 L2 Switch - * - * This software may be used and distributed according to the - * terms of the GNU Public License, Version 2, incorporated - * herein by reference. - * - * Copyright 2013 Freescale Semiconductor, Inc. + * SPDX-License-Identifier: GPL-2.0+ * + * Driver for the Vitesse VSC9953 L2 Switch */ #ifndef _VSC9953_H_ -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 11/16] net/eth.c: Add function to validate a MAC address
The code from common/env_flags.c that checks if a string has the format of a MAC address has been moved in net/eth.c as a separate function called eth_validate_ethaddr_str(). Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v3: - none, new patch; common/env_flags.c | 15 ++- include/net.h | 1 + net/eth.c | 30 ++ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/common/env_flags.c b/common/env_flags.c index 5189f5b..3e39fd1 100644 --- a/common/env_flags.c +++ b/common/env_flags.c @@ -239,19 +239,8 @@ static int _env_flags_validate_type(const char *value, } break; case env_flags_vartype_macaddr: - cur = value; - for (i = 0; i 6; i++) { - skip_num(1, cur, end, 2); - if (cur == end) - return -1; - if (cur + 2 == end is_hex_prefix(cur)) - return -1; - if (i != 5 *end != ':') - return -1; - if (i == 5 *end != '\0') - return -1; - cur = end + 1; - } + if (eth_validate_ethaddr_str(value)) + return -1; break; #endif case env_flags_vartype_end: diff --git a/include/net.h b/include/net.h index d17173d..c487aa7 100644 --- a/include/net.h +++ b/include/net.h @@ -218,6 +218,7 @@ void eth_try_another(int first_restart);/* Change the device */ void eth_set_current(void);/* set nterface to ethcur var */ int eth_get_dev_index(void); /* get the device index */ +int eth_validate_ethaddr_str(const char *addr); void eth_parse_enetaddr(const char *addr, uchar *enetaddr); int eth_getenv_enetaddr(char *name, uchar *enetaddr); int eth_setenv_enetaddr(char *name, const uchar *enetaddr); diff --git a/net/eth.c b/net/eth.c index 953b731..a6fdf1b 100644 --- a/net/eth.c +++ b/net/eth.c @@ -7,6 +7,7 @@ */ #include common.h +#include linux/ctype.h #include command.h #include dm.h #include environment.h @@ -19,6 +20,35 @@ DECLARE_GLOBAL_DATA_PTR; +int eth_validate_ethaddr_str(const char *addr) +{ + unsigned long val; + int i; + const char *cur; + char *end; + + if (!addr) + return -1; + + cur = addr; + for (i = 0; i 6; i++) { + val = simple_strtoul(cur, end, 16); + if (cur + 1 != end cur + 2 != end) + return -1; + if (val 0xff) + return -1; + if (cur + 2 = end tolower(*(cur + 1)) == 'x') + return -1; + if (i != 5 *end != ':') + return -1; + if (i == 5 *end != '\0') + return -1; + cur = end + 1; + } + + return 0; +} + void eth_parse_enetaddr(const char *addr, uchar *enetaddr) { char *end; -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 15/16] drivers/net/vsc9953: Add commands for VLAN ingress filtering
The command: ethsw [port port_no] ingress filtering { [help] | show | enable | disable } - enable/disable VLAN ingress filtering on port can be used to enable/disable/show VLAN ingress filtering on a port. This command has also been added to the ethsw generic parser from common/cmd_ethsw.c Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; Changes for v3: - replaced values returned by functions called by the parser with CMD_RET_* macros; - each variabled is declared on a separate line, with one space instead of tab(s); - vsc9953_port_ingress_filtering_get() returns enabled value; common/cmd_ethsw.c| 65 ++ drivers/net/vsc9953.c | 86 +++ include/ethsw.h | 4 +++ 3 files changed, 155 insertions(+) diff --git a/common/cmd_ethsw.c b/common/cmd_ethsw.c index 44a7f01..1b69fbb 100644 --- a/common/cmd_ethsw.c +++ b/common/cmd_ethsw.c @@ -102,6 +102,17 @@ static int ethsw_vlan_learn_help_key_func(struct ethsw_command_def *parsed_cmd) return CMD_RET_SUCCESS; } +#define ETHSW_PORT_INGR_FLTR_HELP ethsw [port port_no] ingress filtering \ + { [help] | show | enable | disable } \ +- enable/disable VLAN ingress filtering on port + +static int ethsw_ingr_fltr_help_key_func(struct ethsw_command_def *parsed_cmd) +{ + printf(ETHSW_PORT_INGR_FLTR_HELP\n); + + return CMD_RET_SUCCESS; +} + static struct keywords_to_function { enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS]; int cmd_func_offset; @@ -473,6 +484,53 @@ static struct keywords_to_function { .cmd_func_offset = offsetof(struct ethsw_command_func, vlan_learn_set), .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_ingress, + ethsw_id_filtering, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = ethsw_ingr_fltr_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_ingress, + ethsw_id_filtering, + ethsw_id_help, + ethsw_id_key_end, + }, + .cmd_func_offset = -1, + .keyword_function = ethsw_ingr_fltr_help_key_func, + }, { + .cmd_keyword = { + ethsw_id_ingress, + ethsw_id_filtering, + ethsw_id_show, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_ingr_filt_show), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_ingress, + ethsw_id_filtering, + ethsw_id_enable, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_ingr_filt_set), + .keyword_function = NULL, + }, { + .cmd_keyword = { + ethsw_id_ingress, + ethsw_id_filtering, + ethsw_id_disable, + ethsw_id_key_end, + }, + .cmd_func_offset = offsetof(struct ethsw_command_func, + port_ingr_filt_set), + .keyword_function = NULL, }, }; @@ -596,6 +654,12 @@ struct keyword_def { }, { .keyword_name = private, .match = keyword_match_gen, + }, { + .keyword_name = ingress, + .match = keyword_match_gen, + }, { + .keyword_name = filtering, + .match = keyword_match_gen, }, }; @@ -957,4 +1021,5 @@ U_BOOT_CMD(ethsw, ETHSW_MAX_CMD_PARAMS, 0, do_ethsw, ETHSW_PORT_UNTAG_HELP\n
[U-Boot] [PATCH v3 00/16] Add more commands for VSC9953 L2 Switch
This patch set adds several features for VSC9953 L2 Switch: - VLAN configuration; - port statistics; - FDB table operations; - enable/disable HW learning; - private/shared VLAN learning. Also, the parser needed to be changed to allow commands with optional parameters and to allow developers to easily add new commands. This set also creates a parser with generic commands for L2 Ethernet Switche drivers. Since new features are added, the default configuration had to be changed to: - HW learning enabled on all ports; (HW default) - All ports are in VLAN 1; - All ports are VLAN aware; - All ports have POP_COUNT 1; - All ports have PVID 1; - All ports have TPID 0x8100; (HW default) - All ports tag frames classified to all VLANs that are not PVID; If the user decides to compile the VSC9953 driver without the support for commands, the above default configuration should be sufficient to make the L2 Switch work in unmanaged mode. New supported commands: - show a port's statistics; - enable/disable/show learning configuration on a port; - add/delete a MAC entry in FDB; show the FDB table; - add/remove a VLAN to/from a port (VLAN members); - set/show PVID (ingress and egress VLAN tagging) for a port; - set egress tagging mod for a port; - configure VID source for egress tag; - make VLAN learning shared or private; - enable/disable VLAN ingress filtering on a port. Changes for v2: - removed Change-id field; - Added the patch that changes the License at the end of the patch set for an easier integration; Changes for v3: - added a patch that creates a parser with generic commands for Ethernet switch drivers - added a patch that adds new functions for working with bitfields; - added a patch that exports a function that verifies if a string has the format of a MAC address - added a patch to rename macros from vsc9953.h that started with CONFIG_ - added a patch with a bug fix fdone in the Cleanup patch - all patches declare each variable on a line, without using tabs - in the parser, the MAC address is no longer remembered dynamically, but statically - the parser now returns CMD_RET_* macros instead of 1 and 0 - small code fixes Codrin Ciubotariu (16): drivers/net/vsc9953: Remove 'CONFIG_' from macros' name drivers/net/vsc9953: Cleanup patch drivers/net/vsc9953: Fix bug when enabling a port drivers/net/vsc9953: Fix missing reserved register include/bitfield: Add new bitfield operations drivers/net/vsc9953: Add default configuration for VSC9953 L2 Switch common/cmd_ethsw: Add generic commands for Ethernet Switches drivers/net/vsc9953: Use the generic Ethernet Switch parser drivers/net/vsc9953: Add command to show/clear port counters drivers/net/vsc9953: Add commands to enable/disable HW learning net/eth.c: Add function to validate a MAC address drivers/net/vsc9953: Add commands to manipulate the FDB for VSC9953 drivers/net/vsc9953: Add VLAN commands for VSC9953 drivers/net/vsc9953: Add command for shared/private VLAN learning drivers/net/vsc9953: Add commands for VLAN ingress filtering drivers/net/vsc9953: Add GPL-2.0+ SPDX-License-Identifier common/Makefile|1 + common/cmd_ethsw.c | 1025 common/env_flags.c | 15 +- drivers/net/vsc9953.c | 2247 +++- include/bitfield.h | 32 + include/configs/T104xRDB.h |2 +- include/ethsw.h| 95 ++ include/net.h |1 + include/vsc9953.h | 389 ++-- net/eth.c | 30 + 10 files changed, 3502 insertions(+), 335 deletions(-) create mode 100644 common/cmd_ethsw.c create mode 100644 include/ethsw.h -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 06/11 v2] drivers/net/vsc9953: Add commands to enable/disable HW learning
The command: ethsw [port port_no] learning { [help] | show | auto | disable } can be used to enable/disable HW learning on a port. Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; drivers/net/vsc9953.c | 188 ++ include/vsc9953.h | 6 ++ 2 files changed, 194 insertions(+) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 62ab0eb..1936c4a 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -672,6 +672,73 @@ static void vsc9953_port_config_show(int port_no) printf(%8s\n, duplex == DUPLEX_FULL ? full : half); } +enum port_learn_mode { + PORT_LEARN_NONE, + PORT_LEARN_AUTO +}; + +/* Set learning configuration for a VSC9953 port */ +static void vsc9953_port_learn_mode_set(int port_no, enum port_learn_mode mode) +{ + struct vsc9953_analyzer *l2ana_reg; + + /* Administrative down */ + if (!vsc9953_l2sw.port[port_no].enabled) { + printf(Port %d is administrative down\n, port_no); + return; + } + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + switch (mode) { + case PORT_LEARN_NONE: + clrbits_le32(l2ana_reg-port[port_no].port_cfg, +CONFIG_VSC9953_PORT_CFG_LEARN_DROP | +CONFIG_VSC9953_PORT_CFG_LEARN_CPU | +CONFIG_VSC9953_PORT_CFG_LEARN_AUTO | +CONFIG_VSC9953_PORT_CFG_LEARN_ENA); + break; + case PORT_LEARN_AUTO: + clrsetbits_le32(l2ana_reg-port[port_no].port_cfg, + CONFIG_VSC9953_PORT_CFG_LEARN_DROP | + CONFIG_VSC9953_PORT_CFG_LEARN_CPU, + CONFIG_VSC9953_PORT_CFG_LEARN_ENA | + CONFIG_VSC9953_PORT_CFG_LEARN_AUTO); + break; + default: + printf(Unknown learn mode for port %d\n, port_no); + } +} + +/* Get learning configuration for a VSC9953 port */ +static int vsc9953_port_learn_mode_get(int port_no, enum port_learn_mode *mode) +{ + u32 val; + struct vsc9953_analyzer *l2ana_reg; + + /* Administrative down */ + if (!vsc9953_l2sw.port[port_no].enabled) { + printf(Port %d is administrative down\n, port_no); + return -1; + } + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + /* For now we only support HW learning (auto) and no learning */ + val = in_le32(l2ana_reg-port[port_no].port_cfg); + if ((val (CONFIG_VSC9953_PORT_CFG_LEARN_ENA | + CONFIG_VSC9953_PORT_CFG_LEARN_AUTO)) == + (CONFIG_VSC9953_PORT_CFG_LEARN_ENA | +CONFIG_VSC9953_PORT_CFG_LEARN_AUTO)) + *mode = PORT_LEARN_AUTO; + else + *mode = PORT_LEARN_NONE; + + return 0; +} + /* Show VSC9953 ports' statistics */ static void vsc9953_port_statistics_show(int port_no) { @@ -895,6 +962,8 @@ enum keyword_id { id_disable, id_statistics, id_clear, + id_learning, + id_auto, id_count, /* keep last */ }; @@ -1002,6 +1071,84 @@ static int vsc9953_port_stats_clear_key_func(struct command_def *parsed_cmd) return 0; } +#define VSC9953_LEARN_HELP ethsw [port port_no] learning \ +{ [help] | show | auto | disable } \ +- enable/disable/show learning configuration on a port + +static int vsc9953_learn_help_key_func(struct command_def *parsed_cmd) +{ + printf(VSC9953_LEARN_HELP\n); + + return 0; +} + +static int vsc9953_learn_show_key_func(struct command_def *parsed_cmd) +{ + int i; + enum port_learn_modemode; + + if (parsed_cmd-port != VSC9953_CMD_PORT_ALL) { + if (vsc9953_port_learn_mode_get(parsed_cmd-port, mode)) + return -1; + printf(%7s %11s\n, Port, Learn mode); + switch (mode) { + case PORT_LEARN_NONE: + printf(%7d %11s\n, parsed_cmd-port, disable); + break; + case PORT_LEARN_AUTO: + printf(%7d %11s\n, parsed_cmd-port, auto); + break; + default: + printf(%7d %11s\n, parsed_cmd-port, -); + } + } else { + printf(%7s %11s\n, Port, Learn mode); + for (i = 0; i VSC9953_MAX_PORTS; i++) { + if (vsc9953_port_learn_mode_get(i, mode)) + continue; + switch (mode
[U-Boot] [PATCH 00/11 v2] Add more commands for VSC9953 L2 Switch
This patch set adds several features for VSC9953 L2 Switch: - VLAN configuration; - port statistics; - FDB table operations; - enable/disable HW learning; - private/shared VLAN learning. Also, the parser needed to be changed to allow commands with optional parameters and to allow developers to easily add new commands. Since new features are added, the default configuration had to be changed to: - HW learning enabled on all ports; (HW default) - All ports are in VLAN 1; - All ports are VLAN aware; - All ports have POP_COUNT 1; - All ports have PVID 1; - All ports have TPID 0x8100; (HW default) - All ports tag frames classified to all VLANs that are not PVID; If the user decides to compile the VSC9953 driver without the support for commands, the above default configuration should be sufficient to make the L2 Switch work in unmanaged mode. New supported commands: - show a port's statistics; - enable/disable/show learning configuration on a port; - add/delete a MAC entry in FDB; show the FDB table; - add/remove a VLAN to/from a port (VLAN members); - set/show PVID (ingress and egress VLAN tagging) for a port; - set egress tagging mod for a port; - configure VID source for egress tag; - make VLAN learning shared or private; - enable/disable VLAN ingress filtering on a port. Changes for v2: - removed Change-id field; - Added the patch that changes the License at the end of the patch set for an easier integration; Codrin Ciubotariu (11): drivers/net/vsc9953: Cleanup patch drivers/net/vsc9953: Fix missing reserved register drivers/net/vsc9953: Add default configuration for VSC9953 L2 Switch drivers/net/vsc9953: Refractor the parser for VSC9953 commands drivers/net/vsc9953: Add command to show/clear port counters drivers/net/vsc9953: Add commands to enable/disable HW learning drivers/net/vsc9953: Add commands to manipulate the FDB for VSC9953 drivers/net/vsc9953: Add VLAN commands for VSC9953 drivers/net/vsc9953: Add command for shared/private VLAN learning drivers/net/vsc9953: Add commands for VLAN ingress filtering drivers/net/vsc9953: Add GPL-2.0+ SPDX-License-Identifier drivers/net/vsc9953.c | 2816 ++--- include/vsc9953.h | 274 - 2 files changed, 2948 insertions(+), 142 deletions(-) -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 03/11 v2] drivers/net/vsc9953: Add default configuration for VSC9953 L2 Switch
At startup, the default configuration should be: - enable HW learning on all ports (HW default); - all ports are VLAN aware; - all ports are members of VLAN 1; - all ports have Port-based VLAN 1; - on all ports, the switch is allowed to remove maximum one VLAN tag, - on egress, the switch should add a VLAN tag if the frame is classified to a different VLAN than the port's Port-based VLAN; Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; drivers/net/vsc9953.c | 266 +- include/vsc9953.h | 61 +++- 2 files changed, 325 insertions(+), 2 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 720ae47..9dec683 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -1,5 +1,5 @@ /* - * Copyright 2014 Freescale Semiconductor, Inc. + * Copyright 2014-2015 Freescale Semiconductor, Inc. * * SPDX-License-Identifier: GPL-2.0+ * @@ -176,6 +176,268 @@ static int vsc9953_port_init(int port_no) return 0; } +static int vsc9953_vlan_table_poll_idle(void) +{ + struct vsc9953_analyzer *l2ana_reg; + int timeout; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + timeout = 5; + while (((in_le32(l2ana_reg-ana_tables.vlan_access) + CONFIG_VSC9953_VLAN_CMD_MASK) != + CONFIG_VSC9953_VLAN_CMD_IDLE) --timeout) + udelay(1); + + return !!timeout; +} + +/* vlan table set/clear all membership of vid */ +static void vsc9953_vlan_table_membership_all_set(int vid, int set) +{ + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + if (!vsc9953_vlan_table_poll_idle()) { + debug(VLAN table timeout\n); + return; + } + + /* read current vlan configuration */ + clrsetbits_le32(l2ana_reg-ana_tables.vlan_tidx, + CONFIG_VSC9953_ANA_TBL_VID_MASK, + field_set(vid, CONFIG_VSC9953_ANA_TBL_VID_MASK)); + + clrsetbits_le32(l2ana_reg-ana_tables.vlan_access, + CONFIG_VSC9953_VLAN_CMD_MASK, + field_set(CONFIG_VSC9953_VLAN_CMD_READ, + CONFIG_VSC9953_VLAN_CMD_MASK)); + + if (!vsc9953_vlan_table_poll_idle()) { + debug(VLAN table timeout\n); + return; + } + + clrsetbits_le32(l2ana_reg-ana_tables.vlan_tidx, + CONFIG_VSC9953_ANA_TBL_VID_MASK, + field_set(vid, CONFIG_VSC9953_ANA_TBL_VID_MASK)); + + if (!set) + clrsetbits_le32(l2ana_reg-ana_tables.vlan_access, + CONFIG_VSC9953_VLAN_PORT_MASK | + CONFIG_VSC9953_VLAN_CMD_MASK, + field_set(CONFIG_VSC9953_VLAN_CMD_WRITE, + CONFIG_VSC9953_VLAN_CMD_MASK)); + else + clrsetbits_le32(l2ana_reg-ana_tables.vlan_access, + CONFIG_VSC9953_VLAN_PORT_MASK | + CONFIG_VSC9953_VLAN_CMD_MASK, + field_set(CONFIG_VSC9953_VLAN_CMD_WRITE, + CONFIG_VSC9953_VLAN_CMD_MASK) | + CONFIG_VSC9953_VLAN_PORT_MASK); +} + +/* Set PVID for a VSC9953 port */ +static void vsc9953_port_vlan_pvid_set(int port_no, int pvid) +{ + struct vsc9953_analyzer *l2ana_reg; + struct vsc9953_rew_reg *l2rew_reg; + + /* Administrative down */ + if ((!vsc9953_l2sw.port[port_no].enabled)) { + printf(Port %d is administrative down\n, port_no); + return; + } + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + l2rew_reg = (struct vsc9953_rew_reg *)(VSC9953_OFFSET + + VSC9953_REW_OFFSET); + + /* Set PVID on ingress */ + clrsetbits_le32(l2ana_reg-port[port_no].vlan_cfg, + CONFIG_VSC9953_VLAN_CFG_VID_MASK, + field_set(pvid, CONFIG_VSC9953_VLAN_CFG_VID_MASK)); + + /* Set PVID on egress */ + clrsetbits_le32(l2rew_reg-port[port_no].port_vlan_cfg, + CONFIG_VSC9953_PORT_VLAN_CFG_VID_MASK, + field_set(pvid, CONFIG_VSC9953_PORT_VLAN_CFG_VID_MASK)); +} + +static void vsc9953_port_all_vlan_pvid_set(int pvid) +{ + int i; + + for (i = 0; i VSC9953_MAX_PORTS; i++) + vsc9953_port_vlan_pvid_set(i, pvid); +} + +/* Enable/disable vlan aware of a VSC9953 port
[U-Boot] [PATCH 01/11 v2] drivers/net/vsc9953: Cleanup patch
This patch groups some macros defined for registers and replaces some magic numbers from vsc9953 with macros. Also, port and port_nr keywords are replaced with port_no. Also, in some places, this patch replaces in_le32 and out_le32 with clrbits_le32 and setbits_le32 to reduce the number of code lines and to assure that only intended bits of a register are changed. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; drivers/net/vsc9953.c | 100 +- include/vsc9953.h | 47 2 files changed, 88 insertions(+), 59 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index fed7358..720ae47 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -25,44 +25,44 @@ static struct vsc9953_info vsc9953_l2sw = { .port[9] = VSC9953_PORT_INFO_INITIALIZER(9), }; -void vsc9953_port_info_set_mdio(int port, struct mii_dev *bus) +void vsc9953_port_info_set_mdio(int port_no, struct mii_dev *bus) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].bus = bus; + vsc9953_l2sw.port[port_no].bus = bus; } -void vsc9953_port_info_set_phy_address(int port, int address) +void vsc9953_port_info_set_phy_address(int port_no, int address) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].phyaddr = address; + vsc9953_l2sw.port[port_no].phyaddr = address; } -void vsc9953_port_info_set_phy_int(int port, phy_interface_t phy_int) +void vsc9953_port_info_set_phy_int(int port_no, phy_interface_t phy_int) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enet_if = phy_int; + vsc9953_l2sw.port[port_no].enet_if = phy_int; } -void vsc9953_port_enable(int port) +void vsc9953_port_enable(int port_no) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enabled = 1; + vsc9953_l2sw.port[port_no].enabled = 1; } -void vsc9953_port_disable(int port) +void vsc9953_port_disable(int port_no) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enabled = 0; + vsc9953_l2sw.port[port_no].enabled = 0; } static void vsc9953_mdio_write(struct vsc9953_mii_mng *phyregs, int port_addr, @@ -148,21 +148,21 @@ static int init_phy(struct eth_device *dev) return 0; } -static int vsc9953_port_init(int port) +static int vsc9953_port_init(int port_no) { struct eth_device *dev; /* Internal ports never have a PHY */ - if (VSC9953_INTERNAL_PORT_CHECK(port)) + if (VSC9953_INTERNAL_PORT_CHECK(port_no)) return 0; /* alloc eth device */ dev = (struct eth_device *)calloc(1, sizeof(struct eth_device)); if (!dev) - return 1; + return -1; - sprintf(dev-name, SW@PORT%d, port); - dev-priv = vsc9953_l2sw.port[port]; + sprintf(dev-name, SW@PORT%d, port_no); + dev-priv = vsc9953_l2sw.port[port_no]; dev-init = NULL; dev-halt = NULL; dev-send = NULL; @@ -170,7 +170,7 @@ static int vsc9953_port_init(int port) if (init_phy(dev)) { free(dev); - return 1; + return -1; } return 0; @@ -255,8 +255,8 @@ void vsc9953_init(bd_t *bis) out_le32(l2dev_gmii_reg-mac_cfg_status.mac_hdx_cfg, hdx_cfg); out_le32(l2sys_reg-sys.front_port_mode[i], CONFIG_VSC9953_FRONT_PORT_MODE); - out_le32(l2qsys_reg-sys.switch_port_mode[i], -CONFIG_VSC9953_PORT_ENA); + setbits_le32(l2qsys_reg-sys.switch_port_mode[i], +CONFIG_VSC9953_PORT_ENA); out_le32(l2dev_gmii_reg-mac_cfg_status.mac_maxlen_cfg, CONFIG_VSC9953_MAC_MAX_LEN); out_le32(l2sys_reg-pause_cfg.pause_cfg[i], @@ -312,25 +312,23 @@ void vsc9953_init(bd_t *bis) #ifdef CONFIG_VSC9953_CMD /* Enable/disable status of a VSC9953 port */ -static void vsc9953_port_status_set(int port_nr, u8 enabled) +static void vsc9953_port_status_set(int port_no, u8 enabled) { - u32 val; struct vsc9953_qsys_reg *l2qsys_reg; /* Administrative down */ - if (vsc9953_l2sw.port[port_nr].enabled == 0) + if (!vsc9953_l2sw.port[port_no].enabled) return; l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET + VSC9953_QSYS_OFFSET); - val = in_le32(l2qsys_reg
[U-Boot] [PATCH 04/11 v2] drivers/net/vsc9953: Refractor the parser for VSC9953 commands
In order to support multiple commands to configure the VSC9953 L2 Switch, the parser needs to be changed to be more flexible and to support more complex commands. This patch adds a parser that searches for defined keywords in the command and calls the proper function when a match is found. Also, the parser allows for optional keywords, such as port, to apply the command on a port or on all ports. The already defined commands are also changed a bit to: ethsw [port port_no] { enable | disable | show } Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; drivers/net/vsc9953.c | 381 -- 1 file changed, 310 insertions(+), 71 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 9dec683..4df751a 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -10,6 +10,7 @@ #include asm/fsl_serdes.h #include fm_eth.h #include fsl_memac.h +#include errno.h #include vsc9953.h static struct vsc9953_info vsc9953_l2sw = { @@ -575,6 +576,10 @@ void vsc9953_init(bd_t *bis) } #ifdef CONFIG_VSC9953_CMD + +#define VSC9953_MAX_CMD_PARAMS 20 +#define VSC9953_CMD_PORT_ALL -1 + /* Enable/disable status of a VSC9953 port */ static void vsc9953_port_status_set(int port_no, u8 enabled) { @@ -595,15 +600,6 @@ static void vsc9953_port_status_set(int port_no, u8 enabled) CONFIG_VSC9953_PORT_ENA); } -/* Set all VSC9953 ports' status */ -static void vsc9953_port_all_status_set(u8 enabled) -{ - int i; - - for (i = 0; i VSC9953_MAX_PORTS; i++) - vsc9953_port_status_set(i, enabled); -} - /* Start autonegotiation for a VSC9953 PHY */ static void vsc9953_phy_autoneg(int port_no) { @@ -615,15 +611,6 @@ static void vsc9953_phy_autoneg(int port_no) printf(Failed to start PHY for port %d\n, port_no); } -/* Start autonegotiation for all VSC9953 PHYs */ -static void vsc9953_phy_all_autoneg(void) -{ - int i; - - for (i = 0; i VSC9953_MAX_PORTS; i++) - vsc9953_phy_autoneg(i); -} - /* Print a VSC9953 port's configuration */ static void vsc9953_port_config_show(int port_no) { @@ -685,75 +672,327 @@ static void vsc9953_port_config_show(int port_no) printf(%8s\n, duplex == DUPLEX_FULL ? full : half); } -/* Print VSC9953 ports' configuration */ -static void vsc9953_port_all_config_show(void) -{ - int i; +/* IDs used to track keywords in a command */ +enum keyword_id { + id_key_end = -1, + id_help, + id_show, + id_port, + id_enable, + id_disable, + id_count, /* keep last */ +}; - for (i = 0; i VSC9953_MAX_PORTS; i++) - vsc9953_port_config_show(i); -} +enum keyword_opt_id { + id_port_no = id_count + 1, + id_count_all, /* keep last */ +}; -/* function to interpret commands starting with ethsw */ -static int do_ethsw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +struct command_def { + int cmd_to_keywords[VSC9953_MAX_CMD_PARAMS]; + int cmd_keywords_nr; + int port; + int err; + int (*cmd_function)(struct command_def *parsed_cmd); +}; + +#define VSC9953_PORT_CONF_HELP [port port_no] { enable | disable | show } \ +- enable/disable a port; show shows a port's configuration + +static int vsc9953_port_status_key_func(struct command_def *parsed_cmd) { - u8 enable; - u32 port; + int i; + u8 enabled; - if (argc 4) + /* Last keyword should tell us if we should enable/disable the port */ + if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == + id_enable) + enabled = 1; + else if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == +id_disable) + enabled = 0; + else { + parsed_cmd-err = 1; return -1; + } - if (strcmp(argv[1], port)) - return -1; + if (parsed_cmd-port != VSC9953_CMD_PORT_ALL) { + vsc9953_port_status_set(parsed_cmd-port, enabled); + } else { + for (i = 0; i VSC9953_MAX_PORTS; i++) + vsc9953_port_status_set(i, enabled); + } + + return 0; +} + +static int vsc9953_port_config_key_func(struct command_def *parsed_cmd) +{ + int i; + + if (parsed_cmd-port != VSC9953_CMD_PORT_ALL) { + vsc9953_phy_autoneg(parsed_cmd-port); + printf(%8s %8s %8s %8s %8s\n, + Port, Status, Link, Speed, + Duplex); + vsc9953_port_config_show(parsed_cmd-port); - if (!strcmp(argv[3], show)) { - if (!strcmp(argv[2], all)) { - vsc9953_phy_all_autoneg
[U-Boot] [PATCH 05/11 v2] drivers/net/vsc9953: Add command to show/clear port counters
The new added command: ethsw [port port_no] statistics { [help] | [clear] } will print counters like the number of Rx/Tx frames, number of Rx/Tx bytes, number of Rx/Tx unicast frames, etc. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; drivers/net/vsc9953.c | 280 ++ include/vsc9953.h | 116 - 2 files changed, 393 insertions(+), 3 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 4df751a..62ab0eb 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -672,6 +672,219 @@ static void vsc9953_port_config_show(int port_no) printf(%8s\n, duplex == DUPLEX_FULL ? full : half); } +/* Show VSC9953 ports' statistics */ +static void vsc9953_port_statistics_show(int port_no) +{ + u32 rx_val, tx_val; + struct vsc9953_system_reg *l2sys_reg; + + /* Administrative down */ + if (!vsc9953_l2sw.port[port_no].enabled) { + printf(Port %d is administrative down\n, port_no); + return; + } + + l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET + + VSC9953_SYS_OFFSET); + + printf(Statistics for L2 Switch port %d:\n, port_no); + + /* Set counter view for our port */ + out_le32(l2sys_reg-sys.stat_cfg, port_no); + +#define VSC9953_STATS_PRINTF %-15s %10u + + /* Get number of Rx and Tx frames */ + rx_val = in_le32(l2sys_reg-stat.rx_cntrs.c_rx_short) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_frag) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_jabber) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_long) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_64) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_65_127) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_128_255) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_256_511) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_512_1023) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_1024_1526) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_jumbo); + tx_val = in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_64) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_65_127) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_128_255) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_256_511) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_512_1023) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_1024_1526) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_jumbo); + printf(VSC9953_STATS_PRINTF\t\tVSC9953_STATS_PRINTF\n, + Rx frames:, rx_val, Tx frames:, tx_val); + + /* Get number of Rx and Tx bytes */ + rx_val = in_le32(l2sys_reg-stat.rx_cntrs.c_rx_oct); + tx_val = in_le32(l2sys_reg-stat.tx_cntrs.c_tx_oct); + printf(VSC9953_STATS_PRINTF\t\tVSC9953_STATS_PRINTF\n, + Rx bytes:, rx_val, Tx bytes:, tx_val); + + /* Get number of Rx frames received ok and Tx frames sent ok */ + rx_val = in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_0) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_1) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_2) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_3) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_4) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_5) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_6) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_7) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_0) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_1) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_2) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_3) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_4) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_5) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_6) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_7); + tx_val = in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_64) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_65_127) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_128_255) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_256_511) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_512_1023) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_1024_1526) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_jumbo); + printf(VSC9953_STATS_PRINTF\t\tVSC9953_STATS_PRINTF\n, + Rx frames ok:, rx_val, Tx frames ok:, tx_val); + + /* Get number of Rx and Tx unicast frames */ + rx_val
[U-Boot] [PATCH 02/11 v2] drivers/net/vsc9953: Fix missing reserved register
The VSC9953 DS reserves a register between vlan_mask and anag_efil registers. Signed-off-by: Johnson Leung johnson.le...@freescale.com --- Changes for v2: - removed Change-id field; include/vsc9953.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/vsc9953.h b/include/vsc9953.h index 920402f..2b88c5c 100644 --- a/include/vsc9953.h +++ b/include/vsc9953.h @@ -147,6 +147,7 @@ struct vsc9953_ana_ana_tables { struct vsc9953_ana_ana { u32 adv_learn; u32 vlan_mask; + u32 reserved; u32 anag_efil; u32 an_events; u32 storm_limit_burst; -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 07/11 v2] drivers/net/vsc9953: Add commands to manipulate the FDB for VSC9953
The new command: ethsw [port port_no] [vlan vid] fdb { [help] | show | flush | { add | del } mac } Can be used to add and delete FDB entries. Also, the command can be used to show entries from the FDB tables. When used with [port port_no] and [vlan vid], only the matching the FDB entries can be seen or flushed. Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; drivers/net/vsc9953.c | 635 +- include/vsc9953.h | 28 +++ 2 files changed, 662 insertions(+), 1 deletion(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 1936c4a..ef7b50c 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -12,6 +12,7 @@ #include fsl_memac.h #include errno.h #include vsc9953.h +#include linux/ctype.h static struct vsc9953_info vsc9953_l2sw = { .port[0] = VSC9953_PORT_INFO_INITIALIZER(0), @@ -579,6 +580,7 @@ void vsc9953_init(bd_t *bis) #define VSC9953_MAX_CMD_PARAMS 20 #define VSC9953_CMD_PORT_ALL -1 +#define VSC9953_CMD_VLAN_ALL -1 /* Enable/disable status of a VSC9953 port */ static void vsc9953_port_status_set(int port_no, u8 enabled) @@ -952,6 +954,365 @@ static void vsc9953_port_statistics_clear(int port_no) CONFIG_VSC9953_STAT_CLEAR_DR); } +/* wait for FDB to become available */ +static int vsc9953_mac_table_poll_idle(void) +{ + struct vsc9953_analyzer *l2ana_reg; + u32 timeout; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + timeout = 5; + while (((in_le32(l2ana_reg-ana_tables.mac_access) + CONFIG_VSC9953_MAC_CMD_MASK) != +CONFIG_VSC9953_MAC_CMD_IDLE) --timeout) + udelay(1); + + return !!timeout; +} + +/* enum describing available commands for the MAC table */ +enum mac_table_cmd { + MAC_TABLE_READ_DIRECT, + MAC_TABLE_READ_INDIRECT, + MAC_TABLE_WRITE, + MAC_TABLE_LEARN, + MAC_TABLE_FORGET, + MAC_TABLE_GET_NEXT, + MAC_TABLE_AGE, +}; + +/* Issues a command to the FDB table */ +static int vsc9953_mac_table_cmd(enum mac_table_cmd cmd) +{ + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + switch (cmd) { + case MAC_TABLE_READ_DIRECT: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK | + CONFIG_VSC9953_MAC_CMD_VALID, + CONFIG_VSC9953_MAC_CMD_READ); + break; + case MAC_TABLE_READ_INDIRECT: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK, + CONFIG_VSC9953_MAC_CMD_READ | + CONFIG_VSC9953_MAC_CMD_VALID); + break; + case MAC_TABLE_WRITE: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK | + CONFIG_VSC9953_MAC_ENTRYTYPE_MASK, + CONFIG_VSC9953_MAC_CMD_WRITE | + CONFIG_VSC9953_MAC_ENTRYTYPE_LOCKED); + break; + case MAC_TABLE_LEARN: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK | + CONFIG_VSC9953_MAC_ENTRYTYPE_MASK, + CONFIG_VSC9953_MAC_CMD_LEARN | + CONFIG_VSC9953_MAC_ENTRYTYPE_LOCKED | + CONFIG_VSC9953_MAC_CMD_VALID); + break; + case MAC_TABLE_FORGET: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK | + CONFIG_VSC9953_MAC_ENTRYTYPE_MASK, + CONFIG_VSC9953_MAC_CMD_FORGET); + break; + case MAC_TABLE_GET_NEXT: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK | + CONFIG_VSC9953_MAC_ENTRYTYPE_MASK, + CONFIG_VSC9953_MAC_CMD_NEXT); + break; + case MAC_TABLE_AGE: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK | + CONFIG_VSC9953_MAC_ENTRYTYPE_MASK, + CONFIG_VSC9953_MAC_CMD_AGE); + break; + default: + printf(Unknown MAC table command\n
[U-Boot] [PATCH 11/11 v2] drivers/net/vsc9953: Add GPL-2.0+ SPDX-License-Identifier
Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - fixed the Copyright years from 2014-2015 to 2013, 2015; - removed Change-id field; include/vsc9953.h | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/include/vsc9953.h b/include/vsc9953.h index 26a08aa..c3d5ae4 100644 --- a/include/vsc9953.h +++ b/include/vsc9953.h @@ -1,14 +1,9 @@ /* - * vsc9953.h + * Copyright 2013, 2015 Freescale Semiconductor, Inc. * - * Driver for the Vitesse VSC9953 L2 Switch - * - * This software may be used and distributed according to the - * terms of the GNU Public License, Version 2, incorporated - * herein by reference. - * - * Copyright 2013, 2015 Freescale Semiconductor, Inc. + * SPDX-License-Identifier: GPL-2.0+ * + * Driver for the Vitesse VSC9953 L2 Switch */ #ifndef _VSC9953_H_ -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 08/11 v2] drivers/net/vsc9953: Add VLAN commands for VSC9953
The new added commands can be used to configure VLANs for a port on both ingress and egress. The new commands are: ethsw [port port_no] pvid { [help] | show | pvid } - set/show PVID (ingress and egress VLAN tagging) for a port; ethsw [port port_no] vlan { [help] | show | add vid | del vid } - add a VLAN to a port (VLAN members); ethsw [port port_no] untagged { [help] | show | all | none | pvid } - set egress tagging mod for a port ethsw [port port_no] egress tag { [help] | show | pvid | classified } - Configure VID source for egress tag. Tag's VID could be the frame's classified VID or the PVID of the port Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; drivers/net/vsc9953.c | 678 +- include/vsc9953.h | 3 + 2 files changed, 680 insertions(+), 1 deletion(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index ef7b50c..b78a941 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -270,6 +270,31 @@ static void vsc9953_port_vlan_pvid_set(int port_no, int pvid) field_set(pvid, CONFIG_VSC9953_PORT_VLAN_CFG_VID_MASK)); } +#ifdef CONFIG_VSC9953_CMD +/* Set PVID for a VSC9953 port */ +static int vsc9953_port_vlan_pvid_get(int port_nr, int *pvid) +{ + u32 val; + struct vsc9953_analyzer *l2ana_reg; + + /* Administrative down */ + if ((!vsc9953_l2sw.port[port_nr].enabled)) { + printf(Port %d is administrative down\n, port_nr); + return -1; + } + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + /* Get ingress PVID */ + val = in_le32(l2ana_reg-port[port_nr].vlan_cfg); + *pvid = field_get(val CONFIG_VSC9953_VLAN_CFG_VID_MASK, + CONFIG_VSC9953_VLAN_CFG_VID_MASK); + + return 0; +} +#endif + static void vsc9953_port_all_vlan_pvid_set(int pvid) { int i; @@ -407,6 +432,75 @@ static void vsc9953_port_vlan_egr_untag_set(int port_no, } } +#ifdef CONFIG_VSC9953_CMD +/* Get egress tagging configuration for a VSC9953 port */ +static int vsc9953_port_vlan_egr_untag_get(int port_no, + enum egress_untag_mode *mode) +{ + u32 val; + struct vsc9953_rew_reg *l2rew_reg; + + /* Administrative down */ + if ((!vsc9953_l2sw.port[port_no].enabled)) { + printf(Port %d is administrative down\n, port_no); + return -1; + } + + l2rew_reg = (struct vsc9953_rew_reg *)(VSC9953_OFFSET + + VSC9953_REW_OFFSET); + + val = in_le32(l2rew_reg-port[port_no].port_tag_cfg); + + switch (val CONFIG_VSC9953_TAG_CFG_MASK) { + case CONFIG_VSC9953_TAG_CFG_NONE: + *mode = EGRESS_UNTAG_ALL; + return 0; + case CONFIG_VSC9953_TAG_CFG_ALL_PVID_ZERO: + *mode = EGRESS_UNTAG_PVID_AND_ZERO; + return 0; + case CONFIG_VSC9953_TAG_CFG_ALL_ZERO: + *mode = EGRESS_UNTAG_ZERO; + return 0; + case CONFIG_VSC9953_TAG_CFG_ALL: + *mode = EGRESS_UNTAG_NONE; + return 0; + default: + printf(Unknown egress tagging configuration for port %d\n, + port_no); + return -1; + } +} + +/* Shiw egress tagging configuration for a VSC9953 port */ +static void vsc9953_port_vlan_egr_untag_show(int port_no) +{ + enum egress_untag_mode mode; + + if (vsc9953_port_vlan_egr_untag_get(port_no, mode)) { + printf(%7d\t%17s\n, port_no, -); + return; + } + + printf(%7d\t, port_no); + switch (mode) { + case EGRESS_UNTAG_ALL: + printf(%17s\n, none); + break; + case EGRESS_UNTAG_NONE: + printf(%17s\n, all); + break; + case EGRESS_UNTAG_PVID_AND_ZERO: + printf(%17s\n, all but PVID and 0); + break; + case EGRESS_UNTAG_ZERO: + printf(%17s\n, all but 0); + break; + default: + printf(%17s\n, -); + } +} +#endif + static void vsc9953_port_all_vlan_egress_untagged_set( enum egress_untag_mode mode) { @@ -954,6 +1048,102 @@ static void vsc9953_port_statistics_clear(int port_no) CONFIG_VSC9953_STAT_CLEAR_DR); } +/* Add/remove a port to/from a VLAN */ +static void vsc9953_vlan_table_membership_set(int vid, u32 port_no, u8 add) +{ + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + if (!vsc9953_vlan_table_poll_idle
[U-Boot] [PATCH 10/11 v2] drivers/net/vsc9953: Add commands for VLAN ingress filtering
The command: ethsw [port port_no] ingress filtering { [help] | show | enable | disable } - enable/disable VLAN ingress filtering on port can be used to enable/disable/show VLAN ingress filtering on a port. Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; drivers/net/vsc9953.c | 137 ++ 1 file changed, 137 insertions(+) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 3129b03..d5520d9 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -1555,6 +1555,33 @@ static int vsc9953_vlan_learning_get(enum vlan_learning_mode *lrn_mode) return 0; } +/* Enable/disable VLAN ingress filtering on a VSC9953 port */ +static void vsc9953_port_ingress_filtering_set(int port_no, int enabled) +{ + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + if (enabled) + setbits_le32(l2ana_reg-ana.vlan_mask, 1 port_no); + else + clrbits_le32(l2ana_reg-ana.vlan_mask, 1 port_no); +} + +/* Show VLAN ingress filtering on a VSC9953 port */ +static void vsc9953_port_ingress_filtering_get(int port_no, int *enabled) +{ + u32 val; + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + val = in_le32(l2ana_reg-ana.vlan_mask); + *enabled = !!(val (1 port_no)); +} + enum egress_vlan_tag { EGR_TAG_CLASS = 0, EGR_TAG_PVID, @@ -1626,6 +1653,8 @@ enum keyword_id { id_classified, id_shared, id_private, + id_ingress, + id_filtering, id_count, /* keep last */ }; @@ -2031,6 +2060,68 @@ static int vsc9953_port_untag_set_key_func(struct command_def *parsed_cmd) return 0; } +#define VSC9953_PORT_INGR_FLTR_HELP ethsw [port port_no] ingress filtering \ + { [help] | show | enable | disable } \ +- enable/disable VLAN ingress filtering on port + +static int vsc9953_ingr_fltr_help_key_func(struct command_def *parsed_cmd) +{ + printf(VSC9953_PORT_INGR_FLTR_HELP\n); + + return 0; +} + +static int vsc9953_ingr_fltr_show_key_func(struct command_def *parsed_cmd) +{ + int i, enabled; + + printf(%7s\t%18s\n, Port, Ingress filtering); + if (parsed_cmd-port != VSC9953_CMD_PORT_ALL) { + vsc9953_port_ingress_filtering_get(parsed_cmd-port, enabled); + printf(%7d\t%18s\n, parsed_cmd-port, enabled ? enable : + disable); + } else { + for (i = 0; i VSC9953_MAX_PORTS; i++) { + vsc9953_port_ingress_filtering_get(i, enabled); + printf(%7d\t%18s\n, parsed_cmd-port, enabled ? + enable : + disable); + } + } + + return 0; +} + +static int vsc9953_ingr_fltr_set_key_func(struct command_def *parsed_cmd) +{ + int i, enable; + + /* keywords for enabling/disabling ingress filtering +* are the last in the array +*/ + if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == + id_enable) + enable = 1; + else if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == +id_disable) + enable = 0; + else + return -1; + + if (parsed_cmd-port != VSC9953_CMD_PORT_ALL) { + if (!VSC9953_PORT_CHECK(parsed_cmd-port)) { + printf(Invalid port number: %d\n, parsed_cmd-port); + return -1; + } + vsc9953_port_ingress_filtering_set(parsed_cmd-port, enable); + } else { + for (i = 0; i VSC9953_MAX_PORTS; i++) + vsc9953_port_ingress_filtering_set(i, enable); + } + + return 0; +} + #define VSC9953_EGR_VLAN_TAG_HELP ethsw [port port_no] egress tag \ { [help] | show | pvid | classified } \ - Configure VID source for egress tag. \ @@ -2479,6 +2570,45 @@ struct keywords_to_function { id_key_end, }, .keyword_function = vsc9953_vlan_learn_set_key_func, + }, { + .cmd_keyword = { + id_ingress, + id_filtering, + -1, + }, + .keyword_function
[U-Boot] [PATCH 09/11 v2] drivers/net/vsc9953: Add command for shared/private VLAN learning
The command: ethsw vlan fdb { [help] | show | shared | private } - make VLAN learning shared or private configures the FDB to share the FDB entries learned on multiple VLANs or to keep them separated. By default, the FBD uses private VLAN learning. Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - removed Change-id field; drivers/net/vsc9953.c | 155 ++ include/vsc9953.h | 3 + 2 files changed, 158 insertions(+) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index b78a941..3129b03 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -1503,6 +1503,58 @@ static void vsc9953_mac_table_flush(int port, int vid) vsc9953_mac_table_age(port, vid); } +/* VSC9953 VLAN learning modes */ +enum vlan_learning_mode { + SHARED_VLAN_LEARNING, + PRIVATE_VLAN_LEARNING, +}; + +/* Set VLAN learning mode for VSC9953 */ +static void vsc9953_vlan_learning_set(enum vlan_learning_mode lrn_mode) +{ + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + switch (lrn_mode) { + case SHARED_VLAN_LEARNING: + setbits_le32(l2ana_reg-ana.agen_ctrl, +CONFIG_VSC9953_FID_MASK_ALL); + break; + case PRIVATE_VLAN_LEARNING: + clrbits_le32(l2ana_reg-ana.agen_ctrl, +CONFIG_VSC9953_FID_MASK_ALL); + break; + default: + printf(Unknown VLAN learn mode\n); + } +} + +/* Get VLAN learning mode for VSC9953 */ +static int vsc9953_vlan_learning_get(enum vlan_learning_mode *lrn_mode) +{ + u32 val; + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + val = in_le32(l2ana_reg-ana.agen_ctrl); + + if (!(val CONFIG_VSC9953_FID_MASK_ALL)) { + *lrn_mode = PRIVATE_VLAN_LEARNING; + } else if ((val CONFIG_VSC9953_FID_MASK_ALL) == + CONFIG_VSC9953_FID_MASK_ALL) { + *lrn_mode = SHARED_VLAN_LEARNING; + } else { + printf(Unknown VLAN learning mode\n); + return -EINVAL; + } + + return 0; +} + enum egress_vlan_tag { EGR_TAG_CLASS = 0, EGR_TAG_PVID, @@ -1572,6 +1624,8 @@ enum keyword_id { id_egress, id_tag, id_classified, + id_shared, + id_private, id_count, /* keep last */ }; @@ -1868,6 +1922,61 @@ static int vsc9953_vlan_set_key_func(struct command_def *parsed_cmd) return 0; } +#define VSC9953_VLAN_FDB_HELP ethsw vlan fdb \ +{ [help] | show | shared | private } \ +- make VLAN learning shared or private + +static int vsc9953_vlan_learn_help_key_func(struct command_def *parsed_cmd) +{ + printf(VSC9953_VLAN_FDB_HELP\n); + + return 0; +} + +static int vsc9953_vlan_learn_show_key_func(struct command_def *parsed_cmd) +{ + int rc; + enum vlan_learning_mode mode; + + rc = vsc9953_vlan_learning_get(mode); + if (rc) + goto __out_return; + + switch (mode) { + case SHARED_VLAN_LEARNING: + printf(VLAN learning mode: shared\n); + break; + case PRIVATE_VLAN_LEARNING: + printf(VLAN learning mode: private\n); + break; + default: + printf(Unknown VLAN learning mode\n); + rc = -EINVAL; + } + +__out_return: + return rc; +} + +static int vsc9953_vlan_learn_set_key_func(struct command_def *parsed_cmd) +{ + enum vlan_learning_mode mode; + + /* keywords for shared/private are the last in the array */ + if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == + id_shared) + mode = SHARED_VLAN_LEARNING; + else if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == +id_private) + mode = PRIVATE_VLAN_LEARNING; + else + return -1; + + vsc9953_vlan_learning_set(mode); + + return 0; +} + #define VSC9953_PORT_UNTAG_HELP ethsw [port port_no] untagged \ { [help] | show | all | none | pvid } \ - set egress tagging mod for a port @@ -2331,6 +2440,45 @@ struct keywords_to_function { id_key_end, }, .keyword_function = vsc9953_fdb_entry_del_key_func, + }, { + .cmd_keyword = { + id_vlan, + id_fdb, + id_key_end
[U-Boot] [PATCH 08/10] drivers/net/vsc9953: Add VLAN commands for VSC9953
The new added commands can be used to configure VLANs for a port on both ingress and egress. The new commands are: ethsw [port port_no] pvid { [help] | show | pvid } - set/show PVID (ingress and egress VLAN tagging) for a port; ethsw [port port_no] vlan { [help] | show | add vid | del vid } - add a VLAN to a port (VLAN members); ethsw [port port_no] untagged { [help] | show | all | none | pvid } - set egress tagging mod for a port ethsw [port port_no] egress tag { [help] | show | pvid | classified } - Configure VID source for egress tag. Tag's VID could be the frame's classified VID or the PVID of the port Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: If55943254f6f865d4bc2e18a4ab0620ab787fbc1 --- drivers/net/vsc9953.c | 678 +- include/vsc9953.h | 3 + 2 files changed, 680 insertions(+), 1 deletion(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index ef7b50c..b78a941 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -270,6 +270,31 @@ static void vsc9953_port_vlan_pvid_set(int port_no, int pvid) field_set(pvid, CONFIG_VSC9953_PORT_VLAN_CFG_VID_MASK)); } +#ifdef CONFIG_VSC9953_CMD +/* Set PVID for a VSC9953 port */ +static int vsc9953_port_vlan_pvid_get(int port_nr, int *pvid) +{ + u32 val; + struct vsc9953_analyzer *l2ana_reg; + + /* Administrative down */ + if ((!vsc9953_l2sw.port[port_nr].enabled)) { + printf(Port %d is administrative down\n, port_nr); + return -1; + } + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + /* Get ingress PVID */ + val = in_le32(l2ana_reg-port[port_nr].vlan_cfg); + *pvid = field_get(val CONFIG_VSC9953_VLAN_CFG_VID_MASK, + CONFIG_VSC9953_VLAN_CFG_VID_MASK); + + return 0; +} +#endif + static void vsc9953_port_all_vlan_pvid_set(int pvid) { int i; @@ -407,6 +432,75 @@ static void vsc9953_port_vlan_egr_untag_set(int port_no, } } +#ifdef CONFIG_VSC9953_CMD +/* Get egress tagging configuration for a VSC9953 port */ +static int vsc9953_port_vlan_egr_untag_get(int port_no, + enum egress_untag_mode *mode) +{ + u32 val; + struct vsc9953_rew_reg *l2rew_reg; + + /* Administrative down */ + if ((!vsc9953_l2sw.port[port_no].enabled)) { + printf(Port %d is administrative down\n, port_no); + return -1; + } + + l2rew_reg = (struct vsc9953_rew_reg *)(VSC9953_OFFSET + + VSC9953_REW_OFFSET); + + val = in_le32(l2rew_reg-port[port_no].port_tag_cfg); + + switch (val CONFIG_VSC9953_TAG_CFG_MASK) { + case CONFIG_VSC9953_TAG_CFG_NONE: + *mode = EGRESS_UNTAG_ALL; + return 0; + case CONFIG_VSC9953_TAG_CFG_ALL_PVID_ZERO: + *mode = EGRESS_UNTAG_PVID_AND_ZERO; + return 0; + case CONFIG_VSC9953_TAG_CFG_ALL_ZERO: + *mode = EGRESS_UNTAG_ZERO; + return 0; + case CONFIG_VSC9953_TAG_CFG_ALL: + *mode = EGRESS_UNTAG_NONE; + return 0; + default: + printf(Unknown egress tagging configuration for port %d\n, + port_no); + return -1; + } +} + +/* Shiw egress tagging configuration for a VSC9953 port */ +static void vsc9953_port_vlan_egr_untag_show(int port_no) +{ + enum egress_untag_mode mode; + + if (vsc9953_port_vlan_egr_untag_get(port_no, mode)) { + printf(%7d\t%17s\n, port_no, -); + return; + } + + printf(%7d\t, port_no); + switch (mode) { + case EGRESS_UNTAG_ALL: + printf(%17s\n, none); + break; + case EGRESS_UNTAG_NONE: + printf(%17s\n, all); + break; + case EGRESS_UNTAG_PVID_AND_ZERO: + printf(%17s\n, all but PVID and 0); + break; + case EGRESS_UNTAG_ZERO: + printf(%17s\n, all but 0); + break; + default: + printf(%17s\n, -); + } +} +#endif + static void vsc9953_port_all_vlan_egress_untagged_set( enum egress_untag_mode mode) { @@ -954,6 +1048,102 @@ static void vsc9953_port_statistics_clear(int port_no) CONFIG_VSC9953_STAT_CLEAR_DR); } +/* Add/remove a port to/from a VLAN */ +static void vsc9953_vlan_table_membership_set(int vid, u32 port_no, u8 add) +{ + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + if (!vsc9953_vlan_table_poll_idle
[U-Boot] [PATCH 01/10] drivers/net/vsc9953: Cleanup patch
This patch groups some macros defined for registers and replaces some magic numbers from vsc9953 with macros. Also, port and port_nr keywords are replaced with port_no. Also, in some places, this patch replaces in_le32 and out_le32 with clrbits_le32 and setbits_le32 to reduce the number of code lines and to assure that only intended bits of a register are changed. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: Ib5f7d94bd6a39b909bf7b70bb12e15156a7e45c9 --- drivers/net/vsc9953.c | 100 +- include/vsc9953.h | 47 2 files changed, 88 insertions(+), 59 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index fed7358..720ae47 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -25,44 +25,44 @@ static struct vsc9953_info vsc9953_l2sw = { .port[9] = VSC9953_PORT_INFO_INITIALIZER(9), }; -void vsc9953_port_info_set_mdio(int port, struct mii_dev *bus) +void vsc9953_port_info_set_mdio(int port_no, struct mii_dev *bus) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].bus = bus; + vsc9953_l2sw.port[port_no].bus = bus; } -void vsc9953_port_info_set_phy_address(int port, int address) +void vsc9953_port_info_set_phy_address(int port_no, int address) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].phyaddr = address; + vsc9953_l2sw.port[port_no].phyaddr = address; } -void vsc9953_port_info_set_phy_int(int port, phy_interface_t phy_int) +void vsc9953_port_info_set_phy_int(int port_no, phy_interface_t phy_int) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enet_if = phy_int; + vsc9953_l2sw.port[port_no].enet_if = phy_int; } -void vsc9953_port_enable(int port) +void vsc9953_port_enable(int port_no) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enabled = 1; + vsc9953_l2sw.port[port_no].enabled = 1; } -void vsc9953_port_disable(int port) +void vsc9953_port_disable(int port_no) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enabled = 0; + vsc9953_l2sw.port[port_no].enabled = 0; } static void vsc9953_mdio_write(struct vsc9953_mii_mng *phyregs, int port_addr, @@ -148,21 +148,21 @@ static int init_phy(struct eth_device *dev) return 0; } -static int vsc9953_port_init(int port) +static int vsc9953_port_init(int port_no) { struct eth_device *dev; /* Internal ports never have a PHY */ - if (VSC9953_INTERNAL_PORT_CHECK(port)) + if (VSC9953_INTERNAL_PORT_CHECK(port_no)) return 0; /* alloc eth device */ dev = (struct eth_device *)calloc(1, sizeof(struct eth_device)); if (!dev) - return 1; + return -1; - sprintf(dev-name, SW@PORT%d, port); - dev-priv = vsc9953_l2sw.port[port]; + sprintf(dev-name, SW@PORT%d, port_no); + dev-priv = vsc9953_l2sw.port[port_no]; dev-init = NULL; dev-halt = NULL; dev-send = NULL; @@ -170,7 +170,7 @@ static int vsc9953_port_init(int port) if (init_phy(dev)) { free(dev); - return 1; + return -1; } return 0; @@ -255,8 +255,8 @@ void vsc9953_init(bd_t *bis) out_le32(l2dev_gmii_reg-mac_cfg_status.mac_hdx_cfg, hdx_cfg); out_le32(l2sys_reg-sys.front_port_mode[i], CONFIG_VSC9953_FRONT_PORT_MODE); - out_le32(l2qsys_reg-sys.switch_port_mode[i], -CONFIG_VSC9953_PORT_ENA); + setbits_le32(l2qsys_reg-sys.switch_port_mode[i], +CONFIG_VSC9953_PORT_ENA); out_le32(l2dev_gmii_reg-mac_cfg_status.mac_maxlen_cfg, CONFIG_VSC9953_MAC_MAX_LEN); out_le32(l2sys_reg-pause_cfg.pause_cfg[i], @@ -312,25 +312,23 @@ void vsc9953_init(bd_t *bis) #ifdef CONFIG_VSC9953_CMD /* Enable/disable status of a VSC9953 port */ -static void vsc9953_port_status_set(int port_nr, u8 enabled) +static void vsc9953_port_status_set(int port_no, u8 enabled) { - u32 val; struct vsc9953_qsys_reg *l2qsys_reg; /* Administrative down */ - if (vsc9953_l2sw.port[port_nr].enabled == 0) + if (!vsc9953_l2sw.port[port_no].enabled) return; l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET + VSC9953_QSYS_OFFSET); - val = in_le32(l2qsys_reg
[U-Boot] [PATCH 04/10] drivers/net/vsc9953: Refractor the parser for VSC9953 commands
In order to support multiple commands to configure the VSC9953 L2 Switch, the parser needs to be changed to be more flexible and to support more complex commands. This patch adds a parser that searches for defined keywords in the command and calls the proper function when a match is found. Also, the parser allows for optional keywords, such as port, to apply the command on a port or on all ports. The already defined commands are also changed a bit to: ethsw [port port_no] { enable | disable | show } Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I59917e064399a8c7ab8cf96ed941c42219b0826b --- drivers/net/vsc9953.c | 381 -- 1 file changed, 310 insertions(+), 71 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 9dec683..4df751a 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -10,6 +10,7 @@ #include asm/fsl_serdes.h #include fm_eth.h #include fsl_memac.h +#include errno.h #include vsc9953.h static struct vsc9953_info vsc9953_l2sw = { @@ -575,6 +576,10 @@ void vsc9953_init(bd_t *bis) } #ifdef CONFIG_VSC9953_CMD + +#define VSC9953_MAX_CMD_PARAMS 20 +#define VSC9953_CMD_PORT_ALL -1 + /* Enable/disable status of a VSC9953 port */ static void vsc9953_port_status_set(int port_no, u8 enabled) { @@ -595,15 +600,6 @@ static void vsc9953_port_status_set(int port_no, u8 enabled) CONFIG_VSC9953_PORT_ENA); } -/* Set all VSC9953 ports' status */ -static void vsc9953_port_all_status_set(u8 enabled) -{ - int i; - - for (i = 0; i VSC9953_MAX_PORTS; i++) - vsc9953_port_status_set(i, enabled); -} - /* Start autonegotiation for a VSC9953 PHY */ static void vsc9953_phy_autoneg(int port_no) { @@ -615,15 +611,6 @@ static void vsc9953_phy_autoneg(int port_no) printf(Failed to start PHY for port %d\n, port_no); } -/* Start autonegotiation for all VSC9953 PHYs */ -static void vsc9953_phy_all_autoneg(void) -{ - int i; - - for (i = 0; i VSC9953_MAX_PORTS; i++) - vsc9953_phy_autoneg(i); -} - /* Print a VSC9953 port's configuration */ static void vsc9953_port_config_show(int port_no) { @@ -685,75 +672,327 @@ static void vsc9953_port_config_show(int port_no) printf(%8s\n, duplex == DUPLEX_FULL ? full : half); } -/* Print VSC9953 ports' configuration */ -static void vsc9953_port_all_config_show(void) -{ - int i; +/* IDs used to track keywords in a command */ +enum keyword_id { + id_key_end = -1, + id_help, + id_show, + id_port, + id_enable, + id_disable, + id_count, /* keep last */ +}; - for (i = 0; i VSC9953_MAX_PORTS; i++) - vsc9953_port_config_show(i); -} +enum keyword_opt_id { + id_port_no = id_count + 1, + id_count_all, /* keep last */ +}; -/* function to interpret commands starting with ethsw */ -static int do_ethsw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +struct command_def { + int cmd_to_keywords[VSC9953_MAX_CMD_PARAMS]; + int cmd_keywords_nr; + int port; + int err; + int (*cmd_function)(struct command_def *parsed_cmd); +}; + +#define VSC9953_PORT_CONF_HELP [port port_no] { enable | disable | show } \ +- enable/disable a port; show shows a port's configuration + +static int vsc9953_port_status_key_func(struct command_def *parsed_cmd) { - u8 enable; - u32 port; + int i; + u8 enabled; - if (argc 4) + /* Last keyword should tell us if we should enable/disable the port */ + if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == + id_enable) + enabled = 1; + else if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == +id_disable) + enabled = 0; + else { + parsed_cmd-err = 1; return -1; + } - if (strcmp(argv[1], port)) - return -1; + if (parsed_cmd-port != VSC9953_CMD_PORT_ALL) { + vsc9953_port_status_set(parsed_cmd-port, enabled); + } else { + for (i = 0; i VSC9953_MAX_PORTS; i++) + vsc9953_port_status_set(i, enabled); + } + + return 0; +} + +static int vsc9953_port_config_key_func(struct command_def *parsed_cmd) +{ + int i; + + if (parsed_cmd-port != VSC9953_CMD_PORT_ALL) { + vsc9953_phy_autoneg(parsed_cmd-port); + printf(%8s %8s %8s %8s %8s\n, + Port, Status, Link, Speed, + Duplex); + vsc9953_port_config_show(parsed_cmd-port); - if (!strcmp(argv[3], show)) { - if (!strcmp(argv[2], all)) { - vsc9953_phy_all_autoneg
[U-Boot] [PATCH 02/10] drivers/net/vsc9953: Fix missing reserved register
The VSC9953 DS reserves a register between vlan_mask and anag_efil registers. Signed-off-by: Johnson Leung johnson.le...@freescale.com Change-Id: Ia7998cfcae932e8c1146dec98d6c6493b6bc1192 --- include/vsc9953.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/vsc9953.h b/include/vsc9953.h index 920402f..2b88c5c 100644 --- a/include/vsc9953.h +++ b/include/vsc9953.h @@ -147,6 +147,7 @@ struct vsc9953_ana_ana_tables { struct vsc9953_ana_ana { u32 adv_learn; u32 vlan_mask; + u32 reserved; u32 anag_efil; u32 an_events; u32 storm_limit_burst; -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 03/10] drivers/net/vsc9953: Add default configuration for VSC9953 L2 Switch
At startup, the default configuration should be: - enable HW learning on all ports (HW default); - all ports are VLAN aware; - all ports are members of VLAN 1; - all ports have Port-based VLAN 1; - on all ports, the switch is allowed to remove maximum one VLAN tag, - on egress, the switch should add a VLAN tag if the frame is classified to a different VLAN than the port's Port-based VLAN; Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I2cd5ad30371ca8f64aec51afe5bd6b3c0a66569d --- drivers/net/vsc9953.c | 266 +- include/vsc9953.h | 61 +++- 2 files changed, 325 insertions(+), 2 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 720ae47..9dec683 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -1,5 +1,5 @@ /* - * Copyright 2014 Freescale Semiconductor, Inc. + * Copyright 2014-2015 Freescale Semiconductor, Inc. * * SPDX-License-Identifier: GPL-2.0+ * @@ -176,6 +176,268 @@ static int vsc9953_port_init(int port_no) return 0; } +static int vsc9953_vlan_table_poll_idle(void) +{ + struct vsc9953_analyzer *l2ana_reg; + int timeout; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + timeout = 5; + while (((in_le32(l2ana_reg-ana_tables.vlan_access) + CONFIG_VSC9953_VLAN_CMD_MASK) != + CONFIG_VSC9953_VLAN_CMD_IDLE) --timeout) + udelay(1); + + return !!timeout; +} + +/* vlan table set/clear all membership of vid */ +static void vsc9953_vlan_table_membership_all_set(int vid, int set) +{ + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + if (!vsc9953_vlan_table_poll_idle()) { + debug(VLAN table timeout\n); + return; + } + + /* read current vlan configuration */ + clrsetbits_le32(l2ana_reg-ana_tables.vlan_tidx, + CONFIG_VSC9953_ANA_TBL_VID_MASK, + field_set(vid, CONFIG_VSC9953_ANA_TBL_VID_MASK)); + + clrsetbits_le32(l2ana_reg-ana_tables.vlan_access, + CONFIG_VSC9953_VLAN_CMD_MASK, + field_set(CONFIG_VSC9953_VLAN_CMD_READ, + CONFIG_VSC9953_VLAN_CMD_MASK)); + + if (!vsc9953_vlan_table_poll_idle()) { + debug(VLAN table timeout\n); + return; + } + + clrsetbits_le32(l2ana_reg-ana_tables.vlan_tidx, + CONFIG_VSC9953_ANA_TBL_VID_MASK, + field_set(vid, CONFIG_VSC9953_ANA_TBL_VID_MASK)); + + if (!set) + clrsetbits_le32(l2ana_reg-ana_tables.vlan_access, + CONFIG_VSC9953_VLAN_PORT_MASK | + CONFIG_VSC9953_VLAN_CMD_MASK, + field_set(CONFIG_VSC9953_VLAN_CMD_WRITE, + CONFIG_VSC9953_VLAN_CMD_MASK)); + else + clrsetbits_le32(l2ana_reg-ana_tables.vlan_access, + CONFIG_VSC9953_VLAN_PORT_MASK | + CONFIG_VSC9953_VLAN_CMD_MASK, + field_set(CONFIG_VSC9953_VLAN_CMD_WRITE, + CONFIG_VSC9953_VLAN_CMD_MASK) | + CONFIG_VSC9953_VLAN_PORT_MASK); +} + +/* Set PVID for a VSC9953 port */ +static void vsc9953_port_vlan_pvid_set(int port_no, int pvid) +{ + struct vsc9953_analyzer *l2ana_reg; + struct vsc9953_rew_reg *l2rew_reg; + + /* Administrative down */ + if ((!vsc9953_l2sw.port[port_no].enabled)) { + printf(Port %d is administrative down\n, port_no); + return; + } + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + l2rew_reg = (struct vsc9953_rew_reg *)(VSC9953_OFFSET + + VSC9953_REW_OFFSET); + + /* Set PVID on ingress */ + clrsetbits_le32(l2ana_reg-port[port_no].vlan_cfg, + CONFIG_VSC9953_VLAN_CFG_VID_MASK, + field_set(pvid, CONFIG_VSC9953_VLAN_CFG_VID_MASK)); + + /* Set PVID on egress */ + clrsetbits_le32(l2rew_reg-port[port_no].port_vlan_cfg, + CONFIG_VSC9953_PORT_VLAN_CFG_VID_MASK, + field_set(pvid, CONFIG_VSC9953_PORT_VLAN_CFG_VID_MASK)); +} + +static void vsc9953_port_all_vlan_pvid_set(int pvid) +{ + int i; + + for (i = 0; i VSC9953_MAX_PORTS; i++) + vsc9953_port_vlan_pvid_set(i, pvid); +} + +/* Enable/disable vlan aware of a VSC9953
[U-Boot] [PATCH 05/10] drivers/net/vsc9953: Add command to show/clear port counters
The new added command: ethsw [port port_no] statistics { [help] | [clear] } will print counters like the number of Rx/Tx frames, number of Rx/Tx bytes, number of Rx/Tx unicast frames, etc. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I52c4ab024a60b62afe89d4ee3e37f50174597c4b --- drivers/net/vsc9953.c | 280 ++ include/vsc9953.h | 116 - 2 files changed, 393 insertions(+), 3 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 4df751a..62ab0eb 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -672,6 +672,219 @@ static void vsc9953_port_config_show(int port_no) printf(%8s\n, duplex == DUPLEX_FULL ? full : half); } +/* Show VSC9953 ports' statistics */ +static void vsc9953_port_statistics_show(int port_no) +{ + u32 rx_val, tx_val; + struct vsc9953_system_reg *l2sys_reg; + + /* Administrative down */ + if (!vsc9953_l2sw.port[port_no].enabled) { + printf(Port %d is administrative down\n, port_no); + return; + } + + l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET + + VSC9953_SYS_OFFSET); + + printf(Statistics for L2 Switch port %d:\n, port_no); + + /* Set counter view for our port */ + out_le32(l2sys_reg-sys.stat_cfg, port_no); + +#define VSC9953_STATS_PRINTF %-15s %10u + + /* Get number of Rx and Tx frames */ + rx_val = in_le32(l2sys_reg-stat.rx_cntrs.c_rx_short) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_frag) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_jabber) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_long) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_64) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_65_127) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_128_255) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_256_511) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_512_1023) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_1024_1526) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_sz_jumbo); + tx_val = in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_64) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_65_127) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_128_255) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_256_511) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_512_1023) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_1024_1526) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_jumbo); + printf(VSC9953_STATS_PRINTF\t\tVSC9953_STATS_PRINTF\n, + Rx frames:, rx_val, Tx frames:, tx_val); + + /* Get number of Rx and Tx bytes */ + rx_val = in_le32(l2sys_reg-stat.rx_cntrs.c_rx_oct); + tx_val = in_le32(l2sys_reg-stat.tx_cntrs.c_tx_oct); + printf(VSC9953_STATS_PRINTF\t\tVSC9953_STATS_PRINTF\n, + Rx bytes:, rx_val, Tx bytes:, tx_val); + + /* Get number of Rx frames received ok and Tx frames sent ok */ + rx_val = in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_0) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_1) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_2) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_3) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_4) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_5) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_6) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_yellow_prio_7) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_0) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_1) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_2) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_3) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_4) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_5) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_6) + +in_le32(l2sys_reg-stat.rx_cntrs.c_rx_green_prio_7); + tx_val = in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_64) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_65_127) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_128_255) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_256_511) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_512_1023) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_1024_1526) + +in_le32(l2sys_reg-stat.tx_cntrs.c_tx_sz_jumbo); + printf(VSC9953_STATS_PRINTF\t\tVSC9953_STATS_PRINTF\n, + Rx frames ok:, rx_val, Tx frames ok:, tx_val); + + /* Get number of Rx and Tx unicast frames */ + rx_val
[U-Boot] [PATCH 07/10] drivers/net/vsc9953: Add commands to manipulate the FDB for VSC9953
The new command: ethsw [port port_no] [vlan vid] fdb { [help] | show | flush | { add | del } mac } Can be used to add and delete FDB entries. Also, the command can be used to show entries from the FDB tables. When used with [port port_no] and [vlan vid], only the matching the FDB entries can be seen or flushed. Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I63f2df7d2b5c885c96be4fec3874eaf994e3c26f --- drivers/net/vsc9953.c | 635 +- include/vsc9953.h | 28 +++ 2 files changed, 662 insertions(+), 1 deletion(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 1936c4a..ef7b50c 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -12,6 +12,7 @@ #include fsl_memac.h #include errno.h #include vsc9953.h +#include linux/ctype.h static struct vsc9953_info vsc9953_l2sw = { .port[0] = VSC9953_PORT_INFO_INITIALIZER(0), @@ -579,6 +580,7 @@ void vsc9953_init(bd_t *bis) #define VSC9953_MAX_CMD_PARAMS 20 #define VSC9953_CMD_PORT_ALL -1 +#define VSC9953_CMD_VLAN_ALL -1 /* Enable/disable status of a VSC9953 port */ static void vsc9953_port_status_set(int port_no, u8 enabled) @@ -952,6 +954,365 @@ static void vsc9953_port_statistics_clear(int port_no) CONFIG_VSC9953_STAT_CLEAR_DR); } +/* wait for FDB to become available */ +static int vsc9953_mac_table_poll_idle(void) +{ + struct vsc9953_analyzer *l2ana_reg; + u32 timeout; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + timeout = 5; + while (((in_le32(l2ana_reg-ana_tables.mac_access) + CONFIG_VSC9953_MAC_CMD_MASK) != +CONFIG_VSC9953_MAC_CMD_IDLE) --timeout) + udelay(1); + + return !!timeout; +} + +/* enum describing available commands for the MAC table */ +enum mac_table_cmd { + MAC_TABLE_READ_DIRECT, + MAC_TABLE_READ_INDIRECT, + MAC_TABLE_WRITE, + MAC_TABLE_LEARN, + MAC_TABLE_FORGET, + MAC_TABLE_GET_NEXT, + MAC_TABLE_AGE, +}; + +/* Issues a command to the FDB table */ +static int vsc9953_mac_table_cmd(enum mac_table_cmd cmd) +{ + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + switch (cmd) { + case MAC_TABLE_READ_DIRECT: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK | + CONFIG_VSC9953_MAC_CMD_VALID, + CONFIG_VSC9953_MAC_CMD_READ); + break; + case MAC_TABLE_READ_INDIRECT: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK, + CONFIG_VSC9953_MAC_CMD_READ | + CONFIG_VSC9953_MAC_CMD_VALID); + break; + case MAC_TABLE_WRITE: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK | + CONFIG_VSC9953_MAC_ENTRYTYPE_MASK, + CONFIG_VSC9953_MAC_CMD_WRITE | + CONFIG_VSC9953_MAC_ENTRYTYPE_LOCKED); + break; + case MAC_TABLE_LEARN: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK | + CONFIG_VSC9953_MAC_ENTRYTYPE_MASK, + CONFIG_VSC9953_MAC_CMD_LEARN | + CONFIG_VSC9953_MAC_ENTRYTYPE_LOCKED | + CONFIG_VSC9953_MAC_CMD_VALID); + break; + case MAC_TABLE_FORGET: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK | + CONFIG_VSC9953_MAC_ENTRYTYPE_MASK, + CONFIG_VSC9953_MAC_CMD_FORGET); + break; + case MAC_TABLE_GET_NEXT: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK | + CONFIG_VSC9953_MAC_ENTRYTYPE_MASK, + CONFIG_VSC9953_MAC_CMD_NEXT); + break; + case MAC_TABLE_AGE: + clrsetbits_le32(l2ana_reg-ana_tables.mac_access, + CONFIG_VSC9953_MAC_CMD_MASK | + CONFIG_VSC9953_MAC_ENTRYTYPE_MASK, + CONFIG_VSC9953_MAC_CMD_AGE); + break; + default: + printf(Unknown MAC table command\n
[U-Boot] [PATCH 06/10] drivers/net/vsc9953: Add commands to enable/disable HW learning
The command: ethsw [port port_no] learning { [help] | show | auto | disable } can be used to enable/disable HW learning on a port. Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: Id05691c342d9a9b253e591d9c64a8e13225c5e56 --- drivers/net/vsc9953.c | 188 ++ include/vsc9953.h | 6 ++ 2 files changed, 194 insertions(+) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 62ab0eb..1936c4a 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -672,6 +672,73 @@ static void vsc9953_port_config_show(int port_no) printf(%8s\n, duplex == DUPLEX_FULL ? full : half); } +enum port_learn_mode { + PORT_LEARN_NONE, + PORT_LEARN_AUTO +}; + +/* Set learning configuration for a VSC9953 port */ +static void vsc9953_port_learn_mode_set(int port_no, enum port_learn_mode mode) +{ + struct vsc9953_analyzer *l2ana_reg; + + /* Administrative down */ + if (!vsc9953_l2sw.port[port_no].enabled) { + printf(Port %d is administrative down\n, port_no); + return; + } + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + switch (mode) { + case PORT_LEARN_NONE: + clrbits_le32(l2ana_reg-port[port_no].port_cfg, +CONFIG_VSC9953_PORT_CFG_LEARN_DROP | +CONFIG_VSC9953_PORT_CFG_LEARN_CPU | +CONFIG_VSC9953_PORT_CFG_LEARN_AUTO | +CONFIG_VSC9953_PORT_CFG_LEARN_ENA); + break; + case PORT_LEARN_AUTO: + clrsetbits_le32(l2ana_reg-port[port_no].port_cfg, + CONFIG_VSC9953_PORT_CFG_LEARN_DROP | + CONFIG_VSC9953_PORT_CFG_LEARN_CPU, + CONFIG_VSC9953_PORT_CFG_LEARN_ENA | + CONFIG_VSC9953_PORT_CFG_LEARN_AUTO); + break; + default: + printf(Unknown learn mode for port %d\n, port_no); + } +} + +/* Get learning configuration for a VSC9953 port */ +static int vsc9953_port_learn_mode_get(int port_no, enum port_learn_mode *mode) +{ + u32 val; + struct vsc9953_analyzer *l2ana_reg; + + /* Administrative down */ + if (!vsc9953_l2sw.port[port_no].enabled) { + printf(Port %d is administrative down\n, port_no); + return -1; + } + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + /* For now we only support HW learning (auto) and no learning */ + val = in_le32(l2ana_reg-port[port_no].port_cfg); + if ((val (CONFIG_VSC9953_PORT_CFG_LEARN_ENA | + CONFIG_VSC9953_PORT_CFG_LEARN_AUTO)) == + (CONFIG_VSC9953_PORT_CFG_LEARN_ENA | +CONFIG_VSC9953_PORT_CFG_LEARN_AUTO)) + *mode = PORT_LEARN_AUTO; + else + *mode = PORT_LEARN_NONE; + + return 0; +} + /* Show VSC9953 ports' statistics */ static void vsc9953_port_statistics_show(int port_no) { @@ -895,6 +962,8 @@ enum keyword_id { id_disable, id_statistics, id_clear, + id_learning, + id_auto, id_count, /* keep last */ }; @@ -1002,6 +1071,84 @@ static int vsc9953_port_stats_clear_key_func(struct command_def *parsed_cmd) return 0; } +#define VSC9953_LEARN_HELP ethsw [port port_no] learning \ +{ [help] | show | auto | disable } \ +- enable/disable/show learning configuration on a port + +static int vsc9953_learn_help_key_func(struct command_def *parsed_cmd) +{ + printf(VSC9953_LEARN_HELP\n); + + return 0; +} + +static int vsc9953_learn_show_key_func(struct command_def *parsed_cmd) +{ + int i; + enum port_learn_modemode; + + if (parsed_cmd-port != VSC9953_CMD_PORT_ALL) { + if (vsc9953_port_learn_mode_get(parsed_cmd-port, mode)) + return -1; + printf(%7s %11s\n, Port, Learn mode); + switch (mode) { + case PORT_LEARN_NONE: + printf(%7d %11s\n, parsed_cmd-port, disable); + break; + case PORT_LEARN_AUTO: + printf(%7d %11s\n, parsed_cmd-port, auto); + break; + default: + printf(%7d %11s\n, parsed_cmd-port, -); + } + } else { + printf(%7s %11s\n, Port, Learn mode); + for (i = 0; i VSC9953_MAX_PORTS; i++) { + if (vsc9953_port_learn_mode_get(i, mode)) + continue; + switch (mode
[U-Boot] [PATCH] drivers/net/vsc9953: Add GPL-2.0+ SPDX-License-Identifier
Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: Ifd82465cce10e310a4f974ae70dceab838ae27db --- include/vsc9953.h | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/include/vsc9953.h b/include/vsc9953.h index 26a08aa..753abba 100644 --- a/include/vsc9953.h +++ b/include/vsc9953.h @@ -1,14 +1,9 @@ /* - * vsc9953.h + * Copyright 2014-2015 Freescale Semiconductor, Inc. * - * Driver for the Vitesse VSC9953 L2 Switch - * - * This software may be used and distributed according to the - * terms of the GNU Public License, Version 2, incorporated - * herein by reference. - * - * Copyright 2013, 2015 Freescale Semiconductor, Inc. + * SPDX-License-Identifier: GPL-2.0+ * + * Driver for the Vitesse VSC9953 L2 Switch */ #ifndef _VSC9953_H_ -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 09/10] drivers/net/vsc9953: Add command for shared/private VLAN learning
The command: ethsw vlan fdb { [help] | show | shared | private } - make VLAN learning shared or private configures the FDB to share the FDB entries learned on multiple VLANs or to keep them separated. By default, the FBD uses private VLAN learning. Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I6b2ac706ff9ef7bb9d873402b293455366cf5034 --- drivers/net/vsc9953.c | 155 ++ include/vsc9953.h | 3 + 2 files changed, 158 insertions(+) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index b78a941..3129b03 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -1503,6 +1503,58 @@ static void vsc9953_mac_table_flush(int port, int vid) vsc9953_mac_table_age(port, vid); } +/* VSC9953 VLAN learning modes */ +enum vlan_learning_mode { + SHARED_VLAN_LEARNING, + PRIVATE_VLAN_LEARNING, +}; + +/* Set VLAN learning mode for VSC9953 */ +static void vsc9953_vlan_learning_set(enum vlan_learning_mode lrn_mode) +{ + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + switch (lrn_mode) { + case SHARED_VLAN_LEARNING: + setbits_le32(l2ana_reg-ana.agen_ctrl, +CONFIG_VSC9953_FID_MASK_ALL); + break; + case PRIVATE_VLAN_LEARNING: + clrbits_le32(l2ana_reg-ana.agen_ctrl, +CONFIG_VSC9953_FID_MASK_ALL); + break; + default: + printf(Unknown VLAN learn mode\n); + } +} + +/* Get VLAN learning mode for VSC9953 */ +static int vsc9953_vlan_learning_get(enum vlan_learning_mode *lrn_mode) +{ + u32 val; + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + val = in_le32(l2ana_reg-ana.agen_ctrl); + + if (!(val CONFIG_VSC9953_FID_MASK_ALL)) { + *lrn_mode = PRIVATE_VLAN_LEARNING; + } else if ((val CONFIG_VSC9953_FID_MASK_ALL) == + CONFIG_VSC9953_FID_MASK_ALL) { + *lrn_mode = SHARED_VLAN_LEARNING; + } else { + printf(Unknown VLAN learning mode\n); + return -EINVAL; + } + + return 0; +} + enum egress_vlan_tag { EGR_TAG_CLASS = 0, EGR_TAG_PVID, @@ -1572,6 +1624,8 @@ enum keyword_id { id_egress, id_tag, id_classified, + id_shared, + id_private, id_count, /* keep last */ }; @@ -1868,6 +1922,61 @@ static int vsc9953_vlan_set_key_func(struct command_def *parsed_cmd) return 0; } +#define VSC9953_VLAN_FDB_HELP ethsw vlan fdb \ +{ [help] | show | shared | private } \ +- make VLAN learning shared or private + +static int vsc9953_vlan_learn_help_key_func(struct command_def *parsed_cmd) +{ + printf(VSC9953_VLAN_FDB_HELP\n); + + return 0; +} + +static int vsc9953_vlan_learn_show_key_func(struct command_def *parsed_cmd) +{ + int rc; + enum vlan_learning_mode mode; + + rc = vsc9953_vlan_learning_get(mode); + if (rc) + goto __out_return; + + switch (mode) { + case SHARED_VLAN_LEARNING: + printf(VLAN learning mode: shared\n); + break; + case PRIVATE_VLAN_LEARNING: + printf(VLAN learning mode: private\n); + break; + default: + printf(Unknown VLAN learning mode\n); + rc = -EINVAL; + } + +__out_return: + return rc; +} + +static int vsc9953_vlan_learn_set_key_func(struct command_def *parsed_cmd) +{ + enum vlan_learning_mode mode; + + /* keywords for shared/private are the last in the array */ + if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == + id_shared) + mode = SHARED_VLAN_LEARNING; + else if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == +id_private) + mode = PRIVATE_VLAN_LEARNING; + else + return -1; + + vsc9953_vlan_learning_set(mode); + + return 0; +} + #define VSC9953_PORT_UNTAG_HELP ethsw [port port_no] untagged \ { [help] | show | all | none | pvid } \ - set egress tagging mod for a port @@ -2331,6 +2440,45 @@ struct keywords_to_function { id_key_end, }, .keyword_function = vsc9953_fdb_entry_del_key_func, + }, { + .cmd_keyword = { + id_vlan, + id_fdb, + id_key_end
[U-Boot] [PATCH 00/10] Add more commands for VSC9953 L2 Switch
This patch set adds several features for VSC9953 L2 Switch: - VLAN configuration; - port statistics; - FDB table operations; - enable/disable HW learning; - private/shared VLAN learning. Also, the parser needed to be changed to allow commands with optional parameters and to allow developers to easily add new commands. Since new features are added, the default configuration had to be changed to: - HW learning enabled on all ports; (HW default) - All ports are in VLAN 1; - All ports are VLAN aware; - All ports have POP_COUNT 1; - All ports have PVID 1; - All ports have TPID 0x8100; (HW default) - All ports tag frames classified to all VLANs that are not PVID; If the user decides to compile the VSC9953 driver without the support for commands, the above default configuration should be sufficient to make the L2 Switch work in unmanaged mode. New supported commands: - show a port's statistics; - enable/disable/show learning configuration on a port; - add/delete a MAC entry in FDB; show the FDB table; - add/remove a VLAN to/from a port (VLAN members); - set/show PVID (ingress and egress VLAN tagging) for a port; - set egress tagging mod for a port; - configure VID source for egress tag; - make VLAN learning shared or private; - enable/disable VLAN ingress filtering on a port. Codrin Ciubotariu (10): drivers/net/vsc9953: Cleanup patch drivers/net/vsc9953: Fix missing reserved register drivers/net/vsc9953: Add default configuration for VSC9953 L2 Switch drivers/net/vsc9953: Refractor the parser for VSC9953 commands drivers/net/vsc9953: Add command to show/clear port counters drivers/net/vsc9953: Add commands to enable/disable HW learning drivers/net/vsc9953: Add commands to manipulate the FDB for VSC9953 drivers/net/vsc9953: Add VLAN commands for VSC9953 drivers/net/vsc9953: Add command for shared/private VLAN learning drivers/net/vsc9953: Add commands for VLAN ingress filtering drivers/net/vsc9953.c | 2816 ++--- include/vsc9953.h | 265 - 2 files changed, 2946 insertions(+), 135 deletions(-) -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 00/10] Add more commands for VSC9953 L2 Switch
This patch set adds several features for VSC9953 L2 Switch: - VLAN configuration; - port statistics; - FDB table operations; - enable/disable HW learning; - private/shared VLAN learning. Also, the parser needed to be changed to allow commands with optional parameters and to allow developers to easily add new commands. Since new features are added, the default configuration had to be changed to: - HW learning enabled on all ports; (HW default) - All ports are in VLAN 1; - All ports are VLAN aware; - All ports have POP_COUNT 1; - All ports have PVID 1; - All ports have TPID 0x8100; (HW default) - All ports tag frames classified to all VLANs that are not PVID; If the user decides to compile the VSC9953 driver without the support for commands, the above default configuration should be sufficient to make the L2 Switch work in unmanaged mode. New supported commands: - show a port's statistics; - enable/disable/show learning configuration on a port; - add/delete a MAC entry in FDB; show the FDB table; - add/remove a VLAN to/from a port (VLAN members); - set/show PVID (ingress and egress VLAN tagging) for a port; - set egress tagging mod for a port; - configure VID source for egress tag; - make VLAN learning shared or private; - enable/disable VLAN ingress filtering on a port. Codrin Ciubotariu (10): drivers/net/vsc9953: Cleanup patch drivers/net/vsc9953: Fix missing reserved register drivers/net/vsc9953: Add default configuration for VSC9953 L2 Switch drivers/net/vsc9953: Refractor the parser for VSC9953 commands drivers/net/vsc9953: Add command to show/clear port counters drivers/net/vsc9953: Add commands to enable/disable HW learning drivers/net/vsc9953: Add commands to manipulate the FDB for VSC9953 drivers/net/vsc9953: Add VLAN commands for VSC9953 drivers/net/vsc9953: Add command for shared/private VLAN learning drivers/net/vsc9953: Add commands for VLAN ingress filtering drivers/net/vsc9953.c | 2816 ++--- include/vsc9953.h | 265 - 2 files changed, 2946 insertions(+), 135 deletions(-) -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 01/10] drivers/net/vsc9953: Cleanup patch
This patch groups some macros defined for registers and replaces some magic numbers from vsc9953 with macros. Also, port and port_nr keywords are replaced with port_no. Also, in some places, this patch replaces in_le32 and out_le32 with clrbits_le32 and setbits_le32 to reduce the number of code lines and to assure that only intended bits of a register are changed. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: Ib5f7d94bd6a39b909bf7b70bb12e15156a7e45c9 --- drivers/net/vsc9953.c | 100 +- include/vsc9953.h | 47 2 files changed, 88 insertions(+), 59 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index fed7358..720ae47 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -25,44 +25,44 @@ static struct vsc9953_info vsc9953_l2sw = { .port[9] = VSC9953_PORT_INFO_INITIALIZER(9), }; -void vsc9953_port_info_set_mdio(int port, struct mii_dev *bus) +void vsc9953_port_info_set_mdio(int port_no, struct mii_dev *bus) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].bus = bus; + vsc9953_l2sw.port[port_no].bus = bus; } -void vsc9953_port_info_set_phy_address(int port, int address) +void vsc9953_port_info_set_phy_address(int port_no, int address) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].phyaddr = address; + vsc9953_l2sw.port[port_no].phyaddr = address; } -void vsc9953_port_info_set_phy_int(int port, phy_interface_t phy_int) +void vsc9953_port_info_set_phy_int(int port_no, phy_interface_t phy_int) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enet_if = phy_int; + vsc9953_l2sw.port[port_no].enet_if = phy_int; } -void vsc9953_port_enable(int port) +void vsc9953_port_enable(int port_no) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enabled = 1; + vsc9953_l2sw.port[port_no].enabled = 1; } -void vsc9953_port_disable(int port) +void vsc9953_port_disable(int port_no) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enabled = 0; + vsc9953_l2sw.port[port_no].enabled = 0; } static void vsc9953_mdio_write(struct vsc9953_mii_mng *phyregs, int port_addr, @@ -148,21 +148,21 @@ static int init_phy(struct eth_device *dev) return 0; } -static int vsc9953_port_init(int port) +static int vsc9953_port_init(int port_no) { struct eth_device *dev; /* Internal ports never have a PHY */ - if (VSC9953_INTERNAL_PORT_CHECK(port)) + if (VSC9953_INTERNAL_PORT_CHECK(port_no)) return 0; /* alloc eth device */ dev = (struct eth_device *)calloc(1, sizeof(struct eth_device)); if (!dev) - return 1; + return -1; - sprintf(dev-name, SW@PORT%d, port); - dev-priv = vsc9953_l2sw.port[port]; + sprintf(dev-name, SW@PORT%d, port_no); + dev-priv = vsc9953_l2sw.port[port_no]; dev-init = NULL; dev-halt = NULL; dev-send = NULL; @@ -170,7 +170,7 @@ static int vsc9953_port_init(int port) if (init_phy(dev)) { free(dev); - return 1; + return -1; } return 0; @@ -255,8 +255,8 @@ void vsc9953_init(bd_t *bis) out_le32(l2dev_gmii_reg-mac_cfg_status.mac_hdx_cfg, hdx_cfg); out_le32(l2sys_reg-sys.front_port_mode[i], CONFIG_VSC9953_FRONT_PORT_MODE); - out_le32(l2qsys_reg-sys.switch_port_mode[i], -CONFIG_VSC9953_PORT_ENA); + setbits_le32(l2qsys_reg-sys.switch_port_mode[i], +CONFIG_VSC9953_PORT_ENA); out_le32(l2dev_gmii_reg-mac_cfg_status.mac_maxlen_cfg, CONFIG_VSC9953_MAC_MAX_LEN); out_le32(l2sys_reg-pause_cfg.pause_cfg[i], @@ -312,25 +312,23 @@ void vsc9953_init(bd_t *bis) #ifdef CONFIG_VSC9953_CMD /* Enable/disable status of a VSC9953 port */ -static void vsc9953_port_status_set(int port_nr, u8 enabled) +static void vsc9953_port_status_set(int port_no, u8 enabled) { - u32 val; struct vsc9953_qsys_reg *l2qsys_reg; /* Administrative down */ - if (vsc9953_l2sw.port[port_nr].enabled == 0) + if (!vsc9953_l2sw.port[port_no].enabled) return; l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET + VSC9953_QSYS_OFFSET); - val = in_le32(l2qsys_reg
[U-Boot] [PATCH 10/10] drivers/net/vsc9953: Add commands for VLAN ingress filtering
The command: ethsw [port port_no] ingress filtering { [help] | show | enable | disable } - enable/disable VLAN ingress filtering on port can be used to enable/disable/show VLAN ingress filtering on a port. Signed-off-by: Johnson Leung johnson.le...@freescale.com Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I658ef613724e3e1dbf78babde985c4d11c4a2706 --- drivers/net/vsc9953.c | 137 ++ 1 file changed, 137 insertions(+) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 3129b03..d5520d9 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -1555,6 +1555,33 @@ static int vsc9953_vlan_learning_get(enum vlan_learning_mode *lrn_mode) return 0; } +/* Enable/disable VLAN ingress filtering on a VSC9953 port */ +static void vsc9953_port_ingress_filtering_set(int port_no, int enabled) +{ + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + if (enabled) + setbits_le32(l2ana_reg-ana.vlan_mask, 1 port_no); + else + clrbits_le32(l2ana_reg-ana.vlan_mask, 1 port_no); +} + +/* Show VLAN ingress filtering on a VSC9953 port */ +static void vsc9953_port_ingress_filtering_get(int port_no, int *enabled) +{ + u32 val; + struct vsc9953_analyzer *l2ana_reg; + + l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + + VSC9953_ANA_OFFSET); + + val = in_le32(l2ana_reg-ana.vlan_mask); + *enabled = !!(val (1 port_no)); +} + enum egress_vlan_tag { EGR_TAG_CLASS = 0, EGR_TAG_PVID, @@ -1626,6 +1653,8 @@ enum keyword_id { id_classified, id_shared, id_private, + id_ingress, + id_filtering, id_count, /* keep last */ }; @@ -2031,6 +2060,68 @@ static int vsc9953_port_untag_set_key_func(struct command_def *parsed_cmd) return 0; } +#define VSC9953_PORT_INGR_FLTR_HELP ethsw [port port_no] ingress filtering \ + { [help] | show | enable | disable } \ +- enable/disable VLAN ingress filtering on port + +static int vsc9953_ingr_fltr_help_key_func(struct command_def *parsed_cmd) +{ + printf(VSC9953_PORT_INGR_FLTR_HELP\n); + + return 0; +} + +static int vsc9953_ingr_fltr_show_key_func(struct command_def *parsed_cmd) +{ + int i, enabled; + + printf(%7s\t%18s\n, Port, Ingress filtering); + if (parsed_cmd-port != VSC9953_CMD_PORT_ALL) { + vsc9953_port_ingress_filtering_get(parsed_cmd-port, enabled); + printf(%7d\t%18s\n, parsed_cmd-port, enabled ? enable : + disable); + } else { + for (i = 0; i VSC9953_MAX_PORTS; i++) { + vsc9953_port_ingress_filtering_get(i, enabled); + printf(%7d\t%18s\n, parsed_cmd-port, enabled ? + enable : + disable); + } + } + + return 0; +} + +static int vsc9953_ingr_fltr_set_key_func(struct command_def *parsed_cmd) +{ + int i, enable; + + /* keywords for enabling/disabling ingress filtering +* are the last in the array +*/ + if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == + id_enable) + enable = 1; + else if (parsed_cmd-cmd_to_keywords[parsed_cmd-cmd_keywords_nr - 1] == +id_disable) + enable = 0; + else + return -1; + + if (parsed_cmd-port != VSC9953_CMD_PORT_ALL) { + if (!VSC9953_PORT_CHECK(parsed_cmd-port)) { + printf(Invalid port number: %d\n, parsed_cmd-port); + return -1; + } + vsc9953_port_ingress_filtering_set(parsed_cmd-port, enable); + } else { + for (i = 0; i VSC9953_MAX_PORTS; i++) + vsc9953_port_ingress_filtering_set(i, enable); + } + + return 0; +} + #define VSC9953_EGR_VLAN_TAG_HELP ethsw [port port_no] egress tag \ { [help] | show | pvid | classified } \ - Configure VID source for egress tag. \ @@ -2479,6 +2570,45 @@ struct keywords_to_function { id_key_end, }, .keyword_function = vsc9953_vlan_learn_set_key_func, + }, { + .cmd_keyword = { + id_ingress, + id_filtering, + -1, + }, + .keyword_function
[U-Boot] [PATCH v2] mpc85xx/T1040D4RDB: Disable all CPLD interrupts, except QSGMI1 and QSGMI2
By default, CPLD used by Freescale's T1040D4RDB has all the interrupt sources enabled. If the interrupt line is enabled in the OS and one of these sources rises the interrupt without having a driver to handle it, then the board will get an interrupt storm. This patch masks all the interrupts available in CPLD with exception for QSGMII PHY interrupts, for which we have a driver in Linux. This patch depends on patches: mpc85xx/T104xD4RDB: Add T104xD4RDB boards support mpc85xx/T1042D4RDB: Select DIU in cpld mux for T1042D4RDB Changes in v2: - assure that the new CPLD register is available only for T104XD4RDB boards; - added debug message if the CPLD verison doesn't support the int_mask register; - add defines for all interrupt mask bits. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- board/freescale/t104xrdb/cpld.c | 4 board/freescale/t104xrdb/cpld.h | 4 board/freescale/t104xrdb/t104xrdb.c | 11 +++ include/configs/T104xRDB.h | 12 4 files changed, 31 insertions(+) diff --git a/board/freescale/t104xrdb/cpld.c b/board/freescale/t104xrdb/cpld.c index df0e348..0ce4e47 100644 --- a/board/freescale/t104xrdb/cpld.c +++ b/board/freescale/t104xrdb/cpld.c @@ -69,7 +69,11 @@ static void cpld_dump_regs(void) printf(int_status = 0x%02x\n, CPLD_READ(int_status)); printf(flash_ctl_status = 0x%02x\n, CPLD_READ(flash_ctl_status)); printf(fan_ctl_status = 0x%02x\n, CPLD_READ(fan_ctl_status)); +#if defined(CONFIG_T104XD4RDB) + printf(int_mask = 0x%02x\n, CPLD_READ(int_mask)); +#else printf(led_ctl_status = 0x%02x\n, CPLD_READ(led_ctl_status)); +#endif printf(sfp_ctl_status = 0x%02x\n, CPLD_READ(sfp_ctl_status)); printf(misc_ctl_status = 0x%02x\n, CPLD_READ(misc_ctl_status)); printf(boot_override= 0x%02x\n, CPLD_READ(boot_override)); diff --git a/board/freescale/t104xrdb/cpld.h b/board/freescale/t104xrdb/cpld.h index 543ab53..2fb4105 100644 --- a/board/freescale/t104xrdb/cpld.h +++ b/board/freescale/t104xrdb/cpld.h @@ -21,7 +21,11 @@ struct cpld_data { u8 int_status; /* 0x12 - Interrupt status Register */ u8 flash_ctl_status;/* 0x13 - Flash control and status register */ u8 fan_ctl_status; /* 0x14 - Fan control and status register */ +#if defined(CONFIG_T104XD4RDB) + u8 int_mask;/* 0x15 - Interrupt mask Register */ +#else u8 led_ctl_status; /* 0x15 - LED control and status register */ +#endif u8 sfp_ctl_status; /* 0x16 - SFP control and status register */ u8 misc_ctl_status; /* 0x17 - Miscellanies ctrl status register*/ u8 boot_override; /* 0x18 - Boot override register */ diff --git a/board/freescale/t104xrdb/t104xrdb.c b/board/freescale/t104xrdb/t104xrdb.c index 963cae4..c4b658d 100644 --- a/board/freescale/t104xrdb/t104xrdb.c +++ b/board/freescale/t104xrdb/t104xrdb.c @@ -112,6 +112,17 @@ int misc_init_r(void) CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) | MISC_CTL_SG_SEL | MISC_CTL_AURORA_SEL); +#if defined(CONFIG_T1040D4RDB) + /* Mask all CPLD interrupt sources, except QSGMII interrupts */ + if (CPLD_READ(sw_ver) 0x03) { + debug(CPLD SW version 0x%02x doesn't support int_mask\n, + CPLD_READ(sw_ver)); + } else { + CPLD_WRITE(int_mask, CPLD_INT_MASK_ALL + ~(CPLD_INT_MASK_QSGMII1 | CPLD_INT_MASK_QSGMII2)); + } +#endif + return 0; } diff --git a/include/configs/T104xRDB.h b/include/configs/T104xRDB.h index baccbb5..d37f063 100644 --- a/include/configs/T104xRDB.h +++ b/include/configs/T104xRDB.h @@ -295,6 +295,18 @@ $(SRCTREE)/board/freescale/t104xrdb/t1042d4_rcw.cfg #define CPLD_DIU_SEL_DFP 0xc0 #endif +#if defined(CONFIG_T1040D4RDB) +#define CPLD_INT_MASK_ALL 0xFF +#define CPLD_INT_MASK_THERM0x80 +#define CPLD_INT_MASK_DVI_DFP 0x40 +#define CPLD_INT_MASK_QSGMII1 0x20 +#define CPLD_INT_MASK_QSGMII2 0x10 +#define CPLD_INT_MASK_SGMI10x08 +#define CPLD_INT_MASK_SGMI20x04 +#define CPLD_INT_MASK_TDMR10x02 +#define CPLD_INT_MASK_TDMR20x01 +#endif + #define CONFIG_SYS_CPLD_BASE 0xffdf #define CONFIG_SYS_CPLD_BASE_PHYS (0xfull | CONFIG_SYS_CPLD_BASE) #define CONFIG_SYS_CSPR2_EXT (0xf) -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] mpc85xx/T1040D4RDB: Disable all CPLD interrupts, except QSGMI1 and QSGMI2
By default, CPLD used by Freescale's T1040D4RDB has all the interrupt sources enabled. If the interrupt line is enabled in the OS and one of these sources rises the interrupt without having a driver to handle it, then the board will get an interrupt storm. This patch masks all the interrupts available in CPLD with exception for QSGMII PHY interrupts, for which we have a driver in Linux. This patch depends on patches: mpc85xx/T104xD4RDB: Add T104xD4RDB boards support mpc85xx/T1042D4RDB: Select DIU in cpld mux for T1042D4RDB Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- board/freescale/t104xrdb/cpld.c | 2 +- board/freescale/t104xrdb/cpld.h | 2 +- board/freescale/t104xrdb/t104xrdb.c | 11 +++ include/configs/T104xRDB.h | 6 ++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/board/freescale/t104xrdb/cpld.c b/board/freescale/t104xrdb/cpld.c index df0e348..12b4126 100644 --- a/board/freescale/t104xrdb/cpld.c +++ b/board/freescale/t104xrdb/cpld.c @@ -69,7 +69,7 @@ static void cpld_dump_regs(void) printf(int_status = 0x%02x\n, CPLD_READ(int_status)); printf(flash_ctl_status = 0x%02x\n, CPLD_READ(flash_ctl_status)); printf(fan_ctl_status = 0x%02x\n, CPLD_READ(fan_ctl_status)); - printf(led_ctl_status = 0x%02x\n, CPLD_READ(led_ctl_status)); + printf(int_mask = 0x%02x\n, CPLD_READ(int_mask)); printf(sfp_ctl_status = 0x%02x\n, CPLD_READ(sfp_ctl_status)); printf(misc_ctl_status = 0x%02x\n, CPLD_READ(misc_ctl_status)); printf(boot_override= 0x%02x\n, CPLD_READ(boot_override)); diff --git a/board/freescale/t104xrdb/cpld.h b/board/freescale/t104xrdb/cpld.h index 543ab53..d4cfc87 100644 --- a/board/freescale/t104xrdb/cpld.h +++ b/board/freescale/t104xrdb/cpld.h @@ -21,7 +21,7 @@ struct cpld_data { u8 int_status; /* 0x12 - Interrupt status Register */ u8 flash_ctl_status;/* 0x13 - Flash control and status register */ u8 fan_ctl_status; /* 0x14 - Fan control and status register */ - u8 led_ctl_status; /* 0x15 - LED control and status register */ + u8 int_mask;/* 0x15 - Interrupt mask Register */ u8 sfp_ctl_status; /* 0x16 - SFP control and status register */ u8 misc_ctl_status; /* 0x17 - Miscellanies ctrl status register*/ u8 boot_override; /* 0x18 - Boot override register */ diff --git a/board/freescale/t104xrdb/t104xrdb.c b/board/freescale/t104xrdb/t104xrdb.c index 963cae4..c4b658d 100644 --- a/board/freescale/t104xrdb/t104xrdb.c +++ b/board/freescale/t104xrdb/t104xrdb.c @@ -112,6 +112,17 @@ int misc_init_r(void) CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) | MISC_CTL_SG_SEL | MISC_CTL_AURORA_SEL); +#if defined(CONFIG_T1040D4RDB) + /* Mask all CPLD interrupt sources, except QSGMII interrupts */ + if (CPLD_READ(sw_ver) 0x03) { + debug(CPLD SW version 0x%02x doesn't support int_mask\n, + CPLD_READ(sw_ver)); + } else { + CPLD_WRITE(int_mask, CPLD_INT_MASK_ALL + ~(CPLD_INT_MASK_QSGMII1 | CPLD_INT_MASK_QSGMII2)); + } +#endif + return 0; } diff --git a/include/configs/T104xRDB.h b/include/configs/T104xRDB.h index 91c567d..fd19fb3 100644 --- a/include/configs/T104xRDB.h +++ b/include/configs/T104xRDB.h @@ -295,6 +295,12 @@ $(SRCTREE)/board/freescale/t104xrdb/t1042d4_rcw.cfg #define CPLD_DIU_SEL_DFP 0xc0 #endif +#if defined(CONFIG_T1040D4RDB) +#define CPLD_INT_MASK_ALL 0xFF +#define CPLD_INT_MASK_QSGMII1 0x20 +#define CPLD_INT_MASK_QSGMII2 0x10 +#endif + #define CONFIG_SYS_CPLD_BASE 0xffdf #define CONFIG_SYS_CPLD_BASE_PHYS (0xfull | CONFIG_SYS_CPLD_BASE) #define CONFIG_SYS_CSPR2_EXT (0xf) -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] T104xD4RDB: Enable L2 Switch on T104xD4RDB board
This patch enables L2 Switch support for board T104xRDB by defining CONFIG_VSC9953(_CMD) and the addresses for QSGMII Ethernet PHYs. This patch depends on patch: mpc85xx/T104xD4RDB: Add T104xD4RDB boards support Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- include/configs/T104xRDB.h | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/configs/T104xRDB.h b/include/configs/T104xRDB.h index f11db1d..f4006ee 100644 --- a/include/configs/T104xRDB.h +++ b/include/configs/T104xRDB.h @@ -746,11 +746,16 @@ $(SRCTREE)/board/freescale/t104xrdb/t1042d4_rcw.cfg #endif /* Enable VSC9953 L2 Switch driver on T1040 SoC */ -#ifdef CONFIG_T1040RDB +#if defined(CONFIG_T1040RDB) || defined(CONFIG_T1040D4RDB) #define CONFIG_VSC9953 #define CONFIG_VSC9953_CMD +#ifdef CONFIG_T1040RDB #define CONFIG_SYS_FM1_QSGMII11_PHY_ADDR 0x04 #define CONFIG_SYS_FM1_QSGMII21_PHY_ADDR 0x08 +#else +#define CONFIG_SYS_FM1_QSGMII11_PHY_ADDR 0x08 +#define CONFIG_SYS_FM1_QSGMII21_PHY_ADDR 0x0c +#endif #endif #define CONFIG_MII /* MII PHY management */ -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] net/phy/realtek: Disable interrupt on Realtek Ethernet PHY drivers
Some Realtek Ethernet PHYs, like RTL8211D(G/N) and RTL8211E(G), have interrupts enabled by default. If the interrupt is not treated later by the OS and the PHY's interrupt line is enabled and shared with other interrupts, the system will get an interrupt storm. This patch disables the interrupt for PHY devices that use one of the current Realtek Ethernet PHY drivers. Some of Realtek Ethernet PHYs, such as RTL8211B(L) have the interrupt masked. In this case, the functionality of the PHY should not be afected since this patch brings INER and INSR registers to their default values. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: Ic5e353da24f8fec335e446098ed863991a64 --- drivers/net/phy/realtek.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index a3ace68..ee97079 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -3,7 +3,7 @@ * * SPDX-License-Identifier:GPL-2.0+ * - * Copyright 2010-2011 Freescale Semiconductor, Inc. + * Copyright 2010-2011, 2015 Freescale Semiconductor, Inc. * author Andy Fleming */ #include config.h @@ -21,12 +21,28 @@ #define MIIM_RTL8211x_PHYSTAT_SPDDONE 0x0800 #define MIIM_RTL8211x_PHYSTAT_LINK 0x0400 +/* RTL8211x PHY Interrupt Enable Register */ +#define MIIM_RTL8211x_PHY_INER 0x12 +#define MIIM_RTL8211x_PHY_INTR_ENA 0x9f01 +#define MIIM_RTL8211x_PHY_INTR_DIS 0x + +/* RTL8211x PHY Interrupt Status Register */ +#define MIIM_RTL8211x_PHY_INSR 0x13 /* RealTek RTL8211x */ static int rtl8211x_config(struct phy_device *phydev) { phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET); + /* mask interrupt at init; if the interrupt is +* needed indeed, it should be explicitly enabled +*/ + phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER, + MIIM_RTL8211x_PHY_INTR_DIS); + + /* read interrupt status just to clear it */ + phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER); + genphy_config_aneg(phydev); return 0; -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 11/11] board/T1040rdb: Add VSC9953 support for T1040rdb board
This patch configures and initializes the L2 switch on T1040rdb board. The external L2 switch ports may be connected to PHYs only over QSGMII, for T1040rdb. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: None Changes for v3: - Removed Change-id line from comment; Changes for v4: - add define for VSC9953 L2 Switch driver in T1040RDB board config file; board/freescale/t104xrdb/eth.c | 50 ++ include/configs/T104xRDB.h | 8 +++ 2 files changed, 58 insertions(+) diff --git a/board/freescale/t104xrdb/eth.c b/board/freescale/t104xrdb/eth.c index f5c0ec8..7581a4cd 100644 --- a/board/freescale/t104xrdb/eth.c +++ b/board/freescale/t104xrdb/eth.c @@ -6,11 +6,13 @@ #include common.h #include netdev.h +#include asm/fsl_serdes.h #include asm/immap_85xx.h #include fm_eth.h #include fsl_mdio.h #include malloc.h #include asm/fsl_dtsec.h +#include vsc9953.h #include ../common/fman.h @@ -20,6 +22,11 @@ int board_eth_init(bd_t *bis) struct memac_mdio_info memac_mdio_info; unsigned int i; int phy_addr = 0; +#ifdef CONFIG_VSC9953 + phy_interface_t phy_int; + struct mii_dev *bus; +#endif + printf(Initializing Fman\n); memac_mdio_info.regs = @@ -81,6 +88,49 @@ int board_eth_init(bd_t *bis) DEFAULT_FM_MDIO_NAME)); } +#ifdef CONFIG_VSC9953 + /* SerDes configured for QSGMII */ + if (serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_A) = 0) { + for (i = 0; i 4; i++) { + bus = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME); + phy_addr = CONFIG_SYS_FM1_QSGMII11_PHY_ADDR + i; + phy_int = PHY_INTERFACE_MODE_QSGMII; + + vsc9953_port_info_set_mdio(i, bus); + vsc9953_port_info_set_phy_address(i, phy_addr); + vsc9953_port_info_set_phy_int(i, phy_int); + vsc9953_port_enable(i); + } + } + if (serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_B) = 0) { + for (i = 4; i 8; i++) { + bus = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME); + phy_addr = CONFIG_SYS_FM1_QSGMII21_PHY_ADDR + i - 4; + phy_int = PHY_INTERFACE_MODE_QSGMII; + + vsc9953_port_info_set_mdio(i, bus); + vsc9953_port_info_set_phy_address(i, phy_addr); + vsc9953_port_info_set_phy_int(i, phy_int); + vsc9953_port_enable(i); + } + } + + /* Connect DTSEC1 to L2 switch if it doesn't have a PHY */ + if (serdes_get_first_lane(FSL_SRDS_1, SGMII_FM1_DTSEC1) 0) + vsc9953_port_enable(8); + + /* Connect DTSEC2 to L2 switch if it doesn't have a PHY */ + if (serdes_get_first_lane(FSL_SRDS_1, SGMII_FM1_DTSEC2) 0) { + /* Enable L2 On MAC2 using SCFG */ + struct ccsr_scfg *scfg = (struct ccsr_scfg *) + CONFIG_SYS_MPC85xx_SCFG; + + out_be32(scfg-esgmiiselcr, in_be32(scfg-esgmiiselcr) | +(0x8000)); + vsc9953_port_enable(9); + } +#endif + cpu_eth_init(bis); #endif diff --git a/include/configs/T104xRDB.h b/include/configs/T104xRDB.h index 57cdf72..d47f1be 100644 --- a/include/configs/T104xRDB.h +++ b/include/configs/T104xRDB.h @@ -726,6 +726,14 @@ #define CONFIG_SYS_RGMII1_PHY_ADDR 0x01 #define CONFIG_SYS_RGMII2_PHY_ADDR 0x02 +/* Enable VSC9953 L2 Switch driver on T1040 SoC */ +#ifdef CONFIG_T1040RDB +#define CONFIG_VSC9953 +#define CONFIG_VSC9953_CMD +#define CONFIG_SYS_FM1_QSGMII11_PHY_ADDR 0x04 +#define CONFIG_SYS_FM1_QSGMII21_PHY_ADDR 0x08 +#endif + #define CONFIG_MII /* MII PHY management */ #define CONFIG_ETHPRIMEFM1@DTSEC4 #define CONFIG_PHY_GIGE/* Include GbE speed/duplex detection */ -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 06/11] arch/powerpc: Initialize VSC9953 L2 Switch
This patch initializes VSC9953 L2 Switch for boards that have CONFIG_VSC9953 defined in their config file. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - added patch description; Changes for v3: - Removed Change-id line from comment; Changes for v4: - removed define CONFIG_VSC9953 from SoC config header; - patch title and comment changed to reflect the new change; arch/powerpc/cpu/mpc8xxx/cpu.c | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/powerpc/cpu/mpc8xxx/cpu.c b/arch/powerpc/cpu/mpc8xxx/cpu.c index 2d28eb2..c92589f 100644 --- a/arch/powerpc/cpu/mpc8xxx/cpu.c +++ b/arch/powerpc/cpu/mpc8xxx/cpu.c @@ -15,6 +15,7 @@ #include netdev.h #include asm/cache.h #include asm/io.h +#include vsc9953.h DECLARE_GLOBAL_DATA_PTR; @@ -271,5 +272,9 @@ int cpu_eth_init(bd_t *bis) #ifdef CONFIG_FMAN_ENET fm_standard_init(bis); #endif + +#ifdef CONFIG_VSC9953 + vsc9953_init(bis); +#endif return 0; } -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 10/11] board/T1040qds: Add VSC9953 support for T1040qds board
This patch configures and initializes the L2 switch on T1040QDS board. The L2 switch ports must be initialized according to the SerDes protocols. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: None Changes for v3: - Removed Change-id line from comment; Changes for v4: - add define for VSC9953 L2 Switch driver in T1040QDS board config file; board/freescale/t1040qds/eth.c | 91 ++ include/configs/T1040QDS.h | 6 +++ 2 files changed, 97 insertions(+) diff --git a/board/freescale/t1040qds/eth.c b/board/freescale/t1040qds/eth.c index 2f8e753..8c82934 100644 --- a/board/freescale/t1040qds/eth.c +++ b/board/freescale/t1040qds/eth.c @@ -18,6 +18,7 @@ #include fsl_mdio.h #include malloc.h #include asm/fsl_dtsec.h +#include vsc9953.h #include ../common/fman.h #include ../common/qixis.h @@ -439,6 +440,12 @@ int board_eth_init(bd_t *bis) #ifdef CONFIG_FMAN_ENET struct memac_mdio_info memac_mdio_info; unsigned int i; +#ifdef CONFIG_VSC9953 + int lane; + int phy_addr; + phy_interface_t phy_int; + struct mii_dev *bus; +#endif printf(Initializing Fman\n); set_brdcfg9_for_gtx_clk(); @@ -493,6 +500,90 @@ int board_eth_init(bd_t *bis) } } +#ifdef CONFIG_VSC9953 + for (i = 0; i VSC9953_MAX_PORTS; i++) { + lane = -1; + phy_addr = 0; + phy_int = PHY_INTERFACE_MODE_NONE; + switch (i) { + case 0: + case 1: + case 2: + case 3: + lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_A); + /* PHYs connected over QSGMII */ + if (lane = 0) { + phy_addr = CONFIG_SYS_FM1_QSGMII21_PHY_ADDR + + i; + phy_int = PHY_INTERFACE_MODE_QSGMII; + break; + } + lane = serdes_get_first_lane(FSL_SRDS_1, + SGMII_SW1_MAC1 + i); + + if (lane 0) + break; + + /* PHYs connected over QSGMII */ + if (i != 3 || lane_to_slot[lane] == 7) + phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR + + i; + else + phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR; + phy_int = PHY_INTERFACE_MODE_SGMII; + break; + case 4: + case 5: + case 6: + case 7: + lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_B); + /* PHYs connected over QSGMII */ + if (lane = 0) { + phy_addr = CONFIG_SYS_FM1_QSGMII11_PHY_ADDR + + i - 4; + phy_int = PHY_INTERFACE_MODE_QSGMII; + break; + } + lane = serdes_get_first_lane(FSL_SRDS_1, + SGMII_SW1_MAC1 + i); + /* PHYs connected over SGMII */ + if (lane = 0) { + phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR + + i - 3; + phy_int = PHY_INTERFACE_MODE_SGMII; + } + break; + case 8: + if (serdes_get_first_lane(FSL_SRDS_1, + SGMII_FM1_DTSEC1) 0) + /* FM1@DTSEC1 is connected to SW1@PORT8 */ + vsc9953_port_enable(i); + break; + case 9: + if (serdes_get_first_lane(FSL_SRDS_1, + SGMII_FM1_DTSEC2) 0) { + /* Enable L2 On MAC2 using SCFG */ + struct ccsr_scfg *scfg = (struct ccsr_scfg *) + CONFIG_SYS_MPC85xx_SCFG; + + out_be32(scfg-esgmiiselcr, +in_be32(scfg-esgmiiselcr) | +(0x8000)); + vsc9953_port_enable(i); + } + break; + } + + if (lane = 0) { + bus = mii_dev_for_muxval(lane_to_slot[lane]); + vsc9953_port_info_set_mdio(i, bus); + vsc9953_port_enable(i
[U-Boot] [PATCH v3 05/11] net/vsc9953: Add driver for Vitesse VSC9953 L2 Switch IP
This patch adds a driver for VSC9953 L2 Switch. This Vitesse IP is integrated in Freescale T1040 and T1020 SoCs. The L2 switch has 10 Ethernet ports: 2 internal fixed-links (ports 8 and 9) at 2.5 Gbps and and 8 external ports at 1 Gbps. The external ports may be connected to PHYs over QSGMII and SGMII. Commands have also been added to enable/disable a port and to check a port's link speed, duplexity and status. The commands are: ethsw port port_nr enable|disable - enable/disable an l2 switch port ethsw port port_nr show - show an l2 switch port's configuration port_nr=0..9; use all for all ports For more detailse please see doc/README.t1040-l2switch Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - added debug messages if MDIO reads or writes timeout; - added debug messages when reset of VSC9953 switch fails; - replaced Copyright and license to the generic one; Changes for v3: Removed Change-id line from comment; doc/README.t1040-l2switch | 49 + drivers/net/Makefile | 1 + drivers/net/vsc9953.c | 497 ++ include/vsc9953.h | 402 + 4 files changed, 949 insertions(+) create mode 100644 doc/README.t1040-l2switch create mode 100644 drivers/net/vsc9953.c create mode 100644 include/vsc9953.h diff --git a/doc/README.t1040-l2switch b/doc/README.t1040-l2switch new file mode 100644 index 000..6324f18 --- /dev/null +++ b/doc/README.t1040-l2switch @@ -0,0 +1,49 @@ +This file contains information for VSC9953, a Vitesse L2 Switch IP +which is integrated in the T1040/T1020 Freescale SoCs. + +About Device: += +VSC9953 is an 8-port Gigabit Ethernet switch supports the following features: + - 8192 MAC addresses + - Static Address provisioning + - Dynamic learning of MAC addresses and aging + - 4096 VLANs + - Independent and shared VLAN learning (IVL, SVL) + - Policing with storm control and MC/BC protection + - IPv4 and IPv6 multicast + - Jumbo frames (9.6 KB) + - Access Control List + - VLAN editing, translation and remarking + - RMON counters per port + +Switch interfaces: + - 8 Gigabit switch ports (ports 0 to 7) are external and are connected to external PHYs + - 2 switch ports (ports 8 and 9) of 2.5 G are connected (fixed links) + to FMan ports (FM1@DTSEC1 and FM1@DTSEC2) + +Commands Overview: += +Commands supported + - enable/disable a port + - check a port's link speed, duplexity and status. + +Commands syntax + ethsw port port_nr enable|disable - enable/disable an l2 switch port + ethsw port port_nr show - show an l2 switch port's configuration + + port_nr=0..9; use all for all ports + += ethsw port all show +Port Status LinkSpeed Duplex + 0 enabled down 10 half + 1 enabled down 10 half + 2 enabled down 10 half + 3 enabled up 1000 full + 4 disabled down- half + 5 disabled down- half + 6 disabled down- half + 7 disabled down- half + 8 enabled up 2500 full + 9 enabled up 2500 full += + diff --git a/drivers/net/Makefile b/drivers/net/Makefile index fb0cf8c..46c4ac6 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -66,3 +66,4 @@ obj-$(CONFIG_XILINX_LL_TEMAC) += xilinx_ll_temac.o xilinx_ll_temac_mdio.o \ xilinx_ll_temac_fifo.o xilinx_ll_temac_sdma.o obj-$(CONFIG_ZYNQ_GEM) += zynq_gem.o obj-$(CONFIG_FSL_MC_ENET) += fsl_mc/ +obj-$(CONFIG_VSC9953) += vsc9953.o diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c new file mode 100644 index 000..9fc3c18 --- /dev/null +++ b/drivers/net/vsc9953.c @@ -0,0 +1,497 @@ +/* + * Copyright 2014 Freescale Semiconductor, Inc. + * + * SPDX-License-Identifier: GPL-2.0+ + * + * Driver for the Vitesse VSC9953 L2 Switch + */ + +#include asm/io.h +#include asm/fsl_serdes.h +#include fm_eth.h +#include asm/fsl_memac.h +#include vsc9953.h + +static struct vsc9953_info vsc9953_l2sw = { + .port[0] = VSC9953_PORT_INFO_INITIALIZER(0), + .port[1] = VSC9953_PORT_INFO_INITIALIZER(1), + .port[2] = VSC9953_PORT_INFO_INITIALIZER(2), + .port[3] = VSC9953_PORT_INFO_INITIALIZER(3), + .port[4] = VSC9953_PORT_INFO_INITIALIZER(4), + .port[5] = VSC9953_PORT_INFO_INITIALIZER(5), + .port[6] = VSC9953_PORT_INFO_INITIALIZER(6), + .port[7] = VSC9953_PORT_INFO_INITIALIZER(7), + .port[8] = VSC9953_PORT_INFO_INITIALIZER(8), + .port[9] = VSC9953_PORT_INFO_INITIALIZER(9
[U-Boot] [PATCH v3 11/11] board/T1040rdb: Add VSC9953 support for T1040rdb board
This patch configures and initializes the L2 switch on T1040rdb board. The external L2 switch ports may be connected to PHYs only over QSGMII, for T1040rdb. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: None Changed for v3: - Removed Change-id line from comment; board/freescale/t104xrdb/eth.c | 50 ++ include/configs/T104xRDB.h | 6 + 2 files changed, 56 insertions(+) diff --git a/board/freescale/t104xrdb/eth.c b/board/freescale/t104xrdb/eth.c index f5c0ec8..7581a4cd 100644 --- a/board/freescale/t104xrdb/eth.c +++ b/board/freescale/t104xrdb/eth.c @@ -6,11 +6,13 @@ #include common.h #include netdev.h +#include asm/fsl_serdes.h #include asm/immap_85xx.h #include fm_eth.h #include fsl_mdio.h #include malloc.h #include asm/fsl_dtsec.h +#include vsc9953.h #include ../common/fman.h @@ -20,6 +22,11 @@ int board_eth_init(bd_t *bis) struct memac_mdio_info memac_mdio_info; unsigned int i; int phy_addr = 0; +#ifdef CONFIG_VSC9953 + phy_interface_t phy_int; + struct mii_dev *bus; +#endif + printf(Initializing Fman\n); memac_mdio_info.regs = @@ -81,6 +88,49 @@ int board_eth_init(bd_t *bis) DEFAULT_FM_MDIO_NAME)); } +#ifdef CONFIG_VSC9953 + /* SerDes configured for QSGMII */ + if (serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_A) = 0) { + for (i = 0; i 4; i++) { + bus = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME); + phy_addr = CONFIG_SYS_FM1_QSGMII11_PHY_ADDR + i; + phy_int = PHY_INTERFACE_MODE_QSGMII; + + vsc9953_port_info_set_mdio(i, bus); + vsc9953_port_info_set_phy_address(i, phy_addr); + vsc9953_port_info_set_phy_int(i, phy_int); + vsc9953_port_enable(i); + } + } + if (serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_B) = 0) { + for (i = 4; i 8; i++) { + bus = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME); + phy_addr = CONFIG_SYS_FM1_QSGMII21_PHY_ADDR + i - 4; + phy_int = PHY_INTERFACE_MODE_QSGMII; + + vsc9953_port_info_set_mdio(i, bus); + vsc9953_port_info_set_phy_address(i, phy_addr); + vsc9953_port_info_set_phy_int(i, phy_int); + vsc9953_port_enable(i); + } + } + + /* Connect DTSEC1 to L2 switch if it doesn't have a PHY */ + if (serdes_get_first_lane(FSL_SRDS_1, SGMII_FM1_DTSEC1) 0) + vsc9953_port_enable(8); + + /* Connect DTSEC2 to L2 switch if it doesn't have a PHY */ + if (serdes_get_first_lane(FSL_SRDS_1, SGMII_FM1_DTSEC2) 0) { + /* Enable L2 On MAC2 using SCFG */ + struct ccsr_scfg *scfg = (struct ccsr_scfg *) + CONFIG_SYS_MPC85xx_SCFG; + + out_be32(scfg-esgmiiselcr, in_be32(scfg-esgmiiselcr) | +(0x8000)); + vsc9953_port_enable(9); + } +#endif + cpu_eth_init(bis); #endif diff --git a/include/configs/T104xRDB.h b/include/configs/T104xRDB.h index 57cdf72..c77b5d5 100644 --- a/include/configs/T104xRDB.h +++ b/include/configs/T104xRDB.h @@ -726,6 +726,12 @@ #define CONFIG_SYS_RGMII1_PHY_ADDR 0x01 #define CONFIG_SYS_RGMII2_PHY_ADDR 0x02 +#ifdef CONFIG_T1040RDB +#define CONFIG_VSC9953_CMD +#define CONFIG_SYS_FM1_QSGMII11_PHY_ADDR 0x04 +#define CONFIG_SYS_FM1_QSGMII21_PHY_ADDR 0x08 +#endif + #define CONFIG_MII /* MII PHY management */ #define CONFIG_ETHPRIMEFM1@DTSEC4 #define CONFIG_PHY_GIGE/* Include GbE speed/duplex detection */ -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 08/11] board/T1040qds: T1040 FMAN ports FM1@DTSEC1 and FM1@DTSEC2 have no PHYs
Freescale's T1040qds board may be configured to have up to 5 FMAN ports (FM1@DTSEC1 to FM1@DTSEC5). From these 5 ports, 2 of them may be fixed-links (FM1@DTSEC1 annd FM1@DTSEC2), connected to other two ports from an intergrated VSC9953 L2 Switch (switch ports 8 and 9). These fixed-link ports have no PHYs attatched, so they don't have a corresponding MDIO. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - added patch description; Changes for v3: - Removed Change-id line from comment; board/freescale/t1040qds/eth.c | 1 + 1 file changed, 1 insertion(+) diff --git a/board/freescale/t1040qds/eth.c b/board/freescale/t1040qds/eth.c index c6fc146..2f8e753 100644 --- a/board/freescale/t1040qds/eth.c +++ b/board/freescale/t1040qds/eth.c @@ -478,6 +478,7 @@ int board_eth_init(bd_t *bis) for (i = FM1_DTSEC1; i FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) { switch (fm_info_get_enet_if(i)) { case PHY_INTERFACE_MODE_QSGMII: + fm_info_set_mdio(i, NULL); break; case PHY_INTERFACE_MODE_SGMII: t1040_handle_phy_interface_sgmii(i); -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 10/11] board/T1040qds: Add VSC9953 support for T1040qds board
This patch configures and initializes the L2 switch on T1040QDS board. The L2 switch ports must be initialized according to the SerDes protocols. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: None Changes for v3: - Removed Change-id line from comment; board/freescale/t1040qds/eth.c | 91 ++ include/configs/T1040QDS.h | 4 ++ 2 files changed, 95 insertions(+) diff --git a/board/freescale/t1040qds/eth.c b/board/freescale/t1040qds/eth.c index 2f8e753..8c82934 100644 --- a/board/freescale/t1040qds/eth.c +++ b/board/freescale/t1040qds/eth.c @@ -18,6 +18,7 @@ #include fsl_mdio.h #include malloc.h #include asm/fsl_dtsec.h +#include vsc9953.h #include ../common/fman.h #include ../common/qixis.h @@ -439,6 +440,12 @@ int board_eth_init(bd_t *bis) #ifdef CONFIG_FMAN_ENET struct memac_mdio_info memac_mdio_info; unsigned int i; +#ifdef CONFIG_VSC9953 + int lane; + int phy_addr; + phy_interface_t phy_int; + struct mii_dev *bus; +#endif printf(Initializing Fman\n); set_brdcfg9_for_gtx_clk(); @@ -493,6 +500,90 @@ int board_eth_init(bd_t *bis) } } +#ifdef CONFIG_VSC9953 + for (i = 0; i VSC9953_MAX_PORTS; i++) { + lane = -1; + phy_addr = 0; + phy_int = PHY_INTERFACE_MODE_NONE; + switch (i) { + case 0: + case 1: + case 2: + case 3: + lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_A); + /* PHYs connected over QSGMII */ + if (lane = 0) { + phy_addr = CONFIG_SYS_FM1_QSGMII21_PHY_ADDR + + i; + phy_int = PHY_INTERFACE_MODE_QSGMII; + break; + } + lane = serdes_get_first_lane(FSL_SRDS_1, + SGMII_SW1_MAC1 + i); + + if (lane 0) + break; + + /* PHYs connected over QSGMII */ + if (i != 3 || lane_to_slot[lane] == 7) + phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR + + i; + else + phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR; + phy_int = PHY_INTERFACE_MODE_SGMII; + break; + case 4: + case 5: + case 6: + case 7: + lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_B); + /* PHYs connected over QSGMII */ + if (lane = 0) { + phy_addr = CONFIG_SYS_FM1_QSGMII11_PHY_ADDR + + i - 4; + phy_int = PHY_INTERFACE_MODE_QSGMII; + break; + } + lane = serdes_get_first_lane(FSL_SRDS_1, + SGMII_SW1_MAC1 + i); + /* PHYs connected over SGMII */ + if (lane = 0) { + phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR + + i - 3; + phy_int = PHY_INTERFACE_MODE_SGMII; + } + break; + case 8: + if (serdes_get_first_lane(FSL_SRDS_1, + SGMII_FM1_DTSEC1) 0) + /* FM1@DTSEC1 is connected to SW1@PORT8 */ + vsc9953_port_enable(i); + break; + case 9: + if (serdes_get_first_lane(FSL_SRDS_1, + SGMII_FM1_DTSEC2) 0) { + /* Enable L2 On MAC2 using SCFG */ + struct ccsr_scfg *scfg = (struct ccsr_scfg *) + CONFIG_SYS_MPC85xx_SCFG; + + out_be32(scfg-esgmiiselcr, +in_be32(scfg-esgmiiselcr) | +(0x8000)); + vsc9953_port_enable(i); + } + break; + } + + if (lane = 0) { + bus = mii_dev_for_muxval(lane_to_slot[lane]); + vsc9953_port_info_set_mdio(i, bus); + vsc9953_port_enable(i); + } + vsc9953_port_info_set_phy_address(i, phy_addr
[U-Boot] [PATCH v3 00/11] Add driver for VSC9953 Ethernet Switch
This patches add support for VSC9953, a Vitesse L2 Switch IP which is integrated in the T1040/T1020 Freescale SoCs. About Device: = The Seville Gigabit Ethernet switch core contains eight 10/100/1000 Mbps Ethernet ports and two 10/100/1000/2500 Mbps ports. It provides a rich set of Ethernet switching features such as advanced TCAM-based VLAN and QoS processing as well as security processing using a TCAM. Switch interfaces: - 8 Gigabit switch ports (ports 0 to 7) are external and are connected to external PHYs - 2 switch ports (ports 8 and 9) of 2.5 G are connected (fixed links) to FMan ports (FM1@DTSEC1 and FM1@DTSEC2) Commands Overview: = Commands supported - enable/disable a port - check a port's link speed, duplexity and status. Commands syntax ethsw port port_nr enable|disable - enable/disable an l2 switch port ethsw port port_nr show - show an l2 switch port's configuration port_nr=0..9; use all for all ports = ethsw port all show Port Status LinkSpeed Duplex 0 enabled down 10 half 1 enabled down 10 half 2 enabled down 10 half 3 enabled up 1000 full 4 disabled down- half 5 disabled down- half 6 disabled down- half 7 disabled down- half 8 enabled up 2500 full 9 enabled up 2500 full = Changes for v2: - split the bug fix from the implementation of SerDes protocols of L2 Switch ports patch; - added debug messages if MDIO reads or writes timeout; - added debug messages when reset of VSC9953 switch fails; - replaced Copyright and license to the generic one; - added patch descriptions; Changes for v3: - replaced the arrays type from 'int' to 'u8' int the fix for mapping of Freescale SerDes protocols; - removed Change-id lines from almost all the patches; Codrin Ciubotariu (11): net/fm: Fix error when FMAN MAC has no PHY arch/powerpc: Fix mapping of Freescale SerDes protocols arch/powerpc: Add SGMII support for the L2 Switch ports net/fm: Enable FMAN ports if l2switch ports are connected over SGMII net/vsc9953: Add driver for Vitesse VSC9953 L2 Switch IP arch/powerpc: Enable VSC9953 driver on T1040 and T1020 board/T1040qds: Fix lane-to-slot mapping for SerDes protocol 0x89 board/T1040qds: T1040 FMAN ports FM1@DTSEC1 and FM1@DTSEC2 have no PHYs board/T104xrdb: T1040 FMAN ports FM1@DTSEC1 and FM1@DTSEC2 have no PHYs board/T1040qds: Add VSC9953 support for T1040qds board board/T1040rdb: Add VSC9953 support for T1040rdb board arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c | 73 ++-- arch/powerpc/cpu/mpc85xx/t1040_serdes.c| 8 +- arch/powerpc/cpu/mpc8xxx/cpu.c | 5 + arch/powerpc/include/asm/config_mpc85xx.h | 3 + arch/powerpc/include/asm/fsl_serdes.h | 7 + board/freescale/t1040qds/eth.c | 93 + board/freescale/t104xrdb/eth.c | 59 ++- doc/README.t1040-l2switch | 49 +++ drivers/net/Makefile | 1 + drivers/net/fm/eth.c | 30 +- drivers/net/fm/t1040.c | 3 +- drivers/net/vsc9953.c | 497 + include/configs/T1040QDS.h | 4 + include/configs/T104xRDB.h | 6 + include/vsc9953.h | 402 15 files changed, 1191 insertions(+), 49 deletions(-) create mode 100644 doc/README.t1040-l2switch create mode 100644 drivers/net/vsc9953.c create mode 100644 include/vsc9953.h -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 01/11] net/fm: Fix error when FMAN MAC has no PHY
U-boot assumes that all FMAN ports have a PHY. Some SoCs (like T1040) have fixed links. This means that the ports are connected MAC to MAc and there is no Ethernet PHY attatched. This patch initializes a FMAN MAC even if it doesn't have a PHY attached. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: None Changes for v3: None drivers/net/fm/eth.c | 30 ++ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c index f1e39b9..1d1089d 100644 --- a/drivers/net/fm/eth.c +++ b/drivers/net/fm/eth.c @@ -410,10 +410,15 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd) fmc_tx_port_graceful_stop_disable(fm_eth); #ifdef CONFIG_PHYLIB - ret = phy_startup(fm_eth-phydev); - if (ret) { - printf(%s: Could not initialize\n, fm_eth-phydev-dev-name); - return ret; + if (fm_eth-phydev) { + ret = phy_startup(fm_eth-phydev); + if (ret) { + printf(%s: Could not initialize\n, + fm_eth-phydev-dev-name); + return ret; + } + } else { + return 0; } #else fm_eth-phydev-speed = SPEED_1000; @@ -447,7 +452,8 @@ static void fm_eth_halt(struct eth_device *dev) /* disable bmi Rx port */ bmi_rx_port_disable(fm_eth-rx_port); - phy_shutdown(fm_eth-phydev); + if (fm_eth-phydev) + phy_shutdown(fm_eth-phydev); } static int fm_eth_send(struct eth_device *dev, void *buf, int len) @@ -625,11 +631,12 @@ static int init_phy(struct eth_device *dev) if (fm_eth-bus) { phydev = phy_connect(fm_eth-bus, fm_eth-phyaddr, dev, fm_eth-enet_if); - } - - if (!phydev) { - printf(Failed to connect\n); - return -1; + if (!phydev) { + printf(Failed to connect\n); + return -1; + } + } else { + return 0; } if (fm_eth-type == FM_ETH_1G_E) { @@ -711,8 +718,7 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info) if (!fm_eth_startup(fm_eth)) return 0; - if (init_phy(dev)) - return 0; + init_phy(dev); /* clear the ethernet address */ for (i = 0; i 6; i++) -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 02/11] arch/powerpc: Fix mapping of Freescale SerDes protocols
The number of supported serdes protocols on Freescale SoCs has increased over time. Until now, an u64 variable have been initialized on boot with the configured protocols. However, since this number has increased (enum srds_prtcl has more than 64 values), 64 bits are no longer sufficient to hold track of all the configured protocols. This patch replaces the u64 map values with static arrays. To keep track of the number of serdes protocols, the SERDES_PRCTL_COUNT vale has been added at the end of enum srds_prtcl. This value must always be the last one. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: There is no v1 version of this patch; Changes for v3: - replaced 'int' type of seredesX_prtcl_map[] with 'u8'; - removed Change-id line from comment; arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c | 67 ++ arch/powerpc/include/asm/fsl_serdes.h | 1 + 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c b/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c index 5cfae47..c7d9622 100644 --- a/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c +++ b/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c @@ -15,16 +15,16 @@ #include fsl_corenet2_serdes.h #ifdef CONFIG_SYS_FSL_SRDS_1 -static u64 serdes1_prtcl_map; +static u8 serdes1_prtcl_map[SERDES_PRCTL_COUNT]; #endif #ifdef CONFIG_SYS_FSL_SRDS_2 -static u64 serdes2_prtcl_map; +static u8 serdes2_prtcl_map[SERDES_PRCTL_COUNT]; #endif #ifdef CONFIG_SYS_FSL_SRDS_3 -static u64 serdes3_prtcl_map; +static u8 serdes3_prtcl_map[SERDES_PRCTL_COUNT]; #endif #ifdef CONFIG_SYS_FSL_SRDS_4 -static u64 serdes4_prtcl_map; +static u8 serdes4_prtcl_map[SERDES_PRCTL_COUNT]; #endif #ifdef DEBUG @@ -83,19 +83,19 @@ static const char *serdes_prtcl_str[] = { int is_serdes_configured(enum srds_prtcl device) { - u64 ret = 0; + int ret = 0; #ifdef CONFIG_SYS_FSL_SRDS_1 - ret |= (1ULL device) serdes1_prtcl_map; + ret |= serdes1_prtcl_map[device]; #endif #ifdef CONFIG_SYS_FSL_SRDS_2 - ret |= (1ULL device) serdes2_prtcl_map; + ret |= serdes2_prtcl_map[device]; #endif #ifdef CONFIG_SYS_FSL_SRDS_3 - ret |= (1ULL device) serdes3_prtcl_map; + ret |= serdes3_prtcl_map[device]; #endif #ifdef CONFIG_SYS_FSL_SRDS_4 - ret |= (1ULL device) serdes4_prtcl_map; + ret |= serdes4_prtcl_map[device]; #endif return !!ret; @@ -171,12 +171,14 @@ int serdes_get_first_lane(u32 sd, enum srds_prtcl device) #define BCAP_OVD_MASK 0x1000 #define BYP_CAL_MASK 0x0200 -u64 serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift) +void serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift, + u8 serdes_prtcl_map[SERDES_PRCTL_COUNT]) { ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); - u64 serdes_prtcl_map = 0; u32 cfg; int lane; + + memset(serdes_prtcl_map, 0, sizeof(serdes_prtcl_map)); #ifdef CONFIG_SYS_FSL_ERRATUM_A007186 struct ccsr_sfp_regs __iomem *sfp_regs = (struct ccsr_sfp_regs __iomem *)(CONFIG_SYS_SFP_ADDR); @@ -312,38 +314,43 @@ u64 serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift) for (lane = 0; lane SRDS_MAX_LANES; lane++) { enum srds_prtcl lane_prtcl = serdes_get_prtcl(sd, cfg, lane); - serdes_prtcl_map |= (1ULL lane_prtcl); + if (unlikely(lane_prtcl = SERDES_PRCTL_COUNT)) + debug(Unknown SerDes lane protocol %d\n, lane_prtcl); + else + serdes_prtcl_map[lane_prtcl] = 1; } - - return serdes_prtcl_map; } void fsl_serdes_init(void) { #ifdef CONFIG_SYS_FSL_SRDS_1 - serdes1_prtcl_map = serdes_init(FSL_SRDS_1, - CONFIG_SYS_FSL_CORENET_SERDES_ADDR, - FSL_CORENET2_RCWSR4_SRDS1_PRTCL, - FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT); + serdes_init(FSL_SRDS_1, + CONFIG_SYS_FSL_CORENET_SERDES_ADDR, + FSL_CORENET2_RCWSR4_SRDS1_PRTCL, + FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT, + serdes1_prtcl_map); #endif #ifdef CONFIG_SYS_FSL_SRDS_2 - serdes2_prtcl_map = serdes_init(FSL_SRDS_2, - CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_2 * 0x1000, - FSL_CORENET2_RCWSR4_SRDS2_PRTCL, - FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT); + serdes_init(FSL_SRDS_2, + CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_2 * 0x1000, + FSL_CORENET2_RCWSR4_SRDS2_PRTCL, + FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT, + serdes2_prtcl_map); #endif #ifdef CONFIG_SYS_FSL_SRDS_3 - serdes3_prtcl_map = serdes_init(FSL_SRDS_3
[U-Boot] [PATCH v3 03/11] arch/powerpc: Add SGMII support for the L2 Switch ports
Some Freescale SoCs like T1020 and T1040 have an integrated L2 Switch. The L2 Switch ports may be connected to Ethernet PHYs over SGMII and QSGMII. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - split a bug fix regarding Freescale SerDes protocols into a different patch; Changes for v3: Removed Change-id line from comment; arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c | 6 ++ arch/powerpc/cpu/mpc85xx/t1040_serdes.c| 8 arch/powerpc/include/asm/fsl_serdes.h | 6 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c b/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c index c7d9622..acb1353 100644 --- a/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c +++ b/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c @@ -78,6 +78,12 @@ static const char *serdes_prtcl_str[] = { [INTERLAKEN] = INTERLAKEN, [QSGMII_SW1_A] = QSGMII_SW1_A, [QSGMII_SW1_B] = QSGMII_SW1_B, + [SGMII_SW1_MAC1] = SGMII_SW1_MAC1, + [SGMII_SW1_MAC2] = SGMII_SW1_MAC2, + [SGMII_SW1_MAC3] = SGMII_SW1_MAC3, + [SGMII_SW1_MAC4] = SGMII_SW1_MAC4, + [SGMII_SW1_MAC5] = SGMII_SW1_MAC5, + [SGMII_SW1_MAC6] = SGMII_SW1_MAC6, }; #endif diff --git a/arch/powerpc/cpu/mpc85xx/t1040_serdes.c b/arch/powerpc/cpu/mpc85xx/t1040_serdes.c index d86bb27..d5dccd5 100644 --- a/arch/powerpc/cpu/mpc85xx/t1040_serdes.c +++ b/arch/powerpc/cpu/mpc85xx/t1040_serdes.c @@ -33,10 +33,10 @@ static u8 serdes_cfg_tbl[][SRDS_MAX_LANES] = { PCIE2, PCIE2, SGMII_FM1_DTSEC4, SGMII_FM1_DTSEC5}, [0x87] = {PCIE1, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2, PCIE3, PCIE4, SGMII_FM1_DTSEC5}, - [0x89] = {PCIE1, QSGMII_SW1_A, QSGMII_SW1_A, QSGMII_SW1_A, - PCIE2, PCIE3, QSGMII_SW1_B, SATA1}, - [0x8D] = {PCIE1, QSGMII_SW1_A, QSGMII_SW1_A, QSGMII_SW1_A, - PCIE2, QSGMII_SW1_B, QSGMII_SW1_B, QSGMII_SW1_B}, + [0x89] = {PCIE1, SGMII_SW1_MAC3, SGMII_SW1_MAC1, SGMII_SW1_MAC2, + PCIE2, PCIE3, SGMII_SW1_MAC4, SATA1}, + [0x8D] = {PCIE1, SGMII_SW1_MAC3, SGMII_SW1_MAC1, SGMII_SW1_MAC2, + PCIE2, SGMII_SW1_MAC6, SGMII_SW1_MAC4, SGMII_SW1_MAC5}, [0x8F] = {PCIE1, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, AURORA, NONE, SGMII_FM1_DTSEC4, SGMII_FM1_DTSEC5}, [0xA5] = {PCIE1, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, diff --git a/arch/powerpc/include/asm/fsl_serdes.h b/arch/powerpc/include/asm/fsl_serdes.h index 2dd32c2..45e248e 100644 --- a/arch/powerpc/include/asm/fsl_serdes.h +++ b/arch/powerpc/include/asm/fsl_serdes.h @@ -87,6 +87,12 @@ enum srds_prtcl { SGMII_2500_FM2_DTSEC6, SGMII_2500_FM2_DTSEC9, SGMII_2500_FM2_DTSEC10, + SGMII_SW1_MAC1, + SGMII_SW1_MAC2, + SGMII_SW1_MAC3, + SGMII_SW1_MAC4, + SGMII_SW1_MAC5, + SGMII_SW1_MAC6, SERDES_PRCTL_COUNT /* Keep this item the last one */ }; -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 07/11] board/T1040qds: Fix lane-to-slot mapping for SerDes protocol 0x89
Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: None Changes for v3: - Removed Change-id line from comment; board/freescale/t1040qds/eth.c | 1 + 1 file changed, 1 insertion(+) diff --git a/board/freescale/t1040qds/eth.c b/board/freescale/t1040qds/eth.c index 06d9086..c6fc146 100644 --- a/board/freescale/t1040qds/eth.c +++ b/board/freescale/t1040qds/eth.c @@ -216,6 +216,7 @@ static void initialize_lane_to_slot(void) lane_to_slot[1] = 7; lane_to_slot[2] = 7; lane_to_slot[3] = 7; + lane_to_slot[6] = 7; lane_to_slot[7] = 7; break; case 0x8d: -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 06/11] arch/powerpc: Enable VSC9953 driver on T1040 and T1020
T1040 and T1020 are two Freescale SoCs with an integrated VSC9953 Gigabit L2 Switch. This patch initializes this L2 switch on boards with T1040 and T1020. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - added patch description; Changes for v3: - Removed Change-id line from comment; arch/powerpc/cpu/mpc8xxx/cpu.c| 5 + arch/powerpc/include/asm/config_mpc85xx.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/arch/powerpc/cpu/mpc8xxx/cpu.c b/arch/powerpc/cpu/mpc8xxx/cpu.c index 2d28eb2..c92589f 100644 --- a/arch/powerpc/cpu/mpc8xxx/cpu.c +++ b/arch/powerpc/cpu/mpc8xxx/cpu.c @@ -15,6 +15,7 @@ #include netdev.h #include asm/cache.h #include asm/io.h +#include vsc9953.h DECLARE_GLOBAL_DATA_PTR; @@ -271,5 +272,9 @@ int cpu_eth_init(bd_t *bis) #ifdef CONFIG_FMAN_ENET fm_standard_init(bis); #endif + +#ifdef CONFIG_VSC9953 + vsc9953_init(bis); +#endif return 0; } diff --git a/arch/powerpc/include/asm/config_mpc85xx.h b/arch/powerpc/include/asm/config_mpc85xx.h index 01b0905..79caac1 100644 --- a/arch/powerpc/include/asm/config_mpc85xx.h +++ b/arch/powerpc/include/asm/config_mpc85xx.h @@ -747,6 +747,9 @@ defined(CONFIG_PPC_T1020) || defined(CONFIG_PPC_T1022) #define CONFIG_SYS_FSL_QORIQ_CHASSIS2 /* Freescale Chassis generation 2 */ #define CONFIG_SYS_FSL_CORES_PER_CLUSTER 1 #define CONFIG_SYS_FSL_QMAN_V3 /* QMAN version 3 */ +#if defined(CONFIG_PPC_T1040) || defined(CONFIG_PPC_T1020) +#define CONFIG_VSC9953 /* Vitesse L2 Switch */ +#endif #ifdef CONFIG_SYS_FSL_DDR4 #define CONFIG_SYS_FSL_DDRC_GEN4 #endif -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 04/11] net/fm: Enable FMAN ports if l2switch ports are connected over SGMII
If SerDes is configured to connect L2 Switch ports from T1040 over SGMII or QSGMII, the two FMAN fixed ports (FM1@DTSEC1 and FM2@DTSEC2) that are connected to two L2 swtch ports must be enabled. These ports don't have PHYs and must be treated accordingly. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: None Changes for v3: Removed Change-id line from comment; drivers/net/fm/t1040.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/fm/t1040.c b/drivers/net/fm/t1040.c index d2a097e..0458366 100644 --- a/drivers/net/fm/t1040.c +++ b/drivers/net/fm/t1040.c @@ -50,7 +50,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port) switch (port) { case FM1_DTSEC1: case FM1_DTSEC2: - if (is_serdes_configured(QSGMII_SW1_A + port - FM1_DTSEC1)) + if (is_serdes_configured(QSGMII_SW1_A + port - FM1_DTSEC1) || + is_serdes_configured(SGMII_SW1_MAC1 + port - FM1_DTSEC1)) return PHY_INTERFACE_MODE_QSGMII; case FM1_DTSEC3: case FM1_DTSEC4: -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 09/11] board/T104xrdb: T1040 FMAN ports FM1@DTSEC1 and FM1@DTSEC2 have no PHYs
Freescale's T1040qds board may be configured to have up to 5 FMAN ports (FM1@DTSEC1 to FM1@DTSEC5). From these 5 ports, 2 of them may be fixed-links (FM1@DTSEC1 annd FM1@DTSEC2), connected to other two ports from an intergrated VSC9953 L2 Switch (switch ports 8 and 9). These fixed-link ports have no PHYs attatched, so they don't have a corresponding MDIO. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- Changes for v2: - Added patch description; Changes for v3: - Removed Change-id line from comment; board/freescale/t104xrdb/eth.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/board/freescale/t104xrdb/eth.c b/board/freescale/t104xrdb/eth.c index c8b6c67..f5c0ec8 100644 --- a/board/freescale/t104xrdb/eth.c +++ b/board/freescale/t104xrdb/eth.c @@ -72,8 +72,13 @@ int board_eth_init(bd_t *bis) fm_info_set_phy_address(i, 0); break; } - fm_info_set_mdio(i, -miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME)); + if (fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_QSGMII || + fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_NONE) + fm_info_set_mdio(i, NULL); + else + fm_info_set_mdio(i, +miiphy_get_dev_by_name( + DEFAULT_FM_MDIO_NAME)); } cpu_eth_init(bis); -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 00/11] Add driver for VSC9953 Ethernet Switch
This patches add support for VSC9953, a Vitesse L2 Switch IP which is integrated in the T1040/T1020 Freescale SoCs. About Device: = The Seville Gigabit Ethernet switch core contains eight 10/100/1000 Mbps Ethernet ports and two 10/100/1000/2500 Mbps ports. It provides a rich set of Ethernet switching features such as advanced TCAM-based VLAN and QoS processing as well as security processing using a TCAM. Switch interfaces: - 8 Gigabit switch ports (ports 0 to 7) are external and are connected to external PHYs - 2 switch ports (ports 8 and 9) of 2.5 G are connected (fixed links) to FMan ports (FM1@DTSEC1 and FM1@DTSEC2) Commands Overview: = Commands supported - enable/disable a port - check a port's link speed, duplexity and status. Commands syntax ethsw port port_nr enable|disable - enable/disable an l2 switch port ethsw port port_nr show - show an l2 switch port's configuration port_nr=0..9; use all for all ports = ethsw port all show Port Status LinkSpeed Duplex 0 enabled down 10 half 1 enabled down 10 half 2 enabled down 10 half 3 enabled up 1000 full 4 disabled down- half 5 disabled down- half 6 disabled down- half 7 disabled down- half 8 enabled up 2500 full 9 enabled up 2500 full = Changes since v1: - split the bug fix from the implementation of SerDes protocols of L2 Switch ports patch; - added debug messages if MDIO reads or writes timeout; - added debug messages when reset of VSC9953 switch fails; - replaced Copyright and license to the generic one; - added patch descriptions; Codrin Ciubotariu (11): net/fm: Fix error when FMAN MAC has no PHY arch/powerpc: Fix mapping of Freescale SerDes protocols arch/powerpc: Add SGMII support for the L2 Switch ports net/fm: Enable FMAN ports if l2switch ports are connected over SGMII net/vsc9953: Add driver for Vitesse VSC9953 L2 Switch IP arch/powerpc: Enable VSC9953 driver on T1040 and T1020 board/T1040qds: Fix lane-to-slot mapping for SerDes protocol 0x89 board/T1040qds: T1040 FMAN ports FM1@DTSEC1 and FM1@DTSEC2 have no PHYs board/T104xrdb: T1040 FMAN ports FM1@DTSEC1 and FM1@DTSEC2 have no PHYs board/T1040qds: Add VSC9953 support for T1040qds board board/T1040rdb: Add VSC9953 support for T1040rdb board arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c | 70 ++-- arch/powerpc/cpu/mpc85xx/t1040_serdes.c| 8 +- arch/powerpc/cpu/mpc8xxx/cpu.c | 7 + arch/powerpc/include/asm/config_mpc85xx.h | 3 + arch/powerpc/include/asm/fsl_serdes.h | 7 + board/freescale/t1040qds/eth.c | 95 + board/freescale/t104xrdb/eth.c | 61 ++- doc/README.t1040-l2switch | 49 +++ drivers/net/Makefile | 1 + drivers/net/fm/eth.c | 30 +- drivers/net/fm/t1040.c | 3 +- drivers/net/vsc9953.c | 497 + include/configs/T1040QDS.h | 4 + include/configs/T104xRDB.h | 6 + include/vsc9953.h | 402 15 files changed, 1194 insertions(+), 49 deletions(-) create mode 100644 doc/README.t1040-l2switch create mode 100644 drivers/net/vsc9953.c create mode 100644 include/vsc9953.h -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 01/11] net/fm: Fix error when FMAN MAC has no PHY
U-boot assumes that all FMAN ports have a PHY. Some SoCs (like T1040) have fixed links. This means that the ports are connected MAC to MAc and there is no Ethernet PHY attatched. This patch initializes a FMAN MAC even if it doesn't have a PHY attached. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- drivers/net/fm/eth.c | 30 ++ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c index f1e39b9..1d1089d 100644 --- a/drivers/net/fm/eth.c +++ b/drivers/net/fm/eth.c @@ -410,10 +410,15 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd) fmc_tx_port_graceful_stop_disable(fm_eth); #ifdef CONFIG_PHYLIB - ret = phy_startup(fm_eth-phydev); - if (ret) { - printf(%s: Could not initialize\n, fm_eth-phydev-dev-name); - return ret; + if (fm_eth-phydev) { + ret = phy_startup(fm_eth-phydev); + if (ret) { + printf(%s: Could not initialize\n, + fm_eth-phydev-dev-name); + return ret; + } + } else { + return 0; } #else fm_eth-phydev-speed = SPEED_1000; @@ -447,7 +452,8 @@ static void fm_eth_halt(struct eth_device *dev) /* disable bmi Rx port */ bmi_rx_port_disable(fm_eth-rx_port); - phy_shutdown(fm_eth-phydev); + if (fm_eth-phydev) + phy_shutdown(fm_eth-phydev); } static int fm_eth_send(struct eth_device *dev, void *buf, int len) @@ -625,11 +631,12 @@ static int init_phy(struct eth_device *dev) if (fm_eth-bus) { phydev = phy_connect(fm_eth-bus, fm_eth-phyaddr, dev, fm_eth-enet_if); - } - - if (!phydev) { - printf(Failed to connect\n); - return -1; + if (!phydev) { + printf(Failed to connect\n); + return -1; + } + } else { + return 0; } if (fm_eth-type == FM_ETH_1G_E) { @@ -711,8 +718,7 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info) if (!fm_eth_startup(fm_eth)) return 0; - if (init_phy(dev)) - return 0; + init_phy(dev); /* clear the ethernet address */ for (i = 0; i 6; i++) -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 04/11] net/fm: Enable FMAN ports if l2switch ports are connected over SGMII
If SerDes is configured to connect L2 Switch ports from T1040 over SGMII or QSGMII, the two FMAN fixed ports (FM1@DTSEC1 and FM2@DTSEC2) that are connected to two L2 swtch ports must be enabled. These ports don't have PHYs and must be treated accordingly. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I47f59d6a0c746bd56601518379af2178a036467b --- drivers/net/fm/t1040.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/fm/t1040.c b/drivers/net/fm/t1040.c index d2a097e..0458366 100644 --- a/drivers/net/fm/t1040.c +++ b/drivers/net/fm/t1040.c @@ -50,7 +50,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port) switch (port) { case FM1_DTSEC1: case FM1_DTSEC2: - if (is_serdes_configured(QSGMII_SW1_A + port - FM1_DTSEC1)) + if (is_serdes_configured(QSGMII_SW1_A + port - FM1_DTSEC1) || + is_serdes_configured(SGMII_SW1_MAC1 + port - FM1_DTSEC1)) return PHY_INTERFACE_MODE_QSGMII; case FM1_DTSEC3: case FM1_DTSEC4: -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 05/11] net/vsc9953: Add driver for Vitesse VSC9953 L2 Switch IP
This patch adds a driver for VSC9953 L2 Switch. This Vitesse IP is integrated in Freescale T1040 and T1020 SoCs. The L2 switch has 10 Ethernet ports: 2 internal fixed-links (ports 8 and 9) at 2.5 Gbps and and 8 external ports at 1 Gbps. The external ports may be connected to PHYs over QSGMII and SGMII. Commands have also been added to enable/disable a port and to check a port's link speed, duplexity and status. The commands are: ethsw port port_nr enable|disable - enable/disable an l2 switch port ethsw port port_nr show - show an l2 switch port's configuration port_nr=0..9; use all for all ports For more detailse please see doc/README.t1040-l2switch Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I460852dc67c1dd3b387e57a50d73dc0ec5f77f8b --- doc/README.t1040-l2switch | 49 + drivers/net/Makefile | 1 + drivers/net/vsc9953.c | 497 ++ include/vsc9953.h | 402 + 4 files changed, 949 insertions(+) create mode 100644 doc/README.t1040-l2switch create mode 100644 drivers/net/vsc9953.c create mode 100644 include/vsc9953.h diff --git a/doc/README.t1040-l2switch b/doc/README.t1040-l2switch new file mode 100644 index 000..6324f18 --- /dev/null +++ b/doc/README.t1040-l2switch @@ -0,0 +1,49 @@ +This file contains information for VSC9953, a Vitesse L2 Switch IP +which is integrated in the T1040/T1020 Freescale SoCs. + +About Device: += +VSC9953 is an 8-port Gigabit Ethernet switch supports the following features: + - 8192 MAC addresses + - Static Address provisioning + - Dynamic learning of MAC addresses and aging + - 4096 VLANs + - Independent and shared VLAN learning (IVL, SVL) + - Policing with storm control and MC/BC protection + - IPv4 and IPv6 multicast + - Jumbo frames (9.6 KB) + - Access Control List + - VLAN editing, translation and remarking + - RMON counters per port + +Switch interfaces: + - 8 Gigabit switch ports (ports 0 to 7) are external and are connected to external PHYs + - 2 switch ports (ports 8 and 9) of 2.5 G are connected (fixed links) + to FMan ports (FM1@DTSEC1 and FM1@DTSEC2) + +Commands Overview: += +Commands supported + - enable/disable a port + - check a port's link speed, duplexity and status. + +Commands syntax + ethsw port port_nr enable|disable - enable/disable an l2 switch port + ethsw port port_nr show - show an l2 switch port's configuration + + port_nr=0..9; use all for all ports + += ethsw port all show +Port Status LinkSpeed Duplex + 0 enabled down 10 half + 1 enabled down 10 half + 2 enabled down 10 half + 3 enabled up 1000 full + 4 disabled down- half + 5 disabled down- half + 6 disabled down- half + 7 disabled down- half + 8 enabled up 2500 full + 9 enabled up 2500 full += + diff --git a/drivers/net/Makefile b/drivers/net/Makefile index fb0cf8c..46c4ac6 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -66,3 +66,4 @@ obj-$(CONFIG_XILINX_LL_TEMAC) += xilinx_ll_temac.o xilinx_ll_temac_mdio.o \ xilinx_ll_temac_fifo.o xilinx_ll_temac_sdma.o obj-$(CONFIG_ZYNQ_GEM) += zynq_gem.o obj-$(CONFIG_FSL_MC_ENET) += fsl_mc/ +obj-$(CONFIG_VSC9953) += vsc9953.o diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c new file mode 100644 index 000..9fc3c18 --- /dev/null +++ b/drivers/net/vsc9953.c @@ -0,0 +1,497 @@ +/* + * Copyright 2014 Freescale Semiconductor, Inc. + * + * SPDX-License-Identifier: GPL-2.0+ + * + * Driver for the Vitesse VSC9953 L2 Switch + */ + +#include asm/io.h +#include asm/fsl_serdes.h +#include fm_eth.h +#include asm/fsl_memac.h +#include vsc9953.h + +static struct vsc9953_info vsc9953_l2sw = { + .port[0] = VSC9953_PORT_INFO_INITIALIZER(0), + .port[1] = VSC9953_PORT_INFO_INITIALIZER(1), + .port[2] = VSC9953_PORT_INFO_INITIALIZER(2), + .port[3] = VSC9953_PORT_INFO_INITIALIZER(3), + .port[4] = VSC9953_PORT_INFO_INITIALIZER(4), + .port[5] = VSC9953_PORT_INFO_INITIALIZER(5), + .port[6] = VSC9953_PORT_INFO_INITIALIZER(6), + .port[7] = VSC9953_PORT_INFO_INITIALIZER(7), + .port[8] = VSC9953_PORT_INFO_INITIALIZER(8), + .port[9] = VSC9953_PORT_INFO_INITIALIZER(9), +}; + +void vsc9953_port_info_set_mdio(int port, struct mii_dev *bus) +{ + if (!VSC9953_PORT_CHECK(port)) + return; + + vsc9953_l2sw.port[port].bus = bus; +} + +void
[U-Boot] [PATCH v2 02/11] arch/powerpc: Fix mapping of Freescale SerDes protocols
The number of supported serdes protocols on Freescale SoCs has increased over time. Until now, an u64 variable have been initialized on boot with the configured protocols. However, since this number has increased (enum srds_prtcl has more than 64 values), 64 bits are no longer sufficient to hold track of all the configured protocols. This patch replaces the u64 map values with static arrays. To keep track of the number of serdes protocols, the SERDES_PRCTL_COUNT vale has been added at the end of enum srds_prtcl. This value must always be the last one. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c | 64 ++ arch/powerpc/include/asm/fsl_serdes.h | 1 + 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c b/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c index 5cfae47..f8e6c00 100644 --- a/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c +++ b/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c @@ -15,16 +15,16 @@ #include fsl_corenet2_serdes.h #ifdef CONFIG_SYS_FSL_SRDS_1 -static u64 serdes1_prtcl_map; +static int serdes1_prtcl_map[SERDES_PRCTL_COUNT]; #endif #ifdef CONFIG_SYS_FSL_SRDS_2 -static u64 serdes2_prtcl_map; +static int serdes2_prtcl_map[SERDES_PRCTL_COUNT]; #endif #ifdef CONFIG_SYS_FSL_SRDS_3 -static u64 serdes3_prtcl_map; +static int serdes3_prtcl_map[SERDES_PRCTL_COUNT]; #endif #ifdef CONFIG_SYS_FSL_SRDS_4 -static u64 serdes4_prtcl_map; +static int serdes4_prtcl_map[SERDES_PRCTL_COUNT]; #endif #ifdef DEBUG @@ -83,19 +83,19 @@ static const char *serdes_prtcl_str[] = { int is_serdes_configured(enum srds_prtcl device) { - u64 ret = 0; + int ret = 0; #ifdef CONFIG_SYS_FSL_SRDS_1 - ret |= (1ULL device) serdes1_prtcl_map; + ret |= serdes1_prtcl_map[device]; #endif #ifdef CONFIG_SYS_FSL_SRDS_2 - ret |= (1ULL device) serdes2_prtcl_map; + ret |= serdes2_prtcl_map[device]; #endif #ifdef CONFIG_SYS_FSL_SRDS_3 - ret |= (1ULL device) serdes3_prtcl_map; + ret |= serdes3_prtcl_map[device]; #endif #ifdef CONFIG_SYS_FSL_SRDS_4 - ret |= (1ULL device) serdes4_prtcl_map; + ret |= serdes4_prtcl_map[device]; #endif return !!ret; @@ -171,12 +171,14 @@ int serdes_get_first_lane(u32 sd, enum srds_prtcl device) #define BCAP_OVD_MASK 0x1000 #define BYP_CAL_MASK 0x0200 -u64 serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift) +void serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift, + int serdes_prtcl_map[SERDES_PRCTL_COUNT]) { ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); - u64 serdes_prtcl_map = 0; u32 cfg; int lane; + + memset(serdes_prtcl_map, 0, sizeof(serdes_prtcl_map)); #ifdef CONFIG_SYS_FSL_ERRATUM_A007186 struct ccsr_sfp_regs __iomem *sfp_regs = (struct ccsr_sfp_regs __iomem *)(CONFIG_SYS_SFP_ADDR); @@ -312,38 +314,40 @@ u64 serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift) for (lane = 0; lane SRDS_MAX_LANES; lane++) { enum srds_prtcl lane_prtcl = serdes_get_prtcl(sd, cfg, lane); - serdes_prtcl_map |= (1ULL lane_prtcl); + serdes_prtcl_map[lane_prtcl] = 1; } - - return serdes_prtcl_map; } void fsl_serdes_init(void) { #ifdef CONFIG_SYS_FSL_SRDS_1 - serdes1_prtcl_map = serdes_init(FSL_SRDS_1, - CONFIG_SYS_FSL_CORENET_SERDES_ADDR, - FSL_CORENET2_RCWSR4_SRDS1_PRTCL, - FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT); + serdes_init(FSL_SRDS_1, + CONFIG_SYS_FSL_CORENET_SERDES_ADDR, + FSL_CORENET2_RCWSR4_SRDS1_PRTCL, + FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT, + serdes1_prtcl_map); #endif #ifdef CONFIG_SYS_FSL_SRDS_2 - serdes2_prtcl_map = serdes_init(FSL_SRDS_2, - CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_2 * 0x1000, - FSL_CORENET2_RCWSR4_SRDS2_PRTCL, - FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT); + serdes_init(FSL_SRDS_2, + CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_2 * 0x1000, + FSL_CORENET2_RCWSR4_SRDS2_PRTCL, + FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT, + serdes2_prtcl_map); #endif #ifdef CONFIG_SYS_FSL_SRDS_3 - serdes3_prtcl_map = serdes_init(FSL_SRDS_3, - CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_3 * 0x1000, - FSL_CORENET2_RCWSR4_SRDS3_PRTCL, - FSL_CORENET2_RCWSR4_SRDS3_PRTCL_SHIFT); + serdes_init(FSL_SRDS_3, + CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_3 * 0x1000, + FSL_CORENET2_RCWSR4_SRDS3_PRTCL
[U-Boot] [PATCH v2 08/11] board/T1040qds: T1040 FMAN ports FM1@DTSEC1 and FM1@DTSEC2 have no PHYs
Freescale's T1040qds board may be configured to have up to 5 FMAN ports (FM1@DTSEC1 to FM1@DTSEC5). From these 5 ports, 2 of them may be fixed-links (FM1@DTSEC1 annd FM1@DTSEC2), connected to other two ports from an intergrated VSC9953 L2 Switch (switch ports 8 and 9). These fixed-link ports have no PHYs attatched, so they don't have a corresponding MDIO. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I35d9b33667538eab40463035b5cbb290f7a1ee07 --- board/freescale/t1040qds/eth.c | 1 + 1 file changed, 1 insertion(+) diff --git a/board/freescale/t1040qds/eth.c b/board/freescale/t1040qds/eth.c index c6fc146..2f8e753 100644 --- a/board/freescale/t1040qds/eth.c +++ b/board/freescale/t1040qds/eth.c @@ -478,6 +478,7 @@ int board_eth_init(bd_t *bis) for (i = FM1_DTSEC1; i FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) { switch (fm_info_get_enet_if(i)) { case PHY_INTERFACE_MODE_QSGMII: + fm_info_set_mdio(i, NULL); break; case PHY_INTERFACE_MODE_SGMII: t1040_handle_phy_interface_sgmii(i); -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 06/11] arch/powerpc: Enable VSC9953 driver on T1040 and T1020
Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: If65224646f737270dad1ef3558a400a002e9d4b6 --- arch/powerpc/cpu/mpc8xxx/cpu.c| 7 +++ arch/powerpc/include/asm/config_mpc85xx.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/arch/powerpc/cpu/mpc8xxx/cpu.c b/arch/powerpc/cpu/mpc8xxx/cpu.c index 2d28eb2..41026d1 100644 --- a/arch/powerpc/cpu/mpc8xxx/cpu.c +++ b/arch/powerpc/cpu/mpc8xxx/cpu.c @@ -15,6 +15,9 @@ #include netdev.h #include asm/cache.h #include asm/io.h +#ifdef CONFIG_VSC9953 +#include vsc9953.h +#endif DECLARE_GLOBAL_DATA_PTR; @@ -271,5 +274,9 @@ int cpu_eth_init(bd_t *bis) #ifdef CONFIG_FMAN_ENET fm_standard_init(bis); #endif + +#ifdef CONFIG_VSC9953 + vsc9953_init(bis); +#endif return 0; } diff --git a/arch/powerpc/include/asm/config_mpc85xx.h b/arch/powerpc/include/asm/config_mpc85xx.h index 01b0905..79caac1 100644 --- a/arch/powerpc/include/asm/config_mpc85xx.h +++ b/arch/powerpc/include/asm/config_mpc85xx.h @@ -747,6 +747,9 @@ defined(CONFIG_PPC_T1020) || defined(CONFIG_PPC_T1022) #define CONFIG_SYS_FSL_QORIQ_CHASSIS2 /* Freescale Chassis generation 2 */ #define CONFIG_SYS_FSL_CORES_PER_CLUSTER 1 #define CONFIG_SYS_FSL_QMAN_V3 /* QMAN version 3 */ +#if defined(CONFIG_PPC_T1040) || defined(CONFIG_PPC_T1020) +#define CONFIG_VSC9953 /* Vitesse L2 Switch */ +#endif #ifdef CONFIG_SYS_FSL_DDR4 #define CONFIG_SYS_FSL_DDRC_GEN4 #endif -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 07/11] board/T1040qds: Fix lane-to-slot mapping for SerDes protocol 0x89
Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I911b61580681f4b042b1f280a6a60ebf91d9ab13 --- board/freescale/t1040qds/eth.c | 1 + 1 file changed, 1 insertion(+) diff --git a/board/freescale/t1040qds/eth.c b/board/freescale/t1040qds/eth.c index 06d9086..c6fc146 100644 --- a/board/freescale/t1040qds/eth.c +++ b/board/freescale/t1040qds/eth.c @@ -216,6 +216,7 @@ static void initialize_lane_to_slot(void) lane_to_slot[1] = 7; lane_to_slot[2] = 7; lane_to_slot[3] = 7; + lane_to_slot[6] = 7; lane_to_slot[7] = 7; break; case 0x8d: -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 11/11] board/T1040rdb: Add VSC9953 support for T1040rdb board
This patch configures and initializes the L2 switch on T1040rdb board. The external L2 switch ports may be connected to PHYs only over QSGMII, for T1040rdb. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I56ae23192daa882c66d04b64b9a7d32531a13db0 --- board/freescale/t104xrdb/eth.c | 52 ++ include/configs/T104xRDB.h | 6 + 2 files changed, 58 insertions(+) diff --git a/board/freescale/t104xrdb/eth.c b/board/freescale/t104xrdb/eth.c index f5c0ec8..77c1e89 100644 --- a/board/freescale/t104xrdb/eth.c +++ b/board/freescale/t104xrdb/eth.c @@ -6,11 +6,15 @@ #include common.h #include netdev.h +#include asm/fsl_serdes.h #include asm/immap_85xx.h #include fm_eth.h #include fsl_mdio.h #include malloc.h #include asm/fsl_dtsec.h +#ifdef CONFIG_VSC9953 +#include vsc9953.h +#endif #include ../common/fman.h @@ -20,6 +24,11 @@ int board_eth_init(bd_t *bis) struct memac_mdio_info memac_mdio_info; unsigned int i; int phy_addr = 0; +#ifdef CONFIG_VSC9953 + phy_interface_t phy_int; + struct mii_dev *bus; +#endif + printf(Initializing Fman\n); memac_mdio_info.regs = @@ -81,6 +90,49 @@ int board_eth_init(bd_t *bis) DEFAULT_FM_MDIO_NAME)); } +#ifdef CONFIG_VSC9953 + /* SerDes configured for QSGMII */ + if (serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_A) = 0) { + for (i = 0; i 4; i++) { + bus = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME); + phy_addr = CONFIG_SYS_FM1_QSGMII11_PHY_ADDR + i; + phy_int = PHY_INTERFACE_MODE_QSGMII; + + vsc9953_port_info_set_mdio(i, bus); + vsc9953_port_info_set_phy_address(i, phy_addr); + vsc9953_port_info_set_phy_int(i, phy_int); + vsc9953_port_enable(i); + } + } + if (serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_B) = 0) { + for (i = 4; i 8; i++) { + bus = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME); + phy_addr = CONFIG_SYS_FM1_QSGMII21_PHY_ADDR + i - 4; + phy_int = PHY_INTERFACE_MODE_QSGMII; + + vsc9953_port_info_set_mdio(i, bus); + vsc9953_port_info_set_phy_address(i, phy_addr); + vsc9953_port_info_set_phy_int(i, phy_int); + vsc9953_port_enable(i); + } + } + + /* Connect DTSEC1 to L2 switch if it doesn't have a PHY */ + if (serdes_get_first_lane(FSL_SRDS_1, SGMII_FM1_DTSEC1) 0) + vsc9953_port_enable(8); + + /* Connect DTSEC2 to L2 switch if it doesn't have a PHY */ + if (serdes_get_first_lane(FSL_SRDS_1, SGMII_FM1_DTSEC2) 0) { + /* Enable L2 On MAC2 using SCFG */ + struct ccsr_scfg *scfg = (struct ccsr_scfg *) + CONFIG_SYS_MPC85xx_SCFG; + + out_be32(scfg-esgmiiselcr, in_be32(scfg-esgmiiselcr) | +(0x8000)); + vsc9953_port_enable(9); + } +#endif + cpu_eth_init(bis); #endif diff --git a/include/configs/T104xRDB.h b/include/configs/T104xRDB.h index 57cdf72..c77b5d5 100644 --- a/include/configs/T104xRDB.h +++ b/include/configs/T104xRDB.h @@ -726,6 +726,12 @@ #define CONFIG_SYS_RGMII1_PHY_ADDR 0x01 #define CONFIG_SYS_RGMII2_PHY_ADDR 0x02 +#ifdef CONFIG_T1040RDB +#define CONFIG_VSC9953_CMD +#define CONFIG_SYS_FM1_QSGMII11_PHY_ADDR 0x04 +#define CONFIG_SYS_FM1_QSGMII21_PHY_ADDR 0x08 +#endif + #define CONFIG_MII /* MII PHY management */ #define CONFIG_ETHPRIMEFM1@DTSEC4 #define CONFIG_PHY_GIGE/* Include GbE speed/duplex detection */ -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 03/11] arch/powerpc: Add SGMII support for the L2 Switch ports
Some Freescale SoCs like T1020 and T1040 have an integrated L2 Switch. The L2 Switch ports may be connected to Ethernet PHYs over SGMII and QSGMII. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: Idadad19d469efc45f03c6f8884c3647e02b28df4 --- arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c | 6 ++ arch/powerpc/cpu/mpc85xx/t1040_serdes.c| 8 arch/powerpc/include/asm/fsl_serdes.h | 6 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c b/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c index f8e6c00..03c4642 100644 --- a/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c +++ b/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c @@ -78,6 +78,12 @@ static const char *serdes_prtcl_str[] = { [INTERLAKEN] = INTERLAKEN, [QSGMII_SW1_A] = QSGMII_SW1_A, [QSGMII_SW1_B] = QSGMII_SW1_B, + [SGMII_SW1_MAC1] = SGMII_SW1_MAC1, + [SGMII_SW1_MAC2] = SGMII_SW1_MAC2, + [SGMII_SW1_MAC3] = SGMII_SW1_MAC3, + [SGMII_SW1_MAC4] = SGMII_SW1_MAC4, + [SGMII_SW1_MAC5] = SGMII_SW1_MAC5, + [SGMII_SW1_MAC6] = SGMII_SW1_MAC6, }; #endif diff --git a/arch/powerpc/cpu/mpc85xx/t1040_serdes.c b/arch/powerpc/cpu/mpc85xx/t1040_serdes.c index d86bb27..d5dccd5 100644 --- a/arch/powerpc/cpu/mpc85xx/t1040_serdes.c +++ b/arch/powerpc/cpu/mpc85xx/t1040_serdes.c @@ -33,10 +33,10 @@ static u8 serdes_cfg_tbl[][SRDS_MAX_LANES] = { PCIE2, PCIE2, SGMII_FM1_DTSEC4, SGMII_FM1_DTSEC5}, [0x87] = {PCIE1, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2, PCIE3, PCIE4, SGMII_FM1_DTSEC5}, - [0x89] = {PCIE1, QSGMII_SW1_A, QSGMII_SW1_A, QSGMII_SW1_A, - PCIE2, PCIE3, QSGMII_SW1_B, SATA1}, - [0x8D] = {PCIE1, QSGMII_SW1_A, QSGMII_SW1_A, QSGMII_SW1_A, - PCIE2, QSGMII_SW1_B, QSGMII_SW1_B, QSGMII_SW1_B}, + [0x89] = {PCIE1, SGMII_SW1_MAC3, SGMII_SW1_MAC1, SGMII_SW1_MAC2, + PCIE2, PCIE3, SGMII_SW1_MAC4, SATA1}, + [0x8D] = {PCIE1, SGMII_SW1_MAC3, SGMII_SW1_MAC1, SGMII_SW1_MAC2, + PCIE2, SGMII_SW1_MAC6, SGMII_SW1_MAC4, SGMII_SW1_MAC5}, [0x8F] = {PCIE1, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, AURORA, NONE, SGMII_FM1_DTSEC4, SGMII_FM1_DTSEC5}, [0xA5] = {PCIE1, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, diff --git a/arch/powerpc/include/asm/fsl_serdes.h b/arch/powerpc/include/asm/fsl_serdes.h index 2dd32c2..45e248e 100644 --- a/arch/powerpc/include/asm/fsl_serdes.h +++ b/arch/powerpc/include/asm/fsl_serdes.h @@ -87,6 +87,12 @@ enum srds_prtcl { SGMII_2500_FM2_DTSEC6, SGMII_2500_FM2_DTSEC9, SGMII_2500_FM2_DTSEC10, + SGMII_SW1_MAC1, + SGMII_SW1_MAC2, + SGMII_SW1_MAC3, + SGMII_SW1_MAC4, + SGMII_SW1_MAC5, + SGMII_SW1_MAC6, SERDES_PRCTL_COUNT /* Keep this item the last one */ }; -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 10/11] board/T1040qds: Add VSC9953 support for T1040qds board
This patch configures and initializes the L2 switch on T1040QDS board. The L2 switch ports must be initialized according to the SerDes protocols. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I329f9cc1b1be745da23151e78831d8a3219b7f97 --- board/freescale/t1040qds/eth.c | 93 ++ include/configs/T1040QDS.h | 4 ++ 2 files changed, 97 insertions(+) diff --git a/board/freescale/t1040qds/eth.c b/board/freescale/t1040qds/eth.c index 2f8e753..ba6f518 100644 --- a/board/freescale/t1040qds/eth.c +++ b/board/freescale/t1040qds/eth.c @@ -18,6 +18,9 @@ #include fsl_mdio.h #include malloc.h #include asm/fsl_dtsec.h +#ifdef CONFIG_VSC9953 +#include vsc9953.h +#endif #include ../common/fman.h #include ../common/qixis.h @@ -439,6 +442,12 @@ int board_eth_init(bd_t *bis) #ifdef CONFIG_FMAN_ENET struct memac_mdio_info memac_mdio_info; unsigned int i; +#ifdef CONFIG_VSC9953 + int lane; + int phy_addr; + phy_interface_t phy_int; + struct mii_dev *bus; +#endif printf(Initializing Fman\n); set_brdcfg9_for_gtx_clk(); @@ -493,6 +502,90 @@ int board_eth_init(bd_t *bis) } } +#ifdef CONFIG_VSC9953 + for (i = 0; i VSC9953_MAX_PORTS; i++) { + lane = -1; + phy_addr = 0; + phy_int = PHY_INTERFACE_MODE_NONE; + switch (i) { + case 0: + case 1: + case 2: + case 3: + lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_A); + /* PHYs connected over QSGMII */ + if (lane = 0) { + phy_addr = CONFIG_SYS_FM1_QSGMII21_PHY_ADDR + + i; + phy_int = PHY_INTERFACE_MODE_QSGMII; + break; + } + lane = serdes_get_first_lane(FSL_SRDS_1, + SGMII_SW1_MAC1 + i); + + if (lane 0) + break; + + /* PHYs connected over QSGMII */ + if (i != 3 || lane_to_slot[lane] == 7) + phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR + + i; + else + phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR; + phy_int = PHY_INTERFACE_MODE_SGMII; + break; + case 4: + case 5: + case 6: + case 7: + lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_B); + /* PHYs connected over QSGMII */ + if (lane = 0) { + phy_addr = CONFIG_SYS_FM1_QSGMII11_PHY_ADDR + + i - 4; + phy_int = PHY_INTERFACE_MODE_QSGMII; + break; + } + lane = serdes_get_first_lane(FSL_SRDS_1, + SGMII_SW1_MAC1 + i); + /* PHYs connected over SGMII */ + if (lane = 0) { + phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR + + i - 3; + phy_int = PHY_INTERFACE_MODE_SGMII; + } + break; + case 8: + if (serdes_get_first_lane(FSL_SRDS_1, + SGMII_FM1_DTSEC1) 0) + /* FM1@DTSEC1 is connected to SW1@PORT8 */ + vsc9953_port_enable(i); + break; + case 9: + if (serdes_get_first_lane(FSL_SRDS_1, + SGMII_FM1_DTSEC2) 0) { + /* Enable L2 On MAC2 using SCFG */ + struct ccsr_scfg *scfg = (struct ccsr_scfg *) + CONFIG_SYS_MPC85xx_SCFG; + + out_be32(scfg-esgmiiselcr, +in_be32(scfg-esgmiiselcr) | +(0x8000)); + vsc9953_port_enable(i); + } + break; + } + + if (lane = 0) { + bus = mii_dev_for_muxval(lane_to_slot[lane]); + vsc9953_port_info_set_mdio(i, bus); + vsc9953_port_enable(i); + } + vsc9953_port_info_set_phy_address(i, phy_addr
[U-Boot] [PATCH v2 09/11] board/T104xrdb: T1040 FMAN ports FM1@DTSEC1 and FM1@DTSEC2 have no PHYs
Freescale's T1040qds board may be configured to have up to 5 FMAN ports (FM1@DTSEC1 to FM1@DTSEC5). From these 5 ports, 2 of them may be fixed-links (FM1@DTSEC1 annd FM1@DTSEC2), connected to other two ports from an intergrated VSC9953 L2 Switch (switch ports 8 and 9). These fixed-link ports have no PHYs attatched, so they don't have a corresponding MDIO. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I379544addc0842a6c6fb515fe398a61012cb4b16 --- board/freescale/t104xrdb/eth.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/board/freescale/t104xrdb/eth.c b/board/freescale/t104xrdb/eth.c index c8b6c67..f5c0ec8 100644 --- a/board/freescale/t104xrdb/eth.c +++ b/board/freescale/t104xrdb/eth.c @@ -72,8 +72,13 @@ int board_eth_init(bd_t *bis) fm_info_set_phy_address(i, 0); break; } - fm_info_set_mdio(i, -miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME)); + if (fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_QSGMII || + fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_NONE) + fm_info_set_mdio(i, NULL); + else + fm_info_set_mdio(i, +miiphy_get_dev_by_name( + DEFAULT_FM_MDIO_NAME)); } cpu_eth_init(bis); -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 03/10] net/fm: Enable FMAN ports if l2switch ports are connected over SGMII
If SerDes is configured to connect L2 Switch ports from T1040 over SGMII or QSGMII, the two FMAN fixed ports (FM1@DTSEC1 and FM2@DTSEC2) that are connected to two L2 swtch ports must be enabled. These ports don't have PHYs and must be treated accordingly. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I47f59d6a0c746bd56601518379af2178a036467b --- drivers/net/fm/t1040.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/fm/t1040.c b/drivers/net/fm/t1040.c index d2a097e..0458366 100644 --- a/drivers/net/fm/t1040.c +++ b/drivers/net/fm/t1040.c @@ -50,7 +50,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port) switch (port) { case FM1_DTSEC1: case FM1_DTSEC2: - if (is_serdes_configured(QSGMII_SW1_A + port - FM1_DTSEC1)) + if (is_serdes_configured(QSGMII_SW1_A + port - FM1_DTSEC1) || + is_serdes_configured(SGMII_SW1_MAC1 + port - FM1_DTSEC1)) return PHY_INTERFACE_MODE_QSGMII; case FM1_DTSEC3: case FM1_DTSEC4: -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 08/10] board/T104xrdb: T1040 FMAN ports FM1@DTSEC1 and FM1@DTSEC2 have no PHYs
Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I379544addc0842a6c6fb515fe398a61012cb4b16 --- board/freescale/t104xrdb/eth.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/board/freescale/t104xrdb/eth.c b/board/freescale/t104xrdb/eth.c index c8b6c67..f5c0ec8 100644 --- a/board/freescale/t104xrdb/eth.c +++ b/board/freescale/t104xrdb/eth.c @@ -72,8 +72,13 @@ int board_eth_init(bd_t *bis) fm_info_set_phy_address(i, 0); break; } - fm_info_set_mdio(i, -miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME)); + if (fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_QSGMII || + fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_NONE) + fm_info_set_mdio(i, NULL); + else + fm_info_set_mdio(i, +miiphy_get_dev_by_name( + DEFAULT_FM_MDIO_NAME)); } cpu_eth_init(bis); -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 07/10] board/T1040qds: T1040 FMAN ports FM1@DTSEC1 and FM1@DTSEC2 have no PHYs
Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I35d9b33667538eab40463035b5cbb290f7a1ee07 --- board/freescale/t1040qds/eth.c | 1 + 1 file changed, 1 insertion(+) diff --git a/board/freescale/t1040qds/eth.c b/board/freescale/t1040qds/eth.c index c6fc146..2f8e753 100644 --- a/board/freescale/t1040qds/eth.c +++ b/board/freescale/t1040qds/eth.c @@ -478,6 +478,7 @@ int board_eth_init(bd_t *bis) for (i = FM1_DTSEC1; i FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) { switch (fm_info_get_enet_if(i)) { case PHY_INTERFACE_MODE_QSGMII: + fm_info_set_mdio(i, NULL); break; case PHY_INTERFACE_MODE_SGMII: t1040_handle_phy_interface_sgmii(i); -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 01/10] net/fm: Fix error when FMAN MAC has no PHY
U-boot assumes that all FMAN ports have a PHY. Some SoCs (like T1040) have fixed links. This means that the ports are connected MAC to MAc and there is no Ethernet PHY attatched. This patch initializes a FMAN MAC even if it doesn't have a PHY attached. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com --- drivers/net/fm/eth.c | 30 ++ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c index f1e39b9..1d1089d 100644 --- a/drivers/net/fm/eth.c +++ b/drivers/net/fm/eth.c @@ -410,10 +410,15 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd) fmc_tx_port_graceful_stop_disable(fm_eth); #ifdef CONFIG_PHYLIB - ret = phy_startup(fm_eth-phydev); - if (ret) { - printf(%s: Could not initialize\n, fm_eth-phydev-dev-name); - return ret; + if (fm_eth-phydev) { + ret = phy_startup(fm_eth-phydev); + if (ret) { + printf(%s: Could not initialize\n, + fm_eth-phydev-dev-name); + return ret; + } + } else { + return 0; } #else fm_eth-phydev-speed = SPEED_1000; @@ -447,7 +452,8 @@ static void fm_eth_halt(struct eth_device *dev) /* disable bmi Rx port */ bmi_rx_port_disable(fm_eth-rx_port); - phy_shutdown(fm_eth-phydev); + if (fm_eth-phydev) + phy_shutdown(fm_eth-phydev); } static int fm_eth_send(struct eth_device *dev, void *buf, int len) @@ -625,11 +631,12 @@ static int init_phy(struct eth_device *dev) if (fm_eth-bus) { phydev = phy_connect(fm_eth-bus, fm_eth-phyaddr, dev, fm_eth-enet_if); - } - - if (!phydev) { - printf(Failed to connect\n); - return -1; + if (!phydev) { + printf(Failed to connect\n); + return -1; + } + } else { + return 0; } if (fm_eth-type == FM_ETH_1G_E) { @@ -711,8 +718,7 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info) if (!fm_eth_startup(fm_eth)) return 0; - if (init_phy(dev)) - return 0; + init_phy(dev); /* clear the ethernet address */ for (i = 0; i 6; i++) -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 02/10] arch/powerpc: Add SGMII support for the L2 Switch ports
Some Freescale SoCs like T1020 and T1040 have an integrated L2 Switch. The L2 Switch ports may be connected to Ethernet PHYs over SGMII and QSGMII. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: Idadad19d469efc45f03c6f8884c3647e02b28df4 --- arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c | 70 +++--- arch/powerpc/cpu/mpc85xx/t1040_serdes.c| 8 +-- arch/powerpc/include/asm/fsl_serdes.h | 7 +++ 3 files changed, 51 insertions(+), 34 deletions(-) diff --git a/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c b/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c index 5cfae47..03c4642 100644 --- a/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c +++ b/arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c @@ -15,16 +15,16 @@ #include fsl_corenet2_serdes.h #ifdef CONFIG_SYS_FSL_SRDS_1 -static u64 serdes1_prtcl_map; +static int serdes1_prtcl_map[SERDES_PRCTL_COUNT]; #endif #ifdef CONFIG_SYS_FSL_SRDS_2 -static u64 serdes2_prtcl_map; +static int serdes2_prtcl_map[SERDES_PRCTL_COUNT]; #endif #ifdef CONFIG_SYS_FSL_SRDS_3 -static u64 serdes3_prtcl_map; +static int serdes3_prtcl_map[SERDES_PRCTL_COUNT]; #endif #ifdef CONFIG_SYS_FSL_SRDS_4 -static u64 serdes4_prtcl_map; +static int serdes4_prtcl_map[SERDES_PRCTL_COUNT]; #endif #ifdef DEBUG @@ -78,24 +78,30 @@ static const char *serdes_prtcl_str[] = { [INTERLAKEN] = INTERLAKEN, [QSGMII_SW1_A] = QSGMII_SW1_A, [QSGMII_SW1_B] = QSGMII_SW1_B, + [SGMII_SW1_MAC1] = SGMII_SW1_MAC1, + [SGMII_SW1_MAC2] = SGMII_SW1_MAC2, + [SGMII_SW1_MAC3] = SGMII_SW1_MAC3, + [SGMII_SW1_MAC4] = SGMII_SW1_MAC4, + [SGMII_SW1_MAC5] = SGMII_SW1_MAC5, + [SGMII_SW1_MAC6] = SGMII_SW1_MAC6, }; #endif int is_serdes_configured(enum srds_prtcl device) { - u64 ret = 0; + int ret = 0; #ifdef CONFIG_SYS_FSL_SRDS_1 - ret |= (1ULL device) serdes1_prtcl_map; + ret |= serdes1_prtcl_map[device]; #endif #ifdef CONFIG_SYS_FSL_SRDS_2 - ret |= (1ULL device) serdes2_prtcl_map; + ret |= serdes2_prtcl_map[device]; #endif #ifdef CONFIG_SYS_FSL_SRDS_3 - ret |= (1ULL device) serdes3_prtcl_map; + ret |= serdes3_prtcl_map[device]; #endif #ifdef CONFIG_SYS_FSL_SRDS_4 - ret |= (1ULL device) serdes4_prtcl_map; + ret |= serdes4_prtcl_map[device]; #endif return !!ret; @@ -171,12 +177,14 @@ int serdes_get_first_lane(u32 sd, enum srds_prtcl device) #define BCAP_OVD_MASK 0x1000 #define BYP_CAL_MASK 0x0200 -u64 serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift) +void serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift, + int serdes_prtcl_map[SERDES_PRCTL_COUNT]) { ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); - u64 serdes_prtcl_map = 0; u32 cfg; int lane; + + memset(serdes_prtcl_map, 0, sizeof(serdes_prtcl_map)); #ifdef CONFIG_SYS_FSL_ERRATUM_A007186 struct ccsr_sfp_regs __iomem *sfp_regs = (struct ccsr_sfp_regs __iomem *)(CONFIG_SYS_SFP_ADDR); @@ -312,38 +320,40 @@ u64 serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift) for (lane = 0; lane SRDS_MAX_LANES; lane++) { enum srds_prtcl lane_prtcl = serdes_get_prtcl(sd, cfg, lane); - serdes_prtcl_map |= (1ULL lane_prtcl); + serdes_prtcl_map[lane_prtcl] = 1; } - - return serdes_prtcl_map; } void fsl_serdes_init(void) { #ifdef CONFIG_SYS_FSL_SRDS_1 - serdes1_prtcl_map = serdes_init(FSL_SRDS_1, - CONFIG_SYS_FSL_CORENET_SERDES_ADDR, - FSL_CORENET2_RCWSR4_SRDS1_PRTCL, - FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT); + serdes_init(FSL_SRDS_1, + CONFIG_SYS_FSL_CORENET_SERDES_ADDR, + FSL_CORENET2_RCWSR4_SRDS1_PRTCL, + FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT, + serdes1_prtcl_map); #endif #ifdef CONFIG_SYS_FSL_SRDS_2 - serdes2_prtcl_map = serdes_init(FSL_SRDS_2, - CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_2 * 0x1000, - FSL_CORENET2_RCWSR4_SRDS2_PRTCL, - FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT); + serdes_init(FSL_SRDS_2, + CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_2 * 0x1000, + FSL_CORENET2_RCWSR4_SRDS2_PRTCL, + FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT, + serdes2_prtcl_map); #endif #ifdef CONFIG_SYS_FSL_SRDS_3 - serdes3_prtcl_map = serdes_init(FSL_SRDS_3, - CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_3 * 0x1000, - FSL_CORENET2_RCWSR4_SRDS3_PRTCL, - FSL_CORENET2_RCWSR4_SRDS3_PRTCL_SHIFT); + serdes_init(FSL_SRDS_3, + CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_3 * 0x1000
[U-Boot] [PATCH 09/10] board/T1040qds: Add VSC9953 support for T1040qds board
This patch configures and initializes the L2 switch on T1040QDS board. The L2 switch ports must be initialized according to the SerDes protocols. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I329f9cc1b1be745da23151e78831d8a3219b7f97 --- board/freescale/t1040qds/eth.c | 92 ++ include/configs/T1040QDS.h | 4 ++ 2 files changed, 96 insertions(+) diff --git a/board/freescale/t1040qds/eth.c b/board/freescale/t1040qds/eth.c index 2f8e753..3345070 100644 --- a/board/freescale/t1040qds/eth.c +++ b/board/freescale/t1040qds/eth.c @@ -18,6 +18,9 @@ #include fsl_mdio.h #include malloc.h #include asm/fsl_dtsec.h +#ifdef CONFIG_VSC9953 +#include vsc9953.h +#endif #include ../common/fman.h #include ../common/qixis.h @@ -493,6 +496,95 @@ int board_eth_init(bd_t *bis) } } +#ifdef CONFIG_VSC9953 + int lane; + int phy_addr; + phy_interface_t phy_int; + struct mii_dev *bus; + + for (i = 0; i VSC9953_MAX_PORTS; i++) { + lane = -1; + phy_addr = 0; + phy_int = PHY_INTERFACE_MODE_NONE; + switch (i) { + case 0: + case 1: + case 2: + case 3: + lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_A); + /* PHYs connected over QSGMII */ + if (lane = 0) { + phy_addr = CONFIG_SYS_FM1_QSGMII21_PHY_ADDR + + i; + phy_int = PHY_INTERFACE_MODE_QSGMII; + break; + } + lane = serdes_get_first_lane(FSL_SRDS_1, + SGMII_SW1_MAC1 + i); + + if (lane 0) + break; + + /* PHYs connected over QSGMII */ + if (i != 3 || lane_to_slot[lane] == 7) + phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR + + i; + else + phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR; + phy_int = PHY_INTERFACE_MODE_SGMII; + break; + case 4: + case 5: + case 6: + case 7: + lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_B); + /* PHYs connected over QSGMII */ + if (lane = 0) { + phy_addr = CONFIG_SYS_FM1_QSGMII11_PHY_ADDR + + i - 4; + phy_int = PHY_INTERFACE_MODE_QSGMII; + break; + } + lane = serdes_get_first_lane(FSL_SRDS_1, + SGMII_SW1_MAC1 + i); + /* PHYs connected over SGMII */ + if (lane = 0) { + phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR + + i - 3; + phy_int = PHY_INTERFACE_MODE_SGMII; + } + break; + case 8: + if (serdes_get_first_lane(FSL_SRDS_1, + SGMII_FM1_DTSEC1) 0) + /* FM1@DTSEC1 is connected to SW1@PORT8 */ + vsc9953_port_enable(i); + break; + case 9: + if (serdes_get_first_lane(FSL_SRDS_1, + SGMII_FM1_DTSEC2) 0) { + /* Enable L2 On MAC2 using SCFG */ + struct ccsr_scfg *scfg = (struct ccsr_scfg *) + CONFIG_SYS_MPC85xx_SCFG; + + out_be32(scfg-esgmiiselcr, +in_be32(scfg-esgmiiselcr) | +(0x8000)); + vsc9953_port_enable(i); + } + break; + } + + if (lane = 0) { + bus = mii_dev_for_muxval(lane_to_slot[lane]); + vsc9953_port_info_set_mdio(i, bus); + vsc9953_port_enable(i); + } + vsc9953_port_info_set_phy_address(i, phy_addr); + vsc9953_port_info_set_phy_int(i, phy_int); + } + +#endif cpu_eth_init(bis); #endif diff --git a/include/configs/T1040QDS.h b/include/configs/T1040QDS.h index 6b396bb..8e6f946 100644 --- a/include/configs/T1040QDS.h +++ b/include/configs/T1040QDS.h
[U-Boot] [PATCH 04/10] net/vsc9953: Add driver for Vitesse VSC9953 L2 Switch IP
This patch adds a driver for VSC9953 L2 Switch. This Vitesse IP is integrated in Freescale T1040 and T1020 SoCs. The L2 switch has 10 Ethernet ports: 2 internal fixed-links (ports 8 and 9) at 2.5 Gbps and and 8 external ports at 1 Gbps. The external ports may be connected to PHYs over QSGMII and SGMII. Commands have also been added to enable/disable a port and to check a port's link speed, duplexity and status. The commands are: ethsw port port_nr enable|disable - enable/disable an l2 switch port ethsw port port_nr show - show an l2 switch port's configuration port_nr=0..9; use all for all ports For more detailse please see doc/README.t1040-l2switch Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: I460852dc67c1dd3b387e57a50d73dc0ec5f77f8b --- doc/README.t1040-l2switch | 49 + drivers/net/Makefile | 1 + drivers/net/vsc9953.c | 489 ++ include/vsc9953.h | 402 + 4 files changed, 941 insertions(+) create mode 100644 doc/README.t1040-l2switch create mode 100644 drivers/net/vsc9953.c create mode 100644 include/vsc9953.h diff --git a/doc/README.t1040-l2switch b/doc/README.t1040-l2switch new file mode 100644 index 000..6324f18 --- /dev/null +++ b/doc/README.t1040-l2switch @@ -0,0 +1,49 @@ +This file contains information for VSC9953, a Vitesse L2 Switch IP +which is integrated in the T1040/T1020 Freescale SoCs. + +About Device: += +VSC9953 is an 8-port Gigabit Ethernet switch supports the following features: + - 8192 MAC addresses + - Static Address provisioning + - Dynamic learning of MAC addresses and aging + - 4096 VLANs + - Independent and shared VLAN learning (IVL, SVL) + - Policing with storm control and MC/BC protection + - IPv4 and IPv6 multicast + - Jumbo frames (9.6 KB) + - Access Control List + - VLAN editing, translation and remarking + - RMON counters per port + +Switch interfaces: + - 8 Gigabit switch ports (ports 0 to 7) are external and are connected to external PHYs + - 2 switch ports (ports 8 and 9) of 2.5 G are connected (fixed links) + to FMan ports (FM1@DTSEC1 and FM1@DTSEC2) + +Commands Overview: += +Commands supported + - enable/disable a port + - check a port's link speed, duplexity and status. + +Commands syntax + ethsw port port_nr enable|disable - enable/disable an l2 switch port + ethsw port port_nr show - show an l2 switch port's configuration + + port_nr=0..9; use all for all ports + += ethsw port all show +Port Status LinkSpeed Duplex + 0 enabled down 10 half + 1 enabled down 10 half + 2 enabled down 10 half + 3 enabled up 1000 full + 4 disabled down- half + 5 disabled down- half + 6 disabled down- half + 7 disabled down- half + 8 enabled up 2500 full + 9 enabled up 2500 full += + diff --git a/drivers/net/Makefile b/drivers/net/Makefile index fb0cf8c..46c4ac6 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -66,3 +66,4 @@ obj-$(CONFIG_XILINX_LL_TEMAC) += xilinx_ll_temac.o xilinx_ll_temac_mdio.o \ xilinx_ll_temac_fifo.o xilinx_ll_temac_sdma.o obj-$(CONFIG_ZYNQ_GEM) += zynq_gem.o obj-$(CONFIG_FSL_MC_ENET) += fsl_mc/ +obj-$(CONFIG_VSC9953) += vsc9953.o diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c new file mode 100644 index 000..575c215 --- /dev/null +++ b/drivers/net/vsc9953.c @@ -0,0 +1,489 @@ +/* vsc9953.h + * + * Driver for the Vitesse VSC9953 L2 Switch + * + * This software may be used and distributed according to the + * terms of the GNU Public License, Version 2, incorporated + * herein by reference. + * + * Copyright 2013 Freescale Semiconductor, Inc. + * + */ + +#include asm/io.h +#include asm/fsl_serdes.h +#include fm_eth.h +#include asm/fsl_memac.h +#include vsc9953.h + +static struct vsc9953_info vsc9953_l2sw = { + .port[0] = VSC9953_PORT_INFO_INITIALIZER(0), + .port[1] = VSC9953_PORT_INFO_INITIALIZER(1), + .port[2] = VSC9953_PORT_INFO_INITIALIZER(2), + .port[3] = VSC9953_PORT_INFO_INITIALIZER(3), + .port[4] = VSC9953_PORT_INFO_INITIALIZER(4), + .port[5] = VSC9953_PORT_INFO_INITIALIZER(5), + .port[6] = VSC9953_PORT_INFO_INITIALIZER(6), + .port[7] = VSC9953_PORT_INFO_INITIALIZER(7), + .port[8] = VSC9953_PORT_INFO_INITIALIZER(8), + .port[9] = VSC9953_PORT_INFO_INITIALIZER(9), +}; + +void vsc9953_port_info_set_mdio(int port, struct mii_dev *bus
[U-Boot] [PATCH 05/10] arch/powerpc: Enable VSC9953 driver on T1040 and T1020
Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: If65224646f737270dad1ef3558a400a002e9d4b6 --- arch/powerpc/cpu/mpc8xxx/cpu.c| 7 +++ arch/powerpc/include/asm/config_mpc85xx.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/arch/powerpc/cpu/mpc8xxx/cpu.c b/arch/powerpc/cpu/mpc8xxx/cpu.c index 2d28eb2..41026d1 100644 --- a/arch/powerpc/cpu/mpc8xxx/cpu.c +++ b/arch/powerpc/cpu/mpc8xxx/cpu.c @@ -15,6 +15,9 @@ #include netdev.h #include asm/cache.h #include asm/io.h +#ifdef CONFIG_VSC9953 +#include vsc9953.h +#endif DECLARE_GLOBAL_DATA_PTR; @@ -271,5 +274,9 @@ int cpu_eth_init(bd_t *bis) #ifdef CONFIG_FMAN_ENET fm_standard_init(bis); #endif + +#ifdef CONFIG_VSC9953 + vsc9953_init(bis); +#endif return 0; } diff --git a/arch/powerpc/include/asm/config_mpc85xx.h b/arch/powerpc/include/asm/config_mpc85xx.h index 01b0905..79caac1 100644 --- a/arch/powerpc/include/asm/config_mpc85xx.h +++ b/arch/powerpc/include/asm/config_mpc85xx.h @@ -747,6 +747,9 @@ defined(CONFIG_PPC_T1020) || defined(CONFIG_PPC_T1022) #define CONFIG_SYS_FSL_QORIQ_CHASSIS2 /* Freescale Chassis generation 2 */ #define CONFIG_SYS_FSL_CORES_PER_CLUSTER 1 #define CONFIG_SYS_FSL_QMAN_V3 /* QMAN version 3 */ +#if defined(CONFIG_PPC_T1040) || defined(CONFIG_PPC_T1020) +#define CONFIG_VSC9953 /* Vitesse L2 Switch */ +#endif #ifdef CONFIG_SYS_FSL_DDR4 #define CONFIG_SYS_FSL_DDRC_GEN4 #endif -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot