These patches make it possible to request bus width using platform data. Instead of keep on updating smc911x.h with board specific configuration, use platform data to pass along bus width and irq flags to the driver. While at it, remove some dead code. [PATCH 01/05] smc911x: Remove unused 8-bit I/O operations [PATCH 02/05] smc911x: Fix 16-bit I/O operations [PATCH 03/05] smc911x: Pass along private data and use iomem [PATCH 04/05] smc911x: Introduce platform data flags [PATCH 05/05] smc911x: SuperH architecture support The smc91x driver has gone through a similar change a few months ago. http://www.mail-archive.com/netdev@vger.kernel.org/msg62427.html Signed-off-by: Magnus Damm <damm@igel.co.jp> --- drivers/net/Kconfig | 2 drivers/net/smc911x.c | 423 +++++++++++++++++---------------------- drivers/net/smc911x.h | 505 ++++++++++++++++++++++++++--------------------- include/linux/smc911x.h | 12 + 4 files changed, 483 insertions(+), 459 deletions(-) --
Remove unused SMC_inb() and SMC_outb() functions.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
---
drivers/net/smc911x.h | 4 ----
1 file changed, 4 deletions(-)
--- 0001/drivers/net/smc911x.h
+++ work/drivers/net/smc911x.h 2008-06-02 12:23:49.000000000 +0900
@@ -50,10 +50,8 @@
*/
#if SMC_USE_16BIT
-#define SMC_inb(a, r) readb((a) + (r))
#define SMC_inw(a, r) readw((a) + (r))
#define SMC_inl(a, r) ((SMC_inw(a, r) & 0xFFFF)+(SMC_inw(a+2, r)<<16))
-#define SMC_outb(v, a, r) writeb(v, (a) + (r))
#define SMC_outw(v, a, r) writew(v, (a) + (r))
#define SMC_outl(v, a, r) \
do{ \
@@ -64,10 +62,8 @@
#define SMC_outsl(a, r, p, l) writesw((short*)((a) + (r)), p, l*2)
#elif SMC_USE_32BIT
-#define SMC_inb(a, r) readb((a) + (r))
#define SMC_inw(a, r) readw((a) + (r))
#define SMC_inl(a, r) readl((a) + (r))
-#define SMC_outb(v, a, r) writeb(v, (a) + (r))
#define SMC_outl(v, a, r) writel(v, (a) + (r))
#define SMC_insl(a, r, p, l) readsl((int*)((a) + (r)), p, l)
#define SMC_outsl(a, r, p, l) writesl((int*)((a) + (r)), p, l)
--
On Mon, 02 Jun 2008 20:37:14 +0900 It's a bit strange to have the Author: line using one email address and the s-o-b using a different one. (It's fairly common though). It is fixable by putting the desired From: address right at the top of the changelog, in the email body. --
FWIW, I tend to think it's useful... I like to use @redhat.com sign-offs because I'm working on behalf of red hat, but for all non-NDA email I use an account that doesn't depend on my employer. Because of the potential for unintended info leakage these days, corporate email access is reclaimed the minute you leave a company. It isn't wise to depend on the corporate email account. That's why I patiently and kindly ask people to email me at the addresses I've always used for open source (jgarzik@pobox, jeff@garzik). Open conversations don't need to get locked in a corporate tomb :) Jeff --
This patch fixes the following issues related to 16-bit support:
- Remove unused 16-bit PXA DMA implementation.
- Remove unused SMC_inw() and SMC_outw() functions.
- Fix 16-bit SMC_outl to use writew() instead of writel().
Signed-off-by: Magnus Damm <damm@igel.co.jp>
---
drivers/net/smc911x.h | 66 ++-----------------------------------------------
1 file changed, 3 insertions(+), 63 deletions(-)
--- 0002/drivers/net/smc911x.h
+++ work/drivers/net/smc911x.h 2008-06-02 12:39:11.000000000 +0900
@@ -50,19 +50,16 @@
*/
#if SMC_USE_16BIT
-#define SMC_inw(a, r) readw((a) + (r))
-#define SMC_inl(a, r) ((SMC_inw(a, r) & 0xFFFF)+(SMC_inw(a+2, r)<<16))
-#define SMC_outw(v, a, r) writew(v, (a) + (r))
+#define SMC_inl(a, r) (readw((a) + (r)) & 0xFFFF) + (readw((a) + (r) + 2) << 16))
#define SMC_outl(v, a, r) \
do{ \
- writel(v & 0xFFFF, (a) + (r)); \
- writel(v >> 16, (a) + (r) + 2); \
+ writew(v & 0xFFFF, (a) + (r)); \
+ writew(v >> 16, (a) + (r) + 2); \
} while (0)
#define SMC_insl(a, r, p, l) readsw((short*)((a) + (r)), p, l*2)
#define SMC_outsl(a, r, p, l) writesw((short*)((a) + (r)), p, l*2)
#elif SMC_USE_32BIT
-#define SMC_inw(a, r) readw((a) + (r))
#define SMC_inl(a, r) readl((a) + (r))
#define SMC_outl(v, a, r) writel(v, (a) + (r))
#define SMC_insl(a, r, p, l) readsl((int*)((a) + (r)), p, l)
@@ -132,34 +129,6 @@ smc_pxa_dma_insl(struct device *dev, u_l
}
#endif
-#ifdef SMC_insw
-#undef SMC_insw
-#define SMC_insw(a, r, p, l) \
- smc_pxa_dma_insw(lp->dev, a, lp->physaddr, r, lp->rxdma, p, l)
-
-static inline void
-smc_pxa_dma_insw(struct device *dev, u_long ioaddr, u_long physaddr,
- int reg, int dma, u_char *buf, int len)
-{
- /* 64 bit alignment is required for memory to memory DMA */
- while ((long)buf & 6) {
- *((u16 *)buf) = SMC_inw(ioaddr, reg);
- buf += 2;
- len--;
- }
-
- len *= 2;
- rx_dmabuf = dma_map_single(dev, buf, len, DMA_FROM_DEVICE);
- rx_dmalen = len;
- DCSR(dma) = ...This patch contains changes needed for platform data support:
- Move smc911x_local structure to header file
- Pass along smc911x_local structure pointer to macros
- Keep register base address in smc911x_local structure
- Remove unused ioaddr variables
Signed-off-by: Magnus Damm <damm@igel.co.jp>
---
drivers/net/smc911x.c | 406 ++++++++++++++++++++-----------------------------
drivers/net/smc911x.h | 353 ++++++++++++++++++++++++------------------
2 files changed, 370 insertions(+), 389 deletions(-)
--- 0001/drivers/net/smc911x.c
+++ work/drivers/net/smc911x.c 2008-06-02 18:29:48.000000000 +0900
@@ -106,56 +106,6 @@ MODULE_ALIAS("platform:smc911x");
*/
#define POWER_DOWN 1
-
-/* store this information for the driver.. */
-struct smc911x_local {
- /*
- * If I have to wait until the DMA is finished and ready to reload a
- * packet, I will store the skbuff here. Then, the DMA will send it
- * out and free it.
- */
- struct sk_buff *pending_tx_skb;
-
- /* version/revision of the SMC911x chip */
- u16 version;
- u16 revision;
-
- /* FIFO sizes */
- int tx_fifo_kb;
- int tx_fifo_size;
- int rx_fifo_size;
- int afc_cfg;
-
- /* Contains the current active receive/phy mode */
- int ctl_rfduplx;
- int ctl_rspeed;
-
- u32 msg_enable;
- u32 phy_type;
- struct mii_if_info mii;
-
- /* work queue */
- struct work_struct phy_configure;
- int work_pending;
-
- int tx_throttle;
- spinlock_t lock;
-
- struct net_device *netdev;
-
-#ifdef SMC_USE_DMA
- /* DMA needs the physical address of the chip */
- u_long physaddr;
- int rxdma;
- int txdma;
- int rxdma_active;
- int txdma_active;
- struct sk_buff *current_rx_skb;
- struct sk_buff *current_tx_skb;
- struct device *dev;
-#endif
-};
-
#if SMC_DEBUG > 0
#define DBG(n, args...) \
do { \
@@ -203,24 +153,24 @@ static void PRINT_PKT(u_char *buf, int l
/* this enables an interrupt in the interrupt mask register */
-#define SMC_ENABLE_INT(x) do { \
+#define ...Enable the smc911x driver for the SuperH architecture. While at it remove the unused SMC_USE_SH_DMA definition. Signed-off-by: Magnus Damm <damm@igel.co.jp> --- drivers/net/Kconfig | 2 +- drivers/net/smc911x.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) --- 0001/drivers/net/Kconfig +++ work/drivers/net/Kconfig 2008-06-02 18:36:29.000000000 +0900 @@ -955,7 +955,7 @@ config SMC911X tristate "SMSC LAN911[5678] support" select CRC32 select MII - depends on ARCH_PXA || SH_MAGIC_PANEL_R2 + depends on ARCH_PXA || SUPERH help This is a driver for SMSC's LAN911x series of Ethernet chipsets including the new LAN9115, LAN9116, LAN9117, and LAN9118. --- 0005/drivers/net/smc911x.h +++ work/drivers/net/smc911x.h 2008-06-02 18:58:10.000000000 +0900 @@ -39,7 +39,6 @@ #define SMC_USE_32BIT 1 #define SMC_IRQ_SENSE IRQF_TRIGGER_FALLING #elif defined(CONFIG_SH_MAGIC_PANEL_R2) - #define SMC_USE_SH_DMA 0 #define SMC_USE_16BIT 0 #define SMC_USE_32BIT 1 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW --
This patch adds a new header file for platform data information
together with code that adds run time bus width and irq flag support.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
---
drivers/net/smc911x.c | 17 +++++++++
drivers/net/smc911x.h | 81 +++++++++++++++++++++++++++++++++++++++++++++++
include/linux/smc911x.h | 12 ++++++
3 files changed, 109 insertions(+), 1 deletion(-)
--- 0004/drivers/net/smc911x.c
+++ work/drivers/net/smc911x.c 2008-06-02 18:34:05.000000000 +0900
@@ -1819,6 +1819,7 @@ static int __init smc911x_probe(struct n
int i, retval;
unsigned int val, chip_id, revision;
const char *version_string;
+ unsigned long irq_flags;
DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
@@ -1985,9 +1986,15 @@ static int __init smc911x_probe(struct n
lp->ctl_rfduplx = 1;
lp->ctl_rspeed = 100;
+#ifdef SMC_DYNAMIC_BUS_CONFIG
+ irq_flags = lp->cfg.irq_flags;
+#else
+ irq_flags = IRQF_SHARED | SMC_IRQ_SENSE;
+#endif
+
/* Grab the IRQ */
retval = request_irq(dev->irq, &smc911x_interrupt,
- IRQF_SHARED | SMC_IRQ_SENSE, dev->name, dev);
+ irq_flags, dev->name, dev);
if (retval)
goto err_out;
@@ -2057,6 +2064,7 @@ err_out:
*/
static int smc911x_drv_probe(struct platform_device *pdev)
{
+ struct smc91x_platdata *pd = pdev->dev.platform_data;
struct net_device *ndev;
struct resource *res;
struct smc911x_local *lp;
@@ -2090,6 +2098,13 @@ static int smc911x_drv_probe(struct plat
ndev->irq = platform_get_irq(pdev, 0);
lp = netdev_priv(ndev);
lp->netdev = ndev;
+#ifdef SMC_DYNAMIC_BUS_CONFIG
+ if (!pd) {
+ ret = -EINVAL;
+ goto release_both;
+ }
+ memcpy(&lp->cfg, pd, sizeof(lp->cfg));
+#endif
addr = ioremap(res->start, SMC911X_IO_EXTENT);
if (!addr) {
--- 0004/drivers/net/smc911x.h
+++ work/drivers/net/smc911x.h 2008-06-02 19:37:21.000000000 +0900
@@ -29,6 +29,7 @@
#ifndef _SMC911X_H_
#define _SMC911X_H_
+#include <linux/smc911x.h>
/*
* Use the DMA feature ...