aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ixp2000/pm3386.c
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@wantstofly.org>2006-05-15 15:25:29 -0400
committerStephen Hemminger <shemminger@osdl.org>2006-05-15 15:25:29 -0400
commit1ea739a5f9f469a57d804ebcf70514b8a5efe9da (patch)
tree48269d9f017b7f09eab3577ba78ed81ad9faa7f5 /drivers/net/ixp2000/pm3386.c
parent9be2f7c38e0bd64e8a0f74ea68df1e73e2ddfcc3 (diff)
The ixp2000 driver for the enp2611 was developed on a board with
three gigabit ports, but some enp2611 models only have two ports (and only one onboard PM3386.) The current driver assumes there are always three ports and so it doesn't work on the two-port version of the board at all. This patch adds a bit of logic to the enp2611 driver to limit the number of ports to 2 if the second PM3386 isn't detected. Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org> Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Diffstat (limited to 'drivers/net/ixp2000/pm3386.c')
-rw-r--r--drivers/net/ixp2000/pm3386.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/drivers/net/ixp2000/pm3386.c b/drivers/net/ixp2000/pm3386.c
index 5c7ab7564053..5224651c9aac 100644
--- a/drivers/net/ixp2000/pm3386.c
+++ b/drivers/net/ixp2000/pm3386.c
@@ -86,40 +86,53 @@ static void pm3386_port_reg_write(int port, int _reg, int spacing, u16 value)
86 pm3386_reg_write(port >> 1, reg, value); 86 pm3386_reg_write(port >> 1, reg, value);
87} 87}
88 88
89int pm3386_secondary_present(void)
90{
91 return pm3386_reg_read(1, 0) == 0x3386;
92}
89 93
90void pm3386_reset(void) 94void pm3386_reset(void)
91{ 95{
92 u8 mac[3][6]; 96 u8 mac[3][6];
97 int secondary;
98
99 secondary = pm3386_secondary_present();
93 100
94 /* Save programmed MAC addresses. */ 101 /* Save programmed MAC addresses. */
95 pm3386_get_mac(0, mac[0]); 102 pm3386_get_mac(0, mac[0]);
96 pm3386_get_mac(1, mac[1]); 103 pm3386_get_mac(1, mac[1]);
97 pm3386_get_mac(2, mac[2]); 104 if (secondary)
105 pm3386_get_mac(2, mac[2]);
98 106
99 /* Assert analog and digital reset. */ 107 /* Assert analog and digital reset. */
100 pm3386_reg_write(0, 0x002, 0x0060); 108 pm3386_reg_write(0, 0x002, 0x0060);
101 pm3386_reg_write(1, 0x002, 0x0060); 109 if (secondary)
110 pm3386_reg_write(1, 0x002, 0x0060);
102 mdelay(1); 111 mdelay(1);
103 112
104 /* Deassert analog reset. */ 113 /* Deassert analog reset. */
105 pm3386_reg_write(0, 0x002, 0x0062); 114 pm3386_reg_write(0, 0x002, 0x0062);
106 pm3386_reg_write(1, 0x002, 0x0062); 115 if (secondary)
116 pm3386_reg_write(1, 0x002, 0x0062);
107 mdelay(10); 117 mdelay(10);
108 118
109 /* Deassert digital reset. */ 119 /* Deassert digital reset. */
110 pm3386_reg_write(0, 0x002, 0x0063); 120 pm3386_reg_write(0, 0x002, 0x0063);
111 pm3386_reg_write(1, 0x002, 0x0063); 121 if (secondary)
122 pm3386_reg_write(1, 0x002, 0x0063);
112 mdelay(10); 123 mdelay(10);
113 124
114 /* Restore programmed MAC addresses. */ 125 /* Restore programmed MAC addresses. */
115 pm3386_set_mac(0, mac[0]); 126 pm3386_set_mac(0, mac[0]);
116 pm3386_set_mac(1, mac[1]); 127 pm3386_set_mac(1, mac[1]);
117 pm3386_set_mac(2, mac[2]); 128 if (secondary)
129 pm3386_set_mac(2, mac[2]);
118 130
119 /* Disable carrier on all ports. */ 131 /* Disable carrier on all ports. */
120 pm3386_set_carrier(0, 0); 132 pm3386_set_carrier(0, 0);
121 pm3386_set_carrier(1, 0); 133 pm3386_set_carrier(1, 0);
122 pm3386_set_carrier(2, 0); 134 if (secondary)
135 pm3386_set_carrier(2, 0);
123} 136}
124 137
125static u16 swaph(u16 x) 138static u16 swaph(u16 x)
@@ -127,6 +140,11 @@ static u16 swaph(u16 x)
127 return ((x << 8) | (x >> 8)) & 0xffff; 140 return ((x << 8) | (x >> 8)) & 0xffff;
128} 141}
129 142
143int pm3386_port_count(void)
144{
145 return 2 + pm3386_secondary_present();
146}
147
130void pm3386_init_port(int port) 148void pm3386_init_port(int port)
131{ 149{
132 int pm = port >> 1; 150 int pm = port >> 1;