[PATCH] w1: Make w1 connector notifications depend on connector.
[linux-2.6/verdex.git] / drivers / video / backlight / locomolcd.c
blob60831bb236851d305b391647039708afd5d004e0
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>
23 #include <asm/mach/sharpsl_param.h>
24 #include <asm/mach-types.h>
26 #include "../../../arch/arm/mach-sa1100/generic.h"
28 static struct locomo_dev *locomolcd_dev;
30 static void locomolcd_on(int comadj)
32 locomo_gpio_set_dir(locomolcd_dev, LOCOMO_GPIO_LCD_VSHA_ON, 0);
33 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHA_ON, 1);
34 mdelay(2);
36 locomo_gpio_set_dir(locomolcd_dev, LOCOMO_GPIO_LCD_VSHD_ON, 0);
37 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHD_ON, 1);
38 mdelay(2);
40 locomo_m62332_senddata(locomolcd_dev, comadj, 0);
41 mdelay(5);
43 locomo_gpio_set_dir(locomolcd_dev, LOCOMO_GPIO_LCD_VEE_ON, 0);
44 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VEE_ON, 1);
45 mdelay(10);
47 /* TFTCRST | CPSOUT=0 | CPSEN */
48 locomo_writel(0x01, locomolcd_dev->mapbase + LOCOMO_TC);
50 /* Set CPSD */
51 locomo_writel(6, locomolcd_dev->mapbase + LOCOMO_CPSD);
53 /* TFTCRST | CPSOUT=0 | CPSEN */
54 locomo_writel((0x04 | 0x01), locomolcd_dev->mapbase + LOCOMO_TC);
55 mdelay(10);
57 locomo_gpio_set_dir(locomolcd_dev, LOCOMO_GPIO_LCD_MOD, 0);
58 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_MOD, 1);
61 static void locomolcd_off(int comadj)
63 /* TFTCRST=1 | CPSOUT=1 | CPSEN = 0 */
64 locomo_writel(0x06, locomolcd_dev->mapbase + LOCOMO_TC);
65 mdelay(1);
67 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHA_ON, 0);
68 mdelay(110);
70 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VEE_ON, 0);
71 mdelay(700);
73 /* TFTCRST=0 | CPSOUT=0 | CPSEN = 0 */
74 locomo_writel(0, locomolcd_dev->mapbase + LOCOMO_TC);
75 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_MOD, 0);
76 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHD_ON, 0);
79 void locomolcd_power(int on)
81 int comadj = sharpsl_param.comadj;
82 unsigned long flags;
84 local_irq_save(flags);
86 if (!locomolcd_dev) {
87 local_irq_restore(flags);
88 return;
91 /* read comadj */
92 if (comadj == -1) {
93 if (machine_is_poodle())
94 comadj = 118;
95 if (machine_is_collie())
96 comadj = 128;
99 if (on)
100 locomolcd_on(comadj);
101 else
102 locomolcd_off(comadj);
104 local_irq_restore(flags);
106 EXPORT_SYMBOL(locomolcd_power);
108 static int poodle_lcd_probe(struct locomo_dev *dev)
110 unsigned long flags;
112 local_irq_save(flags);
113 locomolcd_dev = dev;
115 /* the poodle_lcd_power function is called for the first time
116 * from fs_initcall, which is before locomo is activated.
117 * We need to recall poodle_lcd_power here*/
118 #ifdef CONFIG_MACH_POODLE
119 locomolcd_power(1);
120 #endif
121 local_irq_restore(flags);
122 return 0;
125 static int poodle_lcd_remove(struct locomo_dev *dev)
127 unsigned long flags;
128 local_irq_save(flags);
129 locomolcd_dev = NULL;
130 local_irq_restore(flags);
131 return 0;
134 static struct locomo_driver poodle_lcd_driver = {
135 .drv = {
136 .name = "locomo-backlight",
138 .devid = LOCOMO_DEVID_BACKLIGHT,
139 .probe = poodle_lcd_probe,
140 .remove = poodle_lcd_remove,
143 static int __init poodle_lcd_init(void)
145 int ret = locomo_driver_register(&poodle_lcd_driver);
146 if (ret) return ret;
148 #ifdef CONFIG_SA1100_COLLIE
149 sa1100fb_lcd_power = locomolcd_power;
150 #endif
151 return 0;
153 device_initcall(poodle_lcd_init);