hh.org updates
[hh.org.git] / arch / arm / mach-pxa / h4000 / h4000_lcd.c
blob8b50f3afa83479e8a229e623b2cbd82d08492494
1 /*
2 * Use consistent with the GNU GPL is permitted,
3 * provided that this copyright notice is
4 * preserved in its entirety in all copies and derived works.
6 * History:
8 * 2004-03-01 Eddi De Pieri Adapted for h4000 using h3900_lcd.c
9 * 2004 Shawn Anderson Lcd hacking on h4000
10 * see h3900_lcd.c for more history.
14 #include <linux/types.h>
15 #include <asm/arch/hardware.h> /* for pxa-regs.h (__REG) */
16 #include <linux/platform_device.h>
17 #include <asm/arch/pxa-regs.h> /* LCCR[0,1,2,3]* */
18 #include <asm/arch/bitfield.h> /* for pxa-regs.h (Fld, etc) */
19 #include <asm/arch/pxafb.h> /* pxafb_mach_info, set_pxa_fb_info */
20 #include <asm/mach-types.h> /* machine_is_h4000 */
21 #include <linux/lcd.h> /* lcd_device */
22 #include <linux/backlight.h> /* backlight_device */
23 #include <linux/fb.h>
24 #include <linux/err.h>
25 #include <linux/delay.h>
27 #include <asm/arch/h4000-gpio.h>
28 #include <asm/arch/h4000-asic.h>
29 #include <asm/hardware/ipaq-asic3.h>
30 #include <linux/soc/asic3_base.h>
32 extern struct platform_device h4000_asic3;
34 static int h4000_lcd_get_power(struct lcd_device *lm)
36 /* Get the LCD panel power status (0: full on, 1..3: controller
37 * power on, flat panel power off, 4: full off) */
39 if (asic3_get_gpio_status_b(&h4000_asic3.dev) & GPIOB_LCD_PCI) {
40 if (asic3_get_gpio_out_b(&h4000_asic3.dev) & GPIOB_LCD_ON)
41 return 0;
42 else
43 return 2;
44 } else
45 return 4;
48 static int h4000_lcd_set_power(struct lcd_device *lm, int power)
50 /* Enable or disable power to the LCD (0: on; 4: off) */
52 if ( power < 1 ) {
53 asic3_set_gpio_out_c(&h4000_asic3.dev,
54 GPIOC_LCD_3V3_ON, GPIOC_LCD_3V3_ON);
55 mdelay(30);
56 asic3_set_gpio_out_c(&h4000_asic3.dev,
57 GPIOC_LCD_N3V_EN, GPIOC_LCD_N3V_EN);
58 mdelay(5);
59 asic3_set_gpio_out_b(&h4000_asic3.dev,
60 GPIOB_LCD_ON, GPIOB_LCD_ON);
61 mdelay(50);
62 asic3_set_gpio_out_c(&h4000_asic3.dev,
63 GPIOC_LCD_5V_EN, GPIOC_LCD_5V_EN);
64 mdelay(5);
65 } else {
66 mdelay(5);
67 asic3_set_gpio_out_c(&h4000_asic3.dev, GPIOC_LCD_5V_EN, 0);
68 mdelay(50);
69 asic3_set_gpio_out_b(&h4000_asic3.dev, GPIOB_LCD_ON, 0);
70 mdelay(5);
71 asic3_set_gpio_out_c(&h4000_asic3.dev, GPIOC_LCD_N3V_EN,0);
72 mdelay(100);
73 asic3_set_gpio_out_c(&h4000_asic3.dev, GPIOC_LCD_3V3_ON,0);
76 if ( power < 4 ) {
77 mdelay(17); // Wait one from before turning on
78 asic3_set_gpio_out_b(&h4000_asic3.dev,
79 GPIOB_LCD_PCI, GPIOB_LCD_PCI);
80 } else {
81 asic3_set_gpio_out_b(&h4000_asic3.dev, GPIOB_LCD_PCI, 0);
82 mdelay(30); // Wait before turning off
85 return 0;
88 static int h4000_lcd_get_contrast(struct lcd_device *ld)
90 /* Get the current contrast setting (0-max_contrast) */
91 //DBG*/ printk("%s: not implemented yet\n", __FUNCTION__);
92 return 0;
95 static int h4000_lcd_set_contrast(struct lcd_device *ld, int contrast)
97 /* Set LCD panel contrast */
98 //DBG*/ printk("%s: not implemented yet\n", __FUNCTION__);
99 return 0;
102 static struct lcd_properties h4000_lcd_properties =
104 .owner = THIS_MODULE,
105 .get_power = h4000_lcd_get_power,
106 .set_power = h4000_lcd_set_power,
107 .max_contrast = 7,
108 .get_contrast = h4000_lcd_get_contrast,
109 .set_contrast = h4000_lcd_set_contrast,
112 static struct lcd_device *h4000_lcd_dev;
114 static int h4000_lcd_probe(struct platform_device *pdev)
116 h4000_lcd_dev = lcd_device_register("pxa2xx-fb", NULL,
117 &h4000_lcd_properties);
118 if (IS_ERR(h4000_lcd_dev)) {
119 printk("h4000-lcd: Error registering device\n");
120 return -1;
123 return 0;
126 static int h4000_lcd_remove(struct platform_device *pdev)
128 h4000_lcd_set_power(h4000_lcd_dev, 4);
129 lcd_device_unregister(h4000_lcd_dev);
131 return 0;
134 static int h4000_lcd_suspend(struct platform_device *pdev, pm_message_t state)
136 h4000_lcd_set_power(h4000_lcd_dev, 4);
137 return 0;
140 static int h4000_lcd_resume(struct platform_device *pdev)
142 h4000_lcd_set_power(h4000_lcd_dev, 0);
143 return 0;
146 static struct platform_driver h4000_lcd_driver = {
147 .driver = {
148 .name = "h4000_lcd",
150 .probe = h4000_lcd_probe,
151 .remove = h4000_lcd_remove,
152 .suspend = h4000_lcd_suspend,
153 .resume = h4000_lcd_resume,
156 static int h4000_lcd_init(void)
158 if (!machine_is_h4000())
159 return -ENODEV;
161 return platform_driver_register(&h4000_lcd_driver);
164 static void h4000_lcd_exit(void)
166 lcd_device_unregister(h4000_lcd_dev);
167 platform_driver_unregister(&h4000_lcd_driver);
170 module_init(h4000_lcd_init);
171 module_exit(h4000_lcd_exit);
173 MODULE_AUTHOR("h4000 port team h4100-port@handhelds.org");
174 MODULE_DESCRIPTION("Framebuffer driver for iPAQ H4000");
175 MODULE_LICENSE("GPL");
177 /* vim: set ts=8 tw=80 shiftwidth=8 noet: */