Skip to content

Commit d02b1ca

Browse files
hte: handle nvidia,gpio-controller property
The dt binding adds nvidia,gpio-controller property from Tegra234 SoC onwards to simplify code handling gpio chip search. The gpio chip search is needed for the AON GPIO GTE instances to map the hardware timestamp GPIO request (coming from the GPIO framework) to the tegra HTE providers. The patch also adds new gpio chip match function to match from the fwnode instead of the gpio controller label. The addition of the property does not break ABI for the existing Tegra194 code. Signed-off-by: Dipen Patel <dipenp@nvidia.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 0ebc475 commit d02b1ca

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

drivers/hte/hte-tegra194.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,11 @@ static int tegra_get_gpiochip_from_name(struct gpio_chip *chip, void *data)
679679
return !strcmp(chip->label, data);
680680
}
681681

682+
static int tegra_gpiochip_match(struct gpio_chip *chip, void *data)
683+
{
684+
return chip->fwnode == of_node_to_fwnode(data);
685+
}
686+
682687
static int tegra_hte_probe(struct platform_device *pdev)
683688
{
684689
int ret;
@@ -687,6 +692,7 @@ static int tegra_hte_probe(struct platform_device *pdev)
687692
struct device *dev;
688693
struct tegra_hte_soc *hte_dev;
689694
struct hte_chip *gc;
695+
struct device_node *gpio_ctrl;
690696

691697
dev = &pdev->dev;
692698

@@ -754,15 +760,23 @@ static int tegra_hte_probe(struct platform_device *pdev)
754760
gc->match_from_linedata = tegra_hte_match_from_linedata;
755761

756762
if (of_device_is_compatible(dev->of_node,
757-
"nvidia,tegra194-gte-aon"))
763+
"nvidia,tegra194-gte-aon")) {
758764
hte_dev->c = gpiochip_find("tegra194-gpio-aon",
759765
tegra_get_gpiochip_from_name);
760-
else if (of_device_is_compatible(dev->of_node,
761-
"nvidia,tegra234-gte-aon"))
762-
hte_dev->c = gpiochip_find("tegra234-gpio-aon",
763-
tegra_get_gpiochip_from_name);
764-
else
765-
return -ENODEV;
766+
} else {
767+
gpio_ctrl = of_parse_phandle(dev->of_node,
768+
"nvidia,gpio-controller",
769+
0);
770+
if (!gpio_ctrl) {
771+
dev_err(dev,
772+
"gpio controller node not found\n");
773+
return -ENODEV;
774+
}
775+
776+
hte_dev->c = gpiochip_find(gpio_ctrl,
777+
tegra_gpiochip_match);
778+
of_node_put(gpio_ctrl);
779+
}
766780

767781
if (!hte_dev->c)
768782
return dev_err_probe(dev, -EPROBE_DEFER,

0 commit comments

Comments
 (0)