Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp757682pxk; Wed, 9 Sep 2020 19:19:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRZVvoVEm832MiqnUyDv4lWxHYz4mKGTjMh3xCYTRkshdbg7XgQzD5OE0OCauA+VuHjXPZ X-Received: by 2002:a17:906:d78c:: with SMTP id pj12mr6493655ejb.36.1599704346433; Wed, 09 Sep 2020 19:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599704346; cv=none; d=google.com; s=arc-20160816; b=cBYK/Hps9Y8qBOD35jiqJWdL4ffB60g+9GfKR/w3IQJdC69dDPflGSPuPUsstFqnsU nVTr7tHV6FDdKEIbbcimMo+d1HwLJePYNxzHp/2FsJsztJHTcJ0wgD3tQWH9iLAsnL7B /J4xNnGPU7SYb3+RpGLfSq/h4zyR6fFQ1WceB2bW3oDXaEqhl8ZzifJ9uoKrns0SJvQq AXDvwAY+8E49TO/MBF25D7jGJYh4qFvxUe2aw6kShxbNFkJMexTmQcQFoDiZ0ndWdU8z MPskLk1yN8OnWl59VDt9yOKiwSUs+hzn2hXlMucTwadgWaY70eeihsvU4s5nrd2aOSPf k4Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=7OJIUNnPof5fmS9W9OyrAXXYxmfDhwOyhBDHLSmMoF4=; b=e7bKzru5fhMczfQj2uCmug/WtQf0OFcXOOeir5rH28mWRgf2l/Flw8aJEq2WtBIKT7 WXBmAPu63FmY3PAqVImnrWJJPvq1tYw3DDdYQf0AQlye+J9ImoOng83mOsUaa+fRCuFP q18R9QghG0gXIc8R05sP4NaRT30E7wUcQ+srJl8FCJXPEKsw3fufvrpmuWVXgCcmVThB Gpv/o2M4HdEjYV2JzhL8RluMfQ2fcitdPB4v3iJSPsAaFGX4J2RWJrs7ByJxkCvBvOh1 oxIGeWDjxk3aJOhdyRRsRdwQJK6nf48rb8tGfVquiDBTiWuJ8ssBvOw2W318aXap3j7s SBjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm3 header.b=jKjG0D48; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=IsiCXqAL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j26si2490477edf.88.2020.09.09.19.18.43; Wed, 09 Sep 2020 19:19:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm3 header.b=jKjG0D48; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=IsiCXqAL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730790AbgIJCSN (ORCPT + 99 others); Wed, 9 Sep 2020 22:18:13 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:36745 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730699AbgIJCMi (ORCPT ); Wed, 9 Sep 2020 22:12:38 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 37C485C00DB; Wed, 9 Sep 2020 22:11:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 09 Sep 2020 22:11:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm3; bh=7OJIUNnPof5fmS9W9OyrAXXYxm fDhwOyhBDHLSmMoF4=; b=jKjG0D483XpbWMCqQqhQ62Pws1McbdPwT4Y13IHGT8 8t97bt99NNL+Kyttrc1f17CLRmxsuKZR1c3PV1E8Drv9zUkGNUoSq/uzMYVoKyEu 16TuYcXoLhfQDBKWuU5vqXjlN9k5wTAdfbq8FMIxX3nYslzaaW9ZeNbhZPM+iASg ZvS5Byb5ToxOT2iM3Tl1zRiollkyxoj3avqIYE857+u405omFJqMpuysQBFgHlb0 GM5repbCpLBk4XNUHILwY9DJR0Di/mEUDcMRUxUZHLAGvE8JVigwc3bhVNkHmmMx FL0qU9eD8sJJ2y56NAUB1NtgUSVwm4vMhPujQwi2Kehw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=7OJIUNnPof5fmS9W9 OyrAXXYxmfDhwOyhBDHLSmMoF4=; b=IsiCXqALfyi3KjRzWkdG++rytARB47IZ7 +4kW2+1T9GhFEVIIoFRebiKTLIV2rhBxwTqNomu34vRkHRXJfC44u/eUMbifUdMe lCKoQ92Apepcge6RrLLv3mchSs47euk1iSIiTUYo5RHVG2qgfelrqmrTpfSkGf4N 0uNESTQ8Rx4mUU78eNLA4U6p4X6iNihipmWzZPaq95gZKPQrzucj9EL/faznhF72 HGGPxtKfC0hiCmX5ozRehFQc+7bjREvf40/ifTZB1dN7qcFg6onvX44GeSf/QPZb Xvp6ZWAr6+iQTzlNaVnk1rcchPoNqbHfAh7C62rgC2cBzGNTDKW6A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudehiedgheehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegrjhdr ihgurdgruheqnecuggftrfgrthhtvghrnhepkefhieffjeevfeevhedtieeihfefvdejle dvvddthefftedujeethfeuueelfedtnecukfhppedugedrvddruddtledrkeehnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvgifse grjhdrihgurdgruh X-ME-Proxy: Received: from mistburn.lan (ppp14-2-109-85.adl-apt-pir-bras32.tpg.internode.on.net [14.2.109.85]) by mail.messagingengine.com (Postfix) with ESMTPA id 093AB328005D; Wed, 9 Sep 2020 22:11:33 -0400 (EDT) From: Andrew Jeffery To: linux-hwmon@vger.kernel.org Cc: linux@roeck-us.net, jdelvare@suse.com, linux-kernel@vger.kernel.org Subject: [PATCH v2] hwmon: (pmbus) Expose PEC debugfs attribute Date: Thu, 10 Sep 2020 11:41:06 +0930 Message-Id: <20200910021106.2958382-1-andrew@aj.id.au> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enable runtime debug control of whether the PEC byte is exchanged with the PMBus device. Some manufacturers have asked for the PEC to be disabled as part of debugging driver communication issues with devices. Signed-off-by: Andrew Jeffery --- drivers/hwmon/pmbus/pmbus_core.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 44535add3a4a..9e7d5f7f0cd0 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2346,6 +2346,42 @@ static int pmbus_debugfs_get_status(void *data, u64 *val) DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_status, pmbus_debugfs_get_status, NULL, "0x%04llx\n"); +static int pmbus_debugfs_get_pec(void *data, u64 *val) +{ + struct i2c_client *client = data; + + *val = !!(client->flags & I2C_CLIENT_PEC); + + return 0; +} + +static int pmbus_debugfs_set_pec(void *data, u64 val) +{ + int rc; + struct i2c_client *client = data; + + if (!val) { + client->flags &= ~I2C_CLIENT_PEC; + return 0; + } + + if (val != 1) + return -EINVAL; + + rc = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY); + if (rc < 0) + return rc; + + if (!(rc & PB_CAPABILITY_ERROR_CHECK)) + return -EOPNOTSUPP; + + client->flags |= I2C_CLIENT_PEC; + + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_pec, pmbus_debugfs_get_pec, + pmbus_debugfs_set_pec, "%1llu\n"); + static int pmbus_init_debugfs(struct i2c_client *client, struct pmbus_data *data) { @@ -2374,6 +2410,9 @@ static int pmbus_init_debugfs(struct i2c_client *client, if (!entries) return -ENOMEM; + debugfs_create_file("pec", 0664, data->debugfs, client, + &pmbus_debugfs_ops_pec); + for (i = 0; i < data->info->pages; ++i) { /* Check accessibility of status register if it's not page 0 */ if (!i || pmbus_check_status_register(client, i)) { -- 2.25.1