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: 10003943 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 D540B602B3 for ; Fri, 13 Oct 2017 09:27:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C981728FA7 for ; Fri, 13 Oct 2017 09:27:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE45B28FB3; Fri, 13 Oct 2017 09:27: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=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B8BF28FA7 for ; Fri, 13 Oct 2017 09:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c8lTc0SbOmscL8ZAczVAnZHGliziYXwHYSzWByrTF7U=; b=sHPH4mlKQYIWw1 JTSSrq1D0GjPQccQJdw+yVsa7zNYWiaVHW351ykPxzRLhIVtCtb9M/QkAg5wWDDwH6O2ZMQZsPap6 PK3XPXWJ/fc3t50EwJ2RoAQKrfBMquEGrC37fA7v4d4m8+cyFMiPAnqtlknaZWQxV8rfdYAwXdhL9 QwQxALMtu5uyHVuM8/WSNGbITtVoRwKYXBXWwNerwwwoXqiZngoNN5cLo5GLrbr0pfpS7s+tvF2Us 01eAmg5bL7NY51qTH0W/8WhL2NLAA9u9xpYa59y0YsnzNgQzYoTZRQz5cSmy3A6ddw6OM9ncCv+QP K3C9fX51bmNT44j0XmkQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e2wFv-0001eD-Ut; Fri, 13 Oct 2017 09:27:47 +0000 Received: from mail-he1eur01on0137.outbound.protection.outlook.com ([104.47.0.137] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e2wFr-0001bU-Kt for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2017 09:27:46 +0000 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 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?= =?us-ascii?Q?VhrMBTwJMI3IVz1jidyZ63YZuJLNnVr2AAN+1/luOMSDHp0CGXN3RhHmMdAX?= =?us-ascii?Q?2L+ICEdp8DG5g3zYiacNSEoW+HK5bvXJl7xfUryCyZdp3i8AFPx1S4OhWGst?= =?us-ascii?Q?VIgKCs3kE3oECsV1/sNq82N+m0kca3wep0Pnb05+KrkKORl4QJVrC455aV6M?= =?us-ascii?Q?CUK/CQV8HG9/AMKl8tQq9l1G/KyPxMHfysrSJoKvNulCKLTqDR/guc+QC77m?= =?us-ascii?Q?LAnrpwOV6wZmfTETQgUqV68c5tDydkK+mOOWY2FmNsrIWw01ImjZI8tmTJFI?= =?us-ascii?Q?cacmKJC7pK91U7uyBWUm3iaTolaJzMfsIrVzFOfJcHEw97JaYe6+lW1+A/YC?= =?us-ascii?Q?njQIXPa8XAcC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R0202MB2553; 6:HLCbrQH+Tz0SkDEKYrwB/0N99C4uYk7Qqr74LI2/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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171013_022744_176266_FE6DBE5A X-CRM114-Status: GOOD ( 14.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Jean Delvare , Russell King , Rob Herring , Alexandre Belloni , linux-arm-kernel@lists.infradead.org, linux-hwmon@vger.kernel.org, Peter Rosin , Guenter Roeck Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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;