Lines Matching +full:led +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
42 struct led_classdev led; member
47 container_of(lcdev, struct igc_led_classdev, led)
49 static void igc_led_select(struct igc_adapter *adapter, int led, in igc_led_select() argument
52 switch (led) { in igc_led_select()
70 netdev_err(adapter->netdev, "Unknown LED %d selected!\n", led); in igc_led_select()
74 static void igc_led_set(struct igc_adapter *adapter, int led, u32 mode, in igc_led_set() argument
78 struct igc_hw *hw = &adapter->hw; in igc_led_set()
80 igc_led_select(adapter, led, &mask, &shift, &blink_bit); in igc_led_set()
82 pm_runtime_get_sync(&adapter->pdev->dev); in igc_led_set()
83 mutex_lock(&adapter->led_mutex); in igc_led_set()
85 /* Set mode */ in igc_led_set()
88 ledctl |= mode << shift; in igc_led_set()
97 mutex_unlock(&adapter->led_mutex); in igc_led_set()
98 pm_runtime_put(&adapter->pdev->dev); in igc_led_set()
101 static u32 igc_led_get(struct igc_adapter *adapter, int led) in igc_led_get() argument
104 struct igc_hw *hw = &adapter->hw; in igc_led_get()
106 igc_led_select(adapter, led, &mask, &shift, &blink_bit); in igc_led_get()
108 pm_runtime_get_sync(&adapter->pdev->dev); in igc_led_get()
109 mutex_lock(&adapter->led_mutex); in igc_led_get()
111 mutex_unlock(&adapter->led_mutex); in igc_led_get()
112 pm_runtime_put(&adapter->pdev->dev); in igc_led_get()
121 struct igc_adapter *adapter = netdev_priv(ldev->netdev); in igc_led_brightness_set_blocking()
122 u32 mode; in igc_led_brightness_set_blocking() local
125 mode = IGC_LEDCTL_MODE_ON; in igc_led_brightness_set_blocking()
127 mode = IGC_LEDCTL_MODE_OFF; in igc_led_brightness_set_blocking()
129 netdev_dbg(adapter->netdev, "Set brightness for LED %d to mode %u!\n", in igc_led_brightness_set_blocking()
130 ldev->index, mode); in igc_led_brightness_set_blocking()
132 igc_led_set(adapter, ldev->index, mode, false); in igc_led_brightness_set_blocking()
141 return -EOPNOTSUPP; in igc_led_hw_control_is_supported()
144 * mode is selected as well. in igc_led_hw_control_is_supported()
153 return -EOPNOTSUPP; in igc_led_hw_control_is_supported()
155 /* Only one mode can be active at a given time. */ in igc_led_hw_control_is_supported()
156 if (flags & (flags - 1)) in igc_led_hw_control_is_supported()
157 return -EOPNOTSUPP; in igc_led_hw_control_is_supported()
166 struct igc_adapter *adapter = netdev_priv(ldev->netdev); in igc_led_hw_control_set()
167 u32 mode = IGC_LEDCTL_MODE_OFF; in igc_led_hw_control_set() local
171 mode = IGC_LEDCTL_MODE_LINK_10; in igc_led_hw_control_set()
173 mode = IGC_LEDCTL_MODE_LINK_100; in igc_led_hw_control_set()
175 mode = IGC_LEDCTL_MODE_LINK_1000; in igc_led_hw_control_set()
177 mode = IGC_LEDCTL_MODE_LINK_2500; in igc_led_hw_control_set()
180 mode = IGC_LEDCTL_MODE_ACTIVITY; in igc_led_hw_control_set()
182 netdev_dbg(adapter->netdev, "Set HW control for LED %d to mode %u!\n", in igc_led_hw_control_set()
183 ldev->index, mode); in igc_led_hw_control_set()
186 if (mode == IGC_LEDCTL_MODE_ACTIVITY) in igc_led_hw_control_set()
189 igc_led_set(adapter, ldev->index, mode, blink); in igc_led_hw_control_set()
198 struct igc_adapter *adapter = netdev_priv(ldev->netdev); in igc_led_hw_control_get()
199 u32 mode; in igc_led_hw_control_get() local
201 mode = igc_led_get(adapter, ldev->index); in igc_led_hw_control_get()
203 switch (mode) { in igc_led_hw_control_get()
228 return &ldev->netdev->dev; in igc_led_hw_control_get_device()
234 snprintf(buf, buf_len, "igc-%x%x-led%d", in igc_led_get_name()
235 pci_domain_nr(adapter->pdev->bus), in igc_led_get_name()
236 pci_dev_id(adapter->pdev), index); in igc_led_get_name()
243 struct led_classdev *led_cdev = &ldev->led; in igc_setup_ldev()
246 ldev->netdev = netdev; in igc_setup_ldev()
247 ldev->index = index; in igc_setup_ldev()
250 led_cdev->name = led_name; in igc_setup_ldev()
251 led_cdev->flags |= LED_RETAIN_AT_SHUTDOWN; in igc_setup_ldev()
252 led_cdev->max_brightness = 1; in igc_setup_ldev()
253 led_cdev->brightness_set_blocking = igc_led_brightness_set_blocking; in igc_setup_ldev()
254 led_cdev->hw_control_trigger = "netdev"; in igc_setup_ldev()
255 led_cdev->hw_control_is_supported = igc_led_hw_control_is_supported; in igc_setup_ldev()
256 led_cdev->hw_control_set = igc_led_hw_control_set; in igc_setup_ldev()
257 led_cdev->hw_control_get = igc_led_hw_control_get; in igc_setup_ldev()
258 led_cdev->hw_control_get_device = igc_led_hw_control_get_device; in igc_setup_ldev()
260 return led_classdev_register(&netdev->dev, led_cdev); in igc_setup_ldev()
265 struct net_device *netdev = adapter->netdev; in igc_led_setup()
269 mutex_init(&adapter->led_mutex); in igc_led_setup()
273 return -ENOMEM; in igc_led_setup()
281 adapter->leds = leds; in igc_led_setup()
286 for (i--; i >= 0; i--) in igc_led_setup()
287 led_classdev_unregister(&((leds + i)->led)); in igc_led_setup()
295 struct igc_led_classdev *leds = adapter->leds; in igc_led_free()
299 led_classdev_unregister(&((leds + i)->led)); in igc_led_free()