sync hh.org
[hh.org.git] / arch / arm / mach-pxa / himalaya / himalaya_leds.c
blob1eba4c1301debe30446bc75301841720b5fd8e03
1 /*
2 * LED interface for Himalaya, the HTC PocketPC.
4 * License: GPL
6 * Author: Luke Kenneth Casson Leighton, Copyright(C) 2004
8 * Copyright(C) 2004, Luke Kenneth Casson Leighton.
10 * History:
12 * 2004-02-19 Luke Kenneth Casson Leighton created.
16 #include <linux/module.h>
17 #include <linux/delay.h>
19 #include <asm/hardware/ipaq-asic3.h>
20 #include <asm/mach-types.h>
21 #include <asm/arch/ipaq.h>
23 //#include "himalaya_leds.h"
25 extern struct platform_device himalaya_asic3;
26 extern struct ipaq_model_ops ipaq_model_ops;
28 #define CLOCK_CDEX_LED0 (1 << 6) /* clock for led 0? */
29 #define CLOCK_CDEX_LED1 (1 << 7) /* clock for led 1? */
31 void himalaya_set_led (enum led_color color, int duty_time, int cycle_time)
33 if (color == RED_LED)
35 IPAQ_ASIC3_LED_TimeBase(H3900_ASIC3_VIRT, 0) = 0x6 | LEDTBS_BLINK;
36 IPAQ_ASIC3_LED_PeriodTime(H3900_ASIC3_VIRT, 0) = cycle_time;
37 IPAQ_ASIC3_LED_DutyTime(H3900_ASIC3_VIRT, 0) = 0;
38 udelay(1);
39 IPAQ_ASIC3_LED_DutyTime(H3900_ASIC3_VIRT, 0) = duty_time;
41 IPAQ_ASIC3_LED_TimeBase(H3900_ASIC3_VIRT, 1) = 0x6 | LEDTBS_BLINK;
42 IPAQ_ASIC3_LED_PeriodTime(H3900_ASIC3_VIRT, 1) = cycle_time;
43 IPAQ_ASIC3_LED_DutyTime(H3900_ASIC3_VIRT, 1) = 0;
46 if (color == GREEN_LED)
48 IPAQ_ASIC3_LED_TimeBase(H3900_ASIC3_VIRT, 1) = 0x6 | LEDTBS_BLINK;
49 IPAQ_ASIC3_LED_PeriodTime(H3900_ASIC3_VIRT, 1) = cycle_time;
50 IPAQ_ASIC3_LED_DutyTime(H3900_ASIC3_VIRT, 1) = 0;
51 udelay(1);
52 IPAQ_ASIC3_LED_DutyTime(H3900_ASIC3_VIRT, 1) = duty_time;
54 IPAQ_ASIC3_LED_TimeBase(H3900_ASIC3_VIRT, 0) = 0x6 | LEDTBS_BLINK;
55 IPAQ_ASIC3_LED_PeriodTime(H3900_ASIC3_VIRT, 0) = cycle_time;
56 IPAQ_ASIC3_LED_DutyTime(H3900_ASIC3_VIRT, 0) = 0;
59 if (color == YELLOW_LED)
61 IPAQ_ASIC3_LED_TimeBase(H3900_ASIC3_VIRT, 1) = 0x6 | LEDTBS_BLINK;
62 IPAQ_ASIC3_LED_PeriodTime(H3900_ASIC3_VIRT, 1) = cycle_time;
63 IPAQ_ASIC3_LED_DutyTime(H3900_ASIC3_VIRT, 1) = 0;
65 IPAQ_ASIC3_LED_TimeBase(H3900_ASIC3_VIRT, 0) = 0x6 | LEDTBS_BLINK;
66 IPAQ_ASIC3_LED_PeriodTime(H3900_ASIC3_VIRT, 0) = cycle_time;
67 IPAQ_ASIC3_LED_DutyTime(H3900_ASIC3_VIRT, 0) = 0;
69 udelay(1);
70 IPAQ_ASIC3_LED_DutyTime(H3900_ASIC3_VIRT, 1) = duty_time;
71 IPAQ_ASIC3_LED_DutyTime(H3900_ASIC3_VIRT, 0) = duty_time;
74 if (color == BLUE_LED)
75 printk("%s: Blue LED not yet enabled.\n", __FUNCTION__);
77 EXPORT_SYMBOL(himalaya_set_led);
79 static int himalaya_led_init (void)
81 int retval = 0;
83 if (! machine_is_himalaya() )
84 return -ENODEV;
86 ipaq_model_ops.set_led = himalaya_set_led;
87 return retval;
90 static void himalaya_led_exit (void)
92 ipaq_model_ops.set_led = NULL;
95 module_init (himalaya_led_init);
96 module_exit (himalaya_led_exit);