From patchwork Tue Sep 15 14:31:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot for Irina Tirdea X-Patchwork-Id: 7186141 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B11779F32B for ; Tue, 15 Sep 2015 14:36:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DD4B5203EB for ; Tue, 15 Sep 2015 14:36:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01BD0203E6 for ; Tue, 15 Sep 2015 14:36:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751833AbbIOOft (ORCPT ); Tue, 15 Sep 2015 10:35:49 -0400 Received: from mga01.intel.com ([192.55.52.88]:10630 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752444AbbIOOfV (ORCPT ); Tue, 15 Sep 2015 10:35:21 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 15 Sep 2015 07:35:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,536,1437462000"; d="scan'208";a="805620366" Received: from itirdea-desk.rb.intel.com ([10.237.104.230]) by fmsmga002.fm.intel.com with ESMTP; 15 Sep 2015 07:35:15 -0700 From: Irina Tirdea To: Dmitry Torokhov , Bastien Nocera , Aleksei Mamlin , linux-input@vger.kernel.org Cc: Mark Rutland , Octavian Purdila , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Irina Tirdea Subject: [PATCH v6 8/9] Input: goodix - add sysfs interface to dump config Date: Tue, 15 Sep 2015 17:31:22 +0300 Message-Id: <1442327483-19407-9-git-send-email-irina.tirdea@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442327483-19407-1-git-send-email-irina.tirdea@intel.com> References: <1442327483-19407-1-git-send-email-irina.tirdea@intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Goodix devices have a configuration information register area that specify various parameters for the device. The configuration information has a specific format described in the Goodix datasheet. It includes X/Y resolution, maximum supported touch points, interrupt flags, various sesitivity factors and settings for advanced features (like gesture recognition). Export a sysfs interface that would allow reading the configuration information. The default device configuration can be used as a starting point for creating a valid configuration firmware used by the device at init time to update its configuration. This sysfs interface will be exported only if the gpio pins are properly initialized from ACPI/DT. Signed-off-by: Irina Tirdea --- drivers/input/touchscreen/goodix.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index a5dd1bd..641a9e3 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -530,12 +530,35 @@ static ssize_t goodix_esd_timeout_store(struct device *dev, return count; } +static ssize_t goodix_dump_config_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct goodix_ts_data *ts = dev_get_drvdata(dev); + u8 config[GOODIX_CONFIG_MAX_LENGTH]; + int error, count = 0, i; + + error = goodix_i2c_read(ts->client, GOODIX_REG_CONFIG_DATA, + config, ts->cfg_len); + if (error) { + dev_warn(&ts->client->dev, + "Error reading config (%d)\n", error); + return error; + } + + for (i = 0; i < ts->cfg_len; i++) + count += scnprintf(buf + count, PAGE_SIZE - count, "%02x ", + config[i]); + return count; +} + /* ESD timeout in ms. Default disabled (0). Recommended 2000 ms. */ static DEVICE_ATTR(esd_timeout, S_IRUGO | S_IWUSR, goodix_esd_timeout_show, goodix_esd_timeout_store); +static DEVICE_ATTR(dump_config, S_IRUGO, goodix_dump_config_show, NULL); static struct attribute *goodix_attrs[] = { &dev_attr_esd_timeout.attr, + &dev_attr_dump_config.attr, NULL };