From patchwork Wed Sep 9 13:24:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 11765683 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D049D59D for ; Wed, 9 Sep 2020 15:43:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DC252078E for ; Wed, 9 Sep 2020 15:43:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=aj.id.au header.i=@aj.id.au header.b="GU3C3zDL"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="f0GY7bBd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730361AbgIIPmh (ORCPT ); Wed, 9 Sep 2020 11:42:37 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:51747 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730380AbgIIPlh (ORCPT ); Wed, 9 Sep 2020 11:41:37 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id CE43A5C0081; Wed, 9 Sep 2020 09:24:44 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 09 Sep 2020 09:24:44 -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=pA47cFB778b3Ymf9wpPAhJB/Ec 9gzjiU19iV59xcPGY=; b=GU3C3zDL2FhbrBfCnirbeEe6HZGumvsfxJVMXzZ7m6 qr8I88o30ZtttVwIqAC96+83zdxvC2AlqxV8nB4kmIxP0wwNLUD4aoSbRm9XKFPt dJLuxxejjiSU9SexZLHTOS/1wwl1vPcRqwi0mQb0KYKB1jUNVcSInR9RdB3RaVDR 302u8VhhUTjosqknFsiLAYg0G4W26+8ss023eiYlUjBnAfsMUpDXkUdCi2LRADr/ 7piWAZBxaWayhLfJ8xghJgA1rqAmM+DJPrhK5nTgfTsEton2Hy1D+DFcA8OWDJ0r 1Bfqp9NPLc/ndIQOkDNNmIcimC83OrsD88TSqotZZrPA== 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=pA47cFB778b3Ymf9w pPAhJB/Ec9gzjiU19iV59xcPGY=; b=f0GY7bBdhSZu4PeW7rz+WXiu+zhbgJPV4 YLQniA8PR5jgiJK0SLcLScg/sdwcRqJ5EjYpfdnsfMynLwnYqTqfI2fy+xWghZ0a WiShOK0j7YiveO5r4Ccun45Wm/7RzXNnTCIVUZB3F/bI+0oql2b1ZZf9jsIFaaxK UZOjDp8iLK3KICus9BQGdSfOjHDcL9dh+1ltmf4h+E1gLiNPMsl3T1eXAARLbfaP qrGqx1wU58FyEHnLPNr95arySFK5FHJTUE70viwbuScAKnyt2iEXkEkPgePtZhgo 8CHikhwR7IXLkN2A3M96IQ6fD/AMG1ZEVwKBp1NbsDUYOdyE49QxQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudehhedgiedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegrjhdr ihgurdgruheqnecuggftrfgrthhtvghrnhepkefhieffjeevfeevhedtieeihfefvdejle dvvddthefftedujeethfeuueelfedtnecukfhppedugedrvddruddtledrkeehnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvgifse grjhdrihgurdgruh X-ME-Proxy: Received: from localhost.localdomain (ppp14-2-109-85.adl-apt-pir-bras32.tpg.internode.on.net [14.2.109.85]) by mail.messagingengine.com (Postfix) with ESMTPA id 099193066355; Wed, 9 Sep 2020 09:24:41 -0400 (EDT) From: Andrew Jeffery To: linux-hwmon@vger.kernel.org Cc: linux@roeck-us.net, jdelvare@suse.com, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] hwmon: (pmbus) Expose PEC debugfs attribute Date: Wed, 9 Sep 2020 22:54:11 +0930 Message-Id: <20200909132411.2906159-1-andrew@aj.id.au> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@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 Reported-by: kernel test robot Reported-by: Dan Carpenter --- 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..51c8502b35e9 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 -ENOTSUPP; + + client->flags |= I2C_CLIENT_PEC; + + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_pec, pmbus_debugfs_get_pec, + pmbus_debugfs_set_pec, "0x%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)) {