linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Josh Boyer <jwboyer@linux.vnet.ibm.com>
To: paulus@samba.org
Cc: linuxppc-dev@ozlabs.org
Subject: [PATCH v4 2/7] Generalize tsi108 PHY types
Date: Mon, 07 May 2007 16:26:22 -0500	[thread overview]
Message-ID: <1178573182.2990.201.camel@zod.rchland.ibm.com> (raw)
In-Reply-To: <1178572962.2990.197.camel@zod.rchland.ibm.com>

Add a phy_type field to the tsi108 ethernet structures to indicate which PHY
is used on a board.  This is derived from the "compatible" property in the
ethernet-phy node of the device tree.  The default remains the MV88E PHY.

Also, convert the setup code to use of_get_mac_address instead of hard coding
a lookup for the "address" property in the ethernet node.

Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>

---
 arch/powerpc/sysdev/tsi108_dev.c |    7 +++++--
 drivers/net/tsi108_eth.c         |   12 +++++++-----
 drivers/net/tsi108_eth.h         |    9 ---------
 include/asm-powerpc/tsi108.h     |   11 +++++++++++
 4 files changed, 23 insertions(+), 16 deletions(-)

--- linux-2.6.orig/arch/powerpc/sysdev/tsi108_dev.c
+++ linux-2.6/arch/powerpc/sysdev/tsi108_dev.c
@@ -107,8 +107,9 @@ static int __init tsi108_eth_of_init(voi
 			goto err;
 		}
 
-		mac_addr = of_get_property(np, "address", NULL);
-		memcpy(tsi_eth_data.mac_addr, mac_addr, 6);
+		mac_addr = of_get_mac_address(np);
+		if (mac_addr)
+			memcpy(tsi_eth_data.mac_addr, mac_addr, 6);
 
 		ph = of_get_property(np, "phy-handle", NULL);
 		phy = of_find_node_by_phandle(*ph);
@@ -129,6 +130,8 @@ static int __init tsi108_eth_of_init(voi
 		tsi_eth_data.phyregs = res.start;
 		tsi_eth_data.phy = *phy_id;
 		tsi_eth_data.irq_num = irq_of_parse_and_map(np, 0);
+		if (of_device_is_compatible(phy, "bcm54xx"))
+			tsi_eth_data.phy_type = TSI108_PHY_BCM54XX;
 		of_node_put(phy);
 		ret =
 		    platform_device_add_data(tsi_eth_dev, &tsi_eth_data,
--- linux-2.6.orig/drivers/net/tsi108_eth.c
+++ linux-2.6/drivers/net/tsi108_eth.c
@@ -82,6 +82,7 @@ struct tsi108_prv_data {
 	unsigned int phy;		/* Index of PHY for this interface */
 	unsigned int irq_num;
 	unsigned int id;
+	unsigned int phy_type;
 
 	struct timer_list timer;/* Timer that triggers the check phy function */
 	unsigned int rxtail;	/* Next entry in rxring to read */
@@ -1256,11 +1257,11 @@ static void tsi108_init_phy(struct net_d
 	if (i == 0)
 		printk(KERN_ERR "%s function time out \n", __FUNCTION__);
 
-#if (TSI108_PHY_TYPE == PHY_BCM54XX)	/* Broadcom BCM54xx PHY */
-	tsi108_write_mii(data, 0x09, 0x0300);
-	tsi108_write_mii(data, 0x10, 0x1020);
-	tsi108_write_mii(data, 0x1c, 0x8c00);
-#endif
+	if (data->phy_type == TSI108_PHY_BCM54XX) {
+		tsi108_write_mii(data, 0x09, 0x0300);
+		tsi108_write_mii(data, 0x10, 0x1020);
+		tsi108_write_mii(data, 0x1c, 0x8c00);
+	}
 
 	tsi108_write_mii(data,
 			 MII_BMCR,
@@ -1587,6 +1588,7 @@ tsi108_init_one(struct platform_device *
 	data->mii_if.supports_gmii = mii_check_gmii_support(&data->mii_if);
 
 	data->phy = einfo->phy;
+	data->phy_type = einfo->phy_type;
 	data->irq_num = einfo->irq_num;
 	data->id = pdev->id;
 	dev->open = tsi108_open;
--- linux-2.6.orig/drivers/net/tsi108_eth.h
+++ linux-2.6/drivers/net/tsi108_eth.h
@@ -43,15 +43,6 @@
 	in_be32((data->phyregs + (offset)))
 
 /*
- * PHY Configuration Options
- *
- * NOTE: Enable set of definitions corresponding to your board type
- */
-#define PHY_MV88E	1	/* Marvel 88Exxxx PHY */
-#define PHY_BCM54XX	2	/* Broardcom BCM54xx PHY */
-#define TSI108_PHY_TYPE	PHY_MV88E
-
-/*
  * TSI108 GIGE port registers
  */
 
--- linux-2.6.orig/include/asm-powerpc/tsi108.h
+++ linux-2.6/include/asm-powerpc/tsi108.h
@@ -70,6 +70,16 @@
 
 #define TSI108_PCI_CFG_BASE_PHYS	(0xfb000000)
 #define TSI108_PCI_CFG_SIZE		(0x01000000)
+
+/*
+ * PHY Configuration Options
+ *
+ * Specify "bcm54xx" in the compatible property of your device tree phy
+ * nodes if your board uses the Broadcom PHYs
+ */
+#define TSI108_PHY_MV88E	0	/* Marvel 88Exxxx PHY */
+#define TSI108_PHY_BCM54XX	1	/* Broardcom BCM54xx PHY */
+
 /* Global variables */
 
 extern u32 tsi108_pci_cfg_base;
@@ -93,6 +103,7 @@ typedef struct {
 	u16 phy;		/* phy address */
 	u16 irq_num;		/* irq number */
 	u8 mac_addr[6];		/* phy mac address */
+	u16 phy_type;	/* type of phy on board */
 } hw_info;
 
 extern u32 get_vir_csrbase(void);

  parent reply	other threads:[~2007-05-07 21:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-07 21:22 [PATCH v4 0/7] Add support for 750CL Holly board Josh Boyer
2007-05-07 21:25 ` [PATCH v4 1/7] Add tsi108_pci.h for common PCI functions Josh Boyer
2007-05-08  1:15   ` Olof Johansson
2007-05-07 21:26 ` Josh Boyer [this message]
2007-05-08  1:15   ` [PATCH v4 2/7] Generalize tsi108 PHY types Olof Johansson
2007-05-07 21:27 ` [PATCH v4 3/7] Generalize tsi108 PCI setup Josh Boyer
2007-05-08  1:16   ` Olof Johansson
2007-05-07 21:28 ` [PATCH v4 4/7] Add support for 750CL Holly board Josh Boyer
2007-05-08  1:21   ` Olof Johansson
2007-05-08 16:45   ` Nathan Lynch
2007-05-08 17:01     ` Josh Boyer
2007-05-08 23:47       ` Benjamin Herrenschmidt
2007-05-07 21:29 ` [PATCH v4 5/7] Holly defconfig Josh Boyer
2007-05-07 21:31 ` [PATCH v4 6/7] Holly DTS Josh Boyer
2007-05-07 21:32 ` [PATCH v4 7/7] Holly bootwrapper Josh Boyer
2007-05-08  0:16   ` David Gibson
2007-05-08  1:07     ` Josh Boyer
2007-05-08  1:07       ` David Gibson
2007-05-08  3:45 ` [PATCH v4 0/7] Add support for 750CL Holly board Zang Roy-r61911
2007-05-08 10:46   ` Josh Boyer
2007-05-08 13:49     ` Zang Roy-r61911
2007-05-09  2:19       ` Zang Roy-r61911
2007-05-09  2:34         ` Josh Boyer
2007-05-09  2:52           ` Zang Roy-r61911

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=1178573182.2990.201.camel@zod.rchland.ibm.com \
    --to=jwboyer@linux.vnet.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.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).