From: Jonas Karlman <jonas@kwiboo.se>
To: Heiko Stuebner <heiko@sntech.de>
Cc: "andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"robh@kernel.org" <robh@kernel.org>,
"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-rockchip@lists.infradead.org"
<linux-rockchip@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
David Wu <david.wu@rock-chips.com>
Subject: Re: [PATCH 4/4] ethernet: stmmac: dwmac-rk: Add RK3506 GMAC support
Date: Wed, 22 Oct 2025 22:43:41 +0200 [thread overview]
Message-ID: <fe54009a-ee39-43a0-a337-93c46cd7dabe@kwiboo.se> (raw)
In-Reply-To: <20251021224357.195015-5-heiko@sntech.de>
Hi Heiko,
On 10/22/2025 12:43 AM, Heiko Stuebner wrote:
> From: David Wu <david.wu@rock-chips.com>
>
> Add the needed glue blocks for the RK3506-specific setup.
>
> The RK3506 dwmac only supports up to 100MBit with a RMII PHY,
> but no RGMII.
>
> Signed-off-by: David Wu <david.wu@rock-chips.com>
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> ---
> .../net/ethernet/stmicro/stmmac/dwmac-rk.c | 79 +++++++++++++++++++
> 1 file changed, 79 insertions(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 51ea0caf16c1..e1e036e7163c 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -827,6 +827,84 @@ 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
Maybe 0x0020 and 0x002c (lower case x) ?
> +
> +#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_SELET_CRU GRF_CLR_BIT(5)
> +#define RK3506_GMAC_CLK_SELET_IO GRF_BIT(5)
s/SELET/SELECT/
> +
> +#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)
> +{
> + struct device *dev = bsp_priv->dev;
> + unsigned int id = bsp_priv->id, offset;
> +
> + if (IS_ERR(bsp_priv->grf)) {
> + dev_err(dev, "%s: Missing rockchip,grf property\n", __func__);
> + return;
> + }
Please drop this, it is already checked in rk_gmac_setup().
> +
> + offset = (id == 1) ? RK3506_GRF_SOC_CON11 : RK3506_GRF_SOC_CON8;
> + regmap_write(bsp_priv->grf, offset, RK3506_GMAC_RMII_MODE);
> +}
> +
> +static int rk3506_set_speed(struct rk_priv_data *bsp_priv,
> + phy_interface_t interface, int speed)
> +{
> + struct device *dev = bsp_priv->dev;
> + unsigned int val, offset, id = bsp_priv->id;
> +
> + switch (speed) {
> + case 10:
> + val = RK3506_GMAC_CLK_RMII_DIV20;
> + break;
> + case 100:
> + val = RK3506_GMAC_CLK_RMII_DIV2;
> + break;
> + default:
> + dev_err(dev, "unknown speed value for RMII! speed=%d", speed);
> + return -EINVAL;
> + }
> +
> + offset = (id == 1) ? RK3506_GRF_SOC_CON11 : RK3506_GRF_SOC_CON8;
> + regmap_write(bsp_priv->grf, offset, val);
> +
> + return 0;
This should probably be converted to use rk_reg_speed_data with
something like:
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,
};
and:
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_SELET_IO :
> + RK3506_GMAC_CLK_SELET_CRU;
s/SELET/SELECT/
Regards,
Jonas
> + 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
> @@ -1808,6 +1886,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 },
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2025-10-22 20:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-21 22:43 [PATCH 0/4] DWMAC support for Rockchip RK3506 Heiko Stuebner
2025-10-21 22:43 ` [PATCH 1/4] dt-bindings: net: snps,dwmac: move rk3399 line to its correct position Heiko Stuebner
2025-10-22 13:41 ` Andrew Lunn
2025-10-22 17:55 ` Conor Dooley
2025-10-21 22:43 ` [PATCH 2/4] dt-bindings: net: snps,dwmac: Sync list of Rockchip compatibles Heiko Stuebner
2025-10-22 13:41 ` Andrew Lunn
2025-10-22 17:56 ` Conor Dooley
2025-10-21 22:43 ` [PATCH 3/4] dt-bindings: net: rockchip-dwmac: Add compatible string for RK3506 Heiko Stuebner
2025-10-22 13:42 ` Andrew Lunn
2025-10-22 17:56 ` Conor Dooley
2025-10-21 22:43 ` [PATCH 4/4] ethernet: stmmac: dwmac-rk: Add RK3506 GMAC support Heiko Stuebner
2025-10-22 13:44 ` Andrew Lunn
2025-10-22 20:43 ` Jonas Karlman [this message]
2025-10-23 1:26 ` [PATCH 0/4] DWMAC support for Rockchip RK3506 Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fe54009a-ee39-43a0-a337-93c46cd7dabe@kwiboo.se \
--to=jonas@kwiboo.se \
--cc=andrew+netdev@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=david.wu@rock-chips.com \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=heiko@sntech.de \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox