19 #include <linux/kernel.h>
24 #include <linux/module.h>
26 #include <linux/slab.h>
44 "failed to enable backlight: %d\n", rc);
50 dev_dbg(tps65217_bl->
dev,
"backlight enabled\n");
65 "failed to disable backlight: %d\n", rc);
71 dev_dbg(tps65217_bl->
dev,
"backlight disabled\n");
78 struct tps65217_bl *tps65217_bl = bl_get_data(bl);
97 "failed to set brightness level: %d\n", rc);
101 dev_dbg(tps65217_bl->
dev,
"brightness set to %d\n", brightness);
104 rc = tps65217_bl_enable(tps65217_bl);
106 rc = tps65217_bl_disable(tps65217_bl);
114 return bl->
props.brightness;
119 .update_status = tps65217_bl_update_status,
120 .get_brightness = tps65217_bl_get_brightness
123 static int tps65217_bl_hw_init(
struct tps65217_bl *tps65217_bl,
128 rc = tps65217_bl_disable(tps65217_bl);
132 switch (pdata->
isel) {
141 "failed to select ISET1 current level: %d)\n",
146 dev_dbg(tps65217_bl->
dev,
"selected ISET1 current level\n");
157 "failed to select ISET2 current level: %d\n",
162 dev_dbg(tps65217_bl->
dev,
"selected ISET2 current level\n");
168 "invalid value for current level: %d\n", pdata->
isel);
180 "failed to select PWM dimming frequency: %d\n",
203 dev_err(&pdev->
dev,
"failed to allocate platform data\n");
209 if (!of_property_read_u32(node,
"isel", &val)) {
213 "invalid 'isel' value in the device tree\n");
222 if (!of_property_read_u32(node,
"fdim", &val)) {
242 "invalid 'fdim' value in the device tree\n");
269 struct tps65217_bl *tps65217_bl;
273 if (tps->
dev->of_node) {
274 pdata = tps65217_bl_parse_dt(pdev);
276 return PTR_ERR(pdata);
278 if (!pdev->
dev.platform_data) {
279 dev_err(&pdev->
dev,
"no platform data provided\n");
283 pdata = pdev->
dev.platform_data;
288 if (tps65217_bl ==
NULL) {
289 dev_err(&pdev->
dev,
"allocation of struct tps65217_bl failed\n");
294 tps65217_bl->
dev = &pdev->
dev;
297 rc = tps65217_bl_hw_init(tps65217_bl, pdata);
303 bl_props.max_brightness = 100;
306 tps65217_bl->
dev, tps65217_bl,
307 &tps65217_bl_ops, &bl_props);
308 if (IS_ERR(tps65217_bl->
bl)) {
310 "registration of backlight device failed: %d\n", rc);
311 return PTR_ERR(tps65217_bl->
bl);
314 tps65217_bl->
bl->props.brightness = 0;
315 platform_set_drvdata(pdev, tps65217_bl);
322 struct tps65217_bl *tps65217_bl = platform_get_drvdata(pdev);
330 .probe = tps65217_bl_probe,
331 .remove = tps65217_bl_remove,
334 .name =
"tps65217-bl",