13 #include <linux/module.h>
14 #include <linux/kernel.h>
22 #include <linux/slab.h>
51 brightness = pb->
notify(pb->
dev, brightness);
53 if (brightness == 0) {
80 return bl->
props.brightness;
92 .update_status = pwm_backlight_update_status,
93 .get_brightness = pwm_backlight_get_brightness,
94 .check_fb = pwm_backlight_check_fb,
98 static int pwm_backlight_parse_dt(
struct device *
dev,
110 memset(data, 0,
sizeof(*data));
133 ret = of_property_read_u32(node,
"default-brightness-level",
139 dev_warn(dev,
"invalid default brightness level: %u, using %u\n",
164 static int pwm_backlight_parse_dt(
struct device *dev,
182 ret = pwm_backlight_parse_dt(&pdev->
dev, &defdata);
184 dev_err(&pdev->
dev,
"failed to find platform data\n");
217 if (IS_ERR(pb->
pwm)) {
218 dev_err(&pdev->
dev,
"unable to request PWM, trying legacy API\n");
221 if (IS_ERR(pb->
pwm)) {
222 dev_err(&pdev->
dev,
"unable to request legacy PWM\n");
223 ret = PTR_ERR(pb->
pwm);
228 dev_dbg(&pdev->
dev,
"got pwm for backlight\n");
245 &pwm_backlight_ops, &props);
247 dev_err(&pdev->
dev,
"failed to register backlight\n");
253 backlight_update_status(bl);
255 platform_set_drvdata(pdev, bl);
278 static int pwm_backlight_suspend(
struct device *dev)
292 static int pwm_backlight_resume(
struct device *dev)
296 backlight_update_status(bl);
301 pwm_backlight_resume);
307 .name =
"pwm-backlight",
310 .pm = &pwm_backlight_pm_ops,
314 .probe = pwm_backlight_probe,
315 .remove = pwm_backlight_remove,