Lines Matching +full:switch +full:- +full:x +full:- +full:sgmii

36 #define NSS_COMMON_CLK_GATE_PTP_EN(x)		BIT(0x10 + x)  argument
37 #define NSS_COMMON_CLK_GATE_RGMII_RX_EN(x) BIT(0x9 + (x * 2)) argument
38 #define NSS_COMMON_CLK_GATE_RGMII_TX_EN(x) BIT(0x8 + (x * 2)) argument
39 #define NSS_COMMON_CLK_GATE_GMII_RX_EN(x) BIT(0x4 + x) argument
40 #define NSS_COMMON_CLK_GATE_GMII_TX_EN(x) BIT(0x0 + x) argument
43 #define NSS_COMMON_CLK_DIV_OFFSET(x) (x * 8) argument
47 #define NSS_COMMON_CLK_SRC_CTRL_OFFSET(x) (x) argument
50 * MAC1: QSGMII=0 SGMII=0 RGMII=1
51 * MAC2 & MAC3: QSGMII=0 SGMII=1
53 #define NSS_COMMON_CLK_SRC_CTRL_RGMII(x) 1 argument
54 #define NSS_COMMON_CLK_SRC_CTRL_SGMII(x) ((x >= 2) ? 1 : 0) argument
56 #define NSS_COMMON_GMAC_CTL(x) (0x30 + (x * 4)) argument
78 #define QSGMII_PCS_CH_SPEED_SHIFT(x) ((x) * 4) argument
83 /* Only GMAC1/2/3 support SGMII and their CTL register are not contiguous */
84 #define QSGMII_PHY_SGMII_CTL(x) ((x == 1) ? 0x134 : \ argument
85 (0x13c + (4 * (x - 2))))
92 #define QSGMII_PHY_DEEMPHASIS_LVL(x) FIELD_PREP(QSGMII_PHY_DEEMPHASIS_LVL_MASK, (x)) argument
94 #define QSGMII_PHY_PHASE_LOOP_GAIN(x) FIELD_PREP(QSGMII_PHY_PHASE_LOOP_GAIN_MASK, (x)) argument
96 #define QSGMII_PHY_RX_DC_BIAS(x) FIELD_PREP(QSGMII_PHY_RX_DC_BIAS_MASK, (x)) argument
98 #define QSGMII_PHY_RX_INPUT_EQU(x) FIELD_PREP(QSGMII_PHY_RX_INPUT_EQU_MASK, (x)) argument
100 #define QSGMII_PHY_CDR_PI_SLEW(x) FIELD_PREP(QSGMII_PHY_CDR_PI_SLEW_MASK, (x)) argument
102 #define QSGMII_PHY_TX_SLEW(x) FIELD_PREP(QSGMII_PHY_TX_SLEW_MASK, (x)) argument
104 #define QSGMII_PHY_TX_DRV_AMP(x) FIELD_PREP(QSGMII_PHY_TX_DRV_AMP_MASK, (x)) argument
117 struct device *dev = &gmac->pdev->dev; in get_clk_div_sgmii()
120 switch (speed) { in get_clk_div_sgmii()
134 dev_err(dev, "Speed %dMbps not supported in SGMII\n", speed); in get_clk_div_sgmii()
135 return -EINVAL; in get_clk_div_sgmii()
143 struct device *dev = &gmac->pdev->dev; in get_clk_div_rgmii()
146 switch (speed) { in get_clk_div_rgmii()
161 return -EINVAL; in get_clk_div_rgmii()
172 switch (gmac->phy_mode) { in ipq806x_gmac_set_speed()
178 clk_bits = NSS_COMMON_CLK_GATE_RGMII_RX_EN(gmac->id) | in ipq806x_gmac_set_speed()
179 NSS_COMMON_CLK_GATE_RGMII_TX_EN(gmac->id); in ipq806x_gmac_set_speed()
184 clk_bits = NSS_COMMON_CLK_GATE_GMII_RX_EN(gmac->id) | in ipq806x_gmac_set_speed()
185 NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id); in ipq806x_gmac_set_speed()
189 dev_err(&gmac->pdev->dev, "Unsupported PHY mode: \"%s\"\n", in ipq806x_gmac_set_speed()
190 phy_modes(gmac->phy_mode)); in ipq806x_gmac_set_speed()
191 return -EINVAL; in ipq806x_gmac_set_speed()
195 regmap_read(gmac->nss_common, NSS_COMMON_CLK_GATE, &val); in ipq806x_gmac_set_speed()
197 regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val); in ipq806x_gmac_set_speed()
200 regmap_read(gmac->nss_common, NSS_COMMON_CLK_DIV0, &val); in ipq806x_gmac_set_speed()
202 << NSS_COMMON_CLK_DIV_OFFSET(gmac->id)); in ipq806x_gmac_set_speed()
203 val |= div << NSS_COMMON_CLK_DIV_OFFSET(gmac->id); in ipq806x_gmac_set_speed()
204 regmap_write(gmac->nss_common, NSS_COMMON_CLK_DIV0, val); in ipq806x_gmac_set_speed()
207 regmap_read(gmac->nss_common, NSS_COMMON_CLK_GATE, &val); in ipq806x_gmac_set_speed()
209 regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val); in ipq806x_gmac_set_speed()
217 struct device *dev = &gmac->pdev->dev; in ipq806x_gmac_of_parse()
219 gmac->phy_mode = plat_dat->phy_interface; in ipq806x_gmac_of_parse()
221 if (of_property_read_u32(dev->of_node, "qcom,id", &gmac->id) < 0) { in ipq806x_gmac_of_parse()
223 return -EINVAL; in ipq806x_gmac_of_parse()
230 if (gmac->id > 3) { in ipq806x_gmac_of_parse()
232 return -EINVAL; in ipq806x_gmac_of_parse()
235 gmac->core_clk = devm_clk_get(dev, "stmmaceth"); in ipq806x_gmac_of_parse()
236 if (IS_ERR(gmac->core_clk)) { in ipq806x_gmac_of_parse()
238 return PTR_ERR(gmac->core_clk); in ipq806x_gmac_of_parse()
240 clk_set_rate(gmac->core_clk, 266000000); in ipq806x_gmac_of_parse()
243 gmac->nss_common = syscon_regmap_lookup_by_phandle(dev->of_node, in ipq806x_gmac_of_parse()
244 "qcom,nss-common"); in ipq806x_gmac_of_parse()
245 if (IS_ERR(gmac->nss_common)) { in ipq806x_gmac_of_parse()
246 dev_err(dev, "missing nss-common node\n"); in ipq806x_gmac_of_parse()
247 return PTR_ERR(gmac->nss_common); in ipq806x_gmac_of_parse()
251 gmac->qsgmii_csr = syscon_regmap_lookup_by_phandle(dev->of_node, in ipq806x_gmac_of_parse()
252 "qcom,qsgmii-csr"); in ipq806x_gmac_of_parse()
253 if (IS_ERR(gmac->qsgmii_csr)) in ipq806x_gmac_of_parse()
254 dev_err(dev, "missing qsgmii-csr node\n"); in ipq806x_gmac_of_parse()
256 return PTR_ERR_OR_ZERO(gmac->qsgmii_csr); in ipq806x_gmac_of_parse()
270 struct platform_device *pdev = gmac->pdev; in ipq806x_gmac_configure_qsgmii_pcs_speed()
271 struct device *dev = &pdev->dev; in ipq806x_gmac_configure_qsgmii_pcs_speed()
281 if (!of_phy_is_fixed_link(pdev->dev.of_node)) in ipq806x_gmac_configure_qsgmii_pcs_speed()
284 dn = of_get_child_by_name(pdev->dev.of_node, "fixed-link"); in ipq806x_gmac_configure_qsgmii_pcs_speed()
288 dev_err(dev, "found fixed-link node with no speed"); in ipq806x_gmac_configure_qsgmii_pcs_speed()
294 switch (link_speed) { 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()
328 struct platform_device *pdev = gmac->pdev; in ipq806x_gmac_configure_qsgmii_params()
330 struct device *dev = &pdev->dev; in ipq806x_gmac_configure_qsgmii_params()
333 switch (gmac->id) { in ipq806x_gmac_configure_qsgmii_params()
353 default: /* gmac 0 can't be set in SGMII mode */ 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()
355 return -EINVAL; in ipq806x_gmac_configure_qsgmii_params()
368 regmap_write(gmac->qsgmii_csr, QSGMII_PHY_SGMII_CTL(gmac->id), in ipq806x_gmac_configure_qsgmii_params()
378 struct device *dev = &pdev->dev; in ipq806x_gmac_probe()
393 return -ENOMEM; in ipq806x_gmac_probe()
395 gmac->pdev = pdev; in ipq806x_gmac_probe()
403 regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL, in ipq806x_gmac_probe()
411 switch (gmac->phy_mode) { in ipq806x_gmac_probe()
424 regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val); in ipq806x_gmac_probe()
427 regmap_read(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, &val); in ipq806x_gmac_probe()
428 val &= ~(1 << NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id)); in ipq806x_gmac_probe()
429 switch (gmac->phy_mode) { in ipq806x_gmac_probe()
434 val |= NSS_COMMON_CLK_SRC_CTRL_RGMII(gmac->id) << in ipq806x_gmac_probe()
435 NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id); in ipq806x_gmac_probe()
438 val |= NSS_COMMON_CLK_SRC_CTRL_SGMII(gmac->id) << in ipq806x_gmac_probe()
439 NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id); in ipq806x_gmac_probe()
444 regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val); in ipq806x_gmac_probe()
447 regmap_read(gmac->nss_common, NSS_COMMON_CLK_GATE, &val); in ipq806x_gmac_probe()
448 val |= NSS_COMMON_CLK_GATE_PTP_EN(gmac->id); in ipq806x_gmac_probe()
449 switch (gmac->phy_mode) { in ipq806x_gmac_probe()
454 val |= NSS_COMMON_CLK_GATE_RGMII_RX_EN(gmac->id) | in ipq806x_gmac_probe()
455 NSS_COMMON_CLK_GATE_RGMII_TX_EN(gmac->id); in ipq806x_gmac_probe()
458 val |= NSS_COMMON_CLK_GATE_GMII_RX_EN(gmac->id) | in ipq806x_gmac_probe()
459 NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id); in ipq806x_gmac_probe()
464 regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val); in ipq806x_gmac_probe()
466 if (gmac->phy_mode == PHY_INTERFACE_MODE_SGMII) { in ipq806x_gmac_probe()
476 plat_dat->has_gmac = true; in ipq806x_gmac_probe()
477 plat_dat->bsp_priv = gmac; in ipq806x_gmac_probe()
478 plat_dat->set_clk_tx_rate = ipq806x_gmac_set_clk_tx_rate; in ipq806x_gmac_probe()
479 plat_dat->multicast_filter_bins = 0; in ipq806x_gmac_probe()
480 plat_dat->tx_fifo_size = 8192; in ipq806x_gmac_probe()
481 plat_dat->rx_fifo_size = 8192; in ipq806x_gmac_probe()
483 return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); in ipq806x_gmac_probe()
486 dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n", in ipq806x_gmac_probe()
487 phy_modes(gmac->phy_mode)); in ipq806x_gmac_probe()
488 return -EINVAL; in ipq806x_gmac_probe()
492 { .compatible = "qcom,ipq806x-gmac" },
501 .name = "ipq806x-gmac-dwmac",