rtl8821ce_led.c 3.7 KB

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