From patchwork Mon Nov 28 08:42:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 9449195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 29FC06071E for ; Mon, 28 Nov 2016 08:52:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2118320007 for ; Mon, 28 Nov 2016 08:52:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1445E2094F; Mon, 28 Nov 2016 08:52:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DE9120007 for ; Mon, 28 Nov 2016 08:52:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754345AbcK1Iwo (ORCPT ); Mon, 28 Nov 2016 03:52:44 -0500 Received: from mail-he1eur01on0086.outbound.protection.outlook.com ([104.47.0.86]:21120 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754227AbcK1Iwj (ORCPT ); Mon, 28 Nov 2016 03:52:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Utcw+Q9zkeNQj1jScFJW8rKo9K4MQY7RejTlqmzJ1AI=; b=M9qDHcVLnxS6SeRXWshMaDVl7lcjoaCwitzMGatMSCLL/A49yy8roAf8aVTvi/w9se57K/WI2VOkariXPlARDhizKb6R4Oo3jtwlxM37V78UwMXdRKLIsCkdvXGFaEd+1o8kwY/SY5m0miBpOehuByttiNMn7NZqoDndLjFyKh0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=haibo.chen@nxp.com; Received: from b51421-server.ap.freescale.net (192.158.241.86) by VI1PR0401MB2336.eurprd04.prod.outlook.com (10.169.133.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13; Mon, 28 Nov 2016 08:37:15 +0000 From: Haibo Chen To: , CC: , , Subject: [PATCH] input: touchscreen: imx6ul_tsc: add mask when set REG_ADC_CFG Date: Mon, 28 Nov 2016 16:42:23 +0800 Message-ID: <1480322543-8518-1-git-send-email-haibo.chen@nxp.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [192.158.241.86] X-ClientProxiedBy: KL1PR03CA0023.apcprd03.prod.outlook.com (10.165.63.33) To VI1PR0401MB2336.eurprd04.prod.outlook.com (10.169.133.151) X-MS-Office365-Filtering-Correlation-Id: 22365c06-07ae-48e9-7f48-08d41769c36f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:VI1PR0401MB2336; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2336; 3:pAHjTfhr5dJxEr8FjZzlVZnqlvPMAukLujKbhOVSIPs1qhrb3mOiKXDFm9NpsL1nA/F4PbUjq3K5apCO6hTjCGE0DEKMid4UBig2R/rZFrb4SzzYfYnjPMS4A11s8TNbbn14b/7gZeeCs1xkBmAapgAMkIfqW/Zt5OE8lFcleghFTrGoFwOO7Mlchv7gDztutmf/IKMb6sjxam4kb1Um7o5eu/Qdt0BFOBel3gJIxoRtLcYL98jJAWes3ElDvRjAqmzjz8nraT+W1zMQu+GroA== X-Microsoft-Exchange-Diag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HStrhEQalT1t1+nc5z4+GDwITLUHOBvKzGE3ckSmJLcdiYOansQE4q/EU=; 20:dDTVBmgdOPoBDXPI5szSad4+vGKf1qx4QYytUwvjERAiwJcGmkZNWpSSsxruY43QiNrDgcMRNgzD977jLDGRLoI4TdjXQGekL/W4hWsgW0+Pc5V4PdeZvtxh/4983NjKTPjs2x7jX4ecoFrUhEubCy9gUKg7cszosvR8nTEfqeVcVS95POqdCQ2qf1G59RvIztCUSuhGw3DzP585L1vHjbLfVyCmmmdEJtOAbC7t7F3jnx6ZfsfU5R5YE0SBh6948HJiudOxfR9X2BNvE3JZDQXdo4F1OmHBdabCGHFykks3Cwn9ddZkDSECyG+mKhWg9RII2SC8vmnLESJ+7a8QSuGX71UIpZN03OSVQKUyEoNCK+T3fuNy6hh7WXTz/X2hc3HoWA64XL0HEKX6UWfLGbPxXjztFNdwFjNI9BBTI0H5L6bknVaWAKHtHw/cEwmY1TmMp9lvFGEd/pJb0QA1HHeGcOYBXKIaQt91PKIxZyBJNNxDKaPuJNDZnHjlWaRG X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6060326)(6040361)(6045199)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6046074)(6041248)(6061324)(20161123560025)(20161123555025)(20161123564025)(20161123562025); SRVR:VI1PR0401MB2336; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0401MB2336; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2336; 4:Km+nI/SMDCdnIn/TLb8xOAZyddEcoN2BvE/fjQplPCjpwkGJRLA48ZUGc5F4nH9hcNLTd+ClhmECpqY9q318G0HDnZmMjP+Y7RzRRHEtFt1JoIirfzuW62vK8Tm9XKX2fm0fnAnQfVt5Oc8ZLLvtXXQXKT/9gtXg38wfiXVr1fqVRG2v8lSs8hHzeWT2dT8cJ+kzs1QD2JJCQBIU1KOu06UVTZ4R3WmCFNZt8QzGVbRG8tCqCvtocZiDlv2wPymEZvrsHVUVyUP/O/IZWyceJ1cjJt9vZbWkD3uV4ofxM70Av22UlGM9crC7WGod0Bxg1XE5wjsyMNrcJhMCx/ohl/YiLmyuI4/n+AOLgZkL6ZDZq3hR3D+38GpE6+tAvSwenjPkphDH62HD59cd8OAy05aDE3UpajFya0xCiNEaU63Znyk1zTpEECMc2x+wqt+GuQdpslGs1OIMVOLm5FbEaCeuAL1sqN2+Kz0a7vj/5glNKNliukEUCrueO8XI3HwqSuZwVW32YLLISuMuV4uy1eeYGmjYsrlGLX0tmO7zWDWdJAMdnPozT56tTku87dQv8FroW+cTOzmHol7+xBKKHzAMgA3BWhXuGyYfZiS0l9xLQRQkSmRntgF1QYEJhO7rL3R1HRWR+A3XT9HHbGbarAfSo0jV8slwCzKVFhSwuwGhQisSHTAckeiM7p5QNlyo X-Forefront-PRVS: 01401330D1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(33646002)(48376002)(5660300001)(97736004)(6486002)(7736002)(7846002)(305945005)(733004)(6116002)(50466002)(42186005)(2906002)(5001770100001)(4326007)(3846002)(6666003)(106356001)(105586002)(92566002)(189998001)(66066001)(86362001)(47776003)(8676002)(101416001)(68736007)(36756003)(5003940100001)(38730400001)(39060400001)(81156014)(81166006)(39410400001)(39450400002)(39400400001)(39380400001)(50986999)(50226002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB2336; H:b51421-server.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0401MB2336; 23:d5n1OwXn/tLP3TdsoJYi2jhXSUVw9Fjtc6l3fNg?= =?us-ascii?Q?NoZNz8wsaREXAZCjpGbNIJ+ZRvkwOpwU/VLECEy2xWlvAArtFDwD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SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2336; 7:Y9X5ZGOebrK5GGhnXqEX0a9MEcUllP9oaEfQXBsY/5S3v3lvZZ3lbHxWWu/Y4/ArU9xHkwBI/0Etpirg3K9d7ti06XsT+QKZ0LKqkUzchvhjXze3Vlpg8MiLzF/0SNkN0VYVpbnmCxdCXBkwHF853ZkvDvWDkT02E/57DNgYXWzVUSDUjdl37+g+rQI+FMJt9ZqnHTrKZmlwTA93ONdV+aHRyt/J5CnMEn/K+gHN6co+4xHpU/c64GTHRd/TTBbR58YNuBa5B5/p9KsUL1E8EMB+E35cUjFkM8MqLVeNGJO3zM4d/EhWA0WJufVmtpfNg8VI6z1hmewHunHTE5XpdjYo+zR6qVWRPeKJJx8NPnulhkXGYy6yfBq7MMm9XG5wl+eY9DxLeoS0FJNUNewkB8asEFg9mPGSUI/fw48r1xhHEnolXpARAa3bDQADWZdAcwQJs4mZV15VT5FFDvTymw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2016 08:37:15.9490 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2336 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add mask of each function bits of REG_ADC_CFG, and clear these function bits first, otherwise use '|=' operation may get the wrong setting which depends on the original value of REG_ADC_CFG. Signed-off-by: Haibo Chen Reviewed-by: Guy Shapiro --- drivers/input/touchscreen/imx6ul_tsc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c index 31724d9..96358fb 100644 --- a/drivers/input/touchscreen/imx6ul_tsc.c +++ b/drivers/input/touchscreen/imx6ul_tsc.c @@ -29,11 +29,16 @@ #define ADC_CAL (0x1 << 7) #define ADC_CALF 0x2 #define ADC_12BIT_MODE (0x2 << 2) +#define ADC_CONV_MODE_MASK (0x3 << 2) #define ADC_IPG_CLK 0x00 +#define ADC_INPUT_CLK_MASK 0x3 #define ADC_CLK_DIV_8 (0x03 << 5) +#define ADC_CLK_DIV_MASK (0x3 << 5) #define ADC_SHORT_SAMPLE_MODE (0x0 << 4) +#define ADC_SAMPLE_MODE_MASK (0x1 << 4) #define ADC_HARDWARE_TRIGGER (0x1 << 13) #define ADC_AVGS_SHIFT 14 +#define ADC_AVGS_MASK (0x3 << 14) #define SELECT_CHANNEL_4 0x04 #define SELECT_CHANNEL_1 0x01 #define DISABLE_CONVERSION_INT (0x0 << 7) @@ -108,10 +113,14 @@ static int imx6ul_adc_init(struct imx6ul_tsc *tsc) reinit_completion(&tsc->completion); adc_cfg = readl(tsc->adc_regs + REG_ADC_CFG); + adc_cfg &= ~(ADC_CONV_MODE_MASK | ADC_INPUT_CLK_MASK); adc_cfg |= ADC_12BIT_MODE | ADC_IPG_CLK; + adc_cfg &= ~(ADC_CLK_DIV_MASK | ADC_SAMPLE_MODE_MASK); adc_cfg |= ADC_CLK_DIV_8 | ADC_SHORT_SAMPLE_MODE; - if (tsc->average_samples) + if (tsc->average_samples) { + adc_cfg &= ~ADC_AVGS_MASK; adc_cfg |= (tsc->average_samples - 1) << ADC_AVGS_SHIFT; + } adc_cfg &= ~ADC_HARDWARE_TRIGGER; writel(adc_cfg, tsc->adc_regs + REG_ADC_CFG);