hh.org updates
[hh.org.git] / arch / arm / mach-pxa / h3900 / h3900_lcd.c
blob9eeebed720e20375f53302a301996ba6cc6cb192
1 /*
2 * Hardware definitions for HP iPAQ Handheld Computers
4 * Copyright 2000-2003 Hewlett-Packard Company.
6 * Use consistent with the GNU GPL is permitted,
7 * provided that this copyright notice is
8 * preserved in its entirety in all copies and derived works.
10 * COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
11 * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
12 * FITNESS FOR ANY PARTICULAR PURPOSE.
14 * Author: Jamey Hicks.
16 * History:
18 * 2006-09-25 Paul Sokolovsky Split backlight code out to ease maintenance
19 * 2003-05-14 Joshua Wise Adapted for the HP iPAQ H1900
20 * 2002-08-23 Jamey Hicks Adapted for use with PXA250-based iPAQs
21 * 2001-10-?? Andrew Christian Added support for iPAQ H3800
22 * and abstracted EGPIO interface.
25 #include <linux/module.h>
26 #include <linux/init.h>
27 #include <linux/kernel.h>
28 #include <linux/tty.h>
29 #include <linux/sched.h>
30 #include <linux/delay.h>
31 #include <linux/pm.h>
32 #include <linux/lcd.h>
33 #include <linux/backlight.h>
34 #include <linux/fb.h>
35 #include <linux/err.h>
36 #include <linux/platform_device.h>
38 #include <asm/mach-types.h>
39 #include <asm/hardware.h>
40 #include <asm/setup.h>
42 #include <asm/mach/arch.h>
43 #include <asm/arch/pxa-regs.h>
44 #include <asm/arch/h3900-asic.h>
45 #include <asm/arch/ipaq.h>
47 #include <linux/soc/asic2_base.h>
48 #include <linux/soc/asic3_base.h>
50 extern struct platform_device h3900_asic2, h3900_asic3;
53 On screen enable, we get
55 h3800_lcd_power_on(1)
56 LCD controller starts
57 h3800_lcd_enable(1)
59 On screen disable, we get
61 h3800_lcd_enable(0)
62 LCD controller stops
63 h3800_lcd_power_on(0)
66 static int h3900_lcd_set_power( struct lcd_device *lm, int level )
68 if ( level < 1 ) {
69 asic3_set_gpio_out_b(&h3900_asic3.dev, GPIO3_LCD_ON, GPIO3_LCD_ON);
70 mdelay(30);
71 asic3_set_gpio_out_b(&h3900_asic3.dev, GPIO3_LCD_NV_ON, GPIO3_LCD_NV_ON);
72 mdelay(5);
73 asic3_set_gpio_out_b(&h3900_asic3.dev, GPIO3_LCD_9V_ON, GPIO3_LCD_9V_ON);
74 mdelay(50);
75 asic3_set_gpio_out_b(&h3900_asic3.dev, GPIO3_LCD_5V_ON, GPIO3_LCD_5V_ON);
76 mdelay(5);
77 } else {
78 mdelay(5);
79 asic3_set_gpio_out_b(&h3900_asic3.dev, GPIO3_LCD_5V_ON, 0);
80 mdelay(50);
81 asic3_set_gpio_out_b(&h3900_asic3.dev, GPIO3_LCD_9V_ON, 0);
82 mdelay(5);
83 asic3_set_gpio_out_b(&h3900_asic3.dev, GPIO3_LCD_NV_ON, 0);
84 mdelay(100);
85 asic3_set_gpio_out_b(&h3900_asic3.dev, GPIO3_LCD_ON, 0);
88 if ( level < 4 ) {
89 mdelay(17); // Wait one from before turning on
90 asic3_set_gpio_out_b(&h3900_asic3.dev, GPIO3_LCD_PCI, GPIO3_LCD_PCI);
91 } else {
92 asic3_set_gpio_out_b(&h3900_asic3.dev, GPIO3_LCD_PCI, 0);
93 mdelay(30); // Wait before turning off
96 return 0;
99 static int h3900_lcd_get_power( struct lcd_device *lm )
101 if (asic3_get_gpio_out_b(&h3900_asic3.dev) & GPIO3_LCD_PCI) {
102 if (asic3_get_gpio_out_b(&h3900_asic3.dev) & GPIO3_LCD_ON)
103 return 0;
104 else
105 return 2;
106 } else
107 return 4;
110 static struct lcd_properties h3900_lcd_properties = {
111 .owner = THIS_MODULE,
112 .set_power = h3900_lcd_set_power,
113 .get_power = h3900_lcd_get_power,
116 static struct lcd_device *pxafb_lcd_device;
118 static int h3900_lcd_probe(struct device * dev)
120 pxafb_lcd_device = lcd_device_register("pxafb", NULL, &h3900_lcd_properties);
121 if (IS_ERR (pxafb_lcd_device))
122 return PTR_ERR (pxafb_lcd_device);
124 h3900_lcd_set_power (pxafb_lcd_device, 0);
126 return 0;
129 static int h3900_lcd_remove(struct device * dev)
131 h3900_lcd_set_power(pxafb_lcd_device, 4);
132 lcd_device_unregister(pxafb_lcd_device);
134 return 0;
137 static int h3900_lcd_suspend(struct device * dev, pm_message_t state)
139 h3900_lcd_set_power(pxafb_lcd_device, 4);
140 return 0;
143 static int h3900_lcd_resume(struct device * dev)
145 h3900_lcd_set_power(pxafb_lcd_device, 0);
146 return 0;
149 static struct device_driver h3900_lcd_driver = {
150 .name = "h3900_lcd",
151 .bus = &platform_bus_type,
152 .probe = h3900_lcd_probe,
153 .remove = h3900_lcd_remove,
154 .suspend = h3900_lcd_suspend,
155 .resume = h3900_lcd_resume,
159 static int
160 h3900_lcd_init (void)
162 if (!machine_is_h3900())
163 return -ENODEV;
165 return driver_register(&h3900_lcd_driver);
167 return 0;
170 static void
171 h3900_lcd_exit (void)
173 lcd_device_unregister(pxafb_lcd_device);
174 driver_unregister(&h3900_lcd_driver);
177 module_init (h3900_lcd_init);
178 module_exit (h3900_lcd_exit);
180 MODULE_LICENSE("GPL");
181 MODULE_AUTHOR("Phil Blundell <pb@handhelds.org> and others");
182 MODULE_DESCRIPTION("iPAQ h3900 LCD driver glue");