diff options
author | Josh Boyer <jwboyer@linux.vnet.ibm.com> | 2007-05-07 17:26:22 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-05-07 21:54:20 -0400 |
commit | c1b78d05b3281d6f84284d421fc20eed8b8b78ce (patch) | |
tree | b43b65f028cbec38752ed4357c7067d94e48f59b | |
parent | 08390db07a012b972189629a30eb695cdcb0ec14 (diff) |
[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: Josh Boyer <jwboyer@linux.vnet.ibm.com>
Acked-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r-- | arch/powerpc/sysdev/tsi108_dev.c | 7 | ||||
-rw-r--r-- | drivers/net/tsi108_eth.c | 12 | ||||
-rw-r--r-- | drivers/net/tsi108_eth.h | 9 | ||||
-rw-r--r-- | include/asm-powerpc/tsi108.h | 11 |
4 files changed, 23 insertions, 16 deletions
diff --git a/arch/powerpc/sysdev/tsi108_dev.c b/arch/powerpc/sysdev/tsi108_dev.c index 337039ee51e6..7d3b09b7d544 100644 --- a/arch/powerpc/sysdev/tsi108_dev.c +++ b/arch/powerpc/sysdev/tsi108_dev.c | |||
@@ -107,8 +107,9 @@ static int __init tsi108_eth_of_init(void) | |||
107 | goto err; | 107 | goto err; |
108 | } | 108 | } |
109 | 109 | ||
110 | mac_addr = of_get_property(np, "address", NULL); | 110 | mac_addr = of_get_mac_address(np); |
111 | memcpy(tsi_eth_data.mac_addr, mac_addr, 6); | 111 | if (mac_addr) |
112 | memcpy(tsi_eth_data.mac_addr, mac_addr, 6); | ||
112 | 113 | ||
113 | ph = of_get_property(np, "phy-handle", NULL); | 114 | ph = of_get_property(np, "phy-handle", NULL); |
114 | phy = of_find_node_by_phandle(*ph); | 115 | phy = of_find_node_by_phandle(*ph); |
@@ -129,6 +130,8 @@ static int __init tsi108_eth_of_init(void) | |||
129 | tsi_eth_data.phyregs = res.start; | 130 | tsi_eth_data.phyregs = res.start; |
130 | tsi_eth_data.phy = *phy_id; | 131 | tsi_eth_data.phy = *phy_id; |
131 | tsi_eth_data.irq_num = irq_of_parse_and_map(np, 0); | 132 | tsi_eth_data.irq_num = irq_of_parse_and_map(np, 0); |
133 | if (of_device_is_compatible(phy, "bcm54xx")) | ||
134 | tsi_eth_data.phy_type = TSI108_PHY_BCM54XX; | ||
132 | of_node_put(phy); | 135 | of_node_put(phy); |
133 | ret = | 136 | ret = |
134 | platform_device_add_data(tsi_eth_dev, &tsi_eth_data, | 137 | platform_device_add_data(tsi_eth_dev, &tsi_eth_data, |
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c index 0bfc2c9c1c08..1aabc91f6458 100644 --- a/drivers/net/tsi108_eth.c +++ b/drivers/net/tsi108_eth.c | |||
@@ -82,6 +82,7 @@ struct tsi108_prv_data { | |||
82 | unsigned int phy; /* Index of PHY for this interface */ | 82 | unsigned int phy; /* Index of PHY for this interface */ |
83 | unsigned int irq_num; | 83 | unsigned int irq_num; |
84 | unsigned int id; | 84 | unsigned int id; |
85 | unsigned int phy_type; | ||
85 | 86 | ||
86 | struct timer_list timer;/* Timer that triggers the check phy function */ | 87 | struct timer_list timer;/* Timer that triggers the check phy function */ |
87 | unsigned int rxtail; /* Next entry in rxring to read */ | 88 | unsigned int rxtail; /* Next entry in rxring to read */ |
@@ -1256,11 +1257,11 @@ static void tsi108_init_phy(struct net_device *dev) | |||
1256 | if (i == 0) | 1257 | if (i == 0) |
1257 | printk(KERN_ERR "%s function time out \n", __FUNCTION__); | 1258 | printk(KERN_ERR "%s function time out \n", __FUNCTION__); |
1258 | 1259 | ||
1259 | #if (TSI108_PHY_TYPE == PHY_BCM54XX) /* Broadcom BCM54xx PHY */ | 1260 | if (data->phy_type == TSI108_PHY_BCM54XX) { |
1260 | tsi108_write_mii(data, 0x09, 0x0300); | 1261 | tsi108_write_mii(data, 0x09, 0x0300); |
1261 | tsi108_write_mii(data, 0x10, 0x1020); | 1262 | tsi108_write_mii(data, 0x10, 0x1020); |
1262 | tsi108_write_mii(data, 0x1c, 0x8c00); | 1263 | tsi108_write_mii(data, 0x1c, 0x8c00); |
1263 | #endif | 1264 | } |
1264 | 1265 | ||
1265 | tsi108_write_mii(data, | 1266 | tsi108_write_mii(data, |
1266 | MII_BMCR, | 1267 | MII_BMCR, |
@@ -1587,6 +1588,7 @@ tsi108_init_one(struct platform_device *pdev) | |||
1587 | data->mii_if.supports_gmii = mii_check_gmii_support(&data->mii_if); | 1588 | data->mii_if.supports_gmii = mii_check_gmii_support(&data->mii_if); |
1588 | 1589 | ||
1589 | data->phy = einfo->phy; | 1590 | data->phy = einfo->phy; |
1591 | data->phy_type = einfo->phy_type; | ||
1590 | data->irq_num = einfo->irq_num; | 1592 | data->irq_num = einfo->irq_num; |
1591 | data->id = pdev->id; | 1593 | data->id = pdev->id; |
1592 | dev->open = tsi108_open; | 1594 | dev->open = tsi108_open; |
diff --git a/drivers/net/tsi108_eth.h b/drivers/net/tsi108_eth.h index 77a769df228a..5a77ae6c5f36 100644 --- a/drivers/net/tsi108_eth.h +++ b/drivers/net/tsi108_eth.h | |||
@@ -43,15 +43,6 @@ | |||
43 | in_be32((data->phyregs + (offset))) | 43 | in_be32((data->phyregs + (offset))) |
44 | 44 | ||
45 | /* | 45 | /* |
46 | * PHY Configuration Options | ||
47 | * | ||
48 | * NOTE: Enable set of definitions corresponding to your board type | ||
49 | */ | ||
50 | #define PHY_MV88E 1 /* Marvel 88Exxxx PHY */ | ||
51 | #define PHY_BCM54XX 2 /* Broardcom BCM54xx PHY */ | ||
52 | #define TSI108_PHY_TYPE PHY_MV88E | ||
53 | |||
54 | /* | ||
55 | * TSI108 GIGE port registers | 46 | * TSI108 GIGE port registers |
56 | */ | 47 | */ |
57 | 48 | ||
diff --git a/include/asm-powerpc/tsi108.h b/include/asm-powerpc/tsi108.h index 4e95d153be84..20cb072d45ae 100644 --- a/include/asm-powerpc/tsi108.h +++ b/include/asm-powerpc/tsi108.h | |||
@@ -70,6 +70,16 @@ | |||
70 | 70 | ||
71 | #define TSI108_PCI_CFG_BASE_PHYS (0xfb000000) | 71 | #define TSI108_PCI_CFG_BASE_PHYS (0xfb000000) |
72 | #define TSI108_PCI_CFG_SIZE (0x01000000) | 72 | #define TSI108_PCI_CFG_SIZE (0x01000000) |
73 | |||
74 | /* | ||
75 | * PHY Configuration Options | ||
76 | * | ||
77 | * Specify "bcm54xx" in the compatible property of your device tree phy | ||
78 | * nodes if your board uses the Broadcom PHYs | ||
79 | */ | ||
80 | #define TSI108_PHY_MV88E 0 /* Marvel 88Exxxx PHY */ | ||
81 | #define TSI108_PHY_BCM54XX 1 /* Broardcom BCM54xx PHY */ | ||
82 | |||
73 | /* Global variables */ | 83 | /* Global variables */ |
74 | 84 | ||
75 | extern u32 tsi108_pci_cfg_base; | 85 | extern u32 tsi108_pci_cfg_base; |
@@ -93,6 +103,7 @@ typedef struct { | |||
93 | u16 phy; /* phy address */ | 103 | u16 phy; /* phy address */ |
94 | u16 irq_num; /* irq number */ | 104 | u16 irq_num; /* irq number */ |
95 | u8 mac_addr[6]; /* phy mac address */ | 105 | u8 mac_addr[6]; /* phy mac address */ |
106 | u16 phy_type; /* type of phy on board */ | ||
96 | } hw_info; | 107 | } hw_info; |
97 | 108 | ||
98 | extern u32 get_vir_csrbase(void); | 109 | extern u32 get_vir_csrbase(void); |