1
2
3
4
5
6
7
8
9
10
11
12#include <linux/device.h>
13#include <linux/fb.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>
19
20#include <mach/jornada720.h>
21#include <mach/hardware.h>
22
23#include <video/s1d13xxxfb.h>
24
25#define LCD_MAX_CONTRAST 0xff
26#define LCD_DEF_CONTRAST 0x80
27
28static int jornada_lcd_get_power(struct lcd_device *ld)
29{
30 return PPSR & PPC_LDD2 ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
31}
32
33static int jornada_lcd_get_contrast(struct lcd_device *ld)
34{
35 int ret;
36
37 if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK)
38 return 0;
39
40 jornada_ssp_start();
41
42 if (jornada_ssp_byte(GETCONTRAST) == TXDUMMY) {
43 ret = jornada_ssp_byte(TXDUMMY);
44 goto success;
45 }
46
47 dev_err(&ld->dev, "failed to set contrast\n");
48 ret = -ETIMEDOUT;
49
50success:
51 jornada_ssp_end();
52 return ret;
53}
54
55static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
56{
57 int ret = 0;
58
59 jornada_ssp_start();
60
61
62 if (jornada_ssp_byte(SETCONTRAST) == TXDUMMY) {
63
64 if (jornada_ssp_byte(value) == TXDUMMY)
65 goto success;
66 }
67
68 dev_err(&ld->dev, "failed to set contrast\n");
69 ret = -ETIMEDOUT;
70
71success:
72 jornada_ssp_end();
73 return ret;
74}
75
76static int jornada_lcd_set_power(struct lcd_device *ld, int power)
77{
78 if (power != FB_BLANK_UNBLANK) {
79 PPSR &= ~PPC_LDD2;
80 PPDR |= PPC_LDD2;
81 } else {
82 PPSR |= PPC_LDD2;
83 }
84
85 return 0;
86}
87
88static struct lcd_ops jornada_lcd_props = {
89 .get_contrast = jornada_lcd_get_contrast,
90 .set_contrast = jornada_lcd_set_contrast,
91 .get_power = jornada_lcd_get_power,
92 .set_power = jornada_lcd_set_power,
93};
94
95static int jornada_lcd_probe(struct platform_device *pdev)
96{
97 struct lcd_device *lcd_device;
98 int ret;
99
100 lcd_device = devm_lcd_device_register(&pdev->dev, S1D_DEVICENAME,
101 &pdev->dev, NULL, &jornada_lcd_props);
102
103 if (IS_ERR(lcd_device)) {
104 ret = PTR_ERR(lcd_device);
105 dev_err(&pdev->dev, "failed to register device\n");
106 return ret;
107 }
108
109 platform_set_drvdata(pdev, lcd_device);
110
111
112 jornada_lcd_set_contrast(lcd_device, LCD_DEF_CONTRAST);
113 jornada_lcd_set_power(lcd_device, FB_BLANK_UNBLANK);
114
115 msleep(100);
116
117 return 0;
118}
119
120static struct platform_driver jornada_lcd_driver = {
121 .probe = jornada_lcd_probe,
122 .driver = {
123 .name = "jornada_lcd",
124 },
125};
126
127module_platform_driver(jornada_lcd_driver);
128
129MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
130MODULE_DESCRIPTION("HP Jornada 710/720/728 LCD driver");
131MODULE_LICENSE("GPL");
132