From patchwork Fri Oct 21 14:40:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 9389451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BD439607F0 for ; Fri, 21 Oct 2016 14:58:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF3802A254 for ; Fri, 21 Oct 2016 14:58:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3E452A275; Fri, 21 Oct 2016 14:58:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B58332A254 for ; Fri, 21 Oct 2016 14:58:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bxbFZ-0000sH-5Y; Fri, 21 Oct 2016 14:56:49 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bxbFW-0000mA-DQ for linux-arm-kernel@bombadil.infradead.org; Fri, 21 Oct 2016 14:56:46 +0000 Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]) by casper.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bxb0Z-0006mr-0t for linux-arm-kernel@lists.infradead.org; Fri, 21 Oct 2016 14:41:19 +0000 Received: by mail-lf0-x22b.google.com with SMTP id x79so155059685lff.0 for ; Fri, 21 Oct 2016 07:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2rPL97noEZ/8uGFW2mFLyuh4LFY1nNdoZkeBr+D/fH8=; b=iThLzK4bFaqhPRBJQ7NDK1ZQLthCwJ9jGMPd+vXk2Ob90Fe+GcL9P/tFvErkztj3EJ 9giLEZyk7uD/4T0eMnQ5MuuHt1QRHJV2GYlkosTHSlP7T50ayF9OUqix/sf1zwH7pnIN uYTFmTZHbEh5OKrE0zMCMy5WJcrjD3eqSo8DFqSKutmMgC+Gj2WIsuwCSCmZN56lERKZ XczBeqq1btlxmNnfUsDWBljiNmOuWXRi8HnCI50p2JYUKO5l3VBzybRoP5G8TX/dspSc yMjrucafiSinptUPWyqKzCyrMJhBA2O7FUXghYKggKSpDtH9ig+uZ4jMRA2dnXUgtTiG nyBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2rPL97noEZ/8uGFW2mFLyuh4LFY1nNdoZkeBr+D/fH8=; b=XVpn4KD+yQbldKeVcJYtfBSWZHpdkAis57UiMWiX8yJDvZVtFMlJnb7RGMyqNK98BY 585abvBsQHSVDLSry4YrOcEc/cIBq756JMv6qgrj5QFwvRrXZgGBcjlkikdl0FmgcACb ShCK1eox1ADbotfvIIMuOI9Lab+pKjnkSPjgJttgEvcRduJAT/1gv/vlG57NO+3Hib8b dJUDp3FHvBH8w0hqfHNu2ghUZ6BgCWJxAO5CkDN0Wkk0pHWOizyLYT91HCzYqyWXtacP x2GKFhkoKILIMtk2N0gmGazfkelHtFYmouTSX1xwkNQn6hJ8gxe9yzhkC8twiJ7qc1+g npTQ== X-Gm-Message-State: AA6/9RlUYuu2FAOv5k17byXoLgnF249B//5RDHjyIzPb31uSBypx86jRWqnSgTKBvRDEIbLG X-Received: by 10.28.136.131 with SMTP id k125mr10215958wmd.104.1477060857126; Fri, 21 Oct 2016 07:40:57 -0700 (PDT) Received: from localhost.localdomain (LFbn-1-1885-126.w90-73.abo.wanadoo.fr. [90.73.182.126]) by smtp.gmail.com with ESMTPSA id jt8sm3223281wjc.33.2016.10.21.07.40.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Oct 2016 07:40:56 -0700 (PDT) From: Neil Armstrong To: khilman@baylibre.com, carlo@caione.org, linus.walleij@linaro.org Subject: [RFC PATCH 08/13] dwmac-meson8b: add support for phy selection Date: Fri, 21 Oct 2016 16:40:33 +0200 Message-Id: <1477060838-14164-9-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477060838-14164-1-git-send-email-narmstrong@baylibre.com> References: <1477060838-14164-1-git-send-email-narmstrong@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161021_154119_131787_26F31542 X-CRM114-Status: GOOD ( 16.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Neil Armstrong , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The Meson GXL dwmac Glue Layer also provides switching between an external PHY and an internal RMII 10/100 PHY. Add a way to setup the correct PHY switching from a device tree attribute. Currently, the register format is unknown and this is a temporary workaround until a clarification on the registers fields is received from Amlogic. Signed-off-by: Neil Armstrong --- .../net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index 250e4ce..875cd7c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -53,10 +53,15 @@ #define MUX_CLK_NUM_PARENTS 2 +#define PHYSEL_REG0 0x0 +#define PHYSEL_REG0_VALUE 0x10110181 +#define PHYSEL_REG1 0x4 + struct meson8b_dwmac { struct platform_device *pdev; void __iomem *regs; + void __iomem *physel_regs; phy_interface_t phy_mode; @@ -244,6 +249,23 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac) meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, PRG_ETH0_TX_AND_PHY_REF_CLK, PRG_ETH0_TX_AND_PHY_REF_CLK); + /* Select PHY, either internal or external if specified */ + if (!IS_ERR(dwmac->physel_regs) && + of_find_property(dwmac->pdev->dev.of_node, + "amlogic,phy-select", NULL)) { + u32 val; + + ret = of_property_read_u32(dwmac->pdev->dev.of_node, + "amlogic,phy-select", &val); + if (ret) { + dev_err(&dwmac->pdev->dev, "invalid phy-select property\n"); + } else { + writel(PHYSEL_REG0_VALUE, + dwmac->physel_regs + PHYSEL_REG0); + writel(val, dwmac->physel_regs + PHYSEL_REG1); + } + } + return 0; } @@ -272,6 +294,9 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) if (IS_ERR(dwmac->regs)) return PTR_ERR(dwmac->regs); + res = platform_get_resource(pdev, IORESOURCE_MEM, 2); + dwmac->physel_regs = devm_ioremap_resource(&pdev->dev, res); + dwmac->pdev = pdev; dwmac->phy_mode = of_get_phy_mode(pdev->dev.of_node); if (dwmac->phy_mode < 0) {