Skip to content

Commit e86169f

Browse files
Yoichi Yuasaralfbaechle
authored andcommitted
[MIPS] Cobalt: Add Cobalt Raq LED platform register and power off trigger
Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent f4fae82 commit e86169f

3 files changed

Lines changed: 71 additions & 9 deletions

File tree

‎arch/mips/cobalt/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Makefile for the Cobalt micro systems family specific parts of the kernel
33
#
44

5-
obj-y := buttons.o irq.o reset.o rtc.o serial.o setup.o
5+
obj-y := buttons.o irq.o led.o reset.o rtc.o serial.o setup.o
66

77
obj-$(CONFIG_PCI) += pci.o
88
obj-$(CONFIG_EARLY_PRINTK) += console.o

‎arch/mips/cobalt/led.c‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Registration of Cobalt LED platform device.
3+
*
4+
* Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
#include <linux/errno.h>
21+
#include <linux/init.h>
22+
#include <linux/ioport.h>
23+
#include <linux/platform_device.h>
24+
25+
static struct resource cobalt_led_resource __initdata = {
26+
.start = 0x1c000000,
27+
.end = 0x1c000000,
28+
.flags = IORESOURCE_MEM,
29+
};
30+
31+
static __init int cobalt_led_add(void)
32+
{
33+
struct platform_device *pdev;
34+
int retval;
35+
36+
pdev = platform_device_alloc("cobalt-raq-leds", -1);
37+
38+
if (!pdev)
39+
return -ENOMEM;
40+
41+
retval = platform_device_add_resources(pdev, &cobalt_led_resource, 1);
42+
if (retval)
43+
goto err_free_device;
44+
45+
retval = platform_device_add(pdev);
46+
if (retval)
47+
goto err_free_device;
48+
49+
return 0;
50+
51+
err_free_device:
52+
platform_device_put(pdev);
53+
54+
return retval;
55+
}
56+
device_initcall(cobalt_led_add);

‎arch/mips/cobalt/reset.c‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,37 @@
88
* Copyright (C) 1995, 1996, 1997 by Ralf Baechle
99
* Copyright (C) 2001 by Liam Davies (ldavies@agile.tv)
1010
*/
11+
#include <linux/init.h>
1112
#include <linux/jiffies.h>
12-
13-
#include <asm/io.h>
14-
#include <asm/reboot.h>
13+
#include <linux/leds.h>
1514

1615
#include <cobalt.h>
1716

17+
DEFINE_LED_TRIGGER(power_off_led_trigger);
18+
19+
static int __init ledtrig_power_off_init(void)
20+
{
21+
led_trigger_register_simple("power-off", &power_off_led_trigger);
22+
return 0;
23+
}
24+
device_initcall(ledtrig_power_off_init);
25+
1826
void cobalt_machine_halt(void)
1927
{
2028
int state, last, diff;
2129
unsigned long mark;
2230

2331
/*
24-
* turn off bar on Qube, flash power off LED on RaQ (0.5Hz)
32+
* turn on power off LED on RaQ
2533
*
2634
* restart if ENTER and SELECT are pressed
2735
*/
2836

2937
last = COBALT_KEY_PORT;
3038

31-
for (state = 0;;) {
32-
33-
state ^= COBALT_LED_POWER_OFF;
34-
COBALT_LED_PORT = state;
39+
led_trigger_event(power_off_led_trigger, LED_FULL);
3540

41+
for (state = 0;;) {
3642
diff = COBALT_KEY_PORT ^ last;
3743
last ^= diff;
3844

0 commit comments

Comments
 (0)