mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neil Armstrong <narmstrong@baylibre.com>
To: khilman@baylibre.com, carlo@caione.org, linus.walleij@linaro.org
Cc: Neil Armstrong <narmstrong@baylibre.com>,
	linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org
Subject: [RFC PATCH 08/13] dwmac-meson8b: add support for phy selection
Date: Fri, 21 Oct 2016 16:40:33 +0200	[thread overview]
Message-ID: <1477060838-14164-9-git-send-email-narmstrong@baylibre.com> (raw)
In-Reply-To: <1477060838-14164-1-git-send-email-narmstrong@baylibre.com>

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 <narmstrong@baylibre.com>
---
 .../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) {
-- 
1.9.1

  parent reply	other threads:[~2016-10-21 14:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-21 14:40 [RFC PATCH 00/13] ARM64: meson-gxl: Add extended support Neil Armstrong
2016-10-21 14:40 ` [RFC PATCH 01/13] pinctrl: meson: Add GXL pinctrl definitions Neil Armstrong
2016-10-24  1:03   ` Linus Walleij
2016-10-31  9:40     ` Neil Armstrong
2016-10-31 18:23       ` Kevin Hilman
2016-10-30 20:41   ` Rob Herring
2016-10-21 14:40 ` [RFC PATCH 02/13] ARM64: dts: meson-gxbb: Move common nodes to meson-gx Neil Armstrong
2016-10-21 14:40 ` [RFC PATCH 03/13] ARM64: dts: meson-gxl: Add pinctrl nodes Neil Armstrong
2016-10-21 14:40 ` [RFC PATCH 04/13] ARM64: dts: meson-gxl: Add clock nodes Neil Armstrong
2016-10-21 14:40 ` [RFC PATCH 05/13] ARM64: dts: meson-gxl: Add i2c nodes Neil Armstrong
2016-10-21 14:40 ` [RFC PATCH 06/13] ARM64: dts: meson-gxl: Add MMC/SD/SDIO nodes Neil Armstrong
2016-10-21 14:40 ` [RFC PATCH 07/13] ARM64: dts: meson-gxl-p23x: Add uart pinctrl Neil Armstrong
2016-10-21 14:40 ` Neil Armstrong [this message]
2016-10-21 15:46   ` [RFC PATCH 08/13] dwmac-meson8b: add support for phy selection Andrew Lunn
2016-10-21 15:54   ` Andrew Lunn
2016-10-21 15:59     ` Neil Armstrong
2016-10-21 16:08       ` Andrew Lunn
2016-10-31 14:23         ` Neil Armstrong
2016-10-21 14:40 ` [RFC PATCH 09/13] net: phy: Add Meson GXL Internal PHY driver Neil Armstrong
2016-10-21 20:56   ` Florian Fainelli
2016-10-31 14:25     ` Neil Armstrong
2016-10-21 14:40 ` [RFC PATCH 10/13] ARM64: dts: meson-gxl: Add ethernet nodes with internal PHY Neil Armstrong
2016-10-21 14:40 ` [RFC PATCH 11/13] ARM64: dts: meson-gxl-p23x: Enable ethernet Neil Armstrong
2016-10-21 14:40 ` [RFC PATCH 12/13] ARM64: dts: meson-gxl-p23x: Add SD/SDIO/MMC and PWM nodes Neil Armstrong
2016-10-21 14:40 ` [RFC PATCH 13/13] ARM64: dts: meson-gxl-p23x: Enable IR receiver Neil Armstrong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1477060838-14164-9-git-send-email-narmstrong@baylibre.com \
    --to=narmstrong@baylibre.com \
    --cc=carlo@caione.org \
    --cc=devicetree@vger.kernel.org \
    --cc=khilman@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome