Merge branch 'dwmac-support-for-rockchip-rk3506'

Heiko Stuebner says:

====================
DWMAC support for Rockchip RK3506

Some cleanups to the DT binding for Rockchip variants of the dwmac
and adding the RK3506 support on top.

As well as the driver-glue needed for setting up the correct RMII
speed seitings.
====================

Link: https://patch.msgid.link/20251023111213.298860-1-heiko@sntech.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski
2025-10-24 19:07:48 -07:00
4 changed files with 73 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ select:
- rockchip,rk3366-gmac
- rockchip,rk3368-gmac
- rockchip,rk3399-gmac
- rockchip,rk3506-gmac
- rockchip,rk3528-gmac
- rockchip,rk3568-gmac
- rockchip,rk3576-gmac
@@ -50,6 +51,7 @@ properties:
- rockchip,rv1108-gmac
- items:
- enum:
- rockchip,rk3506-gmac
- rockchip,rk3528-gmac
- rockchip,rk3568-gmac
- rockchip,rk3576-gmac
@@ -148,6 +150,7 @@ allOf:
compatible:
contains:
enum:
- rockchip,rk3506-gmac
- rockchip,rk3528-gmac
then:
properties:

View File

@@ -86,10 +86,14 @@ properties:
- rockchip,rk3328-gmac
- rockchip,rk3366-gmac
- rockchip,rk3368-gmac
- rockchip,rk3399-gmac
- rockchip,rk3506-gmac
- rockchip,rk3528-gmac
- rockchip,rk3568-gmac
- rockchip,rk3576-gmac
- rockchip,rk3588-gmac
- rockchip,rk3399-gmac
- rockchip,rv1108-gmac
- rockchip,rv1126-gmac
- snps,dwmac
- snps,dwmac-3.40a
- snps,dwmac-3.50a

View File

@@ -3296,6 +3296,7 @@ F: drivers/*/*/*rockchip*
F: drivers/*/*rockchip*
F: drivers/clk/rockchip/
F: drivers/i2c/busses/i2c-rk3x.c
F: drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
F: sound/soc/rockchip/
N: rockchip

View File

@@ -827,6 +827,69 @@ static const struct rk_gmac_ops rk3399_ops = {
.set_speed = rk3399_set_speed,
};
#define RK3506_GRF_SOC_CON8 0x0020
#define RK3506_GRF_SOC_CON11 0x002c
#define RK3506_GMAC_RMII_MODE GRF_BIT(1)
#define RK3506_GMAC_CLK_RMII_DIV2 GRF_BIT(3)
#define RK3506_GMAC_CLK_RMII_DIV20 GRF_CLR_BIT(3)
#define RK3506_GMAC_CLK_SELECT_CRU GRF_CLR_BIT(5)
#define RK3506_GMAC_CLK_SELECT_IO GRF_BIT(5)
#define RK3506_GMAC_CLK_RMII_GATE GRF_BIT(2)
#define RK3506_GMAC_CLK_RMII_NOGATE GRF_CLR_BIT(2)
static void rk3506_set_to_rmii(struct rk_priv_data *bsp_priv)
{
unsigned int id = bsp_priv->id, offset;
offset = (id == 1) ? RK3506_GRF_SOC_CON11 : RK3506_GRF_SOC_CON8;
regmap_write(bsp_priv->grf, offset, RK3506_GMAC_RMII_MODE);
}
static const struct rk_reg_speed_data rk3506_reg_speed_data = {
.rmii_10 = RK3506_GMAC_CLK_RMII_DIV20,
.rmii_100 = RK3506_GMAC_CLK_RMII_DIV2,
};
static int rk3506_set_speed(struct rk_priv_data *bsp_priv,
phy_interface_t interface, int speed)
{
unsigned int id = bsp_priv->id, offset;
offset = (id == 1) ? RK3506_GRF_SOC_CON11 : RK3506_GRF_SOC_CON8;
return rk_set_reg_speed(bsp_priv, &rk3506_reg_speed_data,
offset, interface, speed);
}
static void rk3506_set_clock_selection(struct rk_priv_data *bsp_priv,
bool input, bool enable)
{
unsigned int value, offset, id = bsp_priv->id;
offset = (id == 1) ? RK3506_GRF_SOC_CON11 : RK3506_GRF_SOC_CON8;
value = input ? RK3506_GMAC_CLK_SELECT_IO :
RK3506_GMAC_CLK_SELECT_CRU;
value |= enable ? RK3506_GMAC_CLK_RMII_NOGATE :
RK3506_GMAC_CLK_RMII_GATE;
regmap_write(bsp_priv->grf, offset, value);
}
static const struct rk_gmac_ops rk3506_ops = {
.set_to_rmii = rk3506_set_to_rmii,
.set_speed = rk3506_set_speed,
.set_clock_selection = rk3506_set_clock_selection,
.regs_valid = true,
.regs = {
0xff4c8000, /* gmac0 */
0xff4d0000, /* gmac1 */
0x0, /* sentinel */
},
};
#define RK3528_VO_GRF_GMAC_CON 0x0018
#define RK3528_VO_GRF_MACPHY_CON0 0x001c
#define RK3528_VO_GRF_MACPHY_CON1 0x0020
@@ -1809,6 +1872,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,rk3506-gmac", .data = &rk3506_ops },
{ .compatible = "rockchip,rk3528-gmac", .data = &rk3528_ops },
{ .compatible = "rockchip,rk3568-gmac", .data = &rk3568_ops },
{ .compatible = "rockchip,rk3576-gmac", .data = &rk3576_ops },