From patchwork Mon May 17 15:40:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12262281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97CFDC433B4 for ; Mon, 17 May 2021 15:41:05 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55AE361108 for ; Mon, 17 May 2021 15:41:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55AE361108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gaBrAKRPcl/R1nCNDOBtwvrYLI46mEvvOPEAjLXmBiY=; b=mkPY+wtz/HqegETtHRfXPneQN i6vX4nx60+5PO7CwfpOaKGQxxrsYd/HSkyDuGuG3+4g7FtBZGu1EesCo7L2k42ulSl0NPWdPPeZle dRQ/vf1RQDE11OinPWgubn7kvzVLxMwvXy6Ayru5d/RziXgDYEfkAhWvx260Q3owjt7ozx96aYrEK YBw5nzHSz4CJBuag6NjDH4bLTGXCFFpPiJ71Xvjrbu9iu5PpsFAsURtWW7DJuuTPvEaiBFkdxeNxC MTMCyL76+FmAaXgV+KdMyfLK0liZdNS802nXbgPkh65xcx32pnv2IO8m9rmmUR1RMPZd1ASpRo9gA 2z/V1MSXQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lifMZ-00FRMF-W6; Mon, 17 May 2021 15:41:00 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lifMY-00FRLr-2S for linux-rockchip@desiato.infradead.org; Mon, 17 May 2021 15:40:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=sdrl07gKaMpUO6Gphj9s3ynLYbNBLTzPcWa3OaDRiPE=; b=xI+gL01LQFMqrgxtnzhX7vs7sF dpRj6Sq+J6D45C2BkXc4J2iXk7mSJlnFV5Ab1wSxq/xJqHuqySDDXkmoRC7NNA0kxOL4UPMZCjyr1 uN8dqQyWP8AQ3wtzfJxujFtGcLcyHDYz/JH6HSURgtb4JqaClCmns6c/iA8z/YAWImObanhayENV+ XOBLnwwjlGjFjz/xhAuc0HbeAvJq3DB+A2emws0s6njSVLAnBIg34ikdYpJTAVxVWCKH9XXyrt+q+ 2crLeTqt6bksNp5KQ+4334DK7IApXZko7nb613QyQhnAf8LpBATyjaGGOEIMKR6HeSKAeEuNDtYdW s+ebcpeg==; Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lifMV-00Dw1B-KS for linux-rockchip@lists.infradead.org; Mon, 17 May 2021 15:40:56 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id DCA571F423BC From: Ezequiel Garcia To: netdev@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org Cc: Jose Abreu , Heiko Stuebner , "David S . Miller" , Jakub Kicinski , Peter Geis , Kever Yang , David Wu , Rob Herring , Johan Jonker , Chen-Yu Tsai , Ezequiel Garcia Subject: [PATCH v3 net-next 1/4] net: stmmac: Don't set has_gmac if has_gmac4 is set Date: Mon, 17 May 2021 12:40:34 -0300 Message-Id: <20210517154037.37946-2-ezequiel@collabora.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210517154037.37946-1-ezequiel@collabora.com> References: <20210517154037.37946-1-ezequiel@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210517_084055_819324_8F8D563F X-CRM114-Status: GOOD ( 10.67 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Some Rockchip platforms have a GMAC4 core, and therefore 'plat_stmmacenet_data.has_gmac' shouldn't be set if 'plat_stmmacenet_data.has_gmac4' is set. Signed-off-by: Ezequiel Garcia --- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 584db4ce6e39..56034f21fcef 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c @@ -1448,7 +1448,11 @@ static int rk_gmac_probe(struct platform_device *pdev) if (IS_ERR(plat_dat)) return PTR_ERR(plat_dat); - plat_dat->has_gmac = true; + /* If the stmmac is not already selected as gmac4, + * then make sure we fallback to gmac. + */ + if (!plat_dat->has_gmac4) + plat_dat->has_gmac = true; plat_dat->fix_mac_speed = rk_fix_speed; plat_dat->bsp_priv = rk_gmac_setup(pdev, plat_dat, data); From patchwork Mon May 17 15:40:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12262285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D14EEC433B4 for ; Mon, 17 May 2021 15:41:10 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9911F61108 for ; Mon, 17 May 2021 15:41:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9911F61108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4Q5cb0F40m0ZlsQ7zcY/vhiDI5DkqC2Qn0UhRbjKa34=; b=bsw9UC3rbtj/1cejvtY+LvQuc wKgq31dlyMVA00mSExiHJZ290c/f+RNm8Xwom8E1AP6hp/+oSyL9n+Ze6mKGzPTKroKCc1lJeQlKF 1cK9GoTPWYmvvEuufgLD3Ly0VMRTlwffcqFU5VGq0VR+RR9oM/Ukz4Qi1rNDKZkN21GYXXw0CIEsS k4o3935pZ1KyV/YslBmyNIDganwv9OH2tHMY3YjmPhxYhWdcmBr9pCw99G6Dg8WCFh5mkFkUwlvK0 /gZqDm6GhYp7raC3DzKBHgy3RWoh9cSP6C+8NJF4MdTzetr30HF7nu1n0GoirXuPnIfsfsX4Mlben McCjCLrjA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lifMe-00FRN7-B0; Mon, 17 May 2021 15:41:04 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lifMc-00FRMT-Av for linux-rockchip@desiato.infradead.org; Mon, 17 May 2021 15:41:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=+WABODUOkGFIrZMOr06ZD0FvrHOxQ+T9otH4rfZo5jg=; b=ojSUjNtNMKlcYRVM1PNVD2n7w3 /FnOcB23Q8Y+0TYun4+9cATjdALVe1xUnNEtyuWuuAde3DMmsSjQk7K6dX/VJtdj2phK7ljTB/HUT yrFWsS9GgpQ3Q1lBmadunkX27R3tRxNVKExvVJ+2IxZqAXXWTuP+CRpLF76gRysuNWO7Nw5ZpWRRK ulaGhmKAVVL6+WpiaEk4Xfbcj81dxnqE+osHNZzndR7yZj1hUfhm5W+Qlo9XWZrlpkk0RnUbOoK7R k4KVzjMR+OIwZjlgzJ6F4WP/A8f1TdJFfyGKHfRGhUWP8ikyBr1BP7oFtrhPewWQt/7wqy0QZwHwt xu3u/Z6A==; Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lifMZ-00Dw1f-OE for linux-rockchip@lists.infradead.org; Mon, 17 May 2021 15:41:01 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 8D5C71F40323 From: Ezequiel Garcia To: netdev@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org Cc: Jose Abreu , Heiko Stuebner , "David S . Miller" , Jakub Kicinski , Peter Geis , Kever Yang , David Wu , Rob Herring , Johan Jonker , Chen-Yu Tsai , Ezequiel Garcia Subject: [PATCH v3 net-next 2/4] net: stmmac: dwmac-rk: Check platform-specific ops Date: Mon, 17 May 2021 12:40:35 -0300 Message-Id: <20210517154037.37946-3-ezequiel@collabora.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210517154037.37946-1-ezequiel@collabora.com> References: <20210517154037.37946-1-ezequiel@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210517_084059_935854_A5015C37 X-CRM114-Status: GOOD ( 11.17 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org From: David Wu Add a check for non-null struct rk_gmac_ops for the configured PHY interface mode, failing if unsupported. Signed-off-by: David Wu [Ezequiel: Refactor so it fails if unsupported] Signed-off-by: Ezequiel Garcia --- .../net/ethernet/stmicro/stmmac/dwmac-rk.c | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 56034f21fcef..791c13d47a35 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c @@ -1342,11 +1342,36 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev, return bsp_priv; } +static int rk_gmac_check_ops(struct rk_priv_data *bsp_priv) +{ + switch (bsp_priv->phy_iface) { + case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_TXID: + if (!bsp_priv->ops->set_to_rgmii) + return -EINVAL; + break; + case PHY_INTERFACE_MODE_RMII: + if (!bsp_priv->ops->set_to_rmii) + return -EINVAL; + break; + default: + dev_err(&bsp_priv->pdev->dev, + "unsupported interface %d", bsp_priv->phy_iface); + } + return 0; +} + static int rk_gmac_powerup(struct rk_priv_data *bsp_priv) { int ret; struct device *dev = &bsp_priv->pdev->dev; + ret = rk_gmac_check_ops(bsp_priv); + if (ret) + return ret; + ret = gmac_clk_enable(bsp_priv, true); if (ret) return ret; @@ -1417,10 +1442,12 @@ static void rk_fix_speed(void *priv, unsigned int speed) case PHY_INTERFACE_MODE_RGMII_ID: case PHY_INTERFACE_MODE_RGMII_RXID: case PHY_INTERFACE_MODE_RGMII_TXID: - bsp_priv->ops->set_rgmii_speed(bsp_priv, speed); + if (bsp_priv->ops->set_rgmii_speed) + bsp_priv->ops->set_rgmii_speed(bsp_priv, speed); break; case PHY_INTERFACE_MODE_RMII: - bsp_priv->ops->set_rmii_speed(bsp_priv, speed); + if (bsp_priv->ops->set_rmii_speed) + bsp_priv->ops->set_rmii_speed(bsp_priv, speed); break; default: dev_err(dev, "unsupported interface %d", bsp_priv->phy_iface); From patchwork Mon May 17 15:40:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12262287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E241C433B4 for ; Mon, 17 May 2021 15:41:16 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF42B61006 for ; Mon, 17 May 2021 15:41:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF42B61006 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3Dgk46gcA4T9X5Nuu6nDrULvS2jGeM17i+eWI1R/U0Y=; b=Vr0EMLFDyjmdcPUAA8N6SB5cB LNDvLq/ulQBOewFIEg1uwtHH17wr85/szo2LN3Bx8YWF3h2Rqd7CkN8pHgezM1e9iVGHOOstVuDQQ jGbQkFKm9Sp8YSIv5osGnq4fI9r26BqetaVR2uLyr/YZfrCtmNRZlLZZis5Ge3ZwlQgs7Tg0lOxWi 8WYu7sdDlx8NFzY5N0q4wnbi2BR12P0dvkFv0OrcjHSC4AVy2jo1ZvhVFbpavR0mSkh87gC0PBAC+ kfYNFy0wwta8hM8bY95CJp2/pXoDefTsjhb6v5eEs9Viz+FMnYepRc95458CrpOJR+ABUx3gkn5nF NXto6spuA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lifMj-00FROr-Uc; Mon, 17 May 2021 15:41:10 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lifMh-00FROA-Eh for linux-rockchip@desiato.infradead.org; Mon, 17 May 2021 15:41:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=EjVhrqSVOUWprwwTE51AgIdnbah59cEq0mxYsG8NUJQ=; b=IeJ+sHS/BEynpcEWHUQfQJzoWg b2MGz+szhOI/obSRmkGa/OrPAHzu4HxU6kZCc0Lvgh7wFQZgzcBMG0GrG2kIPf0an890nyrHylnjW CkQH/o0Ga9/Ej3gL+uIzmRPOLOoSVDXE6aDJQmS1F9zv6TTEUJCuJD7V9sEDPfh/gb2h1VP4Qovbp JmzD+gjRlnMQGhTGrjchmA2y+tX+BWTE0/D4eVlK6HvqBrpDwdpNyvVWU5/42ncQGNegQP+JKvSFC JpDl6OZkA6j3bJb+IYU0OXv8crIqxk9Snkfcr5JwNg0aa0EICsU8e+1taeARcCIiakdgT2qJrEh9X kHytezBA==; Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lifMe-00Dw3L-TJ for linux-rockchip@lists.infradead.org; Mon, 17 May 2021 15:41:06 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 3BE141F423BB From: Ezequiel Garcia To: netdev@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org Cc: Jose Abreu , Heiko Stuebner , "David S . Miller" , Jakub Kicinski , Peter Geis , Kever Yang , David Wu , Rob Herring , Johan Jonker , Chen-Yu Tsai , Ezequiel Garcia Subject: [PATCH v3 net-next 3/4] dt-bindings: net: rockchip-dwmac: add rk3568 compatible string Date: Mon, 17 May 2021 12:40:36 -0300 Message-Id: <20210517154037.37946-4-ezequiel@collabora.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210517154037.37946-1-ezequiel@collabora.com> References: <20210517154037.37946-1-ezequiel@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210517_084105_098068_0E820745 X-CRM114-Status: UNSURE ( 7.05 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Add compatible string for RK3568 gmac, and constrain it to be compatible with Synopsys dwmac 4.20a. Signed-off-by: Ezequiel Garcia --- .../bindings/net/rockchip-dwmac.yaml | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml b/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml index 34a660ad6b30..083623c8d718 100644 --- a/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml +++ b/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml @@ -24,6 +24,7 @@ select: - rockchip,rk3366-gmac - rockchip,rk3368-gmac - rockchip,rk3399-gmac + - rockchip,rk3568-gmac - rockchip,rv1108-gmac required: - compatible @@ -33,18 +34,23 @@ allOf: properties: compatible: - items: - - enum: - - rockchip,px30-gmac - - rockchip,rk3128-gmac - - rockchip,rk3228-gmac - - rockchip,rk3288-gmac - - rockchip,rk3308-gmac - - rockchip,rk3328-gmac - - rockchip,rk3366-gmac - - rockchip,rk3368-gmac - - rockchip,rk3399-gmac - - rockchip,rv1108-gmac + oneOf: + - items: + - enum: + - rockchip,px30-gmac + - rockchip,rk3128-gmac + - rockchip,rk3228-gmac + - rockchip,rk3288-gmac + - rockchip,rk3308-gmac + - rockchip,rk3328-gmac + - rockchip,rk3366-gmac + - rockchip,rk3368-gmac + - rockchip,rk3399-gmac + - rockchip,rv1108-gmac + - items: + - enum: + - rockchip,rk3568-gmac + - const: snps,dwmac-4.20a clocks: minItems: 5 From patchwork Mon May 17 15:40:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12262289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F8ACC433B4 for ; Mon, 17 May 2021 15:41:22 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7777761006 for ; Mon, 17 May 2021 15:41:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7777761006 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rdqPbSM70X6EvEE8pG1IL5KqgMmM1NU9rNSyWISWKVM=; b=kYWMIZSwdlQdLHr6aQAG/G09D kHgbTulHZXTC8EuM5y8jrTbOmh16Jte4x7Lr03W1NfW6DPaVZqbWtDLzcShSzIo+1rBEg7AVQiGPK l552GWKP0EwoDbvLupLxYPL0FJ8bn4o/DF7rgCV0EchlIF1/uSvASLMsCUXI7JAR/4wL450Cpd1jy r4TzQhABi9wvnrMW/FLVYVv/iLmjp4vXdi9jVmoiGPpgG3KLdRbuuBatdYb6HEQdei8IYiFiSJvYj YeCkEEUFE65jL9Mylb1CyfcyrmdEZqjQbZF9BxlJE7Oa+fcFjIrIPZcgSVWPe+zOIGs0+v5wbUB+y xtXTwh+0A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lifMo-00FRQR-T8; Mon, 17 May 2021 15:41:15 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lifMm-00FRPn-Pc for linux-rockchip@desiato.infradead.org; Mon, 17 May 2021 15:41:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=yHrQCScKRPAUV4Ww3ydXaHjQxax4H6xbfMTd08rzNZI=; b=pvLBWTZsS+yz4b7Kdctcx2fyhl vPoPvK5DvPacfMHECQ6xcXDFqRt+nhd9go41G/sRbJOdiGSgpUBUI7M0luR/HIsj00uKJB1E3j32A 3/TSwjl7zb7S98QIa5ZXo6cCLiMD8XnXC7nOOz4V6rzAO2QgNvnje9Xb69J9nSiFpGS80sJKv9nfv gRJs6pOfupB02CXlZaWPackyjc8PZhOUcMiNQrA8L8ezznCEFFyz/CH23V91oW0orGKNE7Hw4tdbl bUM4UkB2E8n6L2YMpia+05YqAv2C0CpXnH1S32gUzir2o2cpe+AMeZu074pZqQodQgmxkBL/cwjrm HsmSUxlA==; Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lifMj-00Dw3j-Qk for linux-rockchip@lists.infradead.org; Mon, 17 May 2021 15:41:11 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 60F471F423BD From: Ezequiel Garcia To: netdev@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org Cc: Jose Abreu , Heiko Stuebner , "David S . Miller" , Jakub Kicinski , Peter Geis , Kever Yang , David Wu , Rob Herring , Johan Jonker , Chen-Yu Tsai , Ezequiel Garcia Subject: [PATCH v3 net-next 4/4] net: stmmac: Add RK3566/RK3568 SoC support Date: Mon, 17 May 2021 12:40:37 -0300 Message-Id: <20210517154037.37946-5-ezequiel@collabora.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210517154037.37946-1-ezequiel@collabora.com> References: <20210517154037.37946-1-ezequiel@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210517_084110_154178_C235AC43 X-CRM114-Status: GOOD ( 15.90 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org From: David Wu Add constants and callback functions for the dwmac present on RK3566/RK3568 SoCs. RK3568 has two MACs, and RK3566 just one, but it's otherwise the same IP core. Signed-off-by: David Wu [Ezequiel: Separate rk3566-gmac support] Signed-off-by: Ezequiel Garcia --- .../net/ethernet/stmicro/stmmac/dwmac-rk.c | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 791c13d47a35..280ac0129572 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c @@ -33,11 +33,13 @@ struct rk_gmac_ops { void (*set_rgmii_speed)(struct rk_priv_data *bsp_priv, int speed); void (*set_rmii_speed)(struct rk_priv_data *bsp_priv, int speed); void (*integrated_phy_powerup)(struct rk_priv_data *bsp_priv); + u32 regs[]; }; struct rk_priv_data { struct platform_device *pdev; phy_interface_t phy_iface; + int id; struct regulator *regulator; bool suspended; const struct rk_gmac_ops *ops; @@ -996,6 +998,107 @@ static const struct rk_gmac_ops rk3399_ops = { .set_rmii_speed = rk3399_set_rmii_speed, }; +#define RK3568_GRF_GMAC0_CON0 0x0380 +#define RK3568_GRF_GMAC0_CON1 0x0384 +#define RK3568_GRF_GMAC1_CON0 0x0388 +#define RK3568_GRF_GMAC1_CON1 0x038c + +/* RK3568_GRF_GMAC0_CON1 && RK3568_GRF_GMAC1_CON1 */ +#define RK3568_GMAC_PHY_INTF_SEL_RGMII \ + (GRF_BIT(4) | GRF_CLR_BIT(5) | GRF_CLR_BIT(6)) +#define RK3568_GMAC_PHY_INTF_SEL_RMII \ + (GRF_CLR_BIT(4) | GRF_CLR_BIT(5) | GRF_BIT(6)) +#define RK3568_GMAC_FLOW_CTRL GRF_BIT(3) +#define RK3568_GMAC_FLOW_CTRL_CLR GRF_CLR_BIT(3) +#define RK3568_GMAC_RXCLK_DLY_ENABLE GRF_BIT(1) +#define RK3568_GMAC_RXCLK_DLY_DISABLE GRF_CLR_BIT(1) +#define RK3568_GMAC_TXCLK_DLY_ENABLE GRF_BIT(0) +#define RK3568_GMAC_TXCLK_DLY_DISABLE GRF_CLR_BIT(0) + +/* RK3568_GRF_GMAC0_CON0 && RK3568_GRF_GMAC1_CON0 */ +#define RK3568_GMAC_CLK_RX_DL_CFG(val) HIWORD_UPDATE(val, 0x7F, 8) +#define RK3568_GMAC_CLK_TX_DL_CFG(val) HIWORD_UPDATE(val, 0x7F, 0) + +static void rk3568_set_to_rgmii(struct rk_priv_data *bsp_priv, + int tx_delay, int rx_delay) +{ + struct device *dev = &bsp_priv->pdev->dev; + u32 con0, con1; + + if (IS_ERR(bsp_priv->grf)) { + dev_err(dev, "Missing rockchip,grf property\n"); + return; + } + + con0 = (bsp_priv->id == 1) ? RK3568_GRF_GMAC1_CON0 : + RK3568_GRF_GMAC0_CON0; + con1 = (bsp_priv->id == 1) ? RK3568_GRF_GMAC1_CON1 : + RK3568_GRF_GMAC0_CON1; + + regmap_write(bsp_priv->grf, con0, + RK3568_GMAC_CLK_RX_DL_CFG(rx_delay) | + RK3568_GMAC_CLK_TX_DL_CFG(tx_delay)); + + regmap_write(bsp_priv->grf, con1, + RK3568_GMAC_PHY_INTF_SEL_RGMII | + RK3568_GMAC_RXCLK_DLY_ENABLE | + RK3568_GMAC_TXCLK_DLY_ENABLE); +} + +static void rk3568_set_to_rmii(struct rk_priv_data *bsp_priv) +{ + struct device *dev = &bsp_priv->pdev->dev; + u32 con1; + + if (IS_ERR(bsp_priv->grf)) { + dev_err(dev, "%s: Missing rockchip,grf property\n", __func__); + return; + } + + con1 = (bsp_priv->id == 1) ? RK3568_GRF_GMAC1_CON1 : + RK3568_GRF_GMAC0_CON1; + regmap_write(bsp_priv->grf, con1, RK3568_GMAC_PHY_INTF_SEL_RMII); +} + +static void rk3568_set_gmac_speed(struct rk_priv_data *bsp_priv, int speed) +{ + struct device *dev = &bsp_priv->pdev->dev; + unsigned long rate; + int ret; + + switch (speed) { + case 10: + rate = 2500000; + break; + case 100: + rate = 25000000; + break; + case 1000: + rate = 125000000; + break; + default: + dev_err(dev, "unknown speed value for GMAC speed=%d", speed); + return; + } + + ret = clk_set_rate(bsp_priv->clk_mac_speed, rate); + if (ret) + dev_err(dev, "%s: set clk_mac_speed rate %ld failed %d\n", + __func__, rate, ret); +} + +static const struct rk_gmac_ops rk3568_ops = { + .set_to_rgmii = rk3568_set_to_rgmii, + .set_to_rmii = rk3568_set_to_rmii, + .set_rgmii_speed = rk3568_set_gmac_speed, + .set_rmii_speed = rk3568_set_gmac_speed, + .regs = { + 0xfe2a0000, /* gmac0 */ + 0xfe010000, /* gmac1 */ + 0x0, /* sentinel */ + }, +}; + #define RV1108_GRF_GMAC_CON0 0X0900 /* RV1108_GRF_GMAC_CON0 */ @@ -1264,6 +1367,7 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev, { struct rk_priv_data *bsp_priv; struct device *dev = &pdev->dev; + struct resource *res; int ret; const char *strings = NULL; int value; @@ -1275,6 +1379,22 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev, of_get_phy_mode(dev->of_node, &bsp_priv->phy_iface); bsp_priv->ops = ops; + /* Some SoCs have multiple MAC controllers, which need + * to be distinguished. + */ + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (res) { + int i = 0; + + while (ops->regs[i]) { + if (ops->regs[i] == res->start) { + bsp_priv->id = i; + break; + } + i++; + } + } + bsp_priv->regulator = devm_regulator_get_optional(dev, "phy"); if (IS_ERR(bsp_priv->regulator)) { if (PTR_ERR(bsp_priv->regulator) == -EPROBE_DEFER) { @@ -1561,6 +1681,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,rk3568-gmac", .data = &rk3568_ops }, { .compatible = "rockchip,rv1108-gmac", .data = &rv1108_ops }, { } };