From patchwork Thu Mar 13 01:53:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Heiny X-Patchwork-Id: 3821521 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 09D7A9F369 for ; Thu, 13 Mar 2014 01:54:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BD27A201B6 for ; Thu, 13 Mar 2014 01:54:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 419D22017E for ; Thu, 13 Mar 2014 01:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752567AbaCMByI (ORCPT ); Wed, 12 Mar 2014 21:54:08 -0400 Received: from us-mx2.synaptics.com ([192.147.44.131]:54609 "EHLO us-mx2.synaptics.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752522AbaCMByH (ORCPT ); Wed, 12 Mar 2014 21:54:07 -0400 Received: from unknown (HELO securemail.synaptics.com) ([172.20.21.135]) by us-mx2.synaptics.com with ESMTP; 12 Mar 2014 18:54:03 -0700 Received: from USW-OWA1.synaptics-inc.local ([10.20.24.16]) by securemail.synaptics.com (PGP Universal service); Wed, 12 Mar 2014 18:39:48 -0700 X-PGP-Universal: processed; by securemail.synaptics.com on Wed, 12 Mar 2014 18:39:48 -0700 Received: from brontomerus.synaptics.com (10.3.20.103) by USW-OWA1.synaptics-inc.local (10.20.24.15) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 12 Mar 2014 18:54:01 -0700 From: Christopher Heiny To: Dmitry Torokhov CC: Linux Input , Christopher Heiny , Andrew Duggan , Vincent Huang , Vivian Ly , Daniel Rosenberg , Linus Walleij , Benjamin Tissoires , David Herrmann , Jiri Kosina Subject: [PATCH v2 01/06] input synaptics-rmi4: Split F01 definitions into header file Date: Wed, 12 Mar 2014 18:53:52 -0700 Message-ID: <1394675637-23853-1-git-send-email-cheiny@synaptics.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.3.20.103] 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=ham 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 Creates rmi_f01.h for use by the firmware update code. Signed-off-by: Christopher Heiny Cc: Dmitry Torokhov Cc: Benjamin Tissoires Cc: Linux Walleij Cc: David Herrmann Cc: Jiri Kosina --- drivers/input/rmi4/rmi_f01.c | 96 ++----------------------------------- drivers/input/rmi4/rmi_f01.h | 110 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 92 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c index ee5f4a1..41cb795 100644 --- a/drivers/input/rmi4/rmi_f01.c +++ b/drivers/input/rmi4/rmi_f01.c @@ -13,95 +13,7 @@ #include #include #include "rmi_driver.h" - -#define RMI_PRODUCT_ID_LENGTH 10 -#define RMI_PRODUCT_INFO_LENGTH 2 - -#define RMI_DATE_CODE_LENGTH 3 - -#define PRODUCT_ID_OFFSET 0x10 -#define PRODUCT_INFO_OFFSET 0x1E - - -/* Force a firmware reset of the sensor */ -#define RMI_F01_CMD_DEVICE_RESET 1 - -/* Various F01_RMI_QueryX bits */ - -#define RMI_F01_QRY1_CUSTOM_MAP (1 << 0) -#define RMI_F01_QRY1_NON_COMPLIANT (1 << 1) -#define RMI_F01_QRY1_HAS_LTS (1 << 2) -#define RMI_F01_QRY1_HAS_SENSOR_ID (1 << 3) -#define RMI_F01_QRY1_HAS_CHARGER_INP (1 << 4) -#define RMI_F01_QRY1_HAS_ADJ_DOZE (1 << 5) -#define RMI_F01_QRY1_HAS_ADJ_DOZE_HOFF (1 << 6) -#define RMI_F01_QRY1_HAS_PROPS_2 (1 << 7) - -#define RMI_F01_QRY5_YEAR_MASK 0x1f -#define RMI_F01_QRY6_MONTH_MASK 0x0f -#define RMI_F01_QRY7_DAY_MASK 0x1f - -#define RMI_F01_QRY2_PRODINFO_MASK 0x7f - -#define RMI_F01_BASIC_QUERY_LEN 21 /* From Query 00 through 20 */ - -struct f01_basic_properties { - u8 manufacturer_id; - bool has_lts; - bool has_adjustable_doze; - bool has_adjustable_doze_holdoff; - char dom[11]; /* YYYY/MM/DD + '\0' */ - u8 product_id[RMI_PRODUCT_ID_LENGTH + 1]; - u16 productinfo; -}; - -/* F01 device status bits */ - -/* Most recent device status event */ -#define RMI_F01_STATUS_CODE(status) ((status) & 0x0f) -/* The device has lost its configuration for some reason. */ -#define RMI_F01_STATUS_UNCONFIGURED(status) (!!((status) & 0x80)) - -/* Control register bits */ - -/* - * Sleep mode controls power management on the device and affects all - * functions of the device. - */ -#define RMI_F01_CTRL0_SLEEP_MODE_MASK 0x03 - -#define RMI_SLEEP_MODE_NORMAL 0x00 -#define RMI_SLEEP_MODE_SENSOR_SLEEP 0x01 -#define RMI_SLEEP_MODE_RESERVED0 0x02 -#define RMI_SLEEP_MODE_RESERVED1 0x03 - -#define RMI_IS_VALID_SLEEPMODE(mode) \ - (mode >= RMI_SLEEP_MODE_NORMAL && mode <= RMI_SLEEP_MODE_RESERVED1) - -/* - * This bit disables whatever sleep mode may be selected by the sleep_mode - * field and forces the device to run at full power without sleeping. - */ -#define RMI_F01_CRTL0_NOSLEEP_BIT (1 << 2) - -/* - * When this bit is set, the touch controller employs a noise-filtering - * algorithm designed for use with a connected battery charger. - */ -#define RMI_F01_CRTL0_CHARGER_BIT (1 << 5) - -/* - * Sets the report rate for the device. The effect of this setting is - * highly product dependent. Check the spec sheet for your particular - * touch sensor. - */ -#define RMI_F01_CRTL0_REPORTRATE_BIT (1 << 6) - -/* - * Written by the host as an indicator that the device has been - * successfully configured. - */ -#define RMI_F01_CRTL0_CONFIGURED_BIT (1 << 7) +#include "rmi_f01.h" /** * @ctrl0 - see the bit definitions above. @@ -136,8 +48,7 @@ struct f01_data { unsigned int num_of_irq_regs; }; -static int rmi_f01_read_properties(struct rmi_device *rmi_dev, - u16 query_base_addr, +int rmi_f01_read_properties(struct rmi_device *rmi_dev, u16 query_base_addr, struct f01_basic_properties *props) { u8 basic_query[RMI_F01_BASIC_QUERY_LEN]; @@ -180,7 +91,8 @@ static int rmi_f01_probe(struct rmi_function *fn) { struct rmi_device *rmi_dev = fn->rmi_dev; struct rmi_driver_data *driver_data = dev_get_drvdata(&rmi_dev->dev); - const struct rmi_device_platform_data *pdata = rmi_get_platform_data(rmi_dev); + const struct rmi_device_platform_data *pdata = + rmi_get_platform_data(rmi_dev); struct f01_data *f01; int error; u16 ctrl_base_addr = fn->fd.control_base_addr; diff --git a/drivers/input/rmi4/rmi_f01.h b/drivers/input/rmi4/rmi_f01.h new file mode 100644 index 0000000..9e5cc2b --- /dev/null +++ b/drivers/input/rmi4/rmi_f01.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Synaptics Incorporated + * + * 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. + */ + +#ifndef _RMI_F01_H +#define _RMI_F01_H + + +#define RMI_PRODUCT_ID_LENGTH 10 +#define RMI_PRODUCT_INFO_LENGTH 2 + +#define RMI_DATE_CODE_LENGTH 3 + +#define PRODUCT_ID_OFFSET 0x10 +#define PRODUCT_INFO_OFFSET 0x1E + + +/* Force a firmware reset of the sensor */ +#define RMI_F01_CMD_DEVICE_RESET 1 + +/* Various F01_RMI_QueryX bits */ + +#define RMI_F01_QRY1_CUSTOM_MAP (1 << 0) +#define RMI_F01_QRY1_NON_COMPLIANT (1 << 1) +#define RMI_F01_QRY1_HAS_LTS (1 << 2) +#define RMI_F01_QRY1_HAS_SENSOR_ID (1 << 3) +#define RMI_F01_QRY1_HAS_CHARGER_INP (1 << 4) +#define RMI_F01_QRY1_HAS_ADJ_DOZE (1 << 5) +#define RMI_F01_QRY1_HAS_ADJ_DOZE_HOFF (1 << 6) +#define RMI_F01_QRY1_HAS_PROPS_2 (1 << 7) + +#define RMI_F01_QRY5_YEAR_MASK 0x1f +#define RMI_F01_QRY6_MONTH_MASK 0x0f +#define RMI_F01_QRY7_DAY_MASK 0x1f + +#define RMI_F01_QRY2_PRODINFO_MASK 0x7f + +#define RMI_F01_BASIC_QUERY_LEN 21 /* From Query 00 through 20 */ + +struct f01_basic_properties { + u8 manufacturer_id; + bool has_lts; + bool has_adjustable_doze; + bool has_adjustable_doze_holdoff; + char dom[11]; /* YYYY/MM/DD + '\0' */ + u8 product_id[RMI_PRODUCT_ID_LENGTH + 1]; + u16 productinfo; +}; + +/* F01 device status bits */ + +/* Most recent device status event */ +#define RMI_F01_STATUS_CODE(status) ((status) & 0x0f) +/* The device has lost its configuration for some reason. */ +#define RMI_F01_STATUS_UNCONFIGURED(status) (!!((status) & 0x80)) + +/* Control register bits */ + +/* + * Sleep mode controls power management on the device and affects all + * functions of the device. + */ +#define RMI_F01_CTRL0_SLEEP_MODE_MASK 0x03 + +#define RMI_SLEEP_MODE_NORMAL 0x00 +#define RMI_SLEEP_MODE_SENSOR_SLEEP 0x01 +#define RMI_SLEEP_MODE_RESERVED0 0x02 +#define RMI_SLEEP_MODE_RESERVED1 0x03 + +#define RMI_IS_VALID_SLEEPMODE(mode) \ + (mode >= RMI_SLEEP_MODE_NORMAL && mode <= RMI_SLEEP_MODE_RESERVED1) + +/* + * This bit disables whatever sleep mode may be selected by the sleep_mode + * field and forces the device to run at full power without sleeping. + */ +#define RMI_F01_CRTL0_NOSLEEP_BIT (1 << 2) + +/* + * When this bit is set, the touch controller employs a noise-filtering + * algorithm designed for use with a connected battery charger. + */ +#define RMI_F01_CRTL0_CHARGER_BIT (1 << 5) + +/* + * Sets the report rate for the device. The effect of this setting is + * highly product dependent. Check the spec sheet for your particular + * touch sensor. + */ +#define RMI_F01_CRTL0_REPORTRATE_BIT (1 << 6) + +/* + * Written by the host as an indicator that the device has been + * successfully configured. + */ +#define RMI_F01_CRTL0_CONFIGURED_BIT (1 << 7) + +/** Read the F01 query registers and populate the basic_properties structure. + * @rmi_dev - the device to be queries. + * @query_base_addr - address of the start of the query registers. + * @props - pointer to the structure to be filled in. + */ +int rmi_f01_read_properties(struct rmi_device *rmi_dev, u16 query_base_addr, + struct f01_basic_properties *props); + +#endif