From: arnd@arndb•de
To: Paul Mackerras <paulus@samba•org>,
Benjamin Herrenschmidt <benh@kernel•crashing.org>
Cc: linuxppc-dev@ozlabs•org, cbe-oss-dev@ozlabs•org,
Christian Krafft <krafft@de•ibm.com>
Subject: [patch 01/11] powerpc/cell: add support for power button of future IBM cell blades
Date: Fri, 04 Jul 2008 21:05:36 +0200 [thread overview]
Message-ID: <20080704190805.638836822@arndb.de> (raw)
In-Reply-To: 20080704190535.316377278@arndb.de
This patch adds support for the power button on future IBM cell blades.
It actually doesn't shut down the machine. Instead it exposes an
input device /dev/input/event0 to userspace which sends KEY_POWER
if power button has been pressed.
haldaemon actually recognizes the button, so a plattform independent acpid
replacement should handle it correctly.
Signed-off-by: Christian Krafft <krafft@de•ibm.com>
Signed-off-by: Arnd Bergmann <arnd@arndb•de>
---
arch/powerpc/platforms/cell/pervasive.c | 70 ++++++++++++++++++++++++++++++-
1 files changed, 69 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/platforms/cell/pervasive.c b/arch/powerpc/platforms/cell/pervasive.c
index 8a3631c..e5bd08c 100644
--- a/arch/powerpc/platforms/cell/pervasive.c
+++ b/arch/powerpc/platforms/cell/pervasive.c
@@ -24,8 +24,10 @@
#undef DEBUG
#include <linux/interrupt.h>
+#include <linux/input.h>
#include <linux/irq.h>
#include <linux/percpu.h>
+#include <linux/platform_device.h>
#include <linux/types.h>
#include <linux/kallsyms.h>
@@ -40,6 +42,9 @@
static int sysreset_hack;
+static struct input_dev *button_dev;
+static struct platform_device *button_pdev;
+
static void cbe_power_save(void)
{
unsigned long ctrl, thread_switch_control;
@@ -105,10 +110,21 @@ static int cbe_system_reset_exception(struct pt_regs *regs)
*/
if (sysreset_hack && (cpu = smp_processor_id()) == 0) {
pmd = cbe_get_cpu_pmd_regs(cpu);
- if (in_be64(&pmd->ras_esc_0) & 0xffff) {
+ if (in_be64(&pmd->ras_esc_0) & 0x0000ffff) {
out_be64(&pmd->ras_esc_0, 0);
return 0;
}
+ if (in_be64(&pmd->ras_esc_0) & 0x00010000) {
+ out_be64(&pmd->ras_esc_0, 0);
+ if (!button_dev)
+ return 0;
+
+ input_report_key(button_dev, KEY_POWER, 1);
+ input_sync(button_dev);
+ input_report_key(button_dev, KEY_POWER, 0);
+ input_sync(button_dev);
+ return 1;
+ }
}
break;
#ifdef CONFIG_CBE_RAS
@@ -155,3 +171,55 @@ void __init cbe_pervasive_init(void)
ppc_md.power_save = cbe_power_save;
ppc_md.system_reset_exception = cbe_system_reset_exception;
}
+
+static int __init cbe_power_button_init(void)
+{
+ int ret;
+ struct input_dev *dev;
+
+ if (!sysreset_hack)
+ return 0;
+
+ dev = input_allocate_device();
+ if (!dev) {
+ ret = -ENOMEM;
+ printk(KERN_ERR "%s: Not enough memory\n", __func__);
+ goto out;
+ }
+
+ set_bit(EV_KEY, dev->evbit);
+ set_bit(KEY_POWER, dev->keybit);
+
+ dev->name = "Power Button";
+ dev->id.bustype = BUS_HOST;
+
+ /* this makes the button look like an acpi power button
+ * no clue whether anyone relies on that though */
+ dev->id.product = 0x02;
+ dev->phys = "LNXPWRBN/button/input0";
+
+ button_pdev = platform_device_register_simple("power_button", 0, NULL, 0);
+ if (IS_ERR(button_pdev)) {
+ ret = PTR_ERR(button_pdev);
+ goto out_free_input;
+ }
+
+ dev->dev.parent = &button_pdev->dev;
+
+ ret = input_register_device(dev);
+ if (ret) {
+ printk(KERN_ERR "%s: Failed to register device\n", __func__);
+ goto out_free_pdev;
+ }
+
+ button_dev = dev;
+ return ret;
+
+out_free_pdev:
+ platform_device_unregister(button_pdev);
+out_free_input:
+ input_free_device(dev);
+out:
+ return ret;
+}
+device_initcall(cbe_power_button_init);
--
1.5.4.3
--
next prev parent reply other threads:[~2008-07-04 19:05 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-04 19:05 [patch 00/11] Cell patches for 2.6.27 arnd
2008-07-04 19:05 ` arnd [this message]
2008-07-07 5:12 ` [patch 01/11] powerpc/cell: add support for power button of future IBM cell blades Benjamin Herrenschmidt
2008-07-07 9:23 ` Christian Krafft
[not found] ` <20080707184756.16e52677@linux.ibm.com>
2008-07-07 16:54 ` [Cbe-oss-dev] [patch 01/02] powerpc/cell: cleanup sysreset_hack for " Christian Krafft
2008-07-07 16:56 ` [Cbe-oss-dev] [patch 02/02] powerpc/cell: add support for power button of future " Christian Krafft
2008-07-09 3:35 ` Benjamin Herrenschmidt
2008-07-09 13:15 ` Arnd Bergmann
2008-07-09 20:45 ` Benjamin Herrenschmidt
2008-07-10 14:34 ` Arnd Bergmann
2008-07-07 5:24 ` [patch 01/11] " Stephen Rothwell
2008-07-07 8:40 ` [Cbe-oss-dev] " Arnd Bergmann
2008-07-04 19:05 ` [patch 02/11] powerpc/axonram: use only one block device major number arnd
2008-07-04 19:05 ` [patch 03/11] powerpc/axonram: enable partitioning of the Axons DDR2 DIMMs arnd
2008-07-04 19:05 ` [patch 04/11] powerpc/spufs: add atomic busy_spus counter to struct cbe_spu_info arnd
2008-07-07 5:19 ` Benjamin Herrenschmidt
2008-07-07 5:30 ` Stephen Rothwell
2008-07-07 8:50 ` [Cbe-oss-dev] " Arnd Bergmann
2008-07-04 19:05 ` [patch 05/11] powerpc/cell: add spu aware cpufreq governor arnd
2008-07-07 5:21 ` Benjamin Herrenschmidt
2008-07-07 5:32 ` Stephen Rothwell
2008-07-07 9:01 ` [Cbe-oss-dev] " Arnd Bergmann
2008-07-07 6:24 ` Stephen Rothwell
2008-07-07 8:58 ` [Cbe-oss-dev] " Arnd Bergmann
2008-07-07 14:59 ` Arnd Bergmann
2008-07-07 15:35 ` Josh Boyer
2008-07-07 21:15 ` Arnd Bergmann
2008-07-07 21:17 ` Josh Boyer
2008-07-08 2:40 ` Stephen Rothwell
2008-07-07 19:56 ` Geoff Levand
2008-07-04 19:05 ` [patch 06/11] powerpc: Add struct iommu_table argument to iommu_map_sg() arnd
2008-07-04 19:05 ` [patch 07/11] powerpc/dma: implement new dma_*map*_attrs() interfaces arnd
2008-07-07 5:27 ` Benjamin Herrenschmidt
2008-07-07 19:15 ` Geoff Levand
2008-07-04 19:05 ` [patch 08/11] powerpc/dma: use the struct dma_attrs in iommu code arnd
2008-07-04 19:05 ` [patch 09/11] powerpc/cell: cell_dma_dev_setup_iommu() return the iommu table arnd
2008-07-04 19:05 ` [patch 10/11] powerpc: move device_to_mask() to dma-mapping.h arnd
2008-07-04 19:05 ` [patch 11/11] powerpc/cell: Add DMA_ATTR_STRONG_ORDERING dma attribute and use in IOMMU code arnd
2008-07-05 5:43 ` [Cbe-oss-dev] " Michael Ellerman
2008-07-05 6:28 ` Benjamin Herrenschmidt
2008-07-05 21:51 ` Arnd Bergmann
2008-07-05 22:20 ` Benjamin Herrenschmidt
2008-07-06 15:15 ` Arnd Bergmann
2008-07-07 0:00 ` Michael Ellerman
2008-07-07 9:01 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080704190805.638836822@arndb.de \
--to=arnd@arndb$(echo .)de \
--cc=benh@kernel$(echo .)crashing.org \
--cc=cbe-oss-dev@ozlabs$(echo .)org \
--cc=krafft@de$(echo .)ibm.com \
--cc=linuxppc-dev@ozlabs$(echo .)org \
--cc=paulus@samba$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox