powerpc/eeh: Fix PE#0 check in eeh_add_to_parent_pe()
[linux/fpc-iii.git] / drivers / net / wireless / rtlwifi / rtl8192ee / led.c
blob8388e371c8e217b1fc5d8632b41745823ef912b2
1 /******************************************************************************
3 * Copyright(c) 2009-2014 Realtek Corporation.
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.
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.
14 * The full GNU General Public License is included in this distribution in the
15 * file called LICENSE.
17 * Contact Information:
18 * wlanfae <wlanfae@realtek.com>
19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20 * Hsinchu 300, Taiwan.
22 * Larry Finger <Larry.Finger@lwfinger.net>
24 *****************************************************************************/
26 #include "../wifi.h"
27 #include "../pci.h"
28 #include "reg.h"
29 #include "led.h"
31 static void _rtl92ee_init_led(struct ieee80211_hw *hw,
32 struct rtl_led *pled, enum rtl_led_pin ledpin)
34 pled->hw = hw;
35 pled->ledpin = ledpin;
36 pled->ledon = false;
39 void rtl92ee_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
41 u32 ledcfg;
42 struct rtl_priv *rtlpriv = rtl_priv(hw);
44 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD,
45 "LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin);
47 switch (pled->ledpin) {
48 case LED_PIN_GPIO0:
49 break;
50 case LED_PIN_LED0:
51 ledcfg = rtl_read_dword(rtlpriv , REG_GPIO_PIN_CTRL);
52 ledcfg &= ~BIT(13);
53 ledcfg |= BIT(21);
54 ledcfg &= ~BIT(29);
56 rtl_write_dword(rtlpriv, REG_GPIO_PIN_CTRL, ledcfg);
58 break;
59 case LED_PIN_LED1:
61 break;
62 default:
63 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
64 "switch case not process\n");
65 break;
67 pled->ledon = true;
70 void rtl92ee_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
72 struct rtl_priv *rtlpriv = rtl_priv(hw);
73 u32 ledcfg;
75 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD,
76 "LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin);
78 switch (pled->ledpin) {
79 case LED_PIN_GPIO0:
80 break;
81 case LED_PIN_LED0:
83 ledcfg = rtl_read_dword(rtlpriv , REG_GPIO_PIN_CTRL);
84 ledcfg |= ~BIT(21);
85 ledcfg &= ~BIT(29);
86 rtl_write_dword(rtlpriv, REG_GPIO_PIN_CTRL, ledcfg);
88 break;
89 case LED_PIN_LED1:
91 break;
92 default:
93 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
94 "switch case not process\n");
95 break;
97 pled->ledon = false;
100 void rtl92ee_init_sw_leds(struct ieee80211_hw *hw)
102 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
104 _rtl92ee_init_led(hw, &pcipriv->ledctl.sw_led0, LED_PIN_LED0);
105 _rtl92ee_init_led(hw, &pcipriv->ledctl.sw_led1, LED_PIN_LED1);
108 static void _rtl92ee_sw_led_control(struct ieee80211_hw *hw,
109 enum led_ctl_mode ledaction)
111 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
112 struct rtl_led *pLed0 = &pcipriv->ledctl.sw_led0;
114 switch (ledaction) {
115 case LED_CTL_POWER_ON:
116 case LED_CTL_LINK:
117 case LED_CTL_NO_LINK:
118 rtl92ee_sw_led_on(hw, pLed0);
119 break;
120 case LED_CTL_POWER_OFF:
121 rtl92ee_sw_led_off(hw, pLed0);
122 break;
123 default:
124 break;
128 void rtl92ee_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction)
130 struct rtl_priv *rtlpriv = rtl_priv(hw);
131 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
133 if ((ppsc->rfoff_reason > RF_CHANGE_BY_PS) &&
134 (ledaction == LED_CTL_TX ||
135 ledaction == LED_CTL_RX ||
136 ledaction == LED_CTL_SITE_SURVEY ||
137 ledaction == LED_CTL_LINK ||
138 ledaction == LED_CTL_NO_LINK ||
139 ledaction == LED_CTL_START_TO_LINK ||
140 ledaction == LED_CTL_POWER_ON)) {
141 return;
143 RT_TRACE(rtlpriv, COMP_LED, DBG_TRACE, "ledaction %d,\n", ledaction);
144 _rtl92ee_sw_led_control(hw, ledaction);