Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1240748pxb; Fri, 21 Jan 2022 13:08:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVe2ZJE1UEwazttra+VOEhRomMeQ5N9j07D0w/fWo1+l5uEE/H0hYTS3slsj1AhFVq2Vy2 X-Received: by 2002:a17:90b:1bd0:: with SMTP id oa16mr1339157pjb.95.1642799289779; Fri, 21 Jan 2022 13:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642799289; cv=none; d=google.com; s=arc-20160816; b=uVyXfDaQ+ceYW3wmfnsqZPTiogICQ54uCw5V1WdqraZu3LM2zqMCP8QUdkfp5OfkHk oZyB8/c1hbBJaBGKB1LXeXbPY8o+z4mWFIJ3ZKIOI9IOYi+617EZVryAHQafLucqjYL2 IgpEtd8BU7kng+r1gcpIxxvZsMfTd1xYutjbk819v/CVkfuiVz+Fb1CE4TDJpD9QX3DH zitBiMS8PtoVp94IzX3qQ6vnvdxrL6g78QYYJwzLNYAyenNG+Od1aZe4SRB07KD5w2xm GQnsoAgDwUqjwU+ZH3CaEVe7qAd1lYbdfOoCaVJhREH05+LgWsjhqaBMh/Okj+gN+M55 rnNg== 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=53BUcnxOK2ZLx7N4BEyMJun8E+PkJUY5Ewjc8eHvHS4=; b=xLfOmeLlG6hvydsyu6XRhSgIYwK6V+SO5Hl7tEzLSVBGoJTkyLMFrqNO7cjQBnGS2F 9sDDxjj7A+jjvYm+VTt/tH2ntsH2oLFmXPVnBKdN7AzPVVCRiBJvgYkS/kgKpO/Xwc6y ywQ2FlW8RUd2NZEI9LnlxF8aqp5cxvWVe80jsKbjQT6pLX7qmblRsqqm1iV0XQ5Y0j/u FEKTqaN+xLdnokjE0uryrqgq28se8a2fdi0fbAZ5wueNwPq5kGRfRw/K5gkDmerRVpdw y2qc46V+ijSGI1D6IVQqa6wtNQnCIJFrgsx46DNW3QB215tYJxvCjoXu2+Kbe2zLZgoU 6IUw== 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 k27si3336108pgf.723.2022.01.21.13.07.58; Fri, 21 Jan 2022 13:08:09 -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 S1358962AbiATHC5 (ORCPT + 99 others); Thu, 20 Jan 2022 02:02:57 -0500 Received: from mailgw01.mediatek.com ([60.244.123.138]:60306 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1358868AbiATHCn (ORCPT ); Thu, 20 Jan 2022 02:02:43 -0500 X-UUID: a7202e029b854287956135aa83f6173d-20220120 X-UUID: a7202e029b854287956135aa83f6173d-20220120 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 725971310; Thu, 20 Jan 2022 15:02:41 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) 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, 20 Jan 2022 15:02:38 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 20 Jan 2022 15:02:37 +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 v1 8/9] net: ethernet: mtk-star-emac: add support for MII interface Date: Thu, 20 Jan 2022 15:02:25 +0800 Message-ID: <20220120070226.1492-9-biao.huang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220120070226.1492-1-biao.huang@mediatek.com> References: <20220120070226.1492-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 Add support for MII interface. If user wants to use MII, assign "MII" to "phy-mode" property in dts. Signed-off-by: Biao Huang Signed-off-by: Yinghua Pan --- drivers/net/ethernet/mediatek/mtk_star_emac.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c index e37fa2cb5433..08a372848651 100644 --- a/drivers/net/ethernet/mediatek/mtk_star_emac.c +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c @@ -193,6 +193,7 @@ static const char *const mtk_star_clk_names[] = { "core", "reg", "trans" }; #define MTK_PERICFG_REG_NIC_CFG1_CON 0x03c8 #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_MII 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) @@ -1463,6 +1464,7 @@ static int mtk_star_set_timing(struct mtk_star_priv *priv) unsigned int delay_val = 0; switch (priv->phy_intf) { + case PHY_INTERFACE_MODE_MII: case PHY_INTERFACE_MODE_RMII: delay_val |= FIELD_PREP(MTK_STAR_BIT_INV_RX_CLK, priv->rx_inv); delay_val |= FIELD_PREP(MTK_STAR_BIT_INV_TX_CLK, priv->tx_inv); @@ -1545,7 +1547,8 @@ static int mtk_star_probe(struct platform_device *pdev) ret = of_get_phy_mode(of_node, &priv->phy_intf); if (ret) { return ret; - } else if (priv->phy_intf != PHY_INTERFACE_MODE_RMII) { + } else if (priv->phy_intf != PHY_INTERFACE_MODE_RMII && + priv->phy_intf != PHY_INTERFACE_MODE_MII) { dev_err(dev, "unsupported phy mode: %s\n", phy_modes(priv->phy_intf)); return -EINVAL; @@ -1613,6 +1616,9 @@ static int mt8516_set_interface_mode(struct net_device *ndev) unsigned int intf_val = 0, rmii_rxc = 0; switch (priv->phy_intf) { + case PHY_INTERFACE_MODE_MII: + intf_val = MTK_PERICFG_BIT_NIC_CFG_CON_MII; + break; 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; @@ -1638,6 +1644,9 @@ static int mt8365_set_interface_mode(struct net_device *ndev) unsigned int intf_val = 0; switch (priv->phy_intf) { + case PHY_INTERFACE_MODE_MII: + intf_val = MTK_PERICFG_BIT_NIC_CFG_CON_MII; + break; 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; -- 2.25.1