netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Dooks <ben-linux@fluff.org>
To: netdev@vger.kernel.org
Cc: jeff@garzik.org, Ben Dooks <ben-linux@fluff.org>
Subject: [patch v2 03/11] DM9000: Add support for DM9000A and DM9000B chips
Date: Sun, 22 Jun 2008 21:16:48 +0100	[thread overview]
Message-ID: <20080622201904.955472088@fluff.org.uk> (raw)
In-Reply-To: 20080622201645.041001353@fluff.org.uk

[-- Attachment #1: simtec/simtec-drivers-net-dm9000-support-dm9000ab.patch --]
[-- Type: text/plain, Size: 4974 bytes --]

Add support for both the DM9000A and DM9000B versions of
the DM9000 networking chip. This includes adding support
for the Link-Change IRQ which is used instead of polling
the PHY every 2 seconds.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>

Index: linux-2.6.26-rc6-quilt1/drivers/net/dm9000.c
===================================================================
--- linux-2.6.26-rc6-quilt1.orig/drivers/net/dm9000.c	2008-06-15 22:52:15.000000000 +0100
+++ linux-2.6.26-rc6-quilt1/drivers/net/dm9000.c	2008-06-15 22:52:19.000000000 +0100
@@ -85,6 +85,16 @@ MODULE_PARM_DESC(watchdog, "transmit tim
  * these two devices.
  */
 
+/* The driver supports the original DM9000E, and now the two newer
+ * devices, DM9000A and DM9000B.
+ */
+
+enum dm9000_type {
+	TYPE_DM9000E,	/* original DM9000 */
+	TYPE_DM9000A,
+	TYPE_DM9000B
+};
+
 /* Structure/enum declaration ------------------------------- */
 typedef struct board_info {
 
@@ -98,9 +108,11 @@ typedef struct board_info {
 	u16 dbug_cnt;
 	u8 io_mode;		/* 0:word, 2:byte */
 	u8 phy_addr;
+	u8 imr_all;
 	unsigned int flags;
 	unsigned int in_suspend :1;
 
+	enum dm9000_type type;
 	int debug_level;
 
 	void (*inblk)(void __iomem *port, void *data, int length);
@@ -302,7 +314,8 @@ static void dm9000_set_io(struct board_i
 
 static void dm9000_schedule_poll(board_info_t *db)
 {
-	schedule_delayed_work(&db->phy_poll, HZ * 2);
+	if (db->type == TYPE_DM9000E)
+		schedule_delayed_work(&db->phy_poll, HZ * 2);
 }
 
 /* Our watchdog timed out. Called by the networking layer */
@@ -516,6 +529,17 @@ dm9000_release_board(struct platform_dev
 	}
 }
 
+static unsigned char dm9000_type_to_char(enum dm9000_type type)
+{
+	switch (type) {
+	case TYPE_DM9000E: return 'e';
+	case TYPE_DM9000A: return 'a';
+	case TYPE_DM9000B: return 'b';
+	}
+
+	return '?';
+}
+
 #define res_size(_r) (((_r)->end - (_r)->start) + 1)
 
 /*
@@ -665,6 +689,23 @@ dm9000_probe(struct platform_device *pde
 		goto out;
 	}
 
+	/* Identify what type of DM9000 we are working on */
+
+	id_val = ior(db, DM9000_CHIPR);
+	dev_dbg(db->dev, "dm9000 revision 0x%02x\n", id_val);
+
+	switch (id_val) {
+	case CHIPR_DM9000A:
+		db->type = TYPE_DM9000A;
+		break;
+	case CHIPR_DM9000B:
+		db->type = TYPE_DM9000B;
+		break;
+	default:
+		dev_dbg(db->dev, "ID %02x => defaulting to DM9000E\n", id_val);
+		db->type = TYPE_DM9000E;
+	}
+
 	/* from this point we assume that we have found a DM9000 */
 
 	/* driver system function */
@@ -715,8 +756,9 @@ dm9000_probe(struct platform_device *pde
 
 	if (ret == 0) {
 		DECLARE_MAC_BUF(mac);
-		printk("%s: dm9000 at %p,%p IRQ %d MAC: %s (%s)\n",
-		       ndev->name,  db->io_addr, db->io_data, ndev->irq,
+		printk("%s: dm9000%c at %p,%p IRQ %d MAC: %s (%s)\n",
+		       ndev->name, dm9000_type_to_char(db->type),
+		       db->io_addr, db->io_data, ndev->irq,
 		       print_mac(mac, ndev->dev_addr), mac_src);
 	}
 	return 0;
@@ -778,6 +820,7 @@ static void
 dm9000_init_dm9000(struct net_device *dev)
 {
 	board_info_t *db = (board_info_t *) dev->priv;
+	unsigned int imr;
 
 	dm9000_dbg(db, 1, "entering %s\n", __func__);
 
@@ -804,8 +847,14 @@ dm9000_init_dm9000(struct net_device *de
 	/* Set address filter table */
 	dm9000_hash_table(dev);
 
+	imr = IMR_PAR | IMR_PTM | IMR_PRM;
+	if (db->type != TYPE_DM9000E)
+		imr |= IMR_LNKCHNG;
+
+	db->imr_all = imr;
+
 	/* Enable TX/RX interrupt mask */
-	iow(db, DM9000_IMR, IMR_PAR | IMR_PTM | IMR_PRM);
+	iow(db, DM9000_IMR, imr);
 
 	/* Init Driver variable */
 	db->tx_pkt_cnt = 0;
@@ -962,8 +1011,15 @@ dm9000_interrupt(int irq, void *dev_id)
 	if (int_status & ISR_PTS)
 		dm9000_tx_done(dev, db);
 
+	if (db->type != TYPE_DM9000E) {
+		if (int_status & ISR_LNKCHNG) {
+			/* fire a link-change request */
+			schedule_delayed_work(&db->phy_poll, 1);
+		}
+	}
+
 	/* Re-enable interrupt mask */
-	iow(db, DM9000_IMR, IMR_PAR | IMR_PTM | IMR_PRM);
+	iow(db, DM9000_IMR, db->imr_all);
 
 	/* Restore previous register address */
 	writeb(reg_save, db->io_addr);
Index: linux-2.6.26-rc6-quilt1/drivers/net/dm9000.h
===================================================================
--- linux-2.6.26-rc6-quilt1.orig/drivers/net/dm9000.h	2008-06-15 22:50:45.000000000 +0100
+++ linux-2.6.26-rc6-quilt1/drivers/net/dm9000.h	2008-06-15 22:52:19.000000000 +0100
@@ -45,6 +45,9 @@
 #define DM9000_CHIPR           0x2C
 #define DM9000_SMCR            0x2F
 
+#define CHIPR_DM9000A	       0x19
+#define CHIPR_DM9000B	       0x1B
+
 #define DM9000_MRCMDX          0xF0
 #define DM9000_MRCMD           0xF2
 #define DM9000_MRRL            0xF4
@@ -131,5 +134,13 @@
 #define DM9000_PKT_RDY		0x01	/* Packet ready to receive */
 #define DM9000_PKT_MAX		1536	/* Received packet max size */
 
+/* DM9000A / DM9000B definitions */
+
+#define IMR_LNKCHNG		(1<<5)
+#define IMR_UNDERRUN		(1<<4)
+
+#define ISR_LNKCHNG		(1<<5)
+#define ISR_UNDERRUN		(1<<4)
+
 #endif /* _DM9000X_H_ */
 

-- 
Ben (ben@fluff.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'

  parent reply	other threads:[~2008-06-22 20:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-22 20:16 [patch v2 00/11] DM9000 patch series for next kernel Ben Dooks
2008-06-22 20:16 ` [patch v2 01/11] DM9000: Remove the 2 resources probe scheme Ben Dooks
2008-06-22 20:34   ` Ben Hutchings
2008-06-22 21:18     ` Ben Dooks
2008-06-23  7:40       ` Laurent Pinchart
2008-06-22 20:16 ` [patch v2 02/11] DM9000: Fixup blackfin after removing 2 resource usage Ben Dooks
2008-06-22 20:35   ` Ben Hutchings
2008-06-23  9:24     ` Ben Dooks
2008-06-23  9:56       ` Bryan Wu
2008-06-23 10:20         ` Ben Dooks
2008-06-24  2:00           ` Bryan Wu
2008-06-22 20:16 ` Ben Dooks [this message]
2008-06-22 20:16 ` [patch v2 04/11] DM9000: Cleanup source code Ben Dooks
2008-06-22 20:16 ` [patch v2 05/11] DM9000: Cleanup source code - remove forward declerations Ben Dooks
2008-06-22 20:16 ` [patch v2 06/11] DM9000: Use NSR to determine link-status on internal PHY Ben Dooks
2008-06-22 20:16 ` [patch v2 07/11] DM9000: Allow the use of the NSR register to get link status Ben Dooks
2008-06-22 20:16 ` [patch v2 08/11] DM9000: Add missing msleep() in EEPROM wait code Ben Dooks
2008-06-22 20:16 ` [patch v2 09/11] DM9000: Re-unit menuconfig entries for DM9000 driver Ben Dooks
2008-06-22 20:16 ` [patch v2 10/11] DM9000: Show Mbps on link change if using simple polling Ben Dooks
2008-06-22 20:16 ` [patch v2 11/11] DM9000: Remove DEFAULT_TRIGGER for request_irq() flags Ben Dooks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080622201904.955472088@fluff.org.uk \
    --to=ben-linux@fluff.org \
    --cc=jeff@garzik.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).