~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/powerpc/platforms/cell/cbe_powerbutton.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*
  3  * driver for powerbutton on IBM cell blades
  4  *
  5  * (C) Copyright IBM Corp. 2005-2008
  6  *
  7  * Author: Christian Krafft <krafft@de.ibm.com>
  8  */
  9 
 10 #include <linux/input.h>
 11 #include <linux/module.h>
 12 #include <linux/of.h>
 13 #include <linux/platform_device.h>
 14 #include <asm/pmi.h>
 15 
 16 static struct input_dev *button_dev;
 17 static struct platform_device *button_pdev;
 18 
 19 static void cbe_powerbutton_handle_pmi(pmi_message_t pmi_msg)
 20 {
 21         BUG_ON(pmi_msg.type != PMI_TYPE_POWER_BUTTON);
 22 
 23         input_report_key(button_dev, KEY_POWER, 1);
 24         input_sync(button_dev);
 25         input_report_key(button_dev, KEY_POWER, 0);
 26         input_sync(button_dev);
 27 }
 28 
 29 static struct pmi_handler cbe_pmi_handler = {
 30         .type                   = PMI_TYPE_POWER_BUTTON,
 31         .handle_pmi_message     = cbe_powerbutton_handle_pmi,
 32 };
 33 
 34 static int __init cbe_powerbutton_init(void)
 35 {
 36         int ret = 0;
 37         struct input_dev *dev;
 38 
 39         if (!of_machine_is_compatible("IBM,CBPLUS-1.0")) {
 40                 printk(KERN_ERR "%s: Not a cell blade.\n", __func__);
 41                 ret = -ENODEV;
 42                 goto out;
 43         }
 44 
 45         dev = input_allocate_device();
 46         if (!dev) {
 47                 ret = -ENOMEM;
 48                 printk(KERN_ERR "%s: Not enough memory.\n", __func__);
 49                 goto out;
 50         }
 51 
 52         set_bit(EV_KEY, dev->evbit);
 53         set_bit(KEY_POWER, dev->keybit);
 54 
 55         dev->name = "Power Button";
 56         dev->id.bustype = BUS_HOST;
 57 
 58         /* this makes the button look like an acpi power button
 59          * no clue whether anyone relies on that though */
 60         dev->id.product = 0x02;
 61         dev->phys = "LNXPWRBN/button/input0";
 62 
 63         button_pdev = platform_device_register_simple("power_button", 0, NULL, 0);
 64         if (IS_ERR(button_pdev)) {
 65                 ret = PTR_ERR(button_pdev);
 66                 goto out_free_input;
 67         }
 68 
 69         dev->dev.parent = &button_pdev->dev;
 70         ret = input_register_device(dev);
 71         if (ret) {
 72                 printk(KERN_ERR "%s: Failed to register device\n", __func__);
 73                 goto out_free_pdev;
 74         }
 75 
 76         button_dev = dev;
 77 
 78         ret = pmi_register_handler(&cbe_pmi_handler);
 79         if (ret) {
 80                 printk(KERN_ERR "%s: Failed to register with pmi.\n", __func__);
 81                 goto out_free_pdev;
 82         }
 83 
 84         goto out;
 85 
 86 out_free_pdev:
 87         platform_device_unregister(button_pdev);
 88 out_free_input:
 89         input_free_device(dev);
 90 out:
 91         return ret;
 92 }
 93 
 94 static void __exit cbe_powerbutton_exit(void)
 95 {
 96         pmi_unregister_handler(&cbe_pmi_handler);
 97         platform_device_unregister(button_pdev);
 98         input_free_device(button_dev);
 99 }
100 
101 module_init(cbe_powerbutton_init);
102 module_exit(cbe_powerbutton_exit);
103 
104 MODULE_DESCRIPTION("Driver for powerbutton on IBM cell blades");
105 MODULE_LICENSE("GPL");
106 MODULE_AUTHOR("Christian Krafft <krafft@de.ibm.com>");
107 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php