Lines Matching refs:lm3533
3 * lm3533-core.c -- LM3533 Core
22 #include <linux/mfd/lm3533.h>
48 .name = "lm3533-als",
55 .name = "lm3533-backlight",
59 .name = "lm3533-backlight",
66 .name = "lm3533-leds",
70 .name = "lm3533-leds",
74 .name = "lm3533-leds",
78 .name = "lm3533-leds",
83 int lm3533_read(struct lm3533 *lm3533, u8 reg, u8 *val)
88 ret = regmap_read(lm3533->regmap, reg, &tmp);
90 dev_err(lm3533->dev, "failed to read register %02x: %d\n",
97 dev_dbg(lm3533->dev, "read [%02x]: %02x\n", reg, *val);
103 int lm3533_write(struct lm3533 *lm3533, u8 reg, u8 val)
107 dev_dbg(lm3533->dev, "write [%02x]: %02x\n", reg, val);
109 ret = regmap_write(lm3533->regmap, reg, val);
111 dev_err(lm3533->dev, "failed to write register %02x: %d\n",
119 int lm3533_update(struct lm3533 *lm3533, u8 reg, u8 val, u8 mask)
123 dev_dbg(lm3533->dev, "update [%02x]: %02x/%02x\n", reg, val, mask);
125 ret = regmap_update_bits(lm3533->regmap, reg, mask, val);
127 dev_err(lm3533->dev, "failed to update register %02x: %d\n",
135 static int lm3533_set_boost_freq(struct lm3533 *lm3533,
140 ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM,
144 dev_err(lm3533->dev, "failed to set boost frequency\n");
150 static int lm3533_set_boost_ovp(struct lm3533 *lm3533,
155 ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM,
159 dev_err(lm3533->dev, "failed to set boost ovp\n");
167 static int lm3533_set_hvled_config(struct lm3533 *lm3533, u8 hvled, u8 bl)
184 ret = lm3533_update(lm3533, LM3533_REG_OUTPUT_CONF1, val, mask);
186 dev_err(lm3533->dev, "failed to set hvled config\n");
194 static int lm3533_set_lvled_config(struct lm3533 *lm3533, u8 lvled, u8 led)
219 ret = lm3533_update(lm3533, reg, val, mask);
221 dev_err(lm3533->dev, "failed to set lvled config\n");
226 static void lm3533_enable(struct lm3533 *lm3533)
228 if (gpio_is_valid(lm3533->gpio_hwen))
229 gpio_set_value(lm3533->gpio_hwen, 1);
232 static void lm3533_disable(struct lm3533 *lm3533)
234 if (gpio_is_valid(lm3533->gpio_hwen))
235 gpio_set_value(lm3533->gpio_hwen, 0);
259 struct lm3533 *lm3533 = dev_get_drvdata(dev);
283 ret = lm3533_read(lm3533, reg, &val);
296 struct lm3533 *lm3533 = dev_get_drvdata(dev);
306 ret = lm3533_set_hvled_config(lm3533, id, val);
308 ret = lm3533_set_lvled_config(lm3533, id, val);
362 struct lm3533 *lm3533 = dev_get_drvdata(dev);
368 if (!lm3533->have_backlights && type == LM3533_ATTR_TYPE_BACKLIGHT)
370 else if (!lm3533->have_leds && type == LM3533_ATTR_TYPE_LED)
381 static int lm3533_device_als_init(struct lm3533 *lm3533)
383 struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
392 ret = mfd_add_devices(lm3533->dev, 0, lm3533_als_devs, 1, NULL,
395 dev_err(lm3533->dev, "failed to add ALS device\n");
399 lm3533->have_als = 1;
404 static int lm3533_device_bl_init(struct lm3533 *lm3533)
406 struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
421 ret = mfd_add_devices(lm3533->dev, 0, lm3533_bl_devs,
424 dev_err(lm3533->dev, "failed to add backlight devices\n");
428 lm3533->have_backlights = 1;
433 static int lm3533_device_led_init(struct lm3533 *lm3533)
435 struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
450 ret = mfd_add_devices(lm3533->dev, 0, lm3533_led_devs,
453 dev_err(lm3533->dev, "failed to add LED devices\n");
457 lm3533->have_leds = 1;
462 static int lm3533_device_setup(struct lm3533 *lm3533,
467 ret = lm3533_set_boost_freq(lm3533, pdata->boost_freq);
471 return lm3533_set_boost_ovp(lm3533, pdata->boost_ovp);
474 static int lm3533_device_init(struct lm3533 *lm3533)
476 struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
479 dev_dbg(lm3533->dev, "%s\n", __func__);
482 dev_err(lm3533->dev, "no platform data\n");
486 lm3533->gpio_hwen = pdata->gpio_hwen;
488 dev_set_drvdata(lm3533->dev, lm3533);
490 if (gpio_is_valid(lm3533->gpio_hwen)) {
491 ret = devm_gpio_request_one(lm3533->dev, lm3533->gpio_hwen,
492 GPIOF_OUT_INIT_LOW, "lm3533-hwen");
494 dev_err(lm3533->dev,
496 lm3533->gpio_hwen);
501 lm3533_enable(lm3533);
503 ret = lm3533_device_setup(lm3533, pdata);
507 lm3533_device_als_init(lm3533);
508 lm3533_device_bl_init(lm3533);
509 lm3533_device_led_init(lm3533);
511 ret = sysfs_create_group(&lm3533->dev->kobj, &lm3533_attribute_group);
513 dev_err(lm3533->dev, "failed to create sysfs attributes\n");
520 mfd_remove_devices(lm3533->dev);
522 lm3533_disable(lm3533);
527 static void lm3533_device_exit(struct lm3533 *lm3533)
529 dev_dbg(lm3533->dev, "%s\n", __func__);
531 sysfs_remove_group(&lm3533->dev->kobj, &lm3533_attribute_group);
533 mfd_remove_devices(lm3533->dev);
534 lm3533_disable(lm3533);
590 struct lm3533 *lm3533;
594 lm3533 = devm_kzalloc(&i2c->dev, sizeof(*lm3533), GFP_KERNEL);
595 if (!lm3533)
598 i2c_set_clientdata(i2c, lm3533);
600 lm3533->regmap = devm_regmap_init_i2c(i2c, ®map_config);
601 if (IS_ERR(lm3533->regmap))
602 return PTR_ERR(lm3533->regmap);
604 lm3533->dev = &i2c->dev;
605 lm3533->irq = i2c->irq;
607 return lm3533_device_init(lm3533);
612 struct lm3533 *lm3533 = i2c_get_clientdata(i2c);
616 lm3533_device_exit(lm3533);
622 { "lm3533", 0 },
629 .name = "lm3533",