leds-lp5562.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. /*
  2. * LP5562 LED driver
  3. *
  4. * Copyright (C) 2013 Texas Instruments
  5. *
  6. * Author: Milo(Woogyom) Kim <milo.kim@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/delay.h>
  13. #include <linux/firmware.h>
  14. #include <linux/i2c.h>
  15. #include <linux/init.h>
  16. #include <linux/leds.h>
  17. #include <linux/module.h>
  18. #include <linux/mutex.h>
  19. #include <linux/of.h>
  20. #include <linux/platform_data/leds-lp55xx.h>
  21. #include <linux/slab.h>
  22. #include "leds-lp55xx-common.h"
  23. #define LP5562_PROGRAM_LENGTH 32
  24. #define LP5562_MAX_LEDS 4
  25. /* ENABLE Register 00h */
  26. #define LP5562_REG_ENABLE 0x00
  27. #define LP5562_EXEC_ENG1_M 0x30
  28. #define LP5562_EXEC_ENG2_M 0x0C
  29. #define LP5562_EXEC_ENG3_M 0x03
  30. #define LP5562_EXEC_M 0x3F
  31. #define LP5562_MASTER_ENABLE 0x40 /* Chip master enable */
  32. #define LP5562_LOGARITHMIC_PWM 0x80 /* Logarithmic PWM adjustment */
  33. #define LP5562_EXEC_RUN 0x2A
  34. #define LP5562_ENABLE_DEFAULT \
  35. (LP5562_MASTER_ENABLE | LP5562_LOGARITHMIC_PWM)
  36. #define LP5562_ENABLE_RUN_PROGRAM \
  37. (LP5562_ENABLE_DEFAULT | LP5562_EXEC_RUN)
  38. /* OPMODE Register 01h */
  39. #define LP5562_REG_OP_MODE 0x01
  40. #define LP5562_MODE_ENG1_M 0x30
  41. #define LP5562_MODE_ENG2_M 0x0C
  42. #define LP5562_MODE_ENG3_M 0x03
  43. #define LP5562_LOAD_ENG1 0x10
  44. #define LP5562_LOAD_ENG2 0x04
  45. #define LP5562_LOAD_ENG3 0x01
  46. #define LP5562_RUN_ENG1 0x20
  47. #define LP5562_RUN_ENG2 0x08
  48. #define LP5562_RUN_ENG3 0x02
  49. #define LP5562_ENG1_IS_LOADING(mode) \
  50. ((mode & LP5562_MODE_ENG1_M) == LP5562_LOAD_ENG1)
  51. #define LP5562_ENG2_IS_LOADING(mode) \
  52. ((mode & LP5562_MODE_ENG2_M) == LP5562_LOAD_ENG2)
  53. #define LP5562_ENG3_IS_LOADING(mode) \
  54. ((mode & LP5562_MODE_ENG3_M) == LP5562_LOAD_ENG3)
  55. /* BRIGHTNESS Registers */
  56. #define LP5562_REG_R_PWM 0x04
  57. #define LP5562_REG_G_PWM 0x03
  58. #define LP5562_REG_B_PWM 0x02
  59. #define LP5562_REG_W_PWM 0x0E
  60. /* CURRENT Registers */
  61. #define LP5562_REG_R_CURRENT 0x07
  62. #define LP5562_REG_G_CURRENT 0x06
  63. #define LP5562_REG_B_CURRENT 0x05
  64. #define LP5562_REG_W_CURRENT 0x0F
  65. /* CONFIG Register 08h */
  66. #define LP5562_REG_CONFIG 0x08
  67. #define LP5562_PWM_HF 0x40
  68. #define LP5562_PWRSAVE_EN 0x20
  69. #define LP5562_CLK_INT 0x01 /* Internal clock */
  70. #define LP5562_DEFAULT_CFG (LP5562_PWM_HF | LP5562_PWRSAVE_EN)
  71. /* RESET Register 0Dh */
  72. #define LP5562_REG_RESET 0x0D
  73. #define LP5562_RESET 0xFF
  74. /* PROGRAM ENGINE Registers */
  75. #define LP5562_REG_PROG_MEM_ENG1 0x10
  76. #define LP5562_REG_PROG_MEM_ENG2 0x30
  77. #define LP5562_REG_PROG_MEM_ENG3 0x50
  78. /* LEDMAP Register 70h */
  79. #define LP5562_REG_ENG_SEL 0x70
  80. #define LP5562_ENG_SEL_PWM 0
  81. #define LP5562_ENG_FOR_RGB_M 0x3F
  82. #define LP5562_ENG_SEL_RGB 0x1B /* R:ENG1, G:ENG2, B:ENG3 */
  83. #define LP5562_ENG_FOR_W_M 0xC0
  84. #define LP5562_ENG1_FOR_W 0x40 /* W:ENG1 */
  85. #define LP5562_ENG2_FOR_W 0x80 /* W:ENG2 */
  86. #define LP5562_ENG3_FOR_W 0xC0 /* W:ENG3 */
  87. /* Program Commands */
  88. #define LP5562_CMD_DISABLE 0x00
  89. #define LP5562_CMD_LOAD 0x15
  90. #define LP5562_CMD_RUN 0x2A
  91. #define LP5562_CMD_DIRECT 0x3F
  92. #define LP5562_PATTERN_OFF 0
  93. static inline void lp5562_wait_opmode_done(void)
  94. {
  95. /* operation mode change needs to be longer than 153 us */
  96. usleep_range(200, 300);
  97. }
  98. static inline void lp5562_wait_enable_done(void)
  99. {
  100. /* it takes more 488 us to update ENABLE register */
  101. usleep_range(500, 600);
  102. }
  103. static void lp5562_set_led_current(struct lp55xx_led *led, u8 led_current)
  104. {
  105. u8 addr[] = {
  106. LP5562_REG_R_CURRENT,
  107. LP5562_REG_G_CURRENT,
  108. LP5562_REG_B_CURRENT,
  109. LP5562_REG_W_CURRENT,
  110. };
  111. led->led_current = led_current;
  112. lp55xx_write(led->chip, addr[led->chan_nr], led_current);
  113. }
  114. static void lp5562_load_engine(struct lp55xx_chip *chip)
  115. {
  116. enum lp55xx_engine_index idx = chip->engine_idx;
  117. u8 mask[] = {
  118. [LP55XX_ENGINE_1] = LP5562_MODE_ENG1_M,
  119. [LP55XX_ENGINE_2] = LP5562_MODE_ENG2_M,
  120. [LP55XX_ENGINE_3] = LP5562_MODE_ENG3_M,
  121. };
  122. u8 val[] = {
  123. [LP55XX_ENGINE_1] = LP5562_LOAD_ENG1,
  124. [LP55XX_ENGINE_2] = LP5562_LOAD_ENG2,
  125. [LP55XX_ENGINE_3] = LP5562_LOAD_ENG3,
  126. };
  127. lp55xx_update_bits(chip, LP5562_REG_OP_MODE, mask[idx], val[idx]);
  128. lp5562_wait_opmode_done();
  129. }
  130. static void lp5562_stop_engine(struct lp55xx_chip *chip)
  131. {
  132. lp55xx_write(chip, LP5562_REG_OP_MODE, LP5562_CMD_DISABLE);
  133. lp5562_wait_opmode_done();
  134. }
  135. static void lp5562_run_engine(struct lp55xx_chip *chip, bool start)
  136. {
  137. int ret;
  138. u8 mode;
  139. u8 exec;
  140. /* stop engine */
  141. if (!start) {
  142. lp55xx_write(chip, LP5562_REG_ENABLE, LP5562_ENABLE_DEFAULT);
  143. lp5562_wait_enable_done();
  144. lp5562_stop_engine(chip);
  145. lp55xx_write(chip, LP5562_REG_ENG_SEL, LP5562_ENG_SEL_PWM);
  146. lp55xx_write(chip, LP5562_REG_OP_MODE, LP5562_CMD_DIRECT);
  147. lp5562_wait_opmode_done();
  148. return;
  149. }
  150. /*
  151. * To run the engine,
  152. * operation mode and enable register should updated at the same time
  153. */
  154. ret = lp55xx_read(chip, LP5562_REG_OP_MODE, &mode);
  155. if (ret)
  156. return;
  157. ret = lp55xx_read(chip, LP5562_REG_ENABLE, &exec);
  158. if (ret)
  159. return;
  160. /* change operation mode to RUN only when each engine is loading */
  161. if (LP5562_ENG1_IS_LOADING(mode)) {
  162. mode = (mode & ~LP5562_MODE_ENG1_M) | LP5562_RUN_ENG1;
  163. exec = (exec & ~LP5562_EXEC_ENG1_M) | LP5562_RUN_ENG1;
  164. }
  165. if (LP5562_ENG2_IS_LOADING(mode)) {
  166. mode = (mode & ~LP5562_MODE_ENG2_M) | LP5562_RUN_ENG2;
  167. exec = (exec & ~LP5562_EXEC_ENG2_M) | LP5562_RUN_ENG2;
  168. }
  169. if (LP5562_ENG3_IS_LOADING(mode)) {
  170. mode = (mode & ~LP5562_MODE_ENG3_M) | LP5562_RUN_ENG3;
  171. exec = (exec & ~LP5562_EXEC_ENG3_M) | LP5562_RUN_ENG3;
  172. }
  173. lp55xx_write(chip, LP5562_REG_OP_MODE, mode);
  174. lp5562_wait_opmode_done();
  175. lp55xx_update_bits(chip, LP5562_REG_ENABLE, LP5562_EXEC_M, exec);
  176. lp5562_wait_enable_done();
  177. }
  178. static int lp5562_update_firmware(struct lp55xx_chip *chip,
  179. const u8 *data, size_t size)
  180. {
  181. enum lp55xx_engine_index idx = chip->engine_idx;
  182. u8 pattern[LP5562_PROGRAM_LENGTH] = {0};
  183. u8 addr[] = {
  184. [LP55XX_ENGINE_1] = LP5562_REG_PROG_MEM_ENG1,
  185. [LP55XX_ENGINE_2] = LP5562_REG_PROG_MEM_ENG2,
  186. [LP55XX_ENGINE_3] = LP5562_REG_PROG_MEM_ENG3,
  187. };
  188. unsigned cmd;
  189. char c[3];
  190. int program_size;
  191. int nrchars;
  192. int offset = 0;
  193. int ret;
  194. int i;
  195. /* clear program memory before updating */
  196. for (i = 0; i < LP5562_PROGRAM_LENGTH; i++)
  197. lp55xx_write(chip, addr[idx] + i, 0);
  198. i = 0;
  199. while ((offset < size - 1) && (i < LP5562_PROGRAM_LENGTH)) {
  200. /* separate sscanfs because length is working only for %s */
  201. ret = sscanf(data + offset, "%2s%n ", c, &nrchars);
  202. if (ret != 1)
  203. goto err;
  204. ret = sscanf(c, "%2x", &cmd);
  205. if (ret != 1)
  206. goto err;
  207. pattern[i] = (u8)cmd;
  208. offset += nrchars;
  209. i++;
  210. }
  211. /* Each instruction is 16bit long. Check that length is even */
  212. if (i % 2)
  213. goto err;
  214. program_size = i;
  215. for (i = 0; i < program_size; i++)
  216. lp55xx_write(chip, addr[idx] + i, pattern[i]);
  217. return 0;
  218. err:
  219. dev_err(&chip->cl->dev, "wrong pattern format\n");
  220. return -EINVAL;
  221. }
  222. static void lp5562_firmware_loaded(struct lp55xx_chip *chip)
  223. {
  224. const struct firmware *fw = chip->fw;
  225. if (fw->size > LP5562_PROGRAM_LENGTH) {
  226. dev_err(&chip->cl->dev, "firmware data size overflow: %zu\n",
  227. fw->size);
  228. return;
  229. }
  230. /*
  231. * Program momery sequence
  232. * 1) set engine mode to "LOAD"
  233. * 2) write firmware data into program memory
  234. */
  235. lp5562_load_engine(chip);
  236. lp5562_update_firmware(chip, fw->data, fw->size);
  237. }
  238. static int lp5562_post_init_device(struct lp55xx_chip *chip)
  239. {
  240. int ret;
  241. u8 cfg = LP5562_DEFAULT_CFG;
  242. /* Set all PWMs to direct control mode */
  243. ret = lp55xx_write(chip, LP5562_REG_OP_MODE, LP5562_CMD_DIRECT);
  244. if (ret)
  245. return ret;
  246. lp5562_wait_opmode_done();
  247. /* Update configuration for the clock setting */
  248. if (!lp55xx_is_extclk_used(chip))
  249. cfg |= LP5562_CLK_INT;
  250. ret = lp55xx_write(chip, LP5562_REG_CONFIG, cfg);
  251. if (ret)
  252. return ret;
  253. /* Initialize all channels PWM to zero -> leds off */
  254. lp55xx_write(chip, LP5562_REG_R_PWM, 0);
  255. lp55xx_write(chip, LP5562_REG_G_PWM, 0);
  256. lp55xx_write(chip, LP5562_REG_B_PWM, 0);
  257. lp55xx_write(chip, LP5562_REG_W_PWM, 0);
  258. /* Set LED map as register PWM by default */
  259. lp55xx_write(chip, LP5562_REG_ENG_SEL, LP5562_ENG_SEL_PWM);
  260. return 0;
  261. }
  262. static void lp5562_led_brightness_work(struct work_struct *work)
  263. {
  264. struct lp55xx_led *led = container_of(work, struct lp55xx_led,
  265. brightness_work);
  266. struct lp55xx_chip *chip = led->chip;
  267. u8 addr[] = {
  268. LP5562_REG_R_PWM,
  269. LP5562_REG_G_PWM,
  270. LP5562_REG_B_PWM,
  271. LP5562_REG_W_PWM,
  272. };
  273. mutex_lock(&chip->lock);
  274. lp55xx_write(chip, addr[led->chan_nr], led->brightness);
  275. mutex_unlock(&chip->lock);
  276. }
  277. static void lp5562_write_program_memory(struct lp55xx_chip *chip,
  278. u8 base, const u8 *rgb, int size)
  279. {
  280. int i;
  281. if (!rgb || size <= 0)
  282. return;
  283. for (i = 0; i < size; i++)
  284. lp55xx_write(chip, base + i, *(rgb + i));
  285. lp55xx_write(chip, base + i, 0);
  286. lp55xx_write(chip, base + i + 1, 0);
  287. }
  288. /* check the size of program count */
  289. static inline bool _is_pc_overflow(struct lp55xx_predef_pattern *ptn)
  290. {
  291. return (ptn->size_r >= LP5562_PROGRAM_LENGTH ||
  292. ptn->size_g >= LP5562_PROGRAM_LENGTH ||
  293. ptn->size_b >= LP5562_PROGRAM_LENGTH);
  294. }
  295. static int lp5562_run_predef_led_pattern(struct lp55xx_chip *chip, int mode)
  296. {
  297. struct lp55xx_predef_pattern *ptn;
  298. int i;
  299. if (mode == LP5562_PATTERN_OFF) {
  300. lp5562_run_engine(chip, false);
  301. return 0;
  302. }
  303. ptn = chip->pdata->patterns + (mode - 1);
  304. if (!ptn || _is_pc_overflow(ptn)) {
  305. dev_err(&chip->cl->dev, "invalid pattern data\n");
  306. return -EINVAL;
  307. }
  308. lp5562_stop_engine(chip);
  309. /* Set LED map as RGB */
  310. lp55xx_write(chip, LP5562_REG_ENG_SEL, LP5562_ENG_SEL_RGB);
  311. /* Load engines */
  312. for (i = LP55XX_ENGINE_1; i <= LP55XX_ENGINE_3; i++) {
  313. chip->engine_idx = i;
  314. lp5562_load_engine(chip);
  315. }
  316. /* Clear program registers */
  317. lp55xx_write(chip, LP5562_REG_PROG_MEM_ENG1, 0);
  318. lp55xx_write(chip, LP5562_REG_PROG_MEM_ENG1 + 1, 0);
  319. lp55xx_write(chip, LP5562_REG_PROG_MEM_ENG2, 0);
  320. lp55xx_write(chip, LP5562_REG_PROG_MEM_ENG2 + 1, 0);
  321. lp55xx_write(chip, LP5562_REG_PROG_MEM_ENG3, 0);
  322. lp55xx_write(chip, LP5562_REG_PROG_MEM_ENG3 + 1, 0);
  323. /* Program engines */
  324. lp5562_write_program_memory(chip, LP5562_REG_PROG_MEM_ENG1,
  325. ptn->r, ptn->size_r);
  326. lp5562_write_program_memory(chip, LP5562_REG_PROG_MEM_ENG2,
  327. ptn->g, ptn->size_g);
  328. lp5562_write_program_memory(chip, LP5562_REG_PROG_MEM_ENG3,
  329. ptn->b, ptn->size_b);
  330. /* Run engines */
  331. lp5562_run_engine(chip, true);
  332. return 0;
  333. }
  334. static ssize_t lp5562_store_pattern(struct device *dev,
  335. struct device_attribute *attr,
  336. const char *buf, size_t len)
  337. {
  338. struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
  339. struct lp55xx_chip *chip = led->chip;
  340. struct lp55xx_predef_pattern *ptn = chip->pdata->patterns;
  341. int num_patterns = chip->pdata->num_patterns;
  342. unsigned long mode;
  343. int ret;
  344. ret = kstrtoul(buf, 0, &mode);
  345. if (ret)
  346. return ret;
  347. if (mode > num_patterns || !ptn)
  348. return -EINVAL;
  349. mutex_lock(&chip->lock);
  350. ret = lp5562_run_predef_led_pattern(chip, mode);
  351. mutex_unlock(&chip->lock);
  352. if (ret)
  353. return ret;
  354. return len;
  355. }
  356. static ssize_t lp5562_store_engine_mux(struct device *dev,
  357. struct device_attribute *attr,
  358. const char *buf, size_t len)
  359. {
  360. struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
  361. struct lp55xx_chip *chip = led->chip;
  362. u8 mask;
  363. u8 val;
  364. /* LED map
  365. * R ... Engine 1 (fixed)
  366. * G ... Engine 2 (fixed)
  367. * B ... Engine 3 (fixed)
  368. * W ... Engine 1 or 2 or 3
  369. */
  370. if (sysfs_streq(buf, "RGB")) {
  371. mask = LP5562_ENG_FOR_RGB_M;
  372. val = LP5562_ENG_SEL_RGB;
  373. } else if (sysfs_streq(buf, "W")) {
  374. enum lp55xx_engine_index idx = chip->engine_idx;
  375. mask = LP5562_ENG_FOR_W_M;
  376. switch (idx) {
  377. case LP55XX_ENGINE_1:
  378. val = LP5562_ENG1_FOR_W;
  379. break;
  380. case LP55XX_ENGINE_2:
  381. val = LP5562_ENG2_FOR_W;
  382. break;
  383. case LP55XX_ENGINE_3:
  384. val = LP5562_ENG3_FOR_W;
  385. break;
  386. default:
  387. return -EINVAL;
  388. }
  389. } else {
  390. dev_err(dev, "choose RGB or W\n");
  391. return -EINVAL;
  392. }
  393. mutex_lock(&chip->lock);
  394. lp55xx_update_bits(chip, LP5562_REG_ENG_SEL, mask, val);
  395. mutex_unlock(&chip->lock);
  396. return len;
  397. }
  398. static LP55XX_DEV_ATTR_WO(led_pattern, lp5562_store_pattern);
  399. static LP55XX_DEV_ATTR_WO(engine_mux, lp5562_store_engine_mux);
  400. static struct attribute *lp5562_attributes[] = {
  401. &dev_attr_led_pattern.attr,
  402. &dev_attr_engine_mux.attr,
  403. NULL,
  404. };
  405. static const struct attribute_group lp5562_group = {
  406. .attrs = lp5562_attributes,
  407. };
  408. /* Chip specific configurations */
  409. static struct lp55xx_device_config lp5562_cfg = {
  410. .max_channel = LP5562_MAX_LEDS,
  411. .reset = {
  412. .addr = LP5562_REG_RESET,
  413. .val = LP5562_RESET,
  414. },
  415. .enable = {
  416. .addr = LP5562_REG_ENABLE,
  417. .val = LP5562_ENABLE_DEFAULT,
  418. },
  419. .post_init_device = lp5562_post_init_device,
  420. .set_led_current = lp5562_set_led_current,
  421. .brightness_work_fn = lp5562_led_brightness_work,
  422. .run_engine = lp5562_run_engine,
  423. .firmware_cb = lp5562_firmware_loaded,
  424. .dev_attr_group = &lp5562_group,
  425. };
  426. static int lp5562_probe(struct i2c_client *client,
  427. const struct i2c_device_id *id)
  428. {
  429. int ret;
  430. struct lp55xx_chip *chip;
  431. struct lp55xx_led *led;
  432. struct lp55xx_platform_data *pdata;
  433. struct device_node *np = client->dev.of_node;
  434. if (!dev_get_platdata(&client->dev)) {
  435. if (np) {
  436. ret = lp55xx_of_populate_pdata(&client->dev, np);
  437. if (ret < 0)
  438. return ret;
  439. } else {
  440. dev_err(&client->dev, "no platform data\n");
  441. return -EINVAL;
  442. }
  443. }
  444. pdata = dev_get_platdata(&client->dev);
  445. chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
  446. if (!chip)
  447. return -ENOMEM;
  448. led = devm_kzalloc(&client->dev,
  449. sizeof(*led) * pdata->num_channels, GFP_KERNEL);
  450. if (!led)
  451. return -ENOMEM;
  452. chip->cl = client;
  453. chip->pdata = pdata;
  454. chip->cfg = &lp5562_cfg;
  455. mutex_init(&chip->lock);
  456. i2c_set_clientdata(client, led);
  457. ret = lp55xx_init_device(chip);
  458. if (ret)
  459. goto err_init;
  460. ret = lp55xx_register_leds(led, chip);
  461. if (ret)
  462. goto err_register_leds;
  463. ret = lp55xx_register_sysfs(chip);
  464. if (ret) {
  465. dev_err(&client->dev, "registering sysfs failed\n");
  466. goto err_register_sysfs;
  467. }
  468. return 0;
  469. err_register_sysfs:
  470. lp55xx_unregister_leds(led, chip);
  471. err_register_leds:
  472. lp55xx_deinit_device(chip);
  473. err_init:
  474. return ret;
  475. }
  476. static int lp5562_remove(struct i2c_client *client)
  477. {
  478. struct lp55xx_led *led = i2c_get_clientdata(client);
  479. struct lp55xx_chip *chip = led->chip;
  480. lp5562_stop_engine(chip);
  481. lp55xx_unregister_sysfs(chip);
  482. lp55xx_unregister_leds(led, chip);
  483. lp55xx_deinit_device(chip);
  484. return 0;
  485. }
  486. static const struct i2c_device_id lp5562_id[] = {
  487. { "lp5562", 0 },
  488. { }
  489. };
  490. MODULE_DEVICE_TABLE(i2c, lp5562_id);
  491. #ifdef CONFIG_OF
  492. static const struct of_device_id of_lp5562_leds_match[] = {
  493. { .compatible = "ti,lp5562", },
  494. {},
  495. };
  496. MODULE_DEVICE_TABLE(of, of_lp5562_leds_match);
  497. #endif
  498. static struct i2c_driver lp5562_driver = {
  499. .driver = {
  500. .name = "lp5562",
  501. .of_match_table = of_match_ptr(of_lp5562_leds_match),
  502. },
  503. .probe = lp5562_probe,
  504. .remove = lp5562_remove,
  505. .id_table = lp5562_id,
  506. };
  507. module_i2c_driver(lp5562_driver);
  508. MODULE_DESCRIPTION("Texas Instruments LP5562 LED Driver");
  509. MODULE_AUTHOR("Milo Kim");
  510. MODULE_LICENSE("GPL");