blob: 8dcc823f41353baa1c1a27db44f86ee4a819bc49 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 King20cf33e2005-06-18 10:15:46 +010025#include <linux/smp.h>
26#include <linux/spinlock.h>
Russell Kingfced80c2008-09-06 12:10:45 +010027#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <asm/leds.h>
31#include <asm/system.h>
32#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010033#include <mach/cm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35static int saved_leds;
36
37static void integrator_leds_event(led_event_t ledevt)
38{
39 unsigned long flags;
40 const unsigned int dbg_base = IO_ADDRESS(INTEGRATOR_DBG_BASE);
41 unsigned int update_alpha_leds;
Russell King1f9c3812005-05-03 12:22:19 +010042
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 // yup, change the LEDs
44 local_irq_save(flags);
45 update_alpha_leds = 0;
46
47 switch(ledevt) {
48 case led_idle_start:
49 cm_control(CM_CTRL_LED, 0);
50 break;
51
52 case led_idle_end:
53 cm_control(CM_CTRL_LED, CM_CTRL_LED);
54 break;
55
56 case led_timer:
57 saved_leds ^= GREEN_LED;
58 update_alpha_leds = 1;
59 break;
60
61 case led_red_on:
62 saved_leds |= RED_LED;
63 update_alpha_leds = 1;
64 break;
65
66 case led_red_off:
67 saved_leds &= ~RED_LED;
68 update_alpha_leds = 1;
69 break;
70
71 default:
72 break;
73 }
74
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);
78 }
79 local_irq_restore(flags);
80}
81
82static int __init leds_init(void)
83{
84 if (machine_is_integrator() || machine_is_cintegrator())
85 leds_event = integrator_leds_event;
86
87 return 0;
88}
89
Russell King20cf33e2005-06-18 10:15:46 +010090core_initcall(leds_init);