2 * linux/arch/arm/mach-integrator/leds.c
4 * Integrator/AP and Integrator/CP LED control routines
6 * Copyright (C) 1999 ARM Limited
7 * Copyright (C) 2000 Deep Blue Solutions Ltd
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.
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.
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
23 #include <linux/kernel.h>
24 #include <linux/init.h>
25 #include <linux/smp.h>
26 #include <linux/spinlock.h>
28 #include <mach/hardware.h>
31 #include <asm/system.h>
32 #include <asm/mach-types.h>
35 static int saved_leds;
37 static void integrator_leds_event(led_event_t ledevt)
40 const unsigned int dbg_base = IO_ADDRESS(INTEGRATOR_DBG_BASE);
41 unsigned int update_alpha_leds;
43 // yup, change the LEDs
44 local_irq_save(flags);
45 update_alpha_leds = 0;
49 cm_control(CM_CTRL_LED, 0);
53 cm_control(CM_CTRL_LED, CM_CTRL_LED);
57 saved_leds ^= GREEN_LED;
58 update_alpha_leds = 1;
62 saved_leds |= RED_LED;
63 update_alpha_leds = 1;
67 saved_leds &= ~RED_LED;
68 update_alpha_leds = 1;
75 if (update_alpha_leds) {
76 while (__raw_readl(dbg_base + INTEGRATOR_DBG_ALPHA_OFFSET) & 1);
77 __raw_writel(saved_leds, dbg_base + INTEGRATOR_DBG_LEDS_OFFSET);
79 local_irq_restore(flags);
82 static int __init leds_init(void)
84 if (machine_is_integrator() || machine_is_cintegrator())
85 leds_event = integrator_leds_event;
90 core_initcall(leds_init);