Commit ab53d8af authored by Mohamed Abbas's avatar Mohamed Abbas Committed by John W. Linville

iwlwifi: Add led support

This patch add LEDS support to 3965 and 4965 drivers. It is based on
led trigger and class. For our drivers we needed to avoid two things.
1- We receive led trigger on/off on each Rx\Tx frame. In our driver
    we can not call led command like that. In this driver once driver
    receive a start of traffic it call the led command to start blinking
    then we count all bytes of Tx and Rx frame, after two second we count the
    blink rate of last two second then id blink rate changed we call the led
     commands
2- Since we can call led command very often, we make sure we call the
    led command after we receive the statistics notification so
    we don't need to wake up the ucode id it is in sleep state.
    This patch was tested with 4965 and 3945.
Signed-off-by: default avatarMohamed Abbas <mabbas@linux.intel.com>
Signed-off-by: Ian Schram<ischram@telenet.be>
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent e0e0a67e
...@@ -2,6 +2,13 @@ config IWLCORE ...@@ -2,6 +2,13 @@ config IWLCORE
tristate "Intel Wireless Wifi Core" tristate "Intel Wireless Wifi Core"
depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
config IWLWIFI_LEDS
bool "Enable LEDS features in iwlwifi driver"
depends on IWLCORE && MAC80211_LEDS && LEDS_CLASS
---help---
This option enables LEDS for the iwlwifi drivers
config IWL4965 config IWL4965
tristate "Intel Wireless WiFi 4965AGN" tristate "Intel Wireless WiFi 4965AGN"
depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
...@@ -37,6 +44,13 @@ config IWL4965_HT ...@@ -37,6 +44,13 @@ config IWL4965_HT
This option enables IEEE 802.11n High Throughput features This option enables IEEE 802.11n High Throughput features
for the iwl4965 driver. for the iwl4965 driver.
config IWL4965_LEDS
bool "Enable LEDS features in iwl4965 driver"
depends on IWL4965 && IWLWIFI_LEDS
---help---
This option enables LEDS for the iwlwifi drivers
config IWL4965_SPECTRUM_MEASUREMENT config IWL4965_SPECTRUM_MEASUREMENT
bool "Enable Spectrum Measurement in iwl4965 driver" bool "Enable Spectrum Measurement in iwl4965 driver"
depends on IWL4965 depends on IWL4965
...@@ -114,6 +128,12 @@ config IWL3945_SPECTRUM_MEASUREMENT ...@@ -114,6 +128,12 @@ config IWL3945_SPECTRUM_MEASUREMENT
---help--- ---help---
This option will enable spectrum measurement for the iwl3945 driver. This option will enable spectrum measurement for the iwl3945 driver.
config IWL3945_LEDS
bool "Enable LEDS features in iwl3945 driver"
depends on IWL3945 && MAC80211_LEDS && LEDS_CLASS
---help---
This option enables LEDS for the iwl3945 driver.
config IWL3945_DEBUG config IWL3945_DEBUG
bool "Enable full debugging output in iwl3945 driver" bool "Enable full debugging output in iwl3945 driver"
depends on IWL3945 depends on IWL3945
......
...@@ -5,8 +5,18 @@ ifeq ($(CONFIG_IWLWIFI_DEBUGFS),y) ...@@ -5,8 +5,18 @@ ifeq ($(CONFIG_IWLWIFI_DEBUGFS),y)
iwlcore-objs += iwl-debugfs.o iwlcore-objs += iwl-debugfs.o
endif endif
ifeq ($(CONFIG_IWLWIFI_LEDS),y)
iwlcore-objs += iwl-led.o
endif
obj-$(CONFIG_IWL3945) += iwl3945.o obj-$(CONFIG_IWL3945) += iwl3945.o
iwl3945-objs = iwl3945-base.o iwl-3945.o iwl-3945-rs.o iwl3945-objs = iwl3945-base.o iwl-3945.o iwl-3945-rs.o
ifeq ($(CONFIG_IWL3945_LEDS),y)
iwl3945-objs += iwl-3945-led.o
endif
obj-$(CONFIG_IWL4965) += iwl4965.o obj-$(CONFIG_IWL4965) += iwl4965.o
iwl4965-objs = iwl4965-base.o iwl-4965.o iwl-4965-rs.o iwl4965-objs = iwl4965-base.o iwl-4965.o iwl-4965-rs.o
This diff is collapsed.
/******************************************************************************
*
* Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* 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:
* James P. Ketrenos <ipw2100-admin@linux.intel.com>
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*
*****************************************************************************/
#ifndef IWL3945_LEDS_H
#define IWL3945_LEDS_H
struct iwl3945_priv;
#ifdef CONFIG_IWL3945_LEDS
#define IWL_LED_SOLID 11
#define IWL_LED_NAME_LEN 31
#define IWL_DEF_LED_INTRVL __constant_cpu_to_le32(1000)
#define IWL_LED_ACTIVITY (0<<1)
#define IWL_LED_LINK (1<<1)
enum led_type {
IWL_LED_TRG_TX,
IWL_LED_TRG_RX,
IWL_LED_TRG_ASSOC,
IWL_LED_TRG_RADIO,
IWL_LED_TRG_MAX,
};
#include <linux/leds.h>
struct iwl3945_led {
struct iwl3945_priv *priv;
struct led_classdev led_dev;
int (*led_on) (struct iwl3945_priv *priv, int led_id);
int (*led_off) (struct iwl3945_priv *priv, int led_id);
int (*led_pattern) (struct iwl3945_priv *priv, int led_id,
enum led_brightness brightness);
enum led_type type;
unsigned int registered;
};
extern int iwl3945_led_register(struct iwl3945_priv *priv);
extern void iwl3945_led_unregister(struct iwl3945_priv *priv);
extern void iwl3945_led_background(struct iwl3945_priv *priv);
#else
static inline int iwl3945_led_register(struct iwl3945_priv *priv) { return 0; }
static inline void iwl3945_led_unregister(struct iwl3945_priv *priv) {}
static inline void iwl3945_led_background(struct iwl3945_priv *priv) {}
#endif /* CONFIG_IWL3945_LEDS */
#endif /* IWL3945_LEDS_H */
...@@ -358,6 +358,8 @@ void iwl3945_hw_rx_statistics(struct iwl3945_priv *priv, struct iwl3945_rx_mem_b ...@@ -358,6 +358,8 @@ void iwl3945_hw_rx_statistics(struct iwl3945_priv *priv, struct iwl3945_rx_mem_b
memcpy(&priv->statistics, pkt->u.raw, sizeof(priv->statistics)); memcpy(&priv->statistics, pkt->u.raw, sizeof(priv->statistics));
iwl3945_led_background(priv);
priv->last_statistics_time = jiffies; priv->last_statistics_time = jiffies;
} }
...@@ -640,6 +642,10 @@ static void iwl3945_handle_data_packet(struct iwl3945_priv *priv, int is_data, ...@@ -640,6 +642,10 @@ static void iwl3945_handle_data_packet(struct iwl3945_priv *priv, int is_data,
if (priv->add_radiotap) if (priv->add_radiotap)
iwl3945_add_radiotap(priv, rxb->skb, rx_hdr, stats); iwl3945_add_radiotap(priv, rxb->skb, rx_hdr, stats);
#ifdef CONFIG_IWL3945_LEDS
if (is_data)
priv->rxtxpackets += len;
#endif
ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats); ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats);
rxb->skb = NULL; rxb->skb = NULL;
} }
......
...@@ -44,6 +44,7 @@ extern struct pci_device_id iwl3945_hw_card_ids[]; ...@@ -44,6 +44,7 @@ extern struct pci_device_id iwl3945_hw_card_ids[];
#include "iwl-prph.h" #include "iwl-prph.h"
#include "iwl-3945-hw.h" #include "iwl-3945-hw.h"
#include "iwl-3945-debug.h" #include "iwl-3945-debug.h"
#include "iwl-3945-led.h"
/* Change firmware file name, using "-" and incrementing number, /* Change firmware file name, using "-" and incrementing number,
* *only* when uCode interface or architecture changes so that it * *only* when uCode interface or architecture changes so that it
...@@ -777,13 +778,15 @@ struct iwl3945_priv { ...@@ -777,13 +778,15 @@ struct iwl3945_priv {
struct iwl3945_init_alive_resp card_alive_init; struct iwl3945_init_alive_resp card_alive_init;
struct iwl3945_alive_resp card_alive; struct iwl3945_alive_resp card_alive;
#ifdef LED #ifdef CONFIG_IWL4965_LEDS
/* LED related variables */ struct iwl3945_led led[IWL_LED_TRG_MAX];
struct iwl3945_activity_blink activity; unsigned long last_blink_time;
unsigned long led_packets; u8 last_blink_rate;
int led_state; u8 allow_blinking;
unsigned int rxtxpackets;
#endif #endif
u16 active_rate; u16 active_rate;
u16 active_rate_basic; u16 active_rate_basic;
......
...@@ -3258,6 +3258,8 @@ void iwl4965_hw_rx_statistics(struct iwl_priv *priv, struct iwl4965_rx_mem_buffe ...@@ -3258,6 +3258,8 @@ void iwl4965_hw_rx_statistics(struct iwl_priv *priv, struct iwl4965_rx_mem_buffe
#endif #endif
} }
iwl_leds_background(priv);
/* If the hardware hasn't reported a change in /* If the hardware hasn't reported a change in
* temperature then don't bother computing a * temperature then don't bother computing a
* calibrated temperature value */ * calibrated temperature value */
...@@ -3539,10 +3541,6 @@ static void iwl4965_handle_data_packet(struct iwl_priv *priv, int is_data, ...@@ -3539,10 +3541,6 @@ static void iwl4965_handle_data_packet(struct iwl_priv *priv, int is_data,
ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats); ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats);
priv->alloc_rxb_skb--; priv->alloc_rxb_skb--;
rxb->skb = NULL; rxb->skb = NULL;
#ifdef LED
priv->led_packets += len;
iwl4965_setup_activity_timer(priv);
#endif
} }
/* Calc max signal level (dBm) among 3 possible receivers */ /* Calc max signal level (dBm) among 3 possible receivers */
......
...@@ -45,6 +45,7 @@ extern struct pci_device_id iwl4965_hw_card_ids[]; ...@@ -45,6 +45,7 @@ extern struct pci_device_id iwl4965_hw_card_ids[];
#include "iwl-csr.h" #include "iwl-csr.h"
#include "iwl-prph.h" #include "iwl-prph.h"
#include "iwl-debug.h" #include "iwl-debug.h"
#include "iwl-led.h"
/* Change firmware file name, using "-" and incrementing number, /* Change firmware file name, using "-" and incrementing number,
* *only* when uCode interface or architecture changes so that it * *only* when uCode interface or architecture changes so that it
...@@ -1050,11 +1051,12 @@ struct iwl_priv { ...@@ -1050,11 +1051,12 @@ struct iwl_priv {
struct iwl4965_init_alive_resp card_alive_init; struct iwl4965_init_alive_resp card_alive_init;
struct iwl4965_alive_resp card_alive; struct iwl4965_alive_resp card_alive;
#ifdef LED #ifdef CONFIG_IWL4965_LEDS
/* LED related variables */ struct iwl4965_led led[IWL_LED_TRG_MAX];
struct iwl4965_activity_blink activity; unsigned long last_blink_time;
unsigned long led_packets; u8 last_blink_rate;
int led_state; u8 allow_blinking;
u64 led_tpt;
#endif #endif
u16 active_rate; u16 active_rate;
......
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
#define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c) #define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c)
#define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060) #define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060)
#define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100) #define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100)
#define CSR_LED_REG (CSR_BASE+0x094)
/* Analog phase-lock-loop configuration (3945 only) /* Analog phase-lock-loop configuration (3945 only)
* Set bit 24. */ * Set bit 24. */
...@@ -214,6 +215,11 @@ ...@@ -214,6 +215,11 @@
#define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000) #define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000)
#define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000) #define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000)
/* LED */
#define CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF)
#define CSR_LED_REG_TRUN_ON (0x78)
#define CSR_LED_REG_TRUN_OFF (0x38)
/*=== HBUS (Host-side Bus) ===*/ /*=== HBUS (Host-side Bus) ===*/
#define HBUS_BASE (0x400) #define HBUS_BASE (0x400)
/* /*
......
This diff is collapsed.
/******************************************************************************
*
* Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* 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:
* James P. Ketrenos <ipw2100-admin@linux.intel.com>
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*
*****************************************************************************/
#ifndef __iwl_leds_h__
#define __iwl_leds_h__
struct iwl_priv;
#ifdef CONFIG_IWLWIFI_LEDS
#include <linux/leds.h>
#define IWL_LED_SOLID 11
#define IWL_LED_NAME_LEN 31
#define IWL_DEF_LED_INTRVL __constant_cpu_to_le32(1000)
#define IWL_LED_ACTIVITY (0<<1)
#define IWL_LED_LINK (1<<1)
enum led_type {
IWL_LED_TRG_TX,
IWL_LED_TRG_RX,
IWL_LED_TRG_ASSOC,
IWL_LED_TRG_RADIO,
IWL_LED_TRG_MAX,
};
struct iwl4965_led {
struct iwl_priv *priv;
struct led_classdev led_dev;
int (*led_on) (struct iwl_priv *priv, int led_id);
int (*led_off) (struct iwl_priv *priv, int led_id);
int (*led_pattern) (struct iwl_priv *priv, int led_id,
enum led_brightness brightness);
enum led_type type;
unsigned int registered;
};
int iwl_leds_register(struct iwl_priv *priv);
void iwl_leds_unregister(struct iwl_priv *priv);
void iwl_leds_background(struct iwl_priv *priv);
#else
static inline int iwl_leds_register(struct iwl_priv *priv)
{
return 0;
}
static inline void iwl_leds_unregister(struct iwl_priv *priv)
{
}
static inline void iwl_leds_background(struct iwl_priv *priv)
{
}
#endif /* CONFIG_IWLWIFI_LEDS */
#endif /* __iwl_leds_h__ */
...@@ -2481,8 +2481,12 @@ static void iwl3945_build_tx_cmd_basic(struct iwl3945_priv *priv, ...@@ -2481,8 +2481,12 @@ static void iwl3945_build_tx_cmd_basic(struct iwl3945_priv *priv,
cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(3); cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(3);
else else
cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(2); cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(2);
} else } else {
cmd->cmd.tx.timeout.pm_frame_timeout = 0; cmd->cmd.tx.timeout.pm_frame_timeout = 0;
#ifdef CONFIG_IWL3945_LEDS
priv->rxtxpackets += le16_to_cpu(cmd->cmd.tx.len);
#endif
}
cmd->cmd.tx.driver_txop = 0; cmd->cmd.tx.driver_txop = 0;
cmd->cmd.tx.tx_flags = tx_flags; cmd->cmd.tx.tx_flags = tx_flags;
...@@ -5855,6 +5859,8 @@ static void iwl3945_alive_start(struct iwl3945_priv *priv) ...@@ -5855,6 +5859,8 @@ static void iwl3945_alive_start(struct iwl3945_priv *priv)
IWL_DEBUG_INFO("ALIVE processing complete.\n"); IWL_DEBUG_INFO("ALIVE processing complete.\n");
wake_up_interruptible(&priv->wait_command_queue); wake_up_interruptible(&priv->wait_command_queue);
iwl3945_led_register(priv);
if (priv->error_recovering) if (priv->error_recovering)
iwl3945_error_recovery(priv); iwl3945_error_recovery(priv);
...@@ -5879,6 +5885,7 @@ static void __iwl3945_down(struct iwl3945_priv *priv) ...@@ -5879,6 +5885,7 @@ static void __iwl3945_down(struct iwl3945_priv *priv)
if (!exit_pending) if (!exit_pending)
set_bit(STATUS_EXIT_PENDING, &priv->status); set_bit(STATUS_EXIT_PENDING, &priv->status);
iwl3945_led_unregister(priv);
iwl3945_clear_stations_table(priv); iwl3945_clear_stations_table(priv);
/* Unblock any waiting calls */ /* Unblock any waiting calls */
......
...@@ -2238,8 +2238,9 @@ static void iwl4965_build_tx_cmd_basic(struct iwl_priv *priv, ...@@ -2238,8 +2238,9 @@ static void iwl4965_build_tx_cmd_basic(struct iwl_priv *priv,
cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(3); cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(3);
else else
cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(2); cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(2);
} else } else {
cmd->cmd.tx.timeout.pm_frame_timeout = 0; cmd->cmd.tx.timeout.pm_frame_timeout = 0;
}
cmd->cmd.tx.driver_txop = 0; cmd->cmd.tx.driver_txop = 0;
cmd->cmd.tx.tx_flags = tx_flags; cmd->cmd.tx.tx_flags = tx_flags;
...@@ -5712,6 +5713,8 @@ static void iwl4965_alive_start(struct iwl_priv *priv) ...@@ -5712,6 +5713,8 @@ static void iwl4965_alive_start(struct iwl_priv *priv)
IWL_DEBUG_INFO("ALIVE processing complete.\n"); IWL_DEBUG_INFO("ALIVE processing complete.\n");
wake_up_interruptible(&priv->wait_command_queue); wake_up_interruptible(&priv->wait_command_queue);
iwl_leds_register(priv);
if (priv->error_recovering) if (priv->error_recovering)
iwl4965_error_recovery(priv); iwl4965_error_recovery(priv);
...@@ -5736,6 +5739,8 @@ static void __iwl4965_down(struct iwl_priv *priv) ...@@ -5736,6 +5739,8 @@ static void __iwl4965_down(struct iwl_priv *priv)
if (!exit_pending) if (!exit_pending)
set_bit(STATUS_EXIT_PENDING, &priv->status); set_bit(STATUS_EXIT_PENDING, &priv->status);
iwl_leds_unregister(priv);
iwlcore_clear_stations_table(priv); iwlcore_clear_stations_table(priv);
/* Unblock any waiting calls */ /* Unblock any waiting calls */
......
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