driver: net: ti: clean up and code optimization
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
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 | 205 +++++++++++++
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, 288 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 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
PATCH 1/7 driver: net: consolidate ti's code in separate folder
Quoted 4 lines · Grygorii Strashko
Add
drivers/net/ti/folder and move all TI's code in this folder for better maintenance.Signed-off-by Grygorii Strashko <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181026/06397a88/attachment.sig>
PATCH 1/7 driver: net: consolidate ti's code in separate folder
In reply to Grygorii StrashkoQuoted 5 lines · Grygorii Strashko
Add
drivers/net/ti/folder and move all TI's code in this folder for better maintenance.Signed-off-by Grygorii Strashko <[email protected]>
PATCH 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 2/7 configs: net: convert DRIVER_TI_KEYSTONE_NET kconfig
Quoted 3 lines · Grygorii Strashko
Convert
DRIVER_TI_KEYSTONE_NETtoKconfig.Signed-off-by Grygorii Strashko <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181026/311a46f4/attachment.sig>
PATCH 2/7 configs: net: convert DRIVER_TI_KEYSTONE_NET kconfig
In reply to Grygorii StrashkoQuoted 4 lines · Grygorii Strashko
Convert
DRIVER_TI_KEYSTONE_NETtoKconfig.Signed-off-by Grygorii Strashko <[email protected]>
PATCH 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
PATCH 3/7 drivers: net: keystone_net: drop non dm code
Quoted 5 lines · Grygorii Strashko
Networking support for all TI K2 boards converted to use DM model and
CONFIG_DM_ETHenabled in all corresponding defconfig files, hence drop unused non DM K2 networking code.Signed-off-by Grygorii Strashko <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181026/4beb00f8/attachment.sig>
PATCH 3/7 drivers: net: keystone_net: drop non dm code
In reply to Grygorii StrashkoQuoted 6 lines · Grygorii Strashko
Networking support for all TI K2 boards converted to use DM model and
CONFIG_DM_ETHenabled in all corresponding defconfig files, hence drop unused non DM K2 networking code.Signed-off-by Grygorii Strashko <[email protected]>
PATCH 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
PATCH 4/7 driver: net: ti: cpsw: update to use SPDX identifier
Quoted 3 lines · Grygorii Strashko
Update to use SPDX license identifier.
Signed-off-by Grygorii Strashko <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181026/1f2693fa/attachment.sig>
PATCH 4/7 driver: net: ti: cpsw: update to use SPDX identifier
In reply to Grygorii StrashkoQuoted 4 lines · Grygorii Strashko
Update to use SPDX license identifier.
Signed-off-by Grygorii Strashko <[email protected]>
PATCH 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 | 205 +++++++++++++++++++++++++++++++++++++++++++++ drivers/net/ti/cpsw_mdio.h | 18 ++++ 3 files changed, 224 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 +205 -0
205 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 5/7 driver: net: ti: introduce common mdio support library
Quoted 5 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.
Signed-off-by Grygorii Strashko <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181026/7aa4186a/attachment.sig>
PATCH 5/7 driver: net: ti: introduce common mdio support library
In reply to Grygorii StrashkoQuoted 4 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.
Quoted 9 lines
Signed-off-by Grygorii Strashko <[email protected]>--- drivers/net/ti/Makefile | 2 +- drivers/net/ti/cpsw_mdio.c | 205 +++++++++++++++++++++++++++++++++++++++++++++ drivers/net/ti/cpsw_mdio.h | 18 ++++ 3 files changed, 224 insertions(+), 1 deletion(-)create mode 100644
drivers/net/ti/cpsw_mdio.c
create mode 100644drivers/net/ti/cpsw_mdio.h
Hi,
why we don't combine this with:
http://patchwork.ozlabs.org/patch/939726/ ? looks much more elegant to me.
cheers,
Hannes
PATCH 5/7 driver: net: ti: introduce common mdio support library
Quoted 16 lines · Hannes Schmelzer
Quoted 4 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.
Quoted 9 lines
Signed-off-by Grygorii Strashko <[email protected]>--- drivers/net/ti/Makefile | 2 +- drivers/net/ti/cpsw_mdio.c | 205 +++++++++++++++++++++++++++++++++++++++++++++ drivers/net/ti/cpsw_mdio.h | 18 ++++ 3 files changed, 224 insertions(+), 1 deletion(-)create mode 100644
drivers/net/ti/cpsw_mdio.c
create mode 100644drivers/net/ti/cpsw_mdio.h
Quoted 3 lines
Hi,
why we don't combine this with:
http://patchwork.ozlabs.org/patch/939726/ ? looks much more elegant to me.
I agree we should be moving that direction, but consolidating TI MDIO implementation is fairly orthogonal. Also haven't heard back from Ken on feedback to that patch.
Quoted 7 lines
cheers,
Hannes_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 5/7 driver: net: ti: introduce common mdio support library
Quoted 17 lines · Joe Hershberger
Quoted 16 lines · Hannes Schmelzer
Quoted 13 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.
Signed-off-by Grygorii Strashko <[email protected]>--- drivers/net/ti/Makefile | 2 +- drivers/net/ti/cpsw_mdio.c | 205 +++++++++++++++++++++++++++++++++++++++++++++ drivers/net/ti/cpsw_mdio.h | 18 ++++ 3 files changed, 224 insertions(+), 1 deletion(-)create mode 100644
drivers/net/ti/cpsw_mdio.c
create mode 100644drivers/net/ti/cpsw_mdio.h
Quoted 7 lines
Quoted 3 lines
Hi,
why we don't combine this with:
http://patchwork.ozlabs.org/patch/939726/ ? looks much more elegant to me.I agree we should be moving that direction, but consolidating TI MDIO implementation is fairly orthogonal. Also haven't heard back from Ken on feedback to that patch.
The mdio here is not modeled as device/driver and I, honestly, see no reasons for this at least now.
Signature · 2 lines
regards, -grygorii
PATCH 5/7 driver: net: ti: introduce common mdio support library
In reply to Grygorii StrashkoQuoted 92 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.
Signed-off-by Grygorii Strashko <[email protected]>--- drivers/net/ti/Makefile | 2 +- drivers/net/ti/cpsw_mdio.c | 205 +++++++++++++++++++++++++++++++++++++++++++++ drivers/net/ti/cpsw_mdio.h | 18 ++++ 3 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ti/cpsw_mdio.c create mode 100644 drivers/net/ti/cpsw_mdio.hdrivers/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.odrivers/net/ti/cpsw_mdio.c new file +60
-0@@ -0,0 +1,205 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* CPSW MDIO generic driver for TI AMxx/K2x/EMAC devices. +* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +*/ + +#include <common.h> +#include <asm/io.h> +#include <miiphy.h> + +struct cpsw_mdio_regs { +u32 version; +u32 control; +#define CONTROL_IDLE BIT(31) +#define CONTROL_ENABLE BIT(30) +#define CONTROL_FAULT BIT(19) +#define CONTROL_FAULT_ENABLE BIT(18) +#define CONTROL_DIV_MASK GENMASK(15, 0) + +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_PHY_REG_SHIFT (21) +#define USERACCESS_PHY_ADDR_SHIFT (16) +#define USERACCESS_DATA GENMASK(15, 0) + } user[0 ]; +}; + +#define CPSW_MDIO_DIV_DEF 0xff +#define PHY_REG_MASK 0x1f +#define PHY_ID_MASK 0x1f + +/* +* This timeout definition is a worst-case ultra defensive measure against +* unexpected controller lock ups. Ideally, we should never ever hit this +* scenario in practice. +*/ +#define CPSW_MDIO_TIMEOUT 100/* msecs */ + +struct cpsw_mdio { +struct cpsw_mdio_regs *regs; +struct mii_dev *bus; +int div; +};
drivers/net/ti/cpsw_mdio.c line 70
Quoted 10 lines
drivers/net/ti/cpsw_mdio.c new file +10
-0+ +/* wait until hardware is ready for another user access */ +static inline u32 cpsw_mdio_wait_for_user_access (struct cpsw_mdio *mdio) +{ +u32 reg =0 ; +int timeout =CPSW_MDIO_TIMEOUT ; + +while (timeout-- && ((reg =readl (&mdio->regs->user[0 ].access)) + &USERACCESS_GO )) +udelay (10 );
Seems we should be using wait_for_bit instead of this function.
Quoted 91 lines
drivers/net/ti/cpsw_mdio.c new file +91
-0+ +if (timeout ==-1 ) { +printf ("wait_for_user_access Timeout\n" ); +return -ETIMEDOUT ; + } + +return reg; +} + +static int cpsw_mdio_read (struct mii_dev *bus,int phy_id, +int dev_addr,int phy_reg) +{ +struct cpsw_mdio *mdio = bus->priv; +int data; +u32 reg; + +if (phy_reg & ~PHY_REG_MASK || phy_id & ~PHY_ID_MASK ) +return -EINVAL ; + +cpsw_mdio_wait_for_user_access (mdio); + reg = (USERACCESS_GO |USERACCESS_READ | + (phy_reg <<USERACCESS_PHY_REG_SHIFT ) | + (phy_id <<USERACCESS_PHY_ADDR_SHIFT )); +writel (reg, &mdio->regs->user[0 ].access); + reg =cpsw_mdio_wait_for_user_access (mdio); + + 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) +{ +struct cpsw_mdio *mdio = bus->priv; +u32 reg; + +if (phy_reg & ~PHY_REG_MASK || phy_id & ~PHY_ID_MASK ) +return -EINVAL ; + +cpsw_mdio_wait_for_user_access (mdio); + reg = (USERACCESS_GO |USERACCESS_WRITE | + (phy_reg <<USERACCESS_PHY_REG_SHIFT ) | + (phy_id <<USERACCESS_PHY_ADDR_SHIFT ) | + (data &USERACCESS_DATA )); +writel (reg, &mdio->regs->user[0 ].access); +cpsw_mdio_wait_for_user_access (mdio); + +return 0 ; +} + +u32 cpsw_mdio_get_alive (struct mii_dev *bus) +{ +struct cpsw_mdio *mdio = bus->priv; +u32 val; + + val =readl (&mdio->regs->control); +return val &GENMASK (15 ,0 ); +} + +struct mii_dev *cpsw_mdio_init (const char *name,u32 mdio_base, +u32 bus_freq,int fck_freq) +{ +struct cpsw_mdio *cpsw_mdio; +int ret; + + cpsw_mdio =calloc (1 ,sizeof (*cpsw_mdio)); +if (!cpsw_mdio) { +debug ("failed to alloc cpsw_mdio\n" ); +return NULL ; + } + + cpsw_mdio->bus =mdio_alloc (); +if (!cpsw_mdio->bus) { +debug ("failed to alloc mii bus\n" ); +free (cpsw_mdio); +return NULL ; + } + + cpsw_mdio->regs = (struct cpsw_mdio_regs *)mdio_base; + +if (!bus_freq || !fck_freq) + cpsw_mdio->div =CPSW_MDIO_DIV_DEF ; +else + cpsw_mdio->div = (fck_freq / bus_freq) -1 ; + cpsw_mdio->div &=CONTROL_DIV_MASK ; + +/* set enable and clock divider */ +writel (cpsw_mdio->div |CONTROL_ENABLE |CONTROL_FAULT | +CONTROL_FAULT_ENABLE , &cpsw_mdio->regs->control); +while (readl (&cpsw_mdio->regs->control) &CONTROL_IDLE ) + ;
drivers/net/ti/cpsw_mdio.c line 171
Quoted 10 lines
drivers/net/ti/cpsw_mdio.c new file +10
-0+ +/* +* 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 );
mdelay(1);
drivers/net/ti/cpsw_mdio.c line 176
Quoted 5 lines
drivers/net/ti/cpsw_mdio.c new file +5
-0+ + cpsw_mdio->bus->read = cpsw_mdio_read; + cpsw_mdio->bus->write = cpsw_mdio_write; + cpsw_mdio->bus->priv = cpsw_mdio; +strcpy (cpsw_mdio->bus->name, name);
snprintf(cpsw_mdio->bus->name, sizeof(cpsw_mdio->bus->name), name);
drivers/net/ti/cpsw_mdio.c line 187
Quoted 11 lines
drivers/net/ti/cpsw_mdio.c new file +11
-0+ + ret =mdio_register (cpsw_mdio->bus); +if (ret <0 ) { +debug ("failed to register mii bus\n" ); + goto free_bus; + } + +return cpsw_mdio->bus; + +free_bus: +free (cpsw_mdio->bus);
mdio_free(cpsw_mdio->bus);
Quoted 49 lines
drivers/net/ti/cpsw_mdio.c new file +18
-0+free (cpsw_mdio); +return NULL ; +} + +void cpsw_mdio_free (struct mii_dev *bus) +{ +struct cpsw_mdio *mdio = bus->priv; +u32 reg; + +/* disable mdio */ + reg =readl (&mdio->regs->control); + reg &= ~CONTROL_ENABLE ; +writel (reg, &mdio->regs->control); + +mdio_unregister (bus); +mdio_free (bus); +free (mdio); +}drivers/net/ti/cpsw_mdio.h new file +18
-1@@ -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_ */ --2.10.5
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 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
PATCH 6/7 driver: net: ti: cpsw: switch to use common mdio lib
Quoted 3 lines · Grygorii Strashko
Update TI CPSW driver to re-use common mdio lib
Signed-off-by Grygorii Strashko <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181026/cd987b88/attachment.sig>
PATCH 6/7 driver: net: ti: cpsw: switch to use common mdio lib
In reply to Grygorii StrashkoQuoted 4 lines · Grygorii Strashko
Update TI CPSW driver to re-use common mdio lib
Signed-off-by Grygorii Strashko <[email protected]>
PATCH 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
PATCH 7/7 driver: net: ti: keystone_net: switch to use common mdio lib
Quoted 3 lines · Grygorii Strashko
Update TI Keystone 2 driver to re-use common mdio lib.
Signed-off-by Grygorii Strashko <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181026/f99ec8ec/attachment.sig>
PATCH 7/7 driver: net: ti: keystone_net: switch to use common mdio lib
In reply to Grygorii StrashkoQuoted 4 lines · Grygorii Strashko
Update TI Keystone 2 driver to re-use common mdio lib.
Signed-off-by Grygorii Strashko <[email protected]>