Commit c1b78d05 authored by Josh Boyer's avatar Josh Boyer Committed by Paul Mackerras

[POWERPC] Generalize tsi108 PHY types

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: default avatarJosh Boyer <jwboyer@linux.vnet.ibm.com>
Acked-by: default avatarOlof Johansson <olof@lixom.net>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 08390db0
...@@ -107,7 +107,8 @@ static int __init tsi108_eth_of_init(void) ...@@ -107,7 +107,8 @@ static int __init tsi108_eth_of_init(void)
goto err; goto err;
} }
mac_addr = of_get_property(np, "address", NULL); mac_addr = of_get_mac_address(np);
if (mac_addr)
memcpy(tsi_eth_data.mac_addr, mac_addr, 6); memcpy(tsi_eth_data.mac_addr, mac_addr, 6);
ph = of_get_property(np, "phy-handle", NULL); ph = of_get_property(np, "phy-handle", NULL);
...@@ -129,6 +130,8 @@ static int __init tsi108_eth_of_init(void) ...@@ -129,6 +130,8 @@ static int __init tsi108_eth_of_init(void)
tsi_eth_data.phyregs = res.start; tsi_eth_data.phyregs = res.start;
tsi_eth_data.phy = *phy_id; tsi_eth_data.phy = *phy_id;
tsi_eth_data.irq_num = irq_of_parse_and_map(np, 0); 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); of_node_put(phy);
ret = ret =
platform_device_add_data(tsi_eth_dev, &tsi_eth_data, platform_device_add_data(tsi_eth_dev, &tsi_eth_data,
......
...@@ -82,6 +82,7 @@ struct tsi108_prv_data { ...@@ -82,6 +82,7 @@ struct tsi108_prv_data {
unsigned int phy; /* Index of PHY for this interface */ unsigned int phy; /* Index of PHY for this interface */
unsigned int irq_num; unsigned int irq_num;
unsigned int id; unsigned int id;
unsigned int phy_type;
struct timer_list timer;/* Timer that triggers the check phy function */ struct timer_list timer;/* Timer that triggers the check phy function */
unsigned int rxtail; /* Next entry in rxring to read */ unsigned int rxtail; /* Next entry in rxring to read */
...@@ -1256,11 +1257,11 @@ static void tsi108_init_phy(struct net_device *dev) ...@@ -1256,11 +1257,11 @@ static void tsi108_init_phy(struct net_device *dev)
if (i == 0) if (i == 0)
printk(KERN_ERR "%s function time out \n", __FUNCTION__); printk(KERN_ERR "%s function time out \n", __FUNCTION__);
#if (TSI108_PHY_TYPE == PHY_BCM54XX) /* Broadcom BCM54xx PHY */ if (data->phy_type == TSI108_PHY_BCM54XX) {
tsi108_write_mii(data, 0x09, 0x0300); tsi108_write_mii(data, 0x09, 0x0300);
tsi108_write_mii(data, 0x10, 0x1020); tsi108_write_mii(data, 0x10, 0x1020);
tsi108_write_mii(data, 0x1c, 0x8c00); tsi108_write_mii(data, 0x1c, 0x8c00);
#endif }
tsi108_write_mii(data, tsi108_write_mii(data,
MII_BMCR, MII_BMCR,
...@@ -1587,6 +1588,7 @@ tsi108_init_one(struct platform_device *pdev) ...@@ -1587,6 +1588,7 @@ tsi108_init_one(struct platform_device *pdev)
data->mii_if.supports_gmii = mii_check_gmii_support(&data->mii_if); data->mii_if.supports_gmii = mii_check_gmii_support(&data->mii_if);
data->phy = einfo->phy; data->phy = einfo->phy;
data->phy_type = einfo->phy_type;
data->irq_num = einfo->irq_num; data->irq_num = einfo->irq_num;
data->id = pdev->id; data->id = pdev->id;
dev->open = tsi108_open; dev->open = tsi108_open;
......
...@@ -42,15 +42,6 @@ ...@@ -42,15 +42,6 @@
#define TSI_READ_PHY(offset) \ #define TSI_READ_PHY(offset) \
in_be32((data->phyregs + (offset))) 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 * TSI108 GIGE port registers
*/ */
......
...@@ -70,6 +70,16 @@ ...@@ -70,6 +70,16 @@
#define TSI108_PCI_CFG_BASE_PHYS (0xfb000000) #define TSI108_PCI_CFG_BASE_PHYS (0xfb000000)
#define TSI108_PCI_CFG_SIZE (0x01000000) #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 */ /* Global variables */
extern u32 tsi108_pci_cfg_base; extern u32 tsi108_pci_cfg_base;
...@@ -93,6 +103,7 @@ typedef struct { ...@@ -93,6 +103,7 @@ typedef struct {
u16 phy; /* phy address */ u16 phy; /* phy address */
u16 irq_num; /* irq number */ u16 irq_num; /* irq number */
u8 mac_addr[6]; /* phy mac address */ u8 mac_addr[6]; /* phy mac address */
u16 phy_type; /* type of phy on board */
} hw_info; } hw_info;
extern u32 get_vir_csrbase(void); extern u32 get_vir_csrbase(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment