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

Thierry Reding <[email protected]> Thu, 9 Feb 2023 10:02:32 +0100
Newsgroups dev.linux.lists.timestamp,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-doc,org.kernel.vger.linux-gpio,org.kernel.vger.linux-kernel,org.kernel.vger.linux-tegra
Message-ID <Y+S2qES83S4pZKOb@orome>
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 <[email protected]>
> >>> ---
> >>>  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
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAmPktqgACgkQ3SOs138+
s6EpbxAAk28C3+2tpKxyVTrcXW2ws04VXUjVf2QP535J0kRWuq9f9bo81P0Fd4XZ
gQocbe5T1MRIePkqRYvZcXE5omLA7ATUVOxZHSiBOUkM0QtHe14WAN7xQ3AFeK5b
2R9Tx3HNmj2BOE666UCflda/OqkOOCqSf8R1Y0JL+efzK+80ve4nutR1ycJTJG7R
IWYwKTAraLvlUKmDhMtTerojVM7tknVKI1vYjeZKaXKfcDCgbUmgd3AkP4Bvu5HZ
bx/pBuscvukEcoTR7hofMnaHrBSSFeWIiNga6GgiWqdbubHathCVRZWFqvMifD1k
j5Cxi1LPUa4sNBBCiD+kt2lmlO2QAD2vL3ra9KHKhQ4G0fO1OTfMnd1f+ZBKP6u2
BQ7U3CrmF+v8DkDxCENIjMPzbwu5HlNKKfROEXBjGx5zwqdzjkoO6pOSUliOGJAH
jaormuuNAt+meL+o6SxpxHkHhwFdN+zv2cTU2SLM5s0ju7JwGriRyB5MbqhTQNoA
iAL8DW0pLxbr5fdJZMj9YBScq29eLfm62CDRn8l3mUOteDbGF0eDUquaKLDZFo0f
iPcQW5Z6ujzjue/95CiqnXDAgCZ/NNOlrVBc+HiWr7WxVP3vIrfzEsz/g6Dx4LTf
EO/ZwokCmEMsfY7OsWX6ZNyVERbLLpsfznAzMAVKg0p+FwjZ4FU=
=RZDR
-----END PGP SIGNATURE-----