From patchwork Mon Jul 3 04:29:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom Levens X-Patchwork-Id: 9821929 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 2206160237 for ; Mon, 3 Jul 2017 04:29:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 123B42823D for ; Mon, 3 Jul 2017 04:29:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0664D283C5; Mon, 3 Jul 2017 04:29: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=unavailable 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 DAF782838F for ; Mon, 3 Jul 2017 04:29:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752455AbdGCE3b (ORCPT ); Mon, 3 Jul 2017 00:29:31 -0400 Received: from mail-eopbgr00073.outbound.protection.outlook.com ([40.107.0.73]:21312 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752327AbdGCE3S (ORCPT ); Mon, 3 Jul 2017 00:29:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cern.onmicrosoft.com; s=selector1-cern-ch; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7RH9aimSAd4h/exdt97+5qKsJt2yPbOBy+Y2Q+Ip+IU=; b=oyHhDBc4mHTTI7b1XZPzSLBKiQAh+3V1+r8lBCbj16bPbv+iEPIlHfFHWyQOEUlvM8YvJ756iWPhBf4K9PZmmYB+vI/Vt2IWDymQPdX97XbtfMMxQcQXF6muk0EdQFrUhuo2Ieo7jdD+HzaP0YEdIhFCV5JvNs1KeQ/cB5fSDm8= Received: from AM5PR0601CA0026.eurprd06.prod.outlook.com (2603:10a6:203:68::12) by DBXPR06MB462.eurprd06.prod.outlook.com (2a01:111:e400:9423::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1220.11; Mon, 3 Jul 2017 04:29:15 +0000 Received: from AM5EUR02FT050.eop-EUR02.prod.protection.outlook.com (2a01:111:f400:7e1e::200) by AM5PR0601CA0026.outlook.office365.com (2603:10a6:203:68::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1220.11 via Frontend Transport; Mon, 3 Jul 2017 04:29:14 +0000 Authentication-Results: spf=none (sender IP is 188.184.36.17) smtp.mailfrom=mail.cern.ch; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=cern.ch; Received-SPF: None (protection.outlook.com: mail.cern.ch does not designate permitted sender hosts) Received: from cernmx.cern.ch (188.184.36.17) by AM5EUR02FT050.mail.protection.outlook.com (10.152.9.252) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.1220.9 via Frontend Transport; Mon, 3 Jul 2017 04:29:11 +0000 Received: from pcbe13573-vm.dyndns.cern.ch (128.141.154.213) by cernmx.cern.ch (188.184.36.24) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 3 Jul 2017 06:29:02 +0200 Received: from pcbe13573-vm.dyndns.cern.ch (localhost [127.0.0.1]) by pcbe13573-vm.dyndns.cern.ch (8.14.7/8.14.7) with ESMTP id v634T1uk006110; Mon, 3 Jul 2017 06:29:01 +0200 Received: (from tlevens@localhost) by pcbe13573-vm.dyndns.cern.ch (8.14.7/8.14.7/Submit) id v634T1RE006109; Mon, 3 Jul 2017 06:29:01 +0200 From: Tom Levens To: Rob Herring , Mark Rutland , Jean Delvare , Guenter Roeck , "Mike Looijmans" CC: , , Subject: [PATCH v3 3/3] hwmon: ltc2990: support all measurement modes Date: Mon, 3 Jul 2017 06:29:00 +0200 Message-ID: <1499056140-6064-3-git-send-email-tom.levens@cern.ch> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1499056140-6064-1-git-send-email-tom.levens@cern.ch> References: <1499056140-6064-1-git-send-email-tom.levens@cern.ch> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:188.184.36.17; IPV:NLI; CTRY:CH; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(39850400002)(39400400002)(39860400002)(39410400002)(39450400003)(39840400002)(2980300002)(428002)(189002)(199003)(50986999)(76176999)(356003)(50226002)(87636003)(1720100001)(189998001)(2950100002)(42186005)(7636002)(305945005)(8676002)(4326008)(101416001)(23676002)(33646002)(966005)(5660300001)(626005)(105586002)(508600001)(2870700001)(106466001)(36756003)(6306002)(47776003)(74482002)(5820100001)(50466002)(54906002)(2906002)(38730400002)(8936002)(86362001)(575784001)(4720700003); DIR:OUT; SFP:1101; SCL:1; SRVR:DBXPR06MB462; H:cernmx.cern.ch; FPR:; SPF:None; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM5EUR02FT050; 1:6Z6lPjgInQhzurw+qvXvY2YRKyO5cvXILujcNqaxED+5yjc2Og8EGAL2gXNDAtAFLuDErfliXio8lmBSWFvuWDu6suYA3OLQH+Z9DBAgQl/kCa7MajJMrn/Zv0ZRfqz27hCIJgJDH0aWbum7BoavH7j7I4Yzo5KMJzw4EtuigS31uXirVtrpsXp1yXWclnhtE2MfowbLZxo91bnRw9ABZUm/4gK/NPq2k3uZkgmmIDqTrRqkj9xwm8eqF3ev3bxdoUIbBuCmWFx1tDnVJqClYwUlUUMShFJ6KYT+VWN7SNoXGVvNCW8XJsDG+7PufsbooK3APF7ELfHdtHBjhhPpo8VWda8xCAtDG25xosCNUpToQFqu4RWPTbm0LBEMIBUycWAY217zzWKbbl/GyO3aRpjQRvSwOFXZW+EuAFw815aE4UIsSOhyxLutChplxzQE2xsuu59wxgdJlua1l7iQC7FLORvcxgC4oJm9q7BEKtUPpbhR4hRhx8eX3EtRb/DmrJxPN/Axm5itsA077aXGRb2k3HE6HIdBKz9jCZ1t10Oq98l2yllW0Xr4PXhrRb28qha4bNyqacy2TXv1E298r1ZoUCW5aLeCQ7HxW84gk3RbC401Gc7XQxfe0AoTTnRnuPKZLeIgve3a7/w9IPpHkQm9iVGHWnoqh5i0NnQur27Gbry8wRAObPp8lSQtjVETlJmRRoUX5+KdLbwG1G7xjhiCw2Y5e0NiXADu9f2MrP9chk5ys4YXJuS6lgpPFrloPz3QkG6bM37dNjhT/eSuqkSs6qQ6C1ziwUi7segl7CIBtSJwaqHlynMMw/KZSLq+4HRcLC8hHgq+uU2dok3Rd4E0Zk48I6KneL17rc8P9C2UjSNzu+Gvnbnk+2Woy1x3rGiOKxjt/dtl9IS6poZ6XCEEEUge1Xn6kMzNsMZi1v 1uQ8PvUIJC2+QqTcvViBGk X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: efc5ee28-68b1-4c31-bed7-08d4c1cc0f98 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DBXPR06MB462; X-Microsoft-Exchange-Diagnostics: 1; DBXPR06MB462; 3:zW8DQqSFgJrPlhdN3SFUsppihG466JBI4NfTfYHEFSFNxYU8+Sl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zAYvGb4Yl5o87dgW0LeYU+fUPs0uOGLfrkzx69Bg2TIaP2zqnM7ciQ6ZcoKM48uo36C0jECxmzGLUHv8purKPKGhioOnpKQGgPGWe3ysLDBTLKNtGycBobZ4IrnHrhiv6NS7ICJJ7Osyb37jYYmsYLtEPs8W/CQmnIbVs0aVTHxhq1Wb46pfx3E92PAPprh+QvUeIYJ1J75DMuFsuRWqgSEDjronea+FXzSyomRwx5uhKu9JIKmdObUK/Krm96iN1Od/AvuZ1c6Mirt5Gzsl3HlQmyhAjEXMPkXiFjGZPENNuDhh5p93jina5+EZDkQNteeXcAw7uF0kd4nfYNDGkGPfnEukCSA39Mt9uXgmCD/rZ/KdI/p0bXGVAWkSzmee1+hAygxzQaDWAgEMSPvf/WqdEVK3aUG+ekU8+d3yT8VMn5uKgoPTC8uA/DiEJsHADiONhIaRQyf+ukz X-Microsoft-Exchange-Diagnostics: 1; DBXPR06MB462; 20:4FKUUNp+eJPc1PzwXK96szXaQ0CwpXO/AcXWxXkeY5RaSkvzAWXTqoaL9hfceIukiZjCukwXeguPhKPgkyAIQ9eC3l9ybsJUdJiImuax/6/CPVmA6vnm49xGnd3ghxSecw10gIxNfHigrOtKPbgNeERdecnt83WLgxgCYM8Um05NOKc3/mMHFbxQjugv1QigBgSmDpzt9NzB13ntIlDVBvz+9xm6Jf46JAIZhj2EEfSTKqMlr8z06Qn5R7nDl5jrdQZym4oaB19KZGJK/aDZsMLvIr7ZQUgWV/xbOZtKZDoXmUEKRov+THNhS5XQqjj5eysCtSjvqyBD0aZOaV6PQY+vm68pxazK4wM/xalQACpWTdEgeIq1AzBe+B4de5FmkEgad+iUxY4ZfGMQN7aOtmnuU1XysfOfvhFljgtRBiVwO8x99v9tvvcw8v4ohNoPhaNVvHZ2Lhr2HhJQtDM9GW5qCzgDeu4rN03NiKG6JDgy5I4OzkN1O7Zml/WNV1ue X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506)(133145235818549)(72170088055959)(236129657087228)(112613623882745); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(13018025)(8121501046)(5005006)(13016025)(100000703101)(100105400095)(93006095)(93003095)(10201501046)(3002001)(6041248)(20161123564025)(20161123558100)(20161123560025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201702281529075)(201703011903075)(201703061421075)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DBXPR06MB462; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DBXPR06MB462; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQlhQUjA2TUI0NjI7NDpkN0dheGlxWTBBZUozSGF6Y1cyTmpoUGpxK3Fi?= =?utf-8?B?UnFsRHdzU1duSkFiRVBURVNVN1I0bkRFZUVJS0tBVHlzV3VHelhNZGdhNTZB?= =?utf-8?B?aUY3TkR0MlpFUGNGTmpRYUVUWW5HbVdOZUJwSFg4TldRQ0E1RVYwaFdIcVZq?= =?utf-8?B?QmZTR1FwUnprV0ROUi9KOGdBN3Rjb3BNTFV4M0N4U1ZBZXMwUm5HcTVpYjd3?= =?utf-8?B?NU1uZmhBSExROWhqZFQxN2NJSVNLdEJaVmNzRFduUmVuaE1GUmZUcXMyVTdU?= =?utf-8?B?VzV4SFBRTWJpU2Z3R05SeE9SZjh6Z1hvejlsTTY2L21QRkhodENycHl1NEVl?= =?utf-8?B?eEtEU09ydVh2ZmVSc3ZzMHpuVnhrR3hvK0szb2NVOFQzYk1aRlo0UGZiWlk3?= =?utf-8?B?NVdxS0VNVk90a2ZLNklWVDR4ejJLMHcyc01JQTVwUFJzaU9seGU4Nk5rcnZY?= =?utf-8?B?ZXN1Skd4N0ROYVZYdW45MVc1djFBT3FqK3dlY054MXh2OWZDckI4dTFKdi9W?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U+shbP2F0fDSFUOou2I4eZojrYbJZd+OcWtVGEueDxQaC/gMjcTPqCH2RZrYzgEUplTpx9eB7ENA21dkF94PxlYOHsSL70miVIvaLHu9PdKP3rJXpp+DAHfIZTpOxN4eA66DT+tw4rpQTRvXQRJ7CoT+CIDgqhfknQy1GZiVBugTR6uJxSOBzi3NfJaBmnIzJqye9R/pzUHskQteFPRQ8C5z3EoLpYU9bQFwVkTmbV7oBDacxSIqaUOJg+MiPnsm1x5xHU/RANvPfQctgW3XR0LM48KeL8AhWn5roymonuVwYBTURxKuJYkogr1NiKVrUkDzi4xWdnS8kcdzsanZcF0iTpjBcSK/Bb/MA8BmP7oTBembL9Mp9yy1kCcjaXObDflx0= X-OriginatorOrg: cern.ch X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2017 04:29:11.6333 (UTC) X-MS-Exchange-CrossTenant-Id: c80d3499-4a40-4a8c-986e-abce017d6b19 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c80d3499-4a40-4a8c-986e-abce017d6b19; Ip=[188.184.36.17]; Helo=[cernmx.cern.ch] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR06MB462 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Updated version of the ltc2990 driver which supports all measurement modes (current, voltage, temperature) available in the chip. If devicetree is used, the mode must be specified with the property "lltc,meas-mode". The format and possible values of the property are described in the binding. If devicetree is not used, the mode of the chip will not be configured. Unless the chip is configured by another source, only the internal temperature and supply voltage will be measured. Signed-off-by: Tom Levens Tested-By: mike.looijmans@topic.nl --- Documentation/hwmon/ltc2990 | 24 ++++-- drivers/hwmon/Kconfig | 7 +- drivers/hwmon/ltc2990.c | 196 +++++++++++++++++++++++++++++++++++++------- 3 files changed, 185 insertions(+), 42 deletions(-) diff --git a/Documentation/hwmon/ltc2990 b/Documentation/hwmon/ltc2990 index c25211e..3ed68f6 100644 --- a/Documentation/hwmon/ltc2990 +++ b/Documentation/hwmon/ltc2990 @@ -8,6 +8,7 @@ Supported chips: Datasheet: http://www.linear.com/product/ltc2990 Author: Mike Looijmans + Tom Levens Description @@ -16,10 +17,8 @@ Description LTC2990 is a Quad I2C Voltage, Current and Temperature Monitor. The chip's inputs can measure 4 voltages, or two inputs together (1+2 and 3+4) can be combined to measure a differential voltage, which is typically used to -measure current through a series resistor, or a temperature. - -This driver currently uses the 2x differential mode only. In order to support -other modes, the driver will need to be expanded. +measure current through a series resistor, or a temperature with an external +diode. Usage Notes @@ -32,12 +31,19 @@ devices explicitly. Sysfs attributes ---------------- +in0_input Voltage at Vcc pin in millivolt (range 2.5V to 5V) +temp1_input Internal chip temperature in millidegrees Celcius + +A subset of the following attributes are visible, depending on the measurement +mode of the chip. + +in[1-4]_input Voltage at V[1-4] pin in millivolt +temp2_input External temperature sensor TR1 in millidegrees Celcius +temp3_input External temperature sensor TR2 in millidegrees Celcius +curr1_input Current in mA across V1-V2 assuming a 1mOhm sense resistor +curr2_input Current in mA across V3-V4 assuming a 1mOhm sense resistor + The "curr*_input" measurements actually report the voltage drop across the input pins in microvolts. This is equivalent to the current through a 1mOhm sense resistor. Divide the reported value by the actual sense resistor value in mOhm to get the actual value. - -in0_input Voltage at Vcc pin in millivolt (range 2.5V to 5V) -temp1_input Internal chip temperature in millidegrees Celcius -curr1_input Current in mA across v1-v2 assuming a 1mOhm sense resistor. -curr2_input Current in mA across v3-v4 assuming a 1mOhm sense resistor. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 5ef2814..578e5a9 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -709,15 +709,12 @@ config SENSORS_LTC2945 be called ltc2945. config SENSORS_LTC2990 - tristate "Linear Technology LTC2990 (current monitoring mode only)" + tristate "Linear Technology LTC2990" depends on I2C help If you say yes here you get support for Linear Technology LTC2990 I2C System Monitor. The LTC2990 supports a combination of voltage, - current and temperature monitoring, but in addition to the Vcc supply - voltage and chip temperature, this driver currently only supports - reading two currents by measuring two differential voltages across - series resistors. + current and temperature monitoring. This driver can also be built as a module. If so, the module will be called ltc2990. diff --git a/drivers/hwmon/ltc2990.c b/drivers/hwmon/ltc2990.c index e320d21..32f3a8d 100644 --- a/drivers/hwmon/ltc2990.c +++ b/drivers/hwmon/ltc2990.c @@ -5,10 +5,6 @@ * Author: Mike Looijmans * * License: GPLv2 - * - * This driver assumes the chip is wired as a dual current monitor, and - * reports the voltage drop across two series resistors. It also reports - * the chip's internal temperature and Vcc power supply voltage. */ #include @@ -18,6 +14,7 @@ #include #include #include +#include #define LTC2990_STATUS 0x00 #define LTC2990_CONTROL 0x01 @@ -29,35 +26,109 @@ #define LTC2990_V4_MSB 0x0C #define LTC2990_VCC_MSB 0x0E -#define LTC2990_CONTROL_KELVIN BIT(7) -#define LTC2990_CONTROL_SINGLE BIT(6) -#define LTC2990_CONTROL_MEASURE_ALL (0x3 << 3) -#define LTC2990_CONTROL_MODE_CURRENT 0x06 -#define LTC2990_CONTROL_MODE_VOLTAGE 0x07 +#define LTC2990_IN0 BIT(0) +#define LTC2990_IN1 BIT(1) +#define LTC2990_IN2 BIT(2) +#define LTC2990_IN3 BIT(3) +#define LTC2990_IN4 BIT(4) +#define LTC2990_CURR1 BIT(5) +#define LTC2990_CURR2 BIT(6) +#define LTC2990_TEMP1 BIT(7) +#define LTC2990_TEMP2 BIT(8) +#define LTC2990_TEMP3 BIT(9) +#define LTC2990_NONE 0 +#define LTC2990_ALL GENMASK(9, 0) + +#define LTC2990_MODE0_SHIFT 0 +#define LTC2990_MODE0_MASK GENMASK(2, 0) +#define LTC2990_MODE1_SHIFT 3 +#define LTC2990_MODE1_MASK GENMASK(1, 0) + +/* Enabled measurements for mode bits 2..0 */ +static const int ltc2990_attrs_ena_0[] = { + LTC2990_IN1 | LTC2990_IN2 | LTC2990_TEMP3, + LTC2990_CURR1 | LTC2990_TEMP3, + LTC2990_CURR1 | LTC2990_IN3 | LTC2990_IN4, + LTC2990_TEMP2 | LTC2990_IN3 | LTC2990_IN4, + LTC2990_TEMP2 | LTC2990_CURR2, + LTC2990_TEMP2 | LTC2990_TEMP3, + LTC2990_CURR1 | LTC2990_CURR2, + LTC2990_IN1 | LTC2990_IN2 | LTC2990_IN3 | LTC2990_IN4 +}; + +/* Enabled measurements for mode bits 4..3 */ +static const int ltc2990_attrs_ena_1[] = { + LTC2990_NONE, + LTC2990_TEMP2 | LTC2990_IN1 | LTC2990_CURR1, + LTC2990_TEMP3 | LTC2990_IN3 | LTC2990_CURR2, + LTC2990_ALL +}; + +struct ltc2990_data { + struct i2c_client *i2c; + u32 mode[2]; +}; /* Return the converted value from the given register in uV or mC */ -static int ltc2990_get_value(struct i2c_client *i2c, u8 reg, int *result) +static int ltc2990_get_value(struct i2c_client *i2c, int index, int *result) { int val; + u8 reg; + + switch (index) { + case LTC2990_IN0: + reg = LTC2990_VCC_MSB; + break; + case LTC2990_IN1: + case LTC2990_CURR1: + case LTC2990_TEMP2: + reg = LTC2990_V1_MSB; + break; + case LTC2990_IN2: + reg = LTC2990_V2_MSB; + break; + case LTC2990_IN3: + case LTC2990_CURR2: + case LTC2990_TEMP3: + reg = LTC2990_V3_MSB; + break; + case LTC2990_IN4: + reg = LTC2990_V4_MSB; + break; + case LTC2990_TEMP1: + reg = LTC2990_TINT_MSB; + break; + default: + return -EINVAL; + } val = i2c_smbus_read_word_swapped(i2c, reg); if (unlikely(val < 0)) return val; - switch (reg) { - case LTC2990_TINT_MSB: - /* internal temp, 0.0625 degrees/LSB, 13-bit */ + switch (index) { + case LTC2990_TEMP1: + case LTC2990_TEMP2: + case LTC2990_TEMP3: + /* temp, 0.0625 degrees/LSB */ *result = sign_extend32(val, 12) * 1000 / 16; break; - case LTC2990_V1_MSB: - case LTC2990_V3_MSB: - /* Vx-Vy, 19.42uV/LSB. Depends on mode. */ + case LTC2990_CURR1: + case LTC2990_CURR2: + /* Vx-Vy, 19.42uV/LSB */ *result = sign_extend32(val, 14) * 1942 / 100; break; - case LTC2990_VCC_MSB: - /* Vcc, 305.18μV/LSB, 2.5V offset */ + case LTC2990_IN0: + /* Vcc, 305.18uV/LSB, 2.5V offset */ *result = sign_extend32(val, 14) * 30518 / (100 * 1000) + 2500; break; + case LTC2990_IN1: + case LTC2990_IN2: + case LTC2990_IN3: + case LTC2990_IN4: + /* Vx, 305.18uV/LSB */ + *result = sign_extend32(val, 14) * 30518 / (100 * 1000); + break; default: return -EINVAL; /* won't happen, keep compiler happy */ } @@ -69,48 +140,117 @@ static ssize_t ltc2990_show_value(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct ltc2990_data *data = dev_get_drvdata(dev); int value; int ret; - ret = ltc2990_get_value(dev_get_drvdata(dev), attr->index, &value); + ret = ltc2990_get_value(data->i2c, attr->index, &value); if (unlikely(ret < 0)) return ret; return snprintf(buf, PAGE_SIZE, "%d\n", value); } +static umode_t ltc2990_attrs_visible(struct kobject *kobj, + struct attribute *a, int n) +{ + struct device *dev = container_of(kobj, struct device, kobj); + struct ltc2990_data *data = dev_get_drvdata(dev); + struct device_attribute *da = + container_of(a, struct device_attribute, attr); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + int attrs_mask = LTC2990_IN0 | LTC2990_TEMP1 | + ltc2990_attrs_ena_0[data->mode[0]] & + ltc2990_attrs_ena_1[data->mode[1]]; + + if (attr->index & attrs_mask) + return a->mode; + + return 0; +} + static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, ltc2990_show_value, NULL, - LTC2990_TINT_MSB); + LTC2990_TEMP1); +static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, ltc2990_show_value, NULL, + LTC2990_TEMP2); +static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, ltc2990_show_value, NULL, + LTC2990_TEMP3); static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc2990_show_value, NULL, - LTC2990_V1_MSB); + LTC2990_CURR1); static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, ltc2990_show_value, NULL, - LTC2990_V3_MSB); + LTC2990_CURR2); static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, ltc2990_show_value, NULL, - LTC2990_VCC_MSB); + LTC2990_IN0); +static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc2990_show_value, NULL, + LTC2990_IN1); +static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc2990_show_value, NULL, + LTC2990_IN2); +static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, ltc2990_show_value, NULL, + LTC2990_IN3); +static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, ltc2990_show_value, NULL, + LTC2990_IN4); static struct attribute *ltc2990_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, + &sensor_dev_attr_temp2_input.dev_attr.attr, + &sensor_dev_attr_temp3_input.dev_attr.attr, &sensor_dev_attr_curr1_input.dev_attr.attr, &sensor_dev_attr_curr2_input.dev_attr.attr, &sensor_dev_attr_in0_input.dev_attr.attr, + &sensor_dev_attr_in1_input.dev_attr.attr, + &sensor_dev_attr_in2_input.dev_attr.attr, + &sensor_dev_attr_in3_input.dev_attr.attr, + &sensor_dev_attr_in4_input.dev_attr.attr, NULL, }; -ATTRIBUTE_GROUPS(ltc2990); + +static const struct attribute_group ltc2990_group = { + .attrs = ltc2990_attrs, + .is_visible = ltc2990_attrs_visible, +}; +__ATTRIBUTE_GROUPS(ltc2990); static int ltc2990_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { int ret; struct device *hwmon_dev; + struct ltc2990_data *data; + struct device_node *of_node = i2c->dev.of_node; if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) return -ENODEV; - /* Setup continuous mode, current monitor */ + data = devm_kzalloc(&i2c->dev, sizeof(struct ltc2990_data), GFP_KERNEL); + if (unlikely(!data)) + return -ENOMEM; + + data->i2c = i2c; + + if (of_node) { + ret = of_property_read_u32_array(of_node, "lltc,meas-mode", + data->mode, 2); + if (ret < 0) + return ret; + + if (data->mode[0] & ~LTC2990_MODE0_MASK || + data->mode[1] & ~LTC2990_MODE1_MASK) + return -EINVAL; + } else { + ret = i2c_smbus_read_byte_data(i2c, LTC2990_CONTROL); + if (ret < 0) + return ret; + + data->mode[0] = ret >> LTC2990_MODE0_SHIFT & LTC2990_MODE0_MASK; + data->mode[1] = ret >> LTC2990_MODE1_SHIFT & LTC2990_MODE1_MASK; + } + + /* Setup continuous mode */ ret = i2c_smbus_write_byte_data(i2c, LTC2990_CONTROL, - LTC2990_CONTROL_MEASURE_ALL | - LTC2990_CONTROL_MODE_CURRENT); + data->mode[0] << LTC2990_MODE0_SHIFT | + data->mode[1] << LTC2990_MODE1_SHIFT); if (ret < 0) { dev_err(&i2c->dev, "Error: Failed to set control mode.\n"); return ret; @@ -124,7 +264,7 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c, hwmon_dev = devm_hwmon_device_register_with_groups(&i2c->dev, i2c->name, - i2c, + data, ltc2990_groups); return PTR_ERR_OR_ZERO(hwmon_dev);