net: stmmac: Make code changes to support dlkm compilation

Replace ethqos function calls with function pointer in stmmac.
Makefile changes to compile all ethqos files as single ko.

Change-Id: Iae8fb981b59cf14e33d31530a8798cc56c0e9926
Signed-off-by: Sneh Shah <snehshah@codeaurora.org>
This commit is contained in:
Sneh Shah 2021-04-28 11:49:30 +05:30
commit bbaefbdf62
8 changed files with 65 additions and 43 deletions

View file

@ -18,9 +18,8 @@ obj-$(CONFIG_DWMAC_LPC18XX) += dwmac-lpc18xx.o
obj-$(CONFIG_DWMAC_MEDIATEK) += dwmac-mediatek.o
obj-$(CONFIG_DWMAC_MESON) += dwmac-meson.o dwmac-meson8b.o
obj-$(CONFIG_DWMAC_OXNAS) += dwmac-oxnas.o
obj-$(CONFIG_DWMAC_QCOM_ETHQOS) += dwmac-qcom-gpio.o
obj-$(CONFIG_DWMAC_QCOM_ETHQOS) += dwmac-qcom-ethqos.o
obj-$(CONFIG_DWMAC_QCOM_ETHQOS) += dwmac-qcom-pps.o
obj-$(CONFIG_DWMAC_QCOM_ETHQOS) += dwmac-qcom-eth.o
dwmac-qcom-eth-objs := dwmac-qcom-ethqos.o dwmac-qcom-gpio.o dwmac-qcom-pps.o
obj-$(CONFIG_DWMAC_ROCKCHIP) += dwmac-rk.o
obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o
obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o

View file

@ -113,7 +113,6 @@
#define AUTONEG_STATE_MASK 0x20
#define MICREL_LINK_UP_INTR_STATUS BIT(0)
bool phy_intr_en;
void *ipc_emac_log_ctxt;
struct emac_emb_smmu_cb_ctx emac_emb_smmu_ctx = {0};
@ -1011,6 +1010,7 @@ static irqreturn_t ETHQOS_PHY_ISR(int irq, void *dev_data)
static int ethqos_phy_intr_enable(struct qcom_ethqos *ethqos)
{
int ret = 0;
struct stmmac_priv *priv = qcom_ethqos_get_priv(ethqos);
INIT_WORK(&ethqos->emac_phy_work, ethqos_defer_phy_isr_work);
init_completion(&ethqos->clk_enable_done);
@ -1022,7 +1022,7 @@ static int ethqos_phy_intr_enable(struct qcom_ethqos *ethqos)
ethqos->phy_intr);
return ret;
}
phy_intr_en = true;
priv->plat->phy_intr_en_extn_stm = true;
return ret;
}
@ -1103,7 +1103,7 @@ static void qcom_ethqos_phy_suspend_clks(struct qcom_ethqos *ethqos)
ETHQOSINFO("Enter\n");
if (phy_intr_en)
if (priv->plat->phy_intr_en_extn_stm)
reinit_completion(&ethqos->clk_enable_done);
ethqos->clks_suspended = 1;
@ -1170,17 +1170,26 @@ static void qcom_ethqos_phy_resume_clks(struct qcom_ethqos *ethqos)
ethqos->clks_suspended = 0;
if (phy_intr_en)
if (priv->plat->phy_intr_en_extn_stm)
complete_all(&ethqos->clk_enable_done);
ETHQOSINFO("Exit\n");
}
void qcom_ethqos_request_phy_wol(struct plat_stmmacenet_data *plat)
static void qcom_ethqos_request_phy_wol(void *plat_n)
{
struct qcom_ethqos *ethqos = plat->bsp_priv;
struct platform_device *pdev = ethqos->pdev;
struct net_device *ndev = platform_get_drvdata(pdev);
struct plat_stmmacenet_data *plat = plat_n;
struct qcom_ethqos *ethqos;
struct platform_device *pdev;
struct net_device *ndev;
if (!plat)
return;
ethqos = plat->bsp_priv;
pdev = ethqos->pdev;
ndev = platform_get_drvdata(pdev);
ethqos->phy_wol_supported = 0;
ethqos->phy_wol_wolopts = 0;
@ -1615,6 +1624,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
plat_dat->pmt = 1;
plat_dat->tso_en = of_property_read_bool(np, "snps,tso");
plat_dat->early_eth = ethqos->early_eth_enabled;
plat_dat->handle_prv_ioctl = ethqos_handle_prv_ioctl;
plat_dat->request_phy_wol = qcom_ethqos_request_phy_wol;
plat_dat->init_pps = ethqos_init_pps;
if (of_property_read_bool(pdev->dev.of_node,
"emac-core-version")) {
@ -1647,6 +1659,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
}
}
plat_dat->stmmac_emb_smmu_ctx = emac_emb_smmu_ctx;
ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
if (ret)
goto err_clk;
@ -1703,18 +1717,21 @@ static int qcom_ethqos_remove(struct platform_device *pdev)
{
struct qcom_ethqos *ethqos;
int ret;
struct stmmac_priv *priv;
ethqos = get_stmmac_bsp_priv(&pdev->dev);
if (!ethqos)
return -ENODEV;
priv = qcom_ethqos_get_priv(pethqos);
ret = stmmac_pltfr_remove(pdev);
clk_disable_unprepare(ethqos->rgmii_clk);
if (phy_intr_en)
if (priv->plat->phy_intr_en_extn_stm)
free_irq(ethqos->phy_intr, ethqos);
if (phy_intr_en)
if (priv->plat->phy_intr_en_extn_stm)
cancel_work_sync(&ethqos->emac_phy_work);
emac_emb_smmu_exit();

View file

@ -309,5 +309,5 @@ struct dwmac_qcom_avb_algorithm {
void dwmac_qcom_program_avb_algorithm(struct stmmac_priv *priv,
struct ifr_data_struct *req);
unsigned int dwmac_qcom_get_plat_tx_coal_frames(struct sk_buff *skb);
void qcom_ethqos_request_phy_wol(struct plat_stmmacenet_data *plat);
int ethqos_init_pps(void *priv);
#endif

View file

@ -254,11 +254,17 @@ int ppsout_config(struct stmmac_priv *priv, struct pps_cfg *eth_pps_cfg)
return 0;
}
int ethqos_init_pps(struct stmmac_priv *priv)
int ethqos_init_pps(void *priv_n)
{
struct stmmac_priv *priv;
u32 value;
struct pps_cfg eth_pps_cfg = {0};
if (!priv_n)
return -ENODEV;
priv = priv_n;
priv->ptpaddr = priv->ioaddr + PTP_GMAC4_OFFSET;
value = (PTP_TCR_TSENA | PTP_TCR_TSCFUPDT | PTP_TCR_TSUPDT);
priv->hw->ptp->config_hw_tstamping(priv->ptpaddr, value);

View file

@ -249,27 +249,8 @@ enum stmmac_state {
STMMAC_SERVICE_SCHED,
};
struct emac_emb_smmu_cb_ctx {
bool valid;
struct platform_device *pdev_master;
struct platform_device *smmu_pdev;
struct dma_iommu_mapping *mapping;
struct iommu_domain *iommu_domain;
u32 va_start;
u32 va_size;
u32 va_end;
int ret;
};
extern struct emac_emb_smmu_cb_ctx emac_emb_smmu_ctx;
#define GET_MEM_PDEV_DEV (emac_emb_smmu_ctx.valid ? \
&emac_emb_smmu_ctx.smmu_pdev->dev : priv->device)
int ethqos_handle_prv_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
int ethqos_init_pps(struct stmmac_priv *priv);
extern bool phy_intr_en;
void qcom_ethqos_request_phy_wol(struct plat_stmmacenet_data *plat_dat);
#define GET_MEM_PDEV_DEV (priv->plat->stmmac_emb_smmu_ctx.valid ? \
&priv->plat->stmmac_emb_smmu_ctx.smmu_pdev->dev : priv->device)
int stmmac_mdio_unregister(struct net_device *ndev);
int stmmac_mdio_register(struct net_device *ndev);

View file

@ -1096,7 +1096,7 @@ static int stmmac_init_phy(struct net_device *dev)
return -ENODEV;
}
ret = phylink_connect_phy(priv->phylink, priv->phydev);
if (phy_intr_en) {
if (priv->plat->phy_intr_en_extn_stm) {
priv->phydev->irq = PHY_IGNORE_INTERRUPT;
priv->phydev->interrupts = PHY_INTERRUPT_ENABLED;
if (priv->phydev->drv->ack_interrupt &&
@ -1113,7 +1113,7 @@ static int stmmac_init_phy(struct net_device *dev)
!priv->phydev->drv->config_intr(priv->phydev)) {
pr_err(" qcom-ethqos: %s config_phy_intr successful aftre connect\n",
__func__);
qcom_ethqos_request_phy_wol(priv->plat);
priv->plat->request_phy_wol(priv->plat);
}
} else {
pr_info("stmmac phy polling mode\n");
@ -2692,7 +2692,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
clk_set_rate(priv->plat->clk_ptp_ref,
priv->plat->clk_ptp_rate);
ret = ethqos_init_pps(priv);
ret = priv->plat->init_pps(priv);
}
priv->tx_lpi_timer = STMMAC_DEFAULT_TWT_LS;
@ -4073,12 +4073,14 @@ static void stmmac_poll_controller(struct net_device *dev)
*/
static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct stmmac_priv *priv = netdev_priv (dev);
int ret = -EOPNOTSUPP;
struct stmmac_priv *priv;
if (!netif_running(dev))
return -EINVAL;
priv = netdev_priv(dev);
switch (cmd) {
case SIOCGMIIPHY:
case SIOCGMIIREG:
@ -4091,7 +4093,7 @@ static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
case SIOCGHWTSTAMP:
ret = stmmac_hwtstamp_get(dev, rq);
case SIOCDEVPRIVATE:
ret = ethqos_handle_prv_ioctl(dev, rq, cmd);
ret = priv->plat->handle_prv_ioctl(dev, rq, cmd);
break;
default:
break;

View file

@ -266,9 +266,8 @@ int stmmac_mdio_reset(struct mii_bus *bus)
unsigned int mii_address = priv->hw->mii.addr;
bool active_high = true;
#ifdef CONFIG_DWMAC_QCOM_ETHQOS
active_high = false;
#endif
if (priv->plat->early_eth)
return 0;

View file

@ -128,6 +128,18 @@ struct stmmac_txq_cfg {
u32 prio;
};
struct emac_emb_smmu_cb_ctx {
bool valid;
struct platform_device *pdev_master;
struct platform_device *smmu_pdev;
struct dma_iommu_mapping *mapping;
struct iommu_domain *iommu_domain;
u32 va_start;
u32 va_size;
u32 va_end;
int ret;
};
struct plat_stmmacenet_data {
int bus_id;
int phy_addr;
@ -187,5 +199,11 @@ struct plat_stmmacenet_data {
unsigned int (*get_plat_tx_coal_frames)
(struct sk_buff *skb);
bool early_eth;
struct emac_emb_smmu_cb_ctx stmmac_emb_smmu_ctx;
bool phy_intr_en_extn_stm;
int (*handle_prv_ioctl)(struct net_device *dev, struct ifreq *ifr,
int cmd);
void (*request_phy_wol)(void *plat);
int (*init_pps)(void *priv);
};
#endif