From patchwork Wed Jul 23 08:20:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 34121 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f69.google.com (mail-oi0-f69.google.com [209.85.218.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D4FD72061E for ; Wed, 23 Jul 2014 08:20:34 +0000 (UTC) Received: by mail-oi0-f69.google.com with SMTP id h136sf3242105oig.0 for ; Wed, 23 Jul 2014 01:20:34 -0700 (PDT) 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=X6aLEYfyfZfXaRBmASTYIdJ0eCjU4f8hzHLQVOGI6Lw=; b=K/zBZysCo+hNd7BxuwgDj2TIwRw+2QmVAz2HpHS4ocq13tx30Sva8fgK1OShNgXDdd B239Zw5SUn88LWH5UnOAiGoOtWS8XtXoaWEVrhnvG4kW6FRMeTezjhYaFBNfSSLKtCfK kBOCr/YD9q/l8lDflz6/9W+516L3aBZyY2qXAWvES5qcO6bR3mRRD87pedoBwKU+cT8j Di1fJVYmsTq7+EU4o9L6AdjsfoDnPSs24hCfy5cP2VPtBv/cX/L7ldQR33N5CWPoqvsA wS4puhf0g6Wl4F0+Y+2zmaAZ7XWHdPcIVLtVNPd3w7yigZfSabGzvYGus4W3knA9EE0e y8JA== X-Gm-Message-State: ALoCoQmabQ4tLLAGtIxIj1z8J06MxwrkOjOpi7eazIkVLgCn7fB6KWbfRjoUemeRw9NymTSIJdGA X-Received: by 10.182.45.161 with SMTP id o1mr19080798obm.2.1406103633248; Wed, 23 Jul 2014 01:20:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.116 with SMTP id u107ls224250qgd.46.gmail; Wed, 23 Jul 2014 01:20:33 -0700 (PDT) X-Received: by 10.220.95.132 with SMTP id d4mr47773932vcn.33.1406103633011; Wed, 23 Jul 2014 01:20:33 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id gv1si1285484vdb.27.2014.07.23.01.20.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jul 2014 01:20:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hy4so1532555vcb.27 for ; Wed, 23 Jul 2014 01:20:32 -0700 (PDT) X-Received: by 10.52.120.38 with SMTP id kz6mr1514546vdb.86.1406103632811; Wed, 23 Jul 2014 01:20:32 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp260054vcb; Wed, 23 Jul 2014 01:20:32 -0700 (PDT) X-Received: by 10.70.36.98 with SMTP id p2mr8549683pdj.14.1406103631966; Wed, 23 Jul 2014 01:20:31 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xn6si1694431pbc.85.2014.07.23.01.20.31 for ; Wed, 23 Jul 2014 01:20:31 -0700 (PDT) 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 S1757020AbaGWIU2 (ORCPT ); Wed, 23 Jul 2014 04:20:28 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:49601 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757390AbaGWIUX (ORCPT ); Wed, 23 Jul 2014 04:20:23 -0400 Received: by mail-wg0-f44.google.com with SMTP id m15so774200wgh.27 for ; Wed, 23 Jul 2014 01:20:20 -0700 (PDT) X-Received: by 10.180.19.35 with SMTP id b3mr871192wie.52.1406103619893; Wed, 23 Jul 2014 01:20:19 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id n2sm4128081wjf.40.2014.07.23.01.20.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jul 2014 01:20:18 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: Dmitry Artamonow , Alessandro GARDICH , Linus Walleij Subject: [PATCH v2] input: driver for touchscreen on iPaq h3xxx Date: Wed, 23 Jul 2014 10:20:14 +0200 Message-Id: <1406103614-12438-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.220.182 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 driver for the touchscreen connected to the Atmel microcontroller on the iPAQ h3xxx series. Based on a driver from handhelds.org 2.6.21 kernel, written by Alessandro GARDICH, with the bulk of the code for the new input architecture rewritten by Dmitry Atamonow, and the final polish by Linus Walleij. Signed-off-by: Alessandro GARDICH Signed-off-by: Dmitry Artamonow Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - More verbose Kconfig selection text including module info. - Use be16_to_cpup() to deserialize protocol. - Cut fake pressure event reporting. - Report button events properly. - Use devm_input_allocate_device() to allocate input device. - Use input_set_capability() to set up capabilities. --- drivers/input/touchscreen/Kconfig | 12 +++ drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/ipaq-micro-ts.c | 141 ++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 drivers/input/touchscreen/ipaq-micro-ts.c diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index a23a94bb4bcb..6bb9a7dd23b6 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -471,6 +471,18 @@ config TOUCHSCREEN_HP7XX To compile this driver as a module, choose M here: the module will be called jornada720_ts. +config TOUCHSCREEN_IPAQ_MICRO + tristate "HP iPAQ Atmel Micro ASIC touchscreen" + depends on MFD_IPAQ_MICRO + help + Say Y here to enable support for the touchscreen attached to + the Atmel Micro peripheral controller on iPAQ h3100/h3600/h3700 + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called ipaq-micro-ts. + config TOUCHSCREEN_HTCPEN tristate "HTC Shift X9500 touchscreen" depends on ISA diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 126479d8c29a..4be94fce41af 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -46,6 +46,7 @@ obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o obj-$(CONFIG_TOUCHSCREEN_HP7XX) += jornada720_ts.o +obj-$(CONFIG_TOUCHSCREEN_IPAQ_MICRO) += ipaq-micro-ts.o obj-$(CONFIG_TOUCHSCREEN_HTCPEN) += htcpen.o obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o diff --git a/drivers/input/touchscreen/ipaq-micro-ts.c b/drivers/input/touchscreen/ipaq-micro-ts.c new file mode 100644 index 000000000000..d044b06b1bfb --- /dev/null +++ b/drivers/input/touchscreen/ipaq-micro-ts.c @@ -0,0 +1,141 @@ +/* + * 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, touchscreen subdevice + * Author : Alessandro Gardich + * Author : Dmitry Artamonow + * Author : Linus Walleij + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct touchscreen_data { + struct input_dev *input; + struct ipaq_micro *micro; +}; + +static void micro_ts_receive(void *data, int len, unsigned char *msg) +{ + struct touchscreen_data *ts = data; + + if (len == 4) { + input_report_abs(ts->input, ABS_X, + be16_to_cpup((__be16 *) &msg[2])); + input_report_abs(ts->input, ABS_Y, + be16_to_cpup((__be16 *) &msg[0])); + input_report_key(ts->input, BTN_TOUCH, 1); + } + if (len == 0) { + input_report_abs(ts->input, ABS_X, 0); + input_report_abs(ts->input, ABS_Y, 0); + input_report_key(ts->input, BTN_TOUCH, 0); + } + input_sync(ts->input); +} + + +static int micro_ts_probe(struct platform_device *pdev) +{ + struct touchscreen_data *ts; + int ret; + + ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL); + if (!ts) + return -ENOMEM; + ts->micro = dev_get_drvdata(pdev->dev.parent); + + platform_set_drvdata(pdev, ts); + + ts->input = devm_input_allocate_device(&pdev->dev); + if (!ts->input) { + dev_err(&pdev->dev, "failed to allocate input device\n"); + return -ENOMEM; + } + + input_set_capability(ts->input, EV_KEY, BTN_TOUCH); + input_set_capability(ts->input, EV_ABS, ABS_X); + input_set_capability(ts->input, EV_ABS, ABS_Y); + input_set_abs_params(ts->input, ABS_X, 0, 1023, 0, 0); + input_set_abs_params(ts->input, ABS_Y, 0, 1023, 0, 0); + + ts->input->name = "ipaq micro ts"; + + ret = input_register_device(ts->input); + if (ret) { + dev_err(&pdev->dev, "error registering touch input\n"); + return ret; + } + + spin_lock(&ts->micro->lock); + ts->micro->ts = micro_ts_receive; + ts->micro->ts_data = ts; + spin_unlock(&ts->micro->lock); + + dev_info(&pdev->dev, "iPAQ micro touchscreen\n"); + return 0; +} + +static int micro_ts_remove(struct platform_device *pdev) +{ + struct touchscreen_data *ts = platform_get_drvdata(pdev); + + spin_lock(&ts->micro->lock); + ts->micro->ts = NULL; + ts->micro->ts_data = NULL; + spin_unlock(&ts->micro->lock); + + return 0; +} + +static int micro_ts_suspend(struct device *dev) +{ + struct touchscreen_data *ts = dev_get_drvdata(dev); + + spin_lock(&ts->micro->lock); + ts->micro->ts = NULL; + ts->micro->ts_data = NULL; + spin_unlock(&ts->micro->lock); + return 0; +} + +static int micro_ts_resume(struct device *dev) +{ + struct touchscreen_data *ts = dev_get_drvdata(dev); + + spin_lock(&ts->micro->lock); + ts->micro->ts = micro_ts_receive; + ts->micro->ts_data = ts; + spin_unlock(&ts->micro->lock); + return 0; +} + +static const struct dev_pm_ops micro_ts_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(micro_ts_suspend, micro_ts_resume) +}; + +struct platform_driver micro_ts_device_driver = { + .driver = { + .name = "ipaq-micro-ts", + .pm = µ_ts_dev_pm_ops, + }, + .probe = micro_ts_probe, + .remove = micro_ts_remove, +}; +module_platform_driver(micro_ts_device_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("driver for iPAQ Atmel micro touchscreen"); +MODULE_ALIAS("platform:ipaq-micro-ts");