From patchwork Wed Feb 4 10:12:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 44328 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A9DF821513 for ; Wed, 4 Feb 2015 10:13:01 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id l4sf634336lbv.1 for ; Wed, 04 Feb 2015 02:13:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=RZKSPQyCLGtnMLh+uKGf9Y3qObiH3vQ50TuomiHO2cI=; b=i5pd8mtHnWa7hjFmZTy1j4pJG7fi944YjBKUqnETkkMjKm/d0tSjxIrpaVKjoRY/je Z0wy0GlTvKUhmHlSluuN2fIbKcxPJb4LSFfom9cL8UNQnWsGptEvddNhXZFspHae0dEg NOK9qoAN9CHnes5v4xNufadP7pEyOToj8osQTtEEFOjBDDxeFEe/5b19SLR8LTGj+pi1 speDtiy55jkAKlhOvZOf6FX15NMopnkCn6xkeeyaEOq3Yyh7jEdDWITQMTqA4WLS0UcR S5Ou6lCJJPmRqgljFbjlME0xY+gYhD8Q5yfJ2g9c5LbElLoHDkmXPEh69Rd1QHimzJx6 /FsA== X-Gm-Message-State: ALoCoQlr/qT1YgidIYAgZTkzbE2aJI2/c0WjjV9zLy50B25FB6YOxYDe8x4UL9h4B2bLbNswVnQa X-Received: by 10.152.121.65 with SMTP id li1mr3741250lab.0.1423044780361; Wed, 04 Feb 2015 02:13:00 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.73 with SMTP id c9ls12480lae.74.gmail; Wed, 04 Feb 2015 02:13:00 -0800 (PST) X-Received: by 10.112.243.12 with SMTP id wu12mr29911110lbc.91.1423044780068; Wed, 04 Feb 2015 02:13:00 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id 4si967154lal.36.2015.02.04.02.13.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Feb 2015 02:13:00 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id gm9so700402lab.0 for ; Wed, 04 Feb 2015 02:13:00 -0800 (PST) X-Received: by 10.152.20.4 with SMTP id j4mr12545266lae.29.1423044779910; Wed, 04 Feb 2015 02:12:59 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp391574lbj; Wed, 4 Feb 2015 02:12:58 -0800 (PST) X-Received: by 10.68.138.135 with SMTP id qq7mr1552124pbb.139.1423044778072; Wed, 04 Feb 2015 02:12:58 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id te3si1466765pab.230.2015.02.04.02.12.57 for ; Wed, 04 Feb 2015 02:12:58 -0800 (PST) Received-SPF: none (google.com: linux-input-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754809AbbBDKM4 (ORCPT ); Wed, 4 Feb 2015 05:12:56 -0500 Received: from mail-la0-f49.google.com ([209.85.215.49]:51437 "EHLO mail-la0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754614AbbBDKMy (ORCPT ); Wed, 4 Feb 2015 05:12:54 -0500 Received: by mail-la0-f49.google.com with SMTP id gf13so653388lab.8 for ; Wed, 04 Feb 2015 02:12:52 -0800 (PST) X-Received: by 10.153.4.5 with SMTP id ca5mr25897118lad.28.1423044772769; Wed, 04 Feb 2015 02:12:52 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id c6sm260533lag.26.2015.02.04.02.12.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Feb 2015 02:12:51 -0800 (PST) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: Dmitry Artamonow , Alessandro GARDICH , Linus Walleij Subject: [PATCH] input: driver for microcontroller keys on the iPaq h3xxx Date: Wed, 4 Feb 2015 11:12:44 +0100 Message-Id: <1423044764-11265-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 Sender: linux-input-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Dmitry Artamonow This adds a key input driver for the keys found on the h3xxx iPAQ series. Based on a driver from handhelds.org 2.6.21 kernel, written by Alessandro GARDICH. Signed-off-by: Alessandro GARDICH Signed-off-by: Dmitry Artamonow Signed-off-by: Linus Walleij --- Hi Dmitry (Torokhov), I have a vague memory of having sent this patch before but can't find it in my mail archives. So I'm guessing I never sent it properly :P --- drivers/input/keyboard/Kconfig | 7 ++ drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/ipaq-micro-keys.c | 148 +++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 drivers/input/keyboard/ipaq-micro-keys.c diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index a5d9b3f3c871..043b720b500d 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -578,6 +578,13 @@ config KEYBOARD_DAVINCI To compile this driver as a module, choose M here: the module will be called davinci_keyscan. +config KEYBOARD_IPAQ_MICRO + tristate "Buttons on Micro SoC (iPaq h3100,h3600,h3700)" + depends on MFD_IPAQ_MICRO + help + This enables support for the buttons attached to + Micro peripheral controller on iPAQ h3100/h3600/h3700 + config KEYBOARD_OMAP tristate "TI OMAP keypad support" depends on ARCH_OMAP1 diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index febafa527eb6..c59e73bdd260 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_KEYBOARD_TCA6416) += tca6416-keypad.o obj-$(CONFIG_KEYBOARD_TCA8418) += tca8418_keypad.o obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o +obj-$(CONFIG_KEYBOARD_IPAQ_MICRO) += ipaq-micro-keys.o obj-$(CONFIG_KEYBOARD_IMX) += imx_keypad.o obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o diff --git a/drivers/input/keyboard/ipaq-micro-keys.c b/drivers/input/keyboard/ipaq-micro-keys.c new file mode 100644 index 000000000000..7ca8b738cc73 --- /dev/null +++ b/drivers/input/keyboard/ipaq-micro-keys.c @@ -0,0 +1,148 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * h3600 atmel micro companion support, key subdevice + * based on previous kernel 2.4 version + * Author : Alessandro Gardich + * Author : Linus Walleij + * + */ + + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct ipaq_micro_keys { + struct ipaq_micro *micro; + struct input_dev *input; +}; + +static int keycodes[] = { + KEY_RECORD, /* 1: Record button */ + KEY_CALENDAR, /* 2: Calendar */ + KEY_ADDRESSBOOK, /* 3: Contacts (looks like Outlook) */ + KEY_MAIL, /* 4: Envelope (Q on older iPAQs) */ + KEY_HOMEPAGE, /* 5: Start (looks like swoopy arrow) */ + KEY_UP, /* 6: Up */ + KEY_RIGHT, /* 7: Right */ + KEY_LEFT, /* 8: Left */ + KEY_DOWN, /* 9: Down */ +}; + +static void micro_key_receive(void *data, int len, unsigned char *msg) +{ + struct ipaq_micro_keys *keys = data; + int key, down; + + down = (0x80 & msg[0]) ? 1 : 0; + key = 0x7f & msg[0]; + + if (key < ARRAY_SIZE(keycodes)) { + input_report_key(keys->input, keycodes[key], down); + input_sync(keys->input); + } +} + +static int micro_key_probe(struct platform_device *pdev) +{ + struct ipaq_micro_keys *keys; + int ret; + int i; + + keys = devm_kzalloc(&pdev->dev, sizeof(*keys), GFP_KERNEL); + if (!keys) + return -ENOMEM; + keys->input = input_allocate_device(); + if (!keys->input) + return -ENOMEM; + keys->micro = dev_get_drvdata(pdev->dev.parent); + keys->input->evbit[0] = BIT(EV_KEY); + set_bit(EV_KEY, keys->input->evbit); + for (i = 0; i < ARRAY_SIZE(keycodes); i++) + set_bit(keycodes[i], keys->input->keybit); + + keys->input->name = "h3600 micro keys"; + + ret = input_register_device(keys->input); + if (ret) + return ret; + + platform_set_drvdata(pdev, keys); + spin_lock(&keys->micro->lock); + keys->micro->key = micro_key_receive; + keys->micro->key_data = keys; + spin_unlock(&keys->micro->lock); + + return 0; +} + +static int micro_key_remove(struct platform_device *pdev) +{ + struct ipaq_micro_keys *keys = platform_get_drvdata(pdev); + + input_unregister_device(keys->input); + + spin_lock(&keys->micro->lock); + keys->micro->key = NULL; + keys->micro->key_data = NULL; + spin_unlock(&keys->micro->lock); + + return 0; +} + +static int micro_key_suspend(struct device *dev) +{ + struct ipaq_micro_keys *keys = dev_get_drvdata(dev); + + spin_lock(&keys->micro->lock); + keys->micro->key = NULL; + keys->micro->key_data = NULL; + spin_unlock(&keys->micro->lock); + + return 0; +} + +static int micro_key_resume(struct device *dev) +{ + struct ipaq_micro_keys *keys = dev_get_drvdata(dev); + + spin_lock(&keys->micro->lock); + keys->micro->key = micro_key_receive; + keys->micro->key_data = keys; + spin_unlock(&keys->micro->lock); + + return 0; +} + +static const struct dev_pm_ops micro_key_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(micro_key_suspend, micro_key_resume) +}; + +struct platform_driver micro_key_device_driver = { + .driver = { + .name = "ipaq-micro-keys", + .pm = µ_key_dev_pm_ops, + }, + .probe = micro_key_probe, + .remove = micro_key_remove, +}; +module_platform_driver(micro_key_device_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("driver for iPAQ Atmel micro keys"); +MODULE_ALIAS("platform:ipaq-micro-keys");