10 #include <linux/module.h>
12 #include <linux/i2c.h>
15 #include <linux/slab.h>
128 #define INDIC_PATTERN_SIZE 4
178 switch (chip->
type) {
202 dev_err(chip->
dev,
"%s:i2c access fail to register\n", __func__);
220 lm355x_name[chip->
type],
230 preg[REG_TORCH_CTRL].
mask,
232 << preg[REG_TORCH_CTRL].
shift);
240 preg[REG_TORCH_CFG].
mask,
242 preg[REG_TORCH_CFG].
shift);
247 "torch brt is set - ext. torch pin mode\n");
255 preg[REG_FLASH_CTRL].
mask,
257 << preg[REG_FLASH_CTRL].
shift);
269 preg[REG_STROBE_CFG].
mask,
271 preg[REG_STROBE_CFG].
shift);
276 "flash brt is set - ext. strobe pin mode\n");
283 preg[REG_INDI_CTRL].
mask,
285 << preg[REG_INDI_CTRL].
shift);
293 preg[REG_INDI_CFG].
mask,
295 preg[REG_INDI_CFG].
shift);
308 preg[REG_OPMODE].
mask,
309 opmode << preg[REG_OPMODE].
shift);
314 dev_err(chip->
dev,
"%s:i2c access fail to register\n", __func__);
319 static void lm355x_deferred_torch_brightness_set(
struct work_struct *
work)
340 static void lm355x_deferred_strobe_brightness_set(
struct work_struct *work)
350 static void lm355x_strobe_brightness_set(
struct led_classdev *cdev,
361 static void lm355x_deferred_indicator_brightness_set(
struct work_struct *work)
371 static void lm355x_indicator_brightness_set(
struct led_classdev *cdev,
410 dev_err(chip->
dev,
"%s:i2c access fail to register\n", __func__);
416 static const struct regmap_config lm355x_regmap = {
419 .max_register = 0xFF,
432 dev_err(&client->
dev,
"i2c functionality check fail.\n");
437 dev_err(&client->
dev,
"needs Platform Data.\n");
447 chip->
type =
id->driver_data;
448 switch (id->driver_data) {
450 chip->
regs = lm3554_regs;
453 chip->
regs = lm3556_regs;
461 if (IS_ERR(chip->
regmap)) {
462 err = PTR_ERR(chip->
regmap);
464 "Failed to allocate register map: %d\n", err);
469 i2c_set_clientdata(client, chip);
471 err = lm355x_chip_init(chip);
479 chip->
cdev_flash.brightness_set = lm355x_strobe_brightness_set;
488 chip->
cdev_torch.brightness_set = lm355x_torch_brightness_set;
492 goto err_create_torch_file;
495 lm355x_deferred_indicator_brightness_set);
501 chip->
cdev_indicator.brightness_set = lm355x_indicator_brightness_set;
505 goto err_create_indicator_file;
512 goto err_create_pattern_file;
516 lm355x_name[id->driver_data]);
519 err_create_pattern_file:
521 err_create_indicator_file:
523 err_create_torch_file:
556 static struct i2c_driver lm355x_i2c_driver = {
562 .probe = lm355x_probe,
564 .id_table = lm355x_id,