* Leds @ 2008-02-08 10:02 Marco Stornelli 2008-02-08 10:20 ` Leds Simon Kagstrom 0 siblings, 1 reply; 5+ messages in thread From: Marco Stornelli @ 2008-02-08 10:02 UTC (permalink / raw) To: LinuxPPC-Embedded Hi all, how can specify a led device in a dts file? These leds are connected with gpio to the microprocessor. I can't find anything like a led node in the dts files of the other boards. Have you got any suggestions? Regards, Marco ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Leds 2008-02-08 10:02 Leds Marco Stornelli @ 2008-02-08 10:20 ` Simon Kagstrom 2008-02-08 10:43 ` Leds Marco Stornelli 2008-02-08 19:43 ` Leds Grant Likely 0 siblings, 2 replies; 5+ messages in thread From: Simon Kagstrom @ 2008-02-08 10:20 UTC (permalink / raw) To: Marco Stornelli; +Cc: LinuxPPC-Embedded Hi Marco, On Fri, 08 Feb 2008 11:02:16 +0100 Marco Stornelli <marco.stornelli@coritel.it> wrote: > how can specify a led device in a dts file? These leds are connected > with gpio to the microprocessor. I can't find anything like a led node > in the dts files of the other boards. Have you got any suggestions? Although I'm not sure if it's the "standard" way, we just added a "home-made" node like this: resetLED@c0018000 { device_type = "leds"; compatible = "reset-leds"; reg = <c0018000 00008000>; }; and then just get the info in the probe function for the led driver we placed in drivers/leds/: /* Get device info from OF tree */ np = of_find_compatible_node(NULL, "leds", "reset-leds"); if (!np) { dev_err(&pdev->dev, "Could not find device tree node for reset-leds\n"); goto error_classdev; } if (of_address_to_resource(np, 0, &res)) { dev_err(&pdev->dev, "Could not convert reset-leds device tree address\n"); of_node_put(np); goto error_classdev; } ... At least this was all the information we needed from the device tree. // Simon ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Leds 2008-02-08 10:20 ` Leds Simon Kagstrom @ 2008-02-08 10:43 ` Marco Stornelli 2008-02-08 11:26 ` Leds Simon Kagstrom 2008-02-08 19:43 ` Leds Grant Likely 1 sibling, 1 reply; 5+ messages in thread From: Marco Stornelli @ 2008-02-08 10:43 UTC (permalink / raw) To: LinuxPPC-Embedded Simon Kagstrom ha scritto: > Hi Marco, > > On Fri, 08 Feb 2008 11:02:16 +0100 > Marco Stornelli <marco.stornelli@coritel.it> wrote: > >> how can specify a led device in a dts file? These leds are connected >> with gpio to the microprocessor. I can't find anything like a led node >> in the dts files of the other boards. Have you got any suggestions? > > Although I'm not sure if it's the "standard" way, we just added a > "home-made" node like this: > > resetLED@c0018000 { > device_type = "leds"; > compatible = "reset-leds"; > reg = <c0018000 00008000>; > }; > > and then just get the info in the probe function for the led driver > we placed in drivers/leds/: > > /* Get device info from OF tree */ > np = of_find_compatible_node(NULL, "leds", "reset-leds"); > if (!np) { > dev_err(&pdev->dev, "Could not find device tree node for reset-leds\n"); > goto error_classdev; > } > > if (of_address_to_resource(np, 0, &res)) { > dev_err(&pdev->dev, "Could not convert reset-leds device tree address\n"); > of_node_put(np); > goto error_classdev; > } > ... > > At least this was all the information we needed from the device tree. > > // Simon > Thanks. In this case where have you added the device registration? In the probe function? Have you registered the driver with of_register_platform_driver()? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Leds 2008-02-08 10:43 ` Leds Marco Stornelli @ 2008-02-08 11:26 ` Simon Kagstrom 0 siblings, 0 replies; 5+ messages in thread From: Simon Kagstrom @ 2008-02-08 11:26 UTC (permalink / raw) To: Marco Stornelli; +Cc: LinuxPPC-Embedded On Fri, 08 Feb 2008 11:43:25 +0100 Marco Stornelli <marco.stornelli@coritel.it> wrote: > > Although I'm not sure if it's the "standard" way, we just added a > > "home-made" node like this: > > > > resetLED@c0018000 { > > device_type = "leds"; > > compatible = "reset-leds"; > > reg = <c0018000 00008000>; > > }; > > > Thanks. In this case where have you added the device registration? In > the probe function? Have you registered the driver with > of_register_platform_driver()? We put it in the module init function and registered it as a platform device: static int __init led_init(void) { int ret; ret = platform_driver_register(&led_driver); if (ret < 0) return -ENODEV; pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); if (IS_ERR(pdev)) { ret = PTR_ERR(pdev); platform_driver_unregister(&led_driver); } return ret; } And just use the device tree stuff to read out the device address. The driver itself is quite similar to other led drivers found in the same directory, so you can probably base your work on those. This was for kernel 2.6.21, I'm not sure if these things have changed for newer kernels (although I would guess most of it is the same). // Simon ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Leds 2008-02-08 10:20 ` Leds Simon Kagstrom 2008-02-08 10:43 ` Leds Marco Stornelli @ 2008-02-08 19:43 ` Grant Likely 1 sibling, 0 replies; 5+ messages in thread From: Grant Likely @ 2008-02-08 19:43 UTC (permalink / raw) To: Simon Kagstrom; +Cc: Marco Stornelli, LinuxPPC-Embedded On Feb 8, 2008 3:20 AM, Simon Kagstrom <simon.kagstrom@ericsson.com> wrote: > Hi Marco, > > On Fri, 08 Feb 2008 11:02:16 +0100 > Marco Stornelli <marco.stornelli@coritel.it> wrote: > > > how can specify a led device in a dts file? These leds are connected > > with gpio to the microprocessor. I can't find anything like a led node > > in the dts files of the other boards. Have you got any suggestions? > > Although I'm not sure if it's the "standard" way, we just added a > "home-made" node like this: > > resetLED@c0018000 { > device_type = "leds"; > compatible = "reset-leds"; > reg = <c0018000 00008000>; > }; I've been thinking about this a bit over the last couple of months, and I think that there is a better way. Since many LEDs are simply hooked up to GPIO blocks and we're moving towards a common GPIO api (and device tree binding), I think it would be better to use two nodes; a node for the gpio block and a node for all the LEDs in the system. For example (the GPIO dt bindings may differ from my example here, but you get the gist): GPIO0: gpio-controller@1418 { #gpio-cells = <2>; compatible = "fsl,qe-pario-bank"; reg = <0x1418 0x18>; gpio-controller; }; GPIO1: gpio-controller@1460 { #gpio-cells = <2>; compatible = "fsl,qe-pario-bank"; reg = <0x1460 0x18>; gpio-controller; }; leds@0 { compatible = "gpio-leds"; led-labels = "led1", "led2", "led3", "led4"; gpios = <&GPIO0 2 0 /* LED1 */ &GPIO0 3 0 /* LED2 */ &GPIO1 8 0 /* LED3 */ &GPIO1 9 0 /* LED4 */ >; /* More properties are probably needed here to correctly setup the output levels */ }; Doing it this way means the GPIO block will be usable for more than just LEDs. Plus once the 'gpio-leds' driver is written leds can be hooked up almost trivially on new boards. Cheers, g. -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-02-08 19:43 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-02-08 10:02 Leds Marco Stornelli 2008-02-08 10:20 ` Leds Simon Kagstrom 2008-02-08 10:43 ` Leds Marco Stornelli 2008-02-08 11:26 ` Leds Simon Kagstrom 2008-02-08 19:43 ` Leds Grant Likely
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).