summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuinn Jensen <quinn.jensen@freescale.com>2007-05-24 18:11:08 -0600
committerQuinn Jensen <quinn.jensen@freescale.com>2007-05-24 18:11:08 -0600
commit55301e3cf92bc26a4cb997629cf3dddebcdf2b48 (patch)
tree8a287f787b7f7133dc6e425087db30ec2b29fd60
parentd022478aae34d1389393b8308ece7d5dbd767557 (diff)
CR TLSbo79347: Add MXC debug LED driver
Description: * The LED can be used for debugging purpose. To enable the LEDs, in the * config file, select: * CONFIG_LEDS * CONFIG_LEDS_TIMER --- enable the OS tick LED once every 50 ticks (.5sec) * CONFIG_LEDS_CPU --- enable the cpu idle in/out LED (blink fast) * * The two LEDs can be disabled through user space by issuing: * echo "claim" > /sys/devices/system/leds/leds0/event * To release the LEDs back to the normal operation, do: * echo "release" > /sys/devices/system/leds/leds0/event http://www.bitshrine.org/gpp/linux-2.6.19.2-mx-mxc_debug_leds.patch
-rw-r--r--arch/arm/Kconfig6
-rw-r--r--arch/arm/plat-mxc/Makefile6
-rw-r--r--arch/arm/plat-mxc/leds.c111
-rw-r--r--include/asm-arm/arch-mxc/board-mx27ads.h7
-rw-r--r--include/asm-arm/arch-mxc/board-mx31ads.h7
5 files changed, 132 insertions, 5 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 095e9532c48c..3ef7bf9355f3 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -592,7 +592,7 @@ config LEDS
ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_NETWINDER || \
ARCH_OMAP || ARCH_P720T || ARCH_PXA_IDP || \
ARCH_SA1100 || ARCH_SHARK || ARCH_VERSATILE || \
- ARCH_AT91RM9200 || MACH_TRIZEPS4
+ ARCH_AT91RM9200 || MACH_TRIZEPS4 || ARCH_MXC
help
If you say Y here, the LEDs on your machine will be used
to provide useful information about your current system status.
@@ -606,7 +606,7 @@ config LEDS
config LEDS_TIMER
bool "Timer LED" if (!ARCH_CDB89712 && !ARCH_OMAP) || \
- MACH_OMAP_H2 || MACH_OMAP_PERSEUS2
+ MACH_OMAP_H2 || MACH_OMAP_PERSEUS2 || ARCH_MXC
depends on LEDS
default y if ARCH_EBSA110
help
@@ -622,7 +622,7 @@ config LEDS_TIMER
config LEDS_CPU
bool "CPU usage LED" if (!ARCH_CDB89712 && !ARCH_EBSA110 && \
- !ARCH_OMAP) || MACH_OMAP_H2 || MACH_OMAP_PERSEUS2
+ !ARCH_OMAP) || MACH_OMAP_H2 || MACH_OMAP_PERSEUS2 || ARCH_MXC
depends on LEDS
help
If you say Y here, the red LED will be used to give a good real
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index 3204115b8a60..76bffa5b19dd 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -9,8 +9,10 @@ obj-$(CONFIG_ARCH_MX27) += dma_mx2.o
obj-$(CONFIG_ARCH_MX3) += cpu_common.o spba.o
obj-$(CONFIG_MXC_SDMA_API) += sdma/
+
+# LEDs support
+obj-$(CONFIG_LEDS) += leds.o
+
obj-m :=
obj-n :=
obj- :=
-
-
diff --git a/arch/arm/plat-mxc/leds.c b/arch/arm/plat-mxc/leds.c
new file mode 100644
index 000000000000..09d1ee3f4459
--- /dev/null
+++ b/arch/arm/plat-mxc/leds.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ */
+
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/*
+ * The LED can be used for debugging purpose. To enalbe the LEDs, in the
+ * config file, select:
+ * CONFIG_LEDS
+ * CONFIG_LEDS_TIMER --- enable the OS tick LED once every 50 ticks (.5sec)
+ * CONFIG_LEDS_CPU --- enable the cpu idle in/out LED (blink fast)
+ *
+ * The two LEDs can be disabled through user space by issuing:
+ * echo "claim" > /sys/devices/system/leds/leds0/event
+ * To release the LEDs back to the normal operation, do:
+ * echo "release" > /sys/devices/system/leds/leds0/event
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/ioport.h>
+#include <asm/mach-types.h>
+#include <asm/hardware.h>
+#include <asm/leds.h>
+
+#define LED_STATE_ENABLED (1 << 0)
+#define LED_STATE_CLAIMED (1 << 1)
+
+static unsigned int led_state;
+static unsigned int hw_led_state;
+
+static void mxc_leds_event(led_event_t evt)
+{
+ unsigned long flags;
+
+ local_irq_save(flags);
+
+ switch (evt) {
+ case led_start:
+ hw_led_state = MXC_BD_LED1 | MXC_BD_LED2;
+ led_state = LED_STATE_ENABLED;
+ break;
+
+ case led_stop:
+ case led_halted:
+ hw_led_state = 0;
+ led_state &= ~LED_STATE_ENABLED;
+ MXC_BD_LED_OFF(MXC_BD_LED1 | MXC_BD_LED2);
+ break;
+
+ case led_claim:
+ led_state |= LED_STATE_CLAIMED;
+ hw_led_state = 0;
+ break;
+
+ case led_release:
+ led_state &= ~LED_STATE_CLAIMED;
+ hw_led_state = 0;
+ break;
+
+#ifdef CONFIG_LEDS_TIMER
+ case led_timer:
+ if (!(led_state & LED_STATE_CLAIMED))
+ hw_led_state ^= MXC_BD_LED1;
+ break;
+#endif
+
+#ifdef CONFIG_LEDS_CPU
+ case led_idle_start:
+ if (!(led_state & LED_STATE_CLAIMED))
+ hw_led_state &= ~MXC_BD_LED2;
+ break;
+
+ case led_idle_end:
+ if (!(led_state & LED_STATE_CLAIMED))
+ hw_led_state |= MXC_BD_LED2;
+ break;
+#endif
+
+ default:
+ break;
+ }
+
+ if (led_state & LED_STATE_ENABLED) {
+ MXC_BD_LED_OFF(~hw_led_state);
+ MXC_BD_LED_ON(hw_led_state);
+ }
+
+ local_irq_restore(flags);
+}
+
+static int __init mxc_leds_init(void)
+{
+ led_state = LED_STATE_ENABLED;
+ leds_event = mxc_leds_event;
+ return 0;
+}
+
+core_initcall(mxc_leds_init);
diff --git a/include/asm-arm/arch-mxc/board-mx27ads.h b/include/asm-arm/arch-mxc/board-mx27ads.h
index 7bd6cd744573..8f00526a68b6 100644
--- a/include/asm-arm/arch-mxc/board-mx27ads.h
+++ b/include/asm-arm/arch-mxc/board-mx27ads.h
@@ -422,4 +422,11 @@ enum mxc_card_no {
__raw_writew( \
PBC_BCTRL2_ATAFEC_EN |PBC_BCTRL2_ATAFEC_SEL | PBC_BCTRL2_ATA_EN, PBC_BCTRL2_SET_REG)
+#define MXC_BD_LED1 (1 << 5)
+#define MXC_BD_LED2 (1 << 6)
+#define MXC_BD_LED_ON(led) \
+ __raw_writew(led, PBC_BCTRL1_SET_REG)
+#define MXC_BD_LED_OFF(led) \
+ __raw_writew(led, PBC_BCTRL1_CLEAR_REG)
+
#endif /* __ASM_ARCH_MXC_BOARD_MX27ADS_H__ */
diff --git a/include/asm-arm/arch-mxc/board-mx31ads.h b/include/asm-arm/arch-mxc/board-mx31ads.h
index 157b2f3f96bb..4387d78ec78e 100644
--- a/include/asm-arm/arch-mxc/board-mx31ads.h
+++ b/include/asm-arm/arch-mxc/board-mx31ads.h
@@ -352,4 +352,11 @@
#define PBC_ATA_SIGNAL_INACTIVE() \
__raw_writew(PBC_BCTRL2_ATA_EN, PBC_BASE_ADDRESS + PBC_BCTRL2_SET);
+#define MXC_BD_LED1 (1 << 6)
+#define MXC_BD_LED2 (1 << 7)
+#define MXC_BD_LED_ON(led) \
+ __raw_writew(led, PBC_BASE_ADDRESS + PBC_BCTRL1_SET)
+#define MXC_BD_LED_OFF(led) \
+ __raw_writew(led, PBC_BASE_ADDRESS + PBC_BCTRL1_CLEAR)
+
#endif /* __ASM_ARCH_MXC_BOARD_MX31ADS_H__ */