leds-lp5521.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /*
  2. * LP5521 LED chip driver.
  3. *
  4. * Copyright (C) 2010 Nokia Corporation
  5. *
  6. * Contact: Samu Onkalo <samu.p.onkalo@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. */
  22. #include <linux/module.h>
  23. #include <linux/init.h>
  24. #include <linux/i2c.h>
  25. #include <linux/mutex.h>
  26. #include <linux/gpio.h>
  27. #include <linux/interrupt.h>
  28. #include <linux/delay.h>
  29. #include <linux/ctype.h>
  30. #include <linux/spinlock.h>
  31. #include <linux/wait.h>
  32. #include <linux/leds.h>
  33. #include <linux/leds-lp5521.h>
  34. #include <linux/workqueue.h>
  35. #include <linux/slab.h>
  36. #include <linux/platform_data/leds-lp55xx.h>
  37. #include <linux/firmware.h>
  38. #include "leds-lp55xx-common.h"
  39. #define LP5521_PROGRAM_LENGTH 32 /* in bytes */
  40. #define LP5521_MAX_LEDS 3 /* Maximum number of LEDs */
  41. #define LP5521_MAX_ENGINES 3 /* Maximum number of engines */
  42. #define LP5521_ENG_MASK_BASE 0x30 /* 00110000 */
  43. #define LP5521_ENG_STATUS_MASK 0x07 /* 00000111 */
  44. #define LP5521_CMD_LOAD 0x15 /* 00010101 */
  45. #define LP5521_CMD_RUN 0x2a /* 00101010 */
  46. #define LP5521_CMD_DIRECT 0x3f /* 00111111 */
  47. #define LP5521_CMD_DISABLED 0x00 /* 00000000 */
  48. /* Registers */
  49. #define LP5521_REG_ENABLE 0x00
  50. #define LP5521_REG_OP_MODE 0x01
  51. #define LP5521_REG_R_PWM 0x02
  52. #define LP5521_REG_G_PWM 0x03
  53. #define LP5521_REG_B_PWM 0x04
  54. #define LP5521_REG_R_CURRENT 0x05
  55. #define LP5521_REG_G_CURRENT 0x06
  56. #define LP5521_REG_B_CURRENT 0x07
  57. #define LP5521_REG_CONFIG 0x08
  58. #define LP5521_REG_R_CHANNEL_PC 0x09
  59. #define LP5521_REG_G_CHANNEL_PC 0x0A
  60. #define LP5521_REG_B_CHANNEL_PC 0x0B
  61. #define LP5521_REG_STATUS 0x0C
  62. #define LP5521_REG_RESET 0x0D
  63. #define LP5521_REG_GPO 0x0E
  64. #define LP5521_REG_R_PROG_MEM 0x10
  65. #define LP5521_REG_G_PROG_MEM 0x30
  66. #define LP5521_REG_B_PROG_MEM 0x50
  67. #define LP5521_PROG_MEM_BASE LP5521_REG_R_PROG_MEM
  68. #define LP5521_PROG_MEM_SIZE 0x20
  69. /* Base register to set LED current */
  70. #define LP5521_REG_LED_CURRENT_BASE LP5521_REG_R_CURRENT
  71. /* Base register to set the brightness */
  72. #define LP5521_REG_LED_PWM_BASE LP5521_REG_R_PWM
  73. /* Bits in ENABLE register */
  74. #define LP5521_MASTER_ENABLE 0x40 /* Chip master enable */
  75. #define LP5521_LOGARITHMIC_PWM 0x80 /* Logarithmic PWM adjustment */
  76. #define LP5521_EXEC_RUN 0x2A
  77. #define LP5521_ENABLE_DEFAULT \
  78. (LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM)
  79. #define LP5521_ENABLE_RUN_PROGRAM \
  80. (LP5521_ENABLE_DEFAULT | LP5521_EXEC_RUN)
  81. /* Status */
  82. #define LP5521_EXT_CLK_USED 0x08
  83. /* default R channel current register value */
  84. #define LP5521_REG_R_CURR_DEFAULT 0xAF
  85. /* Pattern Mode */
  86. #define PATTERN_OFF 0
  87. /* Reset register value */
  88. #define LP5521_RESET 0xFF
  89. /* Program Memory Operations */
  90. #define LP5521_MODE_R_M 0x30 /* Operation Mode Register */
  91. #define LP5521_MODE_G_M 0x0C
  92. #define LP5521_MODE_B_M 0x03
  93. #define LP5521_LOAD_R 0x10
  94. #define LP5521_LOAD_G 0x04
  95. #define LP5521_LOAD_B 0x01
  96. #define LP5521_R_IS_LOADING(mode) \
  97. ((mode & LP5521_MODE_R_M) == LP5521_LOAD_R)
  98. #define LP5521_G_IS_LOADING(mode) \
  99. ((mode & LP5521_MODE_G_M) == LP5521_LOAD_G)
  100. #define LP5521_B_IS_LOADING(mode) \
  101. ((mode & LP5521_MODE_B_M) == LP5521_LOAD_B)
  102. #define LP5521_EXEC_R_M 0x30 /* Enable Register */
  103. #define LP5521_EXEC_G_M 0x0C
  104. #define LP5521_EXEC_B_M 0x03
  105. #define LP5521_EXEC_M 0x3F
  106. #define LP5521_RUN_R 0x20
  107. #define LP5521_RUN_G 0x08
  108. #define LP5521_RUN_B 0x02
  109. struct lp5521_led {
  110. int id;
  111. u8 chan_nr;
  112. u8 led_current;
  113. u8 max_current;
  114. struct led_classdev cdev;
  115. struct work_struct brightness_work;
  116. u8 brightness;
  117. };
  118. struct lp5521_chip {
  119. struct lp5521_platform_data *pdata;
  120. struct mutex lock; /* Serialize control */
  121. struct i2c_client *client;
  122. struct lp5521_led leds[LP5521_MAX_LEDS];
  123. u8 num_channels;
  124. u8 num_leds;
  125. };
  126. static inline void lp5521_wait_opmode_done(void)
  127. {
  128. /* operation mode change needs to be longer than 153 us */
  129. usleep_range(200, 300);
  130. }
  131. static inline void lp5521_wait_enable_done(void)
  132. {
  133. /* it takes more 488 us to update ENABLE register */
  134. usleep_range(500, 600);
  135. }
  136. static void lp5521_set_led_current(struct lp55xx_led *led, u8 led_current)
  137. {
  138. led->led_current = led_current;
  139. lp55xx_write(led->chip, LP5521_REG_LED_CURRENT_BASE + led->chan_nr,
  140. led_current);
  141. }
  142. static inline int lp5521_write(struct i2c_client *client, u8 reg, u8 value)
  143. {
  144. return i2c_smbus_write_byte_data(client, reg, value);
  145. }
  146. static int lp5521_read(struct i2c_client *client, u8 reg, u8 *buf)
  147. {
  148. s32 ret;
  149. ret = i2c_smbus_read_byte_data(client, reg);
  150. if (ret < 0)
  151. return ret;
  152. *buf = ret;
  153. return 0;
  154. }
  155. static void lp5521_load_engine(struct lp55xx_chip *chip)
  156. {
  157. enum lp55xx_engine_index idx = chip->engine_idx;
  158. u8 mask[] = {
  159. [LP55XX_ENGINE_1] = LP5521_MODE_R_M,
  160. [LP55XX_ENGINE_2] = LP5521_MODE_G_M,
  161. [LP55XX_ENGINE_3] = LP5521_MODE_B_M,
  162. };
  163. u8 val[] = {
  164. [LP55XX_ENGINE_1] = LP5521_LOAD_R,
  165. [LP55XX_ENGINE_2] = LP5521_LOAD_G,
  166. [LP55XX_ENGINE_3] = LP5521_LOAD_B,
  167. };
  168. lp55xx_update_bits(chip, LP5521_REG_OP_MODE, mask[idx], val[idx]);
  169. lp5521_wait_opmode_done();
  170. }
  171. static void lp5521_stop_engine(struct lp55xx_chip *chip)
  172. {
  173. lp55xx_write(chip, LP5521_REG_OP_MODE, 0);
  174. lp5521_wait_opmode_done();
  175. }
  176. static void lp5521_run_engine(struct lp55xx_chip *chip, bool start)
  177. {
  178. int ret;
  179. u8 mode;
  180. u8 exec;
  181. /* stop engine */
  182. if (!start) {
  183. lp5521_stop_engine(chip);
  184. lp55xx_write(chip, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
  185. lp5521_wait_opmode_done();
  186. return;
  187. }
  188. /*
  189. * To run the engine,
  190. * operation mode and enable register should updated at the same time
  191. */
  192. ret = lp55xx_read(chip, LP5521_REG_OP_MODE, &mode);
  193. if (ret)
  194. return;
  195. ret = lp55xx_read(chip, LP5521_REG_ENABLE, &exec);
  196. if (ret)
  197. return;
  198. /* change operation mode to RUN only when each engine is loading */
  199. if (LP5521_R_IS_LOADING(mode)) {
  200. mode = (mode & ~LP5521_MODE_R_M) | LP5521_RUN_R;
  201. exec = (exec & ~LP5521_EXEC_R_M) | LP5521_RUN_R;
  202. }
  203. if (LP5521_G_IS_LOADING(mode)) {
  204. mode = (mode & ~LP5521_MODE_G_M) | LP5521_RUN_G;
  205. exec = (exec & ~LP5521_EXEC_G_M) | LP5521_RUN_G;
  206. }
  207. if (LP5521_B_IS_LOADING(mode)) {
  208. mode = (mode & ~LP5521_MODE_B_M) | LP5521_RUN_B;
  209. exec = (exec & ~LP5521_EXEC_B_M) | LP5521_RUN_B;
  210. }
  211. lp55xx_write(chip, LP5521_REG_OP_MODE, mode);
  212. lp5521_wait_opmode_done();
  213. lp55xx_update_bits(chip, LP5521_REG_ENABLE, LP5521_EXEC_M, exec);
  214. lp5521_wait_enable_done();
  215. }
  216. static int lp5521_update_program_memory(struct lp55xx_chip *chip,
  217. const u8 *data, size_t size)
  218. {
  219. enum lp55xx_engine_index idx = chip->engine_idx;
  220. u8 pattern[LP5521_PROGRAM_LENGTH] = {0};
  221. u8 addr[] = {
  222. [LP55XX_ENGINE_1] = LP5521_REG_R_PROG_MEM,
  223. [LP55XX_ENGINE_2] = LP5521_REG_G_PROG_MEM,
  224. [LP55XX_ENGINE_3] = LP5521_REG_B_PROG_MEM,
  225. };
  226. unsigned cmd;
  227. char c[3];
  228. int program_size;
  229. int nrchars;
  230. int offset = 0;
  231. int ret;
  232. int i;
  233. /* clear program memory before updating */
  234. for (i = 0; i < LP5521_PROGRAM_LENGTH; i++)
  235. lp55xx_write(chip, addr[idx] + i, 0);
  236. i = 0;
  237. while ((offset < size - 1) && (i < LP5521_PROGRAM_LENGTH)) {
  238. /* separate sscanfs because length is working only for %s */
  239. ret = sscanf(data + offset, "%2s%n ", c, &nrchars);
  240. if (ret != 1)
  241. goto err;
  242. ret = sscanf(c, "%2x", &cmd);
  243. if (ret != 1)
  244. goto err;
  245. pattern[i] = (u8)cmd;
  246. offset += nrchars;
  247. i++;
  248. }
  249. /* Each instruction is 16bit long. Check that length is even */
  250. if (i % 2)
  251. goto err;
  252. program_size = i;
  253. for (i = 0; i < program_size; i++)
  254. lp55xx_write(chip, addr[idx] + i, pattern[i]);
  255. return 0;
  256. err:
  257. dev_err(&chip->cl->dev, "wrong pattern format\n");
  258. return -EINVAL;
  259. }
  260. static void lp5521_firmware_loaded(struct lp55xx_chip *chip)
  261. {
  262. const struct firmware *fw = chip->fw;
  263. if (fw->size > LP5521_PROGRAM_LENGTH) {
  264. dev_err(&chip->cl->dev, "firmware data size overflow: %zu\n",
  265. fw->size);
  266. return;
  267. }
  268. /*
  269. * Program momery sequence
  270. * 1) set engine mode to "LOAD"
  271. * 2) write firmware data into program memory
  272. */
  273. lp5521_load_engine(chip);
  274. lp5521_update_program_memory(chip, fw->data, fw->size);
  275. }
  276. static int lp5521_post_init_device(struct lp55xx_chip *chip)
  277. {
  278. int ret;
  279. u8 val;
  280. /*
  281. * Make sure that the chip is reset by reading back the r channel
  282. * current reg. This is dummy read is required on some platforms -
  283. * otherwise further access to the R G B channels in the
  284. * LP5521_REG_ENABLE register will not have any effect - strange!
  285. */
  286. ret = lp55xx_read(chip, LP5521_REG_R_CURRENT, &val);
  287. if (ret) {
  288. dev_err(&chip->cl->dev, "error in resetting chip\n");
  289. return ret;
  290. }
  291. if (val != LP5521_REG_R_CURR_DEFAULT) {
  292. dev_err(&chip->cl->dev,
  293. "unexpected data in register (expected 0x%x got 0x%x)\n",
  294. LP5521_REG_R_CURR_DEFAULT, val);
  295. ret = -EINVAL;
  296. return ret;
  297. }
  298. usleep_range(10000, 20000);
  299. /* Set all PWMs to direct control mode */
  300. ret = lp55xx_write(chip, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
  301. val = chip->pdata->update_config ?
  302. : (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT);
  303. ret = lp55xx_write(chip, LP5521_REG_CONFIG, val);
  304. if (ret)
  305. return ret;
  306. /* Initialize all channels PWM to zero -> leds off */
  307. lp55xx_write(chip, LP5521_REG_R_PWM, 0);
  308. lp55xx_write(chip, LP5521_REG_G_PWM, 0);
  309. lp55xx_write(chip, LP5521_REG_B_PWM, 0);
  310. /* Set engines are set to run state when OP_MODE enables engines */
  311. ret = lp55xx_write(chip, LP5521_REG_ENABLE, LP5521_ENABLE_RUN_PROGRAM);
  312. if (ret)
  313. return ret;
  314. lp5521_wait_enable_done();
  315. return 0;
  316. }
  317. static int lp5521_run_selftest(struct lp5521_chip *chip, char *buf)
  318. {
  319. int ret;
  320. u8 status;
  321. ret = lp5521_read(chip->client, LP5521_REG_STATUS, &status);
  322. if (ret < 0)
  323. return ret;
  324. /* Check that ext clock is really in use if requested */
  325. if (chip->pdata && chip->pdata->clock_mode == LP5521_CLOCK_EXT)
  326. if ((status & LP5521_EXT_CLK_USED) == 0)
  327. return -EIO;
  328. return 0;
  329. }
  330. static void lp5521_led_brightness_work(struct work_struct *work)
  331. {
  332. struct lp55xx_led *led = container_of(work, struct lp55xx_led,
  333. brightness_work);
  334. struct lp55xx_chip *chip = led->chip;
  335. mutex_lock(&chip->lock);
  336. lp55xx_write(chip, LP5521_REG_LED_PWM_BASE + led->chan_nr,
  337. led->brightness);
  338. mutex_unlock(&chip->lock);
  339. }
  340. static ssize_t lp5521_selftest(struct device *dev,
  341. struct device_attribute *attr,
  342. char *buf)
  343. {
  344. struct i2c_client *client = to_i2c_client(dev);
  345. struct lp5521_chip *chip = i2c_get_clientdata(client);
  346. int ret;
  347. mutex_lock(&chip->lock);
  348. ret = lp5521_run_selftest(chip, buf);
  349. mutex_unlock(&chip->lock);
  350. return sprintf(buf, "%s\n", ret ? "FAIL" : "OK");
  351. }
  352. static void lp5521_clear_program_memory(struct i2c_client *cl)
  353. {
  354. int i;
  355. u8 rgb_mem[] = {
  356. LP5521_REG_R_PROG_MEM,
  357. LP5521_REG_G_PROG_MEM,
  358. LP5521_REG_B_PROG_MEM,
  359. };
  360. for (i = 0; i < ARRAY_SIZE(rgb_mem); i++) {
  361. lp5521_write(cl, rgb_mem[i], 0);
  362. lp5521_write(cl, rgb_mem[i] + 1, 0);
  363. }
  364. }
  365. static void lp5521_write_program_memory(struct i2c_client *cl,
  366. u8 base, u8 *rgb, int size)
  367. {
  368. int i;
  369. if (!rgb || size <= 0)
  370. return;
  371. for (i = 0; i < size; i++)
  372. lp5521_write(cl, base + i, *(rgb + i));
  373. lp5521_write(cl, base + i, 0);
  374. lp5521_write(cl, base + i + 1, 0);
  375. }
  376. static inline struct lp5521_led_pattern *lp5521_get_pattern
  377. (struct lp5521_chip *chip, u8 offset)
  378. {
  379. struct lp5521_led_pattern *ptn;
  380. ptn = chip->pdata->patterns + (offset - 1);
  381. return ptn;
  382. }
  383. static void lp5521_run_led_pattern(int mode, struct lp5521_chip *chip)
  384. {
  385. struct lp5521_led_pattern *ptn;
  386. struct i2c_client *cl = chip->client;
  387. int num_patterns = chip->pdata->num_patterns;
  388. if (mode > num_patterns || !(chip->pdata->patterns))
  389. return;
  390. if (mode == PATTERN_OFF) {
  391. lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT);
  392. usleep_range(1000, 2000);
  393. lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
  394. } else {
  395. ptn = lp5521_get_pattern(chip, mode);
  396. if (!ptn)
  397. return;
  398. lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_LOAD);
  399. usleep_range(1000, 2000);
  400. lp5521_clear_program_memory(cl);
  401. lp5521_write_program_memory(cl, LP5521_REG_R_PROG_MEM,
  402. ptn->r, ptn->size_r);
  403. lp5521_write_program_memory(cl, LP5521_REG_G_PROG_MEM,
  404. ptn->g, ptn->size_g);
  405. lp5521_write_program_memory(cl, LP5521_REG_B_PROG_MEM,
  406. ptn->b, ptn->size_b);
  407. lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_RUN);
  408. usleep_range(1000, 2000);
  409. lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_RUN_PROGRAM);
  410. }
  411. }
  412. /* device attributes */
  413. static DEVICE_ATTR(selftest, S_IRUGO, lp5521_selftest, NULL);
  414. static struct attribute *lp5521_attributes[] = {
  415. &dev_attr_selftest.attr,
  416. NULL
  417. };
  418. static const struct attribute_group lp5521_group = {
  419. .attrs = lp5521_attributes,
  420. };
  421. static void lp5521_unregister_sysfs(struct i2c_client *client)
  422. {
  423. struct device *dev = &client->dev;
  424. sysfs_remove_group(&dev->kobj, &lp5521_group);
  425. }
  426. /* Chip specific configurations */
  427. static struct lp55xx_device_config lp5521_cfg = {
  428. .reset = {
  429. .addr = LP5521_REG_RESET,
  430. .val = LP5521_RESET,
  431. },
  432. .enable = {
  433. .addr = LP5521_REG_ENABLE,
  434. .val = LP5521_ENABLE_DEFAULT,
  435. },
  436. .max_channel = LP5521_MAX_LEDS,
  437. .post_init_device = lp5521_post_init_device,
  438. .brightness_work_fn = lp5521_led_brightness_work,
  439. .set_led_current = lp5521_set_led_current,
  440. .firmware_cb = lp5521_firmware_loaded,
  441. .run_engine = lp5521_run_engine,
  442. .dev_attr_group = &lp5521_group,
  443. };
  444. static int lp5521_probe(struct i2c_client *client,
  445. const struct i2c_device_id *id)
  446. {
  447. int ret;
  448. struct lp55xx_chip *chip;
  449. struct lp55xx_led *led;
  450. struct lp55xx_platform_data *pdata = client->dev.platform_data;
  451. if (!pdata) {
  452. dev_err(&client->dev, "no platform data\n");
  453. return -EINVAL;
  454. }
  455. chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
  456. if (!chip)
  457. return -ENOMEM;
  458. led = devm_kzalloc(&client->dev,
  459. sizeof(*led) * pdata->num_channels, GFP_KERNEL);
  460. if (!led)
  461. return -ENOMEM;
  462. chip->cl = client;
  463. chip->pdata = pdata;
  464. chip->cfg = &lp5521_cfg;
  465. mutex_init(&chip->lock);
  466. i2c_set_clientdata(client, led);
  467. ret = lp55xx_init_device(chip);
  468. if (ret)
  469. goto err_init;
  470. dev_info(&client->dev, "%s programmable led chip found\n", id->name);
  471. ret = lp55xx_register_leds(led, chip);
  472. if (ret)
  473. goto err_register_leds;
  474. ret = lp55xx_register_sysfs(chip);
  475. if (ret) {
  476. dev_err(&client->dev, "registering sysfs failed\n");
  477. goto err_register_sysfs;
  478. }
  479. return 0;
  480. err_register_sysfs:
  481. lp55xx_unregister_leds(led, chip);
  482. err_register_leds:
  483. lp55xx_deinit_device(chip);
  484. err_init:
  485. return ret;
  486. }
  487. static int lp5521_remove(struct i2c_client *client)
  488. {
  489. struct lp5521_chip *old_chip = i2c_get_clientdata(client);
  490. struct lp55xx_led *led = i2c_get_clientdata(client);
  491. struct lp55xx_chip *chip = led->chip;
  492. lp5521_run_led_pattern(PATTERN_OFF, old_chip);
  493. lp5521_unregister_sysfs(client);
  494. lp55xx_unregister_leds(led, chip);
  495. lp55xx_deinit_device(chip);
  496. return 0;
  497. }
  498. static const struct i2c_device_id lp5521_id[] = {
  499. { "lp5521", 0 }, /* Three channel chip */
  500. { }
  501. };
  502. MODULE_DEVICE_TABLE(i2c, lp5521_id);
  503. static struct i2c_driver lp5521_driver = {
  504. .driver = {
  505. .name = "lp5521",
  506. },
  507. .probe = lp5521_probe,
  508. .remove = lp5521_remove,
  509. .id_table = lp5521_id,
  510. };
  511. module_i2c_driver(lp5521_driver);
  512. MODULE_AUTHOR("Mathias Nyman, Yuri Zaporozhets, Samu Onkalo");
  513. MODULE_DESCRIPTION("LP5521 LED engine");
  514. MODULE_LICENSE("GPL v2");