Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5877502pxb; Thu, 27 Jan 2022 01:12:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDOfQfNn4mcPvaHbk3ut9mSLqDwwggLoNRH/byxpYmNUEjxP63zLQWfHJzPVMkjCse99ye X-Received: by 2002:a17:90b:4b8e:: with SMTP id lr14mr1310413pjb.54.1643274731749; Thu, 27 Jan 2022 01:12:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643274731; cv=none; d=google.com; s=arc-20160816; b=OeeRjP3glZMmNPBizjHv1G9QZdBD2w/BBpmcuNanl7QxennfbUCBkdOW4yLpt9K7uJ 5CCNG5XMe/hslwB9/W/zyAT/ESuSUvpAe85I0NKhiy3Fa84caPXIau+MV+DawHLeXTYH J2uD2nZrj0YhujogsZ6sLZxF56k+cP1RVpr05G7xybh9h6VEvDDCf3ytuwB/X3fFMYF2 By4OtB/gdssnZmEYhBNASo2wbOObvNi8BkFu8Kj+vYlAMZBCkJxwNKuviqnQ5Hg/uOss +AW9cmH7VkaLu8eBvDdsU64hu672kUxwskhd7aY5X8GixM0LMEH+up2Sn/ycFTC9Nm6X 3Ltg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2qw2ffgI4gXspAOxurcoOOCktt9Xp6gJ/R//dsFS518=; b=aJsY4alC+a/YRBMOjLorTPh3UbMOMOndDTIbD4+XzsHQWtjx0IAHnc61daILaeGKaz XUuBFed7CCOwQQDrSVSaxGacUlVyT+H3wIGOxG3m7UCG3nJK65vE0Zipv7njwnwY2HY3 Vpsir6UU8mPjwmcoKf7iNEDuB/NCdyGA7lhMbGBf+AWooGGfMs5XWYOWBdNVK01W+tiV KGDFZ+EFPDmanGGKwAGXxtieCHQt8Ze7n6RNgXfoZrN5fOtuOS+NOojgQ9XXY/o3eEI3 f4QgrEO0wFjdsxvC9DylE/8fQy2ydUYFadDulh6CY9mSTUT5KpPOFbyS2Kllay+aQVFj 5o6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w4si1710377pgj.735.2022.01.27.01.12.00; Thu, 27 Jan 2022 01:12:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235002AbiA0B7U (ORCPT + 99 others); Wed, 26 Jan 2022 20:59:20 -0500 Received: from mailgw01.mediatek.com ([60.244.123.138]:41548 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S234786AbiA0B7K (ORCPT ); Wed, 26 Jan 2022 20:59:10 -0500 X-UUID: efa5da12b9f54990af1a8fe571c71682-20220127 X-UUID: efa5da12b9f54990af1a8fe571c71682-20220127 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1421973521; Thu, 27 Jan 2022 09:59:07 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Thu, 27 Jan 2022 09:59:05 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 27 Jan 2022 09:59:04 +0800 From: Biao Huang To: David Miller , Rob Herring , Bartosz Golaszewski , Fabien Parent CC: Jakub Kicinski , Felix Fietkau , "John Crispin" , Sean Wang , Mark Lee , Matthias Brugger , , , , , , Biao Huang , Yinghua Pan , , Macpaul Lin Subject: [PATCH net-next v2 5/9] net: ethernet: mtk-star-emac: add clock pad selection for RMII Date: Thu, 27 Jan 2022 09:58:53 +0800 Message-ID: <20220127015857.9868-6-biao.huang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127015857.9868-1-biao.huang@mediatek.com> References: <20220127015857.9868-1-biao.huang@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch add a new dts property named "mediatek,rmii-rxc" parsing in driver, which will configure MAC to select which pin the RMII reference clock is connected to, TXC or RXC. TXC pad is the default reference clock pin. If user wants to use RXC pad instead, add "mediatek,rmii-rxc" to corresponding device node. Signed-off-by: Biao Huang Signed-off-by: Yinghua Pan --- drivers/net/ethernet/mediatek/mtk_star_emac.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c index a3884beaa3fe..d69f75661e75 100644 --- a/drivers/net/ethernet/mediatek/mtk_star_emac.c +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c @@ -189,6 +189,8 @@ static const char *const mtk_star_clk_names[] = { "core", "reg", "trans" }; #define MTK_PERICFG_REG_NIC_CFG_CON_V2 0x0c10 #define MTK_PERICFG_REG_NIC_CFG_CON_CFG_INTF GENMASK(3, 0) #define MTK_PERICFG_BIT_NIC_CFG_CON_RMII 1 +#define MTK_PERICFG_BIT_NIC_CFG_CON_CLK BIT(0) +#define MTK_PERICFG_BIT_NIC_CFG_CON_CLK_V2 BIT(8) /* Represents the actual structure of descriptors used by the MAC. We can * reuse the same structure for both TX and RX - the layout is the same, only @@ -265,6 +267,7 @@ struct mtk_star_priv { int speed; int duplex; int pause; + bool rmii_rxc; const struct mtk_star_compat *compat_data; @@ -1528,6 +1531,8 @@ static int mtk_star_probe(struct platform_device *pdev) return -ENODEV; } + priv->rmii_rxc = of_property_read_bool(of_node, "mediatek,rmii-rxc"); + if (priv->compat_data->set_interface_mode) { ret = priv->compat_data->set_interface_mode(ndev); if (ret) { @@ -1571,17 +1576,25 @@ static int mt8516_set_interface_mode(struct net_device *ndev) { struct mtk_star_priv *priv = netdev_priv(ndev); struct device *dev = mtk_star_get_dev(priv); - unsigned int intf_val; + unsigned int intf_val, ret, rmii_rxc; switch (priv->phy_intf) { case PHY_INTERFACE_MODE_RMII: intf_val = MTK_PERICFG_BIT_NIC_CFG_CON_RMII; + rmii_rxc = priv->rmii_rxc ? 0 : MTK_PERICFG_BIT_NIC_CFG_CON_CLK; break; default: dev_err(dev, "This interface not supported\n"); return -EINVAL; } + ret = regmap_update_bits(priv->pericfg, + MTK_PERICFG_REG_NIC_CFG1_CON, + MTK_PERICFG_BIT_NIC_CFG_CON_CLK, + rmii_rxc); + if (ret) + return ret; + return regmap_update_bits(priv->pericfg, MTK_PERICFG_REG_NIC_CFG0_CON, MTK_PERICFG_REG_NIC_CFG_CON_CFG_INTF, @@ -1597,6 +1610,7 @@ static int mt8365_set_interface_mode(struct net_device *ndev) switch (priv->phy_intf) { case PHY_INTERFACE_MODE_RMII: intf_val = MTK_PERICFG_BIT_NIC_CFG_CON_RMII; + intf_val |= priv->rmii_rxc ? 0 : MTK_PERICFG_BIT_NIC_CFG_CON_CLK_V2; break; default: dev_err(dev, "This interface not supported\n"); @@ -1605,7 +1619,8 @@ static int mt8365_set_interface_mode(struct net_device *ndev) return regmap_update_bits(priv->pericfg, MTK_PERICFG_REG_NIC_CFG_CON_V2, - MTK_PERICFG_REG_NIC_CFG_CON_CFG_INTF, + MTK_PERICFG_REG_NIC_CFG_CON_CFG_INTF | + MTK_PERICFG_BIT_NIC_CFG_CON_CLK_V2, intf_val); } -- 2.25.1