aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-clps711x/p720t.c
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@canonical.com>2012-03-14 01:55:26 +0800
committerBryan Wu <bryan.wu@canonical.com>2012-08-01 11:22:08 +0800
commit8ee8ef2996df477aa1623bd213b1548ab1b9c07c (patch)
tree2cdafd3f18279be0ac234d83365801693f15b2aa /arch/arm/mach-clps711x/p720t.c
parentARM: mach-integrator: retire custom LED code (diff)
downloadlinux-dev-8ee8ef2996df477aa1623bd213b1548ab1b9c07c.tar.xz
linux-dev-8ee8ef2996df477aa1623bd213b1548ab1b9c07c.zip
ARM: mach-clps711x: retire custom LED code of P720T machine
Add tigger based LED driver into board file of P720T. Remove old LED driver file. Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'arch/arm/mach-clps711x/p720t.c')
-rw-r--r--arch/arm/mach-clps711x/p720t.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/arch/arm/mach-clps711x/p720t.c b/arch/arm/mach-clps711x/p720t.c
index 42ee8f33eafb..09113a941145 100644
--- a/arch/arm/mach-clps711x/p720t.c
+++ b/arch/arm/mach-clps711x/p720t.c
@@ -23,6 +23,8 @@
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/leds.h>
#include <mach/hardware.h>
#include <asm/pgtable.h>
@@ -34,6 +36,8 @@
#include <asm/mach/map.h>
#include <mach/syspld.h>
+#include <asm/hardware/clps7111.h>
+
#include "common.h"
/*
@@ -121,3 +125,60 @@ static int p720t_hw_init(void)
__initcall(p720t_hw_init);
+/*
+ * LED controled by CPLD
+ */
+#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
+static void p720t_led_set(struct led_classdev *cdev,
+ enum led_brightness b)
+{
+ u8 reg = clps_readb(PDDR);
+
+ if (b != LED_OFF)
+ reg |= 0x1;
+ else
+ reg &= ~0x1;
+
+ clps_writeb(reg, PDDR);
+}
+
+static enum led_brightness p720t_led_get(struct led_classdev *cdev)
+{
+ u8 reg = clps_readb(PDDR);
+
+ return (reg & 0x1) ? LED_FULL : LED_OFF;
+}
+
+static int __init p720t_leds_init(void)
+{
+
+ struct led_classdev *cdev;
+ int ret;
+
+ if (!machine_is_p720t())
+ return -ENODEV;
+
+ cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
+ if (!cdev)
+ return -ENOMEM;
+
+ cdev->name = "p720t:0";
+ cdev->brightness_set = p720t_led_set;
+ cdev->brightness_get = p720t_led_get;
+ cdev->default_trigger = "heartbeat";
+
+ ret = led_classdev_register(NULL, cdev);
+ if (ret < 0) {
+ kfree(cdev);
+ return ret;
+ }
+
+ return 0;
+}
+
+/*
+ * Since we may have triggers on any subsystem, defer registration
+ * until after subsystem_init.
+ */
+fs_initcall(p720t_leds_init);
+#endif