Lines Matching +full:led +full:- +full:s
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Linux LED driver for RTL8187
7 * Based on the LED handling in the r8187 driver, which is:
30 struct rtl8187_led *led = &priv->led_tx; in led_turn_on() local
32 /* Don't change the LED, when the device is down. */ in led_turn_on()
33 if (!priv->vif || priv->vif->type == NL80211_IFTYPE_UNSPECIFIED) in led_turn_on()
36 /* Skip if the LED is not registered. */ in led_turn_on()
37 if (!led->dev) in led_turn_on()
39 mutex_lock(&priv->conf_mutex); in led_turn_on()
40 switch (led->ledpin) { in led_turn_on()
42 rtl818x_iowrite8(priv, &priv->map->GPIO0, 0x01); in led_turn_on()
43 rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0x00); in led_turn_on()
46 reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) & ~(1 << 4); in led_turn_on()
47 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg); in led_turn_on()
50 reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) & ~(1 << 5); in led_turn_on()
51 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg); in led_turn_on()
57 mutex_unlock(&priv->conf_mutex); in led_turn_on()
68 struct rtl8187_led *led = &priv->led_tx; in led_turn_off() local
70 /* Don't change the LED, when the device is down. */ in led_turn_off()
71 if (!priv->vif || priv->vif->type == NL80211_IFTYPE_UNSPECIFIED) in led_turn_off()
74 /* Skip if the LED is not registered. */ in led_turn_off()
75 if (!led->dev) in led_turn_off()
77 mutex_lock(&priv->conf_mutex); in led_turn_off()
78 switch (led->ledpin) { in led_turn_off()
80 rtl818x_iowrite8(priv, &priv->map->GPIO0, 0x01); in led_turn_off()
81 rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0x01); in led_turn_off()
84 reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) | (1 << 4); in led_turn_off()
85 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg); in led_turn_off()
88 reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) | (1 << 5); in led_turn_off()
89 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg); in led_turn_off()
95 mutex_unlock(&priv->conf_mutex); in led_turn_off()
98 /* Callback from the LED subsystem. */
102 struct rtl8187_led *led = container_of(led_dev, struct rtl8187_led, in rtl8187_led_brightness_set() local
104 struct ieee80211_hw *hw = led->dev; in rtl8187_led_brightness_set()
110 priv = hw->priv; in rtl8187_led_brightness_set()
111 if (led->is_radio) { in rtl8187_led_brightness_set()
113 ieee80211_queue_delayed_work(hw, &priv->led_on, 0); in rtl8187_led_brightness_set()
117 cancel_delayed_work(&priv->led_on); in rtl8187_led_brightness_set()
118 ieee80211_queue_delayed_work(hw, &priv->led_off, 0); in rtl8187_led_brightness_set()
122 ieee80211_queue_delayed_work(hw, &priv->led_off, 0); in rtl8187_led_brightness_set()
123 /* The LED is off for 1/20 sec - it just blinks. */ in rtl8187_led_brightness_set()
124 ieee80211_queue_delayed_work(hw, &priv->led_on, in rtl8187_led_brightness_set()
127 ieee80211_queue_delayed_work(hw, &priv->led_on, 0); in rtl8187_led_brightness_set()
132 struct rtl8187_led *led, const char *name, in rtl8187_register_led() argument
137 struct rtl8187_priv *priv = dev->priv; in rtl8187_register_led()
139 if (led->dev) in rtl8187_register_led()
140 return -EEXIST; in rtl8187_register_led()
142 return -EINVAL; in rtl8187_register_led()
143 led->dev = dev; in rtl8187_register_led()
144 led->ledpin = ledpin; in rtl8187_register_led()
145 led->is_radio = is_radio; in rtl8187_register_led()
146 strscpy(led->name, name, sizeof(led->name)); in rtl8187_register_led()
148 led->led_dev.name = led->name; in rtl8187_register_led()
149 led->led_dev.default_trigger = default_trigger; in rtl8187_register_led()
150 led->led_dev.brightness_set = rtl8187_led_brightness_set; in rtl8187_register_led()
152 err = led_classdev_register(&priv->udev->dev, &led->led_dev); in rtl8187_register_led()
154 printk(KERN_INFO "LEDs: Failed to register %s\n", name); in rtl8187_register_led()
155 led->dev = NULL; in rtl8187_register_led()
161 static void rtl8187_unregister_led(struct rtl8187_led *led) in rtl8187_unregister_led() argument
163 struct ieee80211_hw *hw = led->dev; in rtl8187_unregister_led()
164 struct rtl8187_priv *priv = hw->priv; in rtl8187_unregister_led()
166 led_classdev_unregister(&led->led_dev); in rtl8187_unregister_led()
167 flush_delayed_work(&priv->led_off); in rtl8187_unregister_led()
168 led->dev = NULL; in rtl8187_unregister_led()
173 struct rtl8187_priv *priv = dev->priv; in rtl8187_leds_init()
178 /* According to the vendor driver, the LED operation depends on the in rtl8187_leds_init()
201 INIT_DELAYED_WORK(&priv->led_on, led_turn_on); in rtl8187_leds_init()
202 INIT_DELAYED_WORK(&priv->led_off, led_turn_off); in rtl8187_leds_init()
205 "rtl8187-%s::radio", wiphy_name(dev->wiphy)); in rtl8187_leds_init()
206 err = rtl8187_register_led(dev, &priv->led_radio, name, in rtl8187_leds_init()
212 "rtl8187-%s::tx", wiphy_name(dev->wiphy)); in rtl8187_leds_init()
213 err = rtl8187_register_led(dev, &priv->led_tx, name, in rtl8187_leds_init()
219 "rtl8187-%s::rx", wiphy_name(dev->wiphy)); in rtl8187_leds_init()
220 err = rtl8187_register_led(dev, &priv->led_rx, name, in rtl8187_leds_init()
225 /* registration of RX LED failed - unregister */ in rtl8187_leds_init()
226 rtl8187_unregister_led(&priv->led_tx); in rtl8187_leds_init()
228 rtl8187_unregister_led(&priv->led_radio); in rtl8187_leds_init()
233 struct rtl8187_priv *priv = dev->priv; in rtl8187_leds_exit()
235 rtl8187_unregister_led(&priv->led_radio); in rtl8187_leds_exit()
236 rtl8187_unregister_led(&priv->led_rx); in rtl8187_leds_exit()
237 rtl8187_unregister_led(&priv->led_tx); in rtl8187_leds_exit()
238 cancel_delayed_work_sync(&priv->led_off); in rtl8187_leds_exit()
239 cancel_delayed_work_sync(&priv->led_on); in rtl8187_leds_exit()