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 :-)
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
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>
24 #ifdef CONFIG_SA1100_COLLIE
25 #include <asm/arch/collie.h>
27 #include <asm/arch/poodle.h>
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);
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);
44 locomo_m62332_senddata(locomolcd_dev
, comadj
, 0);
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);
51 /* TFTCRST | CPSOUT=0 | CPSEN */
52 locomo_writel(0x01, locomolcd_dev
->mapbase
+ LOCOMO_TC
);
55 locomo_writel(6, locomolcd_dev
->mapbase
+ LOCOMO_CPSD
);
57 /* TFTCRST | CPSOUT=0 | CPSEN */
58 locomo_writel((0x04 | 0x01), locomolcd_dev
->mapbase
+ LOCOMO_TC
);
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
);
71 locomo_gpio_write(locomolcd_dev
, LOCOMO_GPIO_LCD_VSHA_ON
, 0);
74 locomo_gpio_write(locomolcd_dev
, LOCOMO_GPIO_LCD_VEE_ON
, 0);
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
)
88 local_irq_save(flags
);
91 local_irq_restore(flags
);
96 #ifdef CONFIG_MACH_POODLE
103 locomolcd_on(comadj
);
105 locomolcd_off(comadj
);
107 local_irq_restore(flags
);
109 EXPORT_SYMBOL(locomolcd_power
);
111 static int poodle_lcd_probe(struct locomo_dev
*dev
)
115 local_irq_save(flags
);
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
124 local_irq_restore(flags
);
128 static int poodle_lcd_remove(struct locomo_dev
*dev
)
131 local_irq_save(flags
);
132 locomolcd_dev
= NULL
;
133 local_irq_restore(flags
);
137 static struct locomo_driver poodle_lcd_driver
= {
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
);
151 #ifdef CONFIG_SA1100_COLLIE
152 sa1100fb_lcd_power
= locomolcd_power
;
156 device_initcall(poodle_lcd_init
);