From: Naresh Solanki <naresh.solanki@9elements.com>
To: devicetree@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>,
Jean Delvare <jdelvare@suse.com>
Cc: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org,
Patrick Rudolph <patrick.rudolph@9elements.com>,
Naresh Solanki <Naresh.Solanki@9elements.com>
Subject: [PATCH 3/8] hwmon: (pmbus/mp2975) Prepare for MP2973 and MP2971
Date: Wed, 12 Jul 2023 13:47:44 +0200 [thread overview]
Message-ID: <20230712114754.500477-3-Naresh.Solanki@9elements.com> (raw)
In-Reply-To: <20230712114754.500477-1-Naresh.Solanki@9elements.com>
From: Patrick Rudolph <patrick.rudolph@9elements.com>
Add support for differntiating between the chips.
The following commits will make use of this mechanism.
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
---
drivers/hwmon/pmbus/mp2975.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/drivers/hwmon/pmbus/mp2975.c b/drivers/hwmon/pmbus/mp2975.c
index 130cfde52e42..04778f2dcbdb 100644
--- a/drivers/hwmon/pmbus/mp2975.c
+++ b/drivers/hwmon/pmbus/mp2975.c
@@ -10,6 +10,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include "pmbus.h"
/* Vendor specific registers. */
@@ -56,8 +57,13 @@
PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | \
PMBUS_HAVE_POUT | PMBUS_PHASE_VIRTUAL)
+enum chips {
+ mp2975
+};
+
struct mp2975_data {
struct pmbus_driver_info info;
+ enum chips chip_id;
int vout_scale;
int vid_step[MP2975_PAGE_NUM];
int vref[MP2975_PAGE_NUM];
@@ -68,6 +74,13 @@ struct mp2975_data {
int curr_sense_gain[MP2975_PAGE_NUM];
};
+static const struct i2c_device_id mp2975_id[] = {
+ {"mp2975", mp2975},
+ {}
+};
+
+MODULE_DEVICE_TABLE(i2c, mp2975_id);
+
#define to_mp2975_data(x) container_of(x, struct mp2975_data, info)
static int mp2975_read_byte_data(struct i2c_client *client, int page, int reg)
@@ -691,6 +704,11 @@ static int mp2975_probe(struct i2c_client *client)
if (!data)
return -ENOMEM;
+ if (client->dev.of_node)
+ data->chip_id = (enum chips)of_device_get_match_data(&client->dev);
+ else
+ data->chip_id = i2c_match_id(mp2975_id, client)->driver_data;
+
memcpy(&data->info, &mp2975_info, sizeof(*info));
info = &data->info;
@@ -739,15 +757,8 @@ static int mp2975_probe(struct i2c_client *client)
return pmbus_do_probe(client, info);
}
-static const struct i2c_device_id mp2975_id[] = {
- {"mp2975", 0},
- {}
-};
-
-MODULE_DEVICE_TABLE(i2c, mp2975_id);
-
static const struct of_device_id __maybe_unused mp2975_of_match[] = {
- {.compatible = "mps,mp2975"},
+ {.compatible = "mps,mp2975", .data = (void *)mp2975},
{}
};
MODULE_DEVICE_TABLE(of, mp2975_of_match);
--
2.41.0
next prev parent reply other threads:[~2023-07-12 11:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-12 11:47 [PATCH 1/8] hwmon: (pmbus/mp2975) Fix whitespace error Naresh Solanki
2023-07-12 11:47 ` [PATCH 2/8] dt-bindings: trivial-devices: Add MPS MP2971 and MP2973 Naresh Solanki
2023-07-12 11:51 ` Krzysztof Kozlowski
2023-07-12 11:47 ` Naresh Solanki [this message]
2023-07-12 11:47 ` [PATCH 4/8] hwmon: (pmbus/mp2975) Simplify VOUT code Naresh Solanki
2023-07-12 15:49 ` Guenter Roeck
2023-07-14 11:23 ` Naresh Solanki
2023-07-12 11:47 ` [PATCH 5/8] hwmon: (pmbus/mp2975) Make phase count variable Naresh Solanki
2023-07-12 11:47 ` [PATCH 6/8] hwmon: (pmbus/mp2975) Add support for MP2971 and MP2973 Naresh Solanki
2023-07-12 17:58 ` Guenter Roeck
2023-07-14 12:25 ` Naresh Solanki
2023-07-12 11:47 ` [PATCH 7/8] hwmon: (pmbus/mp2975) Add regulator support Naresh Solanki
2023-07-12 11:47 ` [PATCH 8/8] hwmon: (pmbus/mp2975) Add OCP limit Naresh Solanki
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=20230712114754.500477-3-Naresh.Solanki@9elements.com \
--to=naresh.solanki@9elements.com \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=patrick.rudolph@9elements.com \
/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