blob: 3ff7a0c30a0f962801f84a5cd58194f7622ca1d2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-footbridge/ebsa285.c
3 *
4 * EBSA285 machine fixup
5 */
6#include <linux/init.h>
Russell King70d13e02008-12-06 08:25:16 +00007#include <linux/spinlock.h>
Bryan Wucf6856d2012-03-14 02:05:24 +08008#include <linux/slab.h>
9#include <linux/leds.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11#include <asm/hardware/dec21285.h>
12#include <asm/mach-types.h>
13
14#include <asm/mach/arch.h>
15
16#include "common.h"
17
Bryan Wucf6856d2012-03-14 02:05:24 +080018/* LEDs */
19#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
20struct ebsa285_led {
21 struct led_classdev cdev;
22 u8 mask;
23};
24
25/*
26 * The triggers lines up below will only be used if the
27 * LED triggers are compiled in.
28 */
29static const struct {
30 const char *name;
31 const char *trigger;
32} ebsa285_leds[] = {
Russell King67130c52013-11-29 00:54:38 +000033 { "ebsa285:amber", "cpu0", },
34 { "ebsa285:green", "heartbeat", },
Bryan Wucf6856d2012-03-14 02:05:24 +080035 { "ebsa285:red",},
36};
37
Russell King67130c52013-11-29 00:54:38 +000038static unsigned char hw_led_state;
39
Bryan Wucf6856d2012-03-14 02:05:24 +080040static void ebsa285_led_set(struct led_classdev *cdev,
41 enum led_brightness b)
42{
43 struct ebsa285_led *led = container_of(cdev,
44 struct ebsa285_led, cdev);
45
Russell King67130c52013-11-29 00:54:38 +000046 if (b == LED_OFF)
47 hw_led_state |= led->mask;
Bryan Wucf6856d2012-03-14 02:05:24 +080048 else
Russell King67130c52013-11-29 00:54:38 +000049 hw_led_state &= ~led->mask;
50 *XBUS_LEDS = hw_led_state;
Bryan Wucf6856d2012-03-14 02:05:24 +080051}
52
53static enum led_brightness ebsa285_led_get(struct led_classdev *cdev)
54{
55 struct ebsa285_led *led = container_of(cdev,
56 struct ebsa285_led, cdev);
57
Russell King67130c52013-11-29 00:54:38 +000058 return hw_led_state & led->mask ? LED_OFF : LED_FULL;
Bryan Wucf6856d2012-03-14 02:05:24 +080059}
60
61static int __init ebsa285_leds_init(void)
62{
63 int i;
64
Russell King67130c52013-11-29 00:54:38 +000065 if (!machine_is_ebsa285())
Bryan Wucf6856d2012-03-14 02:05:24 +080066 return -ENODEV;
67
Russell King67130c52013-11-29 00:54:38 +000068 /* 3 LEDS all off */
69 hw_led_state = XBUS_LED_AMBER | XBUS_LED_GREEN | XBUS_LED_RED;
70 *XBUS_LEDS = hw_led_state;
Bryan Wucf6856d2012-03-14 02:05:24 +080071
72 for (i = 0; i < ARRAY_SIZE(ebsa285_leds); i++) {
73 struct ebsa285_led *led;
74
75 led = kzalloc(sizeof(*led), GFP_KERNEL);
76 if (!led)
77 break;
78
79 led->cdev.name = ebsa285_leds[i].name;
80 led->cdev.brightness_set = ebsa285_led_set;
81 led->cdev.brightness_get = ebsa285_led_get;
82 led->cdev.default_trigger = ebsa285_leds[i].trigger;
83 led->mask = BIT(i);
84
85 if (led_classdev_register(NULL, &led->cdev) < 0) {
86 kfree(led);
87 break;
88 }
89 }
90
91 return 0;
92}
93
94/*
95 * Since we may have triggers on any subsystem, defer registration
96 * until after subsystem_init.
97 */
98fs_initcall(ebsa285_leds_init);
99#endif
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101MACHINE_START(EBSA285, "EBSA285")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100102 /* Maintainer: Russell King */
Nicolas Pitre93ef8882011-07-05 22:38:11 -0400103 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100104 .video_start = 0x000a0000,
105 .video_end = 0x000bffff,
106 .map_io = footbridge_map_io,
Russell King6cefe922013-11-29 01:03:35 +0000107 .init_early = footbridge_sched_clock,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100108 .init_irq = footbridge_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700109 .init_time = footbridge_timer_init,
Russell King6fca1e172011-11-03 19:47:54 +0000110 .restart = footbridge_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111MACHINE_END
112