This patch adds support to the ax88796 ethernet driver to take IRQ flags
given by the platform_device definition.
Signed-off-by: Daniel Mack <[email protected]>
Cc: Ben Dooks <[email protected]>
Cc: David Miller <[email protected]>
---
drivers/net/ax88796.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c
index a4eb6c4..e7c9748 100644
--- a/drivers/net/ax88796.c
+++ b/drivers/net/ax88796.c
@@ -93,6 +93,7 @@ struct ax_device {
unsigned char running;
unsigned char resume_open;
+ unsigned int irqflags;
u32 reg_offsets[0x20];
};
@@ -474,7 +475,8 @@ static int ax_open(struct net_device *dev)
dev_dbg(&ax->dev->dev, "%s: open\n", dev->name);
- ret = request_irq(dev->irq, ax_ei_interrupt, 0, dev->name, dev);
+ ret = request_irq(dev->irq, ax_ei_interrupt, ax->irqflags,
+ dev->name, dev);
if (ret)
return ret;
@@ -829,7 +831,7 @@ static int ax_probe(struct platform_device *pdev)
struct ax_device *ax;
struct resource *res;
size_t size;
- int ret;
+ int ret = 0;
dev = ax__alloc_ei_netdev(sizeof(struct ax_device));
if (dev == NULL)
@@ -850,12 +852,14 @@ static int ax_probe(struct platform_device *pdev)
/* find the platform resources */
- ret = platform_get_irq(pdev, 0);
- if (ret < 0) {
+ res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ if (res == NULL) {
dev_err(&pdev->dev, "no IRQ specified\n");
goto exit_mem;
}
- dev->irq = ret;
+
+ dev->irq = res->start;
+ ax->irqflags = res->flags & IRQF_TRIGGER_MASK;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) {
--
1.6.2
Implement a way to provide the MAC address for ax88796 devices from
their platform data. Boards might decide to set the address
programmatically, taken from boot tags or other sources.
Signed-off-by: Daniel Mack <[email protected]>
Cc: David Miller <[email protected]>
Cc: Ben Dooks <[email protected]>
Cc: Matthias Meier <[email protected]>
---
drivers/net/ax88796.c | 17 ++++++++++++-----
include/net/ax88796.h | 13 ++++++++-----
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c
index e7c9748..62d9c9c 100644
--- a/drivers/net/ax88796.c
+++ b/drivers/net/ax88796.c
@@ -733,12 +733,19 @@ static int ax_init_dev(struct net_device *dev, int first_init)
/* load the mac-address from the device if this is the
* first time we've initialised */
- if (first_init && ax->plat->flags & AXFLG_MAC_FROMDEV) {
- ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP,
- ei_local->mem + E8390_CMD); /* 0x61 */
+ if (first_init) {
+ if (ax->plat->flags & AXFLG_MAC_FROMDEV) {
+ ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP,
+ ei_local->mem + E8390_CMD); /* 0x61 */
+ for (i = 0; i < ETHER_ADDR_LEN; i++)
+ dev->dev_addr[i] =
+ ei_inb(ioaddr + EN1_PHYS_SHIFT(i));
+ }
- for (i = 0 ; i < ETHER_ADDR_LEN ; i++)
- dev->dev_addr[i] = ei_inb(ioaddr + EN1_PHYS_SHIFT(i));
+ if ((ax->plat->flags & AXFLG_MAC_FROMPLATFORM) &&
+ ax->plat->mac_addr)
+ memcpy(dev->dev_addr, ax->plat->mac_addr,
+ ETHER_ADDR_LEN);
}
ax_reset_8390(dev);
diff --git a/include/net/ax88796.h b/include/net/ax88796.h
index 51329da..b9a3bec 100644
--- a/include/net/ax88796.h
+++ b/include/net/ax88796.h
@@ -15,14 +15,17 @@
#define AXFLG_HAS_EEPROM (1<<0)
#define AXFLG_MAC_FROMDEV (1<<1) /* device already has MAC */
#define AXFLG_HAS_93CX6 (1<<2) /* use eeprom_93cx6 driver */
+#define AXFLG_MAC_FROMPLATFORM (1<<3) /* MAC given by platform data */
struct ax_plat_data {
unsigned int flags;
- unsigned char wordlength; /* 1 or 2 */
- unsigned char dcr_val; /* default value for DCR */
- unsigned char rcr_val; /* default value for RCR */
- unsigned char gpoc_val; /* default value for GPOC */
- u32 *reg_offsets; /* register offsets */
+ unsigned char wordlength; /* 1 or 2 */
+ unsigned char dcr_val; /* default value for DCR */
+ unsigned char rcr_val; /* default value for RCR */
+ unsigned char gpoc_val; /* default value for GPOC */
+ u32 *reg_offsets; /* register offsets */
+ u8 *mac_addr; /* MAC addr (only used when
+ AXFLG_MAC_FROMPLATFORM is used */
};
#endif /* __NET_AX88796_PLAT_H */
--
1.6.2
On Sun, Mar 22, 2009 at 05:12:40PM +0100, Daniel Mack wrote:
> This patch adds support to the ax88796 ethernet driver to take IRQ flags
> given by the platform_device definition.
Please note that in contrast to the version I posted here previously,
this patch does not use platform_get_irq_flags() anymore. Nobody seemed
interested in the patch I sent along to implement that in
drivers/base/platform.c, so I gather the flags manually from this driver
now, using platform_get_resource().
Daniel
From: Daniel Mack <[email protected]>
Date: Sun, 22 Mar 2009 17:12:40 +0100
> This patch adds support to the ax88796 ethernet driver to take IRQ flags
> given by the platform_device definition.
>
> Signed-off-by: Daniel Mack <[email protected]>
Applied.
From: Daniel Mack <[email protected]>
Date: Sun, 22 Mar 2009 17:12:41 +0100
> Implement a way to provide the MAC address for ax88796 devices from
> their platform data. Boards might decide to set the address
> programmatically, taken from boot tags or other sources.
>
> Signed-off-by: Daniel Mack <[email protected]>
Also applied, thanks.