2 * LP5521/LP5523/LP55231 Common Driver
4 * Copyright 2012 Texas Instruments
6 * Author: Milo(Woogyom) Kim <milo.kim@ti.com>
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.
12 * Derived from leds-lp5521.c, leds-lp5523.c
15 #include <linux/delay.h>
16 #include <linux/i2c.h>
17 #include <linux/leds.h>
18 #include <linux/module.h>
19 #include <linux/platform_data/leds-lp55xx.h>
21 #include "leds-lp55xx-common.h"
23 int lp55xx_write(struct lp55xx_chip *chip, u8 reg, u8 val)
25 return i2c_smbus_write_byte_data(chip->cl, reg, val);
27 EXPORT_SYMBOL_GPL(lp55xx_write);
29 int lp55xx_read(struct lp55xx_chip *chip, u8 reg, u8 *val)
33 ret = i2c_smbus_read_byte_data(chip->cl, reg);
40 EXPORT_SYMBOL_GPL(lp55xx_read);
42 int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg, u8 mask, u8 val)
47 ret = lp55xx_read(chip, reg, &tmp);
54 return lp55xx_write(chip, reg, tmp);
56 EXPORT_SYMBOL_GPL(lp55xx_update_bits);
58 int lp55xx_init_device(struct lp55xx_chip *chip)
60 struct lp55xx_platform_data *pdata;
61 struct device *dev = &chip->cl->dev;
71 if (pdata->setup_resources) {
72 ret = pdata->setup_resources();
74 dev_err(dev, "setup resoure err: %d\n", ret);
81 usleep_range(1000, 2000); /* Keep enable down at least 1ms */
83 usleep_range(1000, 2000); /* 500us abs min. */
89 EXPORT_SYMBOL_GPL(lp55xx_init_device);
91 MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>");
92 MODULE_DESCRIPTION("LP55xx Common Driver");
93 MODULE_LICENSE("GPL");