From patchwork Thu Jul 2 10:29:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 11638473 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B4502618 for ; Thu, 2 Jul 2020 10:30:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95B86207CD for ; Thu, 2 Jul 2020 10:30:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=sartura-hr.20150623.gappssmtp.com header.i=@sartura-hr.20150623.gappssmtp.com header.b="t8zdM40k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728528AbgGBKaO (ORCPT ); Thu, 2 Jul 2020 06:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728504AbgGBKaM (ORCPT ); Thu, 2 Jul 2020 06:30:12 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82DFAC08C5C1 for ; Thu, 2 Jul 2020 03:30:12 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id s10so27494577wrw.12 for ; Thu, 02 Jul 2020 03:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sartura-hr.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6XZ9Fy33ZwirWwW/Vm8IMd0bk/0qmM6jU4/hDefptfY=; b=t8zdM40kMqkARgd6F0Ua4AF2+6eveItiPhWAZ27n69HXAEY7SOiz3nLTUM/EQSqTgT Sp8rLn9VYI5w2IfK8pPGls2fWX1DbHOGLhyaba4IrC0HtkiTgBs5WDxsn66E8OxAzIoj cLGFwGLSUkxSbr79D9RpCTrqK00uW7xhmy5Z5y5ySPwppZbs+7fGOZm6JT3COCKEDEh+ ZKNETJ175EariGXCSjKyUV3K7WS71eTMFt8m7CRzrudZEw/zCGoARAbQk3+MILLRMDqR s2DnMtS5pULehPVaYmwaEjclel38p8+r6LsGq40UKEwtOv2m2zNfWyLEndnCMa+piS+N mNYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6XZ9Fy33ZwirWwW/Vm8IMd0bk/0qmM6jU4/hDefptfY=; b=YWflKcm5BbD5vsrKaQv3uTaw4oAzD0KJKP2KJ6Ambo2CqMhdDzuTfftVdBGp/n8Zag t1d3mrssPr4boYCxRpd6QXZxvk8g7wMsj9tnIbg7tL1mQRW63aRZEphPAy2NMtTP34IG kbUOGFLGtjWc3phnfpdKowmCDYtyrtbMmCEzSozfsW6q+izAMcBz0VAyjEh+/V51PQO3 y03O3NEsE4J8Uwg1cXtPfU9HbkS35HRcRF8o1Ab+L9MwI7hd/EHSk7KoKJRk1G58v4jY 3Mm3ZW3gR2/00hIJx9E34WNT7mTbChGVPUpXr7QYvFLlsAcPJwrY/8VLlQY9xx2fxrFv JC2A== X-Gm-Message-State: AOAM533aeGwCoPjLAlEIfrpm089nTtmqbqU09h2qA0v8QDEmYXAej62I pwO+s4TESNu/krDeo6vMGYur7A== X-Google-Smtp-Source: ABdhPJyMKhWpSUBUZ3IdCFf0na/xQ08f0GX2RezpLtD1SE2YPNqmajDrSbFhTzxvCzK/zQjyw1V/DA== X-Received: by 2002:a5d:40c9:: with SMTP id b9mr29792661wrq.425.1593685811200; Thu, 02 Jul 2020 03:30:11 -0700 (PDT) Received: from localhost.localdomain (dh207-99-59.xnet.hr. [88.207.99.59]) by smtp.googlemail.com with ESMTPSA id 68sm10406912wmz.40.2020.07.02.03.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 03:30:10 -0700 (PDT) From: Robert Marko To: andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, agross@kernel.org, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: Robert Marko Subject: [net-next,PATCH 1/4] net: mdio-ipq4019: change defines to upper case Date: Thu, 2 Jul 2020 12:29:58 +0200 Message-Id: <20200702103001.233961-2-robert.marko@sartura.hr> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702103001.233961-1-robert.marko@sartura.hr> References: <20200702103001.233961-1-robert.marko@sartura.hr> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In the commit adding the IPQ4019 MDIO driver, defines for timeout and sleep partially used lower case. Lets change it to upper case in line with the rest of driver defines. Signed-off-by: Robert Marko Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- drivers/net/phy/mdio-ipq4019.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/mdio-ipq4019.c b/drivers/net/phy/mdio-ipq4019.c index f1f25489e134..0e78830c070b 100644 --- a/drivers/net/phy/mdio-ipq4019.c +++ b/drivers/net/phy/mdio-ipq4019.c @@ -21,8 +21,8 @@ #define MDIO_CMD_ACCESS_CODE_READ 0 #define MDIO_CMD_ACCESS_CODE_WRITE 1 -#define ipq4019_MDIO_TIMEOUT 10000 -#define ipq4019_MDIO_SLEEP 10 +#define IPQ4019_MDIO_TIMEOUT 10000 +#define IPQ4019_MDIO_SLEEP 10 struct ipq4019_mdio_data { void __iomem *membase; @@ -35,7 +35,7 @@ static int ipq4019_mdio_wait_busy(struct mii_bus *bus) return readl_poll_timeout(priv->membase + MDIO_CMD_REG, busy, (busy & MDIO_CMD_ACCESS_BUSY) == 0, - ipq4019_MDIO_SLEEP, ipq4019_MDIO_TIMEOUT); + IPQ4019_MDIO_SLEEP, IPQ4019_MDIO_TIMEOUT); } static int ipq4019_mdio_read(struct mii_bus *bus, int mii_id, int regnum) From patchwork Thu Jul 2 10:29:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 11638481 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 213D4618 for ; Thu, 2 Jul 2020 10:30:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0671B207CD for ; Thu, 2 Jul 2020 10:30:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=sartura-hr.20150623.gappssmtp.com header.i=@sartura-hr.20150623.gappssmtp.com header.b="1fEi2WIH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728541AbgGBKaq (ORCPT ); Thu, 2 Jul 2020 06:30:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728514AbgGBKaO (ORCPT ); Thu, 2 Jul 2020 06:30:14 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 659E4C08C5DD for ; Thu, 2 Jul 2020 03:30:14 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id o2so27314376wmh.2 for ; Thu, 02 Jul 2020 03:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sartura-hr.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F0K1et+c7L37Nzbq/fKuHgV+8Ew7PJCWV3QsyfuXTTU=; b=1fEi2WIHdfLE+hyuYKNfHSHHxhxmwxb91xzhRrvmfCTdeDa5qYKDFd2UENYBF9pQRB FHqxUN1/LEafenfotRTqtVXOCQrUV6kzOmKOyYt0kFmG4MMwVz3fbF8N6aki9NTGynNo kavJ2wHVBgr/nEw40vV44jlioejc0AUSdagBCkc5KrDTg1qjOWbQNbz5zbpZ4AuhUaX8 Gbadn2mU9a0ECaLFrtFUcF1XPxPqARSGTfQy1Op97lzsyS9xfEXinGJxe6p8WUaKa6CF /UR3cdQIFFSFDpx3RHvmDZ2OyW/1Lq2DIp9pFYxtz4W4tXI/BF5rDNE7iPLGodgZAJ8h E/rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F0K1et+c7L37Nzbq/fKuHgV+8Ew7PJCWV3QsyfuXTTU=; b=qPtSMiCNaNnN7zznOEToN9ZD//FsjsU/6t4yY/wgSBgrH2K/+mLzAbWtZpdO6FFB2b eDW/CtyyOUIzuqnQT7duHUmx1gOvrL6i47noqL6FypUiJw6TocOZEkGHimDBqxT+mr/n UivIqM0zZcBCoxlzkjRBMd/FLbs76ylBXGcZ3JmnpCfailCehbiMH72uD+jOZGNfBUwJ NAcY3a9X6gcY5H4Sw5O+uFq9oAjKTKc/Ow4zoIQHF9HhkH/T17HUBty2nrGOm+nmbdG4 oFQkkMzdlnvD8Wr7u05/jDjmOzHpJKgKznC5iHmejKFEnqqhSHj1OyNk8fW1/yJTaePP 04aA== X-Gm-Message-State: AOAM533dMp++avnlim0RetYJDmkNhYHkCU+olDw83Hlcg/hQs258jX+9 ulBGXQHNiUi61EkIQI2DbSYZig== X-Google-Smtp-Source: ABdhPJxpt2WM81j7Hv6WASmS6W6A/F8mIqAkpSUNmRxtPrR70qHkjCCQsBYAX7aF5NGaExVifQrfNw== X-Received: by 2002:a1c:c242:: with SMTP id s63mr30819203wmf.146.1593685813052; Thu, 02 Jul 2020 03:30:13 -0700 (PDT) Received: from localhost.localdomain (dh207-99-59.xnet.hr. [88.207.99.59]) by smtp.googlemail.com with ESMTPSA id 68sm10406912wmz.40.2020.07.02.03.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 03:30:12 -0700 (PDT) From: Robert Marko To: andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, agross@kernel.org, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: Robert Marko Subject: [net-next,PATCH 2/4] net: mdio-ipq4019: add clock support Date: Thu, 2 Jul 2020 12:29:59 +0200 Message-Id: <20200702103001.233961-3-robert.marko@sartura.hr> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702103001.233961-1-robert.marko@sartura.hr> References: <20200702103001.233961-1-robert.marko@sartura.hr> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Some newer SoC-s have a separate MDIO clock that needs to be enabled. So lets add support for handling the clocks to the driver. Signed-off-by: Robert Marko --- drivers/net/phy/mdio-ipq4019.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/mdio-ipq4019.c b/drivers/net/phy/mdio-ipq4019.c index 0e78830c070b..7660bf006da0 100644 --- a/drivers/net/phy/mdio-ipq4019.c +++ b/drivers/net/phy/mdio-ipq4019.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -24,8 +25,12 @@ #define IPQ4019_MDIO_TIMEOUT 10000 #define IPQ4019_MDIO_SLEEP 10 +#define QCA_MDIO_CLK_DEFAULT_RATE 100000000 + struct ipq4019_mdio_data { - void __iomem *membase; + void __iomem *membase; + struct clk *mdio_clk; + u32 clk_freq; }; static int ipq4019_mdio_wait_busy(struct mii_bus *bus) @@ -100,6 +105,7 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) { struct ipq4019_mdio_data *priv; struct mii_bus *bus; + struct device_node *np = pdev->dev.of_node; int ret; bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv)); @@ -112,6 +118,26 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) if (IS_ERR(priv->membase)) return PTR_ERR(priv->membase); + priv->mdio_clk = devm_clk_get_optional(&pdev->dev, "mdio_ahb"); + if (!IS_ERR(priv->mdio_clk)) { + if (of_property_read_u32(np, "clock-frequency", &priv->clk_freq)) { + dev_warn(&pdev->dev, "Cannot find MDIO clock frequency, using default!\n"); + priv->clk_freq = QCA_MDIO_CLK_DEFAULT_RATE; + } + + ret = clk_set_rate(priv->mdio_clk, priv->clk_freq); + if (ret) { + dev_err(&pdev->dev, "Cannot set MDIO clock rate!\n"); + return ret; + } + + ret = clk_prepare_enable(priv->mdio_clk); + if (ret) { + dev_err(&pdev->dev, "Cannot enable MDIO clock!\n"); + return ret; + } + } + bus->name = "ipq4019_mdio"; bus->read = ipq4019_mdio_read; bus->write = ipq4019_mdio_write; From patchwork Thu Jul 2 10:30:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 11638479 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2D9992A for ; Thu, 2 Jul 2020 10:30:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4BDF20884 for ; Thu, 2 Jul 2020 10:30:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=sartura-hr.20150623.gappssmtp.com header.i=@sartura-hr.20150623.gappssmtp.com header.b="xlSa82hs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728634AbgGBKam (ORCPT ); Thu, 2 Jul 2020 06:30:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728320AbgGBKaR (ORCPT ); Thu, 2 Jul 2020 06:30:17 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99365C08C5DE for ; Thu, 2 Jul 2020 03:30:16 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id j4so25088591wrp.10 for ; Thu, 02 Jul 2020 03:30:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sartura-hr.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AxFc8QsWQJwBLz/+3G2SEV6PK5N4TIC8ua8H9gJBdtc=; b=xlSa82hsahdngAPny0lKB8uTDhQzDBlapiTx2yqPh9kg/pQs10swtam2kBIEne+UYa 3za3JmrV1SEVcj8FWiuHG1WpbQBJsPouR4pzrGdYkTnd3E8CWXKwFMaW2KodEOBTsqVq 0i5wi1fvRV/YRHpT19CVezHYqN1eIW5y1Hvzc+Hy0ZlzgI5uDNkg9YOmsEjgdfVDEmNm IR8zTSi59S5vnq4Hnb3YTRJk52JvffXTzA1gpRdR7Xe+0WxN3+cUW6+DuuQLdFFiqKsl 6aU4EA6XWlDqhiRvIP/jQHCd4gloNzfWyKktrQ6oMGu+mEBaSZXZmR4AFGhEgjyLN0eA lx1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AxFc8QsWQJwBLz/+3G2SEV6PK5N4TIC8ua8H9gJBdtc=; b=AMaR+5jzkQspFxZ1Xk1o5wCt5cAI+4x05in7JMUXRK8efiFCUceICw7RYVTgNnyJXb Q6G/d4GKL6YbJyy9hMntklDdbvx8Vu2X2fgrYVaM7MPXgNj30kTh8NencGl2XMEHa1jf RwLOjKnDNGAZ0skG6wvpWGYJVOhmOrVUfP5rjLr4SfHwi4JZcmsB11ANQMmYnncuUY/J /ZwUrce3Ovb0YiBBv+6aKV4DALqv6N2j2DKKR4OevXFUQfZPagSq+vIQoGlTW0HvjGYg b+TpJ0BG5yInH8p20W++8xmW+OsgT2gSxk/7UqjkNteArndvph+JKcgC/N8TWtMWrvEU ihDQ== X-Gm-Message-State: AOAM532l6doHHb4x/gRhfg+sRgQ8WB/lD9tOh7j2GhnUNqnD6DdIl1Sw mtuOuOabjjZiyokTqlM7cj9xaA== X-Google-Smtp-Source: ABdhPJw1jcSvGoNPOCw6Zwm19skkWRwX+zU0rWJi7jrd2ukpW1FH4rV5FVJhvpsFJludrym9D5fB1A== X-Received: by 2002:adf:f18c:: with SMTP id h12mr29657960wro.375.1593685815245; Thu, 02 Jul 2020 03:30:15 -0700 (PDT) Received: from localhost.localdomain (dh207-99-59.xnet.hr. [88.207.99.59]) by smtp.googlemail.com with ESMTPSA id 68sm10406912wmz.40.2020.07.02.03.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 03:30:14 -0700 (PDT) From: Robert Marko To: andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, agross@kernel.org, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: Robert Marko Subject: [net-next,PATCH 3/4] net: mdio-ipq4019: add Clause 45 support Date: Thu, 2 Jul 2020 12:30:00 +0200 Message-Id: <20200702103001.233961-4-robert.marko@sartura.hr> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702103001.233961-1-robert.marko@sartura.hr> References: <20200702103001.233961-1-robert.marko@sartura.hr> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org While up-streaming the IPQ4019 driver it was thought that the controller had no Clause 45 support, but it actually does and its activated by writing a bit to the mode register. So lets add it as newer SoC-s use the same controller and Clause 45 compliant PHY-s. Signed-off-by: Robert Marko --- drivers/net/phy/mdio-ipq4019.c | 109 ++++++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 17 deletions(-) diff --git a/drivers/net/phy/mdio-ipq4019.c b/drivers/net/phy/mdio-ipq4019.c index 7660bf006da0..9143113d5a6b 100644 --- a/drivers/net/phy/mdio-ipq4019.c +++ b/drivers/net/phy/mdio-ipq4019.c @@ -13,6 +13,7 @@ #include #include +#define MDIO_MODE_REG 0x40 #define MDIO_ADDR_REG 0x44 #define MDIO_DATA_WRITE_REG 0x48 #define MDIO_DATA_READ_REG 0x4c @@ -21,6 +22,12 @@ #define MDIO_CMD_ACCESS_START BIT(8) #define MDIO_CMD_ACCESS_CODE_READ 0 #define MDIO_CMD_ACCESS_CODE_WRITE 1 +#define MDIO_CMD_ACCESS_CODE_C45_ADDR 0 +#define MDIO_CMD_ACCESS_CODE_C45_WRITE 1 +#define MDIO_CMD_ACCESS_CODE_C45_READ 2 + +/* 0 = Clause 22, 1 = Clause 45 */ +#define MDIO_MODE_BIT BIT(8) #define IPQ4019_MDIO_TIMEOUT 10000 #define IPQ4019_MDIO_SLEEP 10 @@ -39,7 +46,7 @@ static int ipq4019_mdio_wait_busy(struct mii_bus *bus) unsigned int busy; return readl_poll_timeout(priv->membase + MDIO_CMD_REG, busy, - (busy & MDIO_CMD_ACCESS_BUSY) == 0, + (busy & MDIO_CMD_ACCESS_BUSY) == 0, IPQ4019_MDIO_SLEEP, IPQ4019_MDIO_TIMEOUT); } @@ -47,18 +54,43 @@ static int ipq4019_mdio_read(struct mii_bus *bus, int mii_id, int regnum) { struct ipq4019_mdio_data *priv = bus->priv; unsigned int cmd; - - /* Reject clause 45 */ - if (regnum & MII_ADDR_C45) - return -EOPNOTSUPP; + unsigned int data; if (ipq4019_mdio_wait_busy(bus)) return -ETIMEDOUT; - /* issue the phy address and reg */ - writel((mii_id << 8) | regnum, priv->membase + MDIO_ADDR_REG); + /* Clause 45 support */ + if (regnum & MII_ADDR_C45) { + unsigned int mmd = (regnum >> 16) & 0x1F; + unsigned int reg = regnum & 0xFFFF; + + /* Enter Clause 45 mode */ + data = readl(priv->membase + MDIO_MODE_REG); + + data |= MDIO_MODE_BIT; + + writel(data, priv->membase + MDIO_MODE_REG); + + /* issue the phy address and mmd */ + writel((mii_id << 8) | mmd, priv->membase + MDIO_ADDR_REG); + + /* issue reg */ + writel(reg, priv->membase + MDIO_DATA_WRITE_REG); + + cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_C45_ADDR; + } else { + /* Enter Clause 22 mode */ + data = readl(priv->membase + MDIO_MODE_REG); - cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_READ; + data &= ~MDIO_MODE_BIT; + + writel(data, priv->membase + MDIO_MODE_REG); + + /* issue the phy address and reg */ + writel((mii_id << 8) | regnum, priv->membase + MDIO_ADDR_REG); + + cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_READ; + } /* issue read command */ writel(cmd, priv->membase + MDIO_CMD_REG); @@ -67,6 +99,15 @@ static int ipq4019_mdio_read(struct mii_bus *bus, int mii_id, int regnum) if (ipq4019_mdio_wait_busy(bus)) return -ETIMEDOUT; + if (regnum & MII_ADDR_C45) { + cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_C45_READ; + + writel(cmd, priv->membase + MDIO_CMD_REG); + + if (ipq4019_mdio_wait_busy(bus)) + return -ETIMEDOUT; + } + /* Read and return data */ return readl(priv->membase + MDIO_DATA_READ_REG); } @@ -76,22 +117,56 @@ static int ipq4019_mdio_write(struct mii_bus *bus, int mii_id, int regnum, { struct ipq4019_mdio_data *priv = bus->priv; unsigned int cmd; - - /* Reject clause 45 */ - if (regnum & MII_ADDR_C45) - return -EOPNOTSUPP; + unsigned int data; if (ipq4019_mdio_wait_busy(bus)) return -ETIMEDOUT; - /* issue the phy address and reg */ - writel((mii_id << 8) | regnum, priv->membase + MDIO_ADDR_REG); + /* Clause 45 support */ + if (regnum & MII_ADDR_C45) { + unsigned int mmd = (regnum >> 16) & 0x1F; + unsigned int reg = regnum & 0xFFFF; + + /* Enter Clause 45 mode */ + data = readl(priv->membase + MDIO_MODE_REG); + + data |= MDIO_MODE_BIT; + + writel(data, priv->membase + MDIO_MODE_REG); + + /* issue the phy address and mmd */ + writel((mii_id << 8) | mmd, priv->membase + MDIO_ADDR_REG); + + /* issue reg */ + writel(reg, priv->membase + MDIO_DATA_WRITE_REG); + + cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_C45_ADDR; + + writel(cmd, priv->membase + MDIO_CMD_REG); + + if (ipq4019_mdio_wait_busy(bus)) + return -ETIMEDOUT; + } else { + /* Enter Clause 22 mode */ + data = readl(priv->membase + MDIO_MODE_REG); + + data &= ~MDIO_MODE_BIT; + + writel(data, priv->membase + MDIO_MODE_REG); + + /* issue the phy address and reg */ + writel((mii_id << 8) | regnum, priv->membase + MDIO_ADDR_REG); + } /* issue write data */ writel(value, priv->membase + MDIO_DATA_WRITE_REG); - - cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_WRITE; + /* issue write command */ + if (regnum & MII_ADDR_C45) + cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_C45_WRITE; + else + cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_WRITE; + writel(cmd, priv->membase + MDIO_CMD_REG); /* Wait write complete */ @@ -105,7 +180,7 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) { struct ipq4019_mdio_data *priv; struct mii_bus *bus; - struct device_node *np = pdev->dev.of_node; + struct device_node *np = pdev->dev.of_node; int ret; bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv)); From patchwork Thu Jul 2 10:30:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 11638477 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1530618 for ; Thu, 2 Jul 2020 10:30:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8918D20747 for ; Thu, 2 Jul 2020 10:30:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=sartura-hr.20150623.gappssmtp.com header.i=@sartura-hr.20150623.gappssmtp.com header.b="KeFi1ABs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728550AbgGBKab (ORCPT ); Thu, 2 Jul 2020 06:30:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728552AbgGBKaT (ORCPT ); Thu, 2 Jul 2020 06:30:19 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93943C08C5E1 for ; Thu, 2 Jul 2020 03:30:18 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id f18so19460959wrs.0 for ; Thu, 02 Jul 2020 03:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sartura-hr.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LlGrsZv5MDXCoixnPWrg/mlv9SQt5SL1loevVSN/VHc=; b=KeFi1ABsxr3fl8GMR0/3qDI8qj0sYAqgYksocmCHaogDsB9OQ3G5HpO6Y6CBVUElHV PvUS3X88SRGYnJImNTB84cxpPTk7lVw9xAogix8X8LJRF8vymzAo+R4PdDRQcyUspUfH WAbhIsS2RcJmQxrnlTbxPcuf1DH88gm3VBZfM6Alq0BSEDO4ZF5QbQxI2d7YOu1iw/lb 4tP4BwAHtDWiQfZU/4tcUT3UbOJ1AuWEsYRORfi0MWP79GUWDvgiBrFx7Qfy0Nt1puyb pNV/n9QLoVLRnSFw4AKwnxG+ByqeBDny3S/7QB8o7vPb2VI1az0o+DFpaD1vabdZV6uE 20Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LlGrsZv5MDXCoixnPWrg/mlv9SQt5SL1loevVSN/VHc=; b=F8fpnIbrmS6umJUILDhNgznNKZFEuxxRIn2xBGMiItczbBr91sSZlwqgSoUSBM2xSR C+8Vo2F5MIAO8zeYDUnLY6yAc/1tes5NfAgyweQ4QyXeDrVuUVf1j6iyaMg9D7A46O10 XLeDC1ksJRJxTfeSeKkd4fPIwLo7Pf+1AXatYJ85MtJv+yDj/yDBR6wizyD539w2volP QBGeIqqP66I3H56b6OfAsZn7Ey+o4vkgRA9ZGqJCK6gF5Z3dDKW9iV2e6feYcZpk05sX SqY8c3lPv/LT3Q4Ngi4QQorWO9Xq4Ywgvzk1LGtuIWIU1M1XKVU3ODc2d9d24PF51ekn MDqw== X-Gm-Message-State: AOAM530mytnX5hQpTXlVeyYWpvzJOcY7XfOYmRab+EyFv0yELe8oHoBS 1lXV1dWbes1fUE+wkp3pIkTImg== X-Google-Smtp-Source: ABdhPJzrKkA5IL6AI6zOIP68F3NzFvD0431eMMCeA/kAyZb4PVbZ8/a84PbeXlReLLXV8E4fU5mjaQ== X-Received: by 2002:a5d:60c7:: with SMTP id x7mr28770641wrt.138.1593685817345; Thu, 02 Jul 2020 03:30:17 -0700 (PDT) Received: from localhost.localdomain (dh207-99-59.xnet.hr. [88.207.99.59]) by smtp.googlemail.com with ESMTPSA id 68sm10406912wmz.40.2020.07.02.03.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 03:30:16 -0700 (PDT) From: Robert Marko To: andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, agross@kernel.org, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: Robert Marko Subject: [net-next,PATCH 4/4] dt-bindings: mdio-ipq4019: add clock support Date: Thu, 2 Jul 2020 12:30:01 +0200 Message-Id: <20200702103001.233961-5-robert.marko@sartura.hr> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702103001.233961-1-robert.marko@sartura.hr> References: <20200702103001.233961-1-robert.marko@sartura.hr> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This adds the necessary bindings for SoC-s that have a separate MDIO clock. Signed-off-by: Robert Marko --- .../devicetree/bindings/net/qcom,ipq4019-mdio.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml b/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml index 13555a89975f..06b4eedb4370 100644 --- a/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +++ b/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml @@ -25,6 +25,17 @@ properties: reg: maxItems: 1 + clocks: + maxItems: 1 + + clock-names: + items: + - const: mdio_ahb + maxItems: 1 + + clock-frequency: + default: 100000000 + required: - compatible - reg