From: "Hawkins, Nick" <nick.hawkins@hpe.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: "jdelvare@suse.com" <jdelvare@suse.com>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"krzysztof.kozlowski+dt@linaro.org"
<krzysztof.kozlowski+dt@linaro.org>,
"Verdun, Jean-Marie" <verdun@hpe.com>,
"corbet@lwn.net" <corbet@lwn.net>,
"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: RE: [PATCH v1 1/6] hwmon: (gxp-fan-ctrl) Add GXP fan controller
Date: Tue, 8 Nov 2022 17:07:28 +0000 [thread overview]
Message-ID: <DM4PR84MB1927932BB574CD149E1C1809883F9@DM4PR84MB1927.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <DM4PR84MB192759BA77DDC69C61E5923F883F9@DM4PR84MB1927.NAMPRD84.PROD.OUTLOOK.COM>
Note: This is a resend, my email client decided to
Change my paragraph format with 70 char lines.
Apologies.
Greetings Guenter,
> > +static bool fan_installed(struct device *dev, int fan) {
> > + struct gxp_fan_ctrl_drvdata *drvdata = dev_get_drvdata(dev);
> > + u32 trans_offset;
> > + u32 trans_shift;
> > + u32 val;
> > +
> > + address_translation(drvdata->data->fan[fan].inst,
> > + &trans_offset,
> > + &trans_shift);
> > +
> > + regmap_read(drvdata->plreg_map, trans_offset, &val);
> > + val = (val >> trans_shift) & drvdata->data->fan[fan].bit;
> > + if (val == drvdata->data->fan[fan].bit)
> > + return 1;
> > + else
> > + return 0;
> return val == drvdata->data->fan[fan].bit;
> Those calculations look quite complex. Is there a public datasheet that would enable me to understand how registers are actually assigned ?
There is no public datasheet as of yet but there is work ongoing to
create one. I will however document exactly how it is setup in hwmon.
There is so much I/O on our board that most of the inputs and outputs
go through an external CPLD we are interfaced with to save pins. A
memory area in our SoC reflects some of the I/O from CPLD in bytes
ranging from 0 to 0xff. Each byte represents information such as byte
0x27, which on this particular platform represents the fan installation
status of fans 0 to 7 respectively with bit 0 to 7. The byte 0x28 represents
something else. Regmap_read/write does a word instead of a single byte
which we are interested in so we use address_translation to keep offsets
easier to read.
> > + } else {
> > + /* Power Off */
> > + val = 0;
> > + }
> What determines power to a fan ? Should the power state be reported with fanX_enable ? Or possibly the installed state ?
This actually is the power state of the system, not the fan. When the
system is off we will see a PWM value of 0xFF on the fan. The idea
here was to report a value of 0 if the system was off.
Would you like me to use fanX_enable (read only) to show it as
disabled while the system is off ?
From a hardware standpoint that would be accurate.
> > +static const struct fan_ctrl_data g10_data = {
> > + .fan[0] = { .inst = 0x00, .fail = 0x02, .id = 0x04, .bit = 0x01 },
> > + .fan[1] = { .inst = 0x00, .fail = 0x02, .id = 0x04, .bit = 0x02 },
> > + .fan[2] = { .inst = 0x00, .fail = 0x02, .id = 0x04, .bit = 0x04 },
> > + .fan[3] = { .inst = 0x00, .fail = 0x02, .id = 0x04, .bit = 0x08 },
> > + .fan[4] = { .inst = 0x00, .fail = 0x02, .id = 0x04, .bit = 0x10 },
> > + .fan[5] = { .inst = 0x00, .fail = 0x02, .id = 0x04, .bit = 0x20 },
> > + .fan[6] = { .inst = 0x00, .fail = 0x02, .id = 0x04, .bit = 0x40 },
> > + .fan[7] = { .inst = 0x00, .fail = 0x02, .id = 0x04, .bit = 0x80 },
> > + .fan[8] = { .inst = 0x01, .fail = 0x03, .id = 0x05, .bit = 0x01 },
> > + .fan[9] = { .inst = 0x01, .fail = 0x03, .id = 0x05, .bit = 0x02 },
> > + .fan[10] = { .inst = 0x01, .fail = 0x03, .id = 0x05, .bit = 0x04 },
> > + .fan[11] = { .inst = 0x01, .fail = 0x03, .id = 0x05, .bit = 0x08 },
> > + .fan[12] = { .inst = 0x01, .fail = 0x03, .id = 0x05, .bit = 0x10 },
> > + .fan[13] = { .inst = 0x01, .fail = 0x03, .id = 0x05, .bit = 0x20 },
> > + .fan[14] = { .inst = 0x01, .fail = 0x03, .id = 0x05, .bit = 0x40 },
> > + .fan[15] = { .inst = 0x01, .fail = 0x03, .id = 0x05, .bit = 0x80 },
> > + .power_bit = 24,
> > +};
> > +
> > +static const struct of_device_id gxp_fan_ctrl_of_match[] = {
> > + { .compatible = "hpe,gxp-fan-ctrl", .data = &g10_data },
> I don't understand the point of attaching g10_data here.
> Why not just access it directly ? There is just one table.
The reason for having this data with the of_device_id binding is that
each platform has different byte offsets as mentioned above. We
would like to be able to reuse the driver if possible for this. We will
soon need g11_data that will be added here. Would a description in
Documentation, comments and commit message allow us to keep
this ?
Thank you for your assistance and feedback with this code,
-Nick Hawkins
next prev parent reply other threads:[~2022-11-08 17:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 19:36 [PATCH v1 0/6] ARM: Add GXP Fan and SPI controllers nick.hawkins
2022-11-04 19:36 ` [PATCH v1 1/6] hwmon: (gxp-fan-ctrl) Add GXP fan controller nick.hawkins
2022-11-04 20:01 ` Guenter Roeck
2022-11-08 16:59 ` Hawkins, Nick
2022-11-08 17:07 ` Hawkins, Nick [this message]
2022-11-07 3:56 ` Bagas Sanjaya
2022-11-08 0:45 ` kernel test robot
2022-11-04 19:36 ` [PATCH v1 2/6] ABI: sysfs-class-hwmon: add a description for fanY_fault nick.hawkins
2022-11-04 19:36 ` [PATCH v1 3/6] dt-bindings: hwmon: Add hpe,gxp-fan-ctrl nick.hawkins
2022-11-06 10:38 ` Krzysztof Kozlowski
2022-11-07 22:36 ` Hawkins, Nick
2022-11-08 11:22 ` Krzysztof Kozlowski
2022-11-04 19:36 ` [PATCH v1 4/6] ARM: dts: add GXP Support for fans and SPI nick.hawkins
2022-11-04 19:36 ` [PATCH v1 5/6] ARM: multi_v7_defconfig: Add GXP Fan and SPI support nick.hawkins
2022-11-06 10:40 ` Krzysztof Kozlowski
2022-11-04 19:36 ` [PATCH v1 6/6] MAINTAINERS: add gxp fan controller and documents nick.hawkins
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=DM4PR84MB1927932BB574CD149E1C1809883F9@DM4PR84MB1927.NAMPRD84.PROD.OUTLOOK.COM \
--to=nick.hawkins@hpe.com \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linux@roeck-us.net \
--cc=robh+dt@kernel.org \
--cc=verdun@hpe.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
all inboxes | Powered by JetHome®