Commit ba48f7bb authored by Larry Finger's avatar Larry Finger Committed by David S. Miller

b43legacy: LED triggers support

Drive the LEDs through the generic LED triggers.

The patch to b43 by Michael Buesch <mb@bu3sch.de> has been ported to b43legacy.
Signed-off-by: default avatarLarry Finger <larry.finger@lwfinger.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent c8b0e6e1
......@@ -34,6 +34,12 @@ config B43LEGACY_PCICORE_AUTOSELECT
select SSB_DRIVER_PCICORE
default y
# LED support
config B43LEGACY_LEDS
bool
depends on MAC80211_LEDS
default y
config B43LEGACY_DEBUG
bool "Broadcom 43xx-legacy debugging"
depends on B43LEGACY
......
obj-$(CONFIG_B43LEGACY) += b43legacy.o
b43legacy-obj-$(CONFIG_B43LEGACY_DEBUG) += debugfs.o
# b43legacy core
b43legacy-y += main.o
b43legacy-y += ilt.o
b43legacy-y += phy.o
b43legacy-y += radio.o
b43legacy-y += sysfs.o
b43legacy-y += xmit.o
# b43legacy LED support
b43legacy-$(CONFIG_B43LEGACY_LEDS) += leds.o
# b43legacy debugging
b43legacy-$(CONFIG_B43LEGACY_DEBUG) += debugfs.o
# b43legacy DMA and PIO
b43legacy-$(CONFIG_B43LEGACY_DMA) += dma.o
b43legacy-$(CONFIG_B43LEGACY_PIO) += pio.o
b43legacy-obj-$(CONFIG_B43LEGACY_DMA) += dma.o
b43legacy-obj-$(CONFIG_B43LEGACY_PIO) += pio.o
obj-$(CONFIG_B43LEGACY) += b43legacy.o
b43legacy-objs := main.o \
ilt.o \
leds.o \
phy.o \
radio.o \
sysfs.o \
xmit.o \
$(b43legacy-obj-y)
......@@ -663,8 +663,10 @@ struct b43legacy_wldev {
/* Various statistics about the physical device. */
struct b43legacy_stats stats;
#define B43legacy_NR_LEDS 4
struct b43legacy_led leds[B43legacy_NR_LEDS];
/* The device LEDs. */
struct b43legacy_led led_tx;
struct b43legacy_led led_rx;
struct b43legacy_led led_assoc;
/* Reason code of the last interrupt. */
u32 irq_reason;
......
This diff is collapsed.
#ifndef B43legacy_LEDS_H_
#define B43legacy_LEDS_H_
struct b43legacy_wldev;
#ifdef CONFIG_B43LEGACY_LEDS
#include <linux/types.h>
#include <linux/timer.h>
#include <linux/leds.h>
#define B43legacy_LED_MAX_NAME_LEN 31
struct b43legacy_led {
u8 behaviour;
bool activelow;
/* Index in the "leds" array in b43legacy_wldev */
u8 index;
struct b43legacy_wldev *dev;
struct timer_list blink_timer;
unsigned long blink_interval;
/* The LED class device */
struct led_classdev led_dev;
/* The index number of the LED. */
u8 index;
/* If activelow is true, the LED is ON if the
* bit is switched off. */
bool activelow;
/* The unique name string for this LED device. */
char name[B43legacy_LED_MAX_NAME_LEN + 1];
};
/* Delay between state changes when blinking in jiffies */
#define B43legacy_LEDBLINK_SLOW (HZ / 1)
#define B43legacy_LEDBLINK_MEDIUM (HZ / 4)
#define B43legacy_LEDBLINK_FAST (HZ / 8)
#define B43legacy_LED_XFER_THRES (HZ / 100)
#define B43legacy_LED_BEHAVIOUR 0x7F
#define B43legacy_LED_ACTIVELOW 0x80
enum { /* LED behaviour values */
/* LED behaviour values */
enum b43legacy_led_behaviour {
B43legacy_LED_OFF,
B43legacy_LED_ON,
B43legacy_LED_ACTIVITY,
......@@ -37,20 +40,24 @@ enum { /* LED behaviour values */
B43legacy_LED_WEIRD,
B43legacy_LED_ASSOC,
B43legacy_LED_INACTIVE,
/* Behaviour values for testing.
* With these values it is easier to figure out
* the real behaviour of leds, in case the SPROM
* is missing information.
*/
B43legacy_LED_TEST_BLINKSLOW,
B43legacy_LED_TEST_BLINKMEDIUM,
B43legacy_LED_TEST_BLINKFAST,
};
int b43legacy_leds_init(struct b43legacy_wldev *dev);
void b43legacy_leds_init(struct b43legacy_wldev *dev);
void b43legacy_leds_exit(struct b43legacy_wldev *dev);
void b43legacy_leds_update(struct b43legacy_wldev *dev, int activity);
void b43legacy_leds_switch_all(struct b43legacy_wldev *dev, int on);
#else /* CONFIG_B43EGACY_LEDS */
/* LED support disabled */
struct b43legacy_led {
/* empty */
};
static inline void b43legacy_leds_init(struct b43legacy_wldev *dev)
{
}
static inline void b43legacy_leds_exit(struct b43legacy_wldev *dev)
{
}
#endif /* CONFIG_B43LEGACY_LEDS */
#endif /* B43legacy_LEDS_H_ */
......@@ -83,10 +83,6 @@ static int modparam_long_retry = B43legacy_DEFAULT_LONG_RETRY_LIMIT;
module_param_named(long_retry, modparam_long_retry, int, 0444);
MODULE_PARM_DESC(long_retry, "Long-Retry-Limit (0 - 15)");
static int modparam_noleds;
module_param_named(noleds, modparam_noleds, int, 0444);
MODULE_PARM_DESC(noleds, "Turn off all LED activity");
static char modparam_fwpostfix[16];
module_param_string(fwpostfix, modparam_fwpostfix, 16, 0444);
MODULE_PARM_DESC(fwpostfix, "Postfix for the firmware files to load.");
......@@ -1217,7 +1213,6 @@ static void b43legacy_interrupt_tasklet(struct b43legacy_wldev *dev)
u32 dma_reason[ARRAY_SIZE(dev->dma_reason)];
u32 merged_dma_reason = 0;
int i;
int activity = 0;
unsigned long flags;
spin_lock_irqsave(&dev->wl->irq_lock, flags);
......@@ -1281,7 +1276,6 @@ static void b43legacy_interrupt_tasklet(struct b43legacy_wldev *dev)
b43legacy_pio_rx(dev->pio.queue0);
else
b43legacy_dma_rx(dev->dma.rx_ring0);
/* We intentionally don't set "activity" to 1, here. */
}
B43legacy_WARN_ON(dma_reason[1] & B43legacy_DMAIRQ_RX_DONE);
B43legacy_WARN_ON(dma_reason[2] & B43legacy_DMAIRQ_RX_DONE);
......@@ -1290,20 +1284,13 @@ static void b43legacy_interrupt_tasklet(struct b43legacy_wldev *dev)
b43legacy_pio_rx(dev->pio.queue3);
else
b43legacy_dma_rx(dev->dma.rx_ring3);
activity = 1;
}
B43legacy_WARN_ON(dma_reason[4] & B43legacy_DMAIRQ_RX_DONE);
B43legacy_WARN_ON(dma_reason[5] & B43legacy_DMAIRQ_RX_DONE);
if (reason & B43legacy_IRQ_TX_OK) {
if (reason & B43legacy_IRQ_TX_OK)
handle_irq_transmit_status(dev);
activity = 1;
/* TODO: In AP mode, this also causes sending of powersave
responses. */
}
if (!modparam_noleds)
b43legacy_leds_update(dev, activity);
b43legacy_interrupt_enable(dev, dev->irq_savedstate);
mmiowb();
spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
......@@ -1755,7 +1742,6 @@ static int b43legacy_gpio_init(struct b43legacy_wldev *dev)
B43legacy_MMIO_STATUS_BITFIELD)
& 0xFFFF3FFF);
b43legacy_leds_switch_all(dev, 0);
b43legacy_write16(dev, B43legacy_MMIO_GPIO_MASK,
b43legacy_read16(dev,
B43legacy_MMIO_GPIO_MASK)
......@@ -2008,7 +1994,6 @@ static bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev)
static void b43legacy_chip_exit(struct b43legacy_wldev *dev)
{
b43legacy_radio_turn_off(dev);
if (!modparam_noleds)
b43legacy_leds_exit(dev);
b43legacy_gpio_cleanup(dev);
/* firmware is released later */
......@@ -2039,9 +2024,11 @@ static int b43legacy_chip_init(struct b43legacy_wldev *dev)
err = b43legacy_gpio_init(dev);
if (err)
goto out; /* firmware is released later */
b43legacy_leds_init(dev);
err = b43legacy_upload_initvals(dev);
if (err)
goto err_gpio_cleanup;
goto err_leds_exit;
b43legacy_radio_turn_on(dev);
b43legacy_write16(dev, 0x03E6, 0x0000);
......@@ -2120,7 +2107,8 @@ static int b43legacy_chip_init(struct b43legacy_wldev *dev)
err_radio_off:
b43legacy_radio_turn_off(dev);
err_gpio_cleanup:
err_leds_exit:
b43legacy_leds_exit(dev);
b43legacy_gpio_cleanup(dev);
goto out;
}
......@@ -2168,7 +2156,6 @@ static void b43legacy_periodic_every1sec(struct b43legacy_wldev *dev)
dev->radio_hw_enable = radio_hw_enable;
b43legacyinfo(dev->wl, "Radio hardware status changed to %s\n",
(radio_hw_enable) ? "enabled" : "disabled");
b43legacy_leds_update(dev, 0);
}
}
......@@ -3498,18 +3485,13 @@ static int b43legacy_wireless_core_attach(struct b43legacy_wldev *dev)
else
have_bphy = 1;
/* Initialize LEDs structs. */
err = b43legacy_leds_init(dev);
if (err)
goto err_powerdown;
dev->phy.gmode = (have_gphy || have_bphy);
tmp = dev->phy.gmode ? B43legacy_TMSLOW_GMODE : 0;
b43legacy_wireless_core_reset(dev, tmp);
err = b43legacy_phy_versioning(dev);
if (err)
goto err_leds_exit;
goto err_powerdown;
/* Check if this device supports multiband. */
if (!pdev ||
(pdev->device != 0x4312 &&
......@@ -3535,10 +3517,10 @@ static int b43legacy_wireless_core_attach(struct b43legacy_wldev *dev)
err = b43legacy_validate_chipaccess(dev);
if (err)
goto err_leds_exit;
goto err_powerdown;
err = b43legacy_setup_modes(dev, have_bphy, have_gphy);
if (err)
goto err_leds_exit;
goto err_powerdown;
/* Now set some default "current_dev" */
if (!wl->current_dev)
......@@ -3553,8 +3535,6 @@ static int b43legacy_wireless_core_attach(struct b43legacy_wldev *dev)
out:
return err;
err_leds_exit:
b43legacy_leds_exit(dev);
err_powerdown:
ssb_bus_may_powerdown(bus);
return err;
......
......@@ -2113,7 +2113,6 @@ void b43legacy_radio_turn_on(struct b43legacy_wldev *dev)
B43legacy_BUG_ON(1);
}
phy->radio_on = 1;
b43legacy_leds_update(dev, 0);
}
void b43legacy_radio_turn_off(struct b43legacy_wldev *dev)
......@@ -2135,7 +2134,6 @@ void b43legacy_radio_turn_off(struct b43legacy_wldev *dev)
b43legacy_phy_write(dev, 0x0015, 0xAA00);
phy->radio_on = 0;
b43legacydbg(dev->wl, "Radio initialized\n");
b43legacy_leds_update(dev, 0);
}
void b43legacy_radio_clear_tssi(struct b43legacy_wldev *dev)
......
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