sync hh.org
[hh.org.git] / arch / arm / mach-sa1100 / h3600_lcd.c
blob4094a8d63271c9b28ec0ccf4c2eb58f91b966531
1 /*
2 * Hardware definitions for Compaq iPAQ H36xx Handheld Computers
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 * Author: Alessandro Gardich.
10 * History : based on 2.4 drivers.
12 * 2005-11-xx Alessandro Gardich, let start.
17 #include <linux/module.h>
18 #include <linux/init.h>
19 #include <linux/kernel.h>
20 #include <linux/tty.h>
21 #include <linux/sched.h>
22 #include <linux/delay.h>
23 #include <linux/pm.h>
24 #include <linux/lcd.h>
25 #include <linux/backlight.h>
26 #include <linux/fb.h>
27 #include <linux/err.h>
28 #include <linux/platform_device.h>
30 #include <asm/mach-types.h>
31 #include <asm/hardware.h>
32 #include <asm/setup.h>
34 #include <asm/mach/arch.h>
35 #include <asm/arch/h3600.h>
36 #include <asm/hardware/ipaq-ops.h>
38 #include <../arch/arm/mach-sa1100/generic.h>
40 static int h3600_lcd_power;
43 * helper for sa1100fb
45 static void __h3600_lcd_power(int enable )
47 assign_ipaqsa_egpio(IPAQ_EGPIO_LCD_POWER, enable);
48 assign_ipaqsa_egpio(IPAQ_EGPIO_LCD_ENABLE, enable);
50 return;
53 /*--- sa1100fb END ---*/
56 static int h3600_lcd_set_power( struct lcd_device *lm, int level )
58 h3600_lcd_power = level;
60 if (level < 1) {
61 assign_ipaqsa_egpio(IPAQ_EGPIO_LCD_POWER, 1);
62 } else {
63 assign_ipaqsa_egpio(IPAQ_EGPIO_LCD_POWER, 0);
66 if (level < 4) {
67 assign_ipaqsa_egpio(IPAQ_EGPIO_LCD_ENABLE, 1);
68 } else {
69 assign_ipaqsa_egpio(IPAQ_EGPIO_LCD_ENABLE, 0);
72 return 0;
75 static int h3600_lcd_get_power( struct lcd_device *lm)
77 return h3600_lcd_power;
81 static struct lcd_properties h3600_lcd_properties = {
82 .owner = THIS_MODULE,
83 .get_power = h3600_lcd_get_power,
84 .set_power = h3600_lcd_set_power,
87 static struct lcd_device *h3600_lcd_device;
89 static int h3600_fp_probe (struct device *dev)
91 if (! machine_is_h3600 ())
92 return -ENODEV;
94 h3600_lcd_device = lcd_device_register("sa1100fb", NULL, &h3600_lcd_properties);
95 if (IS_ERR (h3600_lcd_device))
96 return PTR_ERR (h3600_lcd_device);
98 h3600_lcd_set_power (h3600_lcd_device, 0);
100 sa1100fb_lcd_power = __h3600_lcd_power;
102 return 0;
105 static int h3600_fp_remove (struct device *dev)
107 h3600_lcd_set_power(h3600_lcd_device, 4);
108 lcd_device_unregister (h3600_lcd_device);
110 sa1100fb_lcd_power = NULL;
112 return 0;
115 static int h3600_fp_suspend ( struct device *dev, pm_message_t msg)
117 h3600_lcd_set_power(h3600_lcd_device, 4);
118 return 0;
121 static int h3600_fp_resume (struct device *dev)
123 h3600_lcd_set_power(h3600_lcd_device, 0);
124 return 0;
127 struct device_driver h3600_fp_driver = {
128 .name = "h3600-lcd",
129 .bus = &platform_bus_type,
130 .probe = h3600_fp_probe,
131 .remove = h3600_fp_remove,
132 .suspend = h3600_fp_suspend,
133 .resume = h3600_fp_resume,
136 static int __init h3600_fp_init(void)
138 int rc;
140 if (!machine_is_h3600())
141 return -ENODEV;
143 rc = driver_register(&h3600_fp_driver);
145 return rc;
148 static void __exit h3600_fp_exit(void)
150 lcd_device_unregister(h3600_lcd_device);
151 driver_unregister(&h3600_fp_driver);
154 module_init (h3600_fp_init);
155 module_exit (h3600_fp_exit);
157 MODULE_LICENSE("GPL");
158 MODULE_AUTHOR("Alessandro Gardich <gremlin-4KDpiRHFOM2onA0d6jMUrA@public.gmane.org>");
159 MODULE_DESCRIPTION("iPAQ h3600 LCD driver");