3 * LCD driver for HP Jornada 700 series (710/720/728)
4 * Copyright (C) 2006-2009 Kristoffer Ericson <kristoffer.ericson@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 or any later version as published by the Free Software Foundation.
12 #include <linux/device.h>
14 #include <linux/kernel.h>
15 #include <linux/lcd.h>
16 #include <linux/module.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
20 #include <mach/jornada720.h>
21 #include <mach/hardware.h>
23 #include <video/s1d13xxxfb.h>
25 #define LCD_MAX_CONTRAST 0xff
26 #define LCD_DEF_CONTRAST 0x80
28 static int jornada_lcd_get_power(struct lcd_device
*dev
)
30 /* LDD2 in PPC = LCD POWER */
32 return FB_BLANK_UNBLANK
; /* PW ON */
34 return FB_BLANK_POWERDOWN
; /* PW OFF */
37 static int jornada_lcd_get_contrast(struct lcd_device
*dev
)
41 if (jornada_lcd_get_power(dev
) != FB_BLANK_UNBLANK
)
46 if (jornada_ssp_byte(GETCONTRAST
) != TXDUMMY
) {
47 printk(KERN_ERR
"lcd: get contrast failed\n");
51 ret
= jornada_ssp_byte(TXDUMMY
);
57 static int jornada_lcd_set_contrast(struct lcd_device
*dev
, int value
)
63 /* start by sending our set contrast cmd to mcu */
64 ret
= jornada_ssp_byte(SETCONTRAST
);
66 /* push the new value */
67 if (jornada_ssp_byte(value
) != TXDUMMY
) {
68 printk(KERN_ERR
"lcd : set contrast failed\n");
73 /* if we get here we can assume everything went well */
79 static int jornada_lcd_set_power(struct lcd_device
*dev
, int power
)
81 if (power
!= FB_BLANK_UNBLANK
) {
90 static struct lcd_ops jornada_lcd_props
= {
91 .get_contrast
= jornada_lcd_get_contrast
,
92 .set_contrast
= jornada_lcd_set_contrast
,
93 .get_power
= jornada_lcd_get_power
,
94 .set_power
= jornada_lcd_set_power
,
97 static int jornada_lcd_probe(struct platform_device
*pdev
)
99 struct lcd_device
*lcd_device
;
102 lcd_device
= lcd_device_register(S1D_DEVICENAME
, &pdev
->dev
, NULL
, &jornada_lcd_props
);
104 if (IS_ERR(lcd_device
)) {
105 ret
= PTR_ERR(lcd_device
);
106 printk(KERN_ERR
"lcd : failed to register device\n");
110 platform_set_drvdata(pdev
, lcd_device
);
112 /* lets set our default values */
113 jornada_lcd_set_contrast(lcd_device
, LCD_DEF_CONTRAST
);
114 jornada_lcd_set_power(lcd_device
, FB_BLANK_UNBLANK
);
115 /* give it some time to startup */
121 static int jornada_lcd_remove(struct platform_device
*pdev
)
123 struct lcd_device
*lcd_device
= platform_get_drvdata(pdev
);
125 lcd_device_unregister(lcd_device
);
130 static struct platform_driver jornada_lcd_driver
= {
131 .probe
= jornada_lcd_probe
,
132 .remove
= jornada_lcd_remove
,
134 .name
= "jornada_lcd",
138 static int __init
jornada_lcd_init(void)
140 return platform_driver_register(&jornada_lcd_driver
);
143 static void __exit
jornada_lcd_exit(void)
145 platform_driver_unregister(&jornada_lcd_driver
);
148 MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
149 MODULE_DESCRIPTION("HP Jornada 710/720/728 LCD driver");
150 MODULE_LICENSE("GPL");
152 module_init(jornada_lcd_init
);
153 module_exit(jornada_lcd_exit
);