diff mbox

[net-next,1/4] stmmac: modify and improve the bus_setup platform callback

Message ID 1337751619-21941-1-git-send-email-peppe.cavallaro@st.com
State Deferred, archived
Delegated to: David Miller
Headers show

Commit Message

Giuseppe CAVALLARO May 23, 2012, 5:40 a.m. UTC
This patch modifies and improves the bus_setup callback now
by passing extra parameters that can help on more complex
platforms that require more custom settings.
The patch also updates the documentation.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 Documentation/networking/stmmac.txt               |    3 ++-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   19 +++++++++++++++----
 include/linux/stmmac.h                            |    3 ++-
 3 files changed, 19 insertions(+), 6 deletions(-)

Comments

David Miller May 23, 2012, 5:43 a.m. UTC | #1
As I stated the other day, the net-next tree is closed, therefore only
bug fixes are appropriate at this time.

If there are bug fixes you want integrated in this series, you need
to seperate them out and submit them only at this time.

When net-next opens back up you can submit the rest.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Giuseppe CAVALLARO May 23, 2012, 6:19 a.m. UTC | #2
Hello David

On 5/23/2012 7:43 AM, David Miller wrote:
> 
> As I stated the other day, the net-next tree is closed, therefore only
> bug fixes are appropriate at this time.

Ok, so only these patches shouldbe considered:

  stmmac: update driver's doc
  stmmac: remove two useless initialisation
  stmmac: remove two useless initialisation

and

  stmmac: fix driver Kconfig when built as module
     This is attached to another thread and under review.


> If there are bug fixes you want integrated in this series, you need
> to seperate them out and submit them only at this time.

Thanks, I'm resending them again for net.git.

> When net-next opens back up you can submit the rest.

I'll only resend the following patch (that should be stay in next repo)
later:
     stmmac: modify and improve the bus_setup platform callback

Regards
Peppe

> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Documentation/networking/stmmac.txt b/Documentation/networking/stmmac.txt
index ab1e8d7..20c01bf 100644
--- a/Documentation/networking/stmmac.txt
+++ b/Documentation/networking/stmmac.txt
@@ -121,7 +121,7 @@  and detailed below as well:
 	int pmt;
 	int force_sf_dma_mode;
 	void (*fix_mac_speed)(void *priv, unsigned int speed);
-	void (*bus_setup)(void __iomem *ioaddr);
+	void *(*bus_setup)(void __iomem *ioaddr, struct device *dev, void *d);
 	int (*init)(struct platform_device *pdev);
 	void (*exit)(struct platform_device *pdev);
 	void *bsp_priv;
@@ -156,6 +156,7 @@  Where:
  o bus_setup: perform HW setup of the bus. For example, on some ST platforms
 	     this field is used to configure the AMBA  bridge to generate more
 	     efficient STBus traffic.
+ o bus_data: saved custom data for custom bus setting.
  o init/exit: callbacks used for calling a custom initialisation;
 	     this is sometime necessary on some platforms (e.g. ST boxes)
 	     where the HW needs to have set some PIO lines or system cfg
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 7096633..2fc5462 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -999,10 +999,6 @@  static int stmmac_open(struct net_device *dev)
 	/* Copy the MAC addr into the HW  */
 	priv->hw->mac->set_umac_addr(priv->ioaddr, dev->dev_addr, 0);
 
-	/* If required, perform hw setup of the bus. */
-	if (priv->plat->bus_setup)
-		priv->plat->bus_setup(priv->ioaddr);
-
 	/* Initialize the MAC Core */
 	priv->hw->mac->core_init(priv->ioaddr);
 
@@ -1949,6 +1945,15 @@  struct stmmac_priv *stmmac_dvr_probe(struct device *device,
 		goto error;
 	}
 
+	/* On some platforms, is is possible to perform some hw setup of the bus
+	 * and this is done by calling the bus_setup (when implemented).
+	 * Data from bus_setup can be saved in the patform structure to be
+	 * restored when resume for example form standby.
+	 */
+	if (priv->plat->bus_setup)
+		priv->plat->bus_data =
+			priv->plat->bus_setup(priv->ioaddr, priv->device,
+					      priv->plat->bus_data);
 	return priv;
 
 error:
@@ -2057,6 +2062,8 @@  int stmmac_resume(struct net_device *ndev)
 	priv->hw->dma->start_tx(priv->ioaddr);
 	priv->hw->dma->start_rx(priv->ioaddr);
 
+	priv->plat->bus_data = priv->plat->bus_setup(priv->ioaddr, priv->device,
+						     priv->plat->bus_data);
 #ifdef CONFIG_STMMAC_TIMER
 	if (likely(priv->tm->enable))
 		priv->tm->timer_start(tmrate);
@@ -2083,9 +2090,13 @@  int stmmac_freeze(struct net_device *ndev)
 
 int stmmac_restore(struct net_device *ndev)
 {
+	struct stmmac_priv *priv = netdev_priv(ndev);
+
 	if (!ndev || !netif_running(ndev))
 		return 0;
 
+	priv->plat->bus_data = priv->plat->bus_setup(priv->ioaddr, priv->device,
+						     priv->plat->bus_data);
 	return stmmac_open(ndev);
 }
 #endif /* CONFIG_PM */
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index b69bdb1..cf03968 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -106,7 +106,8 @@  struct plat_stmmacenet_data {
 	int pmt;
 	int force_sf_dma_mode;
 	void (*fix_mac_speed)(void *priv, unsigned int speed);
-	void (*bus_setup)(void __iomem *ioaddr);
+	void *(*bus_setup)(void __iomem *ioaddr, struct device *dev, void *d);
+	void *bus_data;
 	int (*init)(struct platform_device *pdev);
 	void (*exit)(struct platform_device *pdev);
 	void *custom_cfg;