block: move down direct IO plugging
[linux/fpc-iii.git] / drivers / video / backlight / jornada720_lcd.c
blob635b30523fd598556f674ff31c8d46031475718f
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 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 #include <linux/device.h>
15 #include <linux/fb.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 */
33 if (PPSR & PPC_LDD2)
34 return FB_BLANK_UNBLANK; /* PW ON */
35 else
36 return FB_BLANK_POWERDOWN; /* PW OFF */
39 static int jornada_lcd_get_contrast(struct lcd_device *dev)
41 int ret;
43 if (jornada_lcd_get_power(dev) != FB_BLANK_UNBLANK)
44 return 0;
46 jornada_ssp_start();
48 if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) {
49 pr_err("get contrast failed\n");
50 jornada_ssp_end();
51 return -ETIMEDOUT;
52 } else {
53 ret = jornada_ssp_byte(TXDUMMY);
54 jornada_ssp_end();
55 return ret;
59 static int jornada_lcd_set_contrast(struct lcd_device *dev, int value)
61 int ret;
63 jornada_ssp_start();
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");
71 jornada_ssp_end();
72 return -ETIMEDOUT;
75 /* if we get here we can assume everything went well */
76 jornada_ssp_end();
78 return 0;
81 static int jornada_lcd_set_power(struct lcd_device *dev, int power)
83 if (power != FB_BLANK_UNBLANK) {
84 PPSR &= ~PPC_LDD2;
85 PPDR |= PPC_LDD2;
86 } else
87 PPSR |= PPC_LDD2;
89 return 0;
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;
102 int ret;
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");
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 int jornada_lcd_remove(struct platform_device *pdev)
125 struct lcd_device *lcd_device = platform_get_drvdata(pdev);
127 lcd_device_unregister(lcd_device);
129 return 0;
132 static struct platform_driver jornada_lcd_driver = {
133 .probe = jornada_lcd_probe,
134 .remove = jornada_lcd_remove,
135 .driver = {
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");