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 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 #include <linux/device.h>
16 #include <linux/kernel.h>
17 #include <linux/lcd.h>
18 #include <linux/module.h>
19 #include <linux/platform_device.h>
20 #include <linux/delay.h>
22 #include <mach/jornada720.h>
23 #include <mach/hardware.h>
25 #include <video/s1d13xxxfb.h>
27 #define LCD_MAX_CONTRAST 0xff
28 #define LCD_DEF_CONTRAST 0x80
30 static int jornada_lcd_get_power(struct lcd_device
*dev
)
32 /* LDD2 in PPC = LCD POWER */
34 return FB_BLANK_UNBLANK
; /* PW ON */
36 return FB_BLANK_POWERDOWN
; /* PW OFF */
39 static int jornada_lcd_get_contrast(struct lcd_device
*dev
)
43 if (jornada_lcd_get_power(dev
) != FB_BLANK_UNBLANK
)
48 if (jornada_ssp_byte(GETCONTRAST
) != TXDUMMY
) {
49 pr_err("get contrast failed\n");
53 ret
= jornada_ssp_byte(TXDUMMY
);
59 static int jornada_lcd_set_contrast(struct lcd_device
*dev
, int value
)
65 /* start by sending our set contrast cmd to mcu */
66 ret
= jornada_ssp_byte(SETCONTRAST
);
68 /* push the new value */
69 if (jornada_ssp_byte(value
) != TXDUMMY
) {
70 pr_err("set contrast failed\n");
75 /* if we get here we can assume everything went well */
81 static int jornada_lcd_set_power(struct lcd_device
*dev
, int power
)
83 if (power
!= FB_BLANK_UNBLANK
) {
92 static struct lcd_ops jornada_lcd_props
= {
93 .get_contrast
= jornada_lcd_get_contrast
,
94 .set_contrast
= jornada_lcd_set_contrast
,
95 .get_power
= jornada_lcd_get_power
,
96 .set_power
= jornada_lcd_set_power
,
99 static int jornada_lcd_probe(struct platform_device
*pdev
)
101 struct lcd_device
*lcd_device
;
104 lcd_device
= lcd_device_register(S1D_DEVICENAME
, &pdev
->dev
, NULL
, &jornada_lcd_props
);
106 if (IS_ERR(lcd_device
)) {
107 ret
= PTR_ERR(lcd_device
);
108 pr_err("failed to register device\n");
112 platform_set_drvdata(pdev
, lcd_device
);
114 /* lets set our default values */
115 jornada_lcd_set_contrast(lcd_device
, LCD_DEF_CONTRAST
);
116 jornada_lcd_set_power(lcd_device
, FB_BLANK_UNBLANK
);
117 /* give it some time to startup */
123 static int jornada_lcd_remove(struct platform_device
*pdev
)
125 struct lcd_device
*lcd_device
= platform_get_drvdata(pdev
);
127 lcd_device_unregister(lcd_device
);
132 static struct platform_driver jornada_lcd_driver
= {
133 .probe
= jornada_lcd_probe
,
134 .remove
= jornada_lcd_remove
,
136 .name
= "jornada_lcd",
140 module_platform_driver(jornada_lcd_driver
);
142 MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
143 MODULE_DESCRIPTION("HP Jornada 710/720/728 LCD driver");
144 MODULE_LICENSE("GPL");