Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp147038pxb; Fri, 16 Apr 2021 01:50:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTnyh69C2JBuTy+41lGKoAvPzaRcsfkQ5MdJIGvFx7VLTohlK+6hXyfTve0pApQ4toDI4h X-Received: by 2002:a17:907:94c3:: with SMTP id dn3mr7496195ejc.280.1618563036924; Fri, 16 Apr 2021 01:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618563036; cv=none; d=google.com; s=arc-20160816; b=dadmPyCpLEdsPD0oNvFJ9qOX7fruMxpLicUmNw2BrJE5vZ4A86x6+qj37mh04oesEo TsjYXwXHPV9B0nXlCXMCkepdcKNLcxc0OgKPAR44z109pLehBjKSMt2ntdEhDO12FK8R OtEt2zP+qIl2xZHheA+zVGxAvGcJRY3sCvUcdZjdau/+jkfMM8QccE9WJx5+hMpQ5DfR m7elee9q2NR/eJ0BSR2aJB8IWiVYhOOdP7KH1y5d2laZ5tfAgH6aaofrB3cugVKq8cto zzSLTe5oRMp7Dffgtb6wLOTd6Yaom8Q8l2GcTClYeAdiKZ8H/uG7nuV+7sMO6WM3AeOO XVhQ== 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:to:from; bh=yxZOen94Ir7nzWsuVhoTr1doE8y443j802OHnkjjdrg=; b=y/NqUPARZQcZUa20o+sZL8am59XjeLPoUCO78MBeLHS1K/0NEJGPbz54J8waRZXWBw V0OJL2yrDWgpGvgANt0epLhx9VK0Pm8rtmCnTtcYG/IwtEoZEgCt1Y1hVcrHEWcrLmCj Mfl8CQHbnlXNbzPdHejoKh7DeNI3WwvpjDQeSmirL0rWSO7jd3u4SbFxLu91+MNUtRiX nBzu1lyy7SGYxOB7eFnpHs7Br2MtiGD+0SIqaWd/DS8+7aXIud5q1amgrj9Pvn74H4C3 Ik016tZk8mtD+zz41/yYfvzRuWa0fDYNk4qP08KZnbUYG7tpNFL0nR5n7tFqTt1YTHV6 knsw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jt14si4029554ejc.617.2021.04.16.01.50.14; Fri, 16 Apr 2021 01:50:36 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241125AbhDPIsi (ORCPT + 99 others); Fri, 16 Apr 2021 04:48:38 -0400 Received: from mx2.suse.de ([195.135.220.15]:46124 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240889AbhDPIrn (ORCPT ); Fri, 16 Apr 2021 04:47:43 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4A236AF4E; Fri, 16 Apr 2021 08:47:17 +0000 (UTC) From: Thomas Bogendoerfer To: "David S. Miller" , Jakub Kicinski , Rob Herring , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Subject: [PATCH v4 net-next 08/10] net: korina: Get mdio input clock via common clock framework Date: Fri, 16 Apr 2021 10:47:09 +0200 Message-Id: <20210416084712.62561-9-tsbogend@alpha.franken.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210416084712.62561-1-tsbogend@alpha.franken.de> References: <20210416084712.62561-1-tsbogend@alpha.franken.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With device tree clock is provided via CCF. For non device tree use a maximum clock value to not overclock the PHY. The non device tree usage will go away after platform is converted to DT. Signed-off-by: Thomas Bogendoerfer --- drivers/net/ethernet/korina.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c index cd078a5c679b..e95c8d87d893 100644 --- a/drivers/net/ethernet/korina.c +++ b/drivers/net/ethernet/korina.c @@ -57,14 +57,13 @@ #include #include #include +#include #include #include #include #include -#include -#include #include #include @@ -146,10 +145,9 @@ struct korina_private { struct work_struct restart_task; struct net_device *dev; struct device *dmadev; + int mii_clock_freq; }; -extern unsigned int idt_cpu_freq; - static dma_addr_t korina_tx_dma(struct korina_private *lp, int idx) { return lp->td_dma + (idx * sizeof(struct dma_desc)); @@ -899,8 +897,8 @@ static int korina_init(struct net_device *dev) /* Management Clock Prescaler Divisor * Clock independent setting */ - writel(((idt_cpu_freq) / MII_CLOCK + 1) & ~1, - &lp->eth_regs->ethmcp); + writel(((lp->mii_clock_freq) / MII_CLOCK + 1) & ~1, + &lp->eth_regs->ethmcp); writel(0, &lp->eth_regs->miimcfg); /* don't transmit until fifo contains 48b */ @@ -1060,6 +1058,7 @@ static int korina_probe(struct platform_device *pdev) u8 *mac_addr = dev_get_platdata(&pdev->dev); struct korina_private *lp; struct net_device *dev; + struct clk *clk; void __iomem *p; int rc; @@ -1077,6 +1076,16 @@ static int korina_probe(struct platform_device *pdev) eth_hw_addr_random(dev); } + clk = devm_clk_get_optional(&pdev->dev, "mdioclk"); + if (IS_ERR(clk)) + return PTR_ERR(clk); + if (clk) { + clk_prepare_enable(clk); + lp->mii_clock_freq = clk_get_rate(clk); + } else { + lp->mii_clock_freq = 200000000; /* max possible input clk */ + } + lp->rx_irq = platform_get_irq_byname(pdev, "korina_rx"); lp->tx_irq = platform_get_irq_byname(pdev, "korina_tx"); -- 2.29.2