leds-lp5521.c 16 KB

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