Lines Matching refs:lm3533
83 int lm3533_read(struct lm3533 *lm3533, u8 reg, u8 *val) in lm3533_read() argument
88 ret = regmap_read(lm3533->regmap, reg, &tmp); in lm3533_read()
90 dev_err(lm3533->dev, "failed to read register %02x: %d\n", in lm3533_read()
97 dev_dbg(lm3533->dev, "read [%02x]: %02x\n", reg, *val); in lm3533_read()
103 int lm3533_write(struct lm3533 *lm3533, u8 reg, u8 val) in lm3533_write() argument
107 dev_dbg(lm3533->dev, "write [%02x]: %02x\n", reg, val); in lm3533_write()
109 ret = regmap_write(lm3533->regmap, reg, val); in lm3533_write()
111 dev_err(lm3533->dev, "failed to write register %02x: %d\n", in lm3533_write()
119 int lm3533_update(struct lm3533 *lm3533, u8 reg, u8 val, u8 mask) in lm3533_update() argument
123 dev_dbg(lm3533->dev, "update [%02x]: %02x/%02x\n", reg, val, mask); in lm3533_update()
125 ret = regmap_update_bits(lm3533->regmap, reg, mask, val); in lm3533_update()
127 dev_err(lm3533->dev, "failed to update register %02x: %d\n", in lm3533_update()
135 static int lm3533_set_boost_freq(struct lm3533 *lm3533, in lm3533_set_boost_freq() argument
140 ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM, in lm3533_set_boost_freq()
144 dev_err(lm3533->dev, "failed to set boost frequency\n"); in lm3533_set_boost_freq()
150 static int lm3533_set_boost_ovp(struct lm3533 *lm3533, in lm3533_set_boost_ovp() argument
155 ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM, in lm3533_set_boost_ovp()
159 dev_err(lm3533->dev, "failed to set boost ovp\n"); in lm3533_set_boost_ovp()
167 static int lm3533_set_hvled_config(struct lm3533 *lm3533, u8 hvled, u8 bl) in lm3533_set_hvled_config() argument
184 ret = lm3533_update(lm3533, LM3533_REG_OUTPUT_CONF1, val, mask); in lm3533_set_hvled_config()
186 dev_err(lm3533->dev, "failed to set hvled config\n"); in lm3533_set_hvled_config()
194 static int lm3533_set_lvled_config(struct lm3533 *lm3533, u8 lvled, u8 led) in lm3533_set_lvled_config() argument
219 ret = lm3533_update(lm3533, reg, val, mask); in lm3533_set_lvled_config()
221 dev_err(lm3533->dev, "failed to set lvled config\n"); in lm3533_set_lvled_config()
226 static void lm3533_enable(struct lm3533 *lm3533) in lm3533_enable() argument
228 if (gpio_is_valid(lm3533->gpio_hwen)) in lm3533_enable()
229 gpio_set_value(lm3533->gpio_hwen, 1); in lm3533_enable()
232 static void lm3533_disable(struct lm3533 *lm3533) in lm3533_disable() argument
234 if (gpio_is_valid(lm3533->gpio_hwen)) in lm3533_disable()
235 gpio_set_value(lm3533->gpio_hwen, 0); in lm3533_disable()
259 struct lm3533 *lm3533 = dev_get_drvdata(dev); in show_output() local
283 ret = lm3533_read(lm3533, reg, &val); in show_output()
296 struct lm3533 *lm3533 = dev_get_drvdata(dev); in store_output() local
306 ret = lm3533_set_hvled_config(lm3533, id, val); in store_output()
308 ret = lm3533_set_lvled_config(lm3533, id, val); in store_output()
362 struct lm3533 *lm3533 = dev_get_drvdata(dev); in lm3533_attr_is_visible() local
368 if (!lm3533->have_backlights && type == LM3533_ATTR_TYPE_BACKLIGHT) in lm3533_attr_is_visible()
370 else if (!lm3533->have_leds && type == LM3533_ATTR_TYPE_LED) in lm3533_attr_is_visible()
381 static int lm3533_device_als_init(struct lm3533 *lm3533) in lm3533_device_als_init() argument
383 struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev); in lm3533_device_als_init()
392 ret = mfd_add_devices(lm3533->dev, 0, lm3533_als_devs, 1, NULL, in lm3533_device_als_init()
395 dev_err(lm3533->dev, "failed to add ALS device\n"); in lm3533_device_als_init()
399 lm3533->have_als = 1; in lm3533_device_als_init()
404 static int lm3533_device_bl_init(struct lm3533 *lm3533) in lm3533_device_bl_init() argument
406 struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev); in lm3533_device_bl_init()
421 ret = mfd_add_devices(lm3533->dev, 0, lm3533_bl_devs, in lm3533_device_bl_init()
424 dev_err(lm3533->dev, "failed to add backlight devices\n"); in lm3533_device_bl_init()
428 lm3533->have_backlights = 1; in lm3533_device_bl_init()
433 static int lm3533_device_led_init(struct lm3533 *lm3533) in lm3533_device_led_init() argument
435 struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev); in lm3533_device_led_init()
450 ret = mfd_add_devices(lm3533->dev, 0, lm3533_led_devs, in lm3533_device_led_init()
453 dev_err(lm3533->dev, "failed to add LED devices\n"); in lm3533_device_led_init()
457 lm3533->have_leds = 1; in lm3533_device_led_init()
462 static int lm3533_device_setup(struct lm3533 *lm3533, in lm3533_device_setup() argument
467 ret = lm3533_set_boost_freq(lm3533, pdata->boost_freq); in lm3533_device_setup()
471 return lm3533_set_boost_ovp(lm3533, pdata->boost_ovp); in lm3533_device_setup()
474 static int lm3533_device_init(struct lm3533 *lm3533) in lm3533_device_init() argument
476 struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev); in lm3533_device_init()
479 dev_dbg(lm3533->dev, "%s\n", __func__); in lm3533_device_init()
482 dev_err(lm3533->dev, "no platform data\n"); in lm3533_device_init()
486 lm3533->gpio_hwen = pdata->gpio_hwen; in lm3533_device_init()
488 if (gpio_is_valid(lm3533->gpio_hwen)) { in lm3533_device_init()
489 ret = devm_gpio_request_one(lm3533->dev, lm3533->gpio_hwen, in lm3533_device_init()
492 dev_err(lm3533->dev, in lm3533_device_init()
494 lm3533->gpio_hwen); in lm3533_device_init()
499 lm3533_enable(lm3533); in lm3533_device_init()
501 ret = lm3533_device_setup(lm3533, pdata); in lm3533_device_init()
505 lm3533_device_als_init(lm3533); in lm3533_device_init()
506 lm3533_device_bl_init(lm3533); in lm3533_device_init()
507 lm3533_device_led_init(lm3533); in lm3533_device_init()
509 ret = sysfs_create_group(&lm3533->dev->kobj, &lm3533_attribute_group); in lm3533_device_init()
511 dev_err(lm3533->dev, "failed to create sysfs attributes\n"); in lm3533_device_init()
518 mfd_remove_devices(lm3533->dev); in lm3533_device_init()
520 lm3533_disable(lm3533); in lm3533_device_init()
525 static void lm3533_device_exit(struct lm3533 *lm3533) in lm3533_device_exit() argument
527 dev_dbg(lm3533->dev, "%s\n", __func__); in lm3533_device_exit()
529 sysfs_remove_group(&lm3533->dev->kobj, &lm3533_attribute_group); in lm3533_device_exit()
531 mfd_remove_devices(lm3533->dev); in lm3533_device_exit()
532 lm3533_disable(lm3533); in lm3533_device_exit()
587 struct lm3533 *lm3533; in lm3533_i2c_probe() local
591 lm3533 = devm_kzalloc(&i2c->dev, sizeof(*lm3533), GFP_KERNEL); in lm3533_i2c_probe()
592 if (!lm3533) in lm3533_i2c_probe()
595 i2c_set_clientdata(i2c, lm3533); in lm3533_i2c_probe()
597 lm3533->regmap = devm_regmap_init_i2c(i2c, ®map_config); in lm3533_i2c_probe()
598 if (IS_ERR(lm3533->regmap)) in lm3533_i2c_probe()
599 return PTR_ERR(lm3533->regmap); in lm3533_i2c_probe()
601 lm3533->dev = &i2c->dev; in lm3533_i2c_probe()
602 lm3533->irq = i2c->irq; in lm3533_i2c_probe()
604 return lm3533_device_init(lm3533); in lm3533_i2c_probe()
609 struct lm3533 *lm3533 = i2c_get_clientdata(i2c); in lm3533_i2c_remove() local
613 lm3533_device_exit(lm3533); in lm3533_i2c_remove()