Larry Finger | 7bc8863 | 2013-08-21 22:33:59 -0500 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of version 2 of the GNU General Public License as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
Larry Finger | 7bc8863 | 2013-08-21 22:33:59 -0500 | [diff] [blame] | 14 | ******************************************************************************/ |
| 15 | |
| 16 | #include <osdep_service.h> |
| 17 | #include <drv_types.h> |
| 18 | #include <rtl8188e_hal.h> |
| 19 | #include <rtl8188e_led.h> |
navin patidar | e73fd15 | 2014-06-11 22:51:40 +0530 | [diff] [blame] | 20 | #include <usb_ops_linux.h> |
Larry Finger | 7bc8863 | 2013-08-21 22:33:59 -0500 | [diff] [blame] | 21 | |
| 22 | /* LED object. */ |
| 23 | |
| 24 | /* LED_819xUsb routines. */ |
| 25 | /* Description: */ |
| 26 | /* Turn on LED according to LedPin specified. */ |
| 27 | void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) |
| 28 | { |
| 29 | u8 LedCfg; |
| 30 | |
| 31 | if (padapter->bSurpriseRemoved || padapter->bDriverStopped) |
| 32 | return; |
navin patidar | c7b2e99 | 2014-06-11 22:51:36 +0530 | [diff] [blame] | 33 | LedCfg = usb_read8(padapter, REG_LEDCFG2); |
Anish Bhatt | 9c68ed0 | 2015-10-18 22:51:41 -0700 | [diff] [blame] | 34 | usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0) | BIT(5) | BIT(6)); /* SW control led0 on. */ |
Larry Finger | 7bc8863 | 2013-08-21 22:33:59 -0500 | [diff] [blame] | 35 | pLed->bLedOn = true; |
| 36 | } |
| 37 | |
| 38 | /* Description: */ |
| 39 | /* Turn off LED according to LedPin specified. */ |
| 40 | void SwLedOff(struct adapter *padapter, struct LED_871x *pLed) |
| 41 | { |
| 42 | u8 LedCfg; |
| 43 | struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); |
| 44 | |
| 45 | if (padapter->bSurpriseRemoved || padapter->bDriverStopped) |
| 46 | goto exit; |
| 47 | |
navin patidar | c7b2e99 | 2014-06-11 22:51:36 +0530 | [diff] [blame] | 48 | LedCfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */ |
Larry Finger | 7bc8863 | 2013-08-21 22:33:59 -0500 | [diff] [blame] | 49 | |
navin patidar | 373b61b | 2014-04-20 14:17:15 +0530 | [diff] [blame] | 50 | if (pHalData->bLedOpenDrain) { |
Larry Finger | 7bc8863 | 2013-08-21 22:33:59 -0500 | [diff] [blame] | 51 | /* Open-drain arrangement for controlling the LED) */ |
navin patidar | 373b61b | 2014-04-20 14:17:15 +0530 | [diff] [blame] | 52 | LedCfg &= 0x90; /* Set to software control. */ |
Anish Bhatt | 9c68ed0 | 2015-10-18 22:51:41 -0700 | [diff] [blame] | 53 | usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3))); |
navin patidar | c7b2e99 | 2014-06-11 22:51:36 +0530 | [diff] [blame] | 54 | LedCfg = usb_read8(padapter, REG_MAC_PINMUX_CFG); |
navin patidar | 373b61b | 2014-04-20 14:17:15 +0530 | [diff] [blame] | 55 | LedCfg &= 0xFE; |
navin patidar | e76484d | 2014-06-11 22:51:33 +0530 | [diff] [blame] | 56 | usb_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); |
navin patidar | 373b61b | 2014-04-20 14:17:15 +0530 | [diff] [blame] | 57 | } else { |
Anish Bhatt | 9c68ed0 | 2015-10-18 22:51:41 -0700 | [diff] [blame] | 58 | usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3) | BIT(5) | BIT(6))); |
Larry Finger | 7bc8863 | 2013-08-21 22:33:59 -0500 | [diff] [blame] | 59 | } |
| 60 | exit: |
| 61 | pLed->bLedOn = false; |
| 62 | } |
| 63 | |
| 64 | /* Interface to manipulate LED objects. */ |
| 65 | /* Default LED behavior. */ |
| 66 | |
| 67 | /* Description: */ |
| 68 | /* Initialize all LED_871x objects. */ |
| 69 | void rtl8188eu_InitSwLeds(struct adapter *padapter) |
| 70 | { |
| 71 | struct led_priv *pledpriv = &(padapter->ledpriv); |
navin patidar | 74391e1 | 2014-04-20 14:17:11 +0530 | [diff] [blame] | 72 | struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); |
Larry Finger | 7bc8863 | 2013-08-21 22:33:59 -0500 | [diff] [blame] | 73 | |
navin patidar | 74391e1 | 2014-04-20 14:17:11 +0530 | [diff] [blame] | 74 | pledpriv->bRegUseLed = true; |
Larry Finger | d33b128 | 2013-08-25 11:55:15 -0500 | [diff] [blame] | 75 | pledpriv->LedControlHandler = LedControl8188eu; |
navin patidar | 74391e1 | 2014-04-20 14:17:11 +0530 | [diff] [blame] | 76 | haldata->bLedOpenDrain = true; |
Larry Finger | 7bc8863 | 2013-08-21 22:33:59 -0500 | [diff] [blame] | 77 | |
navin patidar | 373b61b | 2014-04-20 14:17:15 +0530 | [diff] [blame] | 78 | InitLed871x(padapter, &(pledpriv->SwLed0)); |
Larry Finger | 7bc8863 | 2013-08-21 22:33:59 -0500 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | /* Description: */ |
| 82 | /* DeInitialize all LED_819xUsb objects. */ |
| 83 | void rtl8188eu_DeInitSwLeds(struct adapter *padapter) |
| 84 | { |
| 85 | struct led_priv *ledpriv = &(padapter->ledpriv); |
| 86 | |
| 87 | DeInitLed871x(&(ledpriv->SwLed0)); |
Larry Finger | 7bc8863 | 2013-08-21 22:33:59 -0500 | [diff] [blame] | 88 | } |