[patch 01/11] powerpc/cell: add support for power button of future IBM cell blades
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 <[EMAIL PROTECTED]> Signed-off-by: Arnd Bergmann <[EMAIL PROTECTED]> --- 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 +#include #include #include +#include #include #include @@ -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) & 0x) { + if (in_be64(&pmd->ras_esc_0) & 0x) { out_be64(&pmd->ras_esc_0, 0); return 0; } + if (in_be64(&pmd->ras_esc_0) & 0x0001) { + 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 -- ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [patch 01/11] powerpc/cell: add support for power button of future IBM cell blades
On Fri, 2008-07-04 at 21:05 +0200, [EMAIL PROTECTED] wrote: > plain text document attachment > (0001-powerpc-cell-add-support-for-power-button-of-future.patch) > 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 <[EMAIL PROTECTED]> > Signed-off-by: Arnd Bergmann <[EMAIL PROTECTED]> > --- And what if CONFIG_INPUT=n or m ? Cheers, Ben. > 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 > +#include > #include > #include > +#include > #include > #include > > @@ -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) & 0x) { > + if (in_be64(&pmd->ras_esc_0) & 0x) { > out_be64(&pmd->ras_esc_0, 0); > return 0; > } > + if (in_be64(&pmd->ras_esc_0) & 0x0001) { > + 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 > ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [patch 01/11] powerpc/cell: add support for power button of future IBM cell blades
Hi Arnd, On Fri, 04 Jul 2008 21:05:36 +0200 [EMAIL PROTECTED] wrote: > > 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 <[EMAIL PROTECTED]> > Signed-off-by: Arnd Bergmann <[EMAIL PROTECTED]> Was this written by you or Christian? > @@ -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) & 0x) { > + if (in_be64(&pmd->ras_esc_0) & 0x) { > out_be64(&pmd->ras_esc_0, 0); > return 0; > } > + if (in_be64(&pmd->ras_esc_0) & 0x0001) { Do we really want to read that register twice? (Just asking, I don't know how the hardware works ...) Also, do we want to recognise this bit even if some lower order bits are set? (this code won't) > +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; > +} Some white space damage here. > + ret = input_register_device(dev); > + if (ret) { > +printk(KERN_ERR "%s: Failed to register device\n", __func__); > + goto out_free_pdev; > +} And here. -- Cheers, Stephen Rothwell[EMAIL PROTECTED] http://www.canb.auug.org.au/~sfr/ pgpkvIK5BBVdO.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [patch 01/11] powerpc/cell: add support for power button of future IBM cell blades
On Mon, 07 Jul 2008 15:12:23 +1000 Benjamin Herrenschmidt <[EMAIL PROTECTED]> wrote: > On Fri, 2008-07-04 at 21:05 +0200, [EMAIL PROTECTED] wrote: > > plain text document attachment > > (0001-powerpc-cell-add-support-for-power-button-of-future.patch) > > 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 <[EMAIL PROTECTED]> > > Signed-off-by: Arnd Bergmann <[EMAIL PROTECTED]> > > --- > > And what if CONFIG_INPUT=n or m ? > > Cheers, > Ben. > hm, good point. Only wrapping with ifdefs will not fix the CONFIG_INPUT=m case. Have to think about it again, will send an update ... Cheers, ck -- Mit freundlichen Gruessen, kind regards, Christian Krafft Linux Kernel Development IBM Systems & Technology Group Phone: +49-07031-16-2032 IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martin Jetter Geschaetsfuehung: Herbert Kircher Sitz der Gesellschaft: Boelingen Registergericht:Amtsgericht Stuttgart, HRB 243294 ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [Cbe-oss-dev] [patch 01/11] powerpc/cell: add support for power button of future IBM cell blades
On Monday 07 July 2008, Stephen Rothwell wrote: > > Signed-off-by: Christian Krafft <[EMAIL PROTECTED]> > > Signed-off-by: Arnd Bergmann <[EMAIL PROTECTED]> > > Was this written by you or Christian? It's from Christian. For some reason, the author is reflected correctly in my git tree, but git-format-patch/quilt-mail must have lost that information. I need to check my scripts. > > @@ -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) & 0x) { > > + if (in_be64(&pmd->ras_esc_0) & 0x) { > > out_be64(&pmd->ras_esc_0, 0); > > return 0; > > } > > + if (in_be64(&pmd->ras_esc_0) & 0x0001) { > > Do we really want to read that register twice? (Just asking, I don't > know how the hardware works ...) Also, do we want to recognise this bit > even if some lower order bits are set? (this code won't) It would probably be cleaner to read it just once, but it's safe to read it multiple times. It only gets written by the BMC when a button gets pressed. The lower bits are for system-reset, i.e. for entering xmon or kdump, while the higher bits are for soft power off, and we certainly don't want to trigger a soft powerp off at the same time as an xmon entry. Arnd <>< ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev