hh.org updates
[hh.org.git] / arch / arm / mach-pxa / htcsable / htcsable_lcd.c
blob9e635684bc5c74bc2212ef84658cea521416e1ea
1 /*
2 * HTC Sable (ipaq hw6915) LCD driver
4 * Use consistent with the GNU GPL is permitted,
5 * provided that this copyright notice is
6 * preserved in its entirety in all copies and derived works.
8 * Copyright not listed but probably the people below at least.
9 * Copyright (C) 2006 Luke Kenneth Casson Leighton (lkcl@lkcl.net)
11 * History:
13 * 2004-03-01 Eddi De Pieri Adapted for h4000 using h3900_lcd.c
14 * 2004 Shawn Anderson Lcd hacking on h4000
15 * see h3900_lcd.c for more history.
16 * 2006nov26 lkcl Adapted for htc sable
20 #include <linux/types.h>
21 #include <asm/arch/hardware.h> /* for pxa-regs.h (__REG) */
22 #include <linux/platform_device.h>
23 #include <asm/arch/pxa-regs.h> /* LCCR[0,1,2,3]* */
24 #include <asm/arch/bitfield.h> /* for pxa-regs.h (Fld, etc) */
25 #include <asm/arch/pxafb.h> /* pxafb_mach_info, set_pxa_fb_info */
26 #include <asm/mach-types.h> /* machine_is_hw6900 */
27 #include <linux/lcd.h> /* lcd_device */
28 #include <linux/backlight.h> /* backlight_device */
29 #include <linux/fb.h>
30 #include <linux/err.h>
31 #include <linux/delay.h>
33 #include <asm/arch/htcsable-gpio.h>
34 #include <asm/arch/htcsable-asic.h>
35 #include <asm/hardware/ipaq-asic3.h>
36 #include <linux/soc/asic3_base.h>
38 extern struct platform_device htcsable_asic3;
40 static int saved_lcdpower = -1;
42 static int htcsable_lcd_set_power(struct lcd_device *lm, int power)
44 /* Enable or disable power to the LCD (0: on; 4: off) */
46 saved_lcdpower = power;
48 if ( power < 1 ) {
49 #if 0
50 asic3_set_gpio_out_d(&htcsable_asic3.dev,
51 GPIOD_LCD_BACKLIGHT, GPIOD_LCD_BACKLIGHT);
52 pxa_set_cken(CKEN0_PWM0, 1); /* this is backlight */
53 mdelay(15);
54 #endif
55 pxa_set_cken(CKEN16_LCD, 1);
56 mdelay(50);
57 asic3_set_gpio_out_a(&htcsable_asic3.dev,
58 GPIOA_LCD_PWR_5, GPIOA_LCD_PWR_5);
59 mdelay(15);
60 asic3_set_gpio_out_c(&htcsable_asic3.dev,
61 GPIOC_LCD_PWR_1, GPIOC_LCD_PWR_1);
62 mdelay(15);
63 asic3_set_gpio_out_c(&htcsable_asic3.dev,
64 GPIOC_LCD_PWR_2, GPIOC_LCD_PWR_2);
66 } else {
67 #if 0
68 asic3_set_gpio_out_d(&htcsable_asic3.dev,
69 GPIOD_LCD_BACKLIGHT, 0);
70 pxa_set_cken(CKEN0_PWM0, 0); /* this is backlight */
71 #endif
72 mdelay(15);
73 pxa_set_cken(CKEN16_LCD, 0);
74 mdelay(50);
75 asic3_set_gpio_out_a(&htcsable_asic3.dev,
76 GPIOA_LCD_PWR_5, 0);
77 mdelay(10);
78 asic3_set_gpio_out_c(&htcsable_asic3.dev,
79 GPIOC_LCD_PWR_1, 0);
80 mdelay(10);
81 asic3_set_gpio_out_c(&htcsable_asic3.dev,
82 GPIOC_LCD_PWR_2, 0);
85 return 0;
88 static int htcsable_lcd_get_power(struct lcd_device *lm)
90 if (saved_lcdpower == -1)
92 htcsable_lcd_set_power(lm, 4);
93 saved_lcdpower = 4;
96 return saved_lcdpower;
99 static struct lcd_properties htcsable_lcd_properties =
101 .owner = THIS_MODULE,
102 .get_power = htcsable_lcd_get_power,
103 .set_power = htcsable_lcd_set_power,
106 static struct lcd_device *htcsable_lcd_dev;
108 static int htcsable_lcd_probe(struct device * dev)
110 htcsable_lcd_dev = lcd_device_register("pxa2xx-fb", NULL,
111 &htcsable_lcd_properties);
112 if (IS_ERR(htcsable_lcd_dev)) {
113 printk("htcsable-lcd: Error registering device\n");
114 return -1;
117 htcsable_lcd_set_power(htcsable_lcd_dev, 0);
118 return 0;
121 static int htcsable_lcd_remove(struct device * dev)
123 htcsable_lcd_set_power(htcsable_lcd_dev, 4);
124 lcd_device_unregister(htcsable_lcd_dev);
126 return 0;
129 static int htcsable_lcd_suspend(struct device * dev, pm_message_t state)
131 htcsable_lcd_set_power(htcsable_lcd_dev, 4);
132 return 0;
135 static int htcsable_lcd_resume(struct device * dev)
137 htcsable_lcd_set_power(htcsable_lcd_dev, 0);
138 return 0;
141 static struct device_driver htcsable_lcd_driver = {
142 .name = "htcsable_lcd",
143 .bus = &platform_bus_type,
144 .probe = htcsable_lcd_probe,
145 .remove = htcsable_lcd_remove,
146 .suspend = htcsable_lcd_suspend,
147 .resume = htcsable_lcd_resume,
150 static int htcsable_lcd_init(void)
152 if (!machine_is_hw6900())
153 return -ENODEV;
155 return driver_register(&htcsable_lcd_driver);
158 static void htcsable_lcd_exit(void)
160 lcd_device_unregister(htcsable_lcd_dev);
161 driver_unregister(&htcsable_lcd_driver);
164 module_init(htcsable_lcd_init);
165 module_exit(htcsable_lcd_exit);
167 MODULE_AUTHOR("h4000 port team h4100-port@handhelds.org; Luke Kenneth Casson Leighton");
168 MODULE_DESCRIPTION("LCD driver for iPAQ hw6915");
169 MODULE_LICENSE("GPL");
171 /* vim: set ts=8 tw=80 shiftwidth=8 noet: */