0001
0002
0003
0004
0005
0006
0007 #include <linux/init.h>
0008 #include <linux/io.h>
0009 #include <linux/spinlock.h>
0010 #include <linux/slab.h>
0011 #include <linux/leds.h>
0012
0013 #include <asm/hardware/dec21285.h>
0014 #include <asm/mach-types.h>
0015
0016 #include <asm/mach/arch.h>
0017
0018 #include "common.h"
0019
0020
0021 #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
0022 #define XBUS_AMBER_L BIT(0)
0023 #define XBUS_GREEN_L BIT(1)
0024 #define XBUS_RED_L BIT(2)
0025 #define XBUS_TOGGLE BIT(7)
0026
0027 struct ebsa285_led {
0028 struct led_classdev cdev;
0029 u8 mask;
0030 };
0031
0032
0033
0034
0035
0036 static const struct {
0037 const char *name;
0038 const char *trigger;
0039 } ebsa285_leds[] = {
0040 { "ebsa285:amber", "cpu0", },
0041 { "ebsa285:green", "heartbeat", },
0042 { "ebsa285:red",},
0043 };
0044
0045 static unsigned char hw_led_state;
0046 static void __iomem *xbus;
0047
0048 static void ebsa285_led_set(struct led_classdev *cdev,
0049 enum led_brightness b)
0050 {
0051 struct ebsa285_led *led = container_of(cdev,
0052 struct ebsa285_led, cdev);
0053
0054 if (b == LED_OFF)
0055 hw_led_state |= led->mask;
0056 else
0057 hw_led_state &= ~led->mask;
0058 writeb(hw_led_state, xbus);
0059 }
0060
0061 static enum led_brightness ebsa285_led_get(struct led_classdev *cdev)
0062 {
0063 struct ebsa285_led *led = container_of(cdev,
0064 struct ebsa285_led, cdev);
0065
0066 return hw_led_state & led->mask ? LED_OFF : LED_FULL;
0067 }
0068
0069 static int __init ebsa285_leds_init(void)
0070 {
0071 int i;
0072
0073 if (!machine_is_ebsa285())
0074 return -ENODEV;
0075
0076 xbus = ioremap(XBUS_CS2, SZ_4K);
0077 if (!xbus)
0078 return -ENOMEM;
0079
0080
0081 hw_led_state = XBUS_AMBER_L | XBUS_GREEN_L | XBUS_RED_L;
0082 writeb(hw_led_state, xbus);
0083
0084 for (i = 0; i < ARRAY_SIZE(ebsa285_leds); i++) {
0085 struct ebsa285_led *led;
0086
0087 led = kzalloc(sizeof(*led), GFP_KERNEL);
0088 if (!led)
0089 break;
0090
0091 led->cdev.name = ebsa285_leds[i].name;
0092 led->cdev.brightness_set = ebsa285_led_set;
0093 led->cdev.brightness_get = ebsa285_led_get;
0094 led->cdev.default_trigger = ebsa285_leds[i].trigger;
0095 led->mask = BIT(i);
0096
0097 if (led_classdev_register(NULL, &led->cdev) < 0) {
0098 kfree(led);
0099 break;
0100 }
0101 }
0102
0103 return 0;
0104 }
0105
0106
0107
0108
0109
0110 fs_initcall(ebsa285_leds_init);
0111 #endif
0112
0113 MACHINE_START(EBSA285, "EBSA285")
0114
0115 .atag_offset = 0x100,
0116 .video_start = 0x000a0000,
0117 .video_end = 0x000bffff,
0118 .map_io = footbridge_map_io,
0119 .init_early = footbridge_sched_clock,
0120 .init_irq = footbridge_init_irq,
0121 .init_time = footbridge_timer_init,
0122 .restart = footbridge_restart,
0123 MACHINE_END
0124