netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next 1/4] stmmac: modify and improve the bus_setup platform callback
@ 2012-05-23  5:40 Giuseppe CAVALLARO
  2012-05-23  5:40 ` [net-next 2/4] stmmac: remove two useless initialisation Giuseppe CAVALLARO
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Giuseppe CAVALLARO @ 2012-05-23  5:40 UTC (permalink / raw)
  To: netdev; +Cc: Giuseppe Cavallaro

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(-)

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;
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [net-next 2/4] stmmac: remove two useless initialisation
  2012-05-23  5:40 [net-next 1/4] stmmac: modify and improve the bus_setup platform callback Giuseppe CAVALLARO
@ 2012-05-23  5:40 ` Giuseppe CAVALLARO
  2012-05-23  5:40 ` [net-next 3/4] stmmac: fix driver's doc when run kernel-doc script Giuseppe CAVALLARO
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Giuseppe CAVALLARO @ 2012-05-23  5:40 UTC (permalink / raw)
  To: netdev; +Cc: Giuseppe Cavallaro

This patch removes two useful initialisation in the
stmmac_rx and stmmac_tx function.
In the former, count var was already reset and in the
stmmac_tx we only need to increment the dirty pointer
w/o setting the entry var.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 2fc5462..b942ed4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -677,7 +677,7 @@ static void stmmac_tx(struct stmmac_priv *priv)
 
 		priv->hw->desc->release_tx_desc(p);
 
-		entry = (++priv->dirty_tx) % txsize;
+		priv->dirty_tx++;
 	}
 	if (unlikely(netif_queue_stopped(priv->dev) &&
 		     stmmac_tx_avail(priv) > STMMAC_TX_THRESH(priv))) {
@@ -1303,7 +1303,6 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit)
 		display_ring(priv->dma_rx, rxsize);
 	}
 #endif
-	count = 0;
 	while (!priv->hw->desc->get_rx_owner(p)) {
 		int status;
 
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [net-next 3/4] stmmac: fix driver's doc when run kernel-doc script
  2012-05-23  5:40 [net-next 1/4] stmmac: modify and improve the bus_setup platform callback Giuseppe CAVALLARO
  2012-05-23  5:40 ` [net-next 2/4] stmmac: remove two useless initialisation Giuseppe CAVALLARO
@ 2012-05-23  5:40 ` Giuseppe CAVALLARO
  2012-05-23  5:40 ` [net-next 4/4] stmmac: update driver's doc Giuseppe CAVALLARO
  2012-05-23  5:43 ` [net-next 1/4] stmmac: modify and improve the bus_setup platform callback David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Giuseppe CAVALLARO @ 2012-05-23  5:40 UTC (permalink / raw)
  To: netdev; +Cc: Giuseppe Cavallaro

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b942ed4..fd8bafc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -833,8 +833,9 @@ static u32 stmmac_get_synopsys_id(struct stmmac_priv *priv)
 
 /**
  * stmmac_selec_desc_mode
- * @dev : device pointer
- * Description: select the Enhanced/Alternate or Normal descriptors */
+ * @priv : private structure
+ * Description: select the Enhanced/Alternate or Normal descriptors
+ */
 static void stmmac_selec_desc_mode(struct stmmac_priv *priv)
 {
 	if (priv->plat->enh_desc) {
@@ -1856,6 +1857,8 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
 /**
  * stmmac_dvr_probe
  * @device: device pointer
+ * @plat_dat: platform data pointer
+ * @addr: iobase memory address
  * Description: this is the main probe function used to
  * call the alloc_etherdev, allocate the priv structure.
  */
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [net-next 4/4] stmmac: update driver's doc
  2012-05-23  5:40 [net-next 1/4] stmmac: modify and improve the bus_setup platform callback Giuseppe CAVALLARO
  2012-05-23  5:40 ` [net-next 2/4] stmmac: remove two useless initialisation Giuseppe CAVALLARO
  2012-05-23  5:40 ` [net-next 3/4] stmmac: fix driver's doc when run kernel-doc script Giuseppe CAVALLARO
@ 2012-05-23  5:40 ` Giuseppe CAVALLARO
  2012-05-23  5:43 ` [net-next 1/4] stmmac: modify and improve the bus_setup platform callback David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Giuseppe CAVALLARO @ 2012-05-23  5:40 UTC (permalink / raw)
  To: netdev; +Cc: Giuseppe Cavallaro

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 Documentation/networking/stmmac.txt |   47 ++++++++++++++++++++---------------
 1 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/Documentation/networking/stmmac.txt b/Documentation/networking/stmmac.txt
index 20c01bf..b71f960 100644
--- a/Documentation/networking/stmmac.txt
+++ b/Documentation/networking/stmmac.txt
@@ -10,8 +10,8 @@ Currently this network device driver is for all STM embedded MAC/GMAC
 (i.e. 7xxx/5xxx SoCs), SPEAr (arm), Loongson1B (mips) and XLINX XC2V3000
 FF1152AMT0221 D1215994A VIRTEX FPGA board.
 
-DWC Ether MAC 10/100/1000 Universal version 3.60a (and older) and DWC Ether MAC 10/100
-Universal version 4.0 have been used for developing this driver.
+DWC Ether MAC 10/100/1000 Universal version 3.60a (and older) and DWC Ether
+MAC 10/100 Universal version 4.0 have been used for developing this driver.
 
 This driver supports both the platform bus and PCI.
 
@@ -54,27 +54,27 @@ net_device structure enabling the scatter/gather feature.
 When one or more packets are received, an interrupt happens. The interrupts
 are not queued so the driver has to scan all the descriptors in the ring during
 the receive process.
-This is based on NAPI so the interrupt handler signals only if there is work to be
-done, and it exits.
+This is based on NAPI so the interrupt handler signals only if there is work
+to be done, and it exits.
 Then the poll method will be scheduled at some future point.
 The incoming packets are stored, by the DMA, in a list of pre-allocated socket
 buffers in order to avoid the memcpy (Zero-copy).
 
 4.3) Timer-Driver Interrupt
-Instead of having the device that asynchronously notifies the frame receptions, the
-driver configures a timer to generate an interrupt at regular intervals.
-Based on the granularity of the timer, the frames that are received by the device
-will experience different levels of latency. Some NICs have dedicated timer
-device to perform this task. STMMAC can use either the RTC device or the TMU
-channel 2  on STLinux platforms.
+Instead of having the device that asynchronously notifies the frame receptions,
+the driver configures a timer to generate an interrupt at regular intervals.
+Based on the granularity of the timer, the frames that are received by the
+device will experience different levels of latency. Some NICs have dedicated
+timer device to perform this task. STMMAC can use either the RTC device or the
+TMU channel 2  on STLinux platforms.
 The timers frequency can be passed to the driver as parameter; when change it,
 take care of both hardware capability and network stability/performance impact.
-Several performance tests on STM platforms showed this optimisation allows to spare
-the CPU while having the maximum throughput.
+Several performance tests on STM platforms showed this optimisation allows to
+spare the CPU while having the maximum throughput.
 
 4.4) WOL
-Wake up on Lan feature through Magic and Unicast frames are supported for the GMAC
-core.
+Wake up on Lan feature through Magic and Unicast frames are supported for the
+GMAC core.
 
 4.5) DMA descriptors
 Driver handles both normal and enhanced descriptors. The latter has been only
@@ -106,7 +106,8 @@ Several driver's information can be passed through the platform
 These are included in the include/linux/stmmac.h header file
 and detailed below as well:
 
- struct plat_stmmacenet_data {
+struct plat_stmmacenet_data {
+	char *phy_bus_name;
 	int bus_id;
 	int phy_addr;
 	int interface;
@@ -122,21 +123,27 @@ and detailed below as well:
 	int force_sf_dma_mode;
 	void (*fix_mac_speed)(void *priv, unsigned int speed);
 	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;
+	void *custom_data;
 	void *bsp_priv;
- };
+};
 
 Where:
+ o phy_bus_name: phy bus name to attach to the stmmac.
  o bus_id: bus identifier.
  o phy_addr: the physical address can be passed from the platform.
 	    If it is set to -1 the driver will automatically
 	    detect it at run-time by probing all the 32 addresses.
  o interface: PHY device's interface.
  o mdio_bus_data: specific platform fields for the MDIO bus.
- o pbl: the Programmable Burst Length is maximum number of beats to
+ o dma_cfg: internal DMA parameters
+   o pbl: the Programmable Burst Length is maximum number of beats to
        be transferred in one DMA transaction.
        GMAC also enables the 4xPBL by default.
+   o fixed_burst/mixed_burst/burst_len
  o clk_csr: fixed CSR Clock range selection.
  o has_gmac: uses the GMAC core.
  o enh_desc: if sets the MAC will use the enhanced descriptor structure.
@@ -161,8 +168,9 @@ Where:
 	     this is sometime necessary on some platforms (e.g. ST boxes)
 	     where the HW needs to have set some PIO lines or system cfg
 	     registers.
- o custom_cfg: this is a custom configuration that can be passed while
-	      initialising the resources.
+ o custom_cfg/custom_data: this is a custom configuration that can be passed
+			   while initialising the resources.
+ o bsp_priv: another private poiter.
 
 For MDIO bus The we have:
 
@@ -181,7 +189,6 @@ Where:
  o irqs: list of IRQs, one per PHY.
  o probed_phy_irq: if irqs is NULL, use this for probed PHY.
 
-
 For DMA engine we have the following internal fields that should be
 tuned according to the HW capabilities.
 
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [net-next 1/4] stmmac: modify and improve the bus_setup platform callback
  2012-05-23  5:40 [net-next 1/4] stmmac: modify and improve the bus_setup platform callback Giuseppe CAVALLARO
                   ` (2 preceding siblings ...)
  2012-05-23  5:40 ` [net-next 4/4] stmmac: update driver's doc Giuseppe CAVALLARO
@ 2012-05-23  5:43 ` David Miller
  2012-05-23  6:19   ` Giuseppe CAVALLARO
  3 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2012-05-23  5:43 UTC (permalink / raw)
  To: peppe.cavallaro; +Cc: netdev


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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [net-next 1/4] stmmac: modify and improve the bus_setup platform callback
  2012-05-23  5:43 ` [net-next 1/4] stmmac: modify and improve the bus_setup platform callback David Miller
@ 2012-05-23  6:19   ` Giuseppe CAVALLARO
  0 siblings, 0 replies; 6+ messages in thread
From: Giuseppe CAVALLARO @ 2012-05-23  6:19 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

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
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-05-23  6:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-23  5:40 [net-next 1/4] stmmac: modify and improve the bus_setup platform callback Giuseppe CAVALLARO
2012-05-23  5:40 ` [net-next 2/4] stmmac: remove two useless initialisation Giuseppe CAVALLARO
2012-05-23  5:40 ` [net-next 3/4] stmmac: fix driver's doc when run kernel-doc script Giuseppe CAVALLARO
2012-05-23  5:40 ` [net-next 4/4] stmmac: update driver's doc Giuseppe CAVALLARO
2012-05-23  5:43 ` [net-next 1/4] stmmac: modify and improve the bus_setup platform callback David Miller
2012-05-23  6:19   ` Giuseppe CAVALLARO

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).