aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/backlight/max8925_bl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/backlight/max8925_bl.c')
-rw-r--r--drivers/video/backlight/max8925_bl.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
index 2c9bce050aa9..5ca11b066b7e 100644
--- a/drivers/video/backlight/max8925_bl.c
+++ b/drivers/video/backlight/max8925_bl.c
@@ -101,6 +101,29 @@ static const struct backlight_ops max8925_backlight_ops = {
101 .get_brightness = max8925_backlight_get_brightness, 101 .get_brightness = max8925_backlight_get_brightness,
102}; 102};
103 103
104#ifdef CONFIG_OF
105static int max8925_backlight_dt_init(struct platform_device *pdev,
106 struct max8925_backlight_pdata *pdata)
107{
108 struct device_node *nproot = pdev->dev.parent->of_node, *np;
109 int dual_string;
110
111 if (!nproot)
112 return -ENODEV;
113 np = of_find_node_by_name(nproot, "backlight");
114 if (!np) {
115 dev_err(&pdev->dev, "failed to find backlight node\n");
116 return -ENODEV;
117 }
118
119 of_property_read_u32(np, "maxim,max8925-dual-string", &dual_string);
120 pdata->dual_string = dual_string;
121 return 0;
122}
123#else
124#define max8925_backlight_dt_init(x, y) (-1)
125#endif
126
104static int max8925_backlight_probe(struct platform_device *pdev) 127static int max8925_backlight_probe(struct platform_device *pdev)
105{ 128{
106 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); 129 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -147,6 +170,13 @@ static int max8925_backlight_probe(struct platform_device *pdev)
147 platform_set_drvdata(pdev, bl); 170 platform_set_drvdata(pdev, bl);
148 171
149 value = 0; 172 value = 0;
173 if (pdev->dev.parent->of_node && !pdata) {
174 pdata = devm_kzalloc(&pdev->dev,
175 sizeof(struct max8925_backlight_pdata),
176 GFP_KERNEL);
177 max8925_backlight_dt_init(pdev, pdata);
178 }
179
150 if (pdata) { 180 if (pdata) {
151 if (pdata->lxw_scl) 181 if (pdata->lxw_scl)
152 value |= (1 << 7); 182 value |= (1 << 7);
@@ -158,7 +188,6 @@ static int max8925_backlight_probe(struct platform_device *pdev)
158 ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 0xfe, value); 188 ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 0xfe, value);
159 if (ret < 0) 189 if (ret < 0)
160 goto out_brt; 190 goto out_brt;
161
162 backlight_update_status(bl); 191 backlight_update_status(bl);
163 return 0; 192 return 0;
164out_brt: 193out_brt: