2023-06-06 01:57:58

by Hawkins, Nick

[permalink] [raw]
Subject: [PATCH v3 0/5] ARM: Add GPIO support

From: Nick Hawkins <[email protected]>

The GXP SoC supports GPIO on multiple interfaces. The interfaces are
CPLD and Host. The GPIOs is a combination of both physical and virtual
I/O across the interfaces. The gpio-gxp driver specifically covers the
CSM(physical), FN2(virtual), and VUHC(virtual) which are the host. The
gpio-gxp-pl driver covers the CPLD which takes physical I/O from the
board and shares it with GXP via a propriety interface that maps the I/O
onto a specific register area of the GXP. The drivers both support
interrupts but from different interrupt parents.

The gxp-fan-ctrl driver in HWMON no longer will report fan presence
or fan failure states as these GPIOs providing this information will be
consumed by the host. It will be the hosts function to keep track of
fan presence and status.

---
Changes since v2:
*Removed shared fan variables between HWMON and GPIO based on feedback
*Removed reporting fan presence and failure from hwmon gxp-fan-ctrl
driver
*Removed GPIO dependency from gxp-fan-ctrl driver
*Changed description and title for hpe,gxp-gpio binding
*Corrected indention on example for hpe,gxp-gpio binding
*Removed additional example from hpe,gxp-gpio binding

Changes since v1:
*Removed ARM device tree changes and defconfig changes to reduce
patchset size
*Removed GXP PSU changes to reduce patchset size
*Corrected hpe,gxp-gpio YAML file based on feedback
*Created new gpio-gxp-pl file to reduce complexity
*Separated code into two files to keep size down: gpio-gxp.c and
gpio-gxp-pl.c
*Fixed Kconfig indentation as well as add new entry for gpio-gxp-pl
*Removed use of linux/of.h and linux/of_device.h
*Added mod_devicetable.h and property.h
*Fixed indentation of defines and uses consistent number of digits
*Corrected defines with improper GPIO_ namespace.
*For masks now use BIT()
*Added comment for PLREG offsets
*Move gpio_chip to be first in structure
*Calculate offset for high and low byte GPIO reads instead of having
H(High) and L(Low) letters added to the variables.
*Removed repeditive use of "? 1 : 0"
*Switched to handle_bad_irq()
*Removed improper bailout on gpiochip_add_data
*Used GENMASK to arm interrupts
*Removed use of of_match_device
*fixed sizeof in devm_kzalloc
*Added COMPILE_TEST to Kconfig
*Added dev_err_probe where applicable
*Removed unecessary parent and compatible checks

Nick Hawkins (5):
dt-bindings: gpio: Add HPE GXP GPIO
gpio: gxp: Add HPE GXP GPIO
dt-bindings: hwmon: hpe,gxp-fan-ctrl: remove fn2 and pl registers
hwmon: (gxp_fan_ctrl) Provide fan info via gpio
MAINTAINERS: hpe: Add GPIO

.../bindings/gpio/hpe,gxp-gpio.yaml | 139 ++++
.../bindings/hwmon/hpe,gxp-fan-ctrl.yaml | 16 +-
MAINTAINERS | 2 +
drivers/gpio/Kconfig | 18 +
drivers/gpio/Makefile | 2 +
drivers/gpio/gpio-gxp-pl.c | 519 ++++++++++++++
drivers/gpio/gpio-gxp.c | 637 ++++++++++++++++++
drivers/hwmon/Kconfig | 2 +-
drivers/hwmon/gxp-fan-ctrl.c | 108 +--
9 files changed, 1324 insertions(+), 119 deletions(-)
create mode 100644 Documentation/devicetree/bindings/gpio/hpe,gxp-gpio.yaml
create mode 100644 drivers/gpio/gpio-gxp-pl.c
create mode 100644 drivers/gpio/gpio-gxp.c

--
2.17.1



2023-06-06 02:02:15

by Hawkins, Nick

[permalink] [raw]
Subject: [PATCH v3 3/5] dt-bindings: hwmon: hpe,gxp-fan-ctrl: remove fn2 and pl registers

From: Nick Hawkins <[email protected]>

Reduce the hpe,gxp-fan-ctrl register references from 3 to 1. The
function2 (fn2) and programmable logic (pl) references are removed.
The purpose of removal being their functionality will be consumed by a
new GPIO driver.

Signed-off-by: Nick Hawkins <[email protected]>

---

v3:
*Modify the subject.
*Remove mention of fan driver receiving data from GPIO as it is no
longer applicable
v2:
*Added more detailed subject and patch description
---
.../bindings/hwmon/hpe,gxp-fan-ctrl.yaml | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/Documentation/devicetree/bindings/hwmon/hpe,gxp-fan-ctrl.yaml b/Documentation/devicetree/bindings/hwmon/hpe,gxp-fan-ctrl.yaml
index 4a52aac6be72..963aa640dc05 100644
--- a/Documentation/devicetree/bindings/hwmon/hpe,gxp-fan-ctrl.yaml
+++ b/Documentation/devicetree/bindings/hwmon/hpe,gxp-fan-ctrl.yaml
@@ -18,21 +18,12 @@ properties:
const: hpe,gxp-fan-ctrl

reg:
- items:
- - description: Fan controller PWM
- - description: Programmable logic
- - description: Function 2
-
- reg-names:
- items:
- - const: base
- - const: pl
- - const: fn2
+ description: Fan controller PWM
+ maxItems: 1

required:
- compatible
- reg
- - reg-names

additionalProperties: false

@@ -40,6 +31,5 @@ examples:
- |
fan-controller@1000c00 {
compatible = "hpe,gxp-fan-ctrl";
- reg = <0x1000c00 0x200>, <0xd1000000 0xff>, <0x80200000 0x100000>;
- reg-names = "base", "pl", "fn2";
+ reg = <0x1000c00 0x200>;
};
--
2.17.1


2023-06-06 02:03:48

by Hawkins, Nick

[permalink] [raw]
Subject: [PATCH v3 4/5] hwmon: (gxp_fan_ctrl) Provide fan info via gpio

From: Nick Hawkins <[email protected]>

The fan driver now is independent of the fan plreg GPIO information.
Therefore there will no longer be presence or fail information available
from the driver. Part of the changes includes removing a system power check
as the GPIO driver needs it to report power state to host.

Signed-off-by: Nick Hawkins <[email protected]>

---

v3:
*Removed shared variable
*Removed GPIO dependency on Kconfig
*Removed present and failure checks surrounding Fans sysfs
v2:
*Removed use of shared functions to GPIO in favor of a shared variable
*Added build dependency on GXP GPIO driver.
---
drivers/hwmon/Kconfig | 2 +-
drivers/hwmon/gxp-fan-ctrl.c | 108 +----------------------------------
2 files changed, 4 insertions(+), 106 deletions(-)

diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 5b3b76477b0e..196ce88d2db9 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -721,7 +721,7 @@ config SENSORS_GXP_FAN_CTRL
If you say yes here you get support for GXP fan control functionality.

The GXP controls fan function via the CPLD through the use of PWM
- registers. This driver reports status and pwm setting of the fans.
+ registers. This driver enables pwm setting of the fans.

config SENSORS_HIH6130
tristate "Honeywell Humidicon HIH-6130 humidity/temperature sensor"
diff --git a/drivers/hwmon/gxp-fan-ctrl.c b/drivers/hwmon/gxp-fan-ctrl.c
index 0014b8b0fd41..55a10c7fc9d6 100644
--- a/drivers/hwmon/gxp-fan-ctrl.c
+++ b/drivers/hwmon/gxp-fan-ctrl.c
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
-/* Copyright (C) 2022 Hewlett-Packard Enterprise Development Company, L.P. */
+/* Copyright (C) 2023 Hewlett-Packard Enterprise Development Company, L.P. */

-#include <linux/bits.h>
#include <linux/err.h>
#include <linux/hwmon.h>
#include <linux/io.h>
@@ -9,52 +8,10 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>

-#define OFS_FAN_INST 0 /* Is 0 because plreg base will be set at INST */
-#define OFS_FAN_FAIL 2 /* Is 2 bytes after base */
-#define OFS_SEVSTAT 0 /* Is 0 because fn2 base will be set at SEVSTAT */
-#define POWER_BIT 24
-
struct gxp_fan_ctrl_drvdata {
- void __iomem *base;
- void __iomem *plreg;
- void __iomem *fn2;
+ void __iomem *base;
};

-static bool fan_installed(struct device *dev, int fan)
-{
- struct gxp_fan_ctrl_drvdata *drvdata = dev_get_drvdata(dev);
- u8 val;
-
- val = readb(drvdata->plreg + OFS_FAN_INST);
-
- return !!(val & BIT(fan));
-}
-
-static long fan_failed(struct device *dev, int fan)
-{
- struct gxp_fan_ctrl_drvdata *drvdata = dev_get_drvdata(dev);
- u8 val;
-
- val = readb(drvdata->plreg + OFS_FAN_FAIL);
-
- return !!(val & BIT(fan));
-}
-
-static long fan_enabled(struct device *dev, int fan)
-{
- struct gxp_fan_ctrl_drvdata *drvdata = dev_get_drvdata(dev);
- u32 val;
-
- /*
- * Check the power status as if the platform is off the value
- * reported for the PWM will be incorrect. Report fan as
- * disabled.
- */
- val = readl(drvdata->fn2 + OFS_SEVSTAT);
-
- return !!((val & BIT(POWER_BIT)) && fan_installed(dev, fan));
-}
-
static int gxp_pwm_write(struct device *dev, u32 attr, int channel, long val)
{
struct gxp_fan_ctrl_drvdata *drvdata = dev_get_drvdata(dev);
@@ -81,37 +38,11 @@ static int gxp_fan_ctrl_write(struct device *dev, enum hwmon_sensor_types type,
}
}

-static int gxp_fan_read(struct device *dev, u32 attr, int channel, long *val)
-{
- switch (attr) {
- case hwmon_fan_enable:
- *val = fan_enabled(dev, channel);
- return 0;
- case hwmon_fan_fault:
- *val = fan_failed(dev, channel);
- return 0;
- default:
- return -EOPNOTSUPP;
- }
-}
-
static int gxp_pwm_read(struct device *dev, u32 attr, int channel, long *val)
{
struct gxp_fan_ctrl_drvdata *drvdata = dev_get_drvdata(dev);
- u32 reg;

- /*
- * Check the power status of the platform. If the platform is off
- * the value reported for the PWM will be incorrect. In this case
- * report a PWM of zero.
- */
-
- reg = readl(drvdata->fn2 + OFS_SEVSTAT);
-
- if (reg & BIT(POWER_BIT))
- *val = fan_installed(dev, channel) ? readb(drvdata->base + channel) : 0;
- else
- *val = 0;
+ *val = readb(drvdata->base + channel);

return 0;
}
@@ -120,8 +51,6 @@ static int gxp_fan_ctrl_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{
switch (type) {
- case hwmon_fan:
- return gxp_fan_read(dev, attr, channel, val);
case hwmon_pwm:
return gxp_pwm_read(dev, attr, channel, val);
default:
@@ -136,16 +65,6 @@ static umode_t gxp_fan_ctrl_is_visible(const void *_data,
umode_t mode = 0;

switch (type) {
- case hwmon_fan:
- switch (attr) {
- case hwmon_fan_enable:
- case hwmon_fan_fault:
- mode = 0444;
- break;
- default:
- break;
- }
- break;
case hwmon_pwm:
switch (attr) {
case hwmon_pwm_input:
@@ -169,15 +88,6 @@ static const struct hwmon_ops gxp_fan_ctrl_ops = {
};

static const struct hwmon_channel_info *gxp_fan_ctrl_info[] = {
- HWMON_CHANNEL_INFO(fan,
- HWMON_F_FAULT | HWMON_F_ENABLE,
- HWMON_F_FAULT | HWMON_F_ENABLE,
- HWMON_F_FAULT | HWMON_F_ENABLE,
- HWMON_F_FAULT | HWMON_F_ENABLE,
- HWMON_F_FAULT | HWMON_F_ENABLE,
- HWMON_F_FAULT | HWMON_F_ENABLE,
- HWMON_F_FAULT | HWMON_F_ENABLE,
- HWMON_F_FAULT | HWMON_F_ENABLE),
HWMON_CHANNEL_INFO(pwm,
HWMON_PWM_INPUT,
HWMON_PWM_INPUT,
@@ -212,18 +122,6 @@ static int gxp_fan_ctrl_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(drvdata->base),
"failed to map base\n");

- drvdata->plreg = devm_platform_ioremap_resource_byname(pdev,
- "pl");
- if (IS_ERR(drvdata->plreg))
- return dev_err_probe(dev, PTR_ERR(drvdata->plreg),
- "failed to map plreg\n");
-
- drvdata->fn2 = devm_platform_ioremap_resource_byname(pdev,
- "fn2");
- if (IS_ERR(drvdata->fn2))
- return dev_err_probe(dev, PTR_ERR(drvdata->fn2),
- "failed to map fn2\n");
-
hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev,
"hpe_gxp_fan_ctrl",
drvdata,
--
2.17.1


2023-06-06 09:43:50

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v3 3/5] dt-bindings: hwmon: hpe,gxp-fan-ctrl: remove fn2 and pl registers

On 06/06/2023 03:42, [email protected] wrote:
> From: Nick Hawkins <[email protected]>
>
> Reduce the hpe,gxp-fan-ctrl register references from 3 to 1. The
> function2 (fn2) and programmable logic (pl) references are removed.
> The purpose of removal being their functionality will be consumed by a
> new GPIO driver.
>
> Signed-off-by: Nick Hawkins <[email protected]>
>


Reviewed-by: Krzysztof Kozlowski <[email protected]>

Best regards,
Krzysztof


2023-06-06 14:33:51

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH v3 4/5] hwmon: (gxp_fan_ctrl) Provide fan info via gpio

On Mon, Jun 05, 2023 at 08:42:33PM -0500, [email protected] wrote:
> From: Nick Hawkins <[email protected]>
>
> The fan driver now is independent of the fan plreg GPIO information.
> Therefore there will no longer be presence or fail information available
> from the driver. Part of the changes includes removing a system power check
> as the GPIO driver needs it to report power state to host.
>
> Signed-off-by: Nick Hawkins <[email protected]>

For my reference:

Reviewed-by: Guenter Roeck <[email protected]>

Let me know if you want me to apply this patch now or if I should wait
for the gpio patches to be accepted.

Guenter

2023-06-07 16:52:28

by Hawkins, Nick

[permalink] [raw]
Subject: Re: [PATCH v3 4/5] hwmon: (gxp_fan_ctrl) Provide fan info via gpio



> > The fan driver now is independent of the fan plreg GPIO information.
> > Therefore there will no longer be presence or fail information available
> > from the driver. Part of the changes includes removing a system power check
> > as the GPIO driver needs it to report power state to host.
> >
> > Signed-off-by: Nick Hawkins <[email protected] <mailto:[email protected]>>


> For my reference:


> Reviewed-by: Guenter Roeck <[email protected] <mailto:[email protected]>>


> Let me know if you want me to apply this patch now or if I should wait
> for the gpio patches to be accepted.

Greetings Guenter,

Please wait until GPIO patches are accepted.

Thanks!

-Nick Hawkins