mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
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. Change-Id: I91e6c812b8e3dc640884d66b41490f5e588a3f28 Signed-off-by: David Wu <david.wu@rock-chips.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -3,9 +3,14 @@ Rockchip SoC RK3288 10/100/1000 Ethernet driver(GMAC)
|
||||
The device node has following properties.
|
||||
|
||||
Required properties:
|
||||
- compatible: Can be one of "rockchip,rk3228-gmac", "rockchip,rk3288-gmac",
|
||||
"rockchip,rk3328-gmac", "rockchip,rk3366-gmac",
|
||||
"rockchip,rk3368-gmac", "rockchip,rk3399-gmac"
|
||||
- compatible: should be "rockchip,<name>-gamc"
|
||||
"rockchip,rk3228-gmac": found on RK322x SoCs
|
||||
"rockchip,rk3288-gmac": found on RK3288 SoCs
|
||||
"rockchip,rk3328-gmac": found on RK3328 SoCs
|
||||
"rockchip,rk3366-gmac": found on RK3366 SoCs
|
||||
"rockchip,rk3368-gmac": found on RK3368 SoCs
|
||||
"rockchip,rk3399-gmac": found on RK3399 SoCs
|
||||
"rockchip,rv1108-gmac": found on RV1108 SoCs
|
||||
- reg: addresses and length of the register sets for the device.
|
||||
- interrupts: Should contain the GMAC interrupts.
|
||||
- interrupt-names: Should contain the interrupt names "macirq".
|
||||
|
||||
@@ -787,6 +787,58 @@ static const struct rk_gmac_ops rk3399_ops = {
|
||||
.set_rmii_speed = rk3399_set_rmii_speed,
|
||||
};
|
||||
|
||||
#define RV1108_GRF_GMAC_CON0 0X0900
|
||||
|
||||
/* RV1108_GRF_GMAC_CON0 */
|
||||
#define RV1108_GMAC_PHY_INTF_SEL_RMII (GRF_CLR_BIT(4) | GRF_CLR_BIT(5) | \
|
||||
GRF_BIT(6))
|
||||
#define RV1108_GMAC_FLOW_CTRL GRF_BIT(3)
|
||||
#define RV1108_GMAC_FLOW_CTRL_CLR GRF_CLR_BIT(3)
|
||||
#define RV1108_GMAC_SPEED_10M GRF_CLR_BIT(2)
|
||||
#define RV1108_GMAC_SPEED_100M GRF_BIT(2)
|
||||
#define RV1108_GMAC_RMII_CLK_25M GRF_BIT(7)
|
||||
#define RV1108_GMAC_RMII_CLK_2_5M GRF_CLR_BIT(7)
|
||||
|
||||
static void rv1108_set_to_rmii(struct rk_priv_data *bsp_priv)
|
||||
{
|
||||
struct device *dev = &bsp_priv->pdev->dev;
|
||||
|
||||
if (IS_ERR(bsp_priv->grf)) {
|
||||
dev_err(dev, "%s: Missing rockchip,grf property\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
regmap_write(bsp_priv->grf, RV1108_GRF_GMAC_CON0,
|
||||
RV1108_GMAC_PHY_INTF_SEL_RMII);
|
||||
}
|
||||
|
||||
static void rv1108_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)
|
||||
{
|
||||
struct device *dev = &bsp_priv->pdev->dev;
|
||||
|
||||
if (IS_ERR(bsp_priv->grf)) {
|
||||
dev_err(dev, "%s: Missing rockchip,grf property\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (speed == 10) {
|
||||
regmap_write(bsp_priv->grf, RV1108_GRF_GMAC_CON0,
|
||||
RV1108_GMAC_RMII_CLK_2_5M |
|
||||
RV1108_GMAC_SPEED_10M);
|
||||
} else if (speed == 100) {
|
||||
regmap_write(bsp_priv->grf, RV1108_GRF_GMAC_CON0,
|
||||
RV1108_GMAC_RMII_CLK_25M |
|
||||
RV1108_GMAC_SPEED_100M);
|
||||
} else {
|
||||
dev_err(dev, "unknown speed value for RMII! speed=%d", speed);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct rk_gmac_ops rv1108_ops = {
|
||||
.set_to_rmii = rv1108_set_to_rmii,
|
||||
.set_rmii_speed = rv1108_set_rmii_speed,
|
||||
};
|
||||
|
||||
#define RK_GRF_MACPHY_CON0 0xb00
|
||||
#define RK_GRF_MACPHY_CON1 0xb04
|
||||
#define RK_GRF_MACPHY_CON2 0xb08
|
||||
@@ -1295,6 +1347,7 @@ static const struct of_device_id rk_gmac_dwmac_match[] = {
|
||||
{ .compatible = "rockchip,rk3366-gmac", .data = &rk3366_ops },
|
||||
{ .compatible = "rockchip,rk3368-gmac", .data = &rk3368_ops },
|
||||
{ .compatible = "rockchip,rk3399-gmac", .data = &rk3399_ops },
|
||||
{ .compatible = "rockchip,rv1108-gmac", .data = &rv1108_ops },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, rk_gmac_dwmac_match);
|
||||
|
||||
Reference in New Issue
Block a user