2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
6 * iPAQ microcontroller backlight support
7 * Author : Linus Walleij <linus.walleij@linaro.org>
10 #include <linux/backlight.h>
11 #include <linux/err.h>
13 #include <linux/init.h>
14 #include <linux/mfd/ipaq-micro.h>
15 #include <linux/module.h>
16 #include <linux/platform_device.h>
18 static int micro_bl_update_status(struct backlight_device
*bd
)
20 struct ipaq_micro
*micro
= dev_get_drvdata(&bd
->dev
);
21 int intensity
= bd
->props
.brightness
;
22 struct ipaq_micro_msg msg
= {
27 if (bd
->props
.power
!= FB_BLANK_UNBLANK
)
29 if (bd
->props
.state
& (BL_CORE_FBBLANK
| BL_CORE_SUSPENDED
))
34 * Byte 0: backlight instance (usually 1)
36 * Byte 2: intensity, 0-255
38 msg
.tx_data
[0] = 0x01;
39 msg
.tx_data
[1] = intensity
> 0 ? 1 : 0;
40 msg
.tx_data
[2] = intensity
;
41 return ipaq_micro_tx_msg_sync(micro
, &msg
);
44 static const struct backlight_ops micro_bl_ops
= {
45 .options
= BL_CORE_SUSPENDRESUME
,
46 .update_status
= micro_bl_update_status
,
49 static struct backlight_properties micro_bl_props
= {
50 .type
= BACKLIGHT_RAW
,
51 .max_brightness
= 255,
52 .power
= FB_BLANK_UNBLANK
,
56 static int micro_backlight_probe(struct platform_device
*pdev
)
58 struct backlight_device
*bd
;
59 struct ipaq_micro
*micro
= dev_get_drvdata(pdev
->dev
.parent
);
61 bd
= devm_backlight_device_register(&pdev
->dev
, "ipaq-micro-backlight",
62 &pdev
->dev
, micro
, µ_bl_ops
,
67 platform_set_drvdata(pdev
, bd
);
68 backlight_update_status(bd
);
73 static struct platform_driver micro_backlight_device_driver
= {
75 .name
= "ipaq-micro-backlight",
77 .probe
= micro_backlight_probe
,
79 module_platform_driver(micro_backlight_device_driver
);
81 MODULE_LICENSE("GPL v2");
82 MODULE_DESCRIPTION("driver for iPAQ Atmel micro backlight");
83 MODULE_ALIAS("platform:ipaq-micro-backlight");