aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorMichael Buesch <mbuesch@freenet.de>2006-03-18 15:28:46 -0500
committerJohn W. Linville <linville@tuxdriver.com>2006-03-27 11:19:40 -0500
commit714eece7c7c300bbc5e8285890e7374958ca37f4 (patch)
tree7a589f5aa916eb5463dbc5d420ee9c161456695e /drivers/net
parent4a1821e4c7a84569f788b7667affe2743317b63f (diff)
[PATCH] bcm43xx: fix some gpio register trashing (hopefully :D)
Signed-off-by: Michael Buesch <mbuesch@freenet.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_leds.c16
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_leds.h2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c71
3 files changed, 46 insertions, 43 deletions
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
index 72a243aac6cb..c8f5ad75d2a6 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
@@ -165,7 +165,7 @@ void bcm43xx_leds_exit(struct bcm43xx_private *bcm)
165 led = &(bcm->leds[i]); 165 led = &(bcm->leds[i]);
166 bcm43xx_led_blink_stop(led, 1); 166 bcm43xx_led_blink_stop(led, 1);
167 } 167 }
168 bcm43xx_leds_turn_off(bcm); 168 bcm43xx_leds_switch_all(bcm, 0);
169} 169}
170 170
171void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity) 171void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
@@ -268,18 +268,26 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
268 bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl); 268 bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl);
269} 269}
270 270
271void bcm43xx_leds_turn_off(struct bcm43xx_private *bcm) 271void bcm43xx_leds_switch_all(struct bcm43xx_private *bcm, int on)
272{ 272{
273 struct bcm43xx_led *led; 273 struct bcm43xx_led *led;
274 u16 ledctl = 0; 274 u16 ledctl;
275 int i; 275 int i;
276 int bit_on;
276 277
278 ledctl = bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_CONTROL);
277 for (i = 0; i < BCM43xx_NR_LEDS; i++) { 279 for (i = 0; i < BCM43xx_NR_LEDS; i++) {
278 led = &(bcm->leds[i]); 280 led = &(bcm->leds[i]);
279 if (led->behaviour == BCM43xx_LED_INACTIVE) 281 if (led->behaviour == BCM43xx_LED_INACTIVE)
280 continue; 282 continue;
281 if (led->activelow) 283 if (on)
284 bit_on = led->activelow ? 0 : 1;
285 else
286 bit_on = led->activelow ? 1 : 0;
287 if (bit_on)
282 ledctl |= (1 << i); 288 ledctl |= (1 << i);
289 else
290 ledctl &= ~(1 << i);
283 } 291 }
284 bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl); 292 bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl);
285} 293}
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_leds.h b/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
index 6f18e2f95db4..d3716cf3aebc 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
@@ -51,6 +51,6 @@ enum { /* LED behaviour values */
51int bcm43xx_leds_init(struct bcm43xx_private *bcm); 51int bcm43xx_leds_init(struct bcm43xx_private *bcm);
52void bcm43xx_leds_exit(struct bcm43xx_private *bcm); 52void bcm43xx_leds_exit(struct bcm43xx_private *bcm);
53void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity); 53void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity);
54void bcm43xx_leds_turn_off(struct bcm43xx_private *bcm); 54void bcm43xx_leds_switch_all(struct bcm43xx_private *bcm, int on);
55 55
56#endif /* BCM43xx_LEDS_H_ */ 56#endif /* BCM43xx_LEDS_H_ */
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index 6a877df2ecf0..eb8fca8279f4 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -2182,13 +2182,10 @@ static int switch_to_gpio_core(struct bcm43xx_private *bcm)
2182 if (unlikely(err == -ENODEV)) { 2182 if (unlikely(err == -ENODEV)) {
2183 printk(KERN_ERR PFX "gpio error: " 2183 printk(KERN_ERR PFX "gpio error: "
2184 "Neither ChipCommon nor PCI core available!\n"); 2184 "Neither ChipCommon nor PCI core available!\n");
2185 return -ENODEV; 2185 }
2186 } else if (unlikely(err != 0)) 2186 }
2187 return -ENODEV;
2188 } else if (unlikely(err != 0))
2189 return -ENODEV;
2190 2187
2191 return 0; 2188 return err;
2192} 2189}
2193 2190
2194/* Initialize the GPIOs 2191/* Initialize the GPIOs
@@ -2198,45 +2195,48 @@ static int bcm43xx_gpio_init(struct bcm43xx_private *bcm)
2198{ 2195{
2199 struct bcm43xx_coreinfo *old_core; 2196 struct bcm43xx_coreinfo *old_core;
2200 int err; 2197 int err;
2201 u32 mask, value; 2198 u32 mask, set;
2202 2199
2203 value = bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD); 2200 bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD,
2204 value &= ~0xc000; 2201 bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD)
2205 bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD, value); 2202 & 0xFFFF3FFF);
2206 2203
2207 mask = 0x0000001F; 2204 bcm43xx_leds_switch_all(bcm, 0);
2208 value = 0x0000000F;
2209 bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL,
2210 bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_CONTROL) & 0xFFF0);
2211 bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_MASK, 2205 bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_MASK,
2212 bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_MASK) | 0x000F); 2206 bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_MASK) | 0x000F);
2213 2207
2214 old_core = bcm->current_core; 2208 mask = 0x0000001F;
2215 2209 set = 0x0000000F;
2216 err = switch_to_gpio_core(bcm);
2217 if (err)
2218 return err;
2219
2220 if (bcm->current_core->rev >= 2){
2221 mask |= 0x10;
2222 value |= 0x10;
2223 }
2224 if (bcm->chip_id == 0x4301) { 2210 if (bcm->chip_id == 0x4301) {
2225 mask |= 0x60; 2211 mask |= 0x0060;
2226 value |= 0x60; 2212 set |= 0x0060;
2213 }
2214 if (0 /* FIXME: conditional unknown */) {
2215 bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_MASK,
2216 bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_MASK)
2217 | 0x0100);
2218 mask |= 0x0180;
2219 set |= 0x0180;
2227 } 2220 }
2228 if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL) { 2221 if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL) {
2229 mask |= 0x200; 2222 bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_MASK,
2230 value |= 0x200; 2223 bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_MASK)
2224 | 0x0200);
2225 mask |= 0x0200;
2226 set |= 0x0200;
2231 } 2227 }
2228 if (bcm->current_core->rev >= 2)
2229 mask |= 0x0010; /* FIXME: This is redundant. */
2232 2230
2231 old_core = bcm->current_core;
2232 err = switch_to_gpio_core(bcm);
2233 if (err)
2234 goto out;
2233 bcm43xx_write32(bcm, BCM43xx_GPIO_CONTROL, 2235 bcm43xx_write32(bcm, BCM43xx_GPIO_CONTROL,
2234 (bcm43xx_read32(bcm, BCM43xx_GPIO_CONTROL) & mask) | value); 2236 (bcm43xx_read32(bcm, BCM43xx_GPIO_CONTROL) & mask) | set);
2235
2236 err = bcm43xx_switch_core(bcm, old_core); 2237 err = bcm43xx_switch_core(bcm, old_core);
2237 assert(err == 0); 2238out:
2238 2239 return err;
2239 return 0;
2240} 2240}
2241 2241
2242/* Turn off all GPIO stuff. Call this on module unload, for example. */ 2242/* Turn off all GPIO stuff. Call this on module unload, for example. */
@@ -2384,11 +2384,6 @@ static int bcm43xx_chip_init(struct bcm43xx_private *bcm)
2384 goto err_gpio_cleanup; 2384 goto err_gpio_cleanup;
2385 bcm43xx_radio_turn_on(bcm); 2385 bcm43xx_radio_turn_on(bcm);
2386 2386
2387 if (modparam_noleds)
2388 bcm43xx_leds_turn_off(bcm);
2389 else
2390 bcm43xx_leds_update(bcm, 0);
2391
2392 bcm43xx_write16(bcm, 0x03E6, 0x0000); 2387 bcm43xx_write16(bcm, 0x03E6, 0x0000);
2393 err = bcm43xx_phy_init(bcm); 2388 err = bcm43xx_phy_init(bcm);
2394 if (err) 2389 if (err)