5 * This file contains the definitions for the LCD timings and functions
6 * to control the LCD power / frontlighting via the w100fb driver.
9 #include <linux/platform_device.h>
11 #include <linux/module.h>
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/tty.h>
15 #include <linux/sched.h>
16 #include <linux/delay.h>
18 #include <linux/lcd.h>
19 #include <linux/backlight.h>
21 #include <linux/err.h>
24 #include <asm/mach-types.h>
25 #include <asm/hardware.h>
26 #include <asm/setup.h>
28 #include <asm/mach/arch.h>
29 #include <asm/arch/pxa-regs.h>
30 #include <asm/arch/eseries-gpio.h>
32 #include <video/w100fb.h>
34 /* ------------------- backlight driver ------------------ */
36 static int current_brightness
= 0;
38 static int e740_bl_update_status (struct backlight_device
*bd
)
40 int intensity
= bd
->props
->brightness
;
43 if (bd
->props
->power
!= FB_BLANK_UNBLANK
)
45 if (bd
->props
->fb_blank
!= FB_BLANK_UNBLANK
)
48 current_brightness
=intensity
;
50 gpio
= w100fb_gpio_read(W100_GPIO_PORT_B
);
53 gpio
|= (((intensity
-1) & 0x3) << 4) | 1;
54 w100fb_gpio_write(W100_GPIO_PORT_B
, gpio
);
59 static int e740_bl_get_brightness (struct backlight_device
*bl
)
61 return current_brightness
;
64 static struct backlight_properties e740_bl_info
= {
66 .update_status
= e740_bl_update_status
,
68 .get_brightness
= e740_bl_get_brightness
,
71 /* -------------------------- LCD driver -----------------------*/
75 void __e740_lcd_set_power(int power
)
78 gpio
= w100fb_gpio_read(W100_GPIO_PORT_B
);
83 w100fb_gpio_write(W100_GPIO_PORT_B
, gpio
);
86 static int e740_lcd_set_power (struct lcd_device
*ld
, int state
)
89 __e740_lcd_set_power(lcd_power
);
94 static int e740_lcd_get_power (struct lcd_device
*ld
){
98 static struct lcd_properties e740_lcd_info
= {
100 .get_power
= e740_lcd_get_power
,
101 .set_power
= e740_lcd_set_power
,
104 /* ----------------------- device declarations -------------------------- */
107 static int e740_lcd_hook_suspend(struct platform_device
*dev
, pm_message_t state
)
109 __e740_lcd_set_power(1);
110 // __e740_set_brightness(NULL, 0);
114 static int e740_lcd_hook_resume(struct platform_device
*dev
)
116 // e740_bl_set_power(NULL, FB_BLANK_UNBLANK);
117 __e740_lcd_set_power(lcd_power
);
123 static struct backlight_device
*e740_bl_device
;
124 static struct lcd_device
*e740_lcd_device
;
126 static int e740_lcd_hook_probe (struct platform_device
*dev
) {
127 e740_lcd_device
= lcd_device_register("w100fb", NULL
, &e740_lcd_info
);
128 e740_bl_device
= backlight_device_register("w100fb", NULL
, &e740_bl_info
);
132 static int e740_lcd_hook_remove(struct platform_device
*dev
)
134 lcd_device_unregister(e740_lcd_device
);
135 backlight_device_unregister(e740_bl_device
);
139 static struct platform_driver e740_lcd_hook_driver
= {
141 .name
= "e740-lcd-hook",
143 .probe
= e740_lcd_hook_probe
,
144 .remove
= e740_lcd_hook_remove
,
146 .suspend
= e740_lcd_hook_suspend
,
147 .resume
= e740_lcd_hook_resume
,
151 static int e740_bl_init (void) {
152 return platform_driver_register(&e740_lcd_hook_driver
);
155 static void e740_bl_exit (void)
157 platform_driver_unregister(&e740_lcd_hook_driver
);
160 module_init (e740_bl_init
);
161 module_exit (e740_bl_exit
);
163 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
164 MODULE_DESCRIPTION("e740 lcd driver");
165 MODULE_LICENSE("GPLv2");