From: Christian Marangi <ansuelsmth@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Jean Delvare <jdelvare@suse.com>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] hwmon: g672: add support for g761
Date: Sat, 25 May 2024 12:47:23 +0200 [thread overview]
Message-ID: <6651f6cc.050a0220.6f744.fff3@mx.google.com> (raw)
In-Reply-To: <bbcce511-1105-40f7-b6e7-beef07971205@roeck-us.net>
On Sat, May 25, 2024 at 07:29:55AM -0700, Guenter Roeck wrote:
> On 5/25/24 03:29, Christian Marangi wrote:
> > Add support for g761 PWM Fan Controller.
> >
> > The g761 is a copy of the g763 with the only difference of supporting
> > and internal clock. This can be configured with the gmt,internal-clock
> > property and in such case clock handling is skipped.
> >
>
> Do you happen to have a datasheet ? The datasheet is not available from GMT,
> making it impossible to validate the changes.
>
No datasheet, online there is only the first page that describe the
features.
This internal clock feature is the only difference to g763 and is
present in a downstream driver from a Asus ipq807x router.
I verified that all the regs match.
> > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> > ---
> > drivers/hwmon/g762.c | 23 ++++++++++++++++++++---
> > 1 file changed, 20 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/hwmon/g762.c b/drivers/hwmon/g762.c
> > index af1228708e25..1629a3141c11 100644
> > --- a/drivers/hwmon/g762.c
> > +++ b/drivers/hwmon/g762.c
> > @@ -69,6 +69,7 @@ enum g762_regs {
> > #define G762_REG_FAN_CMD1_PWM_POLARITY 0x02 /* PWM polarity */
> > #define G762_REG_FAN_CMD1_PULSE_PER_REV 0x01 /* pulse per fan revolution */
> > +#define G761_REG_FAN_CMD2_FAN_CLOCK 0x20 /* choose internal clock*/
> > #define G762_REG_FAN_CMD2_GEAR_MODE_1 0x08 /* fan gear mode */
> > #define G762_REG_FAN_CMD2_GEAR_MODE_0 0x04
> > #define G762_REG_FAN_CMD2_FAN_STARTV_1 0x02 /* fan startup voltage */
> > @@ -115,6 +116,7 @@ enum g762_regs {
> > struct g762_data {
> > struct i2c_client *client;
> > + bool internal_clock;
> > struct clk *clk;
> > /* update mutex */
> > @@ -566,6 +568,7 @@ static int do_set_fan_startv(struct device *dev, unsigned long val)
> > #ifdef CONFIG_OF
> > static const struct of_device_id g762_dt_match[] = {
> > + { .compatible = "gmt,g761" },
> > { .compatible = "gmt,g762" },
> > { .compatible = "gmt,g763" },
> > { },
> > @@ -597,6 +600,16 @@ static int g762_of_clock_enable(struct i2c_client *client)
> > if (!client->dev.of_node)
> > return 0;
> > + data = i2c_get_clientdata(client);
> > +
> > + /* Skip CLK detection and handling if we use internal clock */
> > + data->internal_clock = of_property_read_bool(client->dev.of_node,
> > + "gmt,internal-clock");
> > + if (data->internal_clock) {
> > + do_set_clk_freq(&client->dev, 32768); > + return 0;
> > + }:
> > +
> > clk = of_clk_get(client->dev.of_node, 0);
> > if (IS_ERR(clk)) {
> > dev_err(&client->dev, "failed to get clock\n");
> > @@ -616,7 +629,6 @@ static int g762_of_clock_enable(struct i2c_client *client)
> > goto clk_unprep;
> > }
> > - data = i2c_get_clientdata(client);
> > data->clk = clk;
> > ret = devm_add_action(&client->dev, g762_of_clock_disable, data);
> > @@ -1029,12 +1041,17 @@ static inline int g762_fan_init(struct device *dev)
> > if (IS_ERR(data))
> > return PTR_ERR(data);
> > + if (data->internal_clock)
> > + data->fan_cmd2 |= G761_REG_FAN_CMD2_FAN_CLOCK;
> > +
>
> This and the property must only be accepted for G761.
>
Yes you are right. I limit this only in Documentation but as a failsafe
I should also verify this here. Will do in V2.
> > data->fan_cmd1 |= G762_REG_FAN_CMD1_DET_FAN_FAIL;
> > data->fan_cmd1 |= G762_REG_FAN_CMD1_DET_FAN_OOC;
> > data->valid = false;
> > - return i2c_smbus_write_byte_data(data->client, G762_REG_FAN_CMD1,
> > - data->fan_cmd1);
> > + return (i2c_smbus_write_byte_data(data->client, G762_REG_FAN_CMD1,
> > + data->fan_cmd1) |
> > + i2c_smbus_write_byte_data(data->client, G762_REG_FAN_CMD2,
> > + data->fan_cmd2));
>
> This is wrong. It would logically combine error codes, and execute
> the second write even after the first failed.
>
Ok will change the thing.
> > }
> > static int g762_probe(struct i2c_client *client)
>
--
Ansuel
prev parent reply other threads:[~2024-05-25 14:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-25 10:29 [PATCH 1/3] dt-bindings: hwmon: g762: Convert to yaml schema Christian Marangi
2024-05-25 10:29 ` [PATCH 2/3] dt-bindings: hwmon: g76x: Add support for g761 Christian Marangi
2024-05-25 14:32 ` Guenter Roeck
2024-05-25 10:50 ` Christian Marangi
2024-05-25 14:53 ` Guenter Roeck
2024-05-25 11:12 ` Christian Marangi
2024-05-25 19:58 ` Guenter Roeck
2024-05-25 10:29 ` [PATCH 3/3] hwmon: g672: add " Christian Marangi
2024-05-25 14:29 ` Guenter Roeck
2024-05-25 10:47 ` Christian Marangi [this message]
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=6651f6cc.050a0220.6f744.fff3@mx.google.com \
--to=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=krzk+dt@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=robh@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.