drm: bridge: adv7511: remove s32 format from i2s capabilities
[drm/drm-misc.git] / drivers / net / wireless / ath / ath10k / leds.c
blob9b1d04eb4265bd3dd0bc73df2eed57ffbeaeef3c
1 // SPDX-License-Identifier: ISC
2 /*
3 * Copyright (c) 2005-2011 Atheros Communications Inc.
4 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
5 * Copyright (c) 2018 Sebastian Gottschall <s.gottschall@dd-wrt.com>
6 * Copyright (c) 2018 The Linux Foundation. All rights reserved.
7 */
9 #include <linux/leds.h>
11 #include "core.h"
12 #include "wmi.h"
13 #include "wmi-ops.h"
15 #include "leds.h"
17 static int ath10k_leds_set_brightness_blocking(struct led_classdev *led_cdev,
18 enum led_brightness brightness)
20 struct ath10k *ar = container_of(led_cdev, struct ath10k,
21 leds.cdev);
22 struct gpio_led *led = &ar->leds.wifi_led;
24 mutex_lock(&ar->conf_mutex);
26 if (ar->state != ATH10K_STATE_ON)
27 goto out;
29 ar->leds.gpio_state_pin = (brightness != LED_OFF) ^ led->active_low;
30 ath10k_wmi_gpio_output(ar, led->gpio, ar->leds.gpio_state_pin);
32 out:
33 mutex_unlock(&ar->conf_mutex);
35 return 0;
38 int ath10k_leds_start(struct ath10k *ar)
40 if (ar->hw_params.led_pin == 0)
41 /* leds not supported */
42 return 0;
44 /* under some circumstances, the gpio pin gets reconfigured
45 * to default state by the firmware, so we need to
46 * reconfigure it this behaviour has only ben seen on
47 * QCA9984 and QCA99XX devices so far
49 ath10k_wmi_gpio_config(ar, ar->hw_params.led_pin, 0,
50 WMI_GPIO_PULL_NONE, WMI_GPIO_INTTYPE_DISABLE);
51 ath10k_wmi_gpio_output(ar, ar->hw_params.led_pin, 1);
53 return 0;
56 int ath10k_leds_register(struct ath10k *ar)
58 int ret;
60 if (ar->hw_params.led_pin == 0)
61 /* leds not supported */
62 return 0;
64 snprintf(ar->leds.label, sizeof(ar->leds.label), "ath10k-%s",
65 wiphy_name(ar->hw->wiphy));
66 ar->leds.wifi_led.active_low = 1;
67 ar->leds.wifi_led.gpio = ar->hw_params.led_pin;
68 ar->leds.wifi_led.name = ar->leds.label;
69 ar->leds.wifi_led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
71 ar->leds.cdev.name = ar->leds.label;
72 ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking;
73 ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger;
75 ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev);
76 if (ret)
77 return ret;
79 return 0;
82 void ath10k_leds_unregister(struct ath10k *ar)
84 if (ar->hw_params.led_pin == 0)
85 /* leds not supported */
86 return;
88 led_classdev_unregister(&ar->leds.cdev);