Lines Matching full:gmac

2  * Qualcomm Atheros IPQ806x GMAC glue layer
93 static int get_clk_div_sgmii(struct ipq806x_gmac *gmac, unsigned int speed) in get_clk_div_sgmii() argument
95 struct device *dev = &gmac->pdev->dev; in get_clk_div_sgmii()
119 static int get_clk_div_rgmii(struct ipq806x_gmac *gmac, unsigned int speed) in get_clk_div_rgmii() argument
121 struct device *dev = &gmac->pdev->dev; in get_clk_div_rgmii()
145 static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, unsigned int speed) in ipq806x_gmac_set_speed() argument
150 switch (gmac->phy_mode) { in ipq806x_gmac_set_speed()
152 div = get_clk_div_rgmii(gmac, speed); in ipq806x_gmac_set_speed()
153 clk_bits = NSS_COMMON_CLK_GATE_RGMII_RX_EN(gmac->id) | in ipq806x_gmac_set_speed()
154 NSS_COMMON_CLK_GATE_RGMII_TX_EN(gmac->id); in ipq806x_gmac_set_speed()
158 div = get_clk_div_sgmii(gmac, speed); in ipq806x_gmac_set_speed()
159 clk_bits = NSS_COMMON_CLK_GATE_GMII_RX_EN(gmac->id) | in ipq806x_gmac_set_speed()
160 NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id); in ipq806x_gmac_set_speed()
164 dev_err(&gmac->pdev->dev, "Unsupported PHY mode: \"%s\"\n", in ipq806x_gmac_set_speed()
165 phy_modes(gmac->phy_mode)); in ipq806x_gmac_set_speed()
170 regmap_read(gmac->nss_common, NSS_COMMON_CLK_GATE, &val); in ipq806x_gmac_set_speed()
172 regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val); in ipq806x_gmac_set_speed()
175 regmap_read(gmac->nss_common, NSS_COMMON_CLK_DIV0, &val); in ipq806x_gmac_set_speed()
177 << NSS_COMMON_CLK_DIV_OFFSET(gmac->id)); in ipq806x_gmac_set_speed()
178 val |= div << NSS_COMMON_CLK_DIV_OFFSET(gmac->id); in ipq806x_gmac_set_speed()
179 regmap_write(gmac->nss_common, NSS_COMMON_CLK_DIV0, val); in ipq806x_gmac_set_speed()
182 regmap_read(gmac->nss_common, NSS_COMMON_CLK_GATE, &val); in ipq806x_gmac_set_speed()
184 regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val); in ipq806x_gmac_set_speed()
189 static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac) in ipq806x_gmac_of_parse() argument
191 struct device *dev = &gmac->pdev->dev; in ipq806x_gmac_of_parse()
194 ret = of_get_phy_mode(dev->of_node, &gmac->phy_mode); in ipq806x_gmac_of_parse()
200 if (of_property_read_u32(dev->of_node, "qcom,id", &gmac->id) < 0) { in ipq806x_gmac_of_parse()
209 if (gmac->id > 3) { in ipq806x_gmac_of_parse()
210 dev_err(dev, "invalid gmac id\n"); in ipq806x_gmac_of_parse()
214 gmac->core_clk = devm_clk_get(dev, "stmmaceth"); in ipq806x_gmac_of_parse()
215 if (IS_ERR(gmac->core_clk)) { in ipq806x_gmac_of_parse()
217 return PTR_ERR(gmac->core_clk); in ipq806x_gmac_of_parse()
219 clk_set_rate(gmac->core_clk, 266000000); in ipq806x_gmac_of_parse()
222 gmac->nss_common = syscon_regmap_lookup_by_phandle(dev->of_node, in ipq806x_gmac_of_parse()
224 if (IS_ERR(gmac->nss_common)) { in ipq806x_gmac_of_parse()
226 return PTR_ERR(gmac->nss_common); in ipq806x_gmac_of_parse()
230 gmac->qsgmii_csr = syscon_regmap_lookup_by_phandle(dev->of_node, in ipq806x_gmac_of_parse()
232 if (IS_ERR(gmac->qsgmii_csr)) in ipq806x_gmac_of_parse()
235 return PTR_ERR_OR_ZERO(gmac->qsgmii_csr); in ipq806x_gmac_of_parse()
240 struct ipq806x_gmac *gmac = priv; in ipq806x_gmac_fix_mac_speed() local
242 ipq806x_gmac_set_speed(gmac, speed); in ipq806x_gmac_fix_mac_speed()
250 struct ipq806x_gmac *gmac; in ipq806x_gmac_probe() local
262 gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); in ipq806x_gmac_probe()
263 if (!gmac) { in ipq806x_gmac_probe()
268 gmac->pdev = pdev; in ipq806x_gmac_probe()
270 err = ipq806x_gmac_of_parse(gmac); in ipq806x_gmac_probe()
276 regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL, in ipq806x_gmac_probe()
284 switch (gmac->phy_mode) { in ipq806x_gmac_probe()
293 phy_modes(gmac->phy_mode)); in ipq806x_gmac_probe()
297 regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val); in ipq806x_gmac_probe()
300 regmap_read(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, &val); in ipq806x_gmac_probe()
301 val &= ~(1 << NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id)); in ipq806x_gmac_probe()
302 switch (gmac->phy_mode) { in ipq806x_gmac_probe()
304 val |= NSS_COMMON_CLK_SRC_CTRL_RGMII(gmac->id) << in ipq806x_gmac_probe()
305 NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id); in ipq806x_gmac_probe()
308 val |= NSS_COMMON_CLK_SRC_CTRL_SGMII(gmac->id) << in ipq806x_gmac_probe()
309 NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id); in ipq806x_gmac_probe()
313 phy_modes(gmac->phy_mode)); in ipq806x_gmac_probe()
317 regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val); in ipq806x_gmac_probe()
320 regmap_read(gmac->nss_common, NSS_COMMON_CLK_GATE, &val); in ipq806x_gmac_probe()
321 val |= NSS_COMMON_CLK_GATE_PTP_EN(gmac->id); in ipq806x_gmac_probe()
322 switch (gmac->phy_mode) { in ipq806x_gmac_probe()
324 val |= NSS_COMMON_CLK_GATE_RGMII_RX_EN(gmac->id) | in ipq806x_gmac_probe()
325 NSS_COMMON_CLK_GATE_RGMII_TX_EN(gmac->id); in ipq806x_gmac_probe()
328 val |= NSS_COMMON_CLK_GATE_GMII_RX_EN(gmac->id) | in ipq806x_gmac_probe()
329 NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id); in ipq806x_gmac_probe()
335 regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val); in ipq806x_gmac_probe()
337 if (gmac->phy_mode == PHY_INTERFACE_MODE_SGMII) { in ipq806x_gmac_probe()
338 regmap_write(gmac->qsgmii_csr, QSGMII_PHY_SGMII_CTL(gmac->id), in ipq806x_gmac_probe()
352 plat_dat->bsp_priv = gmac; in ipq806x_gmac_probe()
369 { .compatible = "qcom,ipq806x-gmac" },
378 .name = "ipq806x-gmac-dwmac",