* [PATCH 1/2] dt-bindings: leds: document new usb-ports property @ 2016-12-29 13:03 Rafał Miłecki [not found] ` <20161229130306.30400-1-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2016-12-29 13:03 ` [EXAMPLE 3/2] ARM: BCM53573: Specify ports for USB LED for Tenda AC9 Rafał Miłecki 0 siblings, 2 replies; 5+ messages in thread From: Rafał Miłecki @ 2016-12-29 13:03 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-leds-u79uwXL29TY76Z2rM5mHXA, Richard Purdie, Jacek Anaszewski, Pavel Machek, devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland, Rafał Miłecki From: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org> Some LEDs can be related to particular USB ports (common case for home routers). This property allows describing such a relation. Signed-off-by: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org> --- This patch is based on top of commit 52e847dc431 ("DT: leds: Improve examples by adding some context") sitting in the linux-leds.git (for-4.11). --- Documentation/devicetree/bindings/leds/common.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt index 24b6560..fcfe661 100644 --- a/Documentation/devicetree/bindings/leds/common.txt +++ b/Documentation/devicetree/bindings/leds/common.txt @@ -49,6 +49,14 @@ Optional properties for child nodes: - panic-indicator : This property specifies that the LED should be used, if at all possible, as a panic indicator. +- usb-ports : List of USB ports related to this LED. Some devices have LEDs that + should be used to indicate USB device activity. This can be + described with this property. + There can be more than one LED like this, e.g. some vendors use + one controller per USB version. It's then common to use different + color LEDs depending on device USB standard (like USB 2.0 vs. + USB 3.0). + Required properties for flash LED child nodes: - flash-max-microamp : Maximum flash LED supply current in microamperes. - flash-max-timeout-us : Maximum timeout in microseconds after which the flash @@ -69,6 +77,11 @@ gpio-leds { linux,default-trigger = "heartbeat"; gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>; }; + + usb { + gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>; + usb-ports = <&ohci_port1>, <&ehci_port1>; + }; }; max77693-led { -- 2.10.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <20161229130306.30400-1-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* [PATCH 2/2] usb: core: read USB ports from DT in the usbport LED trigger driver [not found] ` <20161229130306.30400-1-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2016-12-29 13:03 ` Rafał Miłecki 2017-01-03 20:52 ` [PATCH 1/2] dt-bindings: leds: document new usb-ports property Rob Herring 1 sibling, 0 replies; 5+ messages in thread From: Rafał Miłecki @ 2016-12-29 13:03 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-leds-u79uwXL29TY76Z2rM5mHXA, Richard Purdie, Jacek Anaszewski, Pavel Machek, devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland, Rafał Miłecki From: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org> This adds support for using description of relation between LEDs and USB ports from device tree. If device has a properly described LEDs, trigger will know when to turn them on. Signed-off-by: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org> --- drivers/usb/core/ledtrig-usbport.c | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/usb/core/ledtrig-usbport.c b/drivers/usb/core/ledtrig-usbport.c index 1713248..70ad558 100644 --- a/drivers/usb/core/ledtrig-usbport.c +++ b/drivers/usb/core/ledtrig-usbport.c @@ -11,8 +11,10 @@ #include <linux/device.h> #include <linux/leds.h> #include <linux/module.h> +#include <linux/of.h> #include <linux/slab.h> #include <linux/usb.h> +#include <linux/usb/of.h> struct usbport_trig_data { struct led_classdev *led_cdev; @@ -123,6 +125,55 @@ static const struct attribute_group ports_group = { * Adding & removing ports ***************************************/ +/** + * usbport_trig_port_observed - Check if port should be observed + */ +static bool usbport_trig_port_observed(struct usbport_trig_data *usbport_data, + struct usb_device *usb_dev, int port1) +{ + struct device *dev = usbport_data->led_cdev->dev; + struct device_node *led_np = dev->of_node; + struct of_phandle_args args; + struct device_node *port_np; + int count, i; + + if (!led_np) + return false; + + /* Get node of port being added */ + port_np = usb_of_get_child_node(usb_dev->dev.of_node, port1); + if (!port_np) + return false; + + /* Amount of ports this LED references */ + count = of_count_phandle_with_args(led_np, "usb-ports", NULL); + if (count < 0) { + dev_warn(dev, "Failed to get USB ports for %s\n", + led_np->full_name); + return false; + } + + /* Check if port is on this LED's list */ + for (i = 0; i < count; i++) { + int err; + + err = of_parse_phandle_with_args(led_np, "usb-ports", NULL, i, + &args); + if (err) { + dev_err(dev, "Failed to get USB port phandle at index %d: %d\n", + i, err); + continue; + } + + of_node_put(args.np); + + if (args.np == port_np) + return true; + } + + return false; +} + static int usbport_trig_add_port(struct usbport_trig_data *usbport_data, struct usb_device *usb_dev, const char *hub_name, int portnum) @@ -141,6 +192,8 @@ static int usbport_trig_add_port(struct usbport_trig_data *usbport_data, port->data = usbport_data; port->hub = usb_dev; port->portnum = portnum; + port->observed = usbport_trig_port_observed(usbport_data, usb_dev, + portnum); len = strlen(hub_name) + 8; port->port_name = kzalloc(len, GFP_KERNEL); @@ -255,6 +308,7 @@ static void usbport_trig_activate(struct led_classdev *led_cdev) if (err) goto err_free; usb_for_each_dev(usbport_data, usbport_trig_add_usb_dev_ports); + usbport_trig_update_count(usbport_data); /* Notifications */ usbport_data->nb.notifier_call = usbport_trig_notify, -- 2.10.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] dt-bindings: leds: document new usb-ports property [not found] ` <20161229130306.30400-1-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2016-12-29 13:03 ` [PATCH 2/2] usb: core: read USB ports from DT in the usbport LED trigger driver Rafał Miłecki @ 2017-01-03 20:52 ` Rob Herring 2017-01-04 6:33 ` Rafał Miłecki 1 sibling, 1 reply; 5+ messages in thread From: Rob Herring @ 2017-01-03 20:52 UTC (permalink / raw) To: Rafał Miłecki Cc: Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-leds-u79uwXL29TY76Z2rM5mHXA, Richard Purdie, Jacek Anaszewski, Pavel Machek, devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Rutland, Rafał Miłecki On Thu, Dec 29, 2016 at 02:03:04PM +0100, Rafał Miłecki wrote: > From: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org> > > Some LEDs can be related to particular USB ports (common case for home > routers). This property allows describing such a relation. > > Signed-off-by: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org> > --- > This patch is based on top of commit 52e847dc431 ("DT: leds: Improve examples > by adding some context") sitting in the linux-leds.git (for-4.11). > --- > Documentation/devicetree/bindings/leds/common.txt | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt > index 24b6560..fcfe661 100644 > --- a/Documentation/devicetree/bindings/leds/common.txt > +++ b/Documentation/devicetree/bindings/leds/common.txt > @@ -49,6 +49,14 @@ Optional properties for child nodes: > - panic-indicator : This property specifies that the LED should be used, > if at all possible, as a panic indicator. > > +- usb-ports : List of USB ports related to this LED. Some devices have LEDs that > + should be used to indicate USB device activity. This can be > + described with this property. > + There can be more than one LED like this, e.g. some vendors use > + one controller per USB version. It's then common to use different > + color LEDs depending on device USB standard (like USB 2.0 vs. > + USB 3.0). I don't like this being USB specific. Either we should have a generic way to link triggers to other DT nodes or the existing trigger property should be used (and be capable of listing more than 1 port). I'd prefer the latter as I don't think we need another way to specify triggers. > + > Required properties for flash LED child nodes: > - flash-max-microamp : Maximum flash LED supply current in microamperes. > - flash-max-timeout-us : Maximum timeout in microseconds after which the flash > @@ -69,6 +77,11 @@ gpio-leds { > linux,default-trigger = "heartbeat"; > gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>; > }; > + > + usb { > + gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>; > + usb-ports = <&ohci_port1>, <&ehci_port1>; > + }; > }; > > max77693-led { > -- > 2.10.1 > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] dt-bindings: leds: document new usb-ports property 2017-01-03 20:52 ` [PATCH 1/2] dt-bindings: leds: document new usb-ports property Rob Herring @ 2017-01-04 6:33 ` Rafał Miłecki 0 siblings, 0 replies; 5+ messages in thread From: Rafał Miłecki @ 2017-01-04 6:33 UTC (permalink / raw) To: Rob Herring Cc: Greg Kroah-Hartman, linux-usb, linux-leds, Richard Purdie, Jacek Anaszewski, Pavel Machek, devicetree, Mark Rutland, Rafał Miłecki On 01/03/2017 09:52 PM, Rob Herring wrote: > On Thu, Dec 29, 2016 at 02:03:04PM +0100, Rafał Miłecki wrote: >> From: Rafał Miłecki <rafal@milecki.pl> >> >> Some LEDs can be related to particular USB ports (common case for home >> routers). This property allows describing such a relation. >> >> Signed-off-by: Rafał Miłecki <rafal@milecki.pl> >> --- >> This patch is based on top of commit 52e847dc431 ("DT: leds: Improve examples >> by adding some context") sitting in the linux-leds.git (for-4.11). >> --- >> Documentation/devicetree/bindings/leds/common.txt | 13 +++++++++++++ >> 1 file changed, 13 insertions(+) >> >> diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt >> index 24b6560..fcfe661 100644 >> --- a/Documentation/devicetree/bindings/leds/common.txt >> +++ b/Documentation/devicetree/bindings/leds/common.txt >> @@ -49,6 +49,14 @@ Optional properties for child nodes: >> - panic-indicator : This property specifies that the LED should be used, >> if at all possible, as a panic indicator. >> >> +- usb-ports : List of USB ports related to this LED. Some devices have LEDs that >> + should be used to indicate USB device activity. This can be >> + described with this property. >> + There can be more than one LED like this, e.g. some vendors use >> + one controller per USB version. It's then common to use different >> + color LEDs depending on device USB standard (like USB 2.0 vs. >> + USB 3.0). > > I don't like this being USB specific. Either we should have a generic > way to link triggers to other DT nodes or the existing trigger property > should be used (and be capable of listing more than 1 port). I'd prefer > the latter as I don't think we need another way to specify triggers. Hi Rob & thanks for your review. Could you point me to "the existing trigger property" you meant, please? It's not clear to me, sorry. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [EXAMPLE 3/2] ARM: BCM53573: Specify ports for USB LED for Tenda AC9 2016-12-29 13:03 [PATCH 1/2] dt-bindings: leds: document new usb-ports property Rafał Miłecki [not found] ` <20161229130306.30400-1-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2016-12-29 13:03 ` Rafał Miłecki 1 sibling, 0 replies; 5+ messages in thread From: Rafał Miłecki @ 2016-12-29 13:03 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: linux-usb, linux-leds, Richard Purdie, Jacek Anaszewski, Pavel Machek, devicetree, Rob Herring, Mark Rutland, Rafał Miłecki From: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Rafał Miłecki <rafal@milecki.pl> --- This patch was tested & works as expected. It's marked as EXAMPLE just because it should go through ARM tree. --- arch/arm/boot/dts/bcm47189-tenda-ac9.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/boot/dts/bcm47189-tenda-ac9.dts b/arch/arm/boot/dts/bcm47189-tenda-ac9.dts index 4403ae8..00bbe48 100644 --- a/arch/arm/boot/dts/bcm47189-tenda-ac9.dts +++ b/arch/arm/boot/dts/bcm47189-tenda-ac9.dts @@ -24,6 +24,7 @@ compatible = "gpio-leds"; usb { + usb-ports = <&ohci_port1>, <&ehci_port1>; label = "bcm53xx:blue:usb"; gpios = <&chipcommon 1 GPIO_ACTIVE_HIGH>; linux,default-trigger = "default-off"; -- 2.10.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-04 6:33 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-12-29 13:03 [PATCH 1/2] dt-bindings: leds: document new usb-ports property Rafał Miłecki [not found] ` <20161229130306.30400-1-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2016-12-29 13:03 ` [PATCH 2/2] usb: core: read USB ports from DT in the usbport LED trigger driver Rafał Miłecki 2017-01-03 20:52 ` [PATCH 1/2] dt-bindings: leds: document new usb-ports property Rob Herring 2017-01-04 6:33 ` Rafał Miłecki 2016-12-29 13:03 ` [EXAMPLE 3/2] ARM: BCM53573: Specify ports for USB LED for Tenda AC9 Rafał Miłecki
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).