Lines Matching +full:visconti +full:- +full:dwmac
1 // SPDX-License-Identifier: GPL-2.0
2 /* Toshiba Visconti Ethernet Support
59 struct visconti_eth *dwmac = priv; in visconti_eth_fix_mac_speed() local
60 struct net_device *netdev = dev_get_drvdata(dwmac->dev); in visconti_eth_fix_mac_speed()
64 spin_lock_irqsave(&dwmac->lock, flags); in visconti_eth_fix_mac_speed()
67 val = readl(dwmac->reg + MAC_CTRL_REG); in visconti_eth_fix_mac_speed()
72 if (dwmac->phy_intf_sel == ETHER_CONFIG_INTF_RGMII) in visconti_eth_fix_mac_speed()
76 if (dwmac->phy_intf_sel == ETHER_CONFIG_INTF_RGMII) in visconti_eth_fix_mac_speed()
78 if (dwmac->phy_intf_sel == ETHER_CONFIG_INTF_RMII) in visconti_eth_fix_mac_speed()
83 if (dwmac->phy_intf_sel == ETHER_CONFIG_INTF_RGMII) in visconti_eth_fix_mac_speed()
85 if (dwmac->phy_intf_sel == ETHER_CONFIG_INTF_RMII) in visconti_eth_fix_mac_speed()
92 spin_unlock_irqrestore(&dwmac->lock, flags); in visconti_eth_fix_mac_speed()
96 writel(val, dwmac->reg + MAC_CTRL_REG); in visconti_eth_fix_mac_speed()
99 val = readl(dwmac->reg + REG_ETHER_CLOCK_SEL); in visconti_eth_fix_mac_speed()
102 writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); in visconti_eth_fix_mac_speed()
104 /* Set Clock-Mux, Start clock, Set TX_O direction */ in visconti_eth_fix_mac_speed()
105 switch (dwmac->phy_intf_sel) { in visconti_eth_fix_mac_speed()
108 writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); in visconti_eth_fix_mac_speed()
111 writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); in visconti_eth_fix_mac_speed()
114 writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); in visconti_eth_fix_mac_speed()
120 writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); in visconti_eth_fix_mac_speed()
123 writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); in visconti_eth_fix_mac_speed()
126 writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); in visconti_eth_fix_mac_speed()
132 writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); in visconti_eth_fix_mac_speed()
135 writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); in visconti_eth_fix_mac_speed()
139 spin_unlock_irqrestore(&dwmac->lock, flags); in visconti_eth_fix_mac_speed()
144 struct visconti_eth *dwmac = plat_dat->bsp_priv; in visconti_eth_init_hw() local
147 switch (plat_dat->phy_interface) { in visconti_eth_init_hw()
152 dwmac->phy_intf_sel = ETHER_CONFIG_INTF_RGMII; in visconti_eth_init_hw()
155 dwmac->phy_intf_sel = ETHER_CONFIG_INTF_MII; in visconti_eth_init_hw()
158 dwmac->phy_intf_sel = ETHER_CONFIG_INTF_RMII; in visconti_eth_init_hw()
161 dev_err(&pdev->dev, "Unsupported phy-mode (%d)\n", plat_dat->phy_interface); in visconti_eth_init_hw()
162 return -EOPNOTSUPP; in visconti_eth_init_hw()
165 reg_val = dwmac->phy_intf_sel; in visconti_eth_init_hw()
166 writel(reg_val, dwmac->reg + REG_ETHER_CONTROL); in visconti_eth_init_hw()
170 writel(clk_sel_val, dwmac->reg + REG_ETHER_CLOCK_SEL); in visconti_eth_init_hw()
173 dwmac->reg + REG_ETHER_CLOCK_SEL); in visconti_eth_init_hw()
175 /* release internal-reset */ in visconti_eth_init_hw()
177 writel(reg_val, dwmac->reg + REG_ETHER_CONTROL); in visconti_eth_init_hw()
185 struct visconti_eth *dwmac = plat_dat->bsp_priv; in visconti_eth_clock_probe() local
188 dwmac->phy_ref_clk = devm_clk_get(&pdev->dev, "phy_ref_clk"); in visconti_eth_clock_probe()
189 if (IS_ERR(dwmac->phy_ref_clk)) in visconti_eth_clock_probe()
190 return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->phy_ref_clk), in visconti_eth_clock_probe()
193 err = clk_prepare_enable(dwmac->phy_ref_clk); in visconti_eth_clock_probe()
195 dev_err(&pdev->dev, "failed to enable phy_ref clock: %d\n", err); in visconti_eth_clock_probe()
204 struct visconti_eth *dwmac = get_stmmac_bsp_priv(&pdev->dev); in visconti_eth_clock_remove() local
208 clk_disable_unprepare(dwmac->phy_ref_clk); in visconti_eth_clock_remove()
209 clk_disable_unprepare(priv->plat->stmmac_clk); in visconti_eth_clock_remove()
216 struct visconti_eth *dwmac; in visconti_eth_dwmac_probe() local
227 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); in visconti_eth_dwmac_probe()
228 if (!dwmac) in visconti_eth_dwmac_probe()
229 return -ENOMEM; in visconti_eth_dwmac_probe()
231 spin_lock_init(&dwmac->lock); in visconti_eth_dwmac_probe()
232 dwmac->reg = stmmac_res.addr; in visconti_eth_dwmac_probe()
233 dwmac->dev = &pdev->dev; in visconti_eth_dwmac_probe()
234 plat_dat->bsp_priv = dwmac; in visconti_eth_dwmac_probe()
235 plat_dat->fix_mac_speed = visconti_eth_fix_mac_speed; in visconti_eth_dwmac_probe()
243 plat_dat->dma_cfg->aal = 1; in visconti_eth_dwmac_probe()
245 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); in visconti_eth_dwmac_probe()
264 { .compatible = "toshiba,visconti-dwmac" },
273 .name = "visconti-eth-dwmac",
280 MODULE_DESCRIPTION("Toshiba Visconti Ethernet DWMAC glue driver");