Skip to contentSkip to conversation

Add support for HTC Typhoon leds.

PATCH In review Vivien Chappelier 2 participants 2 messages Jun 9, 2007 – Jun 12, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 10/12 Add support for HTC Typhoon leds.

This patch add support for the HTC Typhoon tricolor led.

---

arch/arm/mach-omap1/Makefile       |    1 +
arch/arm/mach-omap1/leds-typhoon.c |  184 ++++++++++++++++++++++++++++++++++++
arch/arm/mach-omap1/leds.c         |    3 +
arch/arm/mach-omap1/leds.h         |    1 +
4 files changed, 189 insertions(+), 0 deletions(-)

create mode 100644 arch/arm/mach-omap1/leds-typhoon.c

arch/arm/mach-omap1/Makefile +0 -0
index 9f6bcbb..5153e43 100644
@@ -46,4 +46,5 @@ led-$(CONFIG_MACH_OMAP_H3)        += leds-h2p2-debug.o

led-$(CONFIG_MACH_OMAP_INNOVATOR) += leds-innovator.o
led-$(CONFIG_MACH_OMAP_PERSEUS2) += leds-h2p2-debug.o
led-$(CONFIG_MACH_OMAP_OSK) += leds-osk.o
+led-$(CONFIG_MACH_TYPHOON) += leds-typhoon.o
obj-$(CONFIG_LEDS) += $(led-y)

arch/arm/mach-omap1/leds-typhoon.c new file +184 -0

184 lines not on this page · raw message

arch/arm/mach-omap1/leds.c +3 -0
index 3f9dcac..59b7135 100644
@@ -28,6 +28,9 @@ omap_leds_init(void)
    else if (machine_is_omap_osk())
        leds_event = osk_leds_event;
 
+    else if (machine_is_typhoon())
+        leds_event = typhoon_leds_event;
+
    else
        return -1;
 
arch/arm/mach-omap1/leds.h +0 -0
index a1e9fed..1760eb0 100644
@@ -1,3 +1,4 @@

extern void innovator_leds_event(led_event_t evt); extern void h2p2_dbg_leds_event(led_event_t evt); extern void osk_leds_event(led_event_t evt); +extern void typhoon_leds_event(led_event_t evt);

Signature · 1 line
1.5.1.3
#1 lore raw
Quoted 94 lines · Vivien Chappelier

This patch add support for the HTC Typhoon tricolor led.

---
 arch/arm/mach-omap1/Makefile       |    1 +
 arch/arm/mach-omap1/leds-typhoon.c |  184
++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap1/leds.c         |    3 +
 arch/arm/mach-omap1/leds.h         |    1 +
 4 files changed, 189 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap1/leds-typhoon.c
arch/arm/mach-omap1/Makefile +1 -0
index 9f6bcbb..5153e43 100644
@@ -46,4 +46,5 @@ led-$(CONFIG_MACH_OMAP_H3)        += leds-h2p2-debug.o
 led-$(CONFIG_MACH_OMAP_INNOVATOR)    += leds-innovator.o
 led-$(CONFIG_MACH_OMAP_PERSEUS2)    += leds-h2p2-debug.o
 led-$(CONFIG_MACH_OMAP_OSK)        += leds-osk.o
+led-$(CONFIG_MACH_TYPHOON)        += leds-typhoon.o
 obj-$(CONFIG_LEDS)            += $(led-y)
arch/arm/mach-omap1/leds-typhoon.c new file +8 -0
new file mode 100644
index 0000000..eff868f
@@ -0,0 +1,184 @@
+/*
+ * linux/arch/arm/mach-omap1/leds-typhoon.c
+ *
+ * Copyright 2005 Vivien Chappelier <[email protected]>
+ *   Modified from leds-h2p2-debug.c
+ *
+ * The HTC Typhoon has a tricolor led. Timers can be setup the 'red'
+ * and 'green' components for blinking. The 'blue' component is on/off

only.
+ */

arch/arm/mach-omap1/leds-typhoon.c new file +42 -0
+#include <linux/init.h>
+#include <linux/kernel_stat.h>
+#include <linux/sched.h>
+#include <linux/version.h>
+
+#include <asm/io.h>
+#include <asm/hardware.h>
+#include <asm/leds.h>
+#include <asm/system.h>
+
+#include <asm/arch/gpio.h>
+#include <asm/arch/board-typhoon.h>
+
+#include "leds.h"
+
+/* led registers */
+#define TYPHOON_LED_STATUS_ON       1
+#define TYPHOON_LED_STATUS_OFF      0
+#define TYPHOON_LED_STATUS_BLINK(on, off) (((on) << 2) | ((off) << 17))
+
+#define TYPHOON_LED_BASE   0xfffba800
+#define TYPHOON_LED_ENABLE 0xfffba801
+#    define LED_ON         (1 << 7)
+#    define LED_BLINK      (1 << 6)
+#    define LED_ONTIME(x)  ((x) & 0x7)
+#    define LED_OFFTIME(x) (((x) & 0x7) << 3)
+
+/* led status */
+#define LED_STATE_ENABLED     (1 << 7)
+#define LED_STATE_CLAIMED     (1 << 6)
+#define LED_BLUE  (1 <<  0)
+#define LED_GREEN (1 <<  1)
+#define LED_RED   (1 <<  2)
+#define LED_MASK (LED_BLUE | LED_GREEN | LED_RED)
+
+#define LED_TIMER LED_GREEN
+#define LED_CPU   LED_RED
+
+/* route power to the tricolor led */
+static void typhoon_start_led(void)
+{
+    omap_writel(omap_readl(OMAP730_IO_CONF_10) & ~0x20,

OMAP730_IO_CONF_10);
+ omap_writel(omap_readl(OMAP730_IO_CONF_10) | 0xd0,
OMAP730_IO_CONF_10);

arch/arm/mach-omap1/leds-typhoon.c new file +9 -0
+    omap_set_gpio_direction(TYPHOON_GPIO_LED_BLUE, 0); /* out */
+
+    omap_writel(omap_readl(OMAP730_MODE_1) | (1 << 29), OMAP730_MODE_1);
+    omap_writeb(LED_ON, TYPHOON_LED_BASE);
+    omap_writeb(1, TYPHOON_LED_ENABLE);
+}
+
+/* power off the tricolor led */
+static void typhoon_stop_led(void)

arch/arm/mach-omap1/leds-typhoon.c line 71

Quoted 10 lines
arch/arm/mach-omap1/leds-typhoon.c new file +10 -0
+{
+    omap_writel(omap_readl(OMAP730_MODE_1) & ~(1 << 29), OMAP730_MODE_1);
+    omap_writeb(0, TYPHOON_LED_BASE);
+    omap_writeb(0, TYPHOON_LED_ENABLE);
+}
+
+/* set the 'blue', 'green' and 'red' components of the tricolor led */
+static void typhoon_set_led(int led)
+{
+    if(led & LED_BLUE)

space before opening parenthesis.

arch/arm/mach-omap1/leds-typhoon.c line 76

Quoted 5 lines
arch/arm/mach-omap1/leds-typhoon.c new file +5 -0
+        omap_set_gpio_dataout(TYPHOON_GPIO_LED_BLUE, 1);
+    else
+        omap_set_gpio_dataout(TYPHOON_GPIO_LED_BLUE, 0);
+
+    if(led & (LED_RED | LED_GREEN)) {

Ditto.

Quoted 1 line

+ if(led & LED_GREEN) {

Ditto.

arch/arm/mach-omap1/leds-typhoon.c line 84

Quoted 7 lines
arch/arm/mach-omap1/leds-typhoon.c new file +7 -0
+            omap_set_gpio_direction(TYPHOON_GPIO_LED_GREEN, 1);
+        } else {
+            omap_set_gpio_direction(TYPHOON_GPIO_LED_GREEN, 0);
+            omap_set_gpio_dataout(TYPHOON_GPIO_LED_GREEN, 0);
+        }
+
+        if(led & LED_RED) {

Ditto.

Quoted 131 lines
arch/arm/mach-omap1/leds-typhoon.c new file +100 -0
+            omap_set_gpio_direction(TYPHOON_GPIO_LED_RED, 1);
+        } else {
+            omap_set_gpio_direction(TYPHOON_GPIO_LED_RED, 0);
+            omap_set_gpio_dataout(TYPHOON_GPIO_LED_RED, 0);
+        }
+    } else {
+        omap_set_gpio_direction(TYPHOON_GPIO_LED_GREEN, 0);
+        omap_set_gpio_dataout(TYPHOON_GPIO_LED_GREEN, 0);
+        omap_set_gpio_direction(TYPHOON_GPIO_LED_RED, 0);
+        omap_set_gpio_dataout(TYPHOON_GPIO_LED_RED, 0);
+    }
+}
+
+
+void typhoon_leds_event(led_event_t evt)
+{
+    unsigned long flags;
+
+    static u16 led_state, hw_led_state;
+
+    local_irq_save(flags);
+
+    if (!(led_state & LED_STATE_ENABLED) && evt != led_start)
+        goto done;
+
+    switch (evt) {
+    case led_start:
+        typhoon_start_led();
+        led_state |= LED_STATE_ENABLED;
+        break;
+
+    case led_stop:
+    case led_halted:
+        /* all leds off during suspend or shutdown */
+        typhoon_set_led(0);
+        typhoon_stop_led();
+        goto done;
+
+    case led_claim:
+        led_state |= LED_STATE_CLAIMED;
+        hw_led_state = 0;
+        break;
+
+    case led_release:
+        led_state &= ~LED_STATE_CLAIMED;
+        break;
+
+#ifdef CONFIG_LEDS_TIMER
+    case led_timer:
+        led_state ^= LED_TIMER;
+        break;
+#endif
+
+#ifdef CONFIG_LEDS_CPU
+    case led_idle_start:
+        led_state &= ~LED_CPU;
+        break;
+
+    case led_idle_end:
+        led_state |= LED_CPU;
+        break;
+#endif
+
+    case led_green_on:
+        hw_led_state |= LED_GREEN;
+        break;
+    case led_green_off:
+        hw_led_state &= ~LED_GREEN;
+        break;
+
+    case led_red_on:
+        hw_led_state |= LED_RED;
+        break;
+    case led_red_off:
+        hw_led_state &= ~LED_RED;
+        break;
+
+    case led_blue_on:
+        hw_led_state |= LED_BLUE;
+        break;
+    case led_blue_off:
+        hw_led_state &= ~LED_BLUE;
+        break;
+
+    default:
+        break;
+    }
+
+
+    /*
+     *  Actually burn the LEDs
+     */
+    if (led_state & LED_STATE_CLAIMED)
+        typhoon_set_led(hw_led_state);
+    else
+        typhoon_set_led(led_state & LED_MASK);
+
+done:
+    local_irq_restore(flags);
+}
arch/arm/mach-omap1/leds.c +3 -0
index 3f9dcac..59b7135 100644
@@ -28,6 +28,9 @@ omap_leds_init(void)
     else if (machine_is_omap_osk())
         leds_event = osk_leds_event;
 
+    else if (machine_is_typhoon())
+        leds_event = typhoon_leds_event;
+
     else
         return -1;
 
arch/arm/mach-omap1/leds.h +1 -1
index a1e9fed..1760eb0 100644
@@ -1,3 +1,4 @@
 extern void innovator_leds_event(led_event_t evt);
 extern void h2p2_dbg_leds_event(led_event_t evt);
 extern void osk_leds_event(led_event_t evt);
+extern void typhoon_leds_event(led_event_t evt);
--

1.5.1.3

_______________________________________________
Linux-omap-open-source mailing list
[email protected]
http://linux.omap.com/mailman/listinfo/linux-omap-open-source

Signature · 1 line
--Trilok Soni