xref: /linux/drivers/video/backlight/lm3533_bl.c (revision 1b9e450de105c1429a15f4e2566695f4f425672a)
17f26c970SJohan Hovold /*
27f26c970SJohan Hovold  * lm3533-bl.c -- LM3533 Backlight driver
37f26c970SJohan Hovold  *
47f26c970SJohan Hovold  * Copyright (C) 2011-2012 Texas Instruments
57f26c970SJohan Hovold  *
67f26c970SJohan Hovold  * Author: Johan Hovold <jhovold@gmail.com>
77f26c970SJohan Hovold  *
87f26c970SJohan Hovold  * This program is free software; you can redistribute it and/or modify it
97f26c970SJohan Hovold  * under  the terms of the GNU General  Public License as published by the
107f26c970SJohan Hovold  * Free Software Foundation;  either version 2 of the License, or (at your
117f26c970SJohan Hovold  * option) any later version.
127f26c970SJohan Hovold  */
137f26c970SJohan Hovold 
147f26c970SJohan Hovold #include <linux/module.h>
157f26c970SJohan Hovold #include <linux/init.h>
167f26c970SJohan Hovold #include <linux/platform_device.h>
177f26c970SJohan Hovold #include <linux/backlight.h>
187f26c970SJohan Hovold #include <linux/fb.h>
197f26c970SJohan Hovold #include <linux/slab.h>
207f26c970SJohan Hovold 
217f26c970SJohan Hovold #include <linux/mfd/lm3533.h>
227f26c970SJohan Hovold 
237f26c970SJohan Hovold 
247f26c970SJohan Hovold #define LM3533_HVCTRLBANK_COUNT		2
257f26c970SJohan Hovold #define LM3533_BL_MAX_BRIGHTNESS	255
267f26c970SJohan Hovold 
277f26c970SJohan Hovold #define LM3533_REG_CTRLBANK_AB_BCONF	0x1a
287f26c970SJohan Hovold 
297f26c970SJohan Hovold 
307f26c970SJohan Hovold struct lm3533_bl {
317f26c970SJohan Hovold 	struct lm3533 *lm3533;
327f26c970SJohan Hovold 	struct lm3533_ctrlbank cb;
337f26c970SJohan Hovold 	struct backlight_device *bd;
347f26c970SJohan Hovold 	int id;
357f26c970SJohan Hovold };
367f26c970SJohan Hovold 
377f26c970SJohan Hovold 
387f26c970SJohan Hovold static inline int lm3533_bl_get_ctrlbank_id(struct lm3533_bl *bl)
397f26c970SJohan Hovold {
407f26c970SJohan Hovold 	return bl->id;
417f26c970SJohan Hovold }
427f26c970SJohan Hovold 
437f26c970SJohan Hovold static int lm3533_bl_update_status(struct backlight_device *bd)
447f26c970SJohan Hovold {
457f26c970SJohan Hovold 	struct lm3533_bl *bl = bl_get_data(bd);
467f26c970SJohan Hovold 	int brightness = bd->props.brightness;
477f26c970SJohan Hovold 
487f26c970SJohan Hovold 	if (bd->props.power != FB_BLANK_UNBLANK)
497f26c970SJohan Hovold 		brightness = 0;
507f26c970SJohan Hovold 	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
517f26c970SJohan Hovold 		brightness = 0;
527f26c970SJohan Hovold 
537f26c970SJohan Hovold 	return lm3533_ctrlbank_set_brightness(&bl->cb, (u8)brightness);
547f26c970SJohan Hovold }
557f26c970SJohan Hovold 
567f26c970SJohan Hovold static int lm3533_bl_get_brightness(struct backlight_device *bd)
577f26c970SJohan Hovold {
587f26c970SJohan Hovold 	struct lm3533_bl *bl = bl_get_data(bd);
597f26c970SJohan Hovold 	u8 val;
607f26c970SJohan Hovold 	int ret;
617f26c970SJohan Hovold 
627f26c970SJohan Hovold 	ret = lm3533_ctrlbank_get_brightness(&bl->cb, &val);
637f26c970SJohan Hovold 	if (ret)
647f26c970SJohan Hovold 		return ret;
657f26c970SJohan Hovold 
667f26c970SJohan Hovold 	return val;
677f26c970SJohan Hovold }
687f26c970SJohan Hovold 
697f26c970SJohan Hovold static const struct backlight_ops lm3533_bl_ops = {
707f26c970SJohan Hovold 	.get_brightness	= lm3533_bl_get_brightness,
717f26c970SJohan Hovold 	.update_status	= lm3533_bl_update_status,
727f26c970SJohan Hovold };
737f26c970SJohan Hovold 
747f26c970SJohan Hovold static ssize_t show_id(struct device *dev,
757f26c970SJohan Hovold 				struct device_attribute *attr, char *buf)
767f26c970SJohan Hovold {
777f26c970SJohan Hovold 	struct lm3533_bl *bl = dev_get_drvdata(dev);
787f26c970SJohan Hovold 
797f26c970SJohan Hovold 	return scnprintf(buf, PAGE_SIZE, "%d\n", bl->id);
807f26c970SJohan Hovold }
817f26c970SJohan Hovold 
827f26c970SJohan Hovold static ssize_t show_als_channel(struct device *dev,
837f26c970SJohan Hovold 				struct device_attribute *attr, char *buf)
847f26c970SJohan Hovold {
857f26c970SJohan Hovold 	struct lm3533_bl *bl = dev_get_drvdata(dev);
867f26c970SJohan Hovold 	unsigned channel = lm3533_bl_get_ctrlbank_id(bl);
877f26c970SJohan Hovold 
887f26c970SJohan Hovold 	return scnprintf(buf, PAGE_SIZE, "%u\n", channel);
897f26c970SJohan Hovold }
907f26c970SJohan Hovold 
917f26c970SJohan Hovold static ssize_t show_als_en(struct device *dev,
927f26c970SJohan Hovold 				struct device_attribute *attr, char *buf)
937f26c970SJohan Hovold {
947f26c970SJohan Hovold 	struct lm3533_bl *bl = dev_get_drvdata(dev);
957f26c970SJohan Hovold 	int ctrlbank = lm3533_bl_get_ctrlbank_id(bl);
967f26c970SJohan Hovold 	u8 val;
977f26c970SJohan Hovold 	u8 mask;
987f26c970SJohan Hovold 	bool enable;
997f26c970SJohan Hovold 	int ret;
1007f26c970SJohan Hovold 
1017f26c970SJohan Hovold 	ret = lm3533_read(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, &val);
1027f26c970SJohan Hovold 	if (ret)
1037f26c970SJohan Hovold 		return ret;
1047f26c970SJohan Hovold 
1057f26c970SJohan Hovold 	mask = 1 << (2 * ctrlbank);
1067f26c970SJohan Hovold 	enable = val & mask;
1077f26c970SJohan Hovold 
1087f26c970SJohan Hovold 	return scnprintf(buf, PAGE_SIZE, "%d\n", enable);
1097f26c970SJohan Hovold }
1107f26c970SJohan Hovold 
1117f26c970SJohan Hovold static ssize_t store_als_en(struct device *dev,
1127f26c970SJohan Hovold 					struct device_attribute *attr,
1137f26c970SJohan Hovold 					const char *buf, size_t len)
1147f26c970SJohan Hovold {
1157f26c970SJohan Hovold 	struct lm3533_bl *bl = dev_get_drvdata(dev);
1167f26c970SJohan Hovold 	int ctrlbank = lm3533_bl_get_ctrlbank_id(bl);
1177f26c970SJohan Hovold 	int enable;
1187f26c970SJohan Hovold 	u8 val;
1197f26c970SJohan Hovold 	u8 mask;
1207f26c970SJohan Hovold 	int ret;
1217f26c970SJohan Hovold 
1227f26c970SJohan Hovold 	if (kstrtoint(buf, 0, &enable))
1237f26c970SJohan Hovold 		return -EINVAL;
1247f26c970SJohan Hovold 
1257f26c970SJohan Hovold 	mask = 1 << (2 * ctrlbank);
1267f26c970SJohan Hovold 
1277f26c970SJohan Hovold 	if (enable)
1287f26c970SJohan Hovold 		val = mask;
1297f26c970SJohan Hovold 	else
1307f26c970SJohan Hovold 		val = 0;
1317f26c970SJohan Hovold 
1327f26c970SJohan Hovold 	ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, val,
1337f26c970SJohan Hovold 									mask);
1347f26c970SJohan Hovold 	if (ret)
1357f26c970SJohan Hovold 		return ret;
1367f26c970SJohan Hovold 
1377f26c970SJohan Hovold 	return len;
1387f26c970SJohan Hovold }
1397f26c970SJohan Hovold 
1407f26c970SJohan Hovold static ssize_t show_linear(struct device *dev,
1417f26c970SJohan Hovold 				struct device_attribute *attr, char *buf)
1427f26c970SJohan Hovold {
1437f26c970SJohan Hovold 	struct lm3533_bl *bl = dev_get_drvdata(dev);
1447f26c970SJohan Hovold 	u8 val;
1457f26c970SJohan Hovold 	u8 mask;
1467f26c970SJohan Hovold 	int linear;
1477f26c970SJohan Hovold 	int ret;
1487f26c970SJohan Hovold 
1497f26c970SJohan Hovold 	ret = lm3533_read(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, &val);
1507f26c970SJohan Hovold 	if (ret)
1517f26c970SJohan Hovold 		return ret;
1527f26c970SJohan Hovold 
1537f26c970SJohan Hovold 	mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1);
1547f26c970SJohan Hovold 
1557f26c970SJohan Hovold 	if (val & mask)
1567f26c970SJohan Hovold 		linear = 1;
1577f26c970SJohan Hovold 	else
1587f26c970SJohan Hovold 		linear = 0;
1597f26c970SJohan Hovold 
1607f26c970SJohan Hovold 	return scnprintf(buf, PAGE_SIZE, "%x\n", linear);
1617f26c970SJohan Hovold }
1627f26c970SJohan Hovold 
1637f26c970SJohan Hovold static ssize_t store_linear(struct device *dev,
1647f26c970SJohan Hovold 					struct device_attribute *attr,
1657f26c970SJohan Hovold 					const char *buf, size_t len)
1667f26c970SJohan Hovold {
1677f26c970SJohan Hovold 	struct lm3533_bl *bl = dev_get_drvdata(dev);
1687f26c970SJohan Hovold 	unsigned long linear;
1697f26c970SJohan Hovold 	u8 mask;
1707f26c970SJohan Hovold 	u8 val;
1717f26c970SJohan Hovold 	int ret;
1727f26c970SJohan Hovold 
1737f26c970SJohan Hovold 	if (kstrtoul(buf, 0, &linear))
1747f26c970SJohan Hovold 		return -EINVAL;
1757f26c970SJohan Hovold 
1767f26c970SJohan Hovold 	mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1);
1777f26c970SJohan Hovold 
1787f26c970SJohan Hovold 	if (linear)
1797f26c970SJohan Hovold 		val = mask;
1807f26c970SJohan Hovold 	else
1817f26c970SJohan Hovold 		val = 0;
1827f26c970SJohan Hovold 
1837f26c970SJohan Hovold 	ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, val,
1847f26c970SJohan Hovold 									mask);
1857f26c970SJohan Hovold 	if (ret)
1867f26c970SJohan Hovold 		return ret;
1877f26c970SJohan Hovold 
1887f26c970SJohan Hovold 	return len;
1897f26c970SJohan Hovold }
1907f26c970SJohan Hovold 
1917f26c970SJohan Hovold static ssize_t show_pwm(struct device *dev,
1927f26c970SJohan Hovold 					struct device_attribute *attr,
1937f26c970SJohan Hovold 					char *buf)
1947f26c970SJohan Hovold {
1957f26c970SJohan Hovold 	struct lm3533_bl *bl = dev_get_drvdata(dev);
1967f26c970SJohan Hovold 	u8 val;
1977f26c970SJohan Hovold 	int ret;
1987f26c970SJohan Hovold 
1997f26c970SJohan Hovold 	ret = lm3533_ctrlbank_get_pwm(&bl->cb, &val);
2007f26c970SJohan Hovold 	if (ret)
2017f26c970SJohan Hovold 		return ret;
2027f26c970SJohan Hovold 
2037f26c970SJohan Hovold 	return scnprintf(buf, PAGE_SIZE, "%u\n", val);
2047f26c970SJohan Hovold }
2057f26c970SJohan Hovold 
2067f26c970SJohan Hovold static ssize_t store_pwm(struct device *dev,
2077f26c970SJohan Hovold 					struct device_attribute *attr,
2087f26c970SJohan Hovold 					const char *buf, size_t len)
2097f26c970SJohan Hovold {
2107f26c970SJohan Hovold 	struct lm3533_bl *bl = dev_get_drvdata(dev);
2117f26c970SJohan Hovold 	u8 val;
2127f26c970SJohan Hovold 	int ret;
2137f26c970SJohan Hovold 
2147f26c970SJohan Hovold 	if (kstrtou8(buf, 0, &val))
2157f26c970SJohan Hovold 		return -EINVAL;
2167f26c970SJohan Hovold 
2177f26c970SJohan Hovold 	ret = lm3533_ctrlbank_set_pwm(&bl->cb, val);
2187f26c970SJohan Hovold 	if (ret)
2197f26c970SJohan Hovold 		return ret;
2207f26c970SJohan Hovold 
2217f26c970SJohan Hovold 	return len;
2227f26c970SJohan Hovold }
2237f26c970SJohan Hovold 
2247f26c970SJohan Hovold static LM3533_ATTR_RO(als_channel);
2257f26c970SJohan Hovold static LM3533_ATTR_RW(als_en);
2267f26c970SJohan Hovold static LM3533_ATTR_RO(id);
2277f26c970SJohan Hovold static LM3533_ATTR_RW(linear);
2287f26c970SJohan Hovold static LM3533_ATTR_RW(pwm);
2297f26c970SJohan Hovold 
2307f26c970SJohan Hovold static struct attribute *lm3533_bl_attributes[] = {
2317f26c970SJohan Hovold 	&dev_attr_als_channel.attr,
2327f26c970SJohan Hovold 	&dev_attr_als_en.attr,
2337f26c970SJohan Hovold 	&dev_attr_id.attr,
2347f26c970SJohan Hovold 	&dev_attr_linear.attr,
2357f26c970SJohan Hovold 	&dev_attr_pwm.attr,
2367f26c970SJohan Hovold 	NULL,
2377f26c970SJohan Hovold };
2387f26c970SJohan Hovold 
2397f26c970SJohan Hovold static umode_t lm3533_bl_attr_is_visible(struct kobject *kobj,
2407f26c970SJohan Hovold 					     struct attribute *attr, int n)
2417f26c970SJohan Hovold {
2427f26c970SJohan Hovold 	struct device *dev = container_of(kobj, struct device, kobj);
2437f26c970SJohan Hovold 	struct lm3533_bl *bl = dev_get_drvdata(dev);
2447f26c970SJohan Hovold 	umode_t mode = attr->mode;
2457f26c970SJohan Hovold 
2467f26c970SJohan Hovold 	if (attr == &dev_attr_als_channel.attr ||
2477f26c970SJohan Hovold 					attr == &dev_attr_als_en.attr) {
2487f26c970SJohan Hovold 		if (!bl->lm3533->have_als)
2497f26c970SJohan Hovold 			mode = 0;
2507f26c970SJohan Hovold 	}
2517f26c970SJohan Hovold 
2527f26c970SJohan Hovold 	return mode;
2537f26c970SJohan Hovold };
2547f26c970SJohan Hovold 
2557f26c970SJohan Hovold static struct attribute_group lm3533_bl_attribute_group = {
2567f26c970SJohan Hovold 	.is_visible	= lm3533_bl_attr_is_visible,
2577f26c970SJohan Hovold 	.attrs		= lm3533_bl_attributes
2587f26c970SJohan Hovold };
2597f26c970SJohan Hovold 
260*1b9e450dSBill Pemberton static int lm3533_bl_setup(struct lm3533_bl *bl,
2617f26c970SJohan Hovold 					struct lm3533_bl_platform_data *pdata)
2627f26c970SJohan Hovold {
2637f26c970SJohan Hovold 	int ret;
2647f26c970SJohan Hovold 
2657f26c970SJohan Hovold 	ret = lm3533_ctrlbank_set_max_current(&bl->cb, pdata->max_current);
2667f26c970SJohan Hovold 	if (ret)
2677f26c970SJohan Hovold 		return ret;
2687f26c970SJohan Hovold 
2697f26c970SJohan Hovold 	return lm3533_ctrlbank_set_pwm(&bl->cb, pdata->pwm);
2707f26c970SJohan Hovold }
2717f26c970SJohan Hovold 
272*1b9e450dSBill Pemberton static int lm3533_bl_probe(struct platform_device *pdev)
2737f26c970SJohan Hovold {
2747f26c970SJohan Hovold 	struct lm3533 *lm3533;
2757f26c970SJohan Hovold 	struct lm3533_bl_platform_data *pdata;
2767f26c970SJohan Hovold 	struct lm3533_bl *bl;
2777f26c970SJohan Hovold 	struct backlight_device *bd;
2787f26c970SJohan Hovold 	struct backlight_properties props;
2797f26c970SJohan Hovold 	int ret;
2807f26c970SJohan Hovold 
2817f26c970SJohan Hovold 	dev_dbg(&pdev->dev, "%s\n", __func__);
2827f26c970SJohan Hovold 
2837f26c970SJohan Hovold 	lm3533 = dev_get_drvdata(pdev->dev.parent);
2847f26c970SJohan Hovold 	if (!lm3533)
2857f26c970SJohan Hovold 		return -EINVAL;
2867f26c970SJohan Hovold 
2877f26c970SJohan Hovold 	pdata = pdev->dev.platform_data;
2887f26c970SJohan Hovold 	if (!pdata) {
2897f26c970SJohan Hovold 		dev_err(&pdev->dev, "no platform data\n");
2907f26c970SJohan Hovold 		return -EINVAL;
2917f26c970SJohan Hovold 	}
2927f26c970SJohan Hovold 
2937f26c970SJohan Hovold 	if (pdev->id < 0 || pdev->id >= LM3533_HVCTRLBANK_COUNT) {
2947f26c970SJohan Hovold 		dev_err(&pdev->dev, "illegal backlight id %d\n", pdev->id);
2957f26c970SJohan Hovold 		return -EINVAL;
2967f26c970SJohan Hovold 	}
2977f26c970SJohan Hovold 
298b4a74615SJingoo Han 	bl = devm_kzalloc(&pdev->dev, sizeof(*bl), GFP_KERNEL);
2997f26c970SJohan Hovold 	if (!bl) {
3007f26c970SJohan Hovold 		dev_err(&pdev->dev,
3017f26c970SJohan Hovold 				"failed to allocate memory for backlight\n");
3027f26c970SJohan Hovold 		return -ENOMEM;
3037f26c970SJohan Hovold 	}
3047f26c970SJohan Hovold 
3057f26c970SJohan Hovold 	bl->lm3533 = lm3533;
3067f26c970SJohan Hovold 	bl->id = pdev->id;
3077f26c970SJohan Hovold 
3087f26c970SJohan Hovold 	bl->cb.lm3533 = lm3533;
3097f26c970SJohan Hovold 	bl->cb.id = lm3533_bl_get_ctrlbank_id(bl);
3107f26c970SJohan Hovold 	bl->cb.dev = NULL;			/* until registered */
3117f26c970SJohan Hovold 
3127f26c970SJohan Hovold 	memset(&props, 0, sizeof(props));
3137f26c970SJohan Hovold 	props.type = BACKLIGHT_RAW;
3147f26c970SJohan Hovold 	props.max_brightness = LM3533_BL_MAX_BRIGHTNESS;
3157f26c970SJohan Hovold 	props.brightness = pdata->default_brightness;
3167f26c970SJohan Hovold 	bd = backlight_device_register(pdata->name, pdev->dev.parent, bl,
3177f26c970SJohan Hovold 						&lm3533_bl_ops, &props);
3187f26c970SJohan Hovold 	if (IS_ERR(bd)) {
3197f26c970SJohan Hovold 		dev_err(&pdev->dev, "failed to register backlight device\n");
320b4a74615SJingoo Han 		return PTR_ERR(bd);
3217f26c970SJohan Hovold 	}
3227f26c970SJohan Hovold 
3237f26c970SJohan Hovold 	bl->bd = bd;
3247f26c970SJohan Hovold 	bl->cb.dev = &bl->bd->dev;
3257f26c970SJohan Hovold 
3267f26c970SJohan Hovold 	platform_set_drvdata(pdev, bl);
3277f26c970SJohan Hovold 
3287f26c970SJohan Hovold 	ret = sysfs_create_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
3297f26c970SJohan Hovold 	if (ret < 0) {
3307f26c970SJohan Hovold 		dev_err(&pdev->dev, "failed to create sysfs attributes\n");
3317f26c970SJohan Hovold 		goto err_unregister;
3327f26c970SJohan Hovold 	}
3337f26c970SJohan Hovold 
3347f26c970SJohan Hovold 	backlight_update_status(bd);
3357f26c970SJohan Hovold 
3367f26c970SJohan Hovold 	ret = lm3533_bl_setup(bl, pdata);
3377f26c970SJohan Hovold 	if (ret)
3387f26c970SJohan Hovold 		goto err_sysfs_remove;
3397f26c970SJohan Hovold 
3407f26c970SJohan Hovold 	ret = lm3533_ctrlbank_enable(&bl->cb);
3417f26c970SJohan Hovold 	if (ret)
3427f26c970SJohan Hovold 		goto err_sysfs_remove;
3437f26c970SJohan Hovold 
3447f26c970SJohan Hovold 	return 0;
3457f26c970SJohan Hovold 
3467f26c970SJohan Hovold err_sysfs_remove:
3477f26c970SJohan Hovold 	sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
3487f26c970SJohan Hovold err_unregister:
3497f26c970SJohan Hovold 	backlight_device_unregister(bd);
3507f26c970SJohan Hovold 
3517f26c970SJohan Hovold 	return ret;
3527f26c970SJohan Hovold }
3537f26c970SJohan Hovold 
3547f26c970SJohan Hovold static int __devexit lm3533_bl_remove(struct platform_device *pdev)
3557f26c970SJohan Hovold {
3567f26c970SJohan Hovold 	struct lm3533_bl *bl = platform_get_drvdata(pdev);
3577f26c970SJohan Hovold 	struct backlight_device *bd = bl->bd;
3587f26c970SJohan Hovold 
3597f26c970SJohan Hovold 	dev_dbg(&bd->dev, "%s\n", __func__);
3607f26c970SJohan Hovold 
3617f26c970SJohan Hovold 	bd->props.power = FB_BLANK_POWERDOWN;
3627f26c970SJohan Hovold 	bd->props.brightness = 0;
3637f26c970SJohan Hovold 
3647f26c970SJohan Hovold 	lm3533_ctrlbank_disable(&bl->cb);
3657f26c970SJohan Hovold 	sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
3667f26c970SJohan Hovold 	backlight_device_unregister(bd);
3677f26c970SJohan Hovold 
3687f26c970SJohan Hovold 	return 0;
3697f26c970SJohan Hovold }
3707f26c970SJohan Hovold 
3717f26c970SJohan Hovold #ifdef CONFIG_PM
3727f26c970SJohan Hovold static int lm3533_bl_suspend(struct platform_device *pdev, pm_message_t state)
3737f26c970SJohan Hovold {
3747f26c970SJohan Hovold 	struct lm3533_bl *bl = platform_get_drvdata(pdev);
3757f26c970SJohan Hovold 
3767f26c970SJohan Hovold 	dev_dbg(&pdev->dev, "%s\n", __func__);
3777f26c970SJohan Hovold 
3787f26c970SJohan Hovold 	return lm3533_ctrlbank_disable(&bl->cb);
3797f26c970SJohan Hovold }
3807f26c970SJohan Hovold 
3817f26c970SJohan Hovold static int lm3533_bl_resume(struct platform_device *pdev)
3827f26c970SJohan Hovold {
3837f26c970SJohan Hovold 	struct lm3533_bl *bl = platform_get_drvdata(pdev);
3847f26c970SJohan Hovold 
3857f26c970SJohan Hovold 	dev_dbg(&pdev->dev, "%s\n", __func__);
3867f26c970SJohan Hovold 
3877f26c970SJohan Hovold 	return lm3533_ctrlbank_enable(&bl->cb);
3887f26c970SJohan Hovold }
3897f26c970SJohan Hovold #else
3907f26c970SJohan Hovold #define lm3533_bl_suspend	NULL
3917f26c970SJohan Hovold #define lm3533_bl_resume	NULL
3927f26c970SJohan Hovold #endif
3937f26c970SJohan Hovold 
3947f26c970SJohan Hovold static void lm3533_bl_shutdown(struct platform_device *pdev)
3957f26c970SJohan Hovold {
3967f26c970SJohan Hovold 	struct lm3533_bl *bl = platform_get_drvdata(pdev);
3977f26c970SJohan Hovold 
3987f26c970SJohan Hovold 	dev_dbg(&pdev->dev, "%s\n", __func__);
3997f26c970SJohan Hovold 
4007f26c970SJohan Hovold 	lm3533_ctrlbank_disable(&bl->cb);
4017f26c970SJohan Hovold }
4027f26c970SJohan Hovold 
4037f26c970SJohan Hovold static struct platform_driver lm3533_bl_driver = {
4047f26c970SJohan Hovold 	.driver = {
4057f26c970SJohan Hovold 		.name	= "lm3533-backlight",
4067f26c970SJohan Hovold 		.owner	= THIS_MODULE,
4077f26c970SJohan Hovold 	},
4087f26c970SJohan Hovold 	.probe		= lm3533_bl_probe,
409d1723fa2SBill Pemberton 	.remove		= lm3533_bl_remove,
4107f26c970SJohan Hovold 	.shutdown	= lm3533_bl_shutdown,
4117f26c970SJohan Hovold 	.suspend	= lm3533_bl_suspend,
4127f26c970SJohan Hovold 	.resume		= lm3533_bl_resume,
4137f26c970SJohan Hovold };
4147f26c970SJohan Hovold module_platform_driver(lm3533_bl_driver);
4157f26c970SJohan Hovold 
4167f26c970SJohan Hovold MODULE_AUTHOR("Johan Hovold <jhovold@gmail.com>");
4177f26c970SJohan Hovold MODULE_DESCRIPTION("LM3533 Backlight driver");
4187f26c970SJohan Hovold MODULE_LICENSE("GPL");
4197f26c970SJohan Hovold MODULE_ALIAS("platform:lm3533-backlight");
420