Message ID | 20190513180744.16493-28-mmaddireddy@nvidia.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | Enable Tegra PCIe root port features | expand |
On Mon, May 13, 2019 at 11:37:42PM +0530, Manikanta Maddireddy wrote: > This new helper function could be used by host drivers to get the reset > GPIO descriptor. If the property isn't assigned, it will return NULL to > the caller. > > Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com> > --- > V3: New patch to add helper function to parse "reset-gpios" > > drivers/pci/of.c | 18 ++++++++++++++++++ > include/linux/of_pci.h | 10 ++++++++++ > 2 files changed, 28 insertions(+) > > diff --git a/drivers/pci/of.c b/drivers/pci/of.c > index 9454c90980c9..2a0282115ff0 100644 > --- a/drivers/pci/of.c > +++ b/drivers/pci/of.c > @@ -6,6 +6,7 @@ > */ > #define pr_fmt(fmt) "PCI: OF: " fmt > > +#include <linux/gpio/consumer.h> > #include <linux/irqdomain.h> > #include <linux/kernel.h> > #include <linux/pci.h> > @@ -224,6 +225,23 @@ int of_pci_get_max_link_speed(struct device_node *node) > } > EXPORT_SYMBOL_GPL(of_pci_get_max_link_speed); > > +/** > + * of_pci_get_reset_gpio() - Get PCI reset gpio descriptor. > + * > + * @node: device node > + * > + * Returns PCI reset gpio descriptor from DT, or an ERR_PTR() if the > + * required property is invalid. > + */ > +struct gpio_desc *of_pci_get_reset_gpio(struct device *dev, > + struct device_node *node, > + int dflags, char *label) > +{ > + return devm_gpiod_get_from_of_node(dev, node, "reset-gpios", 0, dflags, > + label); > +} There's nothing PCI specific about this and 'reset-gpios' is pretty widely used. Either we should have this somewhere common or perhaps not worth a wrapper to save 1 parameter. Also, I believe you can pass just 'reset' so the deprecated form 'reset-gpio' can also be supported. Rob
On 15-May-19 12:01 AM, Rob Herring wrote: > On Mon, May 13, 2019 at 11:37:42PM +0530, Manikanta Maddireddy wrote: >> This new helper function could be used by host drivers to get the reset >> GPIO descriptor. If the property isn't assigned, it will return NULL to >> the caller. >> >> Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com> >> --- >> V3: New patch to add helper function to parse "reset-gpios" >> >> drivers/pci/of.c | 18 ++++++++++++++++++ >> include/linux/of_pci.h | 10 ++++++++++ >> 2 files changed, 28 insertions(+) >> >> diff --git a/drivers/pci/of.c b/drivers/pci/of.c >> index 9454c90980c9..2a0282115ff0 100644 >> --- a/drivers/pci/of.c >> +++ b/drivers/pci/of.c >> @@ -6,6 +6,7 @@ >> */ >> #define pr_fmt(fmt) "PCI: OF: " fmt >> >> +#include <linux/gpio/consumer.h> >> #include <linux/irqdomain.h> >> #include <linux/kernel.h> >> #include <linux/pci.h> >> @@ -224,6 +225,23 @@ int of_pci_get_max_link_speed(struct device_node *node) >> } >> EXPORT_SYMBOL_GPL(of_pci_get_max_link_speed); >> >> +/** >> + * of_pci_get_reset_gpio() - Get PCI reset gpio descriptor. >> + * >> + * @node: device node >> + * >> + * Returns PCI reset gpio descriptor from DT, or an ERR_PTR() if the >> + * required property is invalid. >> + */ >> +struct gpio_desc *of_pci_get_reset_gpio(struct device *dev, >> + struct device_node *node, >> + int dflags, char *label) >> +{ >> + return devm_gpiod_get_from_of_node(dev, node, "reset-gpios", 0, dflags, >> + label); >> +} > There's nothing PCI specific about this and 'reset-gpios' is pretty > widely used. Either we should have this somewhere common or perhaps not > worth a wrapper to save 1 parameter. > > Also, I believe you can pass just 'reset' so the deprecated form > 'reset-gpio' can also be supported. > > Rob I also think that it doesn't need a wrapper to save one parameter. I will drop this patch and use devm_gpiod_get_from_of_node() directly in pci-tegra driver. Manikanta
diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 9454c90980c9..2a0282115ff0 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -6,6 +6,7 @@ */ #define pr_fmt(fmt) "PCI: OF: " fmt +#include <linux/gpio/consumer.h> #include <linux/irqdomain.h> #include <linux/kernel.h> #include <linux/pci.h> @@ -224,6 +225,23 @@ int of_pci_get_max_link_speed(struct device_node *node) } EXPORT_SYMBOL_GPL(of_pci_get_max_link_speed); +/** + * of_pci_get_reset_gpio() - Get PCI reset gpio descriptor. + * + * @node: device node + * + * Returns PCI reset gpio descriptor from DT, or an ERR_PTR() if the + * required property is invalid. + */ +struct gpio_desc *of_pci_get_reset_gpio(struct device *dev, + struct device_node *node, + int dflags, char *label) +{ + return devm_gpiod_get_from_of_node(dev, node, "reset-gpios", 0, dflags, + label); +} +EXPORT_SYMBOL_GPL(of_pci_get_reset_gpio); + /** * of_pci_check_probe_only - Setup probe only mode if linux,pci-probe-only * is present and valid diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index 21a89c4880fa..230ddc813ef9 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h @@ -13,6 +13,9 @@ struct device_node; struct device_node *of_pci_find_child_device(struct device_node *parent, unsigned int devfn); int of_pci_get_devfn(struct device_node *np); +struct gpio_desc *of_pci_get_reset_gpio(struct device *dev, + struct device_node *np, + int dflags, char *label); void of_pci_check_probe_only(void); #else static inline struct device_node *of_pci_find_child_device(struct device_node *parent, @@ -26,6 +29,13 @@ static inline int of_pci_get_devfn(struct device_node *np) return -EINVAL; } +static inline struct gpio_desc *of_pci_get_reset_gpio(struct device *dev, + struct device_node *np, + int dflags, char *label) +{ + return -EINVAL; +} + static inline void of_pci_check_probe_only(void) { } #endif
This new helper function could be used by host drivers to get the reset GPIO descriptor. If the property isn't assigned, it will return NULL to the caller. Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com> --- V3: New patch to add helper function to parse "reset-gpios" drivers/pci/of.c | 18 ++++++++++++++++++ include/linux/of_pci.h | 10 ++++++++++ 2 files changed, 28 insertions(+)