Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | // TI LM3697 LED chip family driver |
Alexander A. Klimov | c543733 | 2020-07-13 16:51:15 +0200 | [diff] [blame] | 3 | // Copyright (C) 2018 Texas Instruments Incorporated - https://www.ti.com/ |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 4 | |
| 5 | #include <linux/gpio/consumer.h> |
| 6 | #include <linux/i2c.h> |
| 7 | #include <linux/of.h> |
| 8 | #include <linux/of_gpio.h> |
| 9 | #include <linux/regulator/consumer.h> |
| 10 | #include <linux/leds-ti-lmu-common.h> |
| 11 | |
| 12 | #define LM3697_REV 0x0 |
| 13 | #define LM3697_RESET 0x1 |
| 14 | #define LM3697_OUTPUT_CONFIG 0x10 |
| 15 | #define LM3697_CTRL_A_RAMP 0x11 |
| 16 | #define LM3697_CTRL_B_RAMP 0x12 |
| 17 | #define LM3697_CTRL_A_B_RT_RAMP 0x13 |
| 18 | #define LM3697_CTRL_A_B_RAMP_CFG 0x14 |
| 19 | #define LM3697_CTRL_A_B_BRT_CFG 0x16 |
| 20 | #define LM3697_CTRL_A_FS_CURR_CFG 0x17 |
| 21 | #define LM3697_CTRL_B_FS_CURR_CFG 0x18 |
| 22 | #define LM3697_PWM_CFG 0x1c |
| 23 | #define LM3697_CTRL_A_BRT_LSB 0x20 |
| 24 | #define LM3697_CTRL_A_BRT_MSB 0x21 |
| 25 | #define LM3697_CTRL_B_BRT_LSB 0x22 |
| 26 | #define LM3697_CTRL_B_BRT_MSB 0x23 |
| 27 | #define LM3697_CTRL_ENABLE 0x24 |
| 28 | |
| 29 | #define LM3697_SW_RESET BIT(0) |
| 30 | |
| 31 | #define LM3697_CTRL_A_EN BIT(0) |
| 32 | #define LM3697_CTRL_B_EN BIT(1) |
| 33 | #define LM3697_CTRL_A_B_EN (LM3697_CTRL_A_EN | LM3697_CTRL_B_EN) |
| 34 | |
| 35 | #define LM3697_MAX_LED_STRINGS 3 |
| 36 | |
| 37 | #define LM3697_CONTROL_A 0 |
| 38 | #define LM3697_CONTROL_B 1 |
| 39 | #define LM3697_MAX_CONTROL_BANKS 2 |
| 40 | |
| 41 | /** |
| 42 | * struct lm3697_led - |
| 43 | * @hvled_strings: Array of LED strings associated with a control bank |
| 44 | * @label: LED label |
| 45 | * @led_dev: LED class device |
| 46 | * @priv: Pointer to the device struct |
| 47 | * @lmu_data: Register and setting values for common code |
| 48 | * @control_bank: Control bank the LED is associated to. 0 is control bank A |
| 49 | * 1 is control bank B |
| 50 | */ |
| 51 | struct lm3697_led { |
| 52 | u32 hvled_strings[LM3697_MAX_LED_STRINGS]; |
| 53 | char label[LED_MAX_NAME_SIZE]; |
| 54 | struct led_classdev led_dev; |
| 55 | struct lm3697 *priv; |
| 56 | struct ti_lmu_bank lmu_data; |
| 57 | int control_bank; |
| 58 | int enabled; |
| 59 | int num_leds; |
| 60 | }; |
| 61 | |
| 62 | /** |
| 63 | * struct lm3697 - |
| 64 | * @enable_gpio: Hardware enable gpio |
| 65 | * @regulator: LED supply regulator pointer |
| 66 | * @client: Pointer to the I2C client |
| 67 | * @regmap: Devices register map |
| 68 | * @dev: Pointer to the devices device struct |
| 69 | * @lock: Lock for reading/writing the device |
| 70 | * @leds: Array of LED strings |
| 71 | */ |
| 72 | struct lm3697 { |
| 73 | struct gpio_desc *enable_gpio; |
| 74 | struct regulator *regulator; |
| 75 | struct i2c_client *client; |
| 76 | struct regmap *regmap; |
| 77 | struct device *dev; |
| 78 | struct mutex lock; |
| 79 | |
| 80 | int bank_cfg; |
Gabriel David | 98d278ca00 | 2020-10-02 18:27:00 -0400 | [diff] [blame] | 81 | int num_banks; |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 82 | |
| 83 | struct lm3697_led leds[]; |
| 84 | }; |
| 85 | |
| 86 | static const struct reg_default lm3697_reg_defs[] = { |
| 87 | {LM3697_OUTPUT_CONFIG, 0x6}, |
| 88 | {LM3697_CTRL_A_RAMP, 0x0}, |
| 89 | {LM3697_CTRL_B_RAMP, 0x0}, |
| 90 | {LM3697_CTRL_A_B_RT_RAMP, 0x0}, |
| 91 | {LM3697_CTRL_A_B_RAMP_CFG, 0x0}, |
| 92 | {LM3697_CTRL_A_B_BRT_CFG, 0x0}, |
| 93 | {LM3697_CTRL_A_FS_CURR_CFG, 0x13}, |
| 94 | {LM3697_CTRL_B_FS_CURR_CFG, 0x13}, |
| 95 | {LM3697_PWM_CFG, 0xc}, |
| 96 | {LM3697_CTRL_A_BRT_LSB, 0x0}, |
| 97 | {LM3697_CTRL_A_BRT_MSB, 0x0}, |
| 98 | {LM3697_CTRL_B_BRT_LSB, 0x0}, |
| 99 | {LM3697_CTRL_B_BRT_MSB, 0x0}, |
| 100 | {LM3697_CTRL_ENABLE, 0x0}, |
| 101 | }; |
| 102 | |
| 103 | static const struct regmap_config lm3697_regmap_config = { |
| 104 | .reg_bits = 8, |
| 105 | .val_bits = 8, |
| 106 | |
| 107 | .max_register = LM3697_CTRL_ENABLE, |
| 108 | .reg_defaults = lm3697_reg_defs, |
| 109 | .num_reg_defaults = ARRAY_SIZE(lm3697_reg_defs), |
| 110 | .cache_type = REGCACHE_FLAT, |
| 111 | }; |
| 112 | |
| 113 | static int lm3697_brightness_set(struct led_classdev *led_cdev, |
| 114 | enum led_brightness brt_val) |
| 115 | { |
| 116 | struct lm3697_led *led = container_of(led_cdev, struct lm3697_led, |
| 117 | led_dev); |
| 118 | int ctrl_en_val = (1 << led->control_bank); |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 119 | struct device *dev = led->priv->dev; |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 120 | int ret; |
| 121 | |
| 122 | mutex_lock(&led->priv->lock); |
| 123 | |
| 124 | if (brt_val == LED_OFF) { |
| 125 | ret = regmap_update_bits(led->priv->regmap, LM3697_CTRL_ENABLE, |
| 126 | ctrl_en_val, ~ctrl_en_val); |
| 127 | if (ret) { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 128 | dev_err(dev, "Cannot write ctrl register\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 129 | goto brightness_out; |
| 130 | } |
| 131 | |
| 132 | led->enabled = LED_OFF; |
| 133 | } else { |
| 134 | ret = ti_lmu_common_set_brightness(&led->lmu_data, brt_val); |
| 135 | if (ret) { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 136 | dev_err(dev, "Cannot write brightness\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 137 | goto brightness_out; |
| 138 | } |
| 139 | |
| 140 | if (!led->enabled) { |
| 141 | ret = regmap_update_bits(led->priv->regmap, |
| 142 | LM3697_CTRL_ENABLE, |
| 143 | ctrl_en_val, ctrl_en_val); |
| 144 | if (ret) { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 145 | dev_err(dev, "Cannot enable the device\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 146 | goto brightness_out; |
| 147 | } |
| 148 | |
| 149 | led->enabled = brt_val; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | brightness_out: |
| 154 | mutex_unlock(&led->priv->lock); |
| 155 | return ret; |
| 156 | } |
| 157 | |
| 158 | static int lm3697_init(struct lm3697 *priv) |
| 159 | { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 160 | struct device *dev = priv->dev; |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 161 | struct lm3697_led *led; |
| 162 | int i, ret; |
| 163 | |
| 164 | if (priv->enable_gpio) { |
| 165 | gpiod_direction_output(priv->enable_gpio, 1); |
| 166 | } else { |
| 167 | ret = regmap_write(priv->regmap, LM3697_RESET, LM3697_SW_RESET); |
| 168 | if (ret) { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 169 | dev_err(dev, "Cannot reset the device\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 170 | goto out; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | ret = regmap_write(priv->regmap, LM3697_CTRL_ENABLE, 0x0); |
| 175 | if (ret) { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 176 | dev_err(dev, "Cannot write ctrl enable\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 177 | goto out; |
| 178 | } |
| 179 | |
| 180 | ret = regmap_write(priv->regmap, LM3697_OUTPUT_CONFIG, priv->bank_cfg); |
| 181 | if (ret) |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 182 | dev_err(dev, "Cannot write OUTPUT config\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 183 | |
Gabriel David | 98d278ca00 | 2020-10-02 18:27:00 -0400 | [diff] [blame] | 184 | for (i = 0; i < priv->num_banks; i++) { |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 185 | led = &priv->leds[i]; |
| 186 | ret = ti_lmu_common_set_ramp(&led->lmu_data); |
| 187 | if (ret) |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 188 | dev_err(dev, "Setting the ramp rate failed\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 189 | } |
| 190 | out: |
| 191 | return ret; |
| 192 | } |
| 193 | |
| 194 | static int lm3697_probe_dt(struct lm3697 *priv) |
| 195 | { |
| 196 | struct fwnode_handle *child = NULL; |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 197 | struct device *dev = priv->dev; |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 198 | struct lm3697_led *led; |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 199 | int ret = -EINVAL; |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 200 | int control_bank; |
| 201 | size_t i = 0; |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 202 | int j; |
| 203 | |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 204 | priv->enable_gpio = devm_gpiod_get_optional(dev, "enable", |
| 205 | GPIOD_OUT_LOW); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 206 | if (IS_ERR(priv->enable_gpio)) { |
| 207 | ret = PTR_ERR(priv->enable_gpio); |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 208 | dev_err(dev, "Failed to get enable gpio: %d\n", ret); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 209 | return ret; |
| 210 | } |
| 211 | |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 212 | priv->regulator = devm_regulator_get(dev, "vled"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 213 | if (IS_ERR(priv->regulator)) |
| 214 | priv->regulator = NULL; |
| 215 | |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 216 | device_for_each_child_node(dev, child) { |
Marek Behún | 3a953dc | 2020-09-18 00:33:02 +0200 | [diff] [blame] | 217 | struct led_init_data init_data = {}; |
| 218 | |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 219 | ret = fwnode_property_read_u32(child, "reg", &control_bank); |
| 220 | if (ret) { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 221 | dev_err(dev, "reg property missing\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 222 | fwnode_handle_put(child); |
| 223 | goto child_out; |
| 224 | } |
| 225 | |
| 226 | if (control_bank > LM3697_CONTROL_B) { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 227 | dev_err(dev, "reg property is invalid\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 228 | ret = -EINVAL; |
| 229 | fwnode_handle_put(child); |
| 230 | goto child_out; |
| 231 | } |
| 232 | |
| 233 | led = &priv->leds[i]; |
| 234 | |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 235 | ret = ti_lmu_common_get_brt_res(dev, child, &led->lmu_data); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 236 | if (ret) |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 237 | dev_warn(dev, |
| 238 | "brightness resolution property missing\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 239 | |
| 240 | led->control_bank = control_bank; |
| 241 | led->lmu_data.regmap = priv->regmap; |
| 242 | led->lmu_data.runtime_ramp_reg = LM3697_CTRL_A_RAMP + |
| 243 | control_bank; |
| 244 | led->lmu_data.msb_brightness_reg = LM3697_CTRL_A_BRT_MSB + |
| 245 | led->control_bank * 2; |
| 246 | led->lmu_data.lsb_brightness_reg = LM3697_CTRL_A_BRT_LSB + |
| 247 | led->control_bank * 2; |
| 248 | |
Andy Shevchenko | 246eab59 | 2019-07-23 23:14:59 +0300 | [diff] [blame] | 249 | led->num_leds = fwnode_property_count_u32(child, "led-sources"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 250 | if (led->num_leds > LM3697_MAX_LED_STRINGS) { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 251 | dev_err(dev, "Too many LED strings defined\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 252 | continue; |
| 253 | } |
| 254 | |
| 255 | ret = fwnode_property_read_u32_array(child, "led-sources", |
| 256 | led->hvled_strings, |
| 257 | led->num_leds); |
| 258 | if (ret) { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 259 | dev_err(dev, "led-sources property missing\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 260 | fwnode_handle_put(child); |
| 261 | goto child_out; |
| 262 | } |
| 263 | |
| 264 | for (j = 0; j < led->num_leds; j++) |
| 265 | priv->bank_cfg |= |
| 266 | (led->control_bank << led->hvled_strings[j]); |
| 267 | |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 268 | ret = ti_lmu_common_get_ramp_params(dev, child, &led->lmu_data); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 269 | if (ret) |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 270 | dev_warn(dev, "runtime-ramp properties missing\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 271 | |
Marek Behún | 3a953dc | 2020-09-18 00:33:02 +0200 | [diff] [blame] | 272 | init_data.fwnode = child; |
| 273 | init_data.devicename = priv->client->name; |
| 274 | /* for backwards compatibility if `label` is not present */ |
| 275 | init_data.default_label = ":"; |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 276 | |
| 277 | led->priv = priv; |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 278 | led->led_dev.max_brightness = led->lmu_data.max_brightness; |
| 279 | led->led_dev.brightness_set_blocking = lm3697_brightness_set; |
| 280 | |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 281 | ret = devm_led_classdev_register_ext(dev, &led->led_dev, |
Marek Behún | 3a953dc | 2020-09-18 00:33:02 +0200 | [diff] [blame] | 282 | &init_data); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 283 | if (ret) { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 284 | dev_err(dev, "led register err: %d\n", ret); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 285 | fwnode_handle_put(child); |
| 286 | goto child_out; |
| 287 | } |
| 288 | |
| 289 | i++; |
| 290 | } |
| 291 | |
| 292 | child_out: |
| 293 | return ret; |
| 294 | } |
| 295 | |
| 296 | static int lm3697_probe(struct i2c_client *client, |
| 297 | const struct i2c_device_id *id) |
| 298 | { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 299 | struct device *dev = &client->dev; |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 300 | struct lm3697 *led; |
| 301 | int count; |
| 302 | int ret; |
| 303 | |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 304 | count = device_get_child_node_count(dev); |
Gabriel David | 98d278ca00 | 2020-10-02 18:27:00 -0400 | [diff] [blame] | 305 | if (!count || count > LM3697_MAX_CONTROL_BANKS) { |
| 306 | dev_err(dev, "Strange device tree!"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 307 | return -ENODEV; |
| 308 | } |
| 309 | |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 310 | led = devm_kzalloc(dev, struct_size(led, leds, count), GFP_KERNEL); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 311 | if (!led) |
| 312 | return -ENOMEM; |
| 313 | |
| 314 | mutex_init(&led->lock); |
| 315 | i2c_set_clientdata(client, led); |
| 316 | |
| 317 | led->client = client; |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 318 | led->dev = dev; |
Gabriel David | 98d278ca00 | 2020-10-02 18:27:00 -0400 | [diff] [blame] | 319 | led->num_banks = count; |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 320 | led->regmap = devm_regmap_init_i2c(client, &lm3697_regmap_config); |
| 321 | if (IS_ERR(led->regmap)) { |
| 322 | ret = PTR_ERR(led->regmap); |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 323 | dev_err(dev, "Failed to allocate register map: %d\n", ret); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 324 | return ret; |
| 325 | } |
| 326 | |
| 327 | ret = lm3697_probe_dt(led); |
| 328 | if (ret) |
| 329 | return ret; |
| 330 | |
| 331 | return lm3697_init(led); |
| 332 | } |
| 333 | |
| 334 | static int lm3697_remove(struct i2c_client *client) |
| 335 | { |
| 336 | struct lm3697 *led = i2c_get_clientdata(client); |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 337 | struct device *dev = &led->client->dev; |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 338 | int ret; |
| 339 | |
| 340 | ret = regmap_update_bits(led->regmap, LM3697_CTRL_ENABLE, |
| 341 | LM3697_CTRL_A_B_EN, 0); |
| 342 | if (ret) { |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 343 | dev_err(dev, "Failed to disable the device\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 344 | return ret; |
| 345 | } |
| 346 | |
| 347 | if (led->enable_gpio) |
| 348 | gpiod_direction_output(led->enable_gpio, 0); |
| 349 | |
| 350 | if (led->regulator) { |
| 351 | ret = regulator_disable(led->regulator); |
| 352 | if (ret) |
Marek Behún | 0b9e357 | 2020-09-18 00:33:03 +0200 | [diff] [blame] | 353 | dev_err(dev, "Failed to disable regulator\n"); |
Dan Murphy | 5c1d824 | 2019-05-06 14:16:14 -0500 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | mutex_destroy(&led->lock); |
| 357 | |
| 358 | return 0; |
| 359 | } |
| 360 | |
| 361 | static const struct i2c_device_id lm3697_id[] = { |
| 362 | { "lm3697", 0 }, |
| 363 | { } |
| 364 | }; |
| 365 | MODULE_DEVICE_TABLE(i2c, lm3697_id); |
| 366 | |
| 367 | static const struct of_device_id of_lm3697_leds_match[] = { |
| 368 | { .compatible = "ti,lm3697", }, |
| 369 | {}, |
| 370 | }; |
| 371 | MODULE_DEVICE_TABLE(of, of_lm3697_leds_match); |
| 372 | |
| 373 | static struct i2c_driver lm3697_driver = { |
| 374 | .driver = { |
| 375 | .name = "lm3697", |
| 376 | .of_match_table = of_lm3697_leds_match, |
| 377 | }, |
| 378 | .probe = lm3697_probe, |
| 379 | .remove = lm3697_remove, |
| 380 | .id_table = lm3697_id, |
| 381 | }; |
| 382 | module_i2c_driver(lm3697_driver); |
| 383 | |
| 384 | MODULE_DESCRIPTION("Texas Instruments LM3697 LED driver"); |
| 385 | MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>"); |
| 386 | MODULE_LICENSE("GPL v2"); |