Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 67430
b: refs/heads/master
c: b418480
h: refs/heads/master
v: v3
  • Loading branch information
Ishizaki Kou authored and Paul Mackerras committed Oct 3, 2007
1 parent c2d07b2 commit 7f37934
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 80755b4144b303882437ac301034f0c7330199a8
refs/heads/master: b41848031ac16aee8d045e86f0b7ad3ba97e961e
94 changes: 93 additions & 1 deletion trunk/arch/powerpc/platforms/celleb/beat.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,24 @@
#include <linux/init.h>
#include <linux/err.h>
#include <linux/rtc.h>
#include <linux/interrupt.h>
#include <linux/irqreturn.h>
#include <linux/reboot.h>

#include <asm/hvconsole.h>
#include <asm/time.h>
#include <asm/machdep.h>
#include <asm/firmware.h>

#include "beat_wrapper.h"
#include "beat.h"
#include "interrupt.h"

static int beat_pm_poweroff_flag;

void beat_restart(char *cmd)
{
beat_shutdown_logical_partition(1);
beat_shutdown_logical_partition(!beat_pm_poweroff_flag);
}

void beat_power_off(void)
Expand Down Expand Up @@ -170,6 +178,90 @@ void beat_kexec_cpu_down(int crash, int secondary)
}
#endif

static irqreturn_t beat_power_event(int virq, void *arg)
{
printk(KERN_DEBUG "Beat: power button pressed\n");
beat_pm_poweroff_flag = 1;
ctrl_alt_del();
return IRQ_HANDLED;
}

static irqreturn_t beat_reset_event(int virq, void *arg)
{
printk(KERN_DEBUG "Beat: reset button pressed\n");
beat_pm_poweroff_flag = 0;
ctrl_alt_del();
return IRQ_HANDLED;
}

static struct beat_event_list {
const char *typecode;
irq_handler_t handler;
unsigned int virq;
} beat_event_list[] = {
{ "power", beat_power_event, 0 },
{ "reset", beat_reset_event, 0 },
};

static int __init beat_register_event(void)
{
u64 path[4], data[2];
int rc, i;
unsigned int virq;

for (i = 0; i < ARRAY_SIZE(beat_event_list); i++) {
struct beat_event_list *ev = &beat_event_list[i];

if (beat_construct_event_receive_port(data) != 0) {
printk(KERN_ERR "Beat: "
"cannot construct event receive port for %s\n",
ev->typecode);
return -EINVAL;
}

virq = irq_create_mapping(NULL, data[0]);
if (virq == NO_IRQ) {
printk(KERN_ERR "Beat: failed to get virtual IRQ"
" for event receive port for %s\n",
ev->typecode);
beat_destruct_event_receive_port(data[0]);
return -EIO;
}
ev->virq = virq;

rc = request_irq(virq, ev->handler, IRQF_DISABLED,
ev->typecode, NULL);
if (rc != 0) {
printk(KERN_ERR "Beat: failed to request virtual IRQ"
" for event receive port for %s\n",
ev->typecode);
beat_destruct_event_receive_port(data[0]);
return rc;
}

path[0] = 0x1000000065780000ul; /* 1,ex */
path[1] = 0x627574746f6e0000ul; /* button */
path[2] = 0;
strncpy((char *)&path[2], ev->typecode, 8);
path[3] = 0;
data[1] = 0;

beat_create_repository_node(path, data);
}
return 0;
}

static int __init beat_event_init(void)
{
if (!firmware_has_feature(FW_FEATURE_BEAT))
return -EINVAL;

beat_pm_poweroff_flag = 0;
return beat_register_event();
}

device_initcall(beat_event_init);

EXPORT_SYMBOL(beat_get_term_char);
EXPORT_SYMBOL(beat_put_term_char);
EXPORT_SYMBOL(beat_halt_code);

0 comments on commit 7f37934

Please sign in to comment.