From patchwork Fri Oct 13 09:27:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 825346 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=axentiatech.onmicrosoft.com header.i=@axentiatech.onmicrosoft.com header.b="v94Br2ii"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yD2Rx3rsRz9sRm for ; Fri, 13 Oct 2017 20:27:25 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754188AbdJMJ1Y (ORCPT ); Fri, 13 Oct 2017 05:27:24 -0400 Received: from mail-he1eur01on0139.outbound.protection.outlook.com ([104.47.0.139]:64377 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751585AbdJMJ1V (ORCPT ); Fri, 13 Oct 2017 05:27:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentiatech.onmicrosoft.com; s=selector1-axentia-se; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=KRE+SZfbmkaiWxVgTY2sScGMfBllB4Wo2gEyXBegO7w=; b=v94Br2iiPNvONA3AUMmQVTJXKsl64fIkdIp3oxABuu5DTX/o+WFvP8wnrcivdWLmM7P/Tqs8DhYZPJ2gfkC849jRldl24tfQsKb2oehY1ptsJqyp3d2gQQV63omosjgeOix1wXvK7T1nrW1q/8QzYG3c2dmyRcSWHwAZFopyiPc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; Received: from orc.pedanet (213.112.203.125) by HE1PR0202MB2553.eurprd02.prod.outlook.com (2603:10a6:3:8f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Fri, 13 Oct 2017 09:27:17 +0000 From: Peter Rosin To: linux-kernel@vger.kernel.org Cc: Peter Rosin , Rob Herring , Mark Rutland , Nicolas Ferre , Alexandre Belloni , Russell King , Guenter Roeck , Jean Delvare , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hwmon@vger.kernel.org Subject: [PATCH 1/2] hwmon: (jc42) optionally try to disable the SMBUS timeout Date: Fri, 13 Oct 2017 11:27:04 +0200 Message-Id: <20171013092705.7038-2-peda@axentia.se> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171013092705.7038-1-peda@axentia.se> References: <20171013092705.7038-1-peda@axentia.se> MIME-Version: 1.0 X-Originating-IP: [213.112.203.125] X-ClientProxiedBy: HE1PR05CA0156.eurprd05.prod.outlook.com (2603:10a6:7:28::43) To HE1PR0202MB2553.eurprd02.prod.outlook.com (2603:10a6:3:8f::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c6d92498-0c82-423d-5ae2-08d5121c9931 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017082002075)(2017052603199)(201703131423075)(201702281549075); SRVR:HE1PR0202MB2553; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0202MB2553; 3:0qDGP7Gw/0es/cgnSYjkEiGW1CQiPD1VpVlkHwrhFkH7SOi+FqqNHx9s5DFhs876938/41fBpC5Hj5pr/+gWAgKfAZrwtN1887GU0GKMHcVRFJcjfdjpR1UPRBqQ2JOrDc/N0aCFP62q2+7kwzjnXmX5t/Sp5OS5XSwr5DVjyx+9hKOZJJr1z0wJa6C01wGDe6A4jL3vsVI+x3rfl23QBrfH4IoV2/uGKjtLjkHc4GykSruSOL5OY6xl1vfoTwem; 25:JcBb7ESaeoH/JQzFteDjg0xQbXuBMWR+ICHQGGtNjDopWvIxFX6/iW1MptR2dPiYIqU8aPqU/UiPQRPrX8Gx5JrrE8BvStr3QWiGeDGq3y92ol9U4aN9nV3+wxdZDlFYbCJSpp1OZYJjFrPx0HnEUxVJEbKHEvWQhEOirBflgivV83u+VlXDqkRtg0omzWTdd3ctUanecyp7SDsttMBZSG1+vxFj7d0xwCBKRGaKvVO/kEeSMnmn7xRoileXUtt+eBi6LG5rEfzFgeZ5pNE/aGqL+xUmUvfRuDgy8MS70YdQi7zfStgDJmzQE+TvdclKOyJf+XCuEIAR+c0kq2Qsug==; 31:OWKwUFWIymOq3IX0y/96MDTMApqyuFyq/IHmUf7Fuxy01okTsdtxzD2nXktXbZM9xk04ZDRLbFKOIzUalrh5ezxN2G2MiYfyFHvrseybhojXYMu/6Q6/EHUrIYwD4dORe1stYSmGWwL3ZCXmaCZb4864KT+QGfbXO//HqoUU+aBu9k0iqzWZjN+nYaoiZZZCk+A71QQTih4rbniBjQsym9AWXdGekZcK1lAiV2x6WcU= X-MS-TrafficTypeDiagnostic: HE1PR0202MB2553: X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(3002001)(10201501046)(6041248)(20161123560025)(2016111802025)(20161123558100)(20161123564025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6043046)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:HE1PR0202MB2553; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:HE1PR0202MB2553; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0202MB2553; 4:6uNUNfQq5X17vXwz7zwcvHD+G6cdm7c9gzKQLl9lHPwgRnSZ2B0ne8DMI1xoe7vzo92MvadIsawaGpI52DoDGgKsE9SZYSfA0jym4krAN9i+7UNTQIpLTVOnn1HsAGvQeNX0m0HEAk3JPrf7P6SCqFPcFTiKCP5t41UXGQPkv2qrhWgoIj6o6w+p25/pF7f4ETZa08QeA6zeE0nXqnIF7lAwNBIY3E8lHgy3G30S4/OlzlP+bdXNyEnZfQZsJcL2 X-Forefront-PRVS: 04599F3534 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(39830400002)(346002)(376002)(199003)(189002)(97736004)(66066001)(25786009)(47776003)(36756003)(101416001)(68736007)(305945005)(189998001)(7736002)(76176999)(50986999)(2906002)(5003940100001)(48376002)(50466002)(53936002)(6916009)(4326008)(7416002)(5660300001)(1076002)(3846002)(8936002)(6116002)(2950100002)(16586007)(316002)(16526018)(2361001)(6506006)(106356001)(2351001)(54906003)(105586002)(6666003)(6512007)(478600001)(86362001)(50226002)(575784001)(33646002)(6486002)(81166006)(74482002)(81156014)(8676002)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0202MB2553; H:orc.pedanet; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0202MB2553; 23:vHbMEvgj5ikWt0FIMZphn76nSZ3AAe1wDJat0Zy?= VhrMBTwJMI3IVz1jidyZ63YZuJLNnVr2AAN+1/luOMSDHp0CGXN3RhHmMdAX2L+ICEdp8DG5g3zYiacNSEoW+HK5bvXJl7xfUryCyZdp3i8AFPx1S4OhWGstVIgKCs3kE3oECsV1/sNq82N+m0kca3wep0Pnb05+KrkKORl4QJVrC455aV6MCUK/CQV8HG9/AMKl8tQq9l1G/KyPxMHfysrS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qr74LI2/g+/8Z35bQyphRXNN/UxiKRnGzBLUF8eFwQRDt/VrWkieWYdti53ezmZ13NK7u+lEAg9LUX6H8n39zSUlmK4UTJGUhFhE0zoPMDYBBnqeoJw4+/hTTph2JUBCSBkIHNRrRrzo6+gGJikCgLh04jxFmnHo3VTGVkdr4BqIrJ34EEziA4J+TeM15A1/4AqLMORcqq9PdC/7Nkz+G/9Mu1bZS1MNhk65TC233LgUGfM2lgGXEYee0BB5wH/3hbDYUnvGMEcpp2MtqZ5dBOZVdqwmBcJ9Y3gVzxrQ+TZEL37pyWyGwg==; 5:9r9mpCvjcAe/uwj2lX4L+2cfEOiqIooD+okFP8wP0IapMJsNuU6OutSjsWcCnKDrkEJ/vG/x5PenxAF0zU4gNR6KJlU9cDH5m3OIFWLJz5dtHXijOSnt74+W/2W9TeKViWA8hN2tsFHfufXgGAdFGw==; 24:qFYus9nNbRkRtjktD4llNSTDiP8wRkBu3AJjW8hAGjH9EYdnb/VTi7OWgf/M1x9PSNT94EoZafEMX7rP+DlsaAtXMFzcXK49nBO/b24owDo=; 7:cca5JAJGJrbp1OLXV4fJAuaIjYkSXsyyuKYxc9BQy1McbAX4k7w+d5XHTLbW5PSUM1gOBDbJazrZvHHvCk6LjhdjuoyL/47zzIZBGpaXZf9MozfkR7IJ5X1ERXGjpKPSvxMG+DR/IU2BN3r6jbcNfhbMzhZQWNb84j7UTICPCAvY7pO0LS3gPGvmgwVGAqZu91tNpeNOkXrJJ5/nIrZ+mr3A5SZ9FCFDLhjiGBAeJu8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2017 09:27:17.4919 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0202MB2553 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org With a nxp,se97 chip on an atmel sama5d31 board, the I2C adapter driver is not always capable of avoiding the 25-35 ms timeout as specified by the SMBUS protocol. This may cause silent corruption of the last bit of any transfer, e.g. a one is read instead of a zero if the sensor chip times out. This also affects the eeprom half of the nxp-se97 chip, where this silent corruption was originally noticed. Other I2C adapters probably suffer similar issues, e.g. bit-banging comes to mind as risky... The SMBUS register in the nxp chip is not a standard Jedec register, but it is not special to the nxp chips either, at least the atmel chips have the same mechanism. Therefore, do not special case this on the manufacturer, it is opt-in via the device property anyway. Signed-off-by: Peter Rosin --- Documentation/devicetree/bindings/hwmon/jc42.txt | 4 ++++ drivers/hwmon/jc42.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/jc42.txt b/Documentation/devicetree/bindings/hwmon/jc42.txt index 07a250498fbb..f569db58f64a 100644 --- a/Documentation/devicetree/bindings/hwmon/jc42.txt +++ b/Documentation/devicetree/bindings/hwmon/jc42.txt @@ -34,6 +34,10 @@ Required properties: - reg: I2C address +Optional properties: +- smbus-timeout-disable: When set, the smbus timeout function will be disabled. + This is not supported on all chips. + Example: temp-sensor@1a { diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c index 1bf22eff0b08..fd816902fa30 100644 --- a/drivers/hwmon/jc42.c +++ b/drivers/hwmon/jc42.c @@ -45,6 +45,7 @@ static const unsigned short normal_i2c[] = { #define JC42_REG_TEMP 0x05 #define JC42_REG_MANID 0x06 #define JC42_REG_DEVICEID 0x07 +#define JC42_REG_SMBUS 0x22 /* NXP and Atmel, possibly others? */ /* Status bits in temperature register */ #define JC42_ALARM_CRIT_BIT 15 @@ -73,6 +74,9 @@ static const unsigned short normal_i2c[] = { #define ONS_MANID 0x1b09 /* ON Semiconductor */ #define STM_MANID 0x104a /* ST Microelectronics */ +/* SMBUS register */ +#define SMBUS_STMOUT BIT(7) /* SMBus time-out, active low */ + /* Supported chips */ /* Analog Devices */ @@ -476,6 +480,22 @@ static int jc42_probe(struct i2c_client *client, const struct i2c_device_id *id) data->extended = !!(cap & JC42_CAP_RANGE); + if (device_property_read_bool(dev, "smbus-timeout-disable")) { + int smbus; + + /* + * Not all chips support this register, but from a + * quick read of various datasheets no chip appears + * incompatible with the below attempt to disable + * the timeout. And the whole thing is opt-in... + */ + smbus = i2c_smbus_read_word_swapped(client, JC42_REG_SMBUS); + if (smbus < 0) + return smbus; + i2c_smbus_write_word_swapped(client, JC42_REG_SMBUS, + smbus | SMBUS_STMOUT); + } + config = i2c_smbus_read_word_swapped(client, JC42_REG_CONFIG); if (config < 0) return config;