2010-09-08 15:46:36 -06:00
|
|
|
#include "headers.h"
|
|
|
|
|
|
|
|
#define STATUS_IMAGE_CHECKSUM_MISMATCH -199
|
|
|
|
#define EVENT_SIGNALED 1
|
|
|
|
|
|
|
|
static B_UINT16 CFG_CalculateChecksum(B_UINT8 *pu8Buffer, B_UINT32 u32Size)
|
|
|
|
{
|
2011-12-07 10:25:06 -07:00
|
|
|
B_UINT16 u16CheckSum = 0;
|
|
|
|
while (u32Size--) {
|
2010-09-08 15:46:36 -06:00
|
|
|
u16CheckSum += (B_UINT8)~(*pu8Buffer);
|
2011-12-07 10:25:06 -07:00
|
|
|
pu8Buffer++;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
return u16CheckSum;
|
|
|
|
}
|
2011-12-07 10:25:06 -07:00
|
|
|
|
2012-05-26 10:05:12 -06:00
|
|
|
BOOLEAN IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
2011-12-07 10:25:06 -07:00
|
|
|
INT Status;
|
|
|
|
Status = (Adapter->gpioBitMap & gpios) ^ gpios;
|
|
|
|
if (Status)
|
2010-09-08 15:46:36 -06:00
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-05-26 10:05:12 -06:00
|
|
|
static INT LED_Blink(struct bcm_mini_adapter *Adapter, UINT GPIO_Num, UCHAR uiLedIndex,
|
2011-12-07 10:25:10 -07:00
|
|
|
ULONG timeout, INT num_of_time, LedEventInfo_t currdriverstate)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
|
|
|
int Status = STATUS_SUCCESS;
|
|
|
|
BOOLEAN bInfinite = FALSE;
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Check if num_of_time is -ve. If yes, blink led in infinite loop */
|
2011-12-07 10:25:09 -07:00
|
|
|
if (num_of_time < 0) {
|
2010-09-08 15:46:36 -06:00
|
|
|
bInfinite = TRUE;
|
|
|
|
num_of_time = 1;
|
|
|
|
}
|
2011-12-07 10:25:09 -07:00
|
|
|
while (num_of_time) {
|
2011-12-07 10:25:06 -07:00
|
|
|
if (currdriverstate == Adapter->DriverState)
|
2010-09-08 15:46:36 -06:00
|
|
|
TURN_ON_LED(GPIO_Num, uiLedIndex);
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Wait for timeout after setting on the LED */
|
2011-12-07 10:25:10 -07:00
|
|
|
Status = wait_event_interruptible_timeout(
|
|
|
|
Adapter->LEDInfo.notify_led_event,
|
|
|
|
currdriverstate != Adapter->DriverState ||
|
|
|
|
kthread_should_stop(),
|
|
|
|
msecs_to_jiffies(timeout));
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
if (kthread_should_stop()) {
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL,
|
|
|
|
"Led thread got signal to exit..hence exiting");
|
|
|
|
Adapter->LEDInfo.led_thread_running =
|
|
|
|
BCM_LED_THREAD_DISABLED;
|
2010-09-08 15:46:36 -06:00
|
|
|
TURN_OFF_LED(GPIO_Num, uiLedIndex);
|
2011-12-07 10:25:06 -07:00
|
|
|
Status = EVENT_SIGNALED;
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
|
|
|
}
|
2011-12-07 10:25:09 -07:00
|
|
|
if (Status) {
|
2010-09-08 15:46:36 -06:00
|
|
|
TURN_OFF_LED(GPIO_Num, uiLedIndex);
|
2011-12-07 10:25:06 -07:00
|
|
|
Status = EVENT_SIGNALED;
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
TURN_OFF_LED(GPIO_Num, uiLedIndex);
|
2011-12-07 10:25:10 -07:00
|
|
|
Status = wait_event_interruptible_timeout(
|
|
|
|
Adapter->LEDInfo.notify_led_event,
|
|
|
|
currdriverstate != Adapter->DriverState ||
|
|
|
|
kthread_should_stop(),
|
|
|
|
msecs_to_jiffies(timeout));
|
2011-12-07 10:25:06 -07:00
|
|
|
if (bInfinite == FALSE)
|
2010-09-08 15:46:36 -06:00
|
|
|
num_of_time--;
|
|
|
|
}
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2010-09-30 02:24:12 -06:00
|
|
|
static INT ScaleRateofTransfer(ULONG rate)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
2011-12-07 10:25:06 -07:00
|
|
|
if (rate <= 3)
|
2010-09-08 15:46:36 -06:00
|
|
|
return rate;
|
2011-12-07 10:25:06 -07:00
|
|
|
else if ((rate > 3) && (rate <= 100))
|
2010-09-08 15:46:36 -06:00
|
|
|
return 5;
|
2011-12-07 10:25:06 -07:00
|
|
|
else if ((rate > 100) && (rate <= 200))
|
2010-09-08 15:46:36 -06:00
|
|
|
return 6;
|
2011-12-07 10:25:06 -07:00
|
|
|
else if ((rate > 200) && (rate <= 300))
|
2010-09-08 15:46:36 -06:00
|
|
|
return 7;
|
2011-12-07 10:25:06 -07:00
|
|
|
else if ((rate > 300) && (rate <= 400))
|
2010-09-08 15:46:36 -06:00
|
|
|
return 8;
|
2011-12-07 10:25:06 -07:00
|
|
|
else if ((rate > 400) && (rate <= 500))
|
2010-09-08 15:46:36 -06:00
|
|
|
return 9;
|
2011-12-07 10:25:06 -07:00
|
|
|
else if ((rate > 500) && (rate <= 600))
|
2010-09-08 15:46:36 -06:00
|
|
|
return 10;
|
|
|
|
else
|
|
|
|
return MAX_NUM_OF_BLINKS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-26 10:05:12 -06:00
|
|
|
static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_Num_tx,
|
2011-12-07 10:25:10 -07:00
|
|
|
UCHAR uiTxLedIndex, UCHAR GPIO_Num_rx, UCHAR uiRxLedIndex,
|
|
|
|
LedEventInfo_t currdriverstate)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Initial values of TX and RX packets */
|
2010-09-08 15:46:36 -06:00
|
|
|
ULONG64 Initial_num_of_packts_tx = 0, Initial_num_of_packts_rx = 0;
|
2011-12-07 10:25:08 -07:00
|
|
|
/* values of TX and RX packets after 1 sec */
|
2010-09-08 15:46:36 -06:00
|
|
|
ULONG64 Final_num_of_packts_tx = 0, Final_num_of_packts_rx = 0;
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Rate of transfer of Tx and Rx in 1 sec */
|
2010-09-08 15:46:36 -06:00
|
|
|
ULONG64 rate_of_transfer_tx = 0, rate_of_transfer_rx = 0;
|
|
|
|
int Status = STATUS_SUCCESS;
|
|
|
|
INT num_of_time = 0, num_of_time_tx = 0, num_of_time_rx = 0;
|
|
|
|
UINT remDelay = 0;
|
|
|
|
BOOLEAN bBlinkBothLED = TRUE;
|
2011-12-07 10:25:08 -07:00
|
|
|
/* UINT GPIO_num = DISABLE_GPIO_NUM; */
|
2010-09-08 15:46:36 -06:00
|
|
|
ulong timeout = 0;
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Read initial value of packets sent/received */
|
2010-11-01 11:34:35 -06:00
|
|
|
Initial_num_of_packts_tx = Adapter->dev->stats.tx_packets;
|
|
|
|
Initial_num_of_packts_rx = Adapter->dev->stats.rx_packets;
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Scale the rate of transfer to no of blinks. */
|
2011-12-07 10:25:06 -07:00
|
|
|
num_of_time_tx = ScaleRateofTransfer((ULONG)rate_of_transfer_tx);
|
|
|
|
num_of_time_rx = ScaleRateofTransfer((ULONG)rate_of_transfer_rx);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
while ((Adapter->device_removed == FALSE)) {
|
2010-09-08 15:46:36 -06:00
|
|
|
timeout = 50;
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* Blink Tx and Rx LED when both Tx and Rx is
|
|
|
|
* in normal bandwidth
|
|
|
|
*/
|
2011-12-07 10:25:09 -07:00
|
|
|
if (bBlinkBothLED) {
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* Assign minimum number of blinks of
|
|
|
|
* either Tx or Rx.
|
|
|
|
*/
|
2011-12-07 10:25:06 -07:00
|
|
|
if (num_of_time_tx > num_of_time_rx)
|
2010-09-08 15:46:36 -06:00
|
|
|
num_of_time = num_of_time_rx;
|
|
|
|
else
|
|
|
|
num_of_time = num_of_time_tx;
|
2011-12-07 10:25:09 -07:00
|
|
|
if (num_of_time > 0) {
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Blink both Tx and Rx LEDs */
|
2011-12-07 10:25:10 -07:00
|
|
|
if (LED_Blink(Adapter, 1 << GPIO_Num_tx,
|
|
|
|
uiTxLedIndex, timeout,
|
|
|
|
num_of_time, currdriverstate)
|
2010-09-08 15:46:36 -06:00
|
|
|
== EVENT_SIGNALED)
|
|
|
|
return EVENT_SIGNALED;
|
2011-12-07 10:25:09 -07:00
|
|
|
|
2011-12-07 10:25:10 -07:00
|
|
|
if (LED_Blink(Adapter, 1 << GPIO_Num_rx,
|
|
|
|
uiRxLedIndex, timeout,
|
|
|
|
num_of_time, currdriverstate)
|
2010-09-08 15:46:36 -06:00
|
|
|
== EVENT_SIGNALED)
|
|
|
|
return EVENT_SIGNALED;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
if (num_of_time == num_of_time_tx) {
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Blink pending rate of Rx */
|
2011-12-07 10:25:10 -07:00
|
|
|
if (LED_Blink(Adapter, (1 << GPIO_Num_rx),
|
|
|
|
uiRxLedIndex, timeout,
|
|
|
|
num_of_time_rx-num_of_time,
|
|
|
|
currdriverstate)
|
|
|
|
== EVENT_SIGNALED)
|
2010-09-08 15:46:36 -06:00
|
|
|
return EVENT_SIGNALED;
|
2011-12-07 10:25:09 -07:00
|
|
|
|
2010-09-08 15:46:36 -06:00
|
|
|
num_of_time = num_of_time_rx;
|
2011-12-07 10:25:09 -07:00
|
|
|
} else {
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Blink pending rate of Tx */
|
2011-12-07 10:25:10 -07:00
|
|
|
if (LED_Blink(Adapter, 1 << GPIO_Num_tx,
|
|
|
|
uiTxLedIndex, timeout,
|
|
|
|
num_of_time_tx-num_of_time,
|
|
|
|
currdriverstate)
|
|
|
|
== EVENT_SIGNALED)
|
2010-09-08 15:46:36 -06:00
|
|
|
return EVENT_SIGNALED;
|
2011-12-07 10:25:09 -07:00
|
|
|
|
2010-09-08 15:46:36 -06:00
|
|
|
num_of_time = num_of_time_tx;
|
|
|
|
}
|
2011-12-07 10:25:09 -07:00
|
|
|
} else {
|
|
|
|
if (num_of_time == num_of_time_tx) {
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Blink pending rate of Rx */
|
2011-12-07 10:25:10 -07:00
|
|
|
if (LED_Blink(Adapter, 1 << GPIO_Num_tx,
|
|
|
|
uiTxLedIndex, timeout,
|
|
|
|
num_of_time, currdriverstate)
|
2010-09-08 15:46:36 -06:00
|
|
|
== EVENT_SIGNALED)
|
|
|
|
return EVENT_SIGNALED;
|
2011-12-07 10:25:09 -07:00
|
|
|
} else {
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Blink pending rate of Tx */
|
2011-12-07 10:25:10 -07:00
|
|
|
if (LED_Blink(Adapter, 1 << GPIO_Num_rx,
|
|
|
|
uiRxLedIndex, timeout,
|
|
|
|
num_of_time, currdriverstate)
|
|
|
|
== EVENT_SIGNALED)
|
2010-09-08 15:46:36 -06:00
|
|
|
return EVENT_SIGNALED;
|
|
|
|
}
|
|
|
|
}
|
2011-12-07 10:25:08 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If Tx/Rx rate is less than maximum blinks per second,
|
|
|
|
* wait till delay completes to 1 second
|
|
|
|
*/
|
2010-09-08 15:46:36 -06:00
|
|
|
remDelay = MAX_NUM_OF_BLINKS - num_of_time;
|
2011-12-07 10:25:09 -07:00
|
|
|
if (remDelay > 0) {
|
2011-12-07 10:25:06 -07:00
|
|
|
timeout = 100 * remDelay;
|
2011-12-07 10:25:10 -07:00
|
|
|
Status = wait_event_interruptible_timeout(
|
|
|
|
Adapter->LEDInfo.notify_led_event,
|
|
|
|
currdriverstate != Adapter->DriverState
|
|
|
|
|| kthread_should_stop(),
|
|
|
|
msecs_to_jiffies(timeout));
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
if (kthread_should_stop()) {
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
|
|
|
|
LED_DUMP_INFO, DBG_LVL_ALL,
|
|
|
|
"Led thread got signal to exit..hence exiting");
|
|
|
|
Adapter->LEDInfo.led_thread_running =
|
|
|
|
BCM_LED_THREAD_DISABLED;
|
2010-09-08 15:46:36 -06:00
|
|
|
return EVENT_SIGNALED;
|
|
|
|
}
|
2011-12-07 10:25:06 -07:00
|
|
|
if (Status)
|
2010-09-08 15:46:36 -06:00
|
|
|
return EVENT_SIGNALED;
|
|
|
|
}
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Turn off both Tx and Rx LEDs before next second */
|
2011-12-07 10:25:06 -07:00
|
|
|
TURN_OFF_LED(1 << GPIO_Num_tx, uiTxLedIndex);
|
|
|
|
TURN_OFF_LED(1 << GPIO_Num_rx, uiTxLedIndex);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
|
|
|
/*
|
2011-12-07 10:25:06 -07:00
|
|
|
* Read the Tx & Rx packets transmission after 1 second and
|
|
|
|
* calculate rate of transfer
|
|
|
|
*/
|
2010-11-01 11:34:35 -06:00
|
|
|
Final_num_of_packts_tx = Adapter->dev->stats.tx_packets;
|
|
|
|
Final_num_of_packts_rx = Adapter->dev->stats.rx_packets;
|
|
|
|
|
2011-12-07 10:25:10 -07:00
|
|
|
rate_of_transfer_tx = Final_num_of_packts_tx -
|
|
|
|
Initial_num_of_packts_tx;
|
|
|
|
rate_of_transfer_rx = Final_num_of_packts_rx -
|
|
|
|
Initial_num_of_packts_rx;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Read initial value of packets sent/received */
|
2010-09-08 15:46:36 -06:00
|
|
|
Initial_num_of_packts_tx = Final_num_of_packts_tx;
|
2011-12-07 10:25:06 -07:00
|
|
|
Initial_num_of_packts_rx = Final_num_of_packts_rx;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Scale the rate of transfer to no of blinks. */
|
2011-12-07 10:25:10 -07:00
|
|
|
num_of_time_tx =
|
|
|
|
ScaleRateofTransfer((ULONG)rate_of_transfer_tx);
|
|
|
|
num_of_time_rx =
|
|
|
|
ScaleRateofTransfer((ULONG)rate_of_transfer_rx);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
* Procedure: ValidateDSDParamsChecksum
|
|
|
|
*
|
|
|
|
* Description: Reads DSD Params and validates checkusm.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* Adapter - Pointer to Adapter structure.
|
|
|
|
* ulParamOffset - Start offset of the DSD parameter to be read and
|
|
|
|
* validated.
|
|
|
|
* usParamLen - Length of the DSD Parameter.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* <OSAL_STATUS_CODE>
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
*/
|
2012-05-26 10:05:12 -06:00
|
|
|
static INT ValidateDSDParamsChecksum(struct bcm_mini_adapter *Adapter, ULONG ulParamOffset,
|
2011-12-07 10:25:10 -07:00
|
|
|
USHORT usParamLen)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
|
|
|
INT Status = STATUS_SUCCESS;
|
2011-12-07 10:25:07 -07:00
|
|
|
PUCHAR puBuffer = NULL;
|
2011-12-07 10:25:06 -07:00
|
|
|
USHORT usChksmOrg = 0;
|
2010-09-08 15:46:36 -06:00
|
|
|
USHORT usChecksumCalculated = 0;
|
|
|
|
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
|
|
|
|
"LED Thread:ValidateDSDParamsChecksum: 0x%lx 0x%X",
|
|
|
|
ulParamOffset, usParamLen);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2010-11-01 07:35:21 -06:00
|
|
|
puBuffer = kmalloc(usParamLen, GFP_KERNEL);
|
2011-12-07 10:25:09 -07:00
|
|
|
if (!puBuffer) {
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL,
|
|
|
|
"LED Thread: ValidateDSDParamsChecksum Allocation failed");
|
2010-09-08 15:46:36 -06:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Read the DSD data from the parameter offset. */
|
2011-12-07 10:25:10 -07:00
|
|
|
if (STATUS_SUCCESS != BeceemNVMRead(Adapter, (PUINT)puBuffer,
|
|
|
|
ulParamOffset, usParamLen)) {
|
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL,
|
|
|
|
"LED Thread: ValidateDSDParamsChecksum BeceemNVMRead failed");
|
2011-12-07 10:25:06 -07:00
|
|
|
Status = STATUS_IMAGE_CHECKSUM_MISMATCH;
|
2010-09-08 15:46:36 -06:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Calculate the checksum of the data read from the DSD parameter. */
|
2011-12-07 10:25:06 -07:00
|
|
|
usChecksumCalculated = CFG_CalculateChecksum(puBuffer, usParamLen);
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
|
|
|
|
"LED Thread: usCheckSumCalculated = 0x%x\n",
|
|
|
|
usChecksumCalculated);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* End of the DSD parameter will have a TWO bytes checksum stored in it.
|
|
|
|
* Read it and compare with the calculated Checksum.
|
|
|
|
*/
|
2011-12-07 10:25:10 -07:00
|
|
|
if (STATUS_SUCCESS != BeceemNVMRead(Adapter, (PUINT)&usChksmOrg,
|
|
|
|
ulParamOffset+usParamLen, 2)) {
|
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL,
|
|
|
|
"LED Thread: ValidateDSDParamsChecksum BeceemNVMRead failed");
|
2011-12-07 10:25:06 -07:00
|
|
|
Status = STATUS_IMAGE_CHECKSUM_MISMATCH;
|
2010-09-08 15:46:36 -06:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
usChksmOrg = ntohs(usChksmOrg);
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
|
|
|
|
"LED Thread: usChksmOrg = 0x%x", usChksmOrg);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* Compare the checksum calculated with the checksum read
|
|
|
|
* from DSD section
|
|
|
|
*/
|
2011-12-07 10:25:09 -07:00
|
|
|
if (usChecksumCalculated ^ usChksmOrg) {
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL,
|
|
|
|
"LED Thread: ValidateDSDParamsChecksum: Checksums don't match");
|
2010-09-08 15:46:36 -06:00
|
|
|
Status = STATUS_IMAGE_CHECKSUM_MISMATCH;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2010-11-01 07:35:21 -06:00
|
|
|
kfree(puBuffer);
|
2010-09-08 15:46:36 -06:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
* Procedure: ValidateHWParmStructure
|
|
|
|
*
|
|
|
|
* Description: Validates HW Parameters.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* Adapter - Pointer to Adapter structure.
|
|
|
|
* ulHwParamOffset - Start offset of the HW parameter Section to be read
|
|
|
|
* and validated.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* <OSAL_STATUS_CODE>
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
*/
|
2012-05-26 10:05:12 -06:00
|
|
|
static INT ValidateHWParmStructure(struct bcm_mini_adapter *Adapter, ULONG ulHwParamOffset)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
|
|
|
|
2011-12-07 10:25:06 -07:00
|
|
|
INT Status = STATUS_SUCCESS;
|
2010-09-08 15:46:36 -06:00
|
|
|
USHORT HwParamLen = 0;
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* Add DSD start offset to the hwParamOffset to get
|
|
|
|
* the actual address.
|
|
|
|
*/
|
2010-09-08 15:46:36 -06:00
|
|
|
ulHwParamOffset += DSD_START_OFFSET;
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Read the Length of HW_PARAM structure */
|
2011-12-07 10:25:06 -07:00
|
|
|
BeceemNVMRead(Adapter, (PUINT)&HwParamLen, ulHwParamOffset, 2);
|
2010-09-08 15:46:36 -06:00
|
|
|
HwParamLen = ntohs(HwParamLen);
|
2011-12-07 10:25:06 -07:00
|
|
|
if (0 == HwParamLen || HwParamLen > Adapter->uiNVMDSDSize)
|
2010-09-08 15:46:36 -06:00
|
|
|
return STATUS_IMAGE_CHECKSUM_MISMATCH;
|
|
|
|
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
|
|
|
|
"LED Thread:HwParamLen = 0x%x", HwParamLen);
|
|
|
|
Status = ValidateDSDParamsChecksum(Adapter, ulHwParamOffset,
|
|
|
|
HwParamLen);
|
2010-09-08 15:46:36 -06:00
|
|
|
return Status;
|
|
|
|
} /* ValidateHWParmStructure() */
|
|
|
|
|
2012-05-26 10:05:12 -06:00
|
|
|
static int ReadLEDInformationFromEEPROM(struct bcm_mini_adapter *Adapter,
|
2011-12-07 10:25:10 -07:00
|
|
|
UCHAR GPIO_Array[])
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
|
|
|
int Status = STATUS_SUCCESS;
|
|
|
|
|
2011-12-07 10:25:06 -07:00
|
|
|
ULONG dwReadValue = 0;
|
|
|
|
USHORT usHwParamData = 0;
|
|
|
|
USHORT usEEPROMVersion = 0;
|
|
|
|
UCHAR ucIndex = 0;
|
|
|
|
UCHAR ucGPIOInfo[32] = {0};
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:10 -07:00
|
|
|
BeceemNVMRead(Adapter, (PUINT)&usEEPROMVersion,
|
|
|
|
EEPROM_VERSION_OFFSET, 2);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
|
|
|
|
"usEEPROMVersion: Minor:0x%X Major:0x%x",
|
|
|
|
usEEPROMVersion&0xFF, ((usEEPROMVersion>>8)&0xFF));
|
2010-09-08 15:46:36 -06:00
|
|
|
|
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
if (((usEEPROMVersion>>8)&0xFF) < EEPROM_MAP5_MAJORVERSION) {
|
2011-12-07 10:25:10 -07:00
|
|
|
BeceemNVMRead(Adapter, (PUINT)&usHwParamData,
|
|
|
|
EEPROM_HW_PARAM_POINTER_ADDRESS, 2);
|
2010-09-08 15:46:36 -06:00
|
|
|
usHwParamData = ntohs(usHwParamData);
|
|
|
|
dwReadValue = usHwParamData;
|
2011-12-07 10:25:09 -07:00
|
|
|
} else {
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* Validate Compatibility section and then read HW param
|
|
|
|
* if compatibility section is valid.
|
|
|
|
*/
|
2010-09-08 15:46:36 -06:00
|
|
|
Status = ValidateDSDParamsChecksum(Adapter,
|
2011-12-07 10:25:06 -07:00
|
|
|
DSD_START_OFFSET,
|
|
|
|
COMPATIBILITY_SECTION_LENGTH_MAP5);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:06 -07:00
|
|
|
if (Status != STATUS_SUCCESS)
|
2010-09-08 15:46:36 -06:00
|
|
|
return Status;
|
2011-12-07 10:25:09 -07:00
|
|
|
|
2011-12-07 10:25:10 -07:00
|
|
|
BeceemNVMRead(Adapter, (PUINT)&dwReadValue,
|
|
|
|
EEPROM_HW_PARAM_POINTER_ADDRRES_MAP5, 4);
|
2010-09-08 15:46:36 -06:00
|
|
|
dwReadValue = ntohl(dwReadValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
|
|
|
|
"LED Thread: Start address of HW_PARAM structure = 0x%lx",
|
|
|
|
dwReadValue);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* Validate if the address read out is within the DSD.
|
|
|
|
* Adapter->uiNVMDSDSize gives whole DSD size inclusive of Autoinit.
|
|
|
|
* lower limit should be above DSD_START_OFFSET and
|
|
|
|
* upper limit should be below (Adapter->uiNVMDSDSize-DSD_START_OFFSET)
|
|
|
|
*/
|
2011-12-07 10:25:06 -07:00
|
|
|
if (dwReadValue < DSD_START_OFFSET ||
|
|
|
|
dwReadValue > (Adapter->uiNVMDSDSize-DSD_START_OFFSET))
|
2010-09-08 15:46:36 -06:00
|
|
|
return STATUS_IMAGE_CHECKSUM_MISMATCH;
|
|
|
|
|
|
|
|
Status = ValidateHWParmStructure(Adapter, dwReadValue);
|
2011-12-07 10:25:09 -07:00
|
|
|
if (Status)
|
2010-09-08 15:46:36 -06:00
|
|
|
return Status;
|
|
|
|
|
|
|
|
/*
|
2011-12-07 10:25:08 -07:00
|
|
|
* Add DSD_START_OFFSET to the offset read from the EEPROM.
|
|
|
|
* This will give the actual start HW Parameters start address.
|
|
|
|
* To read GPIO section, add GPIO offset further.
|
|
|
|
*/
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
dwReadValue +=
|
|
|
|
DSD_START_OFFSET; /* = start address of hw param section. */
|
|
|
|
dwReadValue += GPIO_SECTION_START_OFFSET;
|
|
|
|
/* = GPIO start offset within HW Param section. */
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* Read the GPIO values for 32 GPIOs from EEPROM and map the function
|
2011-12-07 10:25:06 -07:00
|
|
|
* number to GPIO pin number to GPIO_Array
|
|
|
|
*/
|
|
|
|
BeceemNVMRead(Adapter, (UINT *)ucGPIOInfo, dwReadValue, 32);
|
2011-12-07 10:25:09 -07:00
|
|
|
for (ucIndex = 0; ucIndex < 32; ucIndex++) {
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
switch (ucGPIOInfo[ucIndex]) {
|
2011-12-07 10:25:07 -07:00
|
|
|
case RED_LED:
|
|
|
|
GPIO_Array[RED_LED] = ucIndex;
|
|
|
|
Adapter->gpioBitMap |= (1 << ucIndex);
|
|
|
|
break;
|
|
|
|
case BLUE_LED:
|
|
|
|
GPIO_Array[BLUE_LED] = ucIndex;
|
|
|
|
Adapter->gpioBitMap |= (1 << ucIndex);
|
|
|
|
break;
|
|
|
|
case YELLOW_LED:
|
|
|
|
GPIO_Array[YELLOW_LED] = ucIndex;
|
|
|
|
Adapter->gpioBitMap |= (1 << ucIndex);
|
|
|
|
break;
|
|
|
|
case GREEN_LED:
|
|
|
|
GPIO_Array[GREEN_LED] = ucIndex;
|
|
|
|
Adapter->gpioBitMap |= (1 << ucIndex);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
2011-12-07 10:25:07 -07:00
|
|
|
|
|
|
|
}
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
|
|
|
|
"GPIO's bit map correspond to LED :0x%X", Adapter->gpioBitMap);
|
2011-12-07 10:25:06 -07:00
|
|
|
return Status;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-26 10:05:12 -06:00
|
|
|
static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter,
|
2011-12-07 10:25:10 -07:00
|
|
|
BOOLEAN *bEnableThread)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
|
|
|
int Status = STATUS_SUCCESS;
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Array to store GPIO numbers from EEPROM */
|
|
|
|
UCHAR GPIO_Array[NUM_OF_LEDS+1];
|
2010-09-08 15:46:36 -06:00
|
|
|
UINT uiIndex = 0;
|
|
|
|
UINT uiNum_of_LED_Type = 0;
|
|
|
|
PUCHAR puCFGData = NULL;
|
|
|
|
UCHAR bData = 0;
|
|
|
|
memset(GPIO_Array, DISABLE_GPIO_NUM, NUM_OF_LEDS+1);
|
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
if (!Adapter->pstargetparams || IS_ERR(Adapter->pstargetparams)) {
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL, "Target Params not Avail.\n");
|
2010-09-08 15:46:36 -06:00
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Populate GPIO_Array with GPIO numbers for LED functions */
|
|
|
|
/* Read the GPIO numbers from EEPROM */
|
2010-09-08 15:46:36 -06:00
|
|
|
Status = ReadLEDInformationFromEEPROM(Adapter, GPIO_Array);
|
2011-12-07 10:25:09 -07:00
|
|
|
if (Status == STATUS_IMAGE_CHECKSUM_MISMATCH) {
|
2010-09-08 15:46:36 -06:00
|
|
|
*bEnableThread = FALSE;
|
|
|
|
return STATUS_SUCCESS;
|
2011-12-07 10:25:09 -07:00
|
|
|
} else if (Status) {
|
2010-09-08 15:46:36 -06:00
|
|
|
*bEnableThread = FALSE;
|
|
|
|
return Status;
|
|
|
|
}
|
2011-12-07 10:25:08 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CONFIG file read successfully. Deallocate the memory of
|
|
|
|
* uiFileNameBufferSize
|
|
|
|
*/
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
|
|
|
|
"LED Thread: Config file read successfully\n");
|
2010-09-08 15:46:36 -06:00
|
|
|
puCFGData = (PUCHAR) &Adapter->pstargetparams->HostDrvrConfig1;
|
|
|
|
|
|
|
|
/*
|
2011-12-07 10:25:06 -07:00
|
|
|
* Offset for HostDrvConfig1, HostDrvConfig2, HostDrvConfig3 which
|
|
|
|
* will have the information of LED type, LED on state for different
|
|
|
|
* driver state and LED blink state.
|
|
|
|
*/
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
|
2010-09-08 15:46:36 -06:00
|
|
|
bData = *puCFGData;
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* Check Bit 8 for polarity. If it is set,
|
|
|
|
* polarity is reverse polarity
|
|
|
|
*/
|
2011-12-07 10:25:09 -07:00
|
|
|
if (bData & 0x80) {
|
2010-09-08 15:46:36 -06:00
|
|
|
Adapter->LEDInfo.LEDState[uiIndex].BitPolarity = 0;
|
2011-12-07 10:25:08 -07:00
|
|
|
/* unset the bit 8 */
|
2010-09-08 15:46:36 -06:00
|
|
|
bData = bData & 0x7f;
|
|
|
|
}
|
|
|
|
|
|
|
|
Adapter->LEDInfo.LEDState[uiIndex].LED_Type = bData;
|
2011-12-07 10:25:06 -07:00
|
|
|
if (bData <= NUM_OF_LEDS)
|
2011-12-07 10:25:10 -07:00
|
|
|
Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num =
|
|
|
|
GPIO_Array[bData];
|
2010-09-08 15:46:36 -06:00
|
|
|
else
|
2011-12-07 10:25:10 -07:00
|
|
|
Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num =
|
|
|
|
DISABLE_GPIO_NUM;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
|
|
|
puCFGData++;
|
|
|
|
bData = *puCFGData;
|
|
|
|
Adapter->LEDInfo.LEDState[uiIndex].LED_On_State = bData;
|
|
|
|
puCFGData++;
|
|
|
|
bData = *puCFGData;
|
2011-12-07 10:25:06 -07:00
|
|
|
Adapter->LEDInfo.LEDState[uiIndex].LED_Blink_State = bData;
|
2010-09-08 15:46:36 -06:00
|
|
|
puCFGData++;
|
|
|
|
}
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* Check if all the LED settings are disabled. If it is disabled,
|
|
|
|
* dont launch the LED control thread.
|
|
|
|
*/
|
2011-12-07 10:25:09 -07:00
|
|
|
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
|
2011-12-07 10:25:06 -07:00
|
|
|
if ((Adapter->LEDInfo.LEDState[uiIndex].LED_Type == DISABLE_GPIO_NUM) ||
|
|
|
|
(Adapter->LEDInfo.LEDState[uiIndex].LED_Type == 0x7f) ||
|
2010-09-08 15:46:36 -06:00
|
|
|
(Adapter->LEDInfo.LEDState[uiIndex].LED_Type == 0))
|
|
|
|
uiNum_of_LED_Type++;
|
|
|
|
}
|
2011-12-07 10:25:06 -07:00
|
|
|
if (uiNum_of_LED_Type >= NUM_OF_LEDS)
|
2010-09-08 15:46:36 -06:00
|
|
|
*bEnableThread = FALSE;
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
* Procedure: LedGpioInit
|
|
|
|
*
|
|
|
|
* Description: Initializes LED GPIOs. Makes the LED GPIOs to OUTPUT mode
|
|
|
|
* and make the initial state to be OFF.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* Adapter - Pointer to MINI_ADAPTER structure.
|
|
|
|
*
|
|
|
|
* Returns: VOID
|
|
|
|
*
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
*/
|
2012-05-26 10:05:12 -06:00
|
|
|
static VOID LedGpioInit(struct bcm_mini_adapter *Adapter)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
|
|
|
UINT uiResetValue = 0;
|
|
|
|
UINT uiIndex = 0;
|
|
|
|
|
|
|
|
/* Set all LED GPIO Mode to output mode */
|
2011-12-07 10:25:10 -07:00
|
|
|
if (rdmalt(Adapter, GPIO_MODE_REGISTER, &uiResetValue,
|
|
|
|
sizeof(uiResetValue)) < 0)
|
|
|
|
BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL, "LED Thread: RDM Failed\n");
|
2011-12-07 10:25:09 -07:00
|
|
|
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
|
2011-12-07 10:25:10 -07:00
|
|
|
if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num !=
|
|
|
|
DISABLE_GPIO_NUM)
|
2010-09-08 15:46:36 -06:00
|
|
|
uiResetValue |= (1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num);
|
2011-12-07 10:25:10 -07:00
|
|
|
TURN_OFF_LED(1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num,
|
|
|
|
uiIndex);
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
2011-12-07 10:25:10 -07:00
|
|
|
if (wrmalt(Adapter, GPIO_MODE_REGISTER, &uiResetValue,
|
|
|
|
sizeof(uiResetValue)) < 0)
|
|
|
|
BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL, "LED Thread: WRM Failed\n");
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:06 -07:00
|
|
|
Adapter->LEDInfo.bIdle_led_off = FALSE;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2012-05-26 10:05:12 -06:00
|
|
|
static INT BcmGetGPIOPinInfo(struct bcm_mini_adapter *Adapter, UCHAR *GPIO_num_tx,
|
2011-12-07 10:25:10 -07:00
|
|
|
UCHAR *GPIO_num_rx, UCHAR *uiLedTxIndex, UCHAR *uiLedRxIndex,
|
|
|
|
LedEventInfo_t currdriverstate)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
|
|
|
UINT uiIndex = 0;
|
|
|
|
|
|
|
|
*GPIO_num_tx = DISABLE_GPIO_NUM;
|
|
|
|
*GPIO_num_rx = DISABLE_GPIO_NUM;
|
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:06 -07:00
|
|
|
if ((currdriverstate == NORMAL_OPERATION) ||
|
2011-12-07 10:25:07 -07:00
|
|
|
(currdriverstate == IDLEMODE_EXIT) ||
|
2011-12-07 10:25:09 -07:00
|
|
|
(currdriverstate == FW_DOWNLOAD)) {
|
2011-12-07 10:25:10 -07:00
|
|
|
if (Adapter->LEDInfo.LEDState[uiIndex].LED_Blink_State &
|
|
|
|
currdriverstate) {
|
|
|
|
if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num
|
|
|
|
!= DISABLE_GPIO_NUM) {
|
2011-12-07 10:25:09 -07:00
|
|
|
if (*GPIO_num_tx == DISABLE_GPIO_NUM) {
|
2010-09-08 15:46:36 -06:00
|
|
|
*GPIO_num_tx = Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num;
|
|
|
|
*uiLedTxIndex = uiIndex;
|
2011-12-07 10:25:09 -07:00
|
|
|
} else {
|
2010-09-08 15:46:36 -06:00
|
|
|
*GPIO_num_rx = Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num;
|
|
|
|
*uiLedRxIndex = uiIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-07 10:25:09 -07:00
|
|
|
} else {
|
2011-12-07 10:25:10 -07:00
|
|
|
if (Adapter->LEDInfo.LEDState[uiIndex].LED_On_State
|
|
|
|
& currdriverstate) {
|
|
|
|
if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num
|
|
|
|
!= DISABLE_GPIO_NUM) {
|
2010-09-08 15:46:36 -06:00
|
|
|
*GPIO_num_tx = Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num;
|
|
|
|
*uiLedTxIndex = uiIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-07 10:25:06 -07:00
|
|
|
return STATUS_SUCCESS;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
2012-05-26 10:05:12 -06:00
|
|
|
static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
|
|
|
UINT uiIndex = 0;
|
|
|
|
UCHAR GPIO_num = 0;
|
2011-12-07 10:25:06 -07:00
|
|
|
UCHAR uiLedIndex = 0;
|
2010-09-08 15:46:36 -06:00
|
|
|
UINT uiResetValue = 0;
|
|
|
|
LedEventInfo_t currdriverstate = 0;
|
|
|
|
ulong timeout = 0;
|
|
|
|
|
|
|
|
INT Status = 0;
|
|
|
|
|
2011-12-07 10:25:06 -07:00
|
|
|
UCHAR dummyGPIONum = 0;
|
|
|
|
UCHAR dummyIndex = 0;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/* currdriverstate = Adapter->DriverState; */
|
2010-09-08 15:46:36 -06:00
|
|
|
Adapter->LEDInfo.bIdleMode_tx_from_host = FALSE;
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* Wait till event is triggered
|
|
|
|
*
|
|
|
|
* wait_event(Adapter->LEDInfo.notify_led_event,
|
|
|
|
* currdriverstate!= Adapter->DriverState);
|
|
|
|
*/
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:06 -07:00
|
|
|
GPIO_num = DISABLE_GPIO_NUM;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
while (TRUE) {
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Wait till event is triggered */
|
2011-12-07 10:25:06 -07:00
|
|
|
if ((GPIO_num == DISABLE_GPIO_NUM)
|
2010-09-08 15:46:36 -06:00
|
|
|
||
|
2011-12-07 10:25:07 -07:00
|
|
|
((currdriverstate != FW_DOWNLOAD) &&
|
|
|
|
(currdriverstate != NORMAL_OPERATION) &&
|
|
|
|
(currdriverstate != LOWPOWER_MODE_ENTER))
|
2011-12-07 10:25:06 -07:00
|
|
|
||
|
2011-12-07 10:25:07 -07:00
|
|
|
(currdriverstate == LED_THREAD_INACTIVE))
|
2011-12-07 10:25:10 -07:00
|
|
|
Status = wait_event_interruptible(
|
|
|
|
Adapter->LEDInfo.notify_led_event,
|
|
|
|
currdriverstate != Adapter->DriverState
|
|
|
|
|| kthread_should_stop());
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
if (kthread_should_stop() || Adapter->device_removed) {
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL,
|
|
|
|
"Led thread got signal to exit..hence exiting");
|
|
|
|
Adapter->LEDInfo.led_thread_running =
|
|
|
|
BCM_LED_THREAD_DISABLED;
|
2011-12-07 10:25:06 -07:00
|
|
|
TURN_OFF_LED(1 << GPIO_num, uiLedIndex);
|
2011-12-07 10:25:08 -07:00
|
|
|
return; /* STATUS_FAILURE; */
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2011-12-07 10:25:06 -07:00
|
|
|
if (GPIO_num != DISABLE_GPIO_NUM)
|
|
|
|
TURN_OFF_LED(1 << GPIO_num, uiLedIndex);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
if (Adapter->LEDInfo.bLedInitDone == FALSE) {
|
2010-09-08 15:46:36 -06:00
|
|
|
LedGpioInit(Adapter);
|
|
|
|
Adapter->LEDInfo.bLedInitDone = TRUE;
|
|
|
|
}
|
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
switch (Adapter->DriverState) {
|
2011-12-07 10:25:07 -07:00
|
|
|
case DRIVER_INIT:
|
2011-12-07 10:25:08 -07:00
|
|
|
currdriverstate = DRIVER_INIT;
|
|
|
|
/* Adapter->DriverState; */
|
2011-12-07 10:25:10 -07:00
|
|
|
BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum,
|
|
|
|
&uiLedIndex, &dummyIndex, currdriverstate);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:07 -07:00
|
|
|
if (GPIO_num != DISABLE_GPIO_NUM)
|
|
|
|
TURN_ON_LED(1 << GPIO_num, uiLedIndex);
|
2011-12-07 10:25:09 -07:00
|
|
|
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
2011-12-07 10:25:07 -07:00
|
|
|
case FW_DOWNLOAD:
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
|
|
|
|
* LED_DUMP_INFO, DBG_LVL_ALL,
|
|
|
|
* "LED Thread: FW_DN_DONE called\n");
|
|
|
|
*/
|
2011-12-07 10:25:07 -07:00
|
|
|
currdriverstate = FW_DOWNLOAD;
|
2011-12-07 10:25:10 -07:00
|
|
|
BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum,
|
|
|
|
&uiLedIndex, &dummyIndex, currdriverstate);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
if (GPIO_num != DISABLE_GPIO_NUM) {
|
2011-12-07 10:25:07 -07:00
|
|
|
timeout = 50;
|
2011-12-07 10:25:10 -07:00
|
|
|
LED_Blink(Adapter, 1 << GPIO_num, uiLedIndex,
|
|
|
|
timeout, -1, currdriverstate);
|
2011-12-07 10:25:07 -07:00
|
|
|
}
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
2011-12-07 10:25:07 -07:00
|
|
|
case FW_DOWNLOAD_DONE:
|
|
|
|
currdriverstate = FW_DOWNLOAD_DONE;
|
2011-12-07 10:25:10 -07:00
|
|
|
BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum,
|
|
|
|
&uiLedIndex, &dummyIndex, currdriverstate);
|
2011-12-07 10:25:07 -07:00
|
|
|
if (GPIO_num != DISABLE_GPIO_NUM)
|
|
|
|
TURN_ON_LED(1 << GPIO_num, uiLedIndex);
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
|
|
|
|
2011-12-07 10:25:07 -07:00
|
|
|
case SHUTDOWN_EXIT:
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* no break, continue to NO_NETWORK_ENTRY
|
|
|
|
* state as well.
|
|
|
|
*/
|
2011-12-07 10:25:07 -07:00
|
|
|
case NO_NETWORK_ENTRY:
|
|
|
|
currdriverstate = NO_NETWORK_ENTRY;
|
2011-12-07 10:25:10 -07:00
|
|
|
BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum,
|
|
|
|
&uiLedIndex, &dummyGPIONum, currdriverstate);
|
2011-12-07 10:25:07 -07:00
|
|
|
if (GPIO_num != DISABLE_GPIO_NUM)
|
|
|
|
TURN_ON_LED(1 << GPIO_num, uiLedIndex);
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
2011-12-07 10:25:07 -07:00
|
|
|
case NORMAL_OPERATION:
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
2011-12-07 10:25:09 -07:00
|
|
|
UCHAR GPIO_num_tx = DISABLE_GPIO_NUM;
|
|
|
|
UCHAR GPIO_num_rx = DISABLE_GPIO_NUM;
|
|
|
|
UCHAR uiLEDTx = 0;
|
|
|
|
UCHAR uiLEDRx = 0;
|
|
|
|
currdriverstate = NORMAL_OPERATION;
|
|
|
|
Adapter->LEDInfo.bIdle_led_off = FALSE;
|
|
|
|
|
2011-12-07 10:25:10 -07:00
|
|
|
BcmGetGPIOPinInfo(Adapter, &GPIO_num_tx,
|
|
|
|
&GPIO_num_rx, &uiLEDTx, &uiLEDRx,
|
|
|
|
currdriverstate);
|
|
|
|
if ((GPIO_num_tx == DISABLE_GPIO_NUM) &&
|
|
|
|
(GPIO_num_rx ==
|
|
|
|
DISABLE_GPIO_NUM)) {
|
2011-12-07 10:25:09 -07:00
|
|
|
GPIO_num = DISABLE_GPIO_NUM;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If single LED is selected, use same
|
|
|
|
* for both Tx and Rx
|
|
|
|
*/
|
|
|
|
if (GPIO_num_tx == DISABLE_GPIO_NUM) {
|
|
|
|
GPIO_num_tx = GPIO_num_rx;
|
|
|
|
uiLEDTx = uiLEDRx;
|
2011-12-07 10:25:10 -07:00
|
|
|
} else if (GPIO_num_rx ==
|
|
|
|
DISABLE_GPIO_NUM) {
|
2011-12-07 10:25:09 -07:00
|
|
|
GPIO_num_rx = GPIO_num_tx;
|
|
|
|
uiLEDRx = uiLEDTx;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Blink the LED in proportionate
|
|
|
|
* to Tx and Rx transmissions.
|
|
|
|
*/
|
2011-12-07 10:25:10 -07:00
|
|
|
LED_Proportional_Blink(Adapter,
|
|
|
|
GPIO_num_tx, uiLEDTx,
|
|
|
|
GPIO_num_rx, uiLEDRx,
|
|
|
|
currdriverstate);
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-12-07 10:25:07 -07:00
|
|
|
case LOWPOWER_MODE_ENTER:
|
|
|
|
currdriverstate = LOWPOWER_MODE_ENTER;
|
2011-12-07 10:25:10 -07:00
|
|
|
if (DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING ==
|
|
|
|
Adapter->ulPowerSaveMode) {
|
2011-12-07 10:25:07 -07:00
|
|
|
/* Turn OFF all the LED */
|
|
|
|
uiResetValue = 0;
|
2011-12-07 10:25:09 -07:00
|
|
|
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
|
2011-12-07 10:25:07 -07:00
|
|
|
if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num != DISABLE_GPIO_NUM)
|
|
|
|
TURN_OFF_LED((1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num), uiIndex);
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
2011-12-07 10:25:07 -07:00
|
|
|
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
2011-12-07 10:25:07 -07:00
|
|
|
/* Turn off LED And WAKE-UP for Sendinf IDLE mode ACK */
|
|
|
|
Adapter->LEDInfo.bLedInitDone = FALSE;
|
|
|
|
Adapter->LEDInfo.bIdle_led_off = TRUE;
|
|
|
|
wake_up(&Adapter->LEDInfo.idleModeSyncEvent);
|
|
|
|
GPIO_num = DISABLE_GPIO_NUM;
|
|
|
|
break;
|
|
|
|
case IDLEMODE_CONTINUE:
|
|
|
|
currdriverstate = IDLEMODE_CONTINUE;
|
|
|
|
GPIO_num = DISABLE_GPIO_NUM;
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
2011-12-07 10:25:07 -07:00
|
|
|
case IDLEMODE_EXIT:
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
2011-12-07 10:25:07 -07:00
|
|
|
case DRIVER_HALT:
|
|
|
|
currdriverstate = DRIVER_HALT;
|
|
|
|
GPIO_num = DISABLE_GPIO_NUM;
|
2011-12-07 10:25:09 -07:00
|
|
|
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
|
2011-12-07 10:25:10 -07:00
|
|
|
if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num
|
|
|
|
!= DISABLE_GPIO_NUM)
|
2011-12-07 10:25:07 -07:00
|
|
|
TURN_OFF_LED((1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num), uiIndex);
|
|
|
|
}
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Adapter->DriverState = DRIVER_INIT; */
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
2011-12-07 10:25:07 -07:00
|
|
|
case LED_THREAD_INACTIVE:
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL, "InActivating LED thread...");
|
2011-12-07 10:25:07 -07:00
|
|
|
currdriverstate = LED_THREAD_INACTIVE;
|
2011-12-07 10:25:10 -07:00
|
|
|
Adapter->LEDInfo.led_thread_running =
|
|
|
|
BCM_LED_THREAD_RUNNING_INACTIVELY;
|
2011-12-07 10:25:07 -07:00
|
|
|
Adapter->LEDInfo.bLedInitDone = FALSE;
|
2011-12-07 10:25:08 -07:00
|
|
|
/* disable ALL LED */
|
2011-12-07 10:25:09 -07:00
|
|
|
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
|
2011-12-07 10:25:10 -07:00
|
|
|
if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num
|
|
|
|
!= DISABLE_GPIO_NUM)
|
2011-12-07 10:25:07 -07:00
|
|
|
TURN_OFF_LED((1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num), uiIndex);
|
|
|
|
}
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
2011-12-07 10:25:07 -07:00
|
|
|
case LED_THREAD_ACTIVE:
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL, "Activating LED thread again...");
|
2011-12-07 10:25:07 -07:00
|
|
|
if (Adapter->LinkUpStatus == FALSE)
|
|
|
|
Adapter->DriverState = NO_NETWORK_ENTRY;
|
|
|
|
else
|
|
|
|
Adapter->DriverState = NORMAL_OPERATION;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:10 -07:00
|
|
|
Adapter->LEDInfo.led_thread_running =
|
|
|
|
BCM_LED_THREAD_RUNNING_ACTIVELY;
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
2011-12-07 10:25:08 -07:00
|
|
|
/* return; */
|
2011-12-07 10:25:07 -07:00
|
|
|
default:
|
|
|
|
break;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_DISABLED;
|
|
|
|
}
|
|
|
|
|
2012-05-26 10:05:12 -06:00
|
|
|
int InitLedSettings(struct bcm_mini_adapter *Adapter)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
|
|
|
int Status = STATUS_SUCCESS;
|
|
|
|
BOOLEAN bEnableThread = TRUE;
|
|
|
|
UCHAR uiIndex = 0;
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* Initially set BitPolarity to normal polarity. The bit 8 of LED type
|
|
|
|
* is used to change the polarity of the LED.
|
|
|
|
*/
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++)
|
2010-09-08 15:46:36 -06:00
|
|
|
Adapter->LEDInfo.LEDState[uiIndex].BitPolarity = 1;
|
|
|
|
|
2011-12-07 10:25:08 -07:00
|
|
|
/*
|
|
|
|
* Read the LED settings of CONFIG file and map it
|
|
|
|
* to GPIO numbers in EEPROM
|
|
|
|
*/
|
2010-09-08 15:46:36 -06:00
|
|
|
Status = ReadConfigFileStructure(Adapter, &bEnableThread);
|
2011-12-07 10:25:09 -07:00
|
|
|
if (STATUS_SUCCESS != Status) {
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL,
|
|
|
|
"LED Thread: FAILED in ReadConfigFileStructure\n");
|
2010-09-08 15:46:36 -06:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
if (Adapter->LEDInfo.led_thread_running) {
|
|
|
|
if (bEnableThread) {
|
2010-09-08 15:46:36 -06:00
|
|
|
;
|
2011-12-07 10:25:09 -07:00
|
|
|
} else {
|
2010-09-08 15:46:36 -06:00
|
|
|
Adapter->DriverState = DRIVER_HALT;
|
|
|
|
wake_up(&Adapter->LEDInfo.notify_led_event);
|
2011-12-07 10:25:10 -07:00
|
|
|
Adapter->LEDInfo.led_thread_running =
|
|
|
|
BCM_LED_THREAD_DISABLED;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2011-12-07 10:25:09 -07:00
|
|
|
} else if (bEnableThread) {
|
2011-12-07 10:25:08 -07:00
|
|
|
/* Create secondary thread to handle the LEDs */
|
2010-09-08 15:46:36 -06:00
|
|
|
init_waitqueue_head(&Adapter->LEDInfo.notify_led_event);
|
|
|
|
init_waitqueue_head(&Adapter->LEDInfo.idleModeSyncEvent);
|
2011-12-07 10:25:10 -07:00
|
|
|
Adapter->LEDInfo.led_thread_running =
|
|
|
|
BCM_LED_THREAD_RUNNING_ACTIVELY;
|
2011-12-07 10:25:06 -07:00
|
|
|
Adapter->LEDInfo.bIdle_led_off = FALSE;
|
2011-12-07 10:25:10 -07:00
|
|
|
Adapter->LEDInfo.led_cntrl_threadid =
|
|
|
|
kthread_run((int (*)(void *)) LEDControlThread,
|
|
|
|
Adapter, "led_control_thread");
|
2011-12-07 10:25:09 -07:00
|
|
|
if (IS_ERR(Adapter->LEDInfo.led_cntrl_threadid)) {
|
2011-12-07 10:25:10 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
|
|
|
|
DBG_LVL_ALL,
|
|
|
|
"Not able to spawn Kernel Thread\n");
|
|
|
|
Adapter->LEDInfo.led_thread_running =
|
|
|
|
BCM_LED_THREAD_DISABLED;
|
2011-12-07 10:25:07 -07:00
|
|
|
return PTR_ERR(Adapter->LEDInfo.led_cntrl_threadid);
|
|
|
|
}
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
return Status;
|
|
|
|
}
|