mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
net: ethernet: stmmac: Add STMMAC_PTP config option
Add this config option to reduce memory usage, if it was not necessary. ./ksize.sh drivers/net/ethernet/stmicro/ before size: 70125 Bytes after size: 65984 Bytes save size: 4141 Bytes Signed-off-by: David Wu <david.wu@rock-chips.com> Change-Id: I82c404a41a7abde6adf38557d8b2096b17b4b6e5
This commit is contained in:
@@ -38,6 +38,12 @@ config STMMAC_FULL
|
|||||||
This selects the full function, default is Y, full-featured version
|
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.
|
includes 4.10 and other versions, if it is N, only 4.10 core working.
|
||||||
|
|
||||||
|
config STMMAC_PTP
|
||||||
|
bool "PTP feature for STMMAC"
|
||||||
|
default STMMAC_ETH
|
||||||
|
help
|
||||||
|
This selects the ptp timestamp function, default is Y.
|
||||||
|
|
||||||
config STMMAC_PLATFORM
|
config STMMAC_PLATFORM
|
||||||
tristate "STMMAC Platform bus support"
|
tristate "STMMAC Platform bus support"
|
||||||
depends on STMMAC_ETH
|
depends on STMMAC_ETH
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
obj-$(CONFIG_STMMAC_ETH) += stmmac.o
|
obj-$(CONFIG_STMMAC_ETH) += stmmac.o
|
||||||
|
|
||||||
stmmac-objs:= stmmac_main.o stmmac_mdio.o dwmac_lib.o \
|
stmmac-objs:= stmmac_main.o stmmac_mdio.o dwmac_lib.o \
|
||||||
mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o \
|
mmc_core.o dwmac4_descs.o dwmac4_dma.o \
|
||||||
dwmac4_descs.o dwmac4_dma.o \
|
|
||||||
dwmac4_lib.o dwmac4_core.o hwif.o \
|
dwmac4_lib.o dwmac4_core.o hwif.o \
|
||||||
$(stmmac-y)
|
$(stmmac-y)
|
||||||
|
|
||||||
@@ -15,6 +14,8 @@ stmmac-$(CONFIG_STMMAC_FULL) += ring_mode.o chain_mode.o dwmac1000_core.o \
|
|||||||
stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o
|
stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o
|
||||||
stmmac-$(CONFIG_STMMAC_ETHTOOL) += stmmac_ethtool.o
|
stmmac-$(CONFIG_STMMAC_ETHTOOL) += stmmac_ethtool.o
|
||||||
|
|
||||||
|
stmmac-$(CONFIG_STMMAC_PTP) += stmmac_hwtstamp.o stmmac_ptp.o
|
||||||
|
|
||||||
# Ordering matters. Generic driver must be last.
|
# Ordering matters. Generic driver must be last.
|
||||||
obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o
|
obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o
|
||||||
obj-$(CONFIG_DWMAC_ANARION) += dwmac-anarion.o
|
obj-$(CONFIG_DWMAC_ANARION) += dwmac-anarion.o
|
||||||
|
|||||||
@@ -99,7 +99,9 @@ static const struct stmmac_hwif_entry {
|
|||||||
const void *desc;
|
const void *desc;
|
||||||
const void *dma;
|
const void *dma;
|
||||||
const void *mac;
|
const void *mac;
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
const void *hwtimestamp;
|
const void *hwtimestamp;
|
||||||
|
#endif
|
||||||
const void *mode;
|
const void *mode;
|
||||||
const void *tc;
|
const void *tc;
|
||||||
const void *mmc;
|
const void *mmc;
|
||||||
@@ -120,7 +122,9 @@ static const struct stmmac_hwif_entry {
|
|||||||
.desc = NULL,
|
.desc = NULL,
|
||||||
.dma = &dwmac100_dma_ops,
|
.dma = &dwmac100_dma_ops,
|
||||||
.mac = &dwmac100_ops,
|
.mac = &dwmac100_ops,
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
.hwtimestamp = &stmmac_ptp,
|
.hwtimestamp = &stmmac_ptp,
|
||||||
|
#endif
|
||||||
.mode = NULL,
|
.mode = NULL,
|
||||||
.tc = NULL,
|
.tc = NULL,
|
||||||
.mmc = &dwmac_mmc_ops,
|
.mmc = &dwmac_mmc_ops,
|
||||||
@@ -138,7 +142,9 @@ static const struct stmmac_hwif_entry {
|
|||||||
.desc = NULL,
|
.desc = NULL,
|
||||||
.dma = &dwmac1000_dma_ops,
|
.dma = &dwmac1000_dma_ops,
|
||||||
.mac = &dwmac1000_ops,
|
.mac = &dwmac1000_ops,
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
.hwtimestamp = &stmmac_ptp,
|
.hwtimestamp = &stmmac_ptp,
|
||||||
|
#endif
|
||||||
.mode = NULL,
|
.mode = NULL,
|
||||||
.tc = NULL,
|
.tc = NULL,
|
||||||
.mmc = &dwmac_mmc_ops,
|
.mmc = &dwmac_mmc_ops,
|
||||||
@@ -156,7 +162,9 @@ static const struct stmmac_hwif_entry {
|
|||||||
.desc = &dwmac4_desc_ops,
|
.desc = &dwmac4_desc_ops,
|
||||||
.dma = &dwmac4_dma_ops,
|
.dma = &dwmac4_dma_ops,
|
||||||
.mac = &dwmac4_ops,
|
.mac = &dwmac4_ops,
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
.hwtimestamp = &stmmac_ptp,
|
.hwtimestamp = &stmmac_ptp,
|
||||||
|
#endif
|
||||||
.mode = NULL,
|
.mode = NULL,
|
||||||
.tc = &dwmac510_tc_ops,
|
.tc = &dwmac510_tc_ops,
|
||||||
.mmc = &dwmac_mmc_ops,
|
.mmc = &dwmac_mmc_ops,
|
||||||
@@ -174,7 +182,9 @@ static const struct stmmac_hwif_entry {
|
|||||||
.desc = &dwmac4_desc_ops,
|
.desc = &dwmac4_desc_ops,
|
||||||
.dma = &dwmac4_dma_ops,
|
.dma = &dwmac4_dma_ops,
|
||||||
.mac = &dwmac410_ops,
|
.mac = &dwmac410_ops,
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
.hwtimestamp = &stmmac_ptp,
|
.hwtimestamp = &stmmac_ptp,
|
||||||
|
#endif
|
||||||
.mode = &dwmac4_ring_mode_ops,
|
.mode = &dwmac4_ring_mode_ops,
|
||||||
.tc = &dwmac510_tc_ops,
|
.tc = &dwmac510_tc_ops,
|
||||||
.mmc = &dwmac_mmc_ops,
|
.mmc = &dwmac_mmc_ops,
|
||||||
@@ -194,7 +204,9 @@ static const struct stmmac_hwif_entry {
|
|||||||
.desc = &dwmac4_desc_ops,
|
.desc = &dwmac4_desc_ops,
|
||||||
.dma = &dwmac410_dma_ops,
|
.dma = &dwmac410_dma_ops,
|
||||||
.mac = &dwmac410_ops,
|
.mac = &dwmac410_ops,
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
.hwtimestamp = &stmmac_ptp,
|
.hwtimestamp = &stmmac_ptp,
|
||||||
|
#endif
|
||||||
.mode = &dwmac4_ring_mode_ops,
|
.mode = &dwmac4_ring_mode_ops,
|
||||||
#ifdef CONFIG_STMMAC_FULL
|
#ifdef CONFIG_STMMAC_FULL
|
||||||
.tc = &dwmac510_tc_ops,
|
.tc = &dwmac510_tc_ops,
|
||||||
@@ -216,7 +228,9 @@ static const struct stmmac_hwif_entry {
|
|||||||
.desc = &dwmac4_desc_ops,
|
.desc = &dwmac4_desc_ops,
|
||||||
.dma = &dwmac410_dma_ops,
|
.dma = &dwmac410_dma_ops,
|
||||||
.mac = &dwmac510_ops,
|
.mac = &dwmac510_ops,
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
.hwtimestamp = &stmmac_ptp,
|
.hwtimestamp = &stmmac_ptp,
|
||||||
|
#endif
|
||||||
.mode = &dwmac4_ring_mode_ops,
|
.mode = &dwmac4_ring_mode_ops,
|
||||||
.tc = &dwmac510_tc_ops,
|
.tc = &dwmac510_tc_ops,
|
||||||
.mmc = &dwmac_mmc_ops,
|
.mmc = &dwmac_mmc_ops,
|
||||||
@@ -235,7 +249,9 @@ static const struct stmmac_hwif_entry {
|
|||||||
.desc = &dwxgmac210_desc_ops,
|
.desc = &dwxgmac210_desc_ops,
|
||||||
.dma = &dwxgmac210_dma_ops,
|
.dma = &dwxgmac210_dma_ops,
|
||||||
.mac = &dwxgmac210_ops,
|
.mac = &dwxgmac210_ops,
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
.hwtimestamp = &stmmac_ptp,
|
.hwtimestamp = &stmmac_ptp,
|
||||||
|
#endif
|
||||||
.mode = NULL,
|
.mode = NULL,
|
||||||
.tc = &dwmac510_tc_ops,
|
.tc = &dwmac510_tc_ops,
|
||||||
.mmc = &dwxgmac_mmc_ops,
|
.mmc = &dwxgmac_mmc_ops,
|
||||||
@@ -254,7 +270,9 @@ static const struct stmmac_hwif_entry {
|
|||||||
.desc = &dwxgmac210_desc_ops,
|
.desc = &dwxgmac210_desc_ops,
|
||||||
.dma = &dwxgmac210_dma_ops,
|
.dma = &dwxgmac210_dma_ops,
|
||||||
.mac = &dwxlgmac2_ops,
|
.mac = &dwxlgmac2_ops,
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
.hwtimestamp = &stmmac_ptp,
|
.hwtimestamp = &stmmac_ptp,
|
||||||
|
#endif
|
||||||
.mode = NULL,
|
.mode = NULL,
|
||||||
.tc = &dwmac510_tc_ops,
|
.tc = &dwmac510_tc_ops,
|
||||||
.mmc = &dwxgmac_mmc_ops,
|
.mmc = &dwxgmac_mmc_ops,
|
||||||
@@ -325,7 +343,9 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
|
|||||||
mac->desc = mac->desc ? : entry->desc;
|
mac->desc = mac->desc ? : entry->desc;
|
||||||
mac->dma = mac->dma ? : entry->dma;
|
mac->dma = mac->dma ? : entry->dma;
|
||||||
mac->mac = mac->mac ? : entry->mac;
|
mac->mac = mac->mac ? : entry->mac;
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
mac->ptp = mac->ptp ? : entry->hwtimestamp;
|
mac->ptp = mac->ptp ? : entry->hwtimestamp;
|
||||||
|
#endif
|
||||||
mac->mode = mac->mode ? : entry->mode;
|
mac->mode = mac->mode ? : entry->mode;
|
||||||
mac->tc = mac->tc ? : entry->tc;
|
mac->tc = mac->tc ? : entry->tc;
|
||||||
mac->mmc = mac->mmc ? : entry->mmc;
|
mac->mmc = mac->mmc ? : entry->mmc;
|
||||||
|
|||||||
@@ -265,8 +265,18 @@ static inline void stmmac_set_ethtool_ops(struct net_device *netdev)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
void stmmac_ptp_register(struct stmmac_priv *priv);
|
void stmmac_ptp_register(struct stmmac_priv *priv);
|
||||||
void stmmac_ptp_unregister(struct stmmac_priv *priv);
|
void stmmac_ptp_unregister(struct stmmac_priv *priv);
|
||||||
|
#else
|
||||||
|
static inline void stmmac_ptp_register(struct stmmac_priv *priv)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void stmmac_ptp_unregister(struct stmmac_priv *priv)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
int stmmac_resume(struct device *dev);
|
int stmmac_resume(struct device *dev);
|
||||||
int stmmac_suspend(struct device *dev);
|
int stmmac_suspend(struct device *dev);
|
||||||
int stmmac_dvr_remove(struct device *dev);
|
int stmmac_dvr_remove(struct device *dev);
|
||||||
|
|||||||
@@ -470,6 +470,7 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
/**
|
/**
|
||||||
* stmmac_hwtstamp_set - control hardware timestamping.
|
* stmmac_hwtstamp_set - control hardware timestamping.
|
||||||
* @dev: device pointer.
|
* @dev: device pointer.
|
||||||
@@ -723,6 +724,7 @@ static int stmmac_hwtstamp_get(struct net_device *dev, struct ifreq *ifr)
|
|||||||
return copy_to_user(ifr->ifr_data, config,
|
return copy_to_user(ifr->ifr_data, config,
|
||||||
sizeof(*config)) ? -EFAULT : 0;
|
sizeof(*config)) ? -EFAULT : 0;
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_STMMAC_PTP */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* stmmac_init_ptp - init PTP
|
* stmmac_init_ptp - init PTP
|
||||||
@@ -763,7 +765,8 @@ static int stmmac_init_ptp(struct stmmac_priv *priv)
|
|||||||
|
|
||||||
static void stmmac_release_ptp(struct stmmac_priv *priv)
|
static void stmmac_release_ptp(struct stmmac_priv *priv)
|
||||||
{
|
{
|
||||||
clk_disable_unprepare(priv->plat->clk_ptp_ref);
|
if (IS_ENABLED(CONFIG_STMMAC_PTP))
|
||||||
|
clk_disable_unprepare(priv->plat->clk_ptp_ref);
|
||||||
stmmac_ptp_unregister(priv);
|
stmmac_ptp_unregister(priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2704,7 +2707,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
|
|||||||
|
|
||||||
stmmac_mmc_setup(priv);
|
stmmac_mmc_setup(priv);
|
||||||
|
|
||||||
if (init_ptp) {
|
if (IS_ENABLED(CONFIG_STMMAC_PTP) && init_ptp) {
|
||||||
ret = clk_prepare_enable(priv->plat->clk_ptp_ref);
|
ret = clk_prepare_enable(priv->plat->clk_ptp_ref);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
netdev_warn(priv->dev, "failed to enable PTP reference clock: %d\n", ret);
|
netdev_warn(priv->dev, "failed to enable PTP reference clock: %d\n", ret);
|
||||||
@@ -2780,7 +2783,8 @@ static void stmmac_hw_teardown(struct net_device *dev)
|
|||||||
{
|
{
|
||||||
struct stmmac_priv *priv = netdev_priv(dev);
|
struct stmmac_priv *priv = netdev_priv(dev);
|
||||||
|
|
||||||
clk_disable_unprepare(priv->plat->clk_ptp_ref);
|
if (IS_ENABLED(CONFIG_STMMAC_PTP))
|
||||||
|
clk_disable_unprepare(priv->plat->clk_ptp_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2970,7 +2974,8 @@ static int stmmac_release(struct net_device *dev)
|
|||||||
|
|
||||||
netif_carrier_off(dev);
|
netif_carrier_off(dev);
|
||||||
|
|
||||||
stmmac_release_ptp(priv);
|
if (IS_ENABLED(CONFIG_STMMAC_PTP))
|
||||||
|
stmmac_release_ptp(priv);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -4216,12 +4221,14 @@ static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
|
|||||||
case SIOCSMIIREG:
|
case SIOCSMIIREG:
|
||||||
ret = phylink_mii_ioctl(priv->phylink, rq, cmd);
|
ret = phylink_mii_ioctl(priv->phylink, rq, cmd);
|
||||||
break;
|
break;
|
||||||
|
#ifdef CONFIG_STMMAC_PTP
|
||||||
case SIOCSHWTSTAMP:
|
case SIOCSHWTSTAMP:
|
||||||
ret = stmmac_hwtstamp_set(dev, rq);
|
ret = stmmac_hwtstamp_set(dev, rq);
|
||||||
break;
|
break;
|
||||||
case SIOCGHWTSTAMP:
|
case SIOCGHWTSTAMP:
|
||||||
ret = stmmac_hwtstamp_get(dev, rq);
|
ret = stmmac_hwtstamp_get(dev, rq);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -5229,7 +5236,8 @@ int stmmac_suspend(struct device *dev)
|
|||||||
stmmac_mac_set(priv, priv->ioaddr, false);
|
stmmac_mac_set(priv, priv->ioaddr, false);
|
||||||
pinctrl_pm_select_sleep_state(priv->device);
|
pinctrl_pm_select_sleep_state(priv->device);
|
||||||
/* Disable clock in case of PWM is off */
|
/* Disable clock in case of PWM is off */
|
||||||
clk_disable_unprepare(priv->plat->clk_ptp_ref);
|
if (IS_ENABLED(CONFIG_STMMAC_PTP))
|
||||||
|
clk_disable_unprepare(priv->plat->clk_ptp_ref);
|
||||||
clk_disable_unprepare(priv->plat->pclk);
|
clk_disable_unprepare(priv->plat->pclk);
|
||||||
clk_disable_unprepare(priv->plat->stmmac_clk);
|
clk_disable_unprepare(priv->plat->stmmac_clk);
|
||||||
}
|
}
|
||||||
@@ -5299,7 +5307,7 @@ int stmmac_resume(struct device *dev)
|
|||||||
/* enable the clk previously disabled */
|
/* enable the clk previously disabled */
|
||||||
clk_prepare_enable(priv->plat->stmmac_clk);
|
clk_prepare_enable(priv->plat->stmmac_clk);
|
||||||
clk_prepare_enable(priv->plat->pclk);
|
clk_prepare_enable(priv->plat->pclk);
|
||||||
if (priv->plat->clk_ptp_ref)
|
if (IS_ENABLED(CONFIG_STMMAC_PTP) && priv->plat->clk_ptp_ref)
|
||||||
clk_prepare_enable(priv->plat->clk_ptp_ref);
|
clk_prepare_enable(priv->plat->clk_ptp_ref);
|
||||||
/* reset the phy so that it's ready */
|
/* reset the phy so that it's ready */
|
||||||
if (priv->mii)
|
if (priv->mii)
|
||||||
|
|||||||
Reference in New Issue
Block a user