From patchwork Thu May 17 06:44:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ike Panhc X-Patchwork-Id: 159824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 50EE2B6EF1 for ; Thu, 17 May 2012 16:44:48 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SUuS0-0003oB-EV; Thu, 17 May 2012 06:44:40 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SUuRy-0003nq-DM for kernel-team@lists.ubuntu.com; Thu, 17 May 2012 06:44:38 +0000 Received: from [210.242.151.101] (helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SUuRx-0004zX-Cd for kernel-team@lists.ubuntu.com; Thu, 17 May 2012 06:44:38 +0000 From: Ike Panhc To: kernel-team@lists.ubuntu.com Subject: [PATCH 04/18] input: add a key driver for highbank Date: Thu, 17 May 2012 14:44:33 +0800 Message-Id: <1337237073-3424-1-git-send-email-ike.pan@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1337236878-3255-1-git-send-email-ike.pan@canonical.com> References: <1337236878-3255-1-git-send-email-ike.pan@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Rob Herring Add a keyboard driver to handle power and sleep keys from the management controller. These are generated via ipc messages. Signed-off-by: Rob Herring Signed-off-by: Ike Panhc --- arch/arm/boot/dts/highbank.dts | 4 + drivers/input/keyboard/Kconfig | 11 +++ drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/highbank_keys.c | 141 ++++++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+) create mode 100644 drivers/input/keyboard/highbank_keys.c diff --git a/arch/arm/boot/dts/highbank.dts b/arch/arm/boot/dts/highbank.dts index 305635b..4d48f9b 100644 --- a/arch/arm/boot/dts/highbank.dts +++ b/arch/arm/boot/dts/highbank.dts @@ -125,6 +125,10 @@ interrupts = <0 7 4>; }; + ipc-keys { + compatible = "calxeda,hb-keys"; + }; + gpioe: gpio@fff30000 { #gpio-cells = <2>; compatible = "arm,pl061", "arm,primecell"; diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 615c21f..da62beb 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -203,6 +203,17 @@ config KEYBOARD_GPIO_POLLED To compile this driver as a module, choose M here: the module will be called gpio_keys_polled. +config KEYBOARD_HIGHBANK + tristate "Calxeda Highbank Virtual Keys" + depends on ARCH_HIGHBANK + default y + help + This driver implements support for virtual power keys on Calxeda + Highbank systems. + + To compile this driver as a module, choose M here: the + module will be called highbank_keys. + config KEYBOARD_TCA6416 tristate "TCA6416/TCA6408A Keypad Support" depends on I2C diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index ddde0fd..b565c05 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o obj-$(CONFIG_KEYBOARD_GPIO_POLLED) += gpio_keys_polled.o +obj-$(CONFIG_KEYBOARD_HIGHBANK) += highbank_keys.o obj-$(CONFIG_KEYBOARD_TCA6416) += tca6416-keypad.o obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o diff --git a/drivers/input/keyboard/highbank_keys.c b/drivers/input/keyboard/highbank_keys.c new file mode 100644 index 0000000..a84ecf3 --- /dev/null +++ b/drivers/input/keyboard/highbank_keys.c @@ -0,0 +1,141 @@ +/* + * Copyright 2011 Calxeda, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +struct hb_keys_drvdata { + struct input_dev *input; + struct notifier_block nb; +}; + +int hb_keys_notifier(struct notifier_block *nb, unsigned long event, void *data) +{ + struct hb_keys_drvdata *ddata = container_of(nb, struct hb_keys_drvdata, nb); + struct input_dev *input = ddata->input; + u32 *d = data; + u32 key = d[0]; + + if (event != 0x1000 /*HB_IPC_KEY*/) + return 0; + + input_event(input, EV_KEY, key, 1); + input_event(input, EV_KEY, key, 0); + input_sync(input); + return 0; +} + +static int hb_keys_open(struct input_dev *input) +{ + struct hb_keys_drvdata *ddata = input_get_drvdata(input); + return pl320_ipc_register_notifier(&ddata->nb); +} + +static void hb_keys_close(struct input_dev *input) +{ + struct hb_keys_drvdata *ddata = input_get_drvdata(input); + pl320_ipc_unregister_notifier(&ddata->nb); +} + +static int __devinit hb_keys_probe(struct platform_device *pdev) +{ + struct hb_keys_drvdata *ddata; + struct device *dev = &pdev->dev; + struct input_dev *input; + int error; + + ddata = kzalloc(sizeof(*ddata), GFP_KERNEL); + if (!ddata) + return -ENOMEM; + + input = input_allocate_device(); + if (!input) { + dev_err(dev, "failed to allocate state\n"); + error = -ENOMEM; + goto fail1; + } + + platform_set_drvdata(pdev, ddata); + input_set_drvdata(input, ddata); + + ddata->input = input; + ddata->nb.notifier_call = hb_keys_notifier; + + input->name = pdev->name; + input->phys = "highbank/input0"; + input->dev.parent = &pdev->dev; + input->open = hb_keys_open; + input->close = hb_keys_close; + + input->id.bustype = BUS_HOST; + input->id.vendor = 0x0001; + input->id.product = 0x0001; + input->id.version = 0x0100; + + input_set_capability(input, EV_KEY, KEY_POWER); + input_set_capability(input, EV_KEY, KEY_SLEEP); + + error = input_register_device(input); + if (error) { + dev_err(dev, "Unable to register input device, error: %d\n", + error); + goto fail2; + } + + return 0; + + fail2: + input_free_device(input); + fail1: + kfree(ddata); + return error; +} + +static int __devexit hb_keys_remove(struct platform_device *pdev) +{ + struct hb_keys_drvdata *ddata = platform_get_drvdata(pdev); + input_unregister_device(ddata->input); + kfree(ddata); + return 0; +} + +static struct of_device_id hb_keys_of_match[] = { + { .compatible = "calxeda,hb-keys", }, + { }, +}; +MODULE_DEVICE_TABLE(of, hb_keys_of_match); + +static struct platform_driver hb_keys_driver = { + .probe = hb_keys_probe, + .remove = __devexit_p(hb_keys_remove), + .driver = { + .name = "hb-keys", + .of_match_table = hb_keys_of_match, + } +}; + +module_platform_driver(hb_keys_driver); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Calxeda, Inc."); +MODULE_DESCRIPTION("Keys driver for Calxeda Highbank");