Lines Matching refs:gmac
115 static int get_clk_div_sgmii(struct ipq806x_gmac *gmac, unsigned int speed) in get_clk_div_sgmii() argument
117 struct device *dev = &gmac->pdev->dev; in get_clk_div_sgmii()
141 static int get_clk_div_rgmii(struct ipq806x_gmac *gmac, unsigned int speed) in get_clk_div_rgmii() argument
143 struct device *dev = &gmac->pdev->dev; in get_clk_div_rgmii()
167 static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, unsigned int speed) in ipq806x_gmac_set_speed() argument
172 switch (gmac->phy_mode) { in ipq806x_gmac_set_speed()
174 div = get_clk_div_rgmii(gmac, speed); in ipq806x_gmac_set_speed()
175 clk_bits = NSS_COMMON_CLK_GATE_RGMII_RX_EN(gmac->id) | in ipq806x_gmac_set_speed()
176 NSS_COMMON_CLK_GATE_RGMII_TX_EN(gmac->id); in ipq806x_gmac_set_speed()
180 div = get_clk_div_sgmii(gmac, speed); in ipq806x_gmac_set_speed()
181 clk_bits = NSS_COMMON_CLK_GATE_GMII_RX_EN(gmac->id) | in ipq806x_gmac_set_speed()
182 NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id); in ipq806x_gmac_set_speed()
186 dev_err(&gmac->pdev->dev, "Unsupported PHY mode: \"%s\"\n", in ipq806x_gmac_set_speed()
187 phy_modes(gmac->phy_mode)); in ipq806x_gmac_set_speed()
192 regmap_read(gmac->nss_common, NSS_COMMON_CLK_GATE, &val); in ipq806x_gmac_set_speed()
194 regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val); in ipq806x_gmac_set_speed()
197 regmap_read(gmac->nss_common, NSS_COMMON_CLK_DIV0, &val); in ipq806x_gmac_set_speed()
199 << NSS_COMMON_CLK_DIV_OFFSET(gmac->id)); in ipq806x_gmac_set_speed()
200 val |= div << NSS_COMMON_CLK_DIV_OFFSET(gmac->id); in ipq806x_gmac_set_speed()
201 regmap_write(gmac->nss_common, NSS_COMMON_CLK_DIV0, val); in ipq806x_gmac_set_speed()
204 regmap_read(gmac->nss_common, NSS_COMMON_CLK_GATE, &val); in ipq806x_gmac_set_speed()
206 regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val); in ipq806x_gmac_set_speed()
211 static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac) in ipq806x_gmac_of_parse() argument
213 struct device *dev = &gmac->pdev->dev; in ipq806x_gmac_of_parse()
216 ret = of_get_phy_mode(dev->of_node, &gmac->phy_mode); in ipq806x_gmac_of_parse()
222 if (of_property_read_u32(dev->of_node, "qcom,id", &gmac->id) < 0) { in ipq806x_gmac_of_parse()
231 if (gmac->id > 3) { in ipq806x_gmac_of_parse()
236 gmac->core_clk = devm_clk_get(dev, "stmmaceth"); in ipq806x_gmac_of_parse()
237 if (IS_ERR(gmac->core_clk)) { in ipq806x_gmac_of_parse()
239 return PTR_ERR(gmac->core_clk); in ipq806x_gmac_of_parse()
241 clk_set_rate(gmac->core_clk, 266000000); in ipq806x_gmac_of_parse()
244 gmac->nss_common = syscon_regmap_lookup_by_phandle(dev->of_node, in ipq806x_gmac_of_parse()
246 if (IS_ERR(gmac->nss_common)) { in ipq806x_gmac_of_parse()
248 return PTR_ERR(gmac->nss_common); in ipq806x_gmac_of_parse()
252 gmac->qsgmii_csr = syscon_regmap_lookup_by_phandle(dev->of_node, in ipq806x_gmac_of_parse()
254 if (IS_ERR(gmac->qsgmii_csr)) in ipq806x_gmac_of_parse()
257 return PTR_ERR_OR_ZERO(gmac->qsgmii_csr); in ipq806x_gmac_of_parse()
262 struct ipq806x_gmac *gmac = priv; in ipq806x_gmac_fix_mac_speed() local
264 ipq806x_gmac_set_speed(gmac, speed); in ipq806x_gmac_fix_mac_speed()
268 ipq806x_gmac_configure_qsgmii_pcs_speed(struct ipq806x_gmac *gmac) in ipq806x_gmac_configure_qsgmii_pcs_speed() argument
270 struct platform_device *pdev = gmac->pdev; in ipq806x_gmac_configure_qsgmii_pcs_speed()
307 regmap_update_bits(gmac->qsgmii_csr, QSGMII_PCS_ALL_CH_CTL, in ipq806x_gmac_configure_qsgmii_pcs_speed()
309 QSGMII_PCS_CH_SPEED_SHIFT(gmac->id), in ipq806x_gmac_configure_qsgmii_pcs_speed()
311 QSGMII_PCS_CH_SPEED_SHIFT(gmac->id)); in ipq806x_gmac_configure_qsgmii_pcs_speed()
326 ipq806x_gmac_configure_qsgmii_params(struct ipq806x_gmac *gmac) in ipq806x_gmac_configure_qsgmii_params() argument
328 struct platform_device *pdev = gmac->pdev; in ipq806x_gmac_configure_qsgmii_params()
333 switch (gmac->id) { in ipq806x_gmac_configure_qsgmii_params()
354 dev_err(dev, "gmac id %d can't be in SGMII mode", gmac->id); in ipq806x_gmac_configure_qsgmii_params()
368 regmap_write(gmac->qsgmii_csr, QSGMII_PHY_SGMII_CTL(gmac->id), in ipq806x_gmac_configure_qsgmii_params()
379 struct ipq806x_gmac *gmac; in ipq806x_gmac_probe() local
391 gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); in ipq806x_gmac_probe()
392 if (!gmac) { in ipq806x_gmac_probe()
397 gmac->pdev = pdev; in ipq806x_gmac_probe()
399 err = ipq806x_gmac_of_parse(gmac); in ipq806x_gmac_probe()
405 regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL, in ipq806x_gmac_probe()
413 switch (gmac->phy_mode) { in ipq806x_gmac_probe()
423 regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val); in ipq806x_gmac_probe()
426 regmap_read(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, &val); in ipq806x_gmac_probe()
427 val &= ~(1 << NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id)); in ipq806x_gmac_probe()
428 switch (gmac->phy_mode) { in ipq806x_gmac_probe()
430 val |= NSS_COMMON_CLK_SRC_CTRL_RGMII(gmac->id) << in ipq806x_gmac_probe()
431 NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id); in ipq806x_gmac_probe()
434 val |= NSS_COMMON_CLK_SRC_CTRL_SGMII(gmac->id) << in ipq806x_gmac_probe()
435 NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id); in ipq806x_gmac_probe()
440 regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val); in ipq806x_gmac_probe()
443 regmap_read(gmac->nss_common, NSS_COMMON_CLK_GATE, &val); in ipq806x_gmac_probe()
444 val |= NSS_COMMON_CLK_GATE_PTP_EN(gmac->id); in ipq806x_gmac_probe()
445 switch (gmac->phy_mode) { in ipq806x_gmac_probe()
447 val |= NSS_COMMON_CLK_GATE_RGMII_RX_EN(gmac->id) | in ipq806x_gmac_probe()
448 NSS_COMMON_CLK_GATE_RGMII_TX_EN(gmac->id); in ipq806x_gmac_probe()
451 val |= NSS_COMMON_CLK_GATE_GMII_RX_EN(gmac->id) | in ipq806x_gmac_probe()
452 NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id); in ipq806x_gmac_probe()
457 regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val); in ipq806x_gmac_probe()
459 if (gmac->phy_mode == PHY_INTERFACE_MODE_SGMII) { in ipq806x_gmac_probe()
460 err = ipq806x_gmac_configure_qsgmii_params(gmac); in ipq806x_gmac_probe()
464 err = ipq806x_gmac_configure_qsgmii_pcs_speed(gmac); in ipq806x_gmac_probe()
470 plat_dat->bsp_priv = gmac; in ipq806x_gmac_probe()
484 phy_modes(gmac->phy_mode)); in ipq806x_gmac_probe()