summaryrefslogtreecommitdiffstats
path: root/drivers/net/dm9000.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-07-05 18:01:30 +0200
committerSascha Hauer <sha@octopus.labnet.pengutronix.de>2007-07-05 18:01:30 +0200
commit2ae2044e399399a3ed13eaa6b1ee6086c686ac34 (patch)
tree85546e3f67dc69e98306b20eae61d4149d4a40de /drivers/net/dm9000.c
parent56c5a861cefeff11eeda8e6f1c79a27cd22a8b78 (diff)
downloadbarebox-2ae2044e399399a3ed13eaa6b1ee6086c686ac34.tar.gz
barebox-2ae2044e399399a3ed13eaa6b1ee6086c686ac34.tar.xz
svn_rev_179
refacture, remove static eth_device because it does not work with more than one device
Diffstat (limited to 'drivers/net/dm9000.c')
-rw-r--r--drivers/net/dm9000.c69
1 files changed, 36 insertions, 33 deletions
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 98171222e9..cfd847fdce 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -47,6 +47,7 @@ TODO: Homerun NIC and longrun NIC are not functional, only internal at the
#include <driver.h>
#include <clock.h>
#include <miiphy.h>
+#include <malloc.h>
#include <net.h>
#include <init.h>
#include <asm/io.h>
@@ -160,30 +161,6 @@ static void dm9000_reset(void)
udelay(1000); /* delay 1ms */
}
-int dm9000_probe(struct device_d *dev)
-{
-// struct eth_device *ndev = dev->type_data;
-
- printf("dm9000_eth_init()\n");
-
- /* RESET device */
- dm9000_reset();
- dm9000_check_id();
-
- /* Program operating register */
- DM9000_iow(DM9000_NCR, 0x0); /* only intern phy supported by now */
- DM9000_iow(DM9000_TCR, 0); /* TX Polling clear */
- DM9000_iow(DM9000_BPTR, 0x3f); /* Less 3Kb, 200us */
- DM9000_iow(DM9000_FCTR, FCTR_HWOT(3) | FCTR_LWOT(8)); /* Flow Control : High/Low Water */
- DM9000_iow(DM9000_FCR, 0x0); /* SH FIXME: This looks strange! Flow Control */
- DM9000_iow(DM9000_SMCR, 0); /* Special Mode */
- DM9000_iow(DM9000_NSR, NSR_WAKEST | NSR_TX2END | NSR_TX1END); /* clear TX status */
- DM9000_iow(DM9000_ISR, 0x0f); /* Clear interrupt status */
-
- return 0;
-}
-
-
int dm9000_eth_open(struct eth_device *ndev)
{
int lnk, i = 0, ctl;
@@ -429,20 +406,46 @@ printf("dm9000_set_mac_address\n");
return -0;
}
-struct eth_device dm9000_eth = {
- .open = dm9000_eth_open,
- .send = dm9000_eth_send,
- .recv = dm9000_eth_rx,
- .halt = dm9000_eth_halt,
- .get_mac_address = dm9000_get_mac_address,
- .set_mac_address = dm9000_set_mac_address,
-};
+int dm9000_probe(struct device_d *dev)
+{
+ struct eth_device *edev;
+
+ printf("dm9000_eth_init()\n");
+
+ edev = malloc(sizeof(struct eth_device));
+ dev->priv = edev;
+ edev->dev = dev;
+
+ edev->open = dm9000_eth_open;
+ edev->send = dm9000_eth_send;
+ edev->recv = dm9000_eth_rx;
+ edev->halt = dm9000_eth_halt;
+ edev->get_mac_address = dm9000_get_mac_address;
+ edev->set_mac_address = dm9000_set_mac_address;
+
+ /* RESET device */
+ dm9000_reset();
+ dm9000_check_id();
+
+ /* Program operating register */
+ DM9000_iow(DM9000_NCR, 0x0); /* only intern phy supported by now */
+ DM9000_iow(DM9000_TCR, 0); /* TX Polling clear */
+ DM9000_iow(DM9000_BPTR, 0x3f); /* Less 3Kb, 200us */
+ DM9000_iow(DM9000_FCTR, FCTR_HWOT(3) | FCTR_LWOT(8)); /* Flow Control : High/Low Water */
+ DM9000_iow(DM9000_FCR, 0x0); /* SH FIXME: This looks strange! Flow Control */
+ DM9000_iow(DM9000_SMCR, 0); /* Special Mode */
+ DM9000_iow(DM9000_NSR, NSR_WAKEST | NSR_TX2END | NSR_TX1END); /* clear TX status */
+ DM9000_iow(DM9000_ISR, 0x0f); /* Clear interrupt status */
+
+ eth_register(edev);
+
+ return 0;
+}
static struct driver_d dm9000_driver = {
.name = "dm9000",
.probe = dm9000_probe,
.type = DEVICE_TYPE_ETHER,
- .type_data = &dm9000_eth,
};
static int dm9000_init(void)