This source file includes following definitions.
- iwl_mvm_send_led_fw_cmd
- iwl_mvm_led_set
- iwl_led_brightness_set
- iwl_mvm_leds_init
- iwl_mvm_leds_sync
- iwl_mvm_leds_exit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 #include <linux/leds.h>
64 #include "iwl-io.h"
65 #include "iwl-csr.h"
66 #include "mvm.h"
67
68 static void iwl_mvm_send_led_fw_cmd(struct iwl_mvm *mvm, bool on)
69 {
70 struct iwl_led_cmd led_cmd = {
71 .status = cpu_to_le32(on),
72 };
73 struct iwl_host_cmd cmd = {
74 .id = WIDE_ID(LONG_GROUP, LEDS_CMD),
75 .len = { sizeof(led_cmd), },
76 .data = { &led_cmd, },
77 .flags = CMD_ASYNC,
78 };
79 int err;
80
81 if (!iwl_mvm_firmware_running(mvm))
82 return;
83
84 err = iwl_mvm_send_cmd(mvm, &cmd);
85
86 if (err)
87 IWL_WARN(mvm, "LED command failed: %d\n", err);
88 }
89
90 static void iwl_mvm_led_set(struct iwl_mvm *mvm, bool on)
91 {
92 if (fw_has_capa(&mvm->fw->ucode_capa,
93 IWL_UCODE_TLV_CAPA_LED_CMD_SUPPORT)) {
94 iwl_mvm_send_led_fw_cmd(mvm, on);
95 return;
96 }
97
98 iwl_write32(mvm->trans, CSR_LED_REG,
99 on ? CSR_LED_REG_TURN_ON : CSR_LED_REG_TURN_OFF);
100 }
101
102 static void iwl_led_brightness_set(struct led_classdev *led_cdev,
103 enum led_brightness brightness)
104 {
105 struct iwl_mvm *mvm = container_of(led_cdev, struct iwl_mvm, led);
106
107 iwl_mvm_led_set(mvm, brightness > 0);
108 }
109
110 int iwl_mvm_leds_init(struct iwl_mvm *mvm)
111 {
112 int mode = iwlwifi_mod_params.led_mode;
113 int ret;
114
115 switch (mode) {
116 case IWL_LED_BLINK:
117 IWL_ERR(mvm, "Blink led mode not supported, used default\n");
118
119 case IWL_LED_DEFAULT:
120 case IWL_LED_RF_STATE:
121 mode = IWL_LED_RF_STATE;
122 break;
123 case IWL_LED_DISABLE:
124 IWL_INFO(mvm, "Led disabled\n");
125 return 0;
126 default:
127 return -EINVAL;
128 }
129
130 mvm->led.name = kasprintf(GFP_KERNEL, "%s-led",
131 wiphy_name(mvm->hw->wiphy));
132 if (!mvm->led.name)
133 return -ENOMEM;
134
135 mvm->led.brightness_set = iwl_led_brightness_set;
136 mvm->led.max_brightness = 1;
137
138 if (mode == IWL_LED_RF_STATE)
139 mvm->led.default_trigger =
140 ieee80211_get_radio_led_name(mvm->hw);
141
142 ret = led_classdev_register(mvm->trans->dev, &mvm->led);
143 if (ret) {
144 kfree(mvm->led.name);
145 IWL_INFO(mvm, "Failed to enable led\n");
146 return ret;
147 }
148
149 mvm->init_status |= IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE;
150 return 0;
151 }
152
153 void iwl_mvm_leds_sync(struct iwl_mvm *mvm)
154 {
155 if (!(mvm->init_status & IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE))
156 return;
157
158
159
160
161
162 if (mvm->trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_8000)
163 return;
164
165 iwl_mvm_led_set(mvm, mvm->led.brightness > 0);
166 }
167
168 void iwl_mvm_leds_exit(struct iwl_mvm *mvm)
169 {
170 if (!(mvm->init_status & IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE))
171 return;
172
173 led_classdev_unregister(&mvm->led);
174 kfree(mvm->led.name);
175 mvm->init_status &= ~IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE;
176 }