driver: net: ti: clean up and code optimization
v3 cover driver: net: ti: clean up and code optimization
This series contains set of code clean up and optimizations for TI networking drivers. Patch 1 - Adds drivers/net/ti/ folder and moves all TI's networking code
in this folder.
Patches 2,3 - keystone2 clean up
Patch 5 - introduces common TI MDIO support library as existing TI SoCs network
HW IPs have similar MDIO implementation.
Patches 6-7 - conversation of TI CPSW and keystone_net drivers to use common
TI MDIO support library
tested dhcp and kernel boot on:
- k2e/g/hk/l evms
- am437x-gpevm and AM5748 IDK
changes in v3:
- patch 5 comments applied
changes in v2:
- patch 5 comments fixed: use wait_for_bit, snprintf, mdelay, mdio_free
v2: https://patchwork.ozlabs.org/cover/991649/
v1: https://patchwork.ozlabs.org/cover/989449/
TODO: TODO: As per code and documentation davinci_emac.c seems also can be re-worked to use common TI MDIO support library and network PHYs framework. Unfortunately, I have no HW to work with.
Grygorii Strashko (7):
driver: net: consolidate ti's code in separate folder
configs: net: convert DRIVER_TI_KEYSTONE_NET kconfig
drivers: net: keystone_net: drop non dm code
driver: net: ti: cpsw: update to use SPDX identifier
driver: net: ti: introduce common mdio support library
driver: net: ti: cpsw: switch to use common mdio lib
driver: net: ti: keystone_net: switch to use common mdio lib
arch/arm/include/asm/ti-common/keystone_net.h | 27 --
arch/arm/mach-davinci/dp83848.c | 2 +-
arch/arm/mach-davinci/et1011c.c | 2 +-
arch/arm/mach-davinci/ksz8873.c | 2 +-
arch/arm/mach-davinci/lxt972.c | 2 +-
board/ti/ks2_evm/board.c | 53 ----
board/ti/ks2_evm/board.h | 3 -
board/ti/ks2_evm/board_k2e.c | 74 -----
board/ti/ks2_evm/board_k2g.c | 18 --
board/ti/ks2_evm/board_k2hk.c | 42 ---
board/ti/ks2_evm/board_k2l.c | 42 ---
configs/k2e_evm_defconfig | 1 +
configs/k2e_hs_evm_defconfig | 1 +
configs/k2g_evm_defconfig | 1 +
configs/k2g_hs_evm_defconfig | 1 +
configs/k2hk_evm_defconfig | 1 +
configs/k2hk_hs_evm_defconfig | 1 +
configs/k2l_evm_defconfig | 1 +
configs/k2l_hs_evm_defconfig | 1 +
drivers/net/Kconfig | 13 +-
drivers/net/Makefile | 4 +-
drivers/net/ti/Kconfig | 20 ++
drivers/net/ti/Makefile | 7 +
drivers/net/{ => ti}/cpsw-common.c | 0
drivers/net/{ => ti}/cpsw.c | 146 +---------
drivers/net/ti/cpsw_mdio.c | 203 +++++++++++++
drivers/net/ti/cpsw_mdio.h | 18 ++
drivers/net/{ => ti}/davinci_emac.c | 0
drivers/net/{ => ti}/davinci_emac.h | 0
drivers/net/{ => ti}/keystone_net.c | 401 +-------------------------
include/configs/ti_armv7_keystone2.h | 1 -
31 files changed, 286 insertions(+), 802 deletions(-)
create mode 100644 drivers/net/ti/Kconfig
create mode 100644 drivers/net/ti/Makefile
rename drivers/net/{ => ti}/cpsw-common.c (100%)
rename drivers/net/{ => ti}/cpsw.c (90%)
create mode 100644 drivers/net/ti/cpsw_mdio.c
create mode 100644 drivers/net/ti/cpsw_mdio.h
rename drivers/net/{ => ti}/davinci_emac.c (100%)
rename drivers/net/{ => ti}/davinci_emac.h (100%)
rename drivers/net/{ => ti}/keystone_net.c (68%)Signature · 1 line
2.10.5
PATCH v3 1/7 driver: net: consolidate ti's code in separate folder
Add drivers/net/ti/ folder and move all TI's code in this folder for better maintenance.
---
arch/arm/mach-davinci/dp83848.c | 2 +-
arch/arm/mach-davinci/et1011c.c | 2 +-
arch/arm/mach-davinci/ksz8873.c | 2 +-
arch/arm/mach-davinci/lxt972.c | 2 +-
drivers/net/Kconfig | 13 +------------
drivers/net/Makefile | 4 +---
drivers/net/ti/Kconfig | 15 +++++++++++++++
drivers/net/ti/Makefile | 7 +++++++
drivers/net/{ => ti}/cpsw-common.c | 0
drivers/net/{ => ti}/cpsw.c | 0
drivers/net/{ => ti}/davinci_emac.c | 0
drivers/net/{ => ti}/davinci_emac.h | 0
drivers/net/{ => ti}/keystone_net.c | 0
13 files changed, 28 insertions(+), 19 deletions(-)
create mode 100644 drivers/net/ti/Kconfig
create mode 100644 drivers/net/ti/Makefile
rename drivers/net/{ => ti}/cpsw-common.c (100%)
rename drivers/net/{ => ti}/cpsw.c (100%)
rename drivers/net/{ => ti}/davinci_emac.c (100%)
rename drivers/net/{ => ti}/davinci_emac.h (100%)
rename drivers/net/{ => ti}/keystone_net.c (100%)arch/arm/mach-davinci/dp83848.c +1 -1
@@ -12,7 +12,7 @@#include <net.h> #include <dp83848.h> #include <asm/arch/emac_defs.h> -#include "../../../drivers/net/davinci_emac.h" +#include "../../../drivers/net/ti/davinci_emac.h" #ifdef CONFIG_DRIVER_TI_EMAC
arch/arm/mach-davinci/et1011c.c +1 -1
@@ -9,7 +9,7 @@#include <net.h> #include <miiphy.h> #include <asm/arch/emac_defs.h> -#include "../../../drivers/net/davinci_emac.h" +#include "../../../drivers/net/ti/davinci_emac.h" #ifdef CONFIG_DRIVER_TI_EMAC
arch/arm/mach-davinci/ksz8873.c +1 -1
@@ -19,7 +19,7 @@#include <net.h> #include <asm/arch/emac_defs.h> #include <asm/io.h> -#include "../../../drivers/net/davinci_emac.h" +#include "../../../drivers/net/ti/davinci_emac.h" int ksz8873_is_phy_connected (int phy_addr) {
arch/arm/mach-davinci/lxt972.c +1 -1
@@ -13,7 +13,7 @@#include <miiphy.h> #include <lxt971a.h> #include <asm/arch/emac_defs.h> -#include "../../../drivers/net/davinci_emac.h" +#include "../../../drivers/net/ti/davinci_emac.h" #ifdef CONFIG_DRIVER_TI_EMAC
drivers/net/Kconfig +1 -12
@@ -1,5 +1,6 @@ source "drivers/net/phy/Kconfig" source "drivers/net/pfe_eth/Kconfig" +source "drivers/net/ti/Kconfig" config DM_ETH bool "Enable Driver Model for Ethernet drivers"
@@ -11,13 +12,6 @@ config DM_ETH This is currently implemented in net/eth-uclass.c Look in include/net.h for details. -config DRIVER_TI_CPSW - bool "TI Common Platform Ethernet Switch" - select PHYLIB - help - This driver supports the TI three port switch gigabit ethernet - subsystem found in the TI SoCs. - menuconfig NETDEVICES bool "Network device support" depends on NET
@@ -322,11 +316,6 @@ config SH_ETHER help This driver supports the Ethernet for Renesas SH and ARM SoCs. -config DRIVER_TI_EMAC - bool "TI Davinci EMAC" - help - Support for davinci emac - config XILINX_AXIEMAC depends on DM_ETH && (MICROBLAZE || ARCH_ZYNQ || ARCH_ZYNQMP) select PHYLIB
drivers/net/Makefile +1 -3
@@ -30,7 +30,6 @@ obj-$(CONFIG_FTGMAC100) += ftgmac100.o obj-$(CONFIG_FTMAC110) += ftmac110.o obj-$(CONFIG_FTMAC100) += ftmac100.o obj-$(CONFIG_GMAC_ROCKCHIP) += gmac_rockchip.o -obj-$(CONFIG_DRIVER_TI_KEYSTONE_NET) += keystone_net.o obj-$(CONFIG_KS8851_MLL) += ks8851_mll.o obj-$(CONFIG_LAN91C96) += lan91c96.o obj-$(CONFIG_LPC32XX_ETH) += lpc32xx_eth.o
@@ -56,9 +55,7 @@ obj-$(CONFIG_SH_ETHER) += sh_eth.o obj-$(CONFIG_RENESAS_RAVB) += ravb.o obj-$(CONFIG_SMC91111) += smc91111.o obj-$(CONFIG_SMC911X) += smc911x.o -obj-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o obj-$(CONFIG_TSEC_ENET) += tsec.o fsl_mdio.o -obj-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o cpsw-common.o obj-$(CONFIG_FMAN_ENET) += fsl_mdio.o obj-$(CONFIG_ULI526X) += uli526x.o obj-$(CONFIG_VSC7385_ENET) += vsc7385.o
@@ -73,3 +70,4 @@ obj-$(CONFIG_PIC32_ETH) += pic32_mdio.o pic32_eth.o obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o obj-$(CONFIG_FSL_PFE) += pfe_eth/ obj-$(CONFIG_SNI_AVE) += sni_ave.o +obj-y += ti/
drivers/net/ti/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + +config DRIVER_TI_CPSW + bool "TI Common Platform Ethernet Switch" + select PHYLIB + help + This driver supports the TI three port switch gigabit ethernet + subsystem found in the TI SoCs. + +config DRIVER_TI_EMAC + bool "TI Davinci EMAC" + help + Support for davinci emac
drivers/net/ti/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + +obj-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o cpsw-common.o +obj-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o +obj-$(CONFIG_DRIVER_TI_KEYSTONE_NET) += keystone_net.o
drivers/net/ti/cpsw-common.c renamed from drivers/net/cpsw-common.c +0 -0
drivers/net/ti/cpsw.c renamed from drivers/net/cpsw.c +0 -0
drivers/net/ti/davinci_emac.c renamed from drivers/net/davinci_emac.c +0 -0
drivers/net/ti/davinci_emac.h renamed from drivers/net/davinci_emac.h +0 -0
drivers/net/ti/keystone_net.c renamed from drivers/net/keystone_net.c +0 -0
Signature · 1 line
2.10.5
[U-Boot] driver: net: consolidate ti's code in separate folder
Hi Grygorii,
https://patchwork.ozlabs.org/patch/991712/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 2/7 configs: net: convert DRIVER_TI_KEYSTONE_NET kconfig
In reply to Grygorii StrashkoConvert DRIVER_TI_KEYSTONE_NET to Kconfig.
--- configs/k2e_evm_defconfig | 1 + configs/k2e_hs_evm_defconfig | 1 + configs/k2g_evm_defconfig | 1 + configs/k2g_hs_evm_defconfig | 1 + configs/k2hk_evm_defconfig | 1 + configs/k2hk_hs_evm_defconfig | 1 + configs/k2l_evm_defconfig | 1 + configs/k2l_hs_evm_defconfig | 1 + drivers/net/ti/Kconfig | 5 +++++ include/configs/ti_armv7_keystone2.h | 1 - 10 files changed, 13 insertions(+), 1 deletion(-)
configs/k2e_evm_defconfig +1 -0
@@ -56,3 +56,4 @@ CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_STORAGE=y +CONFIG_DRIVER_TI_KEYSTONE_NET=y
configs/k2e_hs_evm_defconfig +1 -0
@@ -49,3 +49,4 @@ CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_STORAGE=y +CONFIG_DRIVER_TI_KEYSTONE_NET=y
configs/k2g_evm_defconfig +1 -0
@@ -60,3 +60,4 @@ CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_STORAGE=y +CONFIG_DRIVER_TI_KEYSTONE_NET=y
configs/k2g_hs_evm_defconfig +1 -0
@@ -53,3 +53,4 @@ CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_STORAGE=y +CONFIG_DRIVER_TI_KEYSTONE_NET=y
configs/k2hk_evm_defconfig +1 -0
@@ -56,3 +56,4 @@ CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_STORAGE=y +CONFIG_DRIVER_TI_KEYSTONE_NET=y
configs/k2hk_hs_evm_defconfig +1 -0
@@ -49,3 +49,4 @@ CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_STORAGE=y +CONFIG_DRIVER_TI_KEYSTONE_NET=y
configs/k2l_evm_defconfig +1 -0
@@ -56,3 +56,4 @@ CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_STORAGE=y +CONFIG_DRIVER_TI_KEYSTONE_NET=y
configs/k2l_hs_evm_defconfig +1 -0
@@ -48,3 +48,4 @@ CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_STORAGE=y +CONFIG_DRIVER_TI_KEYSTONE_NET=y
drivers/net/ti/Kconfig +5 -0
@@ -13,3 +13,8 @@ config DRIVER_TI_EMAC bool "TI Davinci EMAC" help Support for davinci emac + +config DRIVER_TI_KEYSTONE_NET + bool "TI Keystone 2 Ethernet" + help + This driver supports the TI Keystone 2 Ethernet subsystem
include/configs/ti_armv7_keystone2.h +0 -1
@@ -128,7 +128,6 @@#define CONFIG_KSNAV_NETCP_PDMA_TX_SND_QUEUE KS2_NETCP_PDMA_TX_SND_QUEUE/* Keystone net */ -#define CONFIG_DRIVER_TI_KEYSTONE_NET #define CONFIG_KSNET_MAC_ID_BASE KS2_MAC_ID_BASE_ADDR#define CONFIG_KSNET_NETCP_BASE KS2_NETCP_BASE#define CONFIG_KSNET_SERDES_SGMII_BASE KS2_SGMII_SERDES_BASE
Signature · 1 line
2.10.5
PATCH v3 2/7 configs: net: convert DRIVER_TI_KEYSTONE_NET kconfig
Quoted 6 lines · Grygorii Strashko
Convert
DRIVER_TI_KEYSTONE_NETtoKconfig.Reviewed-by Tom Rini <[email protected]>Acked-by Joe Hershberger <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>
[ ... ]
Quoted 5 lines
drivers/net/ti/Kconfig +0
-0
drivers/net/ti/Kconfig config DRIVER_TI_EMAC · line 20
Quoted 9 lines
drivers/net/ti/Kconfig +5
-0@@ -13,3 +13,8 @@ config DRIVER_TI_EMAC bool "TI Davinci EMAC" help Support for davinci emac + +config DRIVER_TI_KEYSTONE_NET + bool "TI Keystone 2 Ethernet" + help + This driver supports the TI Keystone 2 Ethernet subsystem
Spend a few days discovering that this breaks "Freescale AArch64 LS10xx" builds. Fixing up.
Quoted 19 lines
include/configs/ti_armv7_keystone2.h +0
-2@@ -128,7 +128,6 @@#define CONFIG_KSNAV_NETCP_PDMA_TX_SND_QUEUE KS2_NETCP_PDMA_TX_SND_QUEUE/* Keystone net */ -#define CONFIG_DRIVER_TI_KEYSTONE_NET #define CONFIG_KSNET_MAC_ID_BASE KS2_MAC_ID_BASE_ADDR#define CONFIG_KSNET_NETCP_BASE KS2_NETCP_BASE#define CONFIG_KSNET_SERDES_SGMII_BASE KS2_SGMII_SERDES_BASE --2.10.5
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
[U-Boot] configs: net: convert DRIVER_TI_KEYSTONE_NET kconfig
In reply to Grygorii StrashkoHi Grygorii,
https://patchwork.ozlabs.org/patch/991713/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 3/7 drivers: net: keystone_net: drop non dm code
In reply to Grygorii StrashkoNetworking support for all TI K2 boards converted to use DM model and CONFIG_DM_ETH enabled in all corresponding defconfig files, hence drop unused non DM K2 networking code.
--- arch/arm/include/asm/ti-common/keystone_net.h | 14 -- board/ti/ks2_evm/board.c | 53 ----- board/ti/ks2_evm/board.h | 3 - board/ti/ks2_evm/board_k2e.c | 74 ------- board/ti/ks2_evm/board_k2g.c | 18 -- board/ti/ks2_evm/board_k2hk.c | 42 ---- board/ti/ks2_evm/board_k2l.c | 42 ---- drivers/net/ti/keystone_net.c | 287 +------------------------- 8 files changed, 1 insertion(+), 532 deletions(-)
arch/arm/include/asm/ti-common/keystone_net.h +0 -14
@@ -242,18 +242,4 @@ struct mdio_regs { u32 userphysel1; }; -struct eth_priv_t { -char int_name[32 ]; -int rx_flow; -int phy_addr; -int slave_port; -int sgmii_link_type; -phy_interface_t phy_if; -struct phy_device *phy_dev; -}; - -int keystone2_emac_initialize (struct eth_priv_t *eth_priv); -void sgmii_serdes_setup_156p25mhz (void ); -void sgmii_serdes_shutdown (void ); -#endif /* _KEYSTONE_NET_H_ */
board/ti/ks2_evm/board.c +0 -53
59 lines not on this page · raw message
board/ti/ks2_evm/board.h +0 -3
@@ -12,8 +12,6 @@#include <asm/ti-common/keystone_net.h> #include "../common/board_detect.h" -extern struct eth_priv_t eth_priv_cfg[]; -#if defined(CONFIG_TI_I2C_BOARD_DETECT )static inline int board_is_k2g_gp (void ) {
@@ -38,7 +36,6 @@ static inline int board_is_k2g_ice(void) }#endif -int get_num_eth_ports (void );void spl_init_keystone_plls (void );#endif
board/ti/ks2_evm/board_k2e.c +0 -74
80 lines not on this page · raw message
board/ti/ks2_evm/board_k2g.c +0 -18
@@ -354,24 +354,6 @@ void spl_init_keystone_plls(void) }#endif -#ifdef CONFIG_DRIVER_TI_KEYSTONE_NET -struct eth_priv_t eth_priv_cfg[] = { - { - .int_name ="K2G_EMAC" , - .rx_flow =0 , - .phy_addr =0 , - .slave_port =1 , - .sgmii_link_type =SGMII_LINK_MAC_PHY , - .phy_if =PHY_INTERFACE_MODE_RGMII , - }, -}; - -int get_num_eth_ports (void ) -{ -return sizeof (eth_priv_cfg) /sizeof (struct eth_priv_t ); -} -#endif -#ifdef CONFIG_TI_SECURE_DEVICE void board_pmmc_image_process (ulong pmmc_image,size_t pmmc_size) {
board/ti/ks2_evm/board_k2hk.c +0 -42
48 lines not on this page · raw message
board/ti/ks2_evm/board_k2l.c +0 -42
48 lines not on this page · raw message
drivers/net/ti/keystone_net.c +1 -286
332 lines not on this page · raw message
Signature · 1 line
2.10.5
[U-Boot] drivers: net: keystone_net: drop non dm code
Hi Grygorii,
https://patchwork.ozlabs.org/patch/991707/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 4/7 driver: net: ti: cpsw: update to use SPDX identifier
In reply to Grygorii StrashkoUpdate to use SPDX license identifier.
--- drivers/net/ti/cpsw.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/net/ti/cpsw.c +2 -10
@@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * CPSW Ethernet Switch Driver * -* Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation version 2. -* -* This program is distributed "as is" WITHOUT ANY WARRANTY of any -* kind, whether express or implied; without even the implied warranty -* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. +* Copyright (C) 2010-2018 Texas Instruments Incorporated - http://www.ti.com/ */ #include <common.h>
Signature · 1 line
2.10.5
[U-Boot] driver: net: ti: cpsw: update to use SPDX identifier
Hi Grygorii,
https://patchwork.ozlabs.org/patch/991710/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 5/7 driver: net: ti: introduce common mdio support library
In reply to Grygorii StrashkoAll existing TI SoCs network HW have similar MDIO implementation, so introduce common mdio support library which can be reused by TI networking drivers.
--- drivers/net/ti/Makefile | 2 +- drivers/net/ti/cpsw_mdio.c | 203 +++++++++++++++++++++++++++++++++++++++++++++ drivers/net/ti/cpsw_mdio.h | 18 ++++ 3 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ti/cpsw_mdio.c create mode 100644 drivers/net/ti/cpsw_mdio.h
drivers/net/ti/Makefile +1 -1
@@ -2,6 +2,6 @@ # # Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ -obj-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o cpsw-common.o +obj-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o cpsw-common.o cpsw_mdio.o obj-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o obj-$(CONFIG_DRIVER_TI_KEYSTONE_NET) += keystone_net.o
drivers/net/ti/cpsw_mdio.c new file +203 -0
203 lines not on this page · raw message
drivers/net/ti/cpsw_mdio.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* CPSW MDIO generic driver API for TI AMxx/K2x/EMAC devices. +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +*/ + +#ifndef CPSW_MDIO_H_ +#define CPSW_MDIO_H_ + +struct cpsw_mdio ; + +struct mii_dev *cpsw_mdio_init (const char *name,u32 mdio_base, +u32 bus_freq,int fck_freq); +void cpsw_mdio_free (struct mii_dev *bus); +u32 cpsw_mdio_get_alive (struct mii_dev *bus); + +#endif /* CPSW_MDIO_H_ */
Signature · 1 line
2.10.5
PATCH v3 5/7 driver: net: ti: introduce common mdio support library
Quoted 7 lines · Grygorii Strashko
All existing TI SoCs network HW have similar MDIO implementation, so introduce common mdio support library which can be reused by TI networking drivers.
Reviewed-by Tom Rini <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>
[U-Boot] driver: net: ti: introduce common mdio support library
In reply to Grygorii StrashkoHi Grygorii,
https://patchwork.ozlabs.org/patch/991704/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 6/7 driver: net: ti: cpsw: switch to use common mdio lib
In reply to Grygorii StrashkoUpdate TI CPSW driver to re-use common mdio lib
--- drivers/net/ti/cpsw.c | 134 +++----------------------------------------------- 1 file changed, 6 insertions(+), 128 deletions(-)
drivers/net/ti/cpsw.c +6 -128
@@ -21,11 +21,11 @@#include <dm.h> #include <fdt_support.h> +#include "cpsw_mdio.h" +DECLARE_GLOBAL_DATA_PTR ;#define BITMASK (bits) (BIT(bits) - 1) -#define PHY_REG_MASK 0x1f -#define PHY_ID_MASK 0x1f#define NUM_DESCS (PKTBUFSRX * 2)#define PKT_MIN 60#define PKT_MAX (1500 + 14 + 4 + 4)
@@ -76,37 +76,8 @@ DECLARE_GLOBAL_DATA_PTR;* unexpected controller lock ups. Ideally, we should never ever hit this * scenario in practice. */ -#define MDIO_TIMEOUT 100/* msecs */ #define CPDMA_TIMEOUT 100/* msecs */ -struct cpsw_mdio_regs { -u32 version; -u32 control; -#define CONTROL_IDLE BIT(31) -#define CONTROL_ENABLE BIT(30) - -u32 alive; -u32 link; -u32 linkintraw; -u32 linkintmasked; -u32 __reserved_0[2 ]; -u32 userintraw; -u32 userintmasked; -u32 userintmaskset; -u32 userintmaskclr; -u32 __reserved_1[20 ]; - -struct { -u32 access; -u32 physel; -#define USERACCESS_GO BIT(31) -#define USERACCESS_WRITE BIT(30) -#define USERACCESS_ACK BIT(29) -#define USERACCESS_READ (0) -#define USERACCESS_DATA (0xffff) - } user[0 ]; -}; -struct cpsw_regs {u32 id_ver;u32 control;
@@ -484,100 +455,6 @@ static inline void cpsw_ale_port_state(struct cpsw_priv *priv, int port,__raw_writel (tmp, priv->ale_regs + offset); } -static struct cpsw_mdio_regs *mdio_regs; - -/* wait until hardware is ready for another user access */ -static inline u32 wait_for_user_access (void ) -{ -u32 reg =0 ; -int timeout =MDIO_TIMEOUT ; - -while (timeout-- && - ((reg =__raw_readl (&mdio_regs->user[0 ].access)) &USERACCESS_GO )) -udelay (10 ); - -if (timeout ==-1 ) { -printf ("wait_for_user_access Timeout\n" ); -return -ETIMEDOUT ; - } -return reg; -} - -/* wait until hardware state machine is idle */ -static inline void wait_for_idle (void ) -{ -int timeout =MDIO_TIMEOUT ; - -while (timeout-- && - ((__raw_readl (&mdio_regs->control) &CONTROL_IDLE ) ==0 )) -udelay (10 ); - -if (timeout ==-1 ) -printf ("wait_for_idle Timeout\n" ); -} - -static int cpsw_mdio_read (struct mii_dev *bus,int phy_id, -int dev_addr,int phy_reg) -{ -int data; -u32 reg; - -if (phy_reg & ~PHY_REG_MASK || phy_id & ~PHY_ID_MASK ) -return -EINVAL ; - -wait_for_user_access (); - reg = (USERACCESS_GO |USERACCESS_READ | (phy_reg <<21 ) | - (phy_id <<16 )); -__raw_writel (reg, &mdio_regs->user[0 ].access); - reg =wait_for_user_access (); - - data = (reg &USERACCESS_ACK ) ? (reg &USERACCESS_DATA ) :-1 ; -return data; -} - -static int cpsw_mdio_write (struct mii_dev *bus,int phy_id,int dev_addr, -int phy_reg,u16 data) -{ -u32 reg; - -if (phy_reg & ~PHY_REG_MASK || phy_id & ~PHY_ID_MASK ) -return -EINVAL ; - -wait_for_user_access (); - reg = (USERACCESS_GO |USERACCESS_WRITE | (phy_reg <<21 ) | - (phy_id <<16 ) | (data &USERACCESS_DATA )); -__raw_writel (reg, &mdio_regs->user[0 ].access); -wait_for_user_access (); - -return 0 ; -} - -static void cpsw_mdio_init (const char *name,u32 mdio_base,u32 div) -{ -struct mii_dev *bus =mdio_alloc (); - - mdio_regs = (struct cpsw_mdio_regs *)mdio_base; - -/* set enable and clock divider */ -__raw_writel (div |CONTROL_ENABLE , &mdio_regs->control); - -/* -* wait for scan logic to settle: -* the scan time consists of (a) a large fixed component, and (b) a -* small component that varies with the mii bus frequency. These -* were estimated using measurements at 1.1 and 2.2 MHz on tnetv107x -* silicon. Since the effect of (b) was found to be largely -* negligible, we keep things simple here. -*/ -udelay (1000 ); - - bus->read = cpsw_mdio_read; - bus->write = cpsw_mdio_write; -strcpy (bus->name, name); - -mdio_register (bus); -} -/* Set a self-clearing bit in a register, and wait for it to clear */ static inline void setbit_and_wait_for_clear32 (void *addr) {
@@ -1003,7 +880,7 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave)static void cpsw_phy_addr_update (struct cpsw_priv *priv) {struct cpsw_platform_data *data = &priv->data; -u16 alive = mdio_regs->alive &GENMASK (15 ,0 ); +u16 alive =cpsw_mdio_get_alive (priv->bus);int active = data->active_slave;int new_addr =ffs (alive) -1 ;
@@ -1044,11 +921,12 @@ int _cpsw_register(struct cpsw_priv *priv) idx = idx +1 ; } -cpsw_mdio_init (priv->dev->name, data->mdio_base, data->mdio_div); + priv->bus =cpsw_mdio_init (priv->dev->name, data->mdio_base,0 ,0 ); +if (!priv->bus) +return -EFAULT ;cpsw_phy_addr_update (priv); - priv->bus =miiphy_get_dev_by_name (priv->dev->name); for_active_slave(slave, priv)cpsw_phy_init (priv, slave);
Signature · 1 line
2.10.5
[U-Boot] driver: net: ti: cpsw: switch to use common mdio lib
Hi Grygorii,
https://patchwork.ozlabs.org/patch/991708/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 7/7 driver: net: ti: keystone_net: switch to use common mdio lib
In reply to Grygorii StrashkoUpdate TI Keystone 2 driver to re-use common mdio lib.
--- arch/arm/include/asm/ti-common/keystone_net.h | 13 --- drivers/net/ti/Makefile | 2 +- drivers/net/ti/keystone_net.c | 118 ++++---------------------- 3 files changed, 18 insertions(+), 115 deletions(-)
arch/arm/include/asm/ti-common/keystone_net.h +0 -13
@@ -57,19 +57,6 @@/* MDIO clock output frequency */ #define EMAC_MDIO_CLOCK_FREQ 2500000/* 2.5 MHz */ -/* MII Status Register */ -#define MII_STATUS_REG 1 -#define MII_STATUS_LINK_MASK 0x4 - -#define MDIO_CONTROL_IDLE 0x80000000 -#define MDIO_CONTROL_ENABLE 0x40000000 -#define MDIO_CONTROL_FAULT_ENABLE 0x40000 -#define MDIO_CONTROL_FAULT 0x80000 -#define MDIO_USERACCESS0_GO 0x80000000 -#define MDIO_USERACCESS0_WRITE_READ 0x0 -#define MDIO_USERACCESS0_WRITE_WRITE 0x40000000 -#define MDIO_USERACCESS0_ACK 0x20000000 -#define EMAC_MACCONTROL_MIIEN_ENABLE 0x20#define EMAC_MACCONTROL_FULLDUPLEX_ENABLE 0x1#define EMAC_MACCONTROL_GIGABIT_ENABLE BIT(7)
drivers/net/ti/Makefile +1 -1
@@ -4,4 +4,4 @@ obj-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o cpsw-common.o cpsw_mdio.o obj-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o -obj-$(CONFIG_DRIVER_TI_KEYSTONE_NET) += keystone_net.o +obj-$(CONFIG_DRIVER_TI_KEYSTONE_NET) += keystone_net.o cpsw_mdio.o
drivers/net/ti/keystone_net.c +17 -101
187 lines not on this page · raw message
Signature · 1 line
2.10.5
[U-Boot] driver: net: ti: keystone_net: switch to use common mdio lib
Hi Grygorii,
https://patchwork.ozlabs.org/patch/991709/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe