PM / sleep: Asynchronous threads for suspend_noirq
[linux/fpc-iii.git] / drivers / video / backlight / jornada720_lcd.c
blobda3876c9b3ae70465b887838958687c7fd2a9675
1 /*
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>
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>
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 *ld)
30 /* LDD2 in PPC = LCD POWER */
31 if (PPSR & PPC_LDD2)
32 return FB_BLANK_UNBLANK; /* PW ON */
33 else
34 return FB_BLANK_POWERDOWN; /* PW OFF */
37 static int jornada_lcd_get_contrast(struct lcd_device *ld)
39 int ret;
41 if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK)
42 return 0;
44 jornada_ssp_start();
46 if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) {
47 dev_err(&ld->dev, "get contrast failed\n");
48 jornada_ssp_end();
49 return -ETIMEDOUT;
50 } else {
51 ret = jornada_ssp_byte(TXDUMMY);
52 jornada_ssp_end();
53 return ret;
57 static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
59 int ret;
61 jornada_ssp_start();
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 dev_err(&ld->dev, "set contrast failed\n");
69 jornada_ssp_end();
70 return -ETIMEDOUT;
73 /* if we get here we can assume everything went well */
74 jornada_ssp_end();
76 return 0;
79 static int jornada_lcd_set_power(struct lcd_device *ld, int power)
81 if (power != FB_BLANK_UNBLANK) {
82 PPSR &= ~PPC_LDD2;
83 PPDR |= PPC_LDD2;
84 } else {
85 PPSR |= PPC_LDD2;
88 return 0;
91 static struct lcd_ops jornada_lcd_props = {
92 .get_contrast = jornada_lcd_get_contrast,
93 .set_contrast = jornada_lcd_set_contrast,
94 .get_power = jornada_lcd_get_power,
95 .set_power = jornada_lcd_set_power,
98 static int jornada_lcd_probe(struct platform_device *pdev)
100 struct lcd_device *lcd_device;
101 int ret;
103 lcd_device = devm_lcd_device_register(&pdev->dev, S1D_DEVICENAME,
104 &pdev->dev, NULL, &jornada_lcd_props);
106 if (IS_ERR(lcd_device)) {
107 ret = PTR_ERR(lcd_device);
108 dev_err(&pdev->dev, "failed to register device\n");
109 return ret;
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 */
118 msleep(100);
120 return 0;
123 static struct platform_driver jornada_lcd_driver = {
124 .probe = jornada_lcd_probe,
125 .driver = {
126 .name = "jornada_lcd",
130 module_platform_driver(jornada_lcd_driver);
132 MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
133 MODULE_DESCRIPTION("HP Jornada 710/720/728 LCD driver");
134 MODULE_LICENSE("GPL");