[PATCH] usbcore: Improve endpoint sysfs file handling
[linux/fpc-iii.git] / drivers / video / backlight / locomolcd.c
blobada6e75eb048544688e1ca099f002dba1020175a
1 /*
2 * Backlight control code for Sharp Zaurus SL-5500
4 * Copyright 2005 John Lenz <lenz@cs.wisc.edu>
5 * Maintainer: Pavel Machek <pavel@suse.cz> (unless John wants to :-)
6 * GPL v2
8 * This driver assumes single CPU. That's okay, because collie is
9 * slightly old hardware, and noone is going to retrofit second CPU to
10 * old PDA.
13 /* LCD power functions */
14 #include <linux/config.h>
15 #include <linux/module.h>
16 #include <linux/init.h>
17 #include <linux/delay.h>
18 #include <linux/device.h>
19 #include <linux/interrupt.h>
21 #include <asm/hardware/locomo.h>
22 #include <asm/irq.h>
24 #ifdef CONFIG_SA1100_COLLIE
25 #include <asm/arch/collie.h>
26 #else
27 #include <asm/arch/poodle.h>
28 #endif
30 extern void (*sa1100fb_lcd_power)(int on);
32 static struct locomo_dev *locomolcd_dev;
34 static void locomolcd_on(int comadj)
36 locomo_gpio_set_dir(locomolcd_dev, LOCOMO_GPIO_LCD_VSHA_ON, 0);
37 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHA_ON, 1);
38 mdelay(2);
40 locomo_gpio_set_dir(locomolcd_dev, LOCOMO_GPIO_LCD_VSHD_ON, 0);
41 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHD_ON, 1);
42 mdelay(2);
44 locomo_m62332_senddata(locomolcd_dev, comadj, 0);
45 mdelay(5);
47 locomo_gpio_set_dir(locomolcd_dev, LOCOMO_GPIO_LCD_VEE_ON, 0);
48 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VEE_ON, 1);
49 mdelay(10);
51 /* TFTCRST | CPSOUT=0 | CPSEN */
52 locomo_writel(0x01, locomolcd_dev->mapbase + LOCOMO_TC);
54 /* Set CPSD */
55 locomo_writel(6, locomolcd_dev->mapbase + LOCOMO_CPSD);
57 /* TFTCRST | CPSOUT=0 | CPSEN */
58 locomo_writel((0x04 | 0x01), locomolcd_dev->mapbase + LOCOMO_TC);
59 mdelay(10);
61 locomo_gpio_set_dir(locomolcd_dev, LOCOMO_GPIO_LCD_MOD, 0);
62 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_MOD, 1);
65 static void locomolcd_off(int comadj)
67 /* TFTCRST=1 | CPSOUT=1 | CPSEN = 0 */
68 locomo_writel(0x06, locomolcd_dev->mapbase + LOCOMO_TC);
69 mdelay(1);
71 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHA_ON, 0);
72 mdelay(110);
74 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VEE_ON, 0);
75 mdelay(700);
77 /* TFTCRST=0 | CPSOUT=0 | CPSEN = 0 */
78 locomo_writel(0, locomolcd_dev->mapbase + LOCOMO_TC);
79 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_MOD, 0);
80 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHD_ON, 0);
83 void locomolcd_power(int on)
85 int comadj = 118;
86 unsigned long flags;
88 local_irq_save(flags);
90 if (!locomolcd_dev) {
91 local_irq_restore(flags);
92 return;
95 /* read comadj */
96 #ifdef CONFIG_MACH_POODLE
97 comadj = 118;
98 #else
99 comadj = 128;
100 #endif
102 if (on)
103 locomolcd_on(comadj);
104 else
105 locomolcd_off(comadj);
107 local_irq_restore(flags);
109 EXPORT_SYMBOL(locomolcd_power);
111 static int poodle_lcd_probe(struct locomo_dev *dev)
113 unsigned long flags;
115 local_irq_save(flags);
116 locomolcd_dev = dev;
118 /* the poodle_lcd_power function is called for the first time
119 * from fs_initcall, which is before locomo is activated.
120 * We need to recall poodle_lcd_power here*/
121 #ifdef CONFIG_MACH_POODLE
122 locomolcd_power(1);
123 #endif
124 local_irq_restore(flags);
125 return 0;
128 static int poodle_lcd_remove(struct locomo_dev *dev)
130 unsigned long flags;
131 local_irq_save(flags);
132 locomolcd_dev = NULL;
133 local_irq_restore(flags);
134 return 0;
137 static struct locomo_driver poodle_lcd_driver = {
138 .drv = {
139 .name = "locomo-backlight",
141 .devid = LOCOMO_DEVID_BACKLIGHT,
142 .probe = poodle_lcd_probe,
143 .remove = poodle_lcd_remove,
146 static int __init poodle_lcd_init(void)
148 int ret = locomo_driver_register(&poodle_lcd_driver);
149 if (ret) return ret;
151 #ifdef CONFIG_SA1100_COLLIE
152 sa1100fb_lcd_power = locomolcd_power;
153 #endif
154 return 0;
156 device_initcall(poodle_lcd_init);