2008-03-25 23:33:36 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2009-01-08 18:20:02 +00:00
|
|
|
* Copyright(c) 2003 - 2009 Intel Corporation. All rights reserved.
|
2008-03-25 23:33:36 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
*
|
|
|
|
* The full GNU General Public License is included in this distribution in the
|
|
|
|
* file called LICENSE.
|
|
|
|
*
|
|
|
|
* Contact Information:
|
2008-12-09 19:28:58 +00:00
|
|
|
* Intel Linux Wireless <ilw@linux.intel.com>
|
2008-03-25 23:33:36 +00:00
|
|
|
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/wireless.h>
|
|
|
|
#include <net/mac80211.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <asm/unaligned.h>
|
|
|
|
|
2008-04-24 18:55:38 +00:00
|
|
|
#include "iwl-dev.h"
|
2008-03-25 23:33:36 +00:00
|
|
|
#include "iwl-core.h"
|
2008-04-03 23:05:21 +00:00
|
|
|
#include "iwl-io.h"
|
2008-03-25 23:33:36 +00:00
|
|
|
|
2009-09-17 17:43:54 +00:00
|
|
|
/* default: IWL_LED_BLINK(0) using blinking index table */
|
|
|
|
static int led_mode;
|
|
|
|
module_param(led_mode, int, S_IRUGO);
|
|
|
|
MODULE_PARM_DESC(led_mode, "led mode: 0=blinking, 1=On(RF On)/Off(RF Off), "
|
|
|
|
"(default 0)\n");
|
|
|
|
|
2008-07-11 03:53:36 +00:00
|
|
|
#ifdef CONFIG_IWLWIFI_DEBUG
|
|
|
|
static const char *led_type_str[] = {
|
|
|
|
__stringify(IWL_LED_TRG_TX),
|
|
|
|
__stringify(IWL_LED_TRG_RX),
|
|
|
|
__stringify(IWL_LED_TRG_ASSOC),
|
|
|
|
__stringify(IWL_LED_TRG_RADIO),
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
#endif /* CONFIG_IWLWIFI_DEBUG */
|
|
|
|
|
|
|
|
|
2008-03-25 23:33:36 +00:00
|
|
|
static const struct {
|
2009-07-17 16:30:20 +00:00
|
|
|
u16 tpt; /* Mb/s */
|
2008-03-25 23:33:36 +00:00
|
|
|
u8 on_time;
|
2008-07-11 03:53:36 +00:00
|
|
|
u8 off_time;
|
2008-03-25 23:33:36 +00:00
|
|
|
} blink_tbl[] =
|
|
|
|
{
|
|
|
|
{300, 25, 25},
|
|
|
|
{200, 40, 40},
|
|
|
|
{100, 55, 55},
|
|
|
|
{70, 65, 65},
|
|
|
|
{50, 75, 75},
|
|
|
|
{20, 85, 85},
|
2009-09-11 17:38:07 +00:00
|
|
|
{10, 95, 95},
|
|
|
|
{5, 110, 110},
|
|
|
|
{1, 130, 130},
|
2008-07-11 03:53:37 +00:00
|
|
|
{0, 167, 167},
|
|
|
|
/* SOLID_ON */
|
|
|
|
{-1, IWL_LED_SOLID, 0}
|
2008-03-25 23:33:36 +00:00
|
|
|
};
|
|
|
|
|
2008-07-11 03:53:37 +00:00
|
|
|
#define IWL_1MB_RATE (128 * 1024)
|
|
|
|
#define IWL_LED_THRESHOLD (16)
|
|
|
|
#define IWL_MAX_BLINK_TBL (ARRAY_SIZE(blink_tbl) - 1) /* exclude SOLID_ON */
|
|
|
|
#define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1)
|
|
|
|
|
2009-09-11 17:38:14 +00:00
|
|
|
/*
|
|
|
|
* Adjust led blink rate to compensate on a MAC Clock difference on every HW
|
|
|
|
* Led blink rate analysis showed an average deviation of 0% on 3945,
|
|
|
|
* 5% on 4965 HW and 20% on 5000 series and up.
|
|
|
|
* Need to compensate on the led on/off time per HW according to the deviation
|
|
|
|
* to achieve the desired led frequency
|
|
|
|
* The calculation is: (100-averageDeviation)/100 * blinkTime
|
|
|
|
* For code efficiency the calculation will be:
|
|
|
|
* compensation = (100 - averageDeviation) * 64 / 100
|
|
|
|
* NewBlinkTime = (compensation * BlinkTime) / 64
|
|
|
|
*/
|
|
|
|
static inline u8 iwl_blink_compensation(struct iwl_priv *priv,
|
|
|
|
u8 time, u16 compensation)
|
|
|
|
{
|
|
|
|
if (!compensation) {
|
|
|
|
IWL_ERR(priv, "undefined blink compensation: "
|
|
|
|
"use pre-defined blinking time\n");
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (u8)((time * compensation) >> 6);
|
|
|
|
}
|
|
|
|
|
2008-07-11 03:53:37 +00:00
|
|
|
/* [0-256] -> [0..8] FIXME: we need [0..10] */
|
|
|
|
static inline int iwl_brightness_to_idx(enum led_brightness brightness)
|
2008-03-25 23:33:36 +00:00
|
|
|
{
|
2008-07-11 03:53:37 +00:00
|
|
|
return fls(0x000000FF & (u32)brightness);
|
2008-03-25 23:33:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Send led command */
|
2008-07-11 03:53:37 +00:00
|
|
|
static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
|
2008-03-25 23:33:36 +00:00
|
|
|
{
|
|
|
|
struct iwl_host_cmd cmd = {
|
|
|
|
.id = REPLY_LEDS_CMD,
|
2008-07-11 03:53:37 +00:00
|
|
|
.len = sizeof(struct iwl_led_cmd),
|
2008-03-25 23:33:36 +00:00
|
|
|
.data = led_cmd,
|
2009-07-24 18:13:05 +00:00
|
|
|
.flags = CMD_ASYNC,
|
|
|
|
.callback = NULL,
|
2008-03-25 23:33:36 +00:00
|
|
|
};
|
|
|
|
u32 reg;
|
|
|
|
|
2008-03-25 23:33:37 +00:00
|
|
|
reg = iwl_read32(priv, CSR_LED_REG);
|
2008-03-25 23:33:36 +00:00
|
|
|
if (reg != (reg & CSR_LED_BSM_CTRL_MSK))
|
2008-03-25 23:33:37 +00:00
|
|
|
iwl_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK);
|
2008-03-25 23:33:36 +00:00
|
|
|
|
|
|
|
return iwl_send_cmd(priv, &cmd);
|
|
|
|
}
|
|
|
|
|
2008-07-11 03:53:37 +00:00
|
|
|
/* Set led pattern command */
|
2009-07-17 16:30:17 +00:00
|
|
|
static int iwl_led_pattern(struct iwl_priv *priv, int led_id,
|
2008-07-11 03:53:42 +00:00
|
|
|
unsigned int idx)
|
2008-03-25 23:33:36 +00:00
|
|
|
{
|
2008-07-11 03:53:37 +00:00
|
|
|
struct iwl_led_cmd led_cmd = {
|
2008-03-25 23:33:36 +00:00
|
|
|
.id = led_id,
|
|
|
|
.interval = IWL_DEF_LED_INTRVL
|
|
|
|
};
|
|
|
|
|
2008-07-11 03:53:37 +00:00
|
|
|
BUG_ON(idx > IWL_MAX_BLINK_TBL);
|
|
|
|
|
2009-09-11 17:38:14 +00:00
|
|
|
IWL_DEBUG_LED(priv, "Led blink time compensation= %u\n",
|
|
|
|
priv->cfg->led_compensation);
|
|
|
|
led_cmd.on =
|
|
|
|
iwl_blink_compensation(priv, blink_tbl[idx].on_time,
|
|
|
|
priv->cfg->led_compensation);
|
|
|
|
led_cmd.off =
|
|
|
|
iwl_blink_compensation(priv, blink_tbl[idx].off_time,
|
|
|
|
priv->cfg->led_compensation);
|
2008-07-11 03:53:37 +00:00
|
|
|
|
2008-03-25 23:33:36 +00:00
|
|
|
return iwl_send_led_cmd(priv, &led_cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set led register off */
|
2009-07-17 16:30:17 +00:00
|
|
|
static int iwl_led_on_reg(struct iwl_priv *priv, int led_id)
|
2008-03-25 23:33:36 +00:00
|
|
|
{
|
2009-01-27 22:27:56 +00:00
|
|
|
IWL_DEBUG_LED(priv, "led on %d\n", led_id);
|
2008-03-25 23:33:37 +00:00
|
|
|
iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON);
|
2008-03-25 23:33:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2008-07-11 03:53:37 +00:00
|
|
|
/* Set led on command */
|
2009-07-17 16:30:17 +00:00
|
|
|
static int iwl_led_on(struct iwl_priv *priv, int led_id)
|
2008-07-11 03:53:37 +00:00
|
|
|
{
|
|
|
|
struct iwl_led_cmd led_cmd = {
|
|
|
|
.id = led_id,
|
|
|
|
.on = IWL_LED_SOLID,
|
|
|
|
.off = 0,
|
|
|
|
.interval = IWL_DEF_LED_INTRVL
|
|
|
|
};
|
|
|
|
return iwl_send_led_cmd(priv, &led_cmd);
|
|
|
|
}
|
|
|
|
|
2008-03-25 23:33:36 +00:00
|
|
|
/* Set led off command */
|
2009-07-17 16:30:17 +00:00
|
|
|
int iwl_led_off(struct iwl_priv *priv, int led_id)
|
2008-03-25 23:33:36 +00:00
|
|
|
{
|
2008-07-11 03:53:37 +00:00
|
|
|
struct iwl_led_cmd led_cmd = {
|
2008-03-25 23:33:36 +00:00
|
|
|
.id = led_id,
|
|
|
|
.on = 0,
|
|
|
|
.off = 0,
|
|
|
|
.interval = IWL_DEF_LED_INTRVL
|
|
|
|
};
|
2009-01-27 22:27:56 +00:00
|
|
|
IWL_DEBUG_LED(priv, "led off %d\n", led_id);
|
2008-03-25 23:33:36 +00:00
|
|
|
return iwl_send_led_cmd(priv, &led_cmd);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Set led register off */
|
2009-07-17 16:30:17 +00:00
|
|
|
static int iwl_led_off_reg(struct iwl_priv *priv, int led_id)
|
2008-03-25 23:33:36 +00:00
|
|
|
{
|
2009-01-27 22:27:56 +00:00
|
|
|
IWL_DEBUG_LED(priv, "LED Reg off\n");
|
2008-03-25 23:33:37 +00:00
|
|
|
iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_OFF);
|
2008-03-25 23:33:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-07-18 05:53:07 +00:00
|
|
|
/*
|
|
|
|
* Set led register in case of disassociation according to rfkill state
|
|
|
|
*/
|
|
|
|
static int iwl_led_associate(struct iwl_priv *priv, int led_id)
|
|
|
|
{
|
2009-01-27 22:27:56 +00:00
|
|
|
IWL_DEBUG_LED(priv, "Associated\n");
|
2009-09-17 17:43:54 +00:00
|
|
|
if (led_mode == IWL_LED_BLINK)
|
|
|
|
priv->allow_blinking = 1;
|
2009-07-17 16:30:17 +00:00
|
|
|
return iwl_led_on_reg(priv, led_id);
|
2008-07-18 05:53:07 +00:00
|
|
|
}
|
|
|
|
static int iwl_led_disassociate(struct iwl_priv *priv, int led_id)
|
|
|
|
{
|
|
|
|
priv->allow_blinking = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-03-25 23:33:36 +00:00
|
|
|
/*
|
|
|
|
* brightness call back function for Tx/Rx LED
|
|
|
|
*/
|
2008-07-11 03:53:37 +00:00
|
|
|
static int iwl_led_associated(struct iwl_priv *priv, int led_id)
|
2008-03-25 23:33:36 +00:00
|
|
|
{
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
|
|
|
|
!test_bit(STATUS_READY, &priv->status))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
/* start counting Tx/Rx bytes */
|
|
|
|
if (!priv->last_blink_time && priv->allow_blinking)
|
|
|
|
priv->last_blink_time = jiffies;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* brightness call back for association and radio
|
|
|
|
*/
|
2008-07-11 03:53:36 +00:00
|
|
|
static void iwl_led_brightness_set(struct led_classdev *led_cdev,
|
2008-03-25 23:33:36 +00:00
|
|
|
enum led_brightness brightness)
|
|
|
|
{
|
2008-07-11 03:53:36 +00:00
|
|
|
struct iwl_led *led = container_of(led_cdev, struct iwl_led, led_dev);
|
2008-03-25 23:33:36 +00:00
|
|
|
struct iwl_priv *priv = led->priv;
|
|
|
|
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
|
|
|
|
return;
|
|
|
|
|
2008-07-11 03:53:36 +00:00
|
|
|
|
2009-01-27 22:27:56 +00:00
|
|
|
IWL_DEBUG_LED(priv, "Led type = %s brightness = %d\n",
|
2008-07-11 03:53:36 +00:00
|
|
|
led_type_str[led->type], brightness);
|
2008-03-25 23:33:36 +00:00
|
|
|
switch (brightness) {
|
|
|
|
case LED_FULL:
|
|
|
|
if (led->led_on)
|
|
|
|
led->led_on(priv, IWL_LED_LINK);
|
|
|
|
break;
|
|
|
|
case LED_OFF:
|
|
|
|
if (led->led_off)
|
|
|
|
led->led_off(priv, IWL_LED_LINK);
|
|
|
|
break;
|
|
|
|
default:
|
2008-07-11 03:53:37 +00:00
|
|
|
if (led->led_pattern) {
|
|
|
|
int idx = iwl_brightness_to_idx(brightness);
|
|
|
|
led->led_pattern(priv, IWL_LED_LINK, idx);
|
|
|
|
}
|
2008-03-25 23:33:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Register led class with the system
|
|
|
|
*/
|
2008-07-11 03:53:36 +00:00
|
|
|
static int iwl_leds_register_led(struct iwl_priv *priv, struct iwl_led *led,
|
2008-03-25 23:33:36 +00:00
|
|
|
enum led_type type, u8 set_led,
|
2008-08-01 19:57:16 +00:00
|
|
|
char *trigger)
|
2008-03-25 23:33:36 +00:00
|
|
|
{
|
|
|
|
struct device *device = wiphy_dev(priv->hw->wiphy);
|
|
|
|
int ret;
|
|
|
|
|
2008-08-01 19:57:16 +00:00
|
|
|
led->led_dev.name = led->name;
|
2008-07-11 03:53:36 +00:00
|
|
|
led->led_dev.brightness_set = iwl_led_brightness_set;
|
2008-03-25 23:33:36 +00:00
|
|
|
led->led_dev.default_trigger = trigger;
|
|
|
|
|
2008-03-28 23:21:11 +00:00
|
|
|
led->priv = priv;
|
|
|
|
led->type = type;
|
|
|
|
|
2008-03-25 23:33:36 +00:00
|
|
|
ret = led_classdev_register(device, &led->led_dev);
|
|
|
|
if (ret) {
|
2008-12-19 02:37:33 +00:00
|
|
|
IWL_ERR(priv, "Error: failed to register led handler.\n");
|
2008-03-25 23:33:36 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
led->registered = 1;
|
|
|
|
|
|
|
|
if (set_led && led->led_on)
|
|
|
|
led->led_on(priv, IWL_LED_LINK);
|
2008-03-28 23:21:11 +00:00
|
|
|
|
2008-03-25 23:33:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-07-17 16:30:20 +00:00
|
|
|
* calculate blink rate according to last second Tx/Rx activities
|
2008-03-25 23:33:36 +00:00
|
|
|
*/
|
2008-07-11 03:53:37 +00:00
|
|
|
static int iwl_get_blink_rate(struct iwl_priv *priv)
|
2008-03-25 23:33:36 +00:00
|
|
|
{
|
|
|
|
int i;
|
2009-07-17 16:30:20 +00:00
|
|
|
/* count both tx and rx traffic to be able to
|
|
|
|
* handle traffic in either direction
|
|
|
|
*/
|
2009-08-07 22:41:40 +00:00
|
|
|
u64 current_tpt = priv->tx_stats.data_bytes +
|
|
|
|
priv->rx_stats.data_bytes;
|
2008-03-25 23:33:36 +00:00
|
|
|
s64 tpt = current_tpt - priv->led_tpt;
|
|
|
|
|
2008-10-24 06:48:56 +00:00
|
|
|
if (tpt < 0) /* wraparound */
|
2008-03-25 23:33:36 +00:00
|
|
|
tpt = -tpt;
|
|
|
|
|
2009-01-27 22:27:56 +00:00
|
|
|
IWL_DEBUG_LED(priv, "tpt %lld current_tpt %llu\n",
|
2008-07-23 06:50:04 +00:00
|
|
|
(long long)tpt,
|
|
|
|
(unsigned long long)current_tpt);
|
2008-03-25 23:33:36 +00:00
|
|
|
priv->led_tpt = current_tpt;
|
|
|
|
|
2008-07-11 03:53:37 +00:00
|
|
|
if (!priv->allow_blinking)
|
2008-03-25 23:33:36 +00:00
|
|
|
i = IWL_MAX_BLINK_TBL;
|
2008-07-11 03:53:37 +00:00
|
|
|
else
|
2008-03-25 23:33:36 +00:00
|
|
|
for (i = 0; i < IWL_MAX_BLINK_TBL; i++)
|
|
|
|
if (tpt > (blink_tbl[i].tpt * IWL_1MB_RATE))
|
|
|
|
break;
|
|
|
|
|
2009-01-27 22:27:56 +00:00
|
|
|
IWL_DEBUG_LED(priv, "LED BLINK IDX=%d\n", i);
|
2008-07-11 03:53:37 +00:00
|
|
|
return i;
|
2008-03-25 23:33:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* this function called from handler. Since setting Led command can
|
|
|
|
* happen very frequent we postpone led command to be called from
|
|
|
|
* REPLY handler so we know ucode is up
|
|
|
|
*/
|
|
|
|
void iwl_leds_background(struct iwl_priv *priv)
|
|
|
|
{
|
2008-07-11 03:53:37 +00:00
|
|
|
u8 blink_idx;
|
2008-03-25 23:33:36 +00:00
|
|
|
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
|
|
|
|
priv->last_blink_time = 0;
|
|
|
|
return;
|
|
|
|
}
|
2008-07-18 05:53:07 +00:00
|
|
|
if (iwl_is_rfkill(priv)) {
|
2008-03-25 23:33:36 +00:00
|
|
|
priv->last_blink_time = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!priv->allow_blinking) {
|
|
|
|
priv->last_blink_time = 0;
|
2008-07-11 03:53:37 +00:00
|
|
|
if (priv->last_blink_rate != IWL_SOLID_BLINK_IDX) {
|
|
|
|
priv->last_blink_rate = IWL_SOLID_BLINK_IDX;
|
2009-07-17 16:30:17 +00:00
|
|
|
iwl_led_pattern(priv, IWL_LED_LINK,
|
2008-07-11 03:53:37 +00:00
|
|
|
IWL_SOLID_BLINK_IDX);
|
2008-03-25 23:33:36 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!priv->last_blink_time ||
|
|
|
|
!time_after(jiffies, priv->last_blink_time +
|
|
|
|
msecs_to_jiffies(1000)))
|
|
|
|
return;
|
|
|
|
|
2008-07-11 03:53:37 +00:00
|
|
|
blink_idx = iwl_get_blink_rate(priv);
|
2008-03-25 23:33:36 +00:00
|
|
|
|
|
|
|
/* call only if blink rate change */
|
2008-07-11 03:53:37 +00:00
|
|
|
if (blink_idx != priv->last_blink_rate)
|
2009-07-17 16:30:17 +00:00
|
|
|
iwl_led_pattern(priv, IWL_LED_LINK, blink_idx);
|
2008-03-25 23:33:36 +00:00
|
|
|
|
2008-07-11 03:53:36 +00:00
|
|
|
priv->last_blink_time = jiffies;
|
2008-07-11 03:53:37 +00:00
|
|
|
priv->last_blink_rate = blink_idx;
|
2008-03-25 23:33:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Register all led handler */
|
|
|
|
int iwl_leds_register(struct iwl_priv *priv)
|
|
|
|
{
|
|
|
|
char *trigger;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
priv->last_blink_rate = 0;
|
|
|
|
priv->led_tpt = 0;
|
|
|
|
priv->last_blink_time = 0;
|
|
|
|
priv->allow_blinking = 0;
|
|
|
|
|
|
|
|
trigger = ieee80211_get_radio_led_name(priv->hw);
|
2008-08-01 19:57:16 +00:00
|
|
|
snprintf(priv->led[IWL_LED_TRG_RADIO].name,
|
2009-01-29 20:58:26 +00:00
|
|
|
sizeof(priv->led[IWL_LED_TRG_RADIO].name), "iwl-%s::radio",
|
2008-03-25 23:33:36 +00:00
|
|
|
wiphy_name(priv->hw->wiphy));
|
|
|
|
|
2009-07-17 16:30:17 +00:00
|
|
|
priv->led[IWL_LED_TRG_RADIO].led_on = iwl_led_on_reg;
|
|
|
|
priv->led[IWL_LED_TRG_RADIO].led_off = iwl_led_off_reg;
|
2008-03-25 23:33:36 +00:00
|
|
|
priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL;
|
|
|
|
|
2008-07-11 03:53:36 +00:00
|
|
|
ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RADIO],
|
2008-08-01 19:57:16 +00:00
|
|
|
IWL_LED_TRG_RADIO, 1, trigger);
|
2008-03-25 23:33:36 +00:00
|
|
|
if (ret)
|
|
|
|
goto exit_fail;
|
|
|
|
|
|
|
|
trigger = ieee80211_get_assoc_led_name(priv->hw);
|
2008-08-01 19:57:16 +00:00
|
|
|
snprintf(priv->led[IWL_LED_TRG_ASSOC].name,
|
2009-01-29 20:58:26 +00:00
|
|
|
sizeof(priv->led[IWL_LED_TRG_ASSOC].name), "iwl-%s::assoc",
|
2008-03-25 23:33:36 +00:00
|
|
|
wiphy_name(priv->hw->wiphy));
|
|
|
|
|
2008-07-11 03:53:36 +00:00
|
|
|
ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_ASSOC],
|
2008-08-01 19:57:16 +00:00
|
|
|
IWL_LED_TRG_ASSOC, 0, trigger);
|
2008-07-11 03:53:36 +00:00
|
|
|
|
2008-03-25 23:33:36 +00:00
|
|
|
/* for assoc always turn led on */
|
2008-07-18 05:53:07 +00:00
|
|
|
priv->led[IWL_LED_TRG_ASSOC].led_on = iwl_led_associate;
|
|
|
|
priv->led[IWL_LED_TRG_ASSOC].led_off = iwl_led_disassociate;
|
2008-03-25 23:33:36 +00:00
|
|
|
priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL;
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
goto exit_fail;
|
|
|
|
|
|
|
|
trigger = ieee80211_get_rx_led_name(priv->hw);
|
2008-08-01 19:57:16 +00:00
|
|
|
snprintf(priv->led[IWL_LED_TRG_RX].name,
|
2009-01-29 20:58:26 +00:00
|
|
|
sizeof(priv->led[IWL_LED_TRG_RX].name), "iwl-%s::RX",
|
2008-08-01 19:57:16 +00:00
|
|
|
wiphy_name(priv->hw->wiphy));
|
2008-03-25 23:33:36 +00:00
|
|
|
|
2008-07-11 03:53:36 +00:00
|
|
|
ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RX],
|
2008-08-01 19:57:16 +00:00
|
|
|
IWL_LED_TRG_RX, 0, trigger);
|
2008-03-25 23:33:36 +00:00
|
|
|
|
2008-07-11 03:53:37 +00:00
|
|
|
priv->led[IWL_LED_TRG_RX].led_on = iwl_led_associated;
|
|
|
|
priv->led[IWL_LED_TRG_RX].led_off = iwl_led_associated;
|
2009-07-17 16:30:17 +00:00
|
|
|
priv->led[IWL_LED_TRG_RX].led_pattern = iwl_led_pattern;
|
2008-03-25 23:33:36 +00:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
goto exit_fail;
|
|
|
|
|
|
|
|
trigger = ieee80211_get_tx_led_name(priv->hw);
|
2008-08-01 19:57:16 +00:00
|
|
|
snprintf(priv->led[IWL_LED_TRG_TX].name,
|
2009-01-29 20:58:26 +00:00
|
|
|
sizeof(priv->led[IWL_LED_TRG_TX].name), "iwl-%s::TX",
|
2008-08-01 19:57:16 +00:00
|
|
|
wiphy_name(priv->hw->wiphy));
|
|
|
|
|
2008-07-11 03:53:36 +00:00
|
|
|
ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_TX],
|
2008-08-01 19:57:16 +00:00
|
|
|
IWL_LED_TRG_TX, 0, trigger);
|
2008-07-11 03:53:36 +00:00
|
|
|
|
2008-07-11 03:53:37 +00:00
|
|
|
priv->led[IWL_LED_TRG_TX].led_on = iwl_led_associated;
|
|
|
|
priv->led[IWL_LED_TRG_TX].led_off = iwl_led_associated;
|
2009-07-17 16:30:17 +00:00
|
|
|
priv->led[IWL_LED_TRG_TX].led_pattern = iwl_led_pattern;
|
2008-03-25 23:33:36 +00:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
goto exit_fail;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
exit_fail:
|
|
|
|
iwl_leds_unregister(priv);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(iwl_leds_register);
|
|
|
|
|
|
|
|
/* unregister led class */
|
2008-07-11 03:53:36 +00:00
|
|
|
static void iwl_leds_unregister_led(struct iwl_led *led, u8 set_led)
|
2008-03-25 23:33:36 +00:00
|
|
|
{
|
|
|
|
if (!led->registered)
|
|
|
|
return;
|
|
|
|
|
|
|
|
led_classdev_unregister(&led->led_dev);
|
|
|
|
|
|
|
|
if (set_led)
|
|
|
|
led->led_dev.brightness_set(&led->led_dev, LED_OFF);
|
|
|
|
led->registered = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unregister all led handlers */
|
|
|
|
void iwl_leds_unregister(struct iwl_priv *priv)
|
|
|
|
{
|
|
|
|
iwl_leds_unregister_led(&priv->led[IWL_LED_TRG_ASSOC], 0);
|
|
|
|
iwl_leds_unregister_led(&priv->led[IWL_LED_TRG_RX], 0);
|
|
|
|
iwl_leds_unregister_led(&priv->led[IWL_LED_TRG_TX], 0);
|
|
|
|
iwl_leds_unregister_led(&priv->led[IWL_LED_TRG_RADIO], 1);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(iwl_leds_unregister);
|
|
|
|
|