Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-footbridge/ebsa285.c |
| 3 | * |
| 4 | * EBSA285 machine fixup |
| 5 | */ |
| 6 | #include <linux/init.h> |
Russell King | 70d13e0 | 2008-12-06 08:25:16 +0000 | [diff] [blame] | 7 | #include <linux/spinlock.h> |
Bryan Wu | cf6856d | 2012-03-14 02:05:24 +0800 | [diff] [blame] | 8 | #include <linux/slab.h> |
| 9 | #include <linux/leds.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
| 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 Wu | cf6856d | 2012-03-14 02:05:24 +0800 | [diff] [blame] | 18 | /* LEDs */ |
| 19 | #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS) |
| 20 | struct 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 | */ |
| 29 | static const struct { |
| 30 | const char *name; |
| 31 | const char *trigger; |
| 32 | } ebsa285_leds[] = { |
| 33 | { "ebsa285:amber", "heartbeat", }, |
| 34 | { "ebsa285:green", "cpu0", }, |
| 35 | { "ebsa285:red",}, |
| 36 | }; |
| 37 | |
| 38 | static void ebsa285_led_set(struct led_classdev *cdev, |
| 39 | enum led_brightness b) |
| 40 | { |
| 41 | struct ebsa285_led *led = container_of(cdev, |
| 42 | struct ebsa285_led, cdev); |
| 43 | |
| 44 | if (b != LED_OFF) |
| 45 | *XBUS_LEDS |= led->mask; |
| 46 | else |
| 47 | *XBUS_LEDS &= ~led->mask; |
| 48 | } |
| 49 | |
| 50 | static enum led_brightness ebsa285_led_get(struct led_classdev *cdev) |
| 51 | { |
| 52 | struct ebsa285_led *led = container_of(cdev, |
| 53 | struct ebsa285_led, cdev); |
| 54 | |
| 55 | return (*XBUS_LEDS & led->mask) ? LED_FULL : LED_OFF; |
| 56 | } |
| 57 | |
| 58 | static int __init ebsa285_leds_init(void) |
| 59 | { |
| 60 | int i; |
| 61 | |
| 62 | if (machine_is_ebsa285()) |
| 63 | return -ENODEV; |
| 64 | |
| 65 | /* 3 LEDS All ON */ |
| 66 | *XBUS_LEDS |= XBUS_LED_AMBER | XBUS_LED_GREEN | XBUS_LED_RED; |
| 67 | |
| 68 | for (i = 0; i < ARRAY_SIZE(ebsa285_leds); i++) { |
| 69 | struct ebsa285_led *led; |
| 70 | |
| 71 | led = kzalloc(sizeof(*led), GFP_KERNEL); |
| 72 | if (!led) |
| 73 | break; |
| 74 | |
| 75 | led->cdev.name = ebsa285_leds[i].name; |
| 76 | led->cdev.brightness_set = ebsa285_led_set; |
| 77 | led->cdev.brightness_get = ebsa285_led_get; |
| 78 | led->cdev.default_trigger = ebsa285_leds[i].trigger; |
| 79 | led->mask = BIT(i); |
| 80 | |
| 81 | if (led_classdev_register(NULL, &led->cdev) < 0) { |
| 82 | kfree(led); |
| 83 | break; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | /* |
| 91 | * Since we may have triggers on any subsystem, defer registration |
| 92 | * until after subsystem_init. |
| 93 | */ |
| 94 | fs_initcall(ebsa285_leds_init); |
| 95 | #endif |
| 96 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | MACHINE_START(EBSA285, "EBSA285") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 98 | /* Maintainer: Russell King */ |
Nicolas Pitre | 93ef888 | 2011-07-05 22:38:11 -0400 | [diff] [blame] | 99 | .atag_offset = 0x100, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 100 | .video_start = 0x000a0000, |
| 101 | .video_end = 0x000bffff, |
| 102 | .map_io = footbridge_map_io, |
| 103 | .init_irq = footbridge_init_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | .timer = &footbridge_timer, |
Russell King | 6fca1e17 | 2011-11-03 19:47:54 +0000 | [diff] [blame] | 105 | .restart = footbridge_restart, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | MACHINE_END |
| 107 | |