mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Jeffery <andrew@aj.id.au>
To: linux-hwmon@vger.kernel.org
Cc: Andrew Jeffery <andrew@aj.id.au>,
	linux@roeck-us.net, robh+dt@kernel.org, mark.rutland@arm.com,
	jdelvare@suse.com, corbet@lwn.net, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	joel@jms.id.au, openbmc@lists.ozlabs.org
Subject: [PATCH v4 5/6] pmbus: core: Add virtual page config bit
Date: Fri,  3 Nov 2017 15:53:05 +1100	[thread overview]
Message-ID: <20171103045306.26448-6-andrew@aj.id.au> (raw)
In-Reply-To: <20171103045306.26448-1-andrew@aj.id.au>

Some circumstances call for virtual pages to expose multiple values
packed into an extended PMBus register in a manner non-compliant with
the PMBus standard. We should not try to set virtual pages on the
device; add a flag so we can avoid doing so.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
 drivers/hwmon/pmbus/pmbus.h      |  2 ++
 drivers/hwmon/pmbus/pmbus_core.c | 12 ++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index cdf3e288e626..0560a8dbcee0 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -367,6 +367,8 @@ enum pmbus_sensor_classes {
 #define PMBUS_HAVE_PWM12	BIT(20)
 #define PMBUS_HAVE_PWM34	BIT(21)
 
+#define PMBUS_PAGE_VIRTUAL	BIT(31)
+
 enum pmbus_data_format { linear = 0, direct, vid };
 enum vrm_version { vr11 = 0, vr12, vr13 };
 
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 55838b69e99a..af7362de405d 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -164,14 +164,18 @@ int pmbus_set_page(struct i2c_client *client, u8 page)
 	int rv = 0;
 	int newpage;
 
-	if (page != data->currpage) {
+	if (page == data->currpage)
+		return 0;
+
+	if (!(data->info->func[page] & PMBUS_PAGE_VIRTUAL)) {
 		rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
 		newpage = i2c_smbus_read_byte_data(client, PMBUS_PAGE);
 		if (newpage != page)
-			rv = -EIO;
-		else
-			data->currpage = page;
+			return -EIO;
 	}
+
+	data->currpage = page;
+
 	return rv;
 }
 EXPORT_SYMBOL_GPL(pmbus_set_page);
-- 
2.11.0

  parent reply	other threads:[~2017-11-03  4:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03  4:53 [PATCH v4 0/6] pmbus: Expand fan support and add MAX31785 driver Andrew Jeffery
2017-11-03  4:53 ` [PATCH v4 1/6] dt-bindings: pmbus: Add Maxim MAX31785 documentation Andrew Jeffery
2017-11-06 21:52   ` Rob Herring
2017-11-07  1:27   ` [v4,1/6] " Guenter Roeck
2017-11-03  4:53 ` [PATCH v4 2/6] pmbus: Add driver for Maxim MAX31785 Intelligent Fan Controller Andrew Jeffery
2017-11-05 14:08   ` [v4, " Guenter Roeck
2017-11-03  4:53 ` [PATCH v4 3/6] pmbus: core: Add fan control support Andrew Jeffery
2017-11-05 14:39   ` [v4,3/6] " Guenter Roeck
2017-11-10  3:03     ` Andrew Jeffery
2017-11-10  8:24       ` Guenter Roeck
2017-11-03  4:53 ` [PATCH v4 4/6] pmbus: max31785: Add fan control Andrew Jeffery
2017-11-05 15:04   ` [v4,4/6] " Guenter Roeck
2017-11-10  3:10     ` Andrew Jeffery
2017-11-10  8:07       ` Guenter Roeck
2017-11-03  4:53 ` Andrew Jeffery [this message]
2017-11-03  4:53 ` [PATCH v4 6/6] pmbus: max31785: Add dual tachometer support Andrew Jeffery
2017-11-05 14:58   ` [v4,6/6] " Guenter Roeck
2017-11-10  3:12     ` Andrew Jeffery

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171103045306.26448-6-andrew@aj.id.au \
    --to=andrew@aj.id.au \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=joel@jms.id.au \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mark.rutland@arm.com \
    --cc=openbmc@lists.ozlabs.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®