Lines Matching +full:pwm +full:- +full:backlight

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Backlight driver for Marvell Semiconductor 88PM8606
16 #include <linux/backlight.h>
30 int pwm; member
40 int ret = -EINVAL; in backlight_power_set()
62 struct pm860x_chip *chip = data->chip; in pm860x_backlight_set()
72 backlight_power_set(chip, data->port, 1); in pm860x_backlight_set()
74 ret = pm860x_reg_write(data->i2c, data->reg_duty_cycle, value); in pm860x_backlight_set()
78 if ((data->current_brightness == 0) && brightness) { in pm860x_backlight_set()
79 if (data->iset) { in pm860x_backlight_set()
80 ret = pm860x_set_bits(data->i2c, data->reg_current, in pm860x_backlight_set()
81 CURRENT_BITMASK, data->iset); in pm860x_backlight_set()
85 if (data->pwm) { in pm860x_backlight_set()
86 ret = pm860x_set_bits(data->i2c, PM8606_PWM, in pm860x_backlight_set()
87 PM8606_PWM_FREQ_MASK, data->pwm); in pm860x_backlight_set()
93 ret = pm860x_set_bits(data->i2c, data->reg_always_on, in pm860x_backlight_set()
99 ret = pm860x_set_bits(data->i2c, data->reg_always_on, in pm860x_backlight_set()
103 ret = pm860x_set_bits(data->i2c, data->reg_always_on, in pm860x_backlight_set()
111 backlight_power_set(chip, data->port, 0); in pm860x_backlight_set()
113 dev_dbg(chip->dev, "set brightness %d\n", value); in pm860x_backlight_set()
114 data->current_brightness = value; in pm860x_backlight_set()
117 dev_dbg(chip->dev, "set brightness %d failure with return value: %d\n", in pm860x_backlight_set()
130 struct pm860x_chip *chip = data->chip; in pm860x_backlight_get_brightness()
133 ret = pm860x_reg_read(data->i2c, data->reg_duty_cycle); in pm860x_backlight_get_brightness()
136 data->current_brightness = ret; in pm860x_backlight_get_brightness()
137 dev_dbg(chip->dev, "get brightness %d\n", data->current_brightness); in pm860x_backlight_get_brightness()
138 return data->current_brightness; in pm860x_backlight_get_brightness()
140 return -EINVAL; in pm860x_backlight_get_brightness()
157 nproot = of_get_child_by_name(pdev->dev.parent->of_node, "backlights"); in pm860x_backlight_dt_init()
159 dev_err(&pdev->dev, "failed to find backlights node\n"); in pm860x_backlight_dt_init()
160 return -ENODEV; in pm860x_backlight_dt_init()
164 of_property_read_u32(np, "marvell,88pm860x-iset", in pm860x_backlight_dt_init()
166 data->iset = PM8606_WLED_CURRENT(iset); in pm860x_backlight_dt_init()
167 of_property_read_u32(np, "marvell,88pm860x-pwm", in pm860x_backlight_dt_init()
168 &data->pwm); in pm860x_backlight_dt_init()
177 #define pm860x_backlight_dt_init(x, y, z) (-1)
182 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); in pm860x_backlight_probe()
183 struct pm860x_backlight_pdata *pdata = dev_get_platdata(&pdev->dev); in pm860x_backlight_probe()
191 data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_backlight_data), in pm860x_backlight_probe()
194 return -ENOMEM; in pm860x_backlight_probe()
197 dev_err(&pdev->dev, "No REG resource for duty cycle\n"); in pm860x_backlight_probe()
198 return -ENXIO; in pm860x_backlight_probe()
200 data->reg_duty_cycle = res->start; in pm860x_backlight_probe()
203 dev_err(&pdev->dev, "No REG resource for always on\n"); in pm860x_backlight_probe()
204 return -ENXIO; in pm860x_backlight_probe()
206 data->reg_always_on = res->start; in pm860x_backlight_probe()
209 dev_err(&pdev->dev, "No REG resource for current\n"); in pm860x_backlight_probe()
210 return -ENXIO; in pm860x_backlight_probe()
212 data->reg_current = res->start; in pm860x_backlight_probe()
215 sprintf(name, "backlight-%d", pdev->id); in pm860x_backlight_probe()
216 data->port = pdev->id; in pm860x_backlight_probe()
217 data->chip = chip; in pm860x_backlight_probe()
218 data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion; in pm860x_backlight_probe()
219 data->current_brightness = MAX_BRIGHTNESS; in pm860x_backlight_probe()
222 data->pwm = pdata->pwm; in pm860x_backlight_probe()
223 data->iset = pdata->iset; in pm860x_backlight_probe()
230 bl = devm_backlight_device_register(&pdev->dev, name, &pdev->dev, data, in pm860x_backlight_probe()
233 dev_err(&pdev->dev, "failed to register backlight\n"); in pm860x_backlight_probe()
236 bl->props.brightness = MAX_BRIGHTNESS; in pm860x_backlight_probe()
240 /* read current backlight */ in pm860x_backlight_probe()
251 .name = "88pm860x-backlight",
258 MODULE_DESCRIPTION("Backlight Driver for Marvell Semiconductor 88PM8606");
261 MODULE_ALIAS("platform:88pm860x-backlight");