Re: [PATCH 2/7] hte: Add Tegra234 provider

From: Thierry Reding
Date: Thu Feb 09 2023 - 04:02:43 EST


On Tue, Dec 27, 2022 at 04:43:48PM -0800, Dipen Patel wrote:
> On 11/29/22 7:00 PM, Dipen Patel wrote:
> > On 11/11/22 8:01 AM, Thierry Reding wrote:
> >> On Thu, Nov 03, 2022 at 10:45:18AM -0700, Dipen Patel wrote:
> >>> The Tegra234 AON GPIO instance and LIC IRQ support HTE. For the GPIO
> >>> HTE support, it requires to add mapping between GPIO and HTE framework.
> >>>
> >>> Signed-off-by: Dipen Patel <dipenp@xxxxxxxxxx>
> >>> ---
> >>> drivers/hte/hte-tegra194-test.c | 2 +-
> >>> drivers/hte/hte-tegra194.c | 124 ++++++++++++++++++++++++++++++--
> >>> 2 files changed, 121 insertions(+), 5 deletions(-)
> >>>
> >>> diff --git a/drivers/hte/hte-tegra194-test.c b/drivers/hte/hte-tegra194-test.c
> >>> index 5d776a185bd6..d79c28a80517 100644
> >>> --- a/drivers/hte/hte-tegra194-test.c
> >>> +++ b/drivers/hte/hte-tegra194-test.c
> >>> @@ -16,7 +16,7 @@
> >>> #include <linux/hte.h>
> >>>
> <snip>
> >>> MODULE_DEVICE_TABLE(of, tegra_hte_of_match);
> >>> @@ -635,8 +742,17 @@ static int tegra_hte_probe(struct platform_device *pdev)
> >>>
> >>> gc->match_from_linedata = tegra_hte_match_from_linedata;
> >>>
> >>> - hte_dev->c = gpiochip_find("tegra194-gpio-aon",
> >>> - tegra_get_gpiochip_from_name);
> >>> + if (of_device_is_compatible(dev->of_node,
> >>> + "nvidia,tegra194-gte-aon"))
> >>> + hte_dev->c = gpiochip_find("tegra194-gpio-aon",
> >>> + tegra_get_gpiochip_from_name);
> >>> + else if (of_device_is_compatible(dev->of_node,
> >>> + "nvidia,tegra234-gte-aon"))
> >>> + hte_dev->c = gpiochip_find("tegra234-gpio-aon",
> >>> + tegra_get_gpiochip_from_name);
> >>> + else
> >>> + return -ENODEV;
> >>
> >> I'm wondering: instead of doing this cumbersome lookup, perhaps it would
> >> be easier to create a direct link to the right GPIO controller with a
> >> phandle?
> > Possible, need to see if gpiod framework has API exposed to get the gpiochip from
> > the phandle.
>
> Thierry, I can not find any API which can help retrieve gpio_chip from the GPIO controller
> phandle. I need gpio_chip->base to map GPIO line to GTE mapping.

gpiochip_find() should allow you to implement that. So instead of
tegra_get_gpiochip_from_name() you could implement a function that
matches on the phandle that you've read from the HTE node.

You could probably add such a helper to the GPIO core, since it seems to
me like it would be universally helpful.

Actually there's of_find_gpiochip_by_node() in gpiolib-of.c already, so
you could propose to export it for external users.

Thierry

Attachment: signature.asc
Description: PGP signature