Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 2 | /* |
| 3 | * leds-ns2.c - Driver for the Network Space v2 (and parents) dual-GPIO LED |
| 4 | * |
| 5 | * Copyright (C) 2010 LaCie |
| 6 | * |
| 7 | * Author: Simon Guinot <sguinot@lacie.com> |
| 8 | * |
| 9 | * Based on leds-gpio.c by Raphael Assenat <raph@8d.com> |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <linux/kernel.h> |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/slab.h> |
Linus Walleij | c789649 | 2020-01-07 15:10:28 +0100 | [diff] [blame] | 15 | #include <linux/gpio/consumer.h> |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 16 | #include <linux/leds.h> |
Paul Gortmaker | 54f4ded | 2011-07-03 13:56:03 -0400 | [diff] [blame] | 17 | #include <linux/module.h> |
Sachin Kamat | c68f46d | 2013-09-28 04:38:30 -0700 | [diff] [blame] | 18 | #include <linux/of.h> |
Simon Guinot | 4b90432 | 2015-07-02 19:56:42 +0200 | [diff] [blame] | 19 | #include "leds.h" |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 20 | |
Linus Walleij | c789649 | 2020-01-07 15:10:28 +0100 | [diff] [blame] | 21 | enum ns2_led_modes { |
| 22 | NS_V2_LED_OFF, |
| 23 | NS_V2_LED_ON, |
| 24 | NS_V2_LED_SATA, |
| 25 | }; |
| 26 | |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 27 | /* |
| 28 | * If the size of this structure or types of its members is changed, |
| 29 | * the filling of array modval in function ns2_led_register must be changed |
| 30 | * accordingly. |
| 31 | */ |
Linus Walleij | c789649 | 2020-01-07 15:10:28 +0100 | [diff] [blame] | 32 | struct ns2_led_modval { |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 33 | u32 mode; |
| 34 | u32 cmd_level; |
| 35 | u32 slow_level; |
| 36 | } __packed; |
Linus Walleij | c789649 | 2020-01-07 15:10:28 +0100 | [diff] [blame] | 37 | |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 38 | /* |
Vincent Donnefort | f7fafd0 | 2015-07-02 19:56:40 +0200 | [diff] [blame] | 39 | * The Network Space v2 dual-GPIO LED is wired to a CPLD. Three different LED |
| 40 | * modes are available: off, on and SATA activity blinking. The LED modes are |
| 41 | * controlled through two GPIOs (command and slow): each combination of values |
| 42 | * for the command/slow GPIOs corresponds to a LED mode. |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 43 | */ |
| 44 | |
Marek Behún | 01026ce | 2020-09-18 00:33:29 +0200 | [diff] [blame] | 45 | struct ns2_led { |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 46 | struct led_classdev cdev; |
Linus Walleij | ccbbb11 | 2020-01-07 15:10:29 +0100 | [diff] [blame] | 47 | struct gpio_desc *cmd; |
| 48 | struct gpio_desc *slow; |
Simon Guinot | 4b90432 | 2015-07-02 19:56:42 +0200 | [diff] [blame] | 49 | bool can_sleep; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 50 | unsigned char sata; /* True when SATA mode active. */ |
| 51 | rwlock_t rw_lock; /* Lock GPIOs. */ |
Vincent Donnefort | f7fafd0 | 2015-07-02 19:56:40 +0200 | [diff] [blame] | 52 | int num_modes; |
| 53 | struct ns2_led_modval *modval; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 54 | }; |
| 55 | |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 56 | static int ns2_led_get_mode(struct ns2_led *led, enum ns2_led_modes *mode) |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 57 | { |
| 58 | int i; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 59 | int cmd_level; |
| 60 | int slow_level; |
| 61 | |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 62 | cmd_level = gpiod_get_value_cansleep(led->cmd); |
| 63 | slow_level = gpiod_get_value_cansleep(led->slow); |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 64 | |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 65 | for (i = 0; i < led->num_modes; i++) { |
| 66 | if (cmd_level == led->modval[i].cmd_level && |
| 67 | slow_level == led->modval[i].slow_level) { |
| 68 | *mode = led->modval[i].mode; |
Marek Behún | a2fc703 | 2020-09-18 00:33:31 +0200 | [diff] [blame] | 69 | return 0; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 70 | } |
| 71 | } |
| 72 | |
Marek Behún | a2fc703 | 2020-09-18 00:33:31 +0200 | [diff] [blame] | 73 | return -EINVAL; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 74 | } |
| 75 | |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 76 | static void ns2_led_set_mode(struct ns2_led *led, enum ns2_led_modes mode) |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 77 | { |
| 78 | int i; |
Simon Guinot | f539dfe | 2010-09-19 15:30:59 +0200 | [diff] [blame] | 79 | unsigned long flags; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 80 | |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 81 | for (i = 0; i < led->num_modes; i++) |
Marek Behún | 48b77cd | 2020-09-18 00:33:34 +0200 | [diff] [blame] | 82 | if (mode == led->modval[i].mode) |
Simon Guinot | 4b90432 | 2015-07-02 19:56:42 +0200 | [diff] [blame] | 83 | break; |
Simon Guinot | 4b90432 | 2015-07-02 19:56:42 +0200 | [diff] [blame] | 84 | |
Marek Behún | 48b77cd | 2020-09-18 00:33:34 +0200 | [diff] [blame] | 85 | if (i == led->num_modes) |
Simon Guinot | 4b90432 | 2015-07-02 19:56:42 +0200 | [diff] [blame] | 86 | return; |
| 87 | |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 88 | write_lock_irqsave(&led->rw_lock, flags); |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 89 | |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 90 | if (!led->can_sleep) { |
| 91 | gpiod_set_value(led->cmd, led->modval[i].cmd_level); |
| 92 | gpiod_set_value(led->slow, led->modval[i].slow_level); |
Simon Guinot | 4b90432 | 2015-07-02 19:56:42 +0200 | [diff] [blame] | 93 | goto exit_unlock; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 94 | } |
| 95 | |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 96 | gpiod_set_value_cansleep(led->cmd, led->modval[i].cmd_level); |
| 97 | gpiod_set_value_cansleep(led->slow, led->modval[i].slow_level); |
Simon Guinot | 4b90432 | 2015-07-02 19:56:42 +0200 | [diff] [blame] | 98 | |
| 99 | exit_unlock: |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 100 | write_unlock_irqrestore(&led->rw_lock, flags); |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | static void ns2_led_set(struct led_classdev *led_cdev, |
| 104 | enum led_brightness value) |
| 105 | { |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 106 | struct ns2_led *led = container_of(led_cdev, struct ns2_led, cdev); |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 107 | enum ns2_led_modes mode; |
| 108 | |
| 109 | if (value == LED_OFF) |
| 110 | mode = NS_V2_LED_OFF; |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 111 | else if (led->sata) |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 112 | mode = NS_V2_LED_SATA; |
| 113 | else |
| 114 | mode = NS_V2_LED_ON; |
| 115 | |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 116 | ns2_led_set_mode(led, mode); |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 117 | } |
| 118 | |
Jacek Anaszewski | c29e650 | 2015-11-20 11:39:41 +0100 | [diff] [blame] | 119 | static int ns2_led_set_blocking(struct led_classdev *led_cdev, |
| 120 | enum led_brightness value) |
| 121 | { |
| 122 | ns2_led_set(led_cdev, value); |
| 123 | return 0; |
| 124 | } |
| 125 | |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 126 | static ssize_t ns2_led_sata_store(struct device *dev, |
| 127 | struct device_attribute *attr, |
| 128 | const char *buff, size_t count) |
| 129 | { |
Simon Guinot | e5971bb | 2010-10-07 16:35:40 +0200 | [diff] [blame] | 130 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 131 | struct ns2_led *led = container_of(led_cdev, struct ns2_led, cdev); |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 132 | int ret; |
| 133 | unsigned long enable; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 134 | |
Jingoo Han | 3874350 | 2012-10-23 05:25:35 -0700 | [diff] [blame] | 135 | ret = kstrtoul(buff, 10, &enable); |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 136 | if (ret < 0) |
| 137 | return ret; |
| 138 | |
| 139 | enable = !!enable; |
| 140 | |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 141 | if (led->sata == enable) |
Simon Guinot | 4b90432 | 2015-07-02 19:56:42 +0200 | [diff] [blame] | 142 | goto exit; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 143 | |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 144 | led->sata = enable; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 145 | |
Simon Guinot | 4b90432 | 2015-07-02 19:56:42 +0200 | [diff] [blame] | 146 | if (!led_get_brightness(led_cdev)) |
| 147 | goto exit; |
| 148 | |
| 149 | if (enable) |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 150 | ns2_led_set_mode(led, NS_V2_LED_SATA); |
Simon Guinot | 4b90432 | 2015-07-02 19:56:42 +0200 | [diff] [blame] | 151 | else |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 152 | ns2_led_set_mode(led, NS_V2_LED_ON); |
Simon Guinot | 4b90432 | 2015-07-02 19:56:42 +0200 | [diff] [blame] | 153 | |
| 154 | exit: |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 155 | return count; |
| 156 | } |
| 157 | |
| 158 | static ssize_t ns2_led_sata_show(struct device *dev, |
| 159 | struct device_attribute *attr, char *buf) |
| 160 | { |
Simon Guinot | e5971bb | 2010-10-07 16:35:40 +0200 | [diff] [blame] | 161 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 162 | struct ns2_led *led = container_of(led_cdev, struct ns2_led, cdev); |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 163 | |
Marek Behún | a78bd8f | 2020-09-18 00:33:30 +0200 | [diff] [blame] | 164 | return sprintf(buf, "%d\n", led->sata); |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | static DEVICE_ATTR(sata, 0644, ns2_led_sata_show, ns2_led_sata_store); |
| 168 | |
Johan Hovold | 475f854 | 2014-06-25 10:08:51 -0700 | [diff] [blame] | 169 | static struct attribute *ns2_led_attrs[] = { |
| 170 | &dev_attr_sata.attr, |
| 171 | NULL |
| 172 | }; |
| 173 | ATTRIBUTE_GROUPS(ns2_led); |
| 174 | |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 175 | static int ns2_led_register(struct device *dev, struct fwnode_handle *node, |
Marek Behún | a4a469b | 2020-09-18 00:33:33 +0200 | [diff] [blame] | 176 | struct ns2_led *led) |
Marek Behún | f72deb7 | 2020-09-18 00:33:27 +0200 | [diff] [blame] | 177 | { |
Marek Behún | f847ef5 | 2020-09-18 00:33:37 +0200 | [diff] [blame] | 178 | struct led_init_data init_data = {}; |
Marek Behún | f72deb7 | 2020-09-18 00:33:27 +0200 | [diff] [blame] | 179 | struct ns2_led_modval *modval; |
Marek Behún | a4a469b | 2020-09-18 00:33:33 +0200 | [diff] [blame] | 180 | enum ns2_led_modes mode; |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 181 | int nmodes, ret; |
Marek Behún | f72deb7 | 2020-09-18 00:33:27 +0200 | [diff] [blame] | 182 | |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 183 | led->cmd = devm_fwnode_gpiod_get_index(dev, node, "cmd", 0, GPIOD_ASIS, |
| 184 | fwnode_get_name(node)); |
Marek Behún | f72deb7 | 2020-09-18 00:33:27 +0200 | [diff] [blame] | 185 | if (IS_ERR(led->cmd)) |
| 186 | return PTR_ERR(led->cmd); |
| 187 | |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 188 | led->slow = devm_fwnode_gpiod_get_index(dev, node, "slow", 0, |
| 189 | GPIOD_ASIS, |
| 190 | fwnode_get_name(node)); |
Marek Behún | f72deb7 | 2020-09-18 00:33:27 +0200 | [diff] [blame] | 191 | if (IS_ERR(led->slow)) |
| 192 | return PTR_ERR(led->slow); |
| 193 | |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 194 | ret = fwnode_property_count_u32(node, "modes-map"); |
Marek Behún | f72deb7 | 2020-09-18 00:33:27 +0200 | [diff] [blame] | 195 | if (ret < 0 || ret % 3) { |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 196 | dev_err(dev, "Missing or malformed modes-map for %pfw\n", node); |
Marek Behún | f72deb7 | 2020-09-18 00:33:27 +0200 | [diff] [blame] | 197 | return -EINVAL; |
| 198 | } |
| 199 | |
| 200 | nmodes = ret / 3; |
| 201 | modval = devm_kcalloc(dev, nmodes, sizeof(*modval), GFP_KERNEL); |
| 202 | if (!modval) |
| 203 | return -ENOMEM; |
| 204 | |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 205 | fwnode_property_read_u32_array(node, "modes-map", (void *)modval, |
| 206 | nmodes * 3); |
Marek Behún | f72deb7 | 2020-09-18 00:33:27 +0200 | [diff] [blame] | 207 | |
Marek Behún | a4a469b | 2020-09-18 00:33:33 +0200 | [diff] [blame] | 208 | rwlock_init(&led->rw_lock); |
| 209 | |
| 210 | led->cdev.blink_set = NULL; |
| 211 | led->cdev.flags |= LED_CORE_SUSPENDRESUME; |
| 212 | led->cdev.groups = ns2_led_groups; |
| 213 | led->can_sleep = gpiod_cansleep(led->cmd) || gpiod_cansleep(led->slow); |
| 214 | if (led->can_sleep) |
| 215 | led->cdev.brightness_set_blocking = ns2_led_set_blocking; |
| 216 | else |
| 217 | led->cdev.brightness_set = ns2_led_set; |
Marek Behún | f72deb7 | 2020-09-18 00:33:27 +0200 | [diff] [blame] | 218 | led->num_modes = nmodes; |
| 219 | led->modval = modval; |
| 220 | |
Marek Behún | a4a469b | 2020-09-18 00:33:33 +0200 | [diff] [blame] | 221 | ret = ns2_led_get_mode(led, &mode); |
| 222 | if (ret < 0) |
| 223 | return ret; |
Marek Behún | f72deb7 | 2020-09-18 00:33:27 +0200 | [diff] [blame] | 224 | |
Marek Behún | a4a469b | 2020-09-18 00:33:33 +0200 | [diff] [blame] | 225 | /* Set LED initial state. */ |
| 226 | led->sata = (mode == NS_V2_LED_SATA) ? 1 : 0; |
| 227 | led->cdev.brightness = (mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL; |
Simon Guinot | 72052fc | 2012-10-17 12:09:03 +0200 | [diff] [blame] | 228 | |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 229 | init_data.fwnode = node; |
Marek Behún | f847ef5 | 2020-09-18 00:33:37 +0200 | [diff] [blame] | 230 | |
| 231 | ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); |
Marek Behún | a4a469b | 2020-09-18 00:33:33 +0200 | [diff] [blame] | 232 | if (ret) |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 233 | dev_err(dev, "Failed to register LED for node %pfw\n", node); |
Simon Guinot | 72052fc | 2012-10-17 12:09:03 +0200 | [diff] [blame] | 234 | |
Marek Behún | a4a469b | 2020-09-18 00:33:33 +0200 | [diff] [blame] | 235 | return ret; |
Simon Guinot | 72052fc | 2012-10-17 12:09:03 +0200 | [diff] [blame] | 236 | } |
| 237 | |
Bill Pemberton | 98ea1ea | 2012-11-19 13:23:02 -0500 | [diff] [blame] | 238 | static int ns2_led_probe(struct platform_device *pdev) |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 239 | { |
Marek Behún | b3f9692 | 2020-09-18 00:33:32 +0200 | [diff] [blame] | 240 | struct device *dev = &pdev->dev; |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 241 | struct fwnode_handle *child; |
Marek Behún | 01026ce | 2020-09-18 00:33:29 +0200 | [diff] [blame] | 242 | struct ns2_led *leds; |
Marek Behún | a4a469b | 2020-09-18 00:33:33 +0200 | [diff] [blame] | 243 | int count; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 244 | int ret; |
| 245 | |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 246 | count = device_get_child_node_count(dev); |
Marek Behún | a4a469b | 2020-09-18 00:33:33 +0200 | [diff] [blame] | 247 | if (!count) |
| 248 | return -ENODEV; |
Simon Guinot | 72052fc | 2012-10-17 12:09:03 +0200 | [diff] [blame] | 249 | |
Marek Behún | a4a469b | 2020-09-18 00:33:33 +0200 | [diff] [blame] | 250 | leds = devm_kzalloc(dev, array_size(sizeof(*leds), count), GFP_KERNEL); |
Marek Behún | 19d4deb | 2020-09-18 00:33:25 +0200 | [diff] [blame] | 251 | if (!leds) |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 252 | return -ENOMEM; |
| 253 | |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 254 | device_for_each_child_node(dev, child) { |
Marek Behún | a4a469b | 2020-09-18 00:33:33 +0200 | [diff] [blame] | 255 | ret = ns2_led_register(dev, child, leds++); |
| 256 | if (ret) { |
Marek Behún | 940cca1 | 2020-09-26 22:11:30 +0200 | [diff] [blame] | 257 | fwnode_handle_put(child); |
Bryan Wu | a209f76 | 2012-07-04 12:30:50 +0800 | [diff] [blame] | 258 | return ret; |
Marek Behún | a4a469b | 2020-09-18 00:33:33 +0200 | [diff] [blame] | 259 | } |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 260 | } |
| 261 | |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 262 | return 0; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 263 | } |
| 264 | |
Marek Behún | 8fd8f94 | 2020-09-26 22:11:31 +0200 | [diff] [blame] | 265 | static const struct of_device_id of_ns2_leds_match[] = { |
| 266 | { .compatible = "lacie,ns2-leds", }, |
| 267 | {}, |
| 268 | }; |
| 269 | MODULE_DEVICE_TABLE(of, of_ns2_leds_match); |
| 270 | |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 271 | static struct platform_driver ns2_led_driver = { |
| 272 | .probe = ns2_led_probe, |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 273 | .driver = { |
Simon Guinot | 72052fc | 2012-10-17 12:09:03 +0200 | [diff] [blame] | 274 | .name = "leds-ns2", |
Marek Behún | 8fd8f94 | 2020-09-26 22:11:31 +0200 | [diff] [blame] | 275 | .of_match_table = of_ns2_leds_match, |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 276 | }, |
| 277 | }; |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 278 | |
Axel Lin | 892a884 | 2012-01-10 15:09:24 -0800 | [diff] [blame] | 279 | module_platform_driver(ns2_led_driver); |
Simon Guinot | 11efe71 | 2010-07-06 16:08:46 +0200 | [diff] [blame] | 280 | |
| 281 | MODULE_AUTHOR("Simon Guinot <sguinot@lacie.com>"); |
| 282 | MODULE_DESCRIPTION("Network Space v2 LED driver"); |
| 283 | MODULE_LICENSE("GPL"); |
Axel Lin | 892a884 | 2012-01-10 15:09:24 -0800 | [diff] [blame] | 284 | MODULE_ALIAS("platform:leds-ns2"); |