All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Burton <paul.burton@imgtec.com>
To: <linux-mips@linux-mips.org>
Cc: Paul Burton <paul.burton@imgtec.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH 22/28] net: pch_gbe: pull PHY GPIO handling out of Minnow code
Date: Mon, 30 Nov 2015 16:21:47 +0000	[thread overview]
Message-ID: <1448900513-20856-23-git-send-email-paul.burton@imgtec.com> (raw)
In-Reply-To: <1448900513-20856-1-git-send-email-paul.burton@imgtec.com>

The MIPS Boston development board uses the Intel EG20T Platform
Controller Hub, including its gigabit ethernet controller, and requires
that its RTL8211E PHY be reset much like the Minnow platform. Pull the
PHY reset GPIO handling out of Minnow-specific code such that it can be
shared by later patches.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h    |  4 ++-
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   | 33 +++++++++++++++-------
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
index 2a55d6d..884f90b 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
@@ -582,15 +582,17 @@ struct pch_gbe_hw_stats {
 
 /**
  * struct pch_gbe_privdata - PCI Device ID driver data
+ * @phy_reset_gpio:		PHY reset GPIO descriptor.
  * @phy_tx_clk_delay:		Bool, configure the PHY TX delay in software
  * @phy_disable_hibernate:	Bool, disable PHY hibernation
  * @platform_init:		Platform initialization callback, called from
  *				probe, prior to PHY initialization.
  */
 struct pch_gbe_privdata {
+	struct gpio_desc *phy_reset_gpio;
 	bool phy_tx_clk_delay;
 	bool phy_disable_hibernate;
-	int (*platform_init)(struct pci_dev *pdev);
+	int (*platform_init)(struct pci_dev *, struct pch_gbe_privdata *);
 };
 
 /**
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index fde4c11..23d28f0 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -360,6 +360,16 @@ static void pch_gbe_mac_mar_set(struct pch_gbe_hw *hw, u8 * addr, u32 index)
 	pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY);
 }
 
+static void pch_gbe_phy_set_reset(struct pch_gbe_hw *hw, int value)
+{
+	struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
+
+	if (!adapter->pdata || !adapter->pdata->phy_reset_gpio)
+		return;
+
+	gpiod_set_value(adapter->pdata->phy_reset_gpio, value);
+}
+
 /**
  * pch_gbe_mac_reset_hw - Reset hardware
  * @hw:	Pointer to the HW structure
@@ -2627,7 +2637,14 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 	adapter->hw.reg = pcim_iomap_table(pdev)[PCH_GBE_PCI_BAR];
 	adapter->pdata = (struct pch_gbe_privdata *)pci_id->driver_data;
 	if (adapter->pdata && adapter->pdata->platform_init)
-		adapter->pdata->platform_init(pdev);
+		adapter->pdata->platform_init(pdev, pdata);
+
+	if (adapter->pdata && adapter->pdata->phy_reset_gpio) {
+		pch_gbe_phy_set_reset(&adapter->hw, 1);
+		usleep_range(1250, 1500);
+		pch_gbe_phy_set_reset(&adapter->hw, 0);
+		usleep_range(1250, 1500);
+	}
 
 	adapter->ptp_pdev = pci_get_bus_and_slot(adapter->pdev->bus->number,
 					       PCI_DEVFN(12, 4));
@@ -2715,7 +2732,8 @@ err_free_netdev:
 /* The AR803X PHY on the MinnowBoard requires a physical pin to be toggled to
  * ensure it is awake for probe and init. Request the line and reset the PHY.
  */
-static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
+static int pch_gbe_minnow_platform_init(struct pci_dev *pdev,
+					struct pch_gbe_privdata *pdata)
 {
 	unsigned long flags = GPIOF_DIR_OUT | GPIOF_INIT_LOW |
 		GPIOF_EXPORT | GPIOF_ACTIVE_LOW;
@@ -2724,16 +2742,11 @@ static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
 
 	ret = devm_gpio_request_one(&pdev->dev, gpio, flags,
 				    "minnow_phy_reset");
-	if (ret) {
+	if (!ret)
+		pdata->phy_reset_gpio = gpio_to_desc(gpio);
+	else
 		dev_err(&pdev->dev,
 			"ERR: Can't request PHY reset GPIO line '%d'\n", gpio);
-		return ret;
-	}
-
-	gpio_set_value(gpio, 1);
-	usleep_range(1250, 1500);
-	gpio_set_value(gpio, 0);
-	usleep_range(1250, 1500);
 
 	return ret;
 }
-- 
2.6.2


WARNING: multiple messages have this Message-ID (diff)
From: Paul Burton <paul.burton@imgtec.com>
To: linux-mips@linux-mips.org
Cc: Paul Burton <paul.burton@imgtec.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 22/28] net: pch_gbe: pull PHY GPIO handling out of Minnow code
Date: Mon, 30 Nov 2015 16:21:47 +0000	[thread overview]
Message-ID: <1448900513-20856-23-git-send-email-paul.burton@imgtec.com> (raw)
Message-ID: <20151130162147.yk5AZCfVmbIwxlhGIrrIioXCUCWYMYR-rJI6zdMJs6s@z> (raw)
In-Reply-To: <1448900513-20856-1-git-send-email-paul.burton@imgtec.com>

The MIPS Boston development board uses the Intel EG20T Platform
Controller Hub, including its gigabit ethernet controller, and requires
that its RTL8211E PHY be reset much like the Minnow platform. Pull the
PHY reset GPIO handling out of Minnow-specific code such that it can be
shared by later patches.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h    |  4 ++-
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   | 33 +++++++++++++++-------
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
index 2a55d6d..884f90b 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
@@ -582,15 +582,17 @@ struct pch_gbe_hw_stats {
 
 /**
  * struct pch_gbe_privdata - PCI Device ID driver data
+ * @phy_reset_gpio:		PHY reset GPIO descriptor.
  * @phy_tx_clk_delay:		Bool, configure the PHY TX delay in software
  * @phy_disable_hibernate:	Bool, disable PHY hibernation
  * @platform_init:		Platform initialization callback, called from
  *				probe, prior to PHY initialization.
  */
 struct pch_gbe_privdata {
+	struct gpio_desc *phy_reset_gpio;
 	bool phy_tx_clk_delay;
 	bool phy_disable_hibernate;
-	int (*platform_init)(struct pci_dev *pdev);
+	int (*platform_init)(struct pci_dev *, struct pch_gbe_privdata *);
 };
 
 /**
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index fde4c11..23d28f0 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -360,6 +360,16 @@ static void pch_gbe_mac_mar_set(struct pch_gbe_hw *hw, u8 * addr, u32 index)
 	pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY);
 }
 
+static void pch_gbe_phy_set_reset(struct pch_gbe_hw *hw, int value)
+{
+	struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
+
+	if (!adapter->pdata || !adapter->pdata->phy_reset_gpio)
+		return;
+
+	gpiod_set_value(adapter->pdata->phy_reset_gpio, value);
+}
+
 /**
  * pch_gbe_mac_reset_hw - Reset hardware
  * @hw:	Pointer to the HW structure
@@ -2627,7 +2637,14 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 	adapter->hw.reg = pcim_iomap_table(pdev)[PCH_GBE_PCI_BAR];
 	adapter->pdata = (struct pch_gbe_privdata *)pci_id->driver_data;
 	if (adapter->pdata && adapter->pdata->platform_init)
-		adapter->pdata->platform_init(pdev);
+		adapter->pdata->platform_init(pdev, pdata);
+
+	if (adapter->pdata && adapter->pdata->phy_reset_gpio) {
+		pch_gbe_phy_set_reset(&adapter->hw, 1);
+		usleep_range(1250, 1500);
+		pch_gbe_phy_set_reset(&adapter->hw, 0);
+		usleep_range(1250, 1500);
+	}
 
 	adapter->ptp_pdev = pci_get_bus_and_slot(adapter->pdev->bus->number,
 					       PCI_DEVFN(12, 4));
@@ -2715,7 +2732,8 @@ err_free_netdev:
 /* The AR803X PHY on the MinnowBoard requires a physical pin to be toggled to
  * ensure it is awake for probe and init. Request the line and reset the PHY.
  */
-static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
+static int pch_gbe_minnow_platform_init(struct pci_dev *pdev,
+					struct pch_gbe_privdata *pdata)
 {
 	unsigned long flags = GPIOF_DIR_OUT | GPIOF_INIT_LOW |
 		GPIOF_EXPORT | GPIOF_ACTIVE_LOW;
@@ -2724,16 +2742,11 @@ static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
 
 	ret = devm_gpio_request_one(&pdev->dev, gpio, flags,
 				    "minnow_phy_reset");
-	if (ret) {
+	if (!ret)
+		pdata->phy_reset_gpio = gpio_to_desc(gpio);
+	else
 		dev_err(&pdev->dev,
 			"ERR: Can't request PHY reset GPIO line '%d'\n", gpio);
-		return ret;
-	}
-
-	gpio_set_value(gpio, 1);
-	usleep_range(1250, 1500);
-	gpio_set_value(gpio, 0);
-	usleep_range(1250, 1500);
 
 	return ret;
 }
-- 
2.6.2

  parent reply	other threads:[~2015-11-30 16:27 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-30 16:21 [PATCH 00/28] MIPS Boston board support Paul Burton
2015-11-30 16:21 ` Paul Burton
2015-11-30 16:21 ` Paul Burton
2015-11-30 16:21 ` Paul Burton
2015-11-30 16:21 ` [rtc-linux] " Paul Burton
2015-11-30 16:21 ` [PATCH 01/28] serial: earlycon: allow MEM32 I/O for DT earlycon Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 22:52   ` Rob Herring
2015-11-30 22:52     ` Rob Herring
2015-12-02 23:38     ` Peter Hurley
2015-11-30 16:21 ` [PATCH 02/28] dt-bindings: ascii-lcd: Document a binding for simple ASCII LCDs Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 18:57   ` Rob Herring
2015-11-30 18:57     ` Rob Herring
2015-11-30 16:21 ` [PATCH 03/28] auxdisplay: driver for simple memory mapped ASCII LCD displays Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21 ` [PATCH 04/28] MIPS: PCI: compatibility with ARM-like PCI host drivers Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21 ` [PATCH 05/28] PCI: xilinx: keep references to both IRQ domains Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-12-04 18:17   ` Bjorn Helgaas
2015-12-04 18:17     ` Bjorn Helgaas
2015-11-30 16:21 ` [PATCH 06/28] PCI: xilinx: unify INTx & MSI interrupt FIFO decode Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21 ` [PATCH 07/28] PCI: xilinx: always clear interrupt decode register Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21 ` [PATCH 08/28] PCI: xilinx: fix INTX irq dispatch Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21 ` [PATCH 09/28] PCI: xilinx: allow build on MIPS platforms Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21 ` [PATCH 10/28] misc: pch_phub: " Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21 ` [PATCH 11/28] dmaengine: pch_dma: " Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-12-10  3:49   ` Vinod Koul
2015-11-30 16:21 ` [PATCH 12/28] gpio: pch: " Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-12-10 16:23   ` Linus Walleij
2015-11-30 16:21 ` [PATCH 13/28] gpio: pch: allow use from device tree Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-12-10 16:25   ` Linus Walleij
2015-11-30 16:21 ` [PATCH 14/28] i2c: eg20t: allow build on MIPS platforms Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-12-03 21:05   ` Wolfram Sang
2015-11-30 16:21 ` [PATCH 15/28] i2c: eg20t: set i2c_adapter->dev.of_node Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-12-03 21:06   ` Wolfram Sang
2015-11-30 16:21 ` [PATCH 16/28] rtc: m41t80: add devicetree probe support Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21   ` [rtc-linux] " Paul Burton
2015-11-30 16:56   ` Alexandre Belloni
2015-11-30 16:56     ` [rtc-linux] " Alexandre Belloni
2015-11-30 16:21 ` [PATCH 17/28] spi: topcliff-pch: allow build for MIPS platforms Paul Burton
2015-11-30 16:21   ` Paul Burton
     [not found]   ` <1448900513-20856-18-git-send-email-paul.burton-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-11-30 16:39     ` Applied "spi: topcliff-pch: allow build for MIPS platforms" to the spi tree Mark Brown
2015-11-30 16:21 ` [PATCH 18/28] ptp: pch: allow build on MIPS platforms Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-12-01  8:32   ` Richard Cochran
2015-11-30 16:21 ` [PATCH 19/28] net: pch_gbe: " Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21 ` [PATCH 20/28] net: pch_gbe: clear interrupt FIFO during probe Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-12-01  1:48   ` Florian Fainelli
2015-12-01  1:48     ` Florian Fainelli
2015-11-30 16:21 ` [PATCH 21/28] net: pch_gbe: mark Minnow PHY reset GPIO active low Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21 ` Paul Burton [this message]
2015-11-30 16:21   ` [PATCH 22/28] net: pch_gbe: pull PHY GPIO handling out of Minnow code Paul Burton
2015-11-30 16:21 ` [PATCH 23/28] net: pch_gbe: always reset PHY along with MAC Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21 ` [PATCH 24/28] net: pch_gbe: add device tree support Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-12-13  1:22   ` Andy Shevchenko
2015-11-30 16:21 ` [PATCH 25/28] net: pch_gbe: allow longer for resets Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21 ` [PATCH 26/28] MIPS: support for generating FIT (.itb) images Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:21 ` [PATCH 27/28] dt-bindings: mips: img,boston: Document img,boston binding Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 18:34   ` Rob Herring
2015-11-30 16:21 ` [PATCH 28/28] MIPS: Boston board support Paul Burton
2015-11-30 16:21   ` Paul Burton
2015-11-30 16:34 ` [PATCH 00/28] MIPS " Mark Brown
2015-11-30 16:34   ` Mark Brown
2015-11-30 16:34   ` [rtc-linux] " Mark Brown
2015-12-10 16:26   ` Linus Walleij
2015-12-10 16:26     ` Linus Walleij
2015-12-10 16:26     ` [rtc-linux] " Linus Walleij

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=1448900513-20856-23-git-send-email-paul.burton@imgtec.com \
    --to=paul.burton@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.