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.
8 * 2004-03-01 Eddi De Pieri Adapted for htcuniversal using h3900_lcd.c
9 * 2004 Shawn Anderson Lcd hacking on htcuniversal
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_htcuniversal */
21 #include <linux/lcd.h> /* lcd_device */
22 #include <linux/err.h>
23 #include <linux/delay.h>
25 #include <asm/arch/htcuniversal-gpio.h>
26 #include <asm/arch/htcuniversal-asic.h>
27 #include <asm/hardware/ipaq-asic3.h>
28 #include <linux/soc/asic3_base.h>
30 static int saved_lcdpower
=-1;
32 static int powerup_lcd(void)
34 printk( KERN_INFO
"htcuniversal powerup_lcd: called\n");
36 asic3_set_gpio_out_c(&htcuniversal_asic3
.dev
, 1<<GPIOC_LCD_PWR1_ON
, 0);
37 asic3_set_gpio_out_c(&htcuniversal_asic3
.dev
, 1<<GPIOC_LCD_PWR2_ON
, 0);
38 asic3_set_gpio_out_b(&htcuniversal_asic3
.dev
, 1<<GPIOB_LCD_PWR3_ON
, 0);
39 asic3_set_gpio_out_d(&htcuniversal_asic3
.dev
, 1<<GPIOD_LCD_PWR4_ON
, 0);
40 asic3_set_gpio_out_a(&htcuniversal_asic3
.dev
, 1<<GPIOA_LCD_PWR5_ON
, 0);
41 pxa_set_cken(CKEN16_LCD
, 0);
44 asic3_set_gpio_out_a(&htcuniversal_asic3
.dev
, 1<<GPIOA_LCD_PWR5_ON
, 1<<GPIOA_LCD_PWR5_ON
);
46 asic3_set_gpio_out_b(&htcuniversal_asic3
.dev
, 1<<GPIOB_LCD_PWR3_ON
, 1<<GPIOB_LCD_PWR3_ON
);
48 asic3_set_gpio_out_c(&htcuniversal_asic3
.dev
, 1<<GPIOC_LCD_PWR1_ON
, 1<<GPIOC_LCD_PWR1_ON
);
50 asic3_set_gpio_out_c(&htcuniversal_asic3
.dev
, 1<<GPIOC_LCD_PWR2_ON
, 1<<GPIOC_LCD_PWR2_ON
);
52 asic3_set_gpio_out_d(&htcuniversal_asic3
.dev
, 1<<GPIOD_LCD_PWR4_ON
, 1<<GPIOD_LCD_PWR4_ON
);
54 pxa_set_cken(CKEN16_LCD
, 1);
56 SET_HTCUNIVERSAL_GPIO(LCD1
,1);
57 SET_HTCUNIVERSAL_GPIO(LCD2
,1);
61 static int powerdown_lcd(void)
63 printk( KERN_INFO
"htcuniversal powerdown_lcd: called\n");
66 asic3_set_gpio_out_c(&htcuniversal_asic3
.dev
, 1<<GPIOC_LCD_PWR2_ON
, 0);
68 asic3_set_gpio_out_d(&htcuniversal_asic3
.dev
, 1<<GPIOD_LCD_PWR4_ON
, 0);
70 asic3_set_gpio_out_a(&htcuniversal_asic3
.dev
, 1<<GPIOA_LCD_PWR5_ON
, 0);
72 asic3_set_gpio_out_b(&htcuniversal_asic3
.dev
, 1<<GPIOB_LCD_PWR3_ON
, 0);
74 asic3_set_gpio_out_c(&htcuniversal_asic3
.dev
, 1<<GPIOC_LCD_PWR1_ON
, 0);
75 pxa_set_cken(CKEN16_LCD
, 0);
77 SET_HTCUNIVERSAL_GPIO(LCD1
,0);
78 SET_HTCUNIVERSAL_GPIO(LCD2
,0);
80 pxa_set_cken(CKEN16_LCD
, 0);
82 SET_HTCUNIVERSAL_GPIO(LCD1
,0);
83 SET_HTCUNIVERSAL_GPIO(LCD2
,0);
85 asic3_set_gpio_out_c(&htcuniversal_asic3
.dev
, 1<<GPIOC_LCD_PWR2_ON
, 0);
87 asic3_set_gpio_out_d(&htcuniversal_asic3
.dev
, 1<<GPIOD_LCD_PWR4_ON
, 0);
89 asic3_set_gpio_out_a(&htcuniversal_asic3
.dev
, 1<<GPIOA_LCD_PWR5_ON
, 0);
91 asic3_set_gpio_out_b(&htcuniversal_asic3
.dev
, 1<<GPIOB_LCD_PWR3_ON
, 0);
93 asic3_set_gpio_out_c(&htcuniversal_asic3
.dev
, 1<<GPIOC_LCD_PWR1_ON
, 0);
98 static int htcuniversal_lcd_set_power(struct lcd_device
*lm
, int power
)
100 /* Enable or disable power to the LCD (0: on; 4: off) */
114 mdelay(17); // Wait one from before turning on
115 asic3_set_gpio_out_b(&htcuniversal_asic3
.dev
,
116 GPIOB_LCD_PCI
, GPIOB_LCD_PCI
);
118 asic3_set_gpio_out_b (&htcuniversal_asic3
.dev
, GPIOB_LCD_PCI
, 0);
119 mdelay(30); // Wait before turning off
122 saved_lcdpower
=power
;
127 static int htcuniversal_lcd_get_power(struct lcd_device
*lm
)
129 /* Get the LCD panel power status (0: full on, 1..3: controller
130 * power on, flat panel power off, 4: full off) */
133 if (asic3_get_gpio_status_b(&htcuniversal_asic3
.dev
) & GPIOB_LCD_PCI
) {
134 if (asic3_get_gpio_out_b(&htcuniversal_asic3
.dev
) & GPIOB_LCD_ON
)
142 if (saved_lcdpower
== -1)
144 htcuniversal_lcd_set_power(lm
, 4);
148 return saved_lcdpower
;
151 static struct lcd_properties htcuniversal_lcd_properties
=
153 .owner
= THIS_MODULE
,
154 .get_power
= htcuniversal_lcd_get_power
,
155 .set_power
= htcuniversal_lcd_set_power
,
158 static struct lcd_device
*htcuniversal_lcd_dev
;
160 static int htcuniversal_lcd_probe(struct platform_device
* dev
)
162 htcuniversal_lcd_dev
= lcd_device_register("pxa2xx-fb", NULL
,
163 &htcuniversal_lcd_properties
);
164 if (IS_ERR(htcuniversal_lcd_dev
)) {
165 printk("htcuniversal_lcd_probe: error registering devices\n");
172 static int htcuniversal_lcd_remove(struct platform_device
* dev
)
174 htcuniversal_lcd_set_power(htcuniversal_lcd_dev
, 4);
175 lcd_device_unregister(htcuniversal_lcd_dev
);
180 static int htcuniversal_lcd_suspend(struct platform_device
* dev
, pm_message_t state
)
182 printk("htcuniversal_lcd_suspend: called.\n");
183 htcuniversal_lcd_set_power(htcuniversal_lcd_dev
, 4);
187 static int htcuniversal_lcd_resume(struct platform_device
* dev
)
189 printk("htcuniversal_lcd_resume: called.\n");
190 htcuniversal_lcd_set_power(htcuniversal_lcd_dev
, 0);
194 static struct platform_driver htcuniversal_lcd_driver
= {
196 .name
= "htcuniversal_lcd",
198 .probe
= htcuniversal_lcd_probe
,
199 .remove
= htcuniversal_lcd_remove
,
200 .suspend
= htcuniversal_lcd_suspend
,
201 .resume
= htcuniversal_lcd_resume
,
204 static int htcuniversal_lcd_init(void)
206 if (!machine_is_htcuniversal())
209 return platform_driver_register(&htcuniversal_lcd_driver
);
212 static void htcuniversal_lcd_exit(void)
214 lcd_device_unregister(htcuniversal_lcd_dev
);
215 platform_driver_unregister(&htcuniversal_lcd_driver
);
218 module_init(htcuniversal_lcd_init
);
219 module_exit(htcuniversal_lcd_exit
);
221 MODULE_AUTHOR("xanadux.org");
222 MODULE_DESCRIPTION("Framebuffer driver for HTC Universal");
223 MODULE_LICENSE("GPL");