rtl8821ce_led.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2015 - 2016 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 <drv_types.h> /* PADAPTER */
  21. #include <hal_data.h> /* PHAL_DATA_TYPE */
  22. #include <hal_com_led.h> /* PLED_PCIE */
  23. /*
  24. *==============================================================================
  25. * Prototype of protected function.
  26. *==============================================================================
  27. */
  28. /*
  29. *==============================================================================
  30. * LED_819xUsb routines.
  31. *==============================================================================
  32. */
  33. /*
  34. * Description:
  35. * Turn on LED according to LedPin specified.
  36. */
  37. static void SwLedOn_8821ce(PADAPTER adapter, PLED_PCIE pLed)
  38. {
  39. #if 0
  40. u16 LedReg = REG_LEDCFG0;
  41. u8 LedCfg = 0;
  42. struct led_priv *ledpriv = &(adapter->ledpriv);
  43. if (RTW_CANNOT_RUN(adapter))
  44. return;
  45. switch (pLed->LedPin) {
  46. case LED_PIN_LED0:
  47. if (ledpriv->LedStrategy == SW_LED_MODE10)
  48. LedReg = REG_LEDCFG0;
  49. else
  50. LedReg = REG_LEDCFG1;
  51. break;
  52. case LED_PIN_LED1:
  53. LedReg = REG_LEDCFG2;
  54. break;
  55. case LED_PIN_GPIO0:
  56. default:
  57. break;
  58. }
  59. LedCfg = rtw_read8(adapter, LedReg);
  60. LedCfg |= BIT5; /* Set 0x4c[21] */
  61. /* Clear 0x4c[23:22] and 0x4c[19:16] */
  62. LedCfg &= ~(BIT7 | BIT6 | BIT3 | BIT2 | BIT1 | BIT0);
  63. /* SW control led0 on. */
  64. rtw_write8(adapter, LedReg, LedCfg);
  65. pLed->bLedOn = _TRUE;
  66. #else
  67. RTW_INFO("%s(%d)TODO LED\n", __func__, __LINE__);
  68. #endif
  69. }
  70. /*
  71. * Description:
  72. * Turn off LED according to LedPin specified.
  73. */
  74. static void SwLedOff_8821ce(PADAPTER adapter, PLED_PCIE pLed)
  75. {
  76. #if 0
  77. u16 LedReg = REG_LEDCFG0;
  78. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  79. struct led_priv *ledpriv = &adapter->ledpriv;
  80. if (RTW_CANNOT_RUN(adapter))
  81. return;
  82. switch (pLed->LedPin) {
  83. case LED_PIN_LED0:
  84. if (ledpriv->LedStrategy == SW_LED_MODE10)
  85. LedReg = REG_LEDCFG0;
  86. else
  87. LedReg = REG_LEDCFG1;
  88. break;
  89. case LED_PIN_LED1:
  90. LedReg = REG_LEDCFG2;
  91. break;
  92. case LED_PIN_GPIO0:
  93. default:
  94. break;
  95. }
  96. /* Open-drain arrangement for controlling the LED */
  97. if (hal->bLedOpenDrain == _TRUE) {
  98. u8 LedCfg = rtw_read8(adapter, LedReg);
  99. LedCfg &= 0xd0; /* Set to software control. */
  100. rtw_write8(adapter, LedReg, (LedCfg | BIT3));
  101. /* Open-drain arrangement */
  102. LedCfg = rtw_read8(adapter, REG_MAC_PINMUX_CFG);
  103. LedCfg &= 0xFE;/* Set GPIO[8] to input mode */
  104. rtw_write8(adapter, REG_MAC_PINMUX_CFG, LedCfg);
  105. } else
  106. rtw_write8(adapter, LedReg, 0x28);
  107. pLed->bLedOn = _FALSE;
  108. #else
  109. RTW_INFO("%s(%d)TODO LED\n", __func__, __LINE__);
  110. #endif
  111. }
  112. /*
  113. * Description:
  114. * Initialize all LED_871x objects.
  115. */
  116. void rtl8821ce_InitSwLeds(PADAPTER adapter)
  117. {
  118. struct led_priv *pledpriv = &adapter->ledpriv;
  119. pledpriv->LedControlHandler = LedControlPCIE;
  120. pledpriv->SwLedOn = SwLedOn_8821ce;
  121. pledpriv->SwLedOff = SwLedOff_8821ce;
  122. InitLed(adapter, &pledpriv->SwLed0, LED_PIN_LED0);
  123. InitLed(adapter, &pledpriv->SwLed1, LED_PIN_LED1);
  124. }
  125. /*
  126. * Description:
  127. * DeInitialize all LED_819xUsb objects.
  128. */
  129. void rtl8821ce_DeInitSwLeds(PADAPTER adapter)
  130. {
  131. struct led_priv *ledpriv = &adapter->ledpriv;
  132. DeInitLed(&ledpriv->SwLed0);
  133. DeInitLed(&ledpriv->SwLed1);
  134. }