From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: nick.hawkins@hpe.com, verdun@hpe.com, linus.walleij@linaro.org,
brgl@bgdev.pl, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, jdelvare@suse.com,
linux@roeck-us.net, linux@armlinux.org.uk,
linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v1 1/9] gpio: gxp: Add HPE GXP GPIO
Date: Tue, 18 Apr 2023 19:02:23 +0200 [thread overview]
Message-ID: <e28a7788-e4b5-d777-4775-d57a00b0fbcc@linaro.org> (raw)
In-Reply-To: <20230418152824.110823-2-nick.hawkins@hpe.com>
On 18/04/2023 17:28, nick.hawkins@hpe.com wrote:
> From: Nick Hawkins <nick.hawkins@hpe.com>
>
> The GXP SoC supports GPIO on multiple interfaces: Host, CPLD and Soc
> pins. The interface from CPLD and Host are interruptable from vic0
> and vic1. This driver allows support for both of these interfaces
> through the use of different compatible bindings.
>
> Signed-off-by: Nick Hawkins <nick.hawkins@hpe.com>
> ---
> drivers/gpio/Kconfig | 9 +
> drivers/gpio/Makefile | 1 +
> drivers/gpio/gpio-gxp.c | 1056 +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 1066 insertions(+)
> create mode 100644 drivers/gpio/gpio-gxp.c
>
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index 13be729710f2..47435307698c 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -1235,6 +1235,15 @@ config HTC_EGPIO
> several HTC phones. It provides basic support for input
> pins, output pins, and IRQs.
>
> +config GPIO_GXP
> + tristate "GXP GPIO support"
> + depends on ARCH_HPE_GXP
|| COMPILE_TEST
(...)
> +
> + drvdata->chip.parent = &pdev->dev;
> + ret = devm_gpiochip_add_data(&pdev->dev, &drvdata->chip, NULL);
> + if (ret < 0)
> + dev_err(&pdev->dev,
> + "Could not register gpiochip for fn2, %d\n", ret);
> + dev_info(&pdev->dev, "HPE GXP FN2 driver loaded.\n");
Drop non-informative probe successes. They are not needed.
> +
> + return 0;
> +}
> +
> +static int gxp_gpio_pl_init(struct platform_device *pdev)
> +{
> + struct gxp_gpio_drvdata *drvdata = dev_get_drvdata(&pdev->dev);
> + struct gpio_irq_chip *girq;
> + int ret;
> + unsigned int val;
> +
> + drvdata->pl_led = gxp_gpio_init_regmap(pdev, "pl-led", 8);
> + if (IS_ERR(drvdata->pl_led))
> + return dev_err_probe(&pdev->dev, PTR_ERR(drvdata->pl_int),
> + "failed to map pl_led\n");
> +
> + drvdata->pl_health = gxp_gpio_init_regmap(pdev, "pl-health", 8);
> + if (IS_ERR(drvdata->pl_health))
> + return dev_err_probe(&pdev->dev, PTR_ERR(drvdata->pl_int),
> + "failed to map pl_health\n");
> +
> + drvdata->pl_int = gxp_gpio_init_regmap(pdev, "pl-int", 8);
> + if (IS_ERR(drvdata->pl_int))
> + return dev_err_probe(&pdev->dev, PTR_ERR(drvdata->pl_int),
> + "failed to map pl_int\n");
> +
> + drvdata->chip = plreg_chip;
> + drvdata->chip.ngpio = 100;
> + drvdata->chip.parent = &pdev->dev;
> +
> + girq = &drvdata->chip.irq;
> + girq->chip = &gxp_plreg_irqchip;
> + girq->parent_handler = NULL;
> + girq->num_parents = 0;
> + girq->parents = NULL;
> + girq->default_type = IRQ_TYPE_NONE;
> + girq->handler = handle_edge_irq;
> +
> + girq->init_hw = gxp_gpio_irq_init_hw;
> +
> + ret = devm_gpiochip_add_data(&pdev->dev, &drvdata->chip, drvdata);
> + if (ret < 0)
> + dev_err(&pdev->dev, "Could not register gpiochip for plreg, %d\n",
> + ret);
> +
> + regmap_update_bits(drvdata->pl_int, PLREG_INT_HI_PRI_EN,
> + BIT(4) | BIT(5), BIT(4) | BIT(5));
> + regmap_update_bits(drvdata->pl_int, PLREG_INT_GRP_STAT_MASK,
> + BIT(4) | BIT(5), 0x00);
> + regmap_read(drvdata->pl_int, PLREG_INT_HI_PRI_EN, &val);
> + regmap_read(drvdata->pl_int, PLREG_INT_GRP_STAT_MASK, &val);
> +
> + ret = platform_get_irq(pdev, 0);
> + if (ret < 0) {
> + dev_err(&pdev->dev, "Get irq from platform fail - %d\n", ret);
> + return ret;
return dev_err_probe
> + }
> +
> + drvdata->irq = ret;
> +
> + ret = devm_request_irq(&pdev->dev, drvdata->irq, gxp_gpio_pl_irq_handle,
> + IRQF_SHARED, "gxp-pl", drvdata);
> + if (ret < 0) {
> + dev_err(&pdev->dev, "IRQ handler failed - %d\n", ret);
return dev_err_probe
Actually other applicable places as well...
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static const struct of_device_id gxp_gpio_of_match[] = {
> + { .compatible = "hpe,gxp-gpio"},
> + { .compatible = "hpe,gxp-gpio-pl"},
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, gxp_gpio_of_match);
> +
> +static int gxp_gpio_probe(struct platform_device *pdev)
> +{
> + int ret;
> + struct gxp_gpio_drvdata *drvdata;
> + struct device *dev = &pdev->dev;
> + struct device *parent;
> + const struct of_device_id *match = of_match_device(gxp_gpio_of_match, dev);
> +
> + if (!match) {
> + dev_err(dev, "device is not compatible");
It is not possible.
> + return -EINVAL;
> + }
> +
> + parent = dev->parent;
> + if (!parent) {
> + dev_err(dev, "no parent\n");
Why do you need this check?
> + return -ENODEV;
> + }
> +
> + drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gxp_gpio_drvdata),
sizeof(*)
> + GFP_KERNEL);
> + if (!drvdata)
> + return -ENOMEM;
> +
> + platform_set_drvdata(pdev, drvdata);
> +
> + if (strcmp(match->compatible, "hpe,gxp-gpio-pl") == 0)
No, use match data. Anyway this is open-coding of OF functions...
> + ret = gxp_gpio_pl_init(pdev);
> + else
> + ret = gxp_gpio_init(pdev);
> +
> + return ret;
Best regards,
Krzysztof
next prev parent reply other threads:[~2023-04-18 17:02 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-18 15:28 [PATCH v1 0/9] ARM: Add GPIO and PSU Support nick.hawkins
2023-04-18 15:28 ` [PATCH v1 1/9] gpio: gxp: Add HPE GXP GPIO nick.hawkins
2023-04-18 17:02 ` Krzysztof Kozlowski [this message]
2023-04-18 17:17 ` Guenter Roeck
2023-04-27 14:53 ` Hawkins, Nick
2023-04-28 13:32 ` Guenter Roeck
2023-05-12 16:08 ` Hawkins, Nick
2023-04-27 16:28 ` andy.shevchenko
2023-04-27 19:01 ` Hawkins, Nick
2023-04-28 6:51 ` Andy Shevchenko
2023-04-18 15:28 ` [PATCH v1 2/9] hwmon: (gxp_fan_ctrl) Give GPIO access to fan data nick.hawkins
2023-04-18 17:10 ` Guenter Roeck
2023-04-18 18:00 ` kernel test robot
2023-04-19 15:01 ` kernel test robot
2023-04-18 15:28 ` [PATCH v1 3/9] hwmon: (gxp-psu) Add driver to read HPE PSUs nick.hawkins
2023-04-18 17:47 ` Guenter Roeck
2023-04-18 19:33 ` kernel test robot
2023-04-18 15:28 ` [PATCH v1 4/9] dt-bindings: hwmon: Modify hpe,gxp-fan-ctrl nick.hawkins
2023-04-18 17:03 ` Krzysztof Kozlowski
2023-04-18 15:28 ` [PATCH v1 5/9] dt-bindings: gpio: Add HPE GXP GPIO nick.hawkins
2023-04-18 17:08 ` Krzysztof Kozlowski
2023-04-18 15:28 ` [PATCH v1 6/9] dt-bindings: hwmon: Add HPE GXP PSU Support nick.hawkins
2023-04-18 17:10 ` Krzysztof Kozlowski
2023-04-21 18:13 ` Rob Herring
2023-04-18 15:28 ` [PATCH v1 7/9] ARM: dts: gxp: add psu, i2c, gpio nick.hawkins
2023-04-18 17:25 ` Krzysztof Kozlowski
2023-04-27 15:08 ` Hawkins, Nick
2023-04-18 15:28 ` [PATCH v1 8/9] ARM: multi_v7_defconfig: Add PSU, GPIO, and I2C nick.hawkins
2023-04-18 17:10 ` Krzysztof Kozlowski
2023-04-18 15:28 ` [PATCH v1 9/9] MAINTAINERS: hpe: Add GPIO, PSU nick.hawkins
2023-04-18 17:27 ` Krzysztof Kozlowski
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=e28a7788-e4b5-d777-4775-d57a00b0fbcc@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@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=nick.hawkins@hpe.com \
--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;
as well as URLs for NNTP newsgroup(s).