diff options
author | Haojian Zhuang <haojian.zhuang@gmail.com> | 2012-09-17 00:19:04 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-09-19 06:39:13 -0400 |
commit | 63b501e22aa9b22cdfe206a5670aaae646d93021 (patch) | |
tree | fdaa73ff9f80d080be7beb389a968eae0c5abb0d /drivers | |
parent | 70ffd691ffd45e6753eee5b5636df2ff7d2c04c8 (diff) |
mfd: max8925: Use register offset as REG in backlight
Remove the register offset definition. All these register offset
are transfered as IORESOURCE_REG resources.
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mfd/max8925-core.c | 31 | ||||
-rw-r--r-- | drivers/video/backlight/max8925_bl.c | 79 |
2 files changed, 55 insertions, 55 deletions
diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c index e25a24269d51..934be40cd542 100644 --- a/drivers/mfd/max8925-core.c +++ b/drivers/mfd/max8925-core.c | |||
@@ -18,20 +18,16 @@ | |||
18 | #include <linux/mfd/core.h> | 18 | #include <linux/mfd/core.h> |
19 | #include <linux/mfd/max8925.h> | 19 | #include <linux/mfd/max8925.h> |
20 | 20 | ||
21 | static struct resource backlight_resources[] = { | 21 | static struct resource bk_resources[] __devinitdata = { |
22 | { | 22 | { 0x84, 0x84, "mode control", IORESOURCE_REG, }, |
23 | .name = "max8925-backlight", | 23 | { 0x85, 0x85, "control", IORESOURCE_REG, }, |
24 | .start = MAX8925_WLED_MODE_CNTL, | ||
25 | .end = MAX8925_WLED_CNTL, | ||
26 | .flags = IORESOURCE_REG, | ||
27 | }, | ||
28 | }; | 24 | }; |
29 | 25 | ||
30 | static struct mfd_cell backlight_devs[] = { | 26 | static struct mfd_cell bk_devs[] __devinitdata = { |
31 | { | 27 | { |
32 | .name = "max8925-backlight", | 28 | .name = "max8925-backlight", |
33 | .num_resources = 1, | 29 | .num_resources = ARRAY_SIZE(bk_resources), |
34 | .resources = &backlight_resources[0], | 30 | .resources = &bk_resources[0], |
35 | .id = -1, | 31 | .id = -1, |
36 | }, | 32 | }, |
37 | }; | 33 | }; |
@@ -623,13 +619,14 @@ int __devinit max8925_device_init(struct max8925_chip *chip, | |||
623 | } | 619 | } |
624 | 620 | ||
625 | if (pdata && pdata->backlight) { | 621 | if (pdata && pdata->backlight) { |
626 | ret = mfd_add_devices(chip->dev, 0, &backlight_devs[0], | 622 | bk_devs[0].platform_data = &pdata->backlight; |
627 | ARRAY_SIZE(backlight_devs), | 623 | bk_devs[0].pdata_size = sizeof(struct max8925_backlight_pdata); |
628 | &backlight_resources[0], 0, NULL); | 624 | } |
629 | if (ret < 0) { | 625 | ret = mfd_add_devices(chip->dev, 0, bk_devs, ARRAY_SIZE(bk_devs), |
630 | dev_err(chip->dev, "Failed to add backlight subdev\n"); | 626 | NULL, 0, NULL); |
631 | goto out_dev; | 627 | if (ret < 0) { |
632 | } | 628 | dev_err(chip->dev, "Failed to add backlight subdev\n"); |
629 | goto out_dev; | ||
633 | } | 630 | } |
634 | 631 | ||
635 | if (pdata && pdata->power) { | 632 | if (pdata && pdata->power) { |
diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c index 996dadfa09ff..f72ba54f364e 100644 --- a/drivers/video/backlight/max8925_bl.c +++ b/drivers/video/backlight/max8925_bl.c | |||
@@ -27,7 +27,9 @@ | |||
27 | struct max8925_backlight_data { | 27 | struct max8925_backlight_data { |
28 | struct max8925_chip *chip; | 28 | struct max8925_chip *chip; |
29 | 29 | ||
30 | int current_brightness; | 30 | int current_brightness; |
31 | int reg_mode_cntl; | ||
32 | int reg_cntl; | ||
31 | }; | 33 | }; |
32 | 34 | ||
33 | static int max8925_backlight_set(struct backlight_device *bl, int brightness) | 35 | static int max8925_backlight_set(struct backlight_device *bl, int brightness) |
@@ -42,16 +44,16 @@ static int max8925_backlight_set(struct backlight_device *bl, int brightness) | |||
42 | else | 44 | else |
43 | value = brightness; | 45 | value = brightness; |
44 | 46 | ||
45 | ret = max8925_reg_write(chip->i2c, MAX8925_WLED_CNTL, value); | 47 | ret = max8925_reg_write(chip->i2c, data->reg_cntl, value); |
46 | if (ret < 0) | 48 | if (ret < 0) |
47 | goto out; | 49 | goto out; |
48 | 50 | ||
49 | if (!data->current_brightness && brightness) | 51 | if (!data->current_brightness && brightness) |
50 | /* enable WLED output */ | 52 | /* enable WLED output */ |
51 | ret = max8925_set_bits(chip->i2c, MAX8925_WLED_MODE_CNTL, 1, 1); | 53 | ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 1, 1); |
52 | else if (!brightness) | 54 | else if (!brightness) |
53 | /* disable WLED output */ | 55 | /* disable WLED output */ |
54 | ret = max8925_set_bits(chip->i2c, MAX8925_WLED_MODE_CNTL, 1, 0); | 56 | ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 1, 0); |
55 | if (ret < 0) | 57 | if (ret < 0) |
56 | goto out; | 58 | goto out; |
57 | dev_dbg(chip->dev, "set brightness %d\n", value); | 59 | dev_dbg(chip->dev, "set brightness %d\n", value); |
@@ -85,7 +87,7 @@ static int max8925_backlight_get_brightness(struct backlight_device *bl) | |||
85 | struct max8925_chip *chip = data->chip; | 87 | struct max8925_chip *chip = data->chip; |
86 | int ret; | 88 | int ret; |
87 | 89 | ||
88 | ret = max8925_reg_read(chip->i2c, MAX8925_WLED_CNTL); | 90 | ret = max8925_reg_read(chip->i2c, data->reg_cntl); |
89 | if (ret < 0) | 91 | if (ret < 0) |
90 | return -EINVAL; | 92 | return -EINVAL; |
91 | data->current_brightness = ret; | 93 | data->current_brightness = ret; |
@@ -102,69 +104,70 @@ static const struct backlight_ops max8925_backlight_ops = { | |||
102 | static int __devinit max8925_backlight_probe(struct platform_device *pdev) | 104 | static int __devinit max8925_backlight_probe(struct platform_device *pdev) |
103 | { | 105 | { |
104 | struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); | 106 | struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); |
105 | struct max8925_platform_data *max8925_pdata; | 107 | struct max8925_backlight_pdata *pdata = pdev->dev.platform_data; |
106 | struct max8925_backlight_pdata *pdata = NULL; | ||
107 | struct max8925_backlight_data *data; | 108 | struct max8925_backlight_data *data; |
108 | struct backlight_device *bl; | 109 | struct backlight_device *bl; |
109 | struct backlight_properties props; | 110 | struct backlight_properties props; |
110 | struct resource *res; | 111 | struct resource *res; |
111 | char name[MAX8925_NAME_SIZE]; | ||
112 | unsigned char value; | 112 | unsigned char value; |
113 | int ret; | 113 | int ret = 0; |
114 | |||
115 | res = platform_get_resource(pdev, IORESOURCE_REG, 0); | ||
116 | if (res == NULL) { | ||
117 | dev_err(&pdev->dev, "No I/O resource!\n"); | ||
118 | return -EINVAL; | ||
119 | } | ||
120 | |||
121 | if (pdev->dev.parent->platform_data) { | ||
122 | max8925_pdata = pdev->dev.parent->platform_data; | ||
123 | pdata = max8925_pdata->backlight; | ||
124 | } | ||
125 | |||
126 | if (!pdata) { | ||
127 | dev_err(&pdev->dev, "platform data isn't assigned to " | ||
128 | "backlight\n"); | ||
129 | return -EINVAL; | ||
130 | } | ||
131 | 114 | ||
132 | data = devm_kzalloc(&pdev->dev, sizeof(struct max8925_backlight_data), | 115 | data = devm_kzalloc(&pdev->dev, sizeof(struct max8925_backlight_data), |
133 | GFP_KERNEL); | 116 | GFP_KERNEL); |
134 | if (data == NULL) | 117 | if (data == NULL) |
135 | return -ENOMEM; | 118 | return -ENOMEM; |
136 | strncpy(name, res->name, MAX8925_NAME_SIZE); | 119 | |
120 | res = platform_get_resource(pdev, IORESOURCE_REG, 0); | ||
121 | if (!res) { | ||
122 | dev_err(&pdev->dev, "No REG resource for mode control!\n"); | ||
123 | ret = -ENXIO; | ||
124 | goto out; | ||
125 | } | ||
126 | data->reg_mode_cntl = res->start; | ||
127 | res = platform_get_resource(pdev, IORESOURCE_REG, 1); | ||
128 | if (!res) { | ||
129 | dev_err(&pdev->dev, "No REG resource for control!\n"); | ||
130 | ret = -ENXIO; | ||
131 | goto out; | ||
132 | } | ||
133 | data->reg_cntl = res->start; | ||
134 | |||
137 | data->chip = chip; | 135 | data->chip = chip; |
138 | data->current_brightness = 0; | 136 | data->current_brightness = 0; |
139 | 137 | ||
140 | memset(&props, 0, sizeof(struct backlight_properties)); | 138 | memset(&props, 0, sizeof(struct backlight_properties)); |
141 | props.type = BACKLIGHT_RAW; | 139 | props.type = BACKLIGHT_RAW; |
142 | props.max_brightness = MAX_BRIGHTNESS; | 140 | props.max_brightness = MAX_BRIGHTNESS; |
143 | bl = backlight_device_register(name, &pdev->dev, data, | 141 | bl = backlight_device_register("max8925-backlight", &pdev->dev, data, |
144 | &max8925_backlight_ops, &props); | 142 | &max8925_backlight_ops, &props); |
145 | if (IS_ERR(bl)) { | 143 | if (IS_ERR(bl)) { |
146 | dev_err(&pdev->dev, "failed to register backlight\n"); | 144 | dev_err(&pdev->dev, "failed to register backlight\n"); |
147 | return PTR_ERR(bl); | 145 | ret = PTR_ERR(bl); |
146 | goto out; | ||
148 | } | 147 | } |
149 | bl->props.brightness = MAX_BRIGHTNESS; | 148 | bl->props.brightness = MAX_BRIGHTNESS; |
150 | 149 | ||
151 | platform_set_drvdata(pdev, bl); | 150 | platform_set_drvdata(pdev, bl); |
152 | 151 | ||
153 | value = 0; | 152 | value = 0; |
154 | if (pdata->lxw_scl) | 153 | if (pdata) { |
155 | value |= (1 << 7); | 154 | if (pdata->lxw_scl) |
156 | if (pdata->lxw_freq) | 155 | value |= (1 << 7); |
157 | value |= (LWX_FREQ(pdata->lxw_freq) << 4); | 156 | if (pdata->lxw_freq) |
158 | if (pdata->dual_string) | 157 | value |= (LWX_FREQ(pdata->lxw_freq) << 4); |
159 | value |= (1 << 1); | 158 | if (pdata->dual_string) |
160 | ret = max8925_set_bits(chip->i2c, MAX8925_WLED_MODE_CNTL, 0xfe, value); | 159 | value |= (1 << 1); |
160 | } | ||
161 | ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 0xfe, value); | ||
161 | if (ret < 0) | 162 | if (ret < 0) |
162 | goto out; | 163 | goto out_brt; |
163 | 164 | ||
164 | backlight_update_status(bl); | 165 | backlight_update_status(bl); |
165 | return 0; | 166 | return 0; |
166 | out: | 167 | out_brt: |
167 | backlight_device_unregister(bl); | 168 | backlight_device_unregister(bl); |
169 | out: | ||
170 | devm_kfree(&pdev->dev, data); | ||
168 | return ret; | 171 | return ret; |
169 | } | 172 | } |
170 | 173 | ||