Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1240205pxb; Fri, 21 Jan 2022 13:07:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDvNuoXuWCtlsAhoQxAeu75nn6rhqwUkWZ8Y3Ai32e0ZfUyADznVOBp/QKXoXLsYUKnJul X-Received: by 2002:a63:cf13:: with SMTP id j19mr4054255pgg.279.1642799246738; Fri, 21 Jan 2022 13:07:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642799246; cv=none; d=google.com; s=arc-20160816; b=Ej9p3b5LGybP9MOTvbPt9JHjpV9QVPQnKwG9EOsPE/7+QG7jZPAkTlSOPYTv/grdrF zMDLTAF5VO2Dj+yDpbg62iJXZoja9jKFaU+mybXuURwVgu/8CpErLZZazeCmluqCPVjN RZ6XMpbAXEpYRbnQeiTmQwVLdiuBGKrK0PaZcXHg5dopXZ9XO5N4peVUyPOsipOZE21Y WS2DANikG5ASqS/NxnLKjnO4Get5em/UQaLkSlcCH1KcFTUwhYs2oQ6wWyqoEDYa8ySH CNsCe2alc+cCNy91OtqypO1eNSBD/UCSBsN8cIvR5ljFiSwdyvqBLn7mo+H1DQe7ka+a OuWA== 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=4kxeC9/fZzhd1WCGmKYDqUvAVLVSJMCqWsWbPQU7oRk=; b=Wf1Vh0RY/LfY4cofmsHvpEQFSdnLCAMLjq3i+l8nKSdKR4PAJekkMfEkX5JsG9NWIR pwP21S/y94ctcleNZIc3zm7GLzFQyHfgKq+FgGsulae0BqpNV2gLsrlZ3202UCXei7Hz bc7CJMlFVkBYFdSACsl+Lnoo1ZfTfYaXw5DsMxySNCSN891FG+aiQXkPKSB2Qr7ITmAg B0D7Hxc0xh5LEzTxyM7IKpVSrFwGFggKO1SZpSU5atIH8XjxCJqmgcOOgf5xBhW8/tCe DDaeb0e+LLS1BPGnZhdS1TIijPvcJHO0Kgvosr14u4A1Keyg9aTQs+PXMUMJm9uEeUsh f97A== 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 g15si7292592pgr.699.2022.01.21.13.07.14; Fri, 21 Jan 2022 13:07:26 -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 S1358821AbiATHCl (ORCPT + 99 others); Thu, 20 Jan 2022 02:02:41 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:37102 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1358814AbiATHCh (ORCPT ); Thu, 20 Jan 2022 02:02:37 -0500 X-UUID: 52844205dddc43f6b488de29d382d0ef-20220120 X-UUID: 52844205dddc43f6b488de29d382d0ef-20220120 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1876489143; Thu, 20 Jan 2022 15:02:32 +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:31 +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:29 +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 1/9] net: ethernet: mtk-star-emac: store bit_clk_div in compat structure Date: Thu, 20 Jan 2022 15:02:18 +0800 Message-ID: <20220120070226.1492-2-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 From: Fabien Parent Not all the SoC are using the same clock divider. Move the divider into a compat structure specific to the SoCs. Signed-off-by: Biao Huang Signed-off-by: Fabien Parent --- drivers/net/ethernet/mediatek/mtk_star_emac.c | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c index 1d5dd2015453..26f5020f2e9c 100644 --- a/drivers/net/ethernet/mediatek/mtk_star_emac.c +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -232,6 +233,10 @@ struct mtk_star_ring { unsigned int tail; }; +struct mtk_star_compat { + unsigned char bit_clk_div; +}; + struct mtk_star_priv { struct net_device *ndev; @@ -257,6 +262,8 @@ struct mtk_star_priv { int duplex; int pause; + const struct mtk_star_compat *compat_data; + /* Protects against concurrent descriptor access. */ spinlock_t lock; @@ -899,7 +906,7 @@ static void mtk_star_init_config(struct mtk_star_priv *priv) regmap_write(priv->regs, MTK_STAR_REG_SYS_CONF, val); regmap_update_bits(priv->regs, MTK_STAR_REG_MAC_CLK_CONF, MTK_STAR_MSK_MAC_CLK_CONF, - MTK_STAR_BIT_CLK_DIV_10); + priv->compat_data->bit_clk_div); } static void mtk_star_set_mode_rmii(struct mtk_star_priv *priv) @@ -1461,6 +1468,7 @@ static int mtk_star_probe(struct platform_device *pdev) priv = netdev_priv(ndev); priv->ndev = ndev; + priv->compat_data = of_device_get_match_data(&pdev->dev); SET_NETDEV_DEV(ndev, dev); platform_set_drvdata(pdev, ndev); @@ -1556,10 +1564,17 @@ static int mtk_star_probe(struct platform_device *pdev) return devm_register_netdev(dev, ndev); } +static struct mtk_star_compat mtk_star_mt8516_compat = { + .bit_clk_div = MTK_STAR_BIT_CLK_DIV_10, +}; + static const struct of_device_id mtk_star_of_match[] = { - { .compatible = "mediatek,mt8516-eth", }, - { .compatible = "mediatek,mt8518-eth", }, - { .compatible = "mediatek,mt8175-eth", }, + { .compatible = "mediatek,mt8516-eth", + .data = &mtk_star_mt8516_compat }, + { .compatible = "mediatek,mt8518-eth", + .data = &mtk_star_mt8516_compat }, + { .compatible = "mediatek,mt8175-eth", + .data = &mtk_star_mt8516_compat }, { } }; MODULE_DEVICE_TABLE(of, mtk_star_of_match); -- 2.25.1