Lines Matching +full:default +full:- +full:brightness

1 // SPDX-License-Identifier: GPL-2.0-only
3 * leds-max8997.c - LED class driver for MAX8997 LEDs.
14 #include <linux/mfd/max8997-private.h>
51 struct i2c_client *client = led->iodev->i2c; in max8997_led_set_mode()
57 val = led->id ? in max8997_led_set_mode()
59 led->cdev.max_brightness = MAX8997_LED_FLASH_MAX_BRIGHTNESS; in max8997_led_set_mode()
63 val = led->id ? in max8997_led_set_mode()
65 led->cdev.max_brightness = MAX8997_LED_MOVIE_MAX_BRIGHTNESS; in max8997_led_set_mode()
70 val = led->id ? in max8997_led_set_mode()
72 led->cdev.max_brightness = MAX8997_LED_FLASH_MAX_BRIGHTNESS; in max8997_led_set_mode()
77 val = led->id ? in max8997_led_set_mode()
79 led->cdev.max_brightness = MAX8997_LED_MOVIE_MAX_BRIGHTNESS; in max8997_led_set_mode()
81 default: in max8997_led_set_mode()
82 led->cdev.max_brightness = MAX8997_LED_NONE_MAX_BRIGHTNESS; in max8997_led_set_mode()
90 dev_err(led->iodev->dev, in max8997_led_set_mode()
94 led->led_mode = mode; in max8997_led_set_mode()
100 struct i2c_client *client = led->iodev->i2c; in max8997_led_enable()
103 if (led->enabled == enable) in max8997_led_enable()
110 dev_err(led->iodev->dev, in max8997_led_enable()
113 led->enabled = enable; in max8997_led_enable()
120 struct i2c_client *client = led->iodev->i2c; in max8997_led_set_current()
123 switch (led->led_mode) { in max8997_led_set_current()
128 reg = led->id ? MAX8997_REG_FLASH2_CUR : MAX8997_REG_FLASH1_CUR; in max8997_led_set_current()
136 default: in max8997_led_set_current()
143 dev_err(led->iodev->dev, in max8997_led_set_current()
171 mutex_lock(&led->mutex); in max8997_led_show_mode()
173 switch (led->led_mode) { in max8997_led_show_mode()
186 default: in max8997_led_show_mode()
191 mutex_unlock(&led->mutex); in max8997_led_show_mode()
205 mutex_lock(&led->mutex); in max8997_led_store_mode()
220 mutex_unlock(&led->mutex); in max8997_led_store_mode()
235 struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); in max8997_led_probe()
236 struct max8997_platform_data *pdata = dev_get_platdata(iodev->dev); in max8997_led_probe()
242 dev_err(&pdev->dev, "no platform data\n"); in max8997_led_probe()
243 return -ENODEV; in max8997_led_probe()
246 led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); in max8997_led_probe()
248 return -ENOMEM; in max8997_led_probe()
250 led->id = pdev->id; in max8997_led_probe()
251 snprintf(name, sizeof(name), "max8997-led%d", pdev->id); in max8997_led_probe()
253 led->cdev.name = name; in max8997_led_probe()
254 led->cdev.brightness_set = max8997_led_brightness_set; in max8997_led_probe()
255 led->cdev.flags |= LED_CORE_SUSPENDRESUME; in max8997_led_probe()
256 led->cdev.brightness = 0; in max8997_led_probe()
257 led->cdev.groups = max8997_groups; in max8997_led_probe()
258 led->iodev = iodev; in max8997_led_probe()
260 /* initialize mode and brightness according to platform_data */ in max8997_led_probe()
261 if (pdata->led_pdata) { in max8997_led_probe()
262 u8 mode = 0, brightness = 0; in max8997_led_probe() local
264 mode = pdata->led_pdata->mode[led->id]; in max8997_led_probe()
265 brightness = pdata->led_pdata->brightness[led->id]; in max8997_led_probe()
269 if (brightness > led->cdev.max_brightness) in max8997_led_probe()
270 brightness = led->cdev.max_brightness; in max8997_led_probe()
271 max8997_led_set_current(led, brightness); in max8997_led_probe()
272 led->cdev.brightness = brightness; in max8997_led_probe()
278 mutex_init(&led->mutex); in max8997_led_probe()
280 ret = devm_led_classdev_register(&pdev->dev, &led->cdev); in max8997_led_probe()
289 .name = "max8997-led",
299 MODULE_ALIAS("platform:max8997-led");