Commit 714eece7 authored by Michael Buesch's avatar Michael Buesch Committed by John W. Linville

[PATCH] bcm43xx: fix some gpio register trashing (hopefully :D)

Signed-off-by: default avatarMichael Buesch <mbuesch@freenet.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 4a1821e4
...@@ -165,7 +165,7 @@ void bcm43xx_leds_exit(struct bcm43xx_private *bcm) ...@@ -165,7 +165,7 @@ void bcm43xx_leds_exit(struct bcm43xx_private *bcm)
led = &(bcm->leds[i]); led = &(bcm->leds[i]);
bcm43xx_led_blink_stop(led, 1); bcm43xx_led_blink_stop(led, 1);
} }
bcm43xx_leds_turn_off(bcm); bcm43xx_leds_switch_all(bcm, 0);
} }
void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity) void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
...@@ -268,18 +268,26 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity) ...@@ -268,18 +268,26 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl); bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl);
} }
void bcm43xx_leds_turn_off(struct bcm43xx_private *bcm) void bcm43xx_leds_switch_all(struct bcm43xx_private *bcm, int on)
{ {
struct bcm43xx_led *led; struct bcm43xx_led *led;
u16 ledctl = 0; u16 ledctl;
int i; int i;
int bit_on;
ledctl = bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_CONTROL);
for (i = 0; i < BCM43xx_NR_LEDS; i++) { for (i = 0; i < BCM43xx_NR_LEDS; i++) {
led = &(bcm->leds[i]); led = &(bcm->leds[i]);
if (led->behaviour == BCM43xx_LED_INACTIVE) if (led->behaviour == BCM43xx_LED_INACTIVE)
continue; continue;
if (led->activelow) if (on)
bit_on = led->activelow ? 0 : 1;
else
bit_on = led->activelow ? 1 : 0;
if (bit_on)
ledctl |= (1 << i); ledctl |= (1 << i);
else
ledctl &= ~(1 << i);
} }
bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl); bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl);
} }
......
...@@ -51,6 +51,6 @@ enum { /* LED behaviour values */ ...@@ -51,6 +51,6 @@ enum { /* LED behaviour values */
int bcm43xx_leds_init(struct bcm43xx_private *bcm); int bcm43xx_leds_init(struct bcm43xx_private *bcm);
void bcm43xx_leds_exit(struct bcm43xx_private *bcm); void bcm43xx_leds_exit(struct bcm43xx_private *bcm);
void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity); void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity);
void bcm43xx_leds_turn_off(struct bcm43xx_private *bcm); void bcm43xx_leds_switch_all(struct bcm43xx_private *bcm, int on);
#endif /* BCM43xx_LEDS_H_ */ #endif /* BCM43xx_LEDS_H_ */
...@@ -2182,13 +2182,10 @@ static int switch_to_gpio_core(struct bcm43xx_private *bcm) ...@@ -2182,13 +2182,10 @@ static int switch_to_gpio_core(struct bcm43xx_private *bcm)
if (unlikely(err == -ENODEV)) { if (unlikely(err == -ENODEV)) {
printk(KERN_ERR PFX "gpio error: " printk(KERN_ERR PFX "gpio error: "
"Neither ChipCommon nor PCI core available!\n"); "Neither ChipCommon nor PCI core available!\n");
return -ENODEV; }
} else if (unlikely(err != 0)) }
return -ENODEV;
} else if (unlikely(err != 0))
return -ENODEV;
return 0; return err;
} }
/* Initialize the GPIOs /* Initialize the GPIOs
...@@ -2198,45 +2195,48 @@ static int bcm43xx_gpio_init(struct bcm43xx_private *bcm) ...@@ -2198,45 +2195,48 @@ static int bcm43xx_gpio_init(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_coreinfo *old_core; struct bcm43xx_coreinfo *old_core;
int err; int err;
u32 mask, value; u32 mask, set;
value = bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD); bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD,
value &= ~0xc000; bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD)
bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD, value); & 0xFFFF3FFF);
mask = 0x0000001F; bcm43xx_leds_switch_all(bcm, 0);
value = 0x0000000F;
bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL,
bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_CONTROL) & 0xFFF0);
bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_MASK, bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_MASK,
bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_MASK) | 0x000F); bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_MASK) | 0x000F);
old_core = bcm->current_core; mask = 0x0000001F;
set = 0x0000000F;
err = switch_to_gpio_core(bcm);
if (err)
return err;
if (bcm->current_core->rev >= 2){
mask |= 0x10;
value |= 0x10;
}
if (bcm->chip_id == 0x4301) { if (bcm->chip_id == 0x4301) {
mask |= 0x60; mask |= 0x0060;
value |= 0x60; set |= 0x0060;
}
if (0 /* FIXME: conditional unknown */) {
bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_MASK,
bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_MASK)
| 0x0100);
mask |= 0x0180;
set |= 0x0180;
} }
if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL) { if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL) {
mask |= 0x200; bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_MASK,
value |= 0x200; bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_MASK)
| 0x0200);
mask |= 0x0200;
set |= 0x0200;
} }
if (bcm->current_core->rev >= 2)
mask |= 0x0010; /* FIXME: This is redundant. */
old_core = bcm->current_core;
err = switch_to_gpio_core(bcm);
if (err)
goto out;
bcm43xx_write32(bcm, BCM43xx_GPIO_CONTROL, bcm43xx_write32(bcm, BCM43xx_GPIO_CONTROL,
(bcm43xx_read32(bcm, BCM43xx_GPIO_CONTROL) & mask) | value); (bcm43xx_read32(bcm, BCM43xx_GPIO_CONTROL) & mask) | set);
err = bcm43xx_switch_core(bcm, old_core); err = bcm43xx_switch_core(bcm, old_core);
assert(err == 0); out:
return err;
return 0;
} }
/* Turn off all GPIO stuff. Call this on module unload, for example. */ /* 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,11 +2384,6 @@ static int bcm43xx_chip_init(struct bcm43xx_private *bcm)
goto err_gpio_cleanup; goto err_gpio_cleanup;
bcm43xx_radio_turn_on(bcm); bcm43xx_radio_turn_on(bcm);
if (modparam_noleds)
bcm43xx_leds_turn_off(bcm);
else
bcm43xx_leds_update(bcm, 0);
bcm43xx_write16(bcm, 0x03E6, 0x0000); bcm43xx_write16(bcm, 0x03E6, 0x0000);
err = bcm43xx_phy_init(bcm); err = bcm43xx_phy_init(bcm);
if (err) if (err)
......
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