kernel: move ubnt ledbar driver to a separate package
authorFelix Fietkau <nbd@nbd.name>
Fri, 30 Sep 2022 09:26:47 +0000 (11:26 +0200)
committerFelix Fietkau <nbd@nbd.name>
Fri, 30 Sep 2022 09:28:51 +0000 (11:28 +0200)
Simplifies the tree by removing a non-upstream kernel patch and related kconfig
symbols

Signed-off-by: Felix Fietkau <nbd@nbd.name>
14 files changed:
package/kernel/ubnt-ledbar/Makefile [new file with mode: 0644]
package/kernel/ubnt-ledbar/src/Makefile [new file with mode: 0644]
package/kernel/ubnt-ledbar/src/leds-ubnt-ledbar.c [new file with mode: 0644]
target/linux/ath79/patches-5.10/0003-leds-add-reset-controller-based-driver.patch
target/linux/ath79/patches-5.15/0003-leds-add-reset-controller-based-driver.patch
target/linux/generic/config-5.10
target/linux/generic/config-5.15
target/linux/generic/files/drivers/leds/leds-ubnt-ledbar.c [deleted file]
target/linux/generic/hack-5.10/800-ubnt-ledbar-driver.patch [deleted file]
target/linux/generic/hack-5.15/800-ubnt-ledbar-driver.patch [deleted file]
target/linux/mediatek/filogic/config-5.15
target/linux/mediatek/modules.mk
target/linux/ramips/mt7621/config-5.10
target/linux/ramips/mt7621/config-5.15

diff --git a/package/kernel/ubnt-ledbar/Makefile b/package/kernel/ubnt-ledbar/Makefile
new file mode 100644 (file)
index 0000000..8fbae9a
--- /dev/null
@@ -0,0 +1,34 @@
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ubnt-ledbar
+PKG_RELEASE:=1
+PKG_LICENSE:=GPL-2.0
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/leds-ubnt-ledbar
+  SUBMENU:=LED modules
+  TITLE:=Ubiquiti UniFi 6 LR LED support
+  FILES:= \
+       $(PKG_BUILD_DIR)/leds-ubnt-ledbar.ko
+  AUTOLOAD:=$(call AutoProbe,leds-ubnt-ledbar,1)
+  DEPENDS:=@TARGET_mediatek_mt7622 +kmod-i2c-core
+endef
+
+define KernelPackage/leds-ubnt-ledbar/description
+  LED support for Ubiquiti UniFi 6 LR
+endef
+
+define Build/Compile
+       $(KERNEL_MAKE) M="$(PKG_BUILD_DIR)" modules
+endef
+
+$(eval $(call KernelPackage,leds-ubnt-ledbar))
diff --git a/package/kernel/ubnt-ledbar/src/Makefile b/package/kernel/ubnt-ledbar/src/Makefile
new file mode 100644 (file)
index 0000000..a81d937
--- /dev/null
@@ -0,0 +1 @@
+obj-m := leds-ubnt-ledbar.o
diff --git a/package/kernel/ubnt-ledbar/src/leds-ubnt-ledbar.c b/package/kernel/ubnt-ledbar/src/leds-ubnt-ledbar.c
new file mode 100644 (file)
index 0000000..555340c
--- /dev/null
@@ -0,0 +1,255 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
+
+/**
+ * Driver for the Ubiquiti RGB LED controller (LEDBAR).
+ * This Controller is based on a Holtek HT32F52241 and connected
+ * via I2C.
+ *
+ *  - The Controller needs an enable signal set to high when
+ *    performing a transaction. On the U6-LR, this is located
+ *    at Pin 18 (R6902)
+ *
+ *  - The Pin is also printed when calling the "usetled" function
+ *    contained in the ubntapp bootloader application.
+ */
+
+#define UBNT_LEDBAR_MAX_BRIGHTNESS     0xff
+
+#define UBNT_LEDBAR_TRANSACTION_LENGTH 8
+#define UBNT_LEDBAR_TRANSACTION_SUCCESS        (char) 0xaa
+
+#define UBNT_LEDBAR_TRANSACTION_BLUE_IDX       2
+#define UBNT_LEDBAR_TRANSACTION_GREEN_IDX      3
+#define UBNT_LEDBAR_TRANSACTION_RED_IDX                4
+#define UBNT_LEDBAR_TRANSACTION_LED_COUNT_IDX  6
+
+struct ubnt_ledbar {
+       struct mutex lock;
+       u32 led_count;
+       struct i2c_client *client;
+       struct led_classdev led_red;
+       struct led_classdev led_green;
+       struct led_classdev led_blue;
+       struct gpio_desc *enable_gpio;
+       struct gpio_desc *reset_gpio;
+};
+
+static void ubnt_ledbar_perform_transaction(struct ubnt_ledbar *ledbar,
+                                          const char *transaction, int len,
+                                          char *result, int result_len)
+{
+       int i;
+
+       for (i = 0; i < len; i++)
+               i2c_smbus_write_byte(ledbar->client, transaction[i]);
+
+       for (i = 0; i < result_len; i++)
+               result[i] = i2c_smbus_read_byte(ledbar->client);
+}
+
+static int ubnt_ledbar_apply_state(struct ubnt_ledbar *ledbar)
+{
+       char setup_msg[UBNT_LEDBAR_TRANSACTION_LENGTH] = {0x40, 0x10, 0x00, 0x00,
+                                                         0x00, 0x00, 0x00, 0x11};
+       char led_msg[UBNT_LEDBAR_TRANSACTION_LENGTH] = {0x40, 0x00, 0x00, 0x00,
+                                                       0x00, 0x00, 0x00, 0x00};
+       char i2c_response;
+       int ret = 0;
+
+       mutex_lock(&ledbar->lock);
+
+       led_msg[UBNT_LEDBAR_TRANSACTION_BLUE_IDX] = ledbar->led_blue.brightness;
+       led_msg[UBNT_LEDBAR_TRANSACTION_GREEN_IDX] = ledbar->led_green.brightness;
+       led_msg[UBNT_LEDBAR_TRANSACTION_RED_IDX] = ledbar->led_red.brightness;
+       led_msg[UBNT_LEDBAR_TRANSACTION_LED_COUNT_IDX] = ledbar->led_count;
+
+       gpiod_set_value(ledbar->enable_gpio, 1);
+
+       msleep(10);
+
+       ubnt_ledbar_perform_transaction(ledbar, setup_msg, sizeof(setup_msg), &i2c_response, sizeof(i2c_response));
+       if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) {
+               dev_err(&ledbar->client->dev, "Error initializing LED transaction: %02hhx\n", i2c_response);
+               ret = -EINVAL;
+               goto out_gpio;
+       }
+
+       ubnt_ledbar_perform_transaction(ledbar, led_msg, sizeof(led_msg), &i2c_response, sizeof(i2c_response));
+       if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) {
+               dev_err(&ledbar->client->dev, "Failed LED transaction: %02hhx\n", i2c_response);
+               ret = -EINVAL;
+               goto out_gpio;
+       }
+
+       msleep(10);
+out_gpio:
+       gpiod_set_value(ledbar->enable_gpio, 0);
+
+       mutex_unlock(&ledbar->lock);
+
+       return ret;
+}
+
+static void ubnt_ledbar_reset(struct ubnt_ledbar *ledbar)
+{
+       static const char init_msg[16] = {0x02, 0x81, 0xfd, 0x7e,
+                                         0x00, 0x00, 0x00, 0x00,
+                                         0x00, 0x00, 0x00, 0x00,
+                                         0x00, 0x00, 0x00, 0x00};
+       char init_response[4];
+
+       if (!ledbar->reset_gpio)
+               return;
+
+       mutex_lock(&ledbar->lock);
+
+       gpiod_set_value(ledbar->reset_gpio, 1);
+       msleep(10);
+       gpiod_set_value(ledbar->reset_gpio, 0);
+
+       msleep(10);
+
+       gpiod_set_value(ledbar->enable_gpio, 1);
+       msleep(10);
+       ubnt_ledbar_perform_transaction(ledbar, init_msg, sizeof(init_msg), init_response, sizeof(init_response));
+       msleep(10);
+       gpiod_set_value(ledbar->enable_gpio, 0);
+
+       mutex_unlock(&ledbar->lock);
+}
+
+#define UBNT_LEDBAR_CONTROL_RGBS(name)                         \
+static int ubnt_ledbar_set_##name##_brightness(struct led_classdev *led_cdev,\
+                                       enum led_brightness value)      \
+{                                                                      \
+       struct ubnt_ledbar *ledbar = \
+                       container_of(led_cdev, struct ubnt_ledbar, led_##name); \
+       int ret; \
+       led_cdev->brightness = value; \
+       ret = ubnt_ledbar_apply_state(ledbar); \
+       return ret; \
+}
+
+UBNT_LEDBAR_CONTROL_RGBS(red);
+UBNT_LEDBAR_CONTROL_RGBS(green);
+UBNT_LEDBAR_CONTROL_RGBS(blue);
+
+
+static int ubnt_ledbar_init_led(struct device_node *np, struct ubnt_ledbar *ledbar,
+                               struct led_classdev *led_cdev)
+{
+       struct led_init_data init_data = {};
+       int ret;
+
+       if (!np)
+               return 0;
+
+       init_data.fwnode = of_fwnode_handle(np);
+
+       led_cdev->max_brightness = UBNT_LEDBAR_MAX_BRIGHTNESS;
+
+       ret = devm_led_classdev_register_ext(&ledbar->client->dev, led_cdev,
+                                            &init_data);
+       if (ret)
+               dev_err(&ledbar->client->dev, "led register err: %d\n", ret);
+
+       return ret;
+}
+
+
+static int ubnt_ledbar_probe(struct i2c_client *client,
+                            const struct i2c_device_id *id)
+{
+       struct device_node *np = client->dev.of_node;
+       struct ubnt_ledbar *ledbar;
+       int ret;
+
+       ledbar = devm_kzalloc(&client->dev, sizeof(*ledbar), GFP_KERNEL);
+       if (!ledbar)
+               return -ENOMEM;
+
+       ledbar->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
+
+       if (IS_ERR(ledbar->enable_gpio)) {
+               ret = PTR_ERR(ledbar->enable_gpio);
+               dev_err(&client->dev, "Failed to get enable gpio: %d\n", ret);
+               return ret;
+       }
+
+       ledbar->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW);
+
+       if (IS_ERR(ledbar->reset_gpio)) {
+               ret = PTR_ERR(ledbar->reset_gpio);
+               dev_err(&client->dev, "Failed to get reset gpio: %d\n", ret);
+               return ret;
+       }
+
+       ledbar->led_count = 1;
+       of_property_read_u32(np, "led-count", &ledbar->led_count);
+
+       ledbar->client = client;
+
+       mutex_init(&ledbar->lock);
+
+       i2c_set_clientdata(client, ledbar);
+
+       // Reset and initialize the MCU
+       ubnt_ledbar_reset(ledbar);
+
+       ledbar->led_red.brightness_set_blocking = ubnt_ledbar_set_red_brightness;
+       ubnt_ledbar_init_led(of_get_child_by_name(np, "red"), ledbar, &ledbar->led_red);
+
+       ledbar->led_green.brightness_set_blocking = ubnt_ledbar_set_green_brightness;
+       ubnt_ledbar_init_led(of_get_child_by_name(np, "green"), ledbar, &ledbar->led_green);
+
+       ledbar->led_blue.brightness_set_blocking = ubnt_ledbar_set_blue_brightness;
+       ubnt_ledbar_init_led(of_get_child_by_name(np, "blue"), ledbar, &ledbar->led_blue);
+
+       return ubnt_ledbar_apply_state(ledbar);
+}
+
+static int ubnt_ledbar_remove(struct i2c_client *client)
+{
+       struct ubnt_ledbar *ledbar = i2c_get_clientdata(client);
+
+       mutex_destroy(&ledbar->lock);
+
+       return 0;
+}
+
+static const struct i2c_device_id ubnt_ledbar_id[] = {
+       { "ubnt-ledbar", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, ubnt_ledbar_id);
+
+static const struct of_device_id of_ubnt_ledbar_match[] = {
+       { .compatible = "ubnt,ledbar", },
+       {},
+};
+MODULE_DEVICE_TABLE(of, of_ubnt_ledbar_match);
+
+static struct i2c_driver ubnt_ledbar_driver = {
+       .driver = {
+               .name   = "ubnt-ledbar",
+               .of_match_table = of_ubnt_ledbar_match,
+       },
+       .probe          = ubnt_ledbar_probe,
+       .remove         = ubnt_ledbar_remove,
+       .id_table       = ubnt_ledbar_id,
+};
+module_i2c_driver(ubnt_ledbar_driver);
+
+MODULE_DESCRIPTION("Ubiquiti LEDBAR driver");
+MODULE_AUTHOR("David Bauer <mail@david-bauer.net>");
+MODULE_LICENSE("GPL v2");
index 7505f682abadd57e16d10d24c46e3f2e816dfd48..4a721f2af26a3661ec34ff5d8a3479889d0f5d98 100644 (file)
@@ -13,9 +13,9 @@ Signed-off-by: John Crispin <john@phrozen.org>
 
 --- a/drivers/leds/Kconfig
 +++ b/drivers/leds/Kconfig
-@@ -941,6 +941,17 @@ config LEDS_UBNT_LEDBAR
-         To compile this driver as a module, choose M here: the module
-         will be called leds-ubnt-ledbar.
+@@ -931,6 +931,17 @@ config LEDS_ACER_A500
+ source "drivers/leds/blink/Kconfig"
  
 +config LEDS_RESET
 +      tristate "LED support for reset-controller API"
@@ -176,10 +176,10 @@ Signed-off-by: John Crispin <john@phrozen.org>
 +MODULE_ALIAS("platform:leds-reset");
 --- a/drivers/leds/Makefile
 +++ b/drivers/leds/Makefile
-@@ -94,6 +94,7 @@ obj-$(CONFIG_LEDS_WM831X_STATUS)     += leds
+@@ -93,6 +93,7 @@ obj-$(CONFIG_LEDS_TURRIS_OMNIA)              += leds
+ obj-$(CONFIG_LEDS_WM831X_STATUS)      += leds-wm831x-status.o
  obj-$(CONFIG_LEDS_WM8350)             += leds-wm8350.o
  obj-$(CONFIG_LEDS_WRAP)                       += leds-wrap.o
- obj-$(CONFIG_LEDS_UBNT_LEDBAR)                += leds-ubnt-ledbar.o
 +obj-$(CONFIG_LEDS_RESET)              += leds-reset.o
  
  # LED SPI Drivers
index f958e79608ac9fcc578c5439793541a6557b2ce9..7122756c526687e46d9565fbb0e16fe06f319cef 100644 (file)
@@ -13,9 +13,9 @@ Signed-off-by: John Crispin <john@phrozen.org>
 
 --- a/drivers/leds/Kconfig
 +++ b/drivers/leds/Kconfig
-@@ -886,6 +886,17 @@ config LEDS_UBNT_LEDBAR
-         To compile this driver as a module, choose M here: the module
-         will be called leds-ubnt-ledbar.
+@@ -876,6 +876,17 @@ source "drivers/leds/blink/Kconfig"
+ comment "Flash and Torch LED drivers"
+ source "drivers/leds/flash/Kconfig"
  
 +config LEDS_RESET
 +      tristate "LED support for reset-controller API"
@@ -176,10 +176,10 @@ Signed-off-by: John Crispin <john@phrozen.org>
 +MODULE_ALIAS("platform:leds-reset");
 --- a/drivers/leds/Makefile
 +++ b/drivers/leds/Makefile
-@@ -88,6 +88,7 @@ obj-$(CONFIG_LEDS_WM831X_STATUS)     += leds
+@@ -87,6 +87,7 @@ obj-$(CONFIG_LEDS_TURRIS_OMNIA)              += leds
+ obj-$(CONFIG_LEDS_WM831X_STATUS)      += leds-wm831x-status.o
  obj-$(CONFIG_LEDS_WM8350)             += leds-wm8350.o
  obj-$(CONFIG_LEDS_WRAP)                       += leds-wrap.o
- obj-$(CONFIG_LEDS_UBNT_LEDBAR)                += leds-ubnt-ledbar.o
 +obj-$(CONFIG_LEDS_RESET)              += leds-reset.o
  
  # LED SPI Drivers
index 498cdff5812d86fa4bc4639d9ef7f07e47661e42..873fde044c5cd34104dc3a68ea0561151ae617a8 100644 (file)
@@ -3045,7 +3045,6 @@ CONFIG_LEDS_TRIGGER_NETDEV=y
 CONFIG_LEDS_TRIGGER_TIMER=y
 # CONFIG_LEDS_TRIGGER_TRANSIENT is not set
 # CONFIG_LEDS_TURRIS_OMNIA is not set
-# CONFIG_LEDS_UBNT_LEDBAR is not set
 # CONFIG_LEDS_USER is not set
 # CONFIG_LED_TRIGGER_PHY is not set
 # CONFIG_LEGACY_PTYS is not set
index 2da2d2393ce9b0f4e8d4bf9df29510ac6ecb4729..547e3ac8826dbc3df10ab8ae081e4a3c2fc7dfa3 100644 (file)
@@ -3148,7 +3148,6 @@ CONFIG_LEDS_TRIGGER_TIMER=y
 # CONFIG_LEDS_TRIGGER_TRANSIENT is not set
 # CONFIG_LEDS_TRIGGER_TTY is not set
 # CONFIG_LEDS_TURRIS_OMNIA is not set
-# CONFIG_LEDS_UBNT_LEDBAR is not set
 # CONFIG_LEDS_USER is not set
 # CONFIG_LED_TRIGGER_PHY is not set
 # CONFIG_LEGACY_PTYS is not set
diff --git a/target/linux/generic/files/drivers/leds/leds-ubnt-ledbar.c b/target/linux/generic/files/drivers/leds/leds-ubnt-ledbar.c
deleted file mode 100644 (file)
index 555340c..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-
-#include <linux/delay.h>
-#include <linux/i2c.h>
-#include <linux/init.h>
-#include <linux/leds.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/of.h>
-#include <linux/of_gpio.h>
-#include <linux/gpio/consumer.h>
-
-/**
- * Driver for the Ubiquiti RGB LED controller (LEDBAR).
- * This Controller is based on a Holtek HT32F52241 and connected
- * via I2C.
- *
- *  - The Controller needs an enable signal set to high when
- *    performing a transaction. On the U6-LR, this is located
- *    at Pin 18 (R6902)
- *
- *  - The Pin is also printed when calling the "usetled" function
- *    contained in the ubntapp bootloader application.
- */
-
-#define UBNT_LEDBAR_MAX_BRIGHTNESS     0xff
-
-#define UBNT_LEDBAR_TRANSACTION_LENGTH 8
-#define UBNT_LEDBAR_TRANSACTION_SUCCESS        (char) 0xaa
-
-#define UBNT_LEDBAR_TRANSACTION_BLUE_IDX       2
-#define UBNT_LEDBAR_TRANSACTION_GREEN_IDX      3
-#define UBNT_LEDBAR_TRANSACTION_RED_IDX                4
-#define UBNT_LEDBAR_TRANSACTION_LED_COUNT_IDX  6
-
-struct ubnt_ledbar {
-       struct mutex lock;
-       u32 led_count;
-       struct i2c_client *client;
-       struct led_classdev led_red;
-       struct led_classdev led_green;
-       struct led_classdev led_blue;
-       struct gpio_desc *enable_gpio;
-       struct gpio_desc *reset_gpio;
-};
-
-static void ubnt_ledbar_perform_transaction(struct ubnt_ledbar *ledbar,
-                                          const char *transaction, int len,
-                                          char *result, int result_len)
-{
-       int i;
-
-       for (i = 0; i < len; i++)
-               i2c_smbus_write_byte(ledbar->client, transaction[i]);
-
-       for (i = 0; i < result_len; i++)
-               result[i] = i2c_smbus_read_byte(ledbar->client);
-}
-
-static int ubnt_ledbar_apply_state(struct ubnt_ledbar *ledbar)
-{
-       char setup_msg[UBNT_LEDBAR_TRANSACTION_LENGTH] = {0x40, 0x10, 0x00, 0x00,
-                                                         0x00, 0x00, 0x00, 0x11};
-       char led_msg[UBNT_LEDBAR_TRANSACTION_LENGTH] = {0x40, 0x00, 0x00, 0x00,
-                                                       0x00, 0x00, 0x00, 0x00};
-       char i2c_response;
-       int ret = 0;
-
-       mutex_lock(&ledbar->lock);
-
-       led_msg[UBNT_LEDBAR_TRANSACTION_BLUE_IDX] = ledbar->led_blue.brightness;
-       led_msg[UBNT_LEDBAR_TRANSACTION_GREEN_IDX] = ledbar->led_green.brightness;
-       led_msg[UBNT_LEDBAR_TRANSACTION_RED_IDX] = ledbar->led_red.brightness;
-       led_msg[UBNT_LEDBAR_TRANSACTION_LED_COUNT_IDX] = ledbar->led_count;
-
-       gpiod_set_value(ledbar->enable_gpio, 1);
-
-       msleep(10);
-
-       ubnt_ledbar_perform_transaction(ledbar, setup_msg, sizeof(setup_msg), &i2c_response, sizeof(i2c_response));
-       if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) {
-               dev_err(&ledbar->client->dev, "Error initializing LED transaction: %02hhx\n", i2c_response);
-               ret = -EINVAL;
-               goto out_gpio;
-       }
-
-       ubnt_ledbar_perform_transaction(ledbar, led_msg, sizeof(led_msg), &i2c_response, sizeof(i2c_response));
-       if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) {
-               dev_err(&ledbar->client->dev, "Failed LED transaction: %02hhx\n", i2c_response);
-               ret = -EINVAL;
-               goto out_gpio;
-       }
-
-       msleep(10);
-out_gpio:
-       gpiod_set_value(ledbar->enable_gpio, 0);
-
-       mutex_unlock(&ledbar->lock);
-
-       return ret;
-}
-
-static void ubnt_ledbar_reset(struct ubnt_ledbar *ledbar)
-{
-       static const char init_msg[16] = {0x02, 0x81, 0xfd, 0x7e,
-                                         0x00, 0x00, 0x00, 0x00,
-                                         0x00, 0x00, 0x00, 0x00,
-                                         0x00, 0x00, 0x00, 0x00};
-       char init_response[4];
-
-       if (!ledbar->reset_gpio)
-               return;
-
-       mutex_lock(&ledbar->lock);
-
-       gpiod_set_value(ledbar->reset_gpio, 1);
-       msleep(10);
-       gpiod_set_value(ledbar->reset_gpio, 0);
-
-       msleep(10);
-
-       gpiod_set_value(ledbar->enable_gpio, 1);
-       msleep(10);
-       ubnt_ledbar_perform_transaction(ledbar, init_msg, sizeof(init_msg), init_response, sizeof(init_response));
-       msleep(10);
-       gpiod_set_value(ledbar->enable_gpio, 0);
-
-       mutex_unlock(&ledbar->lock);
-}
-
-#define UBNT_LEDBAR_CONTROL_RGBS(name)                         \
-static int ubnt_ledbar_set_##name##_brightness(struct led_classdev *led_cdev,\
-                                       enum led_brightness value)      \
-{                                                                      \
-       struct ubnt_ledbar *ledbar = \
-                       container_of(led_cdev, struct ubnt_ledbar, led_##name); \
-       int ret; \
-       led_cdev->brightness = value; \
-       ret = ubnt_ledbar_apply_state(ledbar); \
-       return ret; \
-}
-
-UBNT_LEDBAR_CONTROL_RGBS(red);
-UBNT_LEDBAR_CONTROL_RGBS(green);
-UBNT_LEDBAR_CONTROL_RGBS(blue);
-
-
-static int ubnt_ledbar_init_led(struct device_node *np, struct ubnt_ledbar *ledbar,
-                               struct led_classdev *led_cdev)
-{
-       struct led_init_data init_data = {};
-       int ret;
-
-       if (!np)
-               return 0;
-
-       init_data.fwnode = of_fwnode_handle(np);
-
-       led_cdev->max_brightness = UBNT_LEDBAR_MAX_BRIGHTNESS;
-
-       ret = devm_led_classdev_register_ext(&ledbar->client->dev, led_cdev,
-                                            &init_data);
-       if (ret)
-               dev_err(&ledbar->client->dev, "led register err: %d\n", ret);
-
-       return ret;
-}
-
-
-static int ubnt_ledbar_probe(struct i2c_client *client,
-                            const struct i2c_device_id *id)
-{
-       struct device_node *np = client->dev.of_node;
-       struct ubnt_ledbar *ledbar;
-       int ret;
-
-       ledbar = devm_kzalloc(&client->dev, sizeof(*ledbar), GFP_KERNEL);
-       if (!ledbar)
-               return -ENOMEM;
-
-       ledbar->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
-
-       if (IS_ERR(ledbar->enable_gpio)) {
-               ret = PTR_ERR(ledbar->enable_gpio);
-               dev_err(&client->dev, "Failed to get enable gpio: %d\n", ret);
-               return ret;
-       }
-
-       ledbar->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW);
-
-       if (IS_ERR(ledbar->reset_gpio)) {
-               ret = PTR_ERR(ledbar->reset_gpio);
-               dev_err(&client->dev, "Failed to get reset gpio: %d\n", ret);
-               return ret;
-       }
-
-       ledbar->led_count = 1;
-       of_property_read_u32(np, "led-count", &ledbar->led_count);
-
-       ledbar->client = client;
-
-       mutex_init(&ledbar->lock);
-
-       i2c_set_clientdata(client, ledbar);
-
-       // Reset and initialize the MCU
-       ubnt_ledbar_reset(ledbar);
-
-       ledbar->led_red.brightness_set_blocking = ubnt_ledbar_set_red_brightness;
-       ubnt_ledbar_init_led(of_get_child_by_name(np, "red"), ledbar, &ledbar->led_red);
-
-       ledbar->led_green.brightness_set_blocking = ubnt_ledbar_set_green_brightness;
-       ubnt_ledbar_init_led(of_get_child_by_name(np, "green"), ledbar, &ledbar->led_green);
-
-       ledbar->led_blue.brightness_set_blocking = ubnt_ledbar_set_blue_brightness;
-       ubnt_ledbar_init_led(of_get_child_by_name(np, "blue"), ledbar, &ledbar->led_blue);
-
-       return ubnt_ledbar_apply_state(ledbar);
-}
-
-static int ubnt_ledbar_remove(struct i2c_client *client)
-{
-       struct ubnt_ledbar *ledbar = i2c_get_clientdata(client);
-
-       mutex_destroy(&ledbar->lock);
-
-       return 0;
-}
-
-static const struct i2c_device_id ubnt_ledbar_id[] = {
-       { "ubnt-ledbar", 0 },
-       { }
-};
-MODULE_DEVICE_TABLE(i2c, ubnt_ledbar_id);
-
-static const struct of_device_id of_ubnt_ledbar_match[] = {
-       { .compatible = "ubnt,ledbar", },
-       {},
-};
-MODULE_DEVICE_TABLE(of, of_ubnt_ledbar_match);
-
-static struct i2c_driver ubnt_ledbar_driver = {
-       .driver = {
-               .name   = "ubnt-ledbar",
-               .of_match_table = of_ubnt_ledbar_match,
-       },
-       .probe          = ubnt_ledbar_probe,
-       .remove         = ubnt_ledbar_remove,
-       .id_table       = ubnt_ledbar_id,
-};
-module_i2c_driver(ubnt_ledbar_driver);
-
-MODULE_DESCRIPTION("Ubiquiti LEDBAR driver");
-MODULE_AUTHOR("David Bauer <mail@david-bauer.net>");
-MODULE_LICENSE("GPL v2");
diff --git a/target/linux/generic/hack-5.10/800-ubnt-ledbar-driver.patch b/target/linux/generic/hack-5.10/800-ubnt-ledbar-driver.patch
deleted file mode 100644 (file)
index 2b4baab..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
---- a/drivers/leds/Kconfig
-+++ b/drivers/leds/Kconfig
-@@ -931,6 +931,16 @@ config LEDS_ACER_A500
- source "drivers/leds/blink/Kconfig"
-+config LEDS_UBNT_LEDBAR
-+      tristate "LED support for Ubiquiti UniFi 6 LR"
-+      depends on LEDS_CLASS && I2C && OF
-+      help
-+        This option enables support for the Ubiquiti LEDBAR
-+        LED driver.
-+
-+        To compile this driver as a module, choose M here: the module
-+        will be called leds-ubnt-ledbar.
-+
- comment "LED Triggers"
- source "drivers/leds/trigger/Kconfig"
---- a/drivers/leds/Makefile
-+++ b/drivers/leds/Makefile
-@@ -93,6 +93,7 @@ obj-$(CONFIG_LEDS_TURRIS_OMNIA)              += leds
- obj-$(CONFIG_LEDS_WM831X_STATUS)      += leds-wm831x-status.o
- obj-$(CONFIG_LEDS_WM8350)             += leds-wm8350.o
- obj-$(CONFIG_LEDS_WRAP)                       += leds-wrap.o
-+obj-$(CONFIG_LEDS_UBNT_LEDBAR)                += leds-ubnt-ledbar.o
- # LED SPI Drivers
- obj-$(CONFIG_LEDS_CR0014114)          += leds-cr0014114.o
diff --git a/target/linux/generic/hack-5.15/800-ubnt-ledbar-driver.patch b/target/linux/generic/hack-5.15/800-ubnt-ledbar-driver.patch
deleted file mode 100644 (file)
index 146e6ae..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
---- a/drivers/leds/Kconfig
-+++ b/drivers/leds/Kconfig
-@@ -876,6 +876,16 @@ source "drivers/leds/blink/Kconfig"
- comment "Flash and Torch LED drivers"
- source "drivers/leds/flash/Kconfig"
-+config LEDS_UBNT_LEDBAR
-+      tristate "LED support for Ubiquiti UniFi 6 LR"
-+      depends on LEDS_CLASS && I2C && OF
-+      help
-+        This option enables support for the Ubiquiti LEDBAR
-+        LED driver.
-+
-+        To compile this driver as a module, choose M here: the module
-+        will be called leds-ubnt-ledbar.
-+
- comment "LED Triggers"
- source "drivers/leds/trigger/Kconfig"
---- a/drivers/leds/Makefile
-+++ b/drivers/leds/Makefile
-@@ -87,6 +87,7 @@ obj-$(CONFIG_LEDS_TURRIS_OMNIA)              += leds
- obj-$(CONFIG_LEDS_WM831X_STATUS)      += leds-wm831x-status.o
- obj-$(CONFIG_LEDS_WM8350)             += leds-wm8350.o
- obj-$(CONFIG_LEDS_WRAP)                       += leds-wrap.o
-+obj-$(CONFIG_LEDS_UBNT_LEDBAR)                += leds-ubnt-ledbar.o
- # LED SPI Drivers
- obj-$(CONFIG_LEDS_CR0014114)          += leds-cr0014114.o
index 963815b2649f6d4ee378edc8d4cc2ec9de87424d..558894e5e56b7588f911a094e3e16ef4a77cd484 100644 (file)
@@ -197,7 +197,6 @@ CONFIG_IRQ_TIME_ACCOUNTING=y
 CONFIG_IRQ_WORK=y
 CONFIG_JBD2=y
 CONFIG_JUMP_LABEL=y
-# CONFIG_LEDS_UBNT_LEDBAR is not set
 CONFIG_LIBFDT=y
 CONFIG_LOCK_DEBUGGING_SUPPORT=y
 CONFIG_LOCK_SPIN_ON_OWNER=y
index 0eb2866cf060441dc85c88fda3102e6b003e1fca..42f2d7d832752e66892ceead959daf7a5c4b6600 100644 (file)
@@ -39,18 +39,4 @@ endef
 
 $(eval $(call KernelPackage,sdhci-mtk))
 
-define KernelPackage/leds-ubnt-ledbar
-  SUBMENU:=LED modules
-  TITLE:=Ubiquiti UniFi 6 LR LED support
-  KCONFIG:=CONFIG_LEDS_UBNT_LEDBAR
-  FILES:= \
-       $(LINUX_DIR)/drivers/leds/leds-ubnt-ledbar.ko
-  AUTOLOAD:=$(call AutoProbe,leds-ubnt-ledbar,1)
-  DEPENDS:=@TARGET_mediatek_mt7622 +kmod-i2c-core
-endef
-
-define KernelPackage/leds-ubnt-ledbar/description
-  LED support for Ubiquiti UniFi 6 LR
-endef
 
-$(eval $(call KernelPackage,leds-ubnt-ledbar))
index 213fce2c363b8980d03efd4ea8b060bda38c7cf8..1b415f3e665bbd2d869b416dcbd691a568b2ab85 100644 (file)
@@ -110,7 +110,6 @@ CONFIG_IRQ_MIPS_CPU=y
 CONFIG_IRQ_WORK=y
 # CONFIG_KERNEL_ZSTD is not set
 CONFIG_LED_TRIGGER_PHY=y
-CONFIG_LEDS_UBNT_LEDBAR=y
 CONFIG_LIBFDT=y
 CONFIG_LOCK_DEBUGGING_SUPPORT=y
 CONFIG_LZO_COMPRESS=y
index 79f0a9bc15802bdc04cb02214d469560ffa43c7d..a8094fe305b2ab79aa2ac4161353d6285dfc6f6e 100644 (file)
@@ -111,7 +111,6 @@ CONFIG_IRQ_FORCED_THREADING=y
 CONFIG_IRQ_MIPS_CPU=y
 CONFIG_IRQ_WORK=y
 CONFIG_KMAP_LOCAL=y
-CONFIG_LEDS_UBNT_LEDBAR=y
 CONFIG_LED_TRIGGER_PHY=y
 CONFIG_LIBFDT=y
 CONFIG_LOCK_DEBUGGING_SUPPORT=y