leds-lp5521.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * LP5521 LED chip driver.
  4. *
  5. * Copyright (C) 2010 Nokia Corporation
  6. * Copyright (C) 2012 Texas Instruments
  7. *
  8. * Contact: Samu Onkalo <samu.p.onkalo@nokia.com>
  9. * Milo(Woogyom) Kim <milo.kim@ti.com>
  10. */
  11. #include <linux/delay.h>
  12. #include <linux/firmware.h>
  13. #include <linux/i2c.h>
  14. #include <linux/leds.h>
  15. #include <linux/module.h>
  16. #include <linux/mutex.h>
  17. #include <linux/platform_data/leds-lp55xx.h>
  18. #include <linux/slab.h>
  19. #include <linux/of.h>
  20. #include "leds-lp55xx-common.h"
  21. #define LP5521_PROGRAM_LENGTH 32
  22. #define LP5521_MAX_LEDS 3
  23. #define LP5521_CMD_DIRECT 0x3F
  24. /* Registers */
  25. #define LP5521_REG_ENABLE 0x00
  26. #define LP5521_REG_OP_MODE 0x01
  27. #define LP5521_REG_R_PWM 0x02
  28. #define LP5521_REG_G_PWM 0x03
  29. #define LP5521_REG_B_PWM 0x04
  30. #define LP5521_REG_R_CURRENT 0x05
  31. #define LP5521_REG_G_CURRENT 0x06
  32. #define LP5521_REG_B_CURRENT 0x07
  33. #define LP5521_REG_CONFIG 0x08
  34. #define LP5521_REG_STATUS 0x0C
  35. #define LP5521_REG_RESET 0x0D
  36. #define LP5521_REG_R_PROG_MEM 0x10
  37. #define LP5521_REG_G_PROG_MEM 0x30
  38. #define LP5521_REG_B_PROG_MEM 0x50
  39. /* Base register to set LED current */
  40. #define LP5521_REG_LED_CURRENT_BASE LP5521_REG_R_CURRENT
  41. /* Base register to set the brightness */
  42. #define LP5521_REG_LED_PWM_BASE LP5521_REG_R_PWM
  43. /* Bits in ENABLE register */
  44. #define LP5521_MASTER_ENABLE 0x40 /* Chip master enable */
  45. #define LP5521_LOGARITHMIC_PWM 0x80 /* Logarithmic PWM adjustment */
  46. #define LP5521_EXEC_RUN 0x2A
  47. #define LP5521_ENABLE_DEFAULT \
  48. (LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM)
  49. #define LP5521_ENABLE_RUN_PROGRAM \
  50. (LP5521_ENABLE_DEFAULT | LP5521_EXEC_RUN)
  51. /* CONFIG register */
  52. #define LP5521_PWM_HF 0x40 /* PWM: 0 = 256Hz, 1 = 558Hz */
  53. #define LP5521_PWRSAVE_EN 0x20 /* 1 = Power save mode */
  54. #define LP5521_CP_MODE_OFF 0 /* Charge pump (CP) off */
  55. #define LP5521_CP_MODE_BYPASS 8 /* CP forced to bypass mode */
  56. #define LP5521_CP_MODE_1X5 0x10 /* CP forced to 1.5x mode */
  57. #define LP5521_CP_MODE_AUTO 0x18 /* Automatic mode selection */
  58. #define LP5521_R_TO_BATT 0x04 /* R out: 0 = CP, 1 = Vbat */
  59. #define LP5521_CLK_INT 0x01 /* Internal clock */
  60. #define LP5521_DEFAULT_CFG \
  61. (LP5521_PWM_HF | LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO)
  62. /* Status */
  63. #define LP5521_EXT_CLK_USED 0x08
  64. /* default R channel current register value */
  65. #define LP5521_REG_R_CURR_DEFAULT 0xAF
  66. /* Reset register value */
  67. #define LP5521_RESET 0xFF
  68. /* Program Memory Operations */
  69. #define LP5521_MODE_R_M 0x30 /* Operation Mode Register */
  70. #define LP5521_MODE_G_M 0x0C
  71. #define LP5521_MODE_B_M 0x03
  72. #define LP5521_LOAD_R 0x10
  73. #define LP5521_LOAD_G 0x04
  74. #define LP5521_LOAD_B 0x01
  75. #define LP5521_R_IS_LOADING(mode) \
  76. ((mode & LP5521_MODE_R_M) == LP5521_LOAD_R)
  77. #define LP5521_G_IS_LOADING(mode) \
  78. ((mode & LP5521_MODE_G_M) == LP5521_LOAD_G)
  79. #define LP5521_B_IS_LOADING(mode) \
  80. ((mode & LP5521_MODE_B_M) == LP5521_LOAD_B)
  81. #define LP5521_EXEC_R_M 0x30 /* Enable Register */
  82. #define LP5521_EXEC_G_M 0x0C
  83. #define LP5521_EXEC_B_M 0x03
  84. #define LP5521_EXEC_M 0x3F
  85. #define LP5521_RUN_R 0x20
  86. #define LP5521_RUN_G 0x08
  87. #define LP5521_RUN_B 0x02
  88. static inline void lp5521_wait_opmode_done(void)
  89. {
  90. /* operation mode change needs to be longer than 153 us */
  91. usleep_range(200, 300);
  92. }
  93. static inline void lp5521_wait_enable_done(void)
  94. {
  95. /* it takes more 488 us to update ENABLE register */
  96. usleep_range(500, 600);
  97. }
  98. static void lp5521_set_led_current(struct lp55xx_led *led, u8 led_current)
  99. {
  100. led->led_current = led_current;
  101. lp55xx_write(led->chip, LP5521_REG_LED_CURRENT_BASE + led->chan_nr,
  102. led_current);
  103. }
  104. static void lp5521_load_engine(struct lp55xx_chip *chip)
  105. {
  106. enum lp55xx_engine_index idx = chip->engine_idx;
  107. static const u8 mask[] = {
  108. [LP55XX_ENGINE_1] = LP5521_MODE_R_M,
  109. [LP55XX_ENGINE_2] = LP5521_MODE_G_M,
  110. [LP55XX_ENGINE_3] = LP5521_MODE_B_M,
  111. };
  112. static const u8 val[] = {
  113. [LP55XX_ENGINE_1] = LP5521_LOAD_R,
  114. [LP55XX_ENGINE_2] = LP5521_LOAD_G,
  115. [LP55XX_ENGINE_3] = LP5521_LOAD_B,
  116. };
  117. lp55xx_update_bits(chip, LP5521_REG_OP_MODE, mask[idx], val[idx]);
  118. lp5521_wait_opmode_done();
  119. }
  120. static void lp5521_stop_all_engines(struct lp55xx_chip *chip)
  121. {
  122. lp55xx_write(chip, LP5521_REG_OP_MODE, 0);
  123. lp5521_wait_opmode_done();
  124. }
  125. static void lp5521_stop_engine(struct lp55xx_chip *chip)
  126. {
  127. enum lp55xx_engine_index idx = chip->engine_idx;
  128. static const u8 mask[] = {
  129. [LP55XX_ENGINE_1] = LP5521_MODE_R_M,
  130. [LP55XX_ENGINE_2] = LP5521_MODE_G_M,
  131. [LP55XX_ENGINE_3] = LP5521_MODE_B_M,
  132. };
  133. lp55xx_update_bits(chip, LP5521_REG_OP_MODE, mask[idx], 0);
  134. lp5521_wait_opmode_done();
  135. }
  136. static void lp5521_run_engine(struct lp55xx_chip *chip, bool start)
  137. {
  138. int ret;
  139. u8 mode;
  140. u8 exec;
  141. /* stop engine */
  142. if (!start) {
  143. lp5521_stop_engine(chip);
  144. lp55xx_write(chip, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
  145. lp5521_wait_opmode_done();
  146. return;
  147. }
  148. /*
  149. * To run the engine,
  150. * operation mode and enable register should updated at the same time
  151. */
  152. ret = lp55xx_read(chip, LP5521_REG_OP_MODE, &mode);
  153. if (ret)
  154. return;
  155. ret = lp55xx_read(chip, LP5521_REG_ENABLE, &exec);
  156. if (ret)
  157. return;
  158. /* change operation mode to RUN only when each engine is loading */
  159. if (LP5521_R_IS_LOADING(mode)) {
  160. mode = (mode & ~LP5521_MODE_R_M) | LP5521_RUN_R;
  161. exec = (exec & ~LP5521_EXEC_R_M) | LP5521_RUN_R;
  162. }
  163. if (LP5521_G_IS_LOADING(mode)) {
  164. mode = (mode & ~LP5521_MODE_G_M) | LP5521_RUN_G;
  165. exec = (exec & ~LP5521_EXEC_G_M) | LP5521_RUN_G;
  166. }
  167. if (LP5521_B_IS_LOADING(mode)) {
  168. mode = (mode & ~LP5521_MODE_B_M) | LP5521_RUN_B;
  169. exec = (exec & ~LP5521_EXEC_B_M) | LP5521_RUN_B;
  170. }
  171. lp55xx_write(chip, LP5521_REG_OP_MODE, mode);
  172. lp5521_wait_opmode_done();
  173. lp55xx_update_bits(chip, LP5521_REG_ENABLE, LP5521_EXEC_M, exec);
  174. lp5521_wait_enable_done();
  175. }
  176. static int lp5521_update_program_memory(struct lp55xx_chip *chip,
  177. const u8 *data, size_t size)
  178. {
  179. enum lp55xx_engine_index idx = chip->engine_idx;
  180. u8 pattern[LP5521_PROGRAM_LENGTH] = {0};
  181. static const u8 addr[] = {
  182. [LP55XX_ENGINE_1] = LP5521_REG_R_PROG_MEM,
  183. [LP55XX_ENGINE_2] = LP5521_REG_G_PROG_MEM,
  184. [LP55XX_ENGINE_3] = LP5521_REG_B_PROG_MEM,
  185. };
  186. unsigned cmd;
  187. char c[3];
  188. int nrchars;
  189. int ret;
  190. int offset = 0;
  191. int i = 0;
  192. while ((offset < size - 1) && (i < LP5521_PROGRAM_LENGTH)) {
  193. /* separate sscanfs because length is working only for %s */
  194. ret = sscanf(data + offset, "%2s%n ", c, &nrchars);
  195. if (ret != 1)
  196. goto err;
  197. ret = sscanf(c, "%2x", &cmd);
  198. if (ret != 1)
  199. goto err;
  200. pattern[i] = (u8)cmd;
  201. offset += nrchars;
  202. i++;
  203. }
  204. /* Each instruction is 16bit long. Check that length is even */
  205. if (i % 2)
  206. goto err;
  207. for (i = 0; i < LP5521_PROGRAM_LENGTH; i++) {
  208. ret = lp55xx_write(chip, addr[idx] + i, pattern[i]);
  209. if (ret)
  210. return -EINVAL;
  211. }
  212. return size;
  213. err:
  214. dev_err(&chip->cl->dev, "wrong pattern format\n");
  215. return -EINVAL;
  216. }
  217. static void lp5521_firmware_loaded(struct lp55xx_chip *chip)
  218. {
  219. const struct firmware *fw = chip->fw;
  220. if (fw->size > LP5521_PROGRAM_LENGTH) {
  221. dev_err(&chip->cl->dev, "firmware data size overflow: %zu\n",
  222. fw->size);
  223. return;
  224. }
  225. /*
  226. * Program memory sequence
  227. * 1) set engine mode to "LOAD"
  228. * 2) write firmware data into program memory
  229. */
  230. lp5521_load_engine(chip);
  231. lp5521_update_program_memory(chip, fw->data, fw->size);
  232. }
  233. static int lp5521_post_init_device(struct lp55xx_chip *chip)
  234. {
  235. int ret;
  236. u8 val;
  237. /*
  238. * Make sure that the chip is reset by reading back the r channel
  239. * current reg. This is dummy read is required on some platforms -
  240. * otherwise further access to the R G B channels in the
  241. * LP5521_REG_ENABLE register will not have any effect - strange!
  242. */
  243. ret = lp55xx_read(chip, LP5521_REG_R_CURRENT, &val);
  244. if (ret) {
  245. dev_err(&chip->cl->dev, "error in resetting chip\n");
  246. return ret;
  247. }
  248. if (val != LP5521_REG_R_CURR_DEFAULT) {
  249. dev_err(&chip->cl->dev,
  250. "unexpected data in register (expected 0x%x got 0x%x)\n",
  251. LP5521_REG_R_CURR_DEFAULT, val);
  252. ret = -EINVAL;
  253. return ret;
  254. }
  255. usleep_range(10000, 20000);
  256. /* Set all PWMs to direct control mode */
  257. ret = lp55xx_write(chip, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
  258. /* Update configuration for the clock setting */
  259. val = LP5521_DEFAULT_CFG;
  260. if (!lp55xx_is_extclk_used(chip))
  261. val |= LP5521_CLK_INT;
  262. ret = lp55xx_write(chip, LP5521_REG_CONFIG, val);
  263. if (ret)
  264. return ret;
  265. /* Initialize all channels PWM to zero -> leds off */
  266. lp55xx_write(chip, LP5521_REG_R_PWM, 0);
  267. lp55xx_write(chip, LP5521_REG_G_PWM, 0);
  268. lp55xx_write(chip, LP5521_REG_B_PWM, 0);
  269. /* Set engines are set to run state when OP_MODE enables engines */
  270. ret = lp55xx_write(chip, LP5521_REG_ENABLE, LP5521_ENABLE_RUN_PROGRAM);
  271. if (ret)
  272. return ret;
  273. lp5521_wait_enable_done();
  274. return 0;
  275. }
  276. static int lp5521_run_selftest(struct lp55xx_chip *chip, char *buf)
  277. {
  278. struct lp55xx_platform_data *pdata = chip->pdata;
  279. int ret;
  280. u8 status;
  281. ret = lp55xx_read(chip, LP5521_REG_STATUS, &status);
  282. if (ret < 0)
  283. return ret;
  284. if (pdata->clock_mode != LP55XX_CLOCK_EXT)
  285. return 0;
  286. /* Check that ext clock is really in use if requested */
  287. if ((status & LP5521_EXT_CLK_USED) == 0)
  288. return -EIO;
  289. return 0;
  290. }
  291. static int lp5521_multicolor_brightness(struct lp55xx_led *led)
  292. {
  293. struct lp55xx_chip *chip = led->chip;
  294. int ret;
  295. int i;
  296. mutex_lock(&chip->lock);
  297. for (i = 0; i < led->mc_cdev.num_colors; i++) {
  298. ret = lp55xx_write(chip,
  299. LP5521_REG_LED_PWM_BASE +
  300. led->mc_cdev.subled_info[i].channel,
  301. led->mc_cdev.subled_info[i].brightness);
  302. if (ret)
  303. break;
  304. }
  305. mutex_unlock(&chip->lock);
  306. return ret;
  307. }
  308. static int lp5521_led_brightness(struct lp55xx_led *led)
  309. {
  310. struct lp55xx_chip *chip = led->chip;
  311. int ret;
  312. mutex_lock(&chip->lock);
  313. ret = lp55xx_write(chip, LP5521_REG_LED_PWM_BASE + led->chan_nr,
  314. led->brightness);
  315. mutex_unlock(&chip->lock);
  316. return ret;
  317. }
  318. static ssize_t show_engine_mode(struct device *dev,
  319. struct device_attribute *attr,
  320. char *buf, int nr)
  321. {
  322. struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
  323. struct lp55xx_chip *chip = led->chip;
  324. enum lp55xx_engine_mode mode = chip->engines[nr - 1].mode;
  325. switch (mode) {
  326. case LP55XX_ENGINE_RUN:
  327. return sprintf(buf, "run\n");
  328. case LP55XX_ENGINE_LOAD:
  329. return sprintf(buf, "load\n");
  330. case LP55XX_ENGINE_DISABLED:
  331. default:
  332. return sprintf(buf, "disabled\n");
  333. }
  334. }
  335. show_mode(1)
  336. show_mode(2)
  337. show_mode(3)
  338. static ssize_t store_engine_mode(struct device *dev,
  339. struct device_attribute *attr,
  340. const char *buf, size_t len, int nr)
  341. {
  342. struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
  343. struct lp55xx_chip *chip = led->chip;
  344. struct lp55xx_engine *engine = &chip->engines[nr - 1];
  345. mutex_lock(&chip->lock);
  346. chip->engine_idx = nr;
  347. if (!strncmp(buf, "run", 3)) {
  348. lp5521_run_engine(chip, true);
  349. engine->mode = LP55XX_ENGINE_RUN;
  350. } else if (!strncmp(buf, "load", 4)) {
  351. lp5521_stop_engine(chip);
  352. lp5521_load_engine(chip);
  353. engine->mode = LP55XX_ENGINE_LOAD;
  354. } else if (!strncmp(buf, "disabled", 8)) {
  355. lp5521_stop_engine(chip);
  356. engine->mode = LP55XX_ENGINE_DISABLED;
  357. }
  358. mutex_unlock(&chip->lock);
  359. return len;
  360. }
  361. store_mode(1)
  362. store_mode(2)
  363. store_mode(3)
  364. static ssize_t store_engine_load(struct device *dev,
  365. struct device_attribute *attr,
  366. const char *buf, size_t len, int nr)
  367. {
  368. struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
  369. struct lp55xx_chip *chip = led->chip;
  370. int ret;
  371. mutex_lock(&chip->lock);
  372. chip->engine_idx = nr;
  373. lp5521_load_engine(chip);
  374. ret = lp5521_update_program_memory(chip, buf, len);
  375. mutex_unlock(&chip->lock);
  376. return ret;
  377. }
  378. store_load(1)
  379. store_load(2)
  380. store_load(3)
  381. static ssize_t lp5521_selftest(struct device *dev,
  382. struct device_attribute *attr,
  383. char *buf)
  384. {
  385. struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
  386. struct lp55xx_chip *chip = led->chip;
  387. int ret;
  388. mutex_lock(&chip->lock);
  389. ret = lp5521_run_selftest(chip, buf);
  390. mutex_unlock(&chip->lock);
  391. return scnprintf(buf, PAGE_SIZE, "%s\n", ret ? "FAIL" : "OK");
  392. }
  393. /* device attributes */
  394. static LP55XX_DEV_ATTR_RW(engine1_mode, show_engine1_mode, store_engine1_mode);
  395. static LP55XX_DEV_ATTR_RW(engine2_mode, show_engine2_mode, store_engine2_mode);
  396. static LP55XX_DEV_ATTR_RW(engine3_mode, show_engine3_mode, store_engine3_mode);
  397. static LP55XX_DEV_ATTR_WO(engine1_load, store_engine1_load);
  398. static LP55XX_DEV_ATTR_WO(engine2_load, store_engine2_load);
  399. static LP55XX_DEV_ATTR_WO(engine3_load, store_engine3_load);
  400. static LP55XX_DEV_ATTR_RO(selftest, lp5521_selftest);
  401. static struct attribute *lp5521_attributes[] = {
  402. &dev_attr_engine1_mode.attr,
  403. &dev_attr_engine2_mode.attr,
  404. &dev_attr_engine3_mode.attr,
  405. &dev_attr_engine1_load.attr,
  406. &dev_attr_engine2_load.attr,
  407. &dev_attr_engine3_load.attr,
  408. &dev_attr_selftest.attr,
  409. NULL
  410. };
  411. static const struct attribute_group lp5521_group = {
  412. .attrs = lp5521_attributes,
  413. };
  414. /* Chip specific configurations */
  415. static struct lp55xx_device_config lp5521_cfg = {
  416. .reset = {
  417. .addr = LP5521_REG_RESET,
  418. .val = LP5521_RESET,
  419. },
  420. .enable = {
  421. .addr = LP5521_REG_ENABLE,
  422. .val = LP5521_ENABLE_DEFAULT,
  423. },
  424. .max_channel = LP5521_MAX_LEDS,
  425. .post_init_device = lp5521_post_init_device,
  426. .brightness_fn = lp5521_led_brightness,
  427. .multicolor_brightness_fn = lp5521_multicolor_brightness,
  428. .set_led_current = lp5521_set_led_current,
  429. .firmware_cb = lp5521_firmware_loaded,
  430. .run_engine = lp5521_run_engine,
  431. .dev_attr_group = &lp5521_group,
  432. };
  433. static int lp5521_probe(struct i2c_client *client,
  434. const struct i2c_device_id *id)
  435. {
  436. int ret;
  437. struct lp55xx_chip *chip;
  438. struct lp55xx_led *led;
  439. struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
  440. struct device_node *np = dev_of_node(&client->dev);
  441. chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
  442. if (!chip)
  443. return -ENOMEM;
  444. chip->cfg = &lp5521_cfg;
  445. if (!pdata) {
  446. if (np) {
  447. pdata = lp55xx_of_populate_pdata(&client->dev, np,
  448. chip);
  449. if (IS_ERR(pdata))
  450. return PTR_ERR(pdata);
  451. } else {
  452. dev_err(&client->dev, "no platform data\n");
  453. return -EINVAL;
  454. }
  455. }
  456. led = devm_kcalloc(&client->dev,
  457. pdata->num_channels, sizeof(*led), GFP_KERNEL);
  458. if (!led)
  459. return -ENOMEM;
  460. chip->cl = client;
  461. chip->pdata = pdata;
  462. mutex_init(&chip->lock);
  463. i2c_set_clientdata(client, led);
  464. ret = lp55xx_init_device(chip);
  465. if (ret)
  466. goto err_init;
  467. dev_info(&client->dev, "%s programmable led chip found\n", id->name);
  468. ret = lp55xx_register_leds(led, chip);
  469. if (ret)
  470. goto err_out;
  471. ret = lp55xx_register_sysfs(chip);
  472. if (ret) {
  473. dev_err(&client->dev, "registering sysfs failed\n");
  474. goto err_out;
  475. }
  476. return 0;
  477. err_out:
  478. lp55xx_deinit_device(chip);
  479. err_init:
  480. return ret;
  481. }
  482. static int lp5521_remove(struct i2c_client *client)
  483. {
  484. struct lp55xx_led *led = i2c_get_clientdata(client);
  485. struct lp55xx_chip *chip = led->chip;
  486. lp5521_stop_all_engines(chip);
  487. lp55xx_unregister_sysfs(chip);
  488. lp55xx_deinit_device(chip);
  489. return 0;
  490. }
  491. static const struct i2c_device_id lp5521_id[] = {
  492. { "lp5521", 0 }, /* Three channel chip */
  493. { }
  494. };
  495. MODULE_DEVICE_TABLE(i2c, lp5521_id);
  496. #ifdef CONFIG_OF
  497. static const struct of_device_id of_lp5521_leds_match[] = {
  498. { .compatible = "national,lp5521", },
  499. {},
  500. };
  501. MODULE_DEVICE_TABLE(of, of_lp5521_leds_match);
  502. #endif
  503. static struct i2c_driver lp5521_driver = {
  504. .driver = {
  505. .name = "lp5521",
  506. .of_match_table = of_match_ptr(of_lp5521_leds_match),
  507. },
  508. .probe = lp5521_probe,
  509. .remove = lp5521_remove,
  510. .id_table = lp5521_id,
  511. };
  512. module_i2c_driver(lp5521_driver);
  513. MODULE_AUTHOR("Mathias Nyman, Yuri Zaporozhets, Samu Onkalo");
  514. MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>");
  515. MODULE_DESCRIPTION("LP5521 LED engine");
  516. MODULE_LICENSE("GPL v2");