From 56f6b33ef06ae7ccd39a31d71fab65df0c5b338f Mon Sep 17 00:00:00 2001 From: David Wu Date: Sat, 18 Sep 2021 16:39:41 +0800 Subject: [PATCH] net: ethernet: stmmac: Add config option for full driver Add this config option to reduce memory usage, if it was not necessary. ./ksize.sh drivers/net/ethernet/stmicro/ before size: 82879 Bytes after size: 59075 Bytes save size: 23804 Bytes Change-Id: I5f6b4573d7358c3b6f046e960c7ddf7d53541b14 Signed-off-by: David Wu --- drivers/net/ethernet/stmicro/stmmac/Kconfig | 7 +++++++ drivers/net/ethernet/stmicro/stmmac/Makefile | 16 ++++++++++------ .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 4 ++++ drivers/net/ethernet/stmicro/stmmac/hwif.c | 12 ++++++++++-- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index cd6159297c0b..804102cc4366 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig @@ -18,6 +18,13 @@ config STMMAC_ETHTOOL help This selects the ethtool function, default is Y. +config STMMAC_FULL + bool "Support full driver for STMMAC" + default STMMAC_ETH + help + This selects the full function, default is Y, full-featured version + includes 4.10 and other versions, if it is N, only 4.10 core working. + config STMMAC_PLATFORM tristate "STMMAC Platform bus support" depends on STMMAC_ETH diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile index 35e5093a367d..a1592b940456 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Makefile +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile @@ -1,13 +1,17 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_STMMAC_ETH) += stmmac.o -stmmac-objs:= stmmac_main.o stmmac_mdio.o ring_mode.o \ - chain_mode.o dwmac_lib.o dwmac1000_core.o dwmac1000_dma.o \ - dwmac100_core.o dwmac100_dma.o enh_desc.o norm_desc.o \ - mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o dwmac4_descs.o \ - dwmac4_dma.o dwmac4_lib.o dwmac4_core.o dwmac5.o hwif.o \ - stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o \ + +stmmac-objs:= stmmac_main.o stmmac_mdio.o dwmac_lib.o \ + mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o \ + dwmac4_descs.o dwmac4_dma.o \ + dwmac4_lib.o dwmac4_core.o hwif.o \ $(stmmac-y) +stmmac-$(CONFIG_STMMAC_FULL) += ring_mode.o chain_mode.o dwmac1000_core.o \ + dwmac1000_dma.o dwmac100_core.o dwmac100_dma.o \ + enh_desc.o norm_desc.o dwmac5.o stmmac_tc.o \ + dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o + stmmac-$(CONFIG_STMMAC_ETHTOOL) += stmmac_ethtool.o # Ordering matters. Generic driver must be last. diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index bc8871e7351f..da5d9e5d08c2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -715,6 +715,7 @@ static void dwmac4_debug(void __iomem *ioaddr, struct stmmac_extra_stats *x, x->mac_gmii_rx_proto_engine++; } +#ifdef CONFIG_STMMAC_FULL const struct stmmac_ops dwmac4_ops = { .core_init = dwmac4_core_init, .set_mac = stmmac_set_mac, @@ -745,6 +746,7 @@ const struct stmmac_ops dwmac4_ops = { .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, }; +#endif const struct stmmac_ops dwmac410_ops = { .core_init = dwmac4_core_init, @@ -777,6 +779,7 @@ const struct stmmac_ops dwmac410_ops = { .set_filter = dwmac4_set_filter, }; +#ifdef CONFIG_STMMAC_FULL const struct stmmac_ops dwmac510_ops = { .core_init = dwmac4_core_init, .set_mac = stmmac_dwmac4_set_mac, @@ -812,6 +815,7 @@ const struct stmmac_ops dwmac510_ops = { .rxp_config = dwmac5_rxp_config, .flex_pps_config = dwmac5_flex_pps_config, }; +#endif int dwmac4_setup(struct stmmac_priv *priv) { diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c index 357309a6d6a5..cbc4824df399 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -23,6 +23,7 @@ static u32 stmmac_get_id(struct stmmac_priv *priv, u32 id_reg) return reg & GENMASK(7, 0); } +#ifdef CONFIG_STMMAC_FULL static void stmmac_dwmac_mode_quirk(struct stmmac_priv *priv) { struct mac_device_info *mac = priv->hw; @@ -68,6 +69,7 @@ static int stmmac_dwmac4_quirks(struct stmmac_priv *priv) stmmac_dwmac_mode_quirk(priv); return 0; } +#endif static const struct stmmac_hwif_entry { bool gmac; @@ -85,6 +87,7 @@ static const struct stmmac_hwif_entry { int (*quirks)(struct stmmac_priv *priv); } stmmac_hw[] = { /* NOTE: New HW versions shall go to the end of this table */ +#ifdef CONFIG_STMMAC_FULL { .gmac = false, .gmac4 = false, @@ -153,7 +156,9 @@ static const struct stmmac_hwif_entry { .tc = NULL, .setup = dwmac4_setup, .quirks = NULL, - }, { + }, +#endif /* CONFIG_STMMAC_FULL */ + { .gmac = false, .gmac4 = true, .xgmac = false, @@ -170,7 +175,9 @@ static const struct stmmac_hwif_entry { .tc = NULL, .setup = dwmac4_setup, .quirks = NULL, - }, { + }, +#ifdef CONFIG_STMMAC_FULL + { .gmac = false, .gmac4 = true, .xgmac = false, @@ -205,6 +212,7 @@ static const struct stmmac_hwif_entry { .setup = dwxgmac2_setup, .quirks = NULL, }, +#endif }; int stmmac_hwif_init(struct stmmac_priv *priv)