hh.org updates
[hh.org.git] / arch / arm / mach-pxa / asus730 / a730_lcd.c
blob955839f1946ff8d71b7d85266f2aca65c54f742a
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 */
8 #include <linux/types.h>
9 #include <asm/arch/hardware.h> /* for pxa-regs.h (__REG) */
10 #include <linux/platform_device.h>
11 #include <asm/arch/pxa-regs.h> /* LCCR[0,1,2,3]* */
12 #include <asm/arch/bitfield.h> /* for pxa-regs.h (Fld, etc) */
13 #include <asm/arch/pxafb.h> /* pxafb_mach_info, set_pxa_fb_info */
14 #include <asm/mach-types.h> /* machine_is_a730 */
15 #include <linux/lcd.h> /* lcd_device */
16 #include <linux/backlight.h> /* backlight_device */
17 #include <linux/fb.h>
18 #include <linux/lcd.h>
19 #include <linux/err.h>
20 #include <linux/delay.h>
22 #include <asm/arch/asus730-gpio.h>
23 #include <asm/arch/pxa-regs.h>
25 extern void pca9535_write_output(u16);
26 extern u32 pca9535_read_input(void);
28 static int a730_lcd_get_power(struct lcd_device *lm)
30 //return (pca9535_read_input() & 0x1);
31 /*int i;
32 int p = pca9535_read_input();*/
33 int i, p = GET_A730_GPIO(LCD_EN);
34 if ((p & 0x1)) i = 0;
35 else if (!(p & 0x1)) i = 4;
36 printk("%s: input=0x%x, i=0x%x\n", __FUNCTION__, p, i);
37 return i;
40 static int a730_lcd_set_power(struct lcd_device *lm, int power)
42 //u16 i = pca9535_read_input();
44 switch (power)
46 case FB_BLANK_UNBLANK://0
47 //i |= 0x1;
48 //pca9535_write_output(i);
49 SET_A730_GPIO(LCD_EN, 0);
50 break;
51 case FB_BLANK_NORMAL://1
52 case FB_BLANK_VSYNC_SUSPEND://2
53 case FB_BLANK_HSYNC_SUSPEND://3
54 case FB_BLANK_POWERDOWN://4
55 //i &= ~0x1;
56 SET_A730_GPIO(LCD_EN, 1);
57 //pca9535_write_output(i);
58 break;
61 return 0;
64 static int a730_lcd_get_contrast(struct lcd_device *ld)
66 return 0;
69 static int a730_lcd_set_contrast(struct lcd_device *ld, int contrast)
71 return 0;
74 static struct lcd_properties a730_lcd_properties =
76 .owner = THIS_MODULE,
77 .get_power = a730_lcd_get_power,
78 .set_power = a730_lcd_set_power,
79 .max_contrast = 7,
80 .get_contrast = a730_lcd_get_contrast,
81 .set_contrast = a730_lcd_set_contrast,
84 static struct lcd_device *a730_lcd_dev = NULL;
86 static int a730_lcd_probe(struct device * dev)
88 pxa_gpio_mode(GPIO_NR_A730_LCD_EN | GPIO_OUT);
89 a730_lcd_dev = lcd_device_register("pxa2xx-fb", NULL, &a730_lcd_properties);
91 if (IS_ERR(a730_lcd_dev)) {
92 printk("a730-lcd: Error registering device\n");
93 return -1;
96 return 0;
99 static int a730_lcd_remove(struct device * dev)
101 a730_lcd_set_power(a730_lcd_dev, 4);
102 lcd_device_unregister(a730_lcd_dev);
103 return 0;
106 static int a730_lcd_suspend(struct device * dev, pm_message_t state)
108 a730_lcd_set_power(a730_lcd_dev, 4);
109 return 0;
112 static int a730_lcd_resume(struct device * dev)
114 a730_lcd_set_power(a730_lcd_dev, 0);
115 return 0;
118 /*********************************************/
120 static struct device_driver a730_lcd_driver = {
121 .name = "a730-lcd",
122 .bus = &platform_bus_type,
123 .probe = a730_lcd_probe,
124 .remove = a730_lcd_remove,
125 .suspend = a730_lcd_suspend,
126 .resume = a730_lcd_resume,
129 static int a730_lcd_init(void)
131 if (!machine_is_a730())
132 return -ENODEV;
134 driver_register(&a730_lcd_driver);
136 return 0;
139 static void a730_lcd_exit(void)
141 lcd_device_unregister(a730_lcd_dev);
142 driver_unregister(&a730_lcd_driver);
145 module_init(a730_lcd_init);
146 module_exit(a730_lcd_exit);
148 MODULE_AUTHOR("Serge Nikolaenko <mypal_hh@utl.ru>");
149 MODULE_DESCRIPTION("LCD handling for ASUS A730(W)");
150 MODULE_LICENSE("GPL");