rtl8188eu_led.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. #include <osdep_service.h>
  21. #include <drv_types.h>
  22. #include <rtl8188e_hal.h>
  23. #include <rtl8188e_led.h>
  24. #include <usb_ops_linux.h>
  25. /* LED object. */
  26. /* LED_819xUsb routines. */
  27. /* Description: */
  28. /* Turn on LED according to LedPin specified. */
  29. void SwLedOn(struct adapter *padapter, struct LED_871x *pLed)
  30. {
  31. u8 LedCfg;
  32. if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
  33. return;
  34. LedCfg = usb_read8(padapter, REG_LEDCFG2);
  35. usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0) | BIT(5) | BIT(6)); /* SW control led0 on. */
  36. pLed->bLedOn = true;
  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. if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
  45. goto exit;
  46. LedCfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */
  47. if (pHalData->bLedOpenDrain) {
  48. /* Open-drain arrangement for controlling the LED) */
  49. LedCfg &= 0x90; /* Set to software control. */
  50. usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3)));
  51. LedCfg = usb_read8(padapter, REG_MAC_PINMUX_CFG);
  52. LedCfg &= 0xFE;
  53. usb_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg);
  54. } else {
  55. usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3) | BIT(5) | BIT(6)));
  56. }
  57. exit:
  58. pLed->bLedOn = false;
  59. }
  60. /* Interface to manipulate LED objects. */
  61. /* Default LED behavior. */
  62. /* Description: */
  63. /* Initialize all LED_871x objects. */
  64. void rtl8188eu_InitSwLeds(struct adapter *padapter)
  65. {
  66. struct led_priv *pledpriv = &(padapter->ledpriv);
  67. struct hal_data_8188e *haldata = GET_HAL_DATA(padapter);
  68. pledpriv->bRegUseLed = true;
  69. pledpriv->LedControlHandler = LedControl8188eu;
  70. haldata->bLedOpenDrain = true;
  71. InitLed871x(padapter, &(pledpriv->SwLed0));
  72. }
  73. /* Description: */
  74. /* DeInitialize all LED_819xUsb objects. */
  75. void rtl8188eu_DeInitSwLeds(struct adapter *padapter)
  76. {
  77. struct led_priv *ledpriv = &(padapter->ledpriv);
  78. DeInitLed871x(&(ledpriv->SwLed0));
  79. }