diff options
author | Qing Xu <qingx@marvell.com> | 2013-02-04 10:40:45 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-02-13 18:23:01 -0500 |
commit | 47ec340cb8e232671e7c4a4689ff32c3bdf329da (patch) | |
tree | 1eae1199083af89a5519bddba4dc1fc04319dcf8 /drivers/video/backlight | |
parent | 678e8cb50647a7580b8122937e8e6e50d949267d (diff) |
mfd: max8925: Support dt for backlight
Add device tree support in max8925 backlight.
Signed-off-by: Qing Xu <qingx@marvell.com>
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/video/backlight')
-rw-r--r-- | drivers/video/backlight/max8925_bl.c | 31 |
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 | ||
105 | static 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 | |||
104 | static int max8925_backlight_probe(struct platform_device *pdev) | 127 | static 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; |
164 | out_brt: | 193 | out_brt: |