| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *  linux/arch/arm/mach-integrator/leds.c | 
|  | 3 | * | 
|  | 4 | *  Integrator/AP and Integrator/CP LED control routines | 
|  | 5 | * | 
|  | 6 | *  Copyright (C) 1999 ARM Limited | 
|  | 7 | *  Copyright (C) 2000 Deep Blue Solutions Ltd | 
|  | 8 | * | 
|  | 9 | * This program is free software; you can redistribute it and/or modify | 
|  | 10 | * it under the terms of the GNU General Public License as published by | 
|  | 11 | * the Free Software Foundation; either version 2 of the License, or | 
|  | 12 | * (at your option) any later version. | 
|  | 13 | * | 
|  | 14 | * This program is distributed in the hope that it will be useful, | 
|  | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 17 | * GNU General Public License for more details. | 
|  | 18 | * | 
|  | 19 | * You should have received a copy of the GNU General Public License | 
|  | 20 | * along with this program; if not, write to the Free Software | 
|  | 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
|  | 22 | */ | 
|  | 23 | #include <linux/kernel.h> | 
|  | 24 | #include <linux/init.h> | 
| Russell King | 20cf33e | 2005-06-18 10:15:46 +0100 | [diff] [blame] | 25 | #include <linux/smp.h> | 
|  | 26 | #include <linux/spinlock.h> | 
| Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 27 | #include <linux/io.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 |  | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 29 | #include <mach/hardware.h> | 
| Russell King | a285edc | 2010-01-14 19:59:37 +0000 | [diff] [blame] | 30 | #include <mach/platform.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <asm/leds.h> | 
|  | 32 | #include <asm/system.h> | 
|  | 33 | #include <asm/mach-types.h> | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 34 | #include <mach/cm.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 |  | 
|  | 36 | static int saved_leds; | 
|  | 37 |  | 
|  | 38 | static void integrator_leds_event(led_event_t ledevt) | 
|  | 39 | { | 
|  | 40 | unsigned long flags; | 
|  | 41 | const unsigned int dbg_base = IO_ADDRESS(INTEGRATOR_DBG_BASE); | 
|  | 42 | unsigned int update_alpha_leds; | 
| Russell King | 1f9c381 | 2005-05-03 12:22:19 +0100 | [diff] [blame] | 43 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | // yup, change the LEDs | 
|  | 45 | local_irq_save(flags); | 
|  | 46 | update_alpha_leds = 0; | 
|  | 47 |  | 
|  | 48 | switch(ledevt) { | 
|  | 49 | case led_idle_start: | 
|  | 50 | cm_control(CM_CTRL_LED, 0); | 
|  | 51 | break; | 
|  | 52 |  | 
|  | 53 | case led_idle_end: | 
|  | 54 | cm_control(CM_CTRL_LED, CM_CTRL_LED); | 
|  | 55 | break; | 
|  | 56 |  | 
|  | 57 | case led_timer: | 
|  | 58 | saved_leds ^= GREEN_LED; | 
|  | 59 | update_alpha_leds = 1; | 
|  | 60 | break; | 
|  | 61 |  | 
|  | 62 | case led_red_on: | 
|  | 63 | saved_leds |= RED_LED; | 
|  | 64 | update_alpha_leds = 1; | 
|  | 65 | break; | 
|  | 66 |  | 
|  | 67 | case led_red_off: | 
|  | 68 | saved_leds &= ~RED_LED; | 
|  | 69 | update_alpha_leds = 1; | 
|  | 70 | break; | 
|  | 71 |  | 
|  | 72 | default: | 
|  | 73 | break; | 
|  | 74 | } | 
|  | 75 |  | 
|  | 76 | if (update_alpha_leds) { | 
|  | 77 | while (__raw_readl(dbg_base + INTEGRATOR_DBG_ALPHA_OFFSET) & 1); | 
|  | 78 | __raw_writel(saved_leds, dbg_base + INTEGRATOR_DBG_LEDS_OFFSET); | 
|  | 79 | } | 
|  | 80 | local_irq_restore(flags); | 
|  | 81 | } | 
|  | 82 |  | 
|  | 83 | static int __init leds_init(void) | 
|  | 84 | { | 
|  | 85 | if (machine_is_integrator() || machine_is_cintegrator()) | 
|  | 86 | leds_event = integrator_leds_event; | 
|  | 87 |  | 
|  | 88 | return 0; | 
|  | 89 | } | 
|  | 90 |  | 
| Russell King | 20cf33e | 2005-06-18 10:15:46 +0100 | [diff] [blame] | 91 | core_initcall(leds_init); |