summaryrefslogtreecommitdiff
path: root/drivers/staging/bcm/led_control.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/bcm/led_control.c')
-rw-r--r--drivers/staging/bcm/led_control.c668
1 files changed, 352 insertions, 316 deletions
diff --git a/drivers/staging/bcm/led_control.c b/drivers/staging/bcm/led_control.c
index eee4f4795a71..074fc39ed678 100644
--- a/drivers/staging/bcm/led_control.c
+++ b/drivers/staging/bcm/led_control.c
@@ -6,6 +6,7 @@
static B_UINT16 CFG_CalculateChecksum(B_UINT8 *pu8Buffer, B_UINT32 u32Size)
{
B_UINT16 u16CheckSum = 0;
+
while (u32Size--) {
u16CheckSum += (B_UINT8)~(*pu8Buffer);
pu8Buffer++;
@@ -16,6 +17,7 @@ static B_UINT16 CFG_CalculateChecksum(B_UINT8 *pu8Buffer, B_UINT32 u32Size)
bool IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios)
{
INT Status;
+
Status = (Adapter->gpioBitMap & gpios) ^ gpios;
if (Status)
return false;
@@ -23,8 +25,12 @@ bool IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios)
return TRUE;
}
-static INT LED_Blink(struct bcm_mini_adapter *Adapter, UINT GPIO_Num, UCHAR uiLedIndex,
- ULONG timeout, INT num_of_time, enum bcm_led_events currdriverstate)
+static INT LED_Blink(struct bcm_mini_adapter *Adapter,
+ UINT GPIO_Num,
+ UCHAR uiLedIndex,
+ ULONG timeout,
+ INT num_of_time,
+ enum bcm_led_events currdriverstate)
{
int Status = STATUS_SUCCESS;
bool bInfinite = false;
@@ -36,7 +42,7 @@ static INT LED_Blink(struct bcm_mini_adapter *Adapter, UINT GPIO_Num, UCHAR uiLe
}
while (num_of_time) {
if (currdriverstate == Adapter->DriverState)
- TURN_ON_LED(GPIO_Num, uiLedIndex);
+ TURN_ON_LED(Adapter, GPIO_Num, uiLedIndex);
/* Wait for timeout after setting on the LED */
Status = wait_event_interruptible_timeout(
@@ -51,17 +57,17 @@ static INT LED_Blink(struct bcm_mini_adapter *Adapter, UINT GPIO_Num, UCHAR uiLe
"Led thread got signal to exit..hence exiting");
Adapter->LEDInfo.led_thread_running =
BCM_LED_THREAD_DISABLED;
- TURN_OFF_LED(GPIO_Num, uiLedIndex);
+ TURN_OFF_LED(Adapter, GPIO_Num, uiLedIndex);
Status = EVENT_SIGNALED;
break;
}
if (Status) {
- TURN_OFF_LED(GPIO_Num, uiLedIndex);
+ TURN_OFF_LED(Adapter, GPIO_Num, uiLedIndex);
Status = EVENT_SIGNALED;
break;
}
- TURN_OFF_LED(GPIO_Num, uiLedIndex);
+ TURN_OFF_LED(Adapter, GPIO_Num, uiLedIndex);
Status = wait_event_interruptible_timeout(
Adapter->LEDInfo.notify_led_event,
currdriverstate != Adapter->DriverState ||
@@ -93,11 +99,59 @@ static INT ScaleRateofTransfer(ULONG rate)
return MAX_NUM_OF_BLINKS;
}
+static INT blink_in_normal_bandwidth(struct bcm_mini_adapter *ad,
+ INT *time,
+ INT *time_tx,
+ INT *time_rx,
+ UCHAR GPIO_Num_tx,
+ UCHAR uiTxLedIndex,
+ UCHAR GPIO_Num_rx,
+ UCHAR uiRxLedIndex,
+ enum bcm_led_events currdriverstate,
+ ulong *timeout)
+{
+ /*
+ * Assign minimum number of blinks of
+ * either Tx or Rx.
+ */
+ *time = (*time_tx > *time_rx ? *time_rx : *time_tx);
+
+ if (*time > 0) {
+ /* Blink both Tx and Rx LEDs */
+ if ((LED_Blink(ad, 1 << GPIO_Num_tx, uiTxLedIndex, *timeout,
+ *time, currdriverstate) == EVENT_SIGNALED) ||
+ (LED_Blink(ad, 1 << GPIO_Num_rx, uiRxLedIndex, *timeout,
+ *time, currdriverstate) == EVENT_SIGNALED))
+ return EVENT_SIGNALED;
+ }
+
+ if (*time == *time_tx) {
+ /* Blink pending rate of Rx */
+ if (LED_Blink(ad, (1 << GPIO_Num_rx), uiRxLedIndex, *timeout,
+ *time_rx - *time,
+ currdriverstate) == EVENT_SIGNALED)
+ return EVENT_SIGNALED;
+ *time = *time_rx;
+ } else {
+ /* Blink pending rate of Tx */
+ if (LED_Blink(ad, 1 << GPIO_Num_tx, uiTxLedIndex, *timeout,
+ *time_tx - *time,
+ currdriverstate) == EVENT_SIGNALED)
+ return EVENT_SIGNALED;
+
+ *time = *time_tx;
+ }
-static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_Num_tx,
- UCHAR uiTxLedIndex, UCHAR GPIO_Num_rx, UCHAR uiRxLedIndex,
- enum bcm_led_events currdriverstate)
+ return 0;
+}
+
+static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter,
+ UCHAR GPIO_Num_tx,
+ UCHAR uiTxLedIndex,
+ UCHAR GPIO_Num_rx,
+ UCHAR uiRxLedIndex,
+ enum bcm_led_events currdriverstate)
{
/* Initial values of TX and RX packets */
ULONG64 Initial_num_of_packts_tx = 0, Initial_num_of_packts_rx = 0;
@@ -108,7 +162,6 @@ static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_N
int Status = STATUS_SUCCESS;
INT num_of_time = 0, num_of_time_tx = 0, num_of_time_rx = 0;
UINT remDelay = 0;
- bool bBlinkBothLED = TRUE;
/* UINT GPIO_num = DISABLE_GPIO_NUM; */
ulong timeout = 0;
@@ -122,73 +175,19 @@ static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_N
while ((Adapter->device_removed == false)) {
timeout = 50;
- /*
- * Blink Tx and Rx LED when both Tx and Rx is
- * in normal bandwidth
- */
- if (bBlinkBothLED) {
- /*
- * Assign minimum number of blinks of
- * either Tx or Rx.
- */
- if (num_of_time_tx > num_of_time_rx)
- num_of_time = num_of_time_rx;
- else
- num_of_time = num_of_time_tx;
- if (num_of_time > 0) {
- /* Blink both Tx and Rx LEDs */
- if (LED_Blink(Adapter, 1 << GPIO_Num_tx,
- uiTxLedIndex, timeout,
- num_of_time, currdriverstate)
- == EVENT_SIGNALED)
- return EVENT_SIGNALED;
-
- if (LED_Blink(Adapter, 1 << GPIO_Num_rx,
- uiRxLedIndex, timeout,
- num_of_time, currdriverstate)
- == EVENT_SIGNALED)
- return EVENT_SIGNALED;
- }
+ if (EVENT_SIGNALED == blink_in_normal_bandwidth(Adapter,
+ &num_of_time,
+ &num_of_time_tx,
+ &num_of_time_rx,
+ GPIO_Num_tx,
+ uiTxLedIndex,
+ GPIO_Num_rx,
+ uiRxLedIndex,
+ currdriverstate,
+ &timeout))
+ return EVENT_SIGNALED;
- if (num_of_time == num_of_time_tx) {
- /* Blink pending rate of Rx */
- if (LED_Blink(Adapter, (1 << GPIO_Num_rx),
- uiRxLedIndex, timeout,
- num_of_time_rx-num_of_time,
- currdriverstate)
- == EVENT_SIGNALED)
- return EVENT_SIGNALED;
-
- num_of_time = num_of_time_rx;
- } else {
- /* Blink pending rate of Tx */
- if (LED_Blink(Adapter, 1 << GPIO_Num_tx,
- uiTxLedIndex, timeout,
- num_of_time_tx-num_of_time,
- currdriverstate)
- == EVENT_SIGNALED)
- return EVENT_SIGNALED;
-
- num_of_time = num_of_time_tx;
- }
- } else {
- if (num_of_time == num_of_time_tx) {
- /* Blink pending rate of Rx */
- if (LED_Blink(Adapter, 1 << GPIO_Num_tx,
- uiTxLedIndex, timeout,
- num_of_time, currdriverstate)
- == EVENT_SIGNALED)
- return EVENT_SIGNALED;
- } else {
- /* Blink pending rate of Tx */
- if (LED_Blink(Adapter, 1 << GPIO_Num_rx,
- uiRxLedIndex, timeout,
- num_of_time, currdriverstate)
- == EVENT_SIGNALED)
- return EVENT_SIGNALED;
- }
- }
/*
* If Tx/Rx rate is less than maximum blinks per second,
@@ -216,8 +215,8 @@ static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_N
}
/* Turn off both Tx and Rx LEDs before next second */
- TURN_OFF_LED(1 << GPIO_Num_tx, uiTxLedIndex);
- TURN_OFF_LED(1 << GPIO_Num_rx, uiTxLedIndex);
+ TURN_OFF_LED(Adapter, 1 << GPIO_Num_tx, uiTxLedIndex);
+ TURN_OFF_LED(Adapter, 1 << GPIO_Num_rx, uiTxLedIndex);
/*
* Read the Tx & Rx packets transmission after 1 second and
@@ -261,8 +260,9 @@ static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_N
* <OSAL_STATUS_CODE>
* -----------------------------------------------------------------------------
*/
-static INT ValidateDSDParamsChecksum(struct bcm_mini_adapter *Adapter, ULONG ulParamOffset,
- USHORT usParamLen)
+static INT ValidateDSDParamsChecksum(struct bcm_mini_adapter *Adapter,
+ ULONG ulParamOffset,
+ USHORT usParamLen)
{
INT Status = STATUS_SUCCESS;
PUCHAR puBuffer = NULL;
@@ -270,24 +270,24 @@ static INT ValidateDSDParamsChecksum(struct bcm_mini_adapter *Adapter, ULONG ulP
USHORT usChecksumCalculated = 0;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
- "LED Thread:ValidateDSDParamsChecksum: 0x%lx 0x%X",
- ulParamOffset, usParamLen);
+ "LED Thread:ValidateDSDParamsChecksum: 0x%lx 0x%X",
+ ulParamOffset, usParamLen);
puBuffer = kmalloc(usParamLen, GFP_KERNEL);
if (!puBuffer) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
- DBG_LVL_ALL,
- "LED Thread: ValidateDSDParamsChecksum Allocation failed");
+ DBG_LVL_ALL,
+ "LED Thread: ValidateDSDParamsChecksum Allocation failed");
return -ENOMEM;
}
/* Read the DSD data from the parameter offset. */
if (STATUS_SUCCESS != BeceemNVMRead(Adapter, (PUINT)puBuffer,
- ulParamOffset, usParamLen)) {
+ ulParamOffset, usParamLen)) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
- DBG_LVL_ALL,
- "LED Thread: ValidateDSDParamsChecksum BeceemNVMRead failed");
+ DBG_LVL_ALL,
+ "LED Thread: ValidateDSDParamsChecksum BeceemNVMRead failed");
Status = STATUS_IMAGE_CHECKSUM_MISMATCH;
goto exit;
}
@@ -295,24 +295,24 @@ static INT ValidateDSDParamsChecksum(struct bcm_mini_adapter *Adapter, ULONG ulP
/* Calculate the checksum of the data read from the DSD parameter. */
usChecksumCalculated = CFG_CalculateChecksum(puBuffer, usParamLen);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
- "LED Thread: usCheckSumCalculated = 0x%x\n",
- usChecksumCalculated);
+ "LED Thread: usCheckSumCalculated = 0x%x\n",
+ usChecksumCalculated);
/*
* End of the DSD parameter will have a TWO bytes checksum stored in it.
* Read it and compare with the calculated Checksum.
*/
if (STATUS_SUCCESS != BeceemNVMRead(Adapter, (PUINT)&usChksmOrg,
- ulParamOffset+usParamLen, 2)) {
+ ulParamOffset+usParamLen, 2)) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
- DBG_LVL_ALL,
- "LED Thread: ValidateDSDParamsChecksum BeceemNVMRead failed");
+ DBG_LVL_ALL,
+ "LED Thread: ValidateDSDParamsChecksum BeceemNVMRead failed");
Status = STATUS_IMAGE_CHECKSUM_MISMATCH;
goto exit;
}
usChksmOrg = ntohs(usChksmOrg);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
- "LED Thread: usChksmOrg = 0x%x", usChksmOrg);
+ "LED Thread: usChksmOrg = 0x%x", usChksmOrg);
/*
* Compare the checksum calculated with the checksum read
@@ -320,8 +320,8 @@ static INT ValidateDSDParamsChecksum(struct bcm_mini_adapter *Adapter, ULONG ulP
*/
if (usChecksumCalculated ^ usChksmOrg) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
- DBG_LVL_ALL,
- "LED Thread: ValidateDSDParamsChecksum: Checksums don't match");
+ DBG_LVL_ALL,
+ "LED Thread: ValidateDSDParamsChecksum: Checksums don't match");
Status = STATUS_IMAGE_CHECKSUM_MISMATCH;
goto exit;
}
@@ -347,7 +347,8 @@ exit:
* <OSAL_STATUS_CODE>
* -----------------------------------------------------------------------------
*/
-static INT ValidateHWParmStructure(struct bcm_mini_adapter *Adapter, ULONG ulHwParamOffset)
+static INT ValidateHWParmStructure(struct bcm_mini_adapter *Adapter,
+ ULONG ulHwParamOffset)
{
INT Status = STATUS_SUCCESS;
@@ -365,9 +366,9 @@ static INT ValidateHWParmStructure(struct bcm_mini_adapter *Adapter, ULONG ulHwP
return STATUS_IMAGE_CHECKSUM_MISMATCH;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
- "LED Thread:HwParamLen = 0x%x", HwParamLen);
+ "LED Thread:HwParamLen = 0x%x", HwParamLen);
Status = ValidateDSDParamsChecksum(Adapter, ulHwParamOffset,
- HwParamLen);
+ HwParamLen);
return Status;
} /* ValidateHWParmStructure() */
@@ -383,16 +384,17 @@ static int ReadLEDInformationFromEEPROM(struct bcm_mini_adapter *Adapter,
UCHAR ucGPIOInfo[32] = {0};
BeceemNVMRead(Adapter, (PUINT)&usEEPROMVersion,
- EEPROM_VERSION_OFFSET, 2);
+ EEPROM_VERSION_OFFSET, 2);
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));
+ "usEEPROMVersion: Minor:0x%X Major:0x%x",
+ usEEPROMVersion & 0xFF,
+ ((usEEPROMVersion >> 8) & 0xFF));
if (((usEEPROMVersion>>8)&0xFF) < EEPROM_MAP5_MAJORVERSION) {
BeceemNVMRead(Adapter, (PUINT)&usHwParamData,
- EEPROM_HW_PARAM_POINTER_ADDRESS, 2);
+ EEPROM_HW_PARAM_POINTER_ADDRESS, 2);
usHwParamData = ntohs(usHwParamData);
dwReadValue = usHwParamData;
} else {
@@ -401,21 +403,21 @@ static int ReadLEDInformationFromEEPROM(struct bcm_mini_adapter *Adapter,
* if compatibility section is valid.
*/
Status = ValidateDSDParamsChecksum(Adapter,
- DSD_START_OFFSET,
- COMPATIBILITY_SECTION_LENGTH_MAP5);
+ DSD_START_OFFSET,
+ COMPATIBILITY_SECTION_LENGTH_MAP5);
if (Status != STATUS_SUCCESS)
return Status;
BeceemNVMRead(Adapter, (PUINT)&dwReadValue,
- EEPROM_HW_PARAM_POINTER_ADDRRES_MAP5, 4);
+ EEPROM_HW_PARAM_POINTER_ADDRRES_MAP5, 4);
dwReadValue = ntohl(dwReadValue);
}
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
- "LED Thread: Start address of HW_PARAM structure = 0x%lx",
- dwReadValue);
+ "LED Thread: Start address of HW_PARAM structure = 0x%lx",
+ dwReadValue);
/*
* Validate if the address read out is within the DSD.
@@ -437,8 +439,8 @@ static int ReadLEDInformationFromEEPROM(struct bcm_mini_adapter *Adapter,
* To read GPIO section, add GPIO offset further.
*/
- dwReadValue +=
- DSD_START_OFFSET; /* = start address of hw param section. */
+ dwReadValue += DSD_START_OFFSET;
+ /* = start address of hw param section. */
dwReadValue += GPIO_SECTION_START_OFFSET;
/* = GPIO start offset within HW Param section. */
@@ -472,13 +474,14 @@ static int ReadLEDInformationFromEEPROM(struct bcm_mini_adapter *Adapter,
}
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
- "GPIO's bit map correspond to LED :0x%X", Adapter->gpioBitMap);
+ "GPIO's bit map correspond to LED :0x%X",
+ Adapter->gpioBitMap);
return Status;
}
static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter,
- bool *bEnableThread)
+ bool *bEnableThread)
{
int Status = STATUS_SUCCESS;
/* Array to store GPIO numbers from EEPROM */
@@ -487,11 +490,13 @@ static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter,
UINT uiNum_of_LED_Type = 0;
PUCHAR puCFGData = NULL;
UCHAR bData = 0;
+ struct bcm_led_state_info *curr_led_state;
+
memset(GPIO_Array, DISABLE_GPIO_NUM, NUM_OF_LEDS+1);
if (!Adapter->pstargetparams || IS_ERR(Adapter->pstargetparams)) {
- BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
- DBG_LVL_ALL, "Target Params not Avail.\n");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
+ DBG_LVL_ALL, "Target Params not Avail.\n");
return -ENOENT;
}
@@ -511,7 +516,7 @@ static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter,
* uiFileNameBufferSize
*/
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
- "LED Thread: Config file read successfully\n");
+ "LED Thread: Config file read successfully\n");
puCFGData = (PUCHAR) &Adapter->pstargetparams->HostDrvrConfig1;
/*
@@ -522,31 +527,30 @@ static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter,
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
bData = *puCFGData;
+ curr_led_state = &Adapter->LEDInfo.LEDState[uiIndex];
/*
* Check Bit 8 for polarity. If it is set,
* polarity is reverse polarity
*/
if (bData & 0x80) {
- Adapter->LEDInfo.LEDState[uiIndex].BitPolarity = 0;
+ curr_led_state->BitPolarity = 0;
/* unset the bit 8 */
bData = bData & 0x7f;
}
- Adapter->LEDInfo.LEDState[uiIndex].LED_Type = bData;
+ curr_led_state->LED_Type = bData;
if (bData <= NUM_OF_LEDS)
- Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num =
- GPIO_Array[bData];
+ curr_led_state->GPIO_Num = GPIO_Array[bData];
else
- Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num =
- DISABLE_GPIO_NUM;
+ curr_led_state->GPIO_Num = DISABLE_GPIO_NUM;
puCFGData++;
bData = *puCFGData;
- Adapter->LEDInfo.LEDState[uiIndex].LED_On_State = bData;
+ curr_led_state->LED_On_State = bData;
puCFGData++;
bData = *puCFGData;
- Adapter->LEDInfo.LEDState[uiIndex].LED_Blink_State = bData;
+ curr_led_state->LED_Blink_State = bData;
puCFGData++;
}
@@ -555,9 +559,11 @@ static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter,
* dont launch the LED control thread.
*/
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
- if ((Adapter->LEDInfo.LEDState[uiIndex].LED_Type == DISABLE_GPIO_NUM) ||
- (Adapter->LEDInfo.LEDState[uiIndex].LED_Type == 0x7f) ||
- (Adapter->LEDInfo.LEDState[uiIndex].LED_Type == 0))
+ curr_led_state = &Adapter->LEDInfo.LEDState[uiIndex];
+
+ if ((curr_led_state->LED_Type == DISABLE_GPIO_NUM) ||
+ (curr_led_state->LED_Type == 0x7f) ||
+ (curr_led_state->LED_Type == 0))
uiNum_of_LED_Type++;
}
if (uiNum_of_LED_Type >= NUM_OF_LEDS)
@@ -584,67 +590,237 @@ static VOID LedGpioInit(struct bcm_mini_adapter *Adapter)
{
UINT uiResetValue = 0;
UINT uiIndex = 0;
+ struct bcm_led_state_info *curr_led_state;
/* Set all LED GPIO Mode to output mode */
if (rdmalt(Adapter, GPIO_MODE_REGISTER, &uiResetValue,
- sizeof(uiResetValue)) < 0)
+ sizeof(uiResetValue)) < 0)
BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
DBG_LVL_ALL, "LED Thread: RDM Failed\n");
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
- if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num !=
- DISABLE_GPIO_NUM)
- uiResetValue |= (1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num);
- TURN_OFF_LED(1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num,
- uiIndex);
+ curr_led_state = &Adapter->LEDInfo.LEDState[uiIndex];
+
+ if (curr_led_state->GPIO_Num != DISABLE_GPIO_NUM)
+ uiResetValue |= (1 << curr_led_state->GPIO_Num);
+
+ TURN_OFF_LED(Adapter, 1 << curr_led_state->GPIO_Num, uiIndex);
+
}
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");
+ sizeof(uiResetValue)) < 0)
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
+ DBG_LVL_ALL, "LED Thread: WRM Failed\n");
Adapter->LEDInfo.bIdle_led_off = false;
}
-static INT BcmGetGPIOPinInfo(struct bcm_mini_adapter *Adapter, UCHAR *GPIO_num_tx,
- UCHAR *GPIO_num_rx, UCHAR *uiLedTxIndex, UCHAR *uiLedRxIndex,
- enum bcm_led_events currdriverstate)
+static INT BcmGetGPIOPinInfo(struct bcm_mini_adapter *Adapter,
+ UCHAR *GPIO_num_tx,
+ UCHAR *GPIO_num_rx,
+ UCHAR *uiLedTxIndex,
+ UCHAR *uiLedRxIndex,
+ enum bcm_led_events currdriverstate)
{
UINT uiIndex = 0;
+ struct bcm_led_state_info *led_state_info;
*GPIO_num_tx = DISABLE_GPIO_NUM;
*GPIO_num_rx = DISABLE_GPIO_NUM;
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
-
- if ((currdriverstate == NORMAL_OPERATION) ||
- (currdriverstate == IDLEMODE_EXIT) ||
- (currdriverstate == FW_DOWNLOAD)) {
- if (Adapter->LEDInfo.LEDState[uiIndex].LED_Blink_State &
- currdriverstate) {
- if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num
- != DISABLE_GPIO_NUM) {
- if (*GPIO_num_tx == DISABLE_GPIO_NUM) {
- *GPIO_num_tx = Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num;
- *uiLedTxIndex = uiIndex;
- } else {
- *GPIO_num_rx = Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num;
- *uiLedRxIndex = uiIndex;
- }
- }
+ led_state_info = &Adapter->LEDInfo.LEDState[uiIndex];
+
+ if (((currdriverstate == NORMAL_OPERATION) ||
+ (currdriverstate == IDLEMODE_EXIT) ||
+ (currdriverstate == FW_DOWNLOAD)) &&
+ (led_state_info->LED_Blink_State & currdriverstate) &&
+ (led_state_info->GPIO_Num != DISABLE_GPIO_NUM)) {
+ if (*GPIO_num_tx == DISABLE_GPIO_NUM) {
+ *GPIO_num_tx = led_state_info->GPIO_Num;
+ *uiLedTxIndex = uiIndex;
+ } else {
+ *GPIO_num_rx = led_state_info->GPIO_Num;
+ *uiLedRxIndex = uiIndex;
}
} else {
- if (Adapter->LEDInfo.LEDState[uiIndex].LED_On_State
- & currdriverstate) {
- if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num
- != DISABLE_GPIO_NUM) {
- *GPIO_num_tx = Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num;
- *uiLedTxIndex = uiIndex;
- }
+ if ((led_state_info->LED_On_State & currdriverstate) &&
+ (led_state_info->GPIO_Num != DISABLE_GPIO_NUM)) {
+ *GPIO_num_tx = led_state_info->GPIO_Num;
+ *uiLedTxIndex = uiIndex;
}
}
}
return STATUS_SUCCESS;
}
+
+static void handle_adapter_driver_state(struct bcm_mini_adapter *ad,
+ enum bcm_led_events currdriverstate,
+ UCHAR GPIO_num,
+ UCHAR dummyGPIONum,
+ UCHAR uiLedIndex,
+ UCHAR dummyIndex,
+ ulong timeout,
+ UINT uiResetValue,
+ UINT uiIndex)
+{
+ switch (ad->DriverState) {
+ case DRIVER_INIT:
+ currdriverstate = DRIVER_INIT;
+ /* ad->DriverState; */
+ BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum,
+ &uiLedIndex, &dummyIndex,
+ currdriverstate);
+
+ if (GPIO_num != DISABLE_GPIO_NUM)
+ TURN_ON_LED(ad, 1 << GPIO_num, uiLedIndex);
+
+ break;
+ case FW_DOWNLOAD:
+ /*
+ * BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
+ * LED_DUMP_INFO, DBG_LVL_ALL,
+ * "LED Thread: FW_DN_DONE called\n");
+ */
+ currdriverstate = FW_DOWNLOAD;
+ BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum,
+ &uiLedIndex, &dummyIndex,
+ currdriverstate);
+
+ if (GPIO_num != DISABLE_GPIO_NUM) {
+ timeout = 50;
+ LED_Blink(ad, 1 << GPIO_num, uiLedIndex, timeout,
+ -1, currdriverstate);
+ }
+ break;
+ case FW_DOWNLOAD_DONE:
+ currdriverstate = FW_DOWNLOAD_DONE;
+ BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum,
+ &uiLedIndex, &dummyIndex, currdriverstate);
+ if (GPIO_num != DISABLE_GPIO_NUM)
+ TURN_ON_LED(ad, 1 << GPIO_num, uiLedIndex);
+ break;
+
+ case SHUTDOWN_EXIT:
+ /*
+ * no break, continue to NO_NETWORK_ENTRY
+ * state as well.
+ */
+ case NO_NETWORK_ENTRY:
+ currdriverstate = NO_NETWORK_ENTRY;
+ BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum,
+ &uiLedIndex, &dummyGPIONum, currdriverstate);
+ if (GPIO_num != DISABLE_GPIO_NUM)
+ TURN_ON_LED(ad, 1 << GPIO_num, uiLedIndex);
+ break;
+ case NORMAL_OPERATION:
+ {
+ UCHAR GPIO_num_tx = DISABLE_GPIO_NUM;
+ UCHAR GPIO_num_rx = DISABLE_GPIO_NUM;
+ UCHAR uiLEDTx = 0;
+ UCHAR uiLEDRx = 0;
+
+ currdriverstate = NORMAL_OPERATION;
+ ad->LEDInfo.bIdle_led_off = false;
+
+ BcmGetGPIOPinInfo(ad, &GPIO_num_tx, &GPIO_num_rx,
+ &uiLEDTx, &uiLEDRx, currdriverstate);
+ if ((GPIO_num_tx == DISABLE_GPIO_NUM) &&
+ (GPIO_num_rx == DISABLE_GPIO_NUM)) {
+ 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;
+ } else if (GPIO_num_rx == DISABLE_GPIO_NUM) {
+ GPIO_num_rx = GPIO_num_tx;
+ uiLEDRx = uiLEDTx;
+ }
+ /*
+ * Blink the LED in proportionate
+ * to Tx and Rx transmissions.
+ */
+ LED_Proportional_Blink(ad,
+ GPIO_num_tx, uiLEDTx,
+ GPIO_num_rx, uiLEDRx,
+ currdriverstate);
+ }
+ }
+ break;
+ case LOWPOWER_MODE_ENTER:
+ currdriverstate = LOWPOWER_MODE_ENTER;
+ if (DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING ==
+ ad->ulPowerSaveMode) {
+ /* Turn OFF all the LED */
+ uiResetValue = 0;
+ for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
+ if (ad->LEDInfo.LEDState[uiIndex].GPIO_Num != DISABLE_GPIO_NUM)
+ TURN_OFF_LED(ad,
+ (1 << ad->LEDInfo.LEDState[uiIndex].GPIO_Num),
+ uiIndex);
+ }
+
+ }
+ /* Turn off LED And WAKE-UP for Sendinf IDLE mode ACK */
+ ad->LEDInfo.bLedInitDone = false;
+ ad->LEDInfo.bIdle_led_off = TRUE;
+ wake_up(&ad->LEDInfo.idleModeSyncEvent);
+ GPIO_num = DISABLE_GPIO_NUM;
+ break;
+ case IDLEMODE_CONTINUE:
+ currdriverstate = IDLEMODE_CONTINUE;
+ GPIO_num = DISABLE_GPIO_NUM;
+ break;
+ case IDLEMODE_EXIT:
+ break;
+ case DRIVER_HALT:
+ currdriverstate = DRIVER_HALT;
+ GPIO_num = DISABLE_GPIO_NUM;
+ for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
+ if (ad->LEDInfo.LEDState[uiIndex].GPIO_Num !=
+ DISABLE_GPIO_NUM)
+ TURN_OFF_LED(ad,
+ (1 << ad->LEDInfo.LEDState[uiIndex].GPIO_Num),
+ uiIndex);
+ }
+ /* ad->DriverState = DRIVER_INIT; */
+ break;
+ case LED_THREAD_INACTIVE:
+ BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, LED_DUMP_INFO,
+ DBG_LVL_ALL, "InActivating LED thread...");
+ currdriverstate = LED_THREAD_INACTIVE;
+ ad->LEDInfo.led_thread_running =
+ BCM_LED_THREAD_RUNNING_INACTIVELY;
+ ad->LEDInfo.bLedInitDone = false;
+ /* disable ALL LED */
+ for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
+ if (ad->LEDInfo.LEDState[uiIndex].GPIO_Num !=
+ DISABLE_GPIO_NUM)
+ TURN_OFF_LED(ad,
+ (1 << ad->LEDInfo.LEDState[uiIndex].GPIO_Num),
+ uiIndex);
+ }
+ break;
+ case LED_THREAD_ACTIVE:
+ BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, LED_DUMP_INFO,
+ DBG_LVL_ALL, "Activating LED thread again...");
+ if (ad->LinkUpStatus == false)
+ ad->DriverState = NO_NETWORK_ENTRY;
+ else
+ ad->DriverState = NORMAL_OPERATION;
+
+ ad->LEDInfo.led_thread_running =
+ BCM_LED_THREAD_RUNNING_ACTIVELY;
+ break;
+ /* return; */
+ default:
+ break;
+ }
+}
+
static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
{
UINT uiIndex = 0;
@@ -691,168 +867,28 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
"Led thread got signal to exit..hence exiting");
Adapter->LEDInfo.led_thread_running =
BCM_LED_THREAD_DISABLED;
- TURN_OFF_LED(1 << GPIO_num, uiLedIndex);
+ TURN_OFF_LED(Adapter, 1 << GPIO_num, uiLedIndex);
return; /* STATUS_FAILURE; */
}
if (GPIO_num != DISABLE_GPIO_NUM)
- TURN_OFF_LED(1 << GPIO_num, uiLedIndex);
+ TURN_OFF_LED(Adapter, 1 << GPIO_num, uiLedIndex);
if (Adapter->LEDInfo.bLedInitDone == false) {
LedGpioInit(Adapter);
Adapter->LEDInfo.bLedInitDone = TRUE;
}
- switch (Adapter->DriverState) {
- case DRIVER_INIT:
- currdriverstate = DRIVER_INIT;
- /* Adapter->DriverState; */
- BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum,
- &uiLedIndex, &dummyIndex, currdriverstate);
-
- if (GPIO_num != DISABLE_GPIO_NUM)
- TURN_ON_LED(1 << GPIO_num, uiLedIndex);
-
- break;
- case FW_DOWNLOAD:
- /*
- * BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
- * LED_DUMP_INFO, DBG_LVL_ALL,
- * "LED Thread: FW_DN_DONE called\n");
- */
- currdriverstate = FW_DOWNLOAD;
- BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum,
- &uiLedIndex, &dummyIndex, currdriverstate);
-
- if (GPIO_num != DISABLE_GPIO_NUM) {
- timeout = 50;
- LED_Blink(Adapter, 1 << GPIO_num, uiLedIndex,
- timeout, -1, currdriverstate);
- }
- break;
- case FW_DOWNLOAD_DONE:
- currdriverstate = FW_DOWNLOAD_DONE;
- BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum,
- &uiLedIndex, &dummyIndex, currdriverstate);
- if (GPIO_num != DISABLE_GPIO_NUM)
- TURN_ON_LED(1 << GPIO_num, uiLedIndex);
- break;
-
- case SHUTDOWN_EXIT:
- /*
- * no break, continue to NO_NETWORK_ENTRY
- * state as well.
- */
- case NO_NETWORK_ENTRY:
- currdriverstate = NO_NETWORK_ENTRY;
- BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum,
- &uiLedIndex, &dummyGPIONum, currdriverstate);
- if (GPIO_num != DISABLE_GPIO_NUM)
- TURN_ON_LED(1 << GPIO_num, uiLedIndex);
- break;
- case NORMAL_OPERATION:
- {
- 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;
-
- BcmGetGPIOPinInfo(Adapter, &GPIO_num_tx,
- &GPIO_num_rx, &uiLEDTx, &uiLEDRx,
- currdriverstate);
- if ((GPIO_num_tx == DISABLE_GPIO_NUM) &&
- (GPIO_num_rx ==
- DISABLE_GPIO_NUM)) {
- 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;
- } else if (GPIO_num_rx ==
- DISABLE_GPIO_NUM) {
- GPIO_num_rx = GPIO_num_tx;
- uiLEDRx = uiLEDTx;
- }
- /*
- * Blink the LED in proportionate
- * to Tx and Rx transmissions.
- */
- LED_Proportional_Blink(Adapter,
- GPIO_num_tx, uiLEDTx,
- GPIO_num_rx, uiLEDRx,
- currdriverstate);
- }
- }
- break;
- case LOWPOWER_MODE_ENTER:
- currdriverstate = LOWPOWER_MODE_ENTER;
- if (DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING ==
- Adapter->ulPowerSaveMode) {
- /* Turn OFF all the LED */
- uiResetValue = 0;
- for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
- if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num != DISABLE_GPIO_NUM)
- TURN_OFF_LED((1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num), uiIndex);
- }
-
- }
- /* 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;
- break;
- case IDLEMODE_EXIT:
- break;
- case DRIVER_HALT:
- currdriverstate = DRIVER_HALT;
- GPIO_num = DISABLE_GPIO_NUM;
- for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
- if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num
- != DISABLE_GPIO_NUM)
- TURN_OFF_LED((1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num), uiIndex);
- }
- /* Adapter->DriverState = DRIVER_INIT; */
- break;
- case LED_THREAD_INACTIVE:
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
- DBG_LVL_ALL, "InActivating LED thread...");
- currdriverstate = LED_THREAD_INACTIVE;
- Adapter->LEDInfo.led_thread_running =
- BCM_LED_THREAD_RUNNING_INACTIVELY;
- Adapter->LEDInfo.bLedInitDone = false;
- /* disable ALL LED */
- for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
- if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num
- != DISABLE_GPIO_NUM)
- TURN_OFF_LED((1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num), uiIndex);
- }
- break;
- case LED_THREAD_ACTIVE:
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
- DBG_LVL_ALL, "Activating LED thread again...");
- if (Adapter->LinkUpStatus == false)
- Adapter->DriverState = NO_NETWORK_ENTRY;
- else
- Adapter->DriverState = NORMAL_OPERATION;
-
- Adapter->LEDInfo.led_thread_running =
- BCM_LED_THREAD_RUNNING_ACTIVELY;
- break;
- /* return; */
- default:
- break;
- }
+ handle_adapter_driver_state(Adapter,
+ currdriverstate,
+ GPIO_num,
+ dummyGPIONum,
+ uiLedIndex,
+ dummyIndex,
+ timeout,
+ uiResetValue,
+ uiIndex
+ );
}
Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_DISABLED;
}
@@ -878,8 +914,8 @@ int InitLedSettings(struct bcm_mini_adapter *Adapter)
Status = ReadConfigFileStructure(Adapter, &bEnableThread);
if (STATUS_SUCCESS != Status) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
- DBG_LVL_ALL,
- "LED Thread: FAILED in ReadConfigFileStructure\n");
+ DBG_LVL_ALL,
+ "LED Thread: FAILED in ReadConfigFileStructure\n");
return Status;
}
@@ -902,11 +938,11 @@ int InitLedSettings(struct bcm_mini_adapter *Adapter)
Adapter->LEDInfo.bIdle_led_off = false;
Adapter->LEDInfo.led_cntrl_threadid =
kthread_run((int (*)(void *)) LEDControlThread,
- Adapter, "led_control_thread");
+ Adapter, "led_control_thread");
if (IS_ERR(Adapter->LEDInfo.led_cntrl_threadid)) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
- DBG_LVL_ALL,
- "Not able to spawn Kernel Thread\n");
+ DBG_LVL_ALL,
+ "Not able to spawn Kernel Thread\n");
Adapter->LEDInfo.led_thread_running =
BCM_LED_THREAD_DISABLED;
return PTR_ERR(Adapter->LEDInfo.led_cntrl_threadid);