Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Backlight driver for Analog Devices ADP5520/ADP5501 MFD PMICs |
| 3 | * |
| 4 | * Copyright 2009 Analog Devices Inc. |
| 5 | * |
| 6 | * Licensed under the GPL-2 or later. |
| 7 | */ |
| 8 | |
| 9 | #include <linux/kernel.h> |
| 10 | #include <linux/init.h> |
| 11 | #include <linux/platform_device.h> |
| 12 | #include <linux/fb.h> |
| 13 | #include <linux/backlight.h> |
| 14 | #include <linux/mfd/adp5520.h> |
| 15 | |
| 16 | struct adp5520_bl { |
| 17 | struct device *master; |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 18 | struct adp5520_backlight_platform_data *pdata; |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 19 | struct mutex lock; |
| 20 | unsigned long cached_daylight_max; |
| 21 | int id; |
| 22 | int current_brightness; |
| 23 | }; |
| 24 | |
| 25 | static int adp5520_bl_set(struct backlight_device *bl, int brightness) |
| 26 | { |
| 27 | struct adp5520_bl *data = bl_get_data(bl); |
| 28 | struct device *master = data->master; |
| 29 | int ret = 0; |
| 30 | |
| 31 | if (data->pdata->en_ambl_sens) { |
| 32 | if ((brightness > 0) && (brightness < ADP5020_MAX_BRIGHTNESS)) { |
| 33 | /* Disable Ambient Light auto adjust */ |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 34 | ret |= adp5520_clr_bits(master, ADP5520_BL_CONTROL, |
| 35 | ADP5520_BL_AUTO_ADJ); |
| 36 | ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX, |
| 37 | brightness); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 38 | } else { |
| 39 | /* |
| 40 | * MAX_BRIGHTNESS -> Enable Ambient Light auto adjust |
| 41 | * restore daylight l3 sysfs brightness |
| 42 | */ |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 43 | ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX, |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 44 | data->cached_daylight_max); |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 45 | ret |= adp5520_set_bits(master, ADP5520_BL_CONTROL, |
| 46 | ADP5520_BL_AUTO_ADJ); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 47 | } |
| 48 | } else { |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 49 | ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX, brightness); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | if (data->current_brightness && brightness == 0) |
| 53 | ret |= adp5520_set_bits(master, |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 54 | ADP5520_MODE_STATUS, ADP5520_DIM_EN); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 55 | else if (data->current_brightness == 0 && brightness) |
| 56 | ret |= adp5520_clr_bits(master, |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 57 | ADP5520_MODE_STATUS, ADP5520_DIM_EN); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 58 | |
| 59 | if (!ret) |
| 60 | data->current_brightness = brightness; |
| 61 | |
| 62 | return ret; |
| 63 | } |
| 64 | |
| 65 | static int adp5520_bl_update_status(struct backlight_device *bl) |
| 66 | { |
| 67 | int brightness = bl->props.brightness; |
| 68 | if (bl->props.power != FB_BLANK_UNBLANK) |
| 69 | brightness = 0; |
| 70 | |
| 71 | if (bl->props.fb_blank != FB_BLANK_UNBLANK) |
| 72 | brightness = 0; |
| 73 | |
| 74 | return adp5520_bl_set(bl, brightness); |
| 75 | } |
| 76 | |
| 77 | static int adp5520_bl_get_brightness(struct backlight_device *bl) |
| 78 | { |
| 79 | struct adp5520_bl *data = bl_get_data(bl); |
| 80 | int error; |
| 81 | uint8_t reg_val; |
| 82 | |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 83 | error = adp5520_read(data->master, ADP5520_BL_VALUE, ®_val); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 84 | |
| 85 | return error ? data->current_brightness : reg_val; |
| 86 | } |
| 87 | |
Emese Revfy | 9905a43 | 2009-12-14 00:58:57 +0100 | [diff] [blame] | 88 | static const struct backlight_ops adp5520_bl_ops = { |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 89 | .update_status = adp5520_bl_update_status, |
| 90 | .get_brightness = adp5520_bl_get_brightness, |
| 91 | }; |
| 92 | |
| 93 | static int adp5520_bl_setup(struct backlight_device *bl) |
| 94 | { |
| 95 | struct adp5520_bl *data = bl_get_data(bl); |
| 96 | struct device *master = data->master; |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 97 | struct adp5520_backlight_platform_data *pdata = data->pdata; |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 98 | int ret = 0; |
| 99 | |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 100 | ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX, |
| 101 | pdata->l1_daylight_max); |
| 102 | ret |= adp5520_write(master, ADP5520_DAYLIGHT_DIM, |
| 103 | pdata->l1_daylight_dim); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 104 | |
| 105 | if (pdata->en_ambl_sens) { |
| 106 | data->cached_daylight_max = pdata->l1_daylight_max; |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 107 | ret |= adp5520_write(master, ADP5520_OFFICE_MAX, |
| 108 | pdata->l2_office_max); |
| 109 | ret |= adp5520_write(master, ADP5520_OFFICE_DIM, |
| 110 | pdata->l2_office_dim); |
| 111 | ret |= adp5520_write(master, ADP5520_DARK_MAX, |
| 112 | pdata->l3_dark_max); |
| 113 | ret |= adp5520_write(master, ADP5520_DARK_DIM, |
| 114 | pdata->l3_dark_dim); |
| 115 | ret |= adp5520_write(master, ADP5520_L2_TRIP, |
| 116 | pdata->l2_trip); |
| 117 | ret |= adp5520_write(master, ADP5520_L2_HYS, |
| 118 | pdata->l2_hyst); |
| 119 | ret |= adp5520_write(master, ADP5520_L3_TRIP, |
| 120 | pdata->l3_trip); |
| 121 | ret |= adp5520_write(master, ADP5520_L3_HYS, |
| 122 | pdata->l3_hyst); |
| 123 | ret |= adp5520_write(master, ADP5520_ALS_CMPR_CFG, |
| 124 | ALS_CMPR_CFG_VAL(pdata->abml_filt, |
| 125 | ADP5520_L3_EN)); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 126 | } |
| 127 | |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 128 | ret |= adp5520_write(master, ADP5520_BL_CONTROL, |
| 129 | BL_CTRL_VAL(pdata->fade_led_law, |
| 130 | pdata->en_ambl_sens)); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 131 | |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 132 | ret |= adp5520_write(master, ADP5520_BL_FADE, FADE_VAL(pdata->fade_in, |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 133 | pdata->fade_out)); |
| 134 | |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 135 | ret |= adp5520_set_bits(master, ADP5520_MODE_STATUS, |
| 136 | ADP5520_BL_EN | ADP5520_DIM_EN); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 137 | |
| 138 | return ret; |
| 139 | } |
| 140 | |
| 141 | static ssize_t adp5520_show(struct device *dev, char *buf, int reg) |
| 142 | { |
| 143 | struct adp5520_bl *data = dev_get_drvdata(dev); |
| 144 | int error; |
| 145 | uint8_t reg_val; |
| 146 | |
| 147 | mutex_lock(&data->lock); |
| 148 | error = adp5520_read(data->master, reg, ®_val); |
| 149 | mutex_unlock(&data->lock); |
| 150 | |
| 151 | return sprintf(buf, "%u\n", reg_val); |
| 152 | } |
| 153 | |
| 154 | static ssize_t adp5520_store(struct device *dev, const char *buf, |
| 155 | size_t count, int reg) |
| 156 | { |
| 157 | struct adp5520_bl *data = dev_get_drvdata(dev); |
| 158 | unsigned long val; |
| 159 | int ret; |
| 160 | |
| 161 | ret = strict_strtoul(buf, 10, &val); |
| 162 | if (ret) |
| 163 | return ret; |
| 164 | |
| 165 | mutex_lock(&data->lock); |
| 166 | adp5520_write(data->master, reg, val); |
| 167 | mutex_unlock(&data->lock); |
| 168 | |
| 169 | return count; |
| 170 | } |
| 171 | |
| 172 | static ssize_t adp5520_bl_dark_max_show(struct device *dev, |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 173 | struct device_attribute *attr, char *buf) |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 174 | { |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 175 | return adp5520_show(dev, buf, ADP5520_DARK_MAX); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | static ssize_t adp5520_bl_dark_max_store(struct device *dev, |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 179 | struct device_attribute *attr, |
| 180 | const char *buf, size_t count) |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 181 | { |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 182 | return adp5520_store(dev, buf, count, ADP5520_DARK_MAX); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 183 | } |
| 184 | static DEVICE_ATTR(dark_max, 0664, adp5520_bl_dark_max_show, |
| 185 | adp5520_bl_dark_max_store); |
| 186 | |
| 187 | static ssize_t adp5520_bl_office_max_show(struct device *dev, |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 188 | struct device_attribute *attr, char *buf) |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 189 | { |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 190 | return adp5520_show(dev, buf, ADP5520_OFFICE_MAX); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | static ssize_t adp5520_bl_office_max_store(struct device *dev, |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 194 | struct device_attribute *attr, |
| 195 | const char *buf, size_t count) |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 196 | { |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 197 | return adp5520_store(dev, buf, count, ADP5520_OFFICE_MAX); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 198 | } |
| 199 | static DEVICE_ATTR(office_max, 0664, adp5520_bl_office_max_show, |
| 200 | adp5520_bl_office_max_store); |
| 201 | |
| 202 | static ssize_t adp5520_bl_daylight_max_show(struct device *dev, |
| 203 | struct device_attribute *attr, char *buf) |
| 204 | { |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 205 | return adp5520_show(dev, buf, ADP5520_DAYLIGHT_MAX); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | static ssize_t adp5520_bl_daylight_max_store(struct device *dev, |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 209 | struct device_attribute *attr, |
| 210 | const char *buf, size_t count) |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 211 | { |
| 212 | struct adp5520_bl *data = dev_get_drvdata(dev); |
| 213 | |
| 214 | strict_strtoul(buf, 10, &data->cached_daylight_max); |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 215 | return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_MAX); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 216 | } |
| 217 | static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show, |
| 218 | adp5520_bl_daylight_max_store); |
| 219 | |
| 220 | static ssize_t adp5520_bl_dark_dim_show(struct device *dev, |
| 221 | struct device_attribute *attr, char *buf) |
| 222 | { |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 223 | return adp5520_show(dev, buf, ADP5520_DARK_DIM); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | static ssize_t adp5520_bl_dark_dim_store(struct device *dev, |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 227 | struct device_attribute *attr, |
| 228 | const char *buf, size_t count) |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 229 | { |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 230 | return adp5520_store(dev, buf, count, ADP5520_DARK_DIM); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 231 | } |
| 232 | static DEVICE_ATTR(dark_dim, 0664, adp5520_bl_dark_dim_show, |
| 233 | adp5520_bl_dark_dim_store); |
| 234 | |
| 235 | static ssize_t adp5520_bl_office_dim_show(struct device *dev, |
| 236 | struct device_attribute *attr, char *buf) |
| 237 | { |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 238 | return adp5520_show(dev, buf, ADP5520_OFFICE_DIM); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | static ssize_t adp5520_bl_office_dim_store(struct device *dev, |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 242 | struct device_attribute *attr, |
| 243 | const char *buf, size_t count) |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 244 | { |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 245 | return adp5520_store(dev, buf, count, ADP5520_OFFICE_DIM); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 246 | } |
| 247 | static DEVICE_ATTR(office_dim, 0664, adp5520_bl_office_dim_show, |
| 248 | adp5520_bl_office_dim_store); |
| 249 | |
| 250 | static ssize_t adp5520_bl_daylight_dim_show(struct device *dev, |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 251 | struct device_attribute *attr, char *buf) |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 252 | { |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 253 | return adp5520_show(dev, buf, ADP5520_DAYLIGHT_DIM); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | static ssize_t adp5520_bl_daylight_dim_store(struct device *dev, |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 257 | struct device_attribute *attr, |
| 258 | const char *buf, size_t count) |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 259 | { |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 260 | return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_DIM); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 261 | } |
| 262 | static DEVICE_ATTR(daylight_dim, 0664, adp5520_bl_daylight_dim_show, |
| 263 | adp5520_bl_daylight_dim_store); |
| 264 | |
| 265 | static struct attribute *adp5520_bl_attributes[] = { |
| 266 | &dev_attr_dark_max.attr, |
| 267 | &dev_attr_dark_dim.attr, |
| 268 | &dev_attr_office_max.attr, |
| 269 | &dev_attr_office_dim.attr, |
| 270 | &dev_attr_daylight_max.attr, |
| 271 | &dev_attr_daylight_dim.attr, |
| 272 | NULL |
| 273 | }; |
| 274 | |
| 275 | static const struct attribute_group adp5520_bl_attr_group = { |
| 276 | .attrs = adp5520_bl_attributes, |
| 277 | }; |
| 278 | |
| 279 | static int __devinit adp5520_bl_probe(struct platform_device *pdev) |
| 280 | { |
| 281 | struct backlight_device *bl; |
| 282 | struct adp5520_bl *data; |
| 283 | int ret = 0; |
| 284 | |
| 285 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
| 286 | if (data == NULL) |
| 287 | return -ENOMEM; |
| 288 | |
| 289 | data->master = pdev->dev.parent; |
| 290 | data->pdata = pdev->dev.platform_data; |
| 291 | |
| 292 | if (data->pdata == NULL) { |
| 293 | dev_err(&pdev->dev, "missing platform data\n"); |
| 294 | kfree(data); |
| 295 | return -ENODEV; |
| 296 | } |
| 297 | |
| 298 | data->id = pdev->id; |
| 299 | data->current_brightness = 0; |
| 300 | |
| 301 | mutex_init(&data->lock); |
| 302 | |
| 303 | bl = backlight_device_register(pdev->name, data->master, |
| 304 | data, &adp5520_bl_ops); |
| 305 | if (IS_ERR(bl)) { |
| 306 | dev_err(&pdev->dev, "failed to register backlight\n"); |
| 307 | kfree(data); |
| 308 | return PTR_ERR(bl); |
| 309 | } |
| 310 | |
| 311 | bl->props.max_brightness = |
| 312 | bl->props.brightness = ADP5020_MAX_BRIGHTNESS; |
| 313 | |
| 314 | if (data->pdata->en_ambl_sens) |
| 315 | ret = sysfs_create_group(&bl->dev.kobj, |
| 316 | &adp5520_bl_attr_group); |
| 317 | |
| 318 | if (ret) { |
| 319 | dev_err(&pdev->dev, "failed to register sysfs\n"); |
| 320 | backlight_device_unregister(bl); |
| 321 | kfree(data); |
| 322 | } |
| 323 | |
| 324 | platform_set_drvdata(pdev, bl); |
| 325 | ret |= adp5520_bl_setup(bl); |
| 326 | backlight_update_status(bl); |
| 327 | |
| 328 | return ret; |
| 329 | } |
| 330 | |
| 331 | static int __devexit adp5520_bl_remove(struct platform_device *pdev) |
| 332 | { |
| 333 | struct backlight_device *bl = platform_get_drvdata(pdev); |
| 334 | struct adp5520_bl *data = bl_get_data(bl); |
| 335 | |
Michael Hennerich | c24b6b6 | 2009-10-10 13:54:04 -0400 | [diff] [blame] | 336 | adp5520_clr_bits(data->master, ADP5520_MODE_STATUS, ADP5520_BL_EN); |
Michael Hennerich | a7998ce | 2009-09-17 14:29:52 -0400 | [diff] [blame] | 337 | |
| 338 | if (data->pdata->en_ambl_sens) |
| 339 | sysfs_remove_group(&bl->dev.kobj, |
| 340 | &adp5520_bl_attr_group); |
| 341 | |
| 342 | backlight_device_unregister(bl); |
| 343 | kfree(data); |
| 344 | |
| 345 | return 0; |
| 346 | } |
| 347 | |
| 348 | #ifdef CONFIG_PM |
| 349 | static int adp5520_bl_suspend(struct platform_device *pdev, |
| 350 | pm_message_t state) |
| 351 | { |
| 352 | struct backlight_device *bl = platform_get_drvdata(pdev); |
| 353 | return adp5520_bl_set(bl, 0); |
| 354 | } |
| 355 | |
| 356 | static int adp5520_bl_resume(struct platform_device *pdev) |
| 357 | { |
| 358 | struct backlight_device *bl = platform_get_drvdata(pdev); |
| 359 | |
| 360 | backlight_update_status(bl); |
| 361 | return 0; |
| 362 | } |
| 363 | #else |
| 364 | #define adp5520_bl_suspend NULL |
| 365 | #define adp5520_bl_resume NULL |
| 366 | #endif |
| 367 | |
| 368 | static struct platform_driver adp5520_bl_driver = { |
| 369 | .driver = { |
| 370 | .name = "adp5520-backlight", |
| 371 | .owner = THIS_MODULE, |
| 372 | }, |
| 373 | .probe = adp5520_bl_probe, |
| 374 | .remove = __devexit_p(adp5520_bl_remove), |
| 375 | .suspend = adp5520_bl_suspend, |
| 376 | .resume = adp5520_bl_resume, |
| 377 | }; |
| 378 | |
| 379 | static int __init adp5520_bl_init(void) |
| 380 | { |
| 381 | return platform_driver_register(&adp5520_bl_driver); |
| 382 | } |
| 383 | module_init(adp5520_bl_init); |
| 384 | |
| 385 | static void __exit adp5520_bl_exit(void) |
| 386 | { |
| 387 | platform_driver_unregister(&adp5520_bl_driver); |
| 388 | } |
| 389 | module_exit(adp5520_bl_exit); |
| 390 | |
| 391 | MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); |
| 392 | MODULE_DESCRIPTION("ADP5520(01) Backlight Driver"); |
| 393 | MODULE_LICENSE("GPL"); |
| 394 | MODULE_ALIAS("platform:adp5520-backlight"); |