1 // SPDX-License-Identifier: GPL-2.0+
3 * Driver for controlling LEDs for cameras connected to the Intel atomisp2
4 * The main purpose of this driver is to turn off LEDs which are on at boot.
10 #include <linux/gpio/consumer.h>
11 #include <linux/gpio/machine.h>
12 #include <linux/leds.h>
13 #include <linux/module.h>
14 #include <linux/mod_devicetable.h>
15 #include <linux/platform_device.h>
16 #include <linux/workqueue.h>
18 /* This must be leds-gpio as the leds-gpio driver binds to the name */
19 #define DEV_NAME "leds-gpio"
21 static const struct gpio_led atomisp2_leds[] = {
23 .name = "atomisp2::camera",
24 .default_state = LEDS_GPIO_DEFSTATE_OFF,
28 static const struct gpio_led_platform_data atomisp2_leds_pdata = {
29 .num_leds = ARRAY_SIZE(atomisp2_leds),
30 .leds = atomisp2_leds,
33 static struct gpiod_lookup_table asus_t100ta_lookup = {
36 GPIO_LOOKUP_IDX("INT33FC:02", 8, NULL, 0, GPIO_ACTIVE_HIGH),
41 static struct gpiod_lookup_table asus_t100chi_lookup = {
44 GPIO_LOOKUP_IDX("INT33FC:01", 24, NULL, 0, GPIO_ACTIVE_HIGH),
49 static const struct dmi_system_id atomisp2_led_systems[] __initconst = {
52 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
53 /* Non exact match to also match T100TAF */
54 DMI_MATCH(DMI_PRODUCT_NAME, "T100TA"),
56 .driver_data = &asus_t100ta_lookup,
60 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
61 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T200TA"),
63 .driver_data = &asus_t100ta_lookup,
67 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
68 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100CHI"),
70 .driver_data = &asus_t100chi_lookup,
72 {} /* Terminating entry */
74 MODULE_DEVICE_TABLE(dmi, atomisp2_led_systems);
76 static struct gpiod_lookup_table *gpio_lookup;
77 static struct platform_device *pdev;
79 static int __init atomisp2_led_init(void)
81 const struct dmi_system_id *system;
83 system = dmi_first_match(atomisp2_led_systems);
87 gpio_lookup = system->driver_data;
88 gpiod_add_lookup_table(gpio_lookup);
90 pdev = platform_device_register_resndata(NULL,
91 DEV_NAME, PLATFORM_DEVID_NONE,
92 NULL, 0, &atomisp2_leds_pdata,
93 sizeof(atomisp2_leds_pdata));
95 gpiod_remove_lookup_table(gpio_lookup);
97 return PTR_ERR_OR_ZERO(pdev);
100 static void __exit atomisp2_led_cleanup(void)
102 platform_device_unregister(pdev);
103 gpiod_remove_lookup_table(gpio_lookup);
106 module_init(atomisp2_led_init);
107 module_exit(atomisp2_led_cleanup);
110 * The ACPI INIT method from Asus WMI's code on the T100TA and T200TA turns the
111 * LED on (without the WMI interface allowing further control over the LED).
112 * Ensure we are loaded after asus-nb-wmi so that we turn the LED off again.
114 MODULE_SOFTDEP("pre: asus_nb_wmi");
116 MODULE_DESCRIPTION("Intel atomisp2 camera LED driver");
117 MODULE_LICENSE("GPL");