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>
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);
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);
40 locomo_m62332_senddata(locomolcd_dev, comadj, 0);
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);
47 /* TFTCRST | CPSOUT=0 | CPSEN */
48 locomo_writel(0x01, locomolcd_dev->mapbase + LOCOMO_TC);
51 locomo_writel(6, locomolcd_dev->mapbase + LOCOMO_CPSD);
53 /* TFTCRST | CPSOUT=0 | CPSEN */
54 locomo_writel((0x04 | 0x01), locomolcd_dev->mapbase + LOCOMO_TC);
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);
67 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHA_ON, 0);
70 locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VEE_ON, 0);
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;
84 local_irq_save(flags);
87 local_irq_restore(flags);
93 if (machine_is_poodle())
95 if (machine_is_collie())
100 locomolcd_on(comadj);
102 locomolcd_off(comadj);
104 local_irq_restore(flags);
106 EXPORT_SYMBOL(locomolcd_power);
108 static int poodle_lcd_probe(struct locomo_dev *dev)
112 local_irq_save(flags);
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
121 local_irq_restore(flags);
125 static int poodle_lcd_remove(struct locomo_dev *dev)
128 local_irq_save(flags);
129 locomolcd_dev = NULL;
130 local_irq_restore(flags);
134 static struct locomo_driver poodle_lcd_driver = {
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);
148 #ifdef CONFIG_SA1100_COLLIE
149 sa1100fb_lcd_power = locomolcd_power;
153 device_initcall(poodle_lcd_init);