Skip to content

Commit 89c9c16

Browse files
SuperDavidWudavem330
authored andcommitted
net: ethernet: stmmac: dwmac-rk: Add rv1108 gmac support
It only supports rmii interface. Add constants and callback functions for the dwmac on rv1108 socs. As can be seen, the base structure is the same, only registers and the bits in them moved slightly. Signed-off-by: David Wu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d3213fb commit 89c9c16

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

Documentation/devicetree/bindings/net/rockchip-dwmac.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Required properties:
1010
"rockchip,rk3366-gmac": found on RK3366 SoCs
1111
"rockchip,rk3368-gmac": found on RK3368 SoCs
1212
"rockchip,rk3399-gmac": found on RK3399 SoCs
13+
"rockchip,rv1108-gmac": found on RV1108 SoCs
1314
- reg: addresses and length of the register sets for the device.
1415
- interrupts: Should contain the GMAC interrupts.
1516
- interrupt-names: Should contain the interrupt names "macirq".

drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,58 @@ static const struct rk_gmac_ops rk3399_ops = {
787787
.set_rmii_speed = rk3399_set_rmii_speed,
788788
};
789789

790+
#define RV1108_GRF_GMAC_CON0 0X0900
791+
792+
/* RV1108_GRF_GMAC_CON0 */
793+
#define RV1108_GMAC_PHY_INTF_SEL_RMII (GRF_CLR_BIT(4) | GRF_CLR_BIT(5) | \
794+
GRF_BIT(6))
795+
#define RV1108_GMAC_FLOW_CTRL GRF_BIT(3)
796+
#define RV1108_GMAC_FLOW_CTRL_CLR GRF_CLR_BIT(3)
797+
#define RV1108_GMAC_SPEED_10M GRF_CLR_BIT(2)
798+
#define RV1108_GMAC_SPEED_100M GRF_BIT(2)
799+
#define RV1108_GMAC_RMII_CLK_25M GRF_BIT(7)
800+
#define RV1108_GMAC_RMII_CLK_2_5M GRF_CLR_BIT(7)
801+
802+
static void rv1108_set_to_rmii(struct rk_priv_data *bsp_priv)
803+
{
804+
struct device *dev = &bsp_priv->pdev->dev;
805+
806+
if (IS_ERR(bsp_priv->grf)) {
807+
dev_err(dev, "%s: Missing rockchip,grf property\n", __func__);
808+
return;
809+
}
810+
811+
regmap_write(bsp_priv->grf, RV1108_GRF_GMAC_CON0,
812+
RV1108_GMAC_PHY_INTF_SEL_RMII);
813+
}
814+
815+
static void rv1108_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)
816+
{
817+
struct device *dev = &bsp_priv->pdev->dev;
818+
819+
if (IS_ERR(bsp_priv->grf)) {
820+
dev_err(dev, "%s: Missing rockchip,grf property\n", __func__);
821+
return;
822+
}
823+
824+
if (speed == 10) {
825+
regmap_write(bsp_priv->grf, RV1108_GRF_GMAC_CON0,
826+
RV1108_GMAC_RMII_CLK_2_5M |
827+
RV1108_GMAC_SPEED_10M);
828+
} else if (speed == 100) {
829+
regmap_write(bsp_priv->grf, RV1108_GRF_GMAC_CON0,
830+
RV1108_GMAC_RMII_CLK_25M |
831+
RV1108_GMAC_SPEED_100M);
832+
} else {
833+
dev_err(dev, "unknown speed value for RMII! speed=%d", speed);
834+
}
835+
}
836+
837+
static const struct rk_gmac_ops rv1108_ops = {
838+
.set_to_rmii = rv1108_set_to_rmii,
839+
.set_rmii_speed = rv1108_set_rmii_speed,
840+
};
841+
790842
#define RK_GRF_MACPHY_CON0 0xb00
791843
#define RK_GRF_MACPHY_CON1 0xb04
792844
#define RK_GRF_MACPHY_CON2 0xb08
@@ -1267,6 +1319,7 @@ static const struct of_device_id rk_gmac_dwmac_match[] = {
12671319
{ .compatible = "rockchip,rk3366-gmac", .data = &rk3366_ops },
12681320
{ .compatible = "rockchip,rk3368-gmac", .data = &rk3368_ops },
12691321
{ .compatible = "rockchip,rk3399-gmac", .data = &rk3399_ops },
1322+
{ .compatible = "rockchip,rv1108-gmac", .data = &rv1108_ops },
12701323
{ }
12711324
};
12721325
MODULE_DEVICE_TABLE(of, rk_gmac_dwmac_match);

0 commit comments

Comments
 (0)