best way to handle LEDs
Subsystems (3)
Hi!
Handheld machines have limited number of software-controlled status LEDs. Collie, for example has two of them; one is labeled "charge" and second is labeled "mail".
At least the "mail" led should be handled from userspace, and it would be nice if (at least) different speeds of blinking could be used -- original Sharp ROM uses at least:
yellow off: not charging
yellow on: charging
yellow fast blink: charge error
I think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Is that acceptable, or should some other interface be used?
Pavel
arch/arm/Kconfig +2 -0
@@ -244,6 +244,8 @@ source "arch/arm/mach-versatile/Kconfig" source "arch/arm/mach-aaec2000/Kconfig" +source "drivers/leds/Kconfig" + # Definitions to make life easier config ARCH_ACORN bool
drivers/Kconfig +2 -0
@@ -54,6 +54,8 @@ source "drivers/mfd/Kconfig" source "drivers/media/Kconfig" +source "drivers/leds/Kconfig" + source "drivers/video/Kconfig" source "sound/Kconfig"
drivers/Makefile +1 -0
@@ -67,3 +67,4 @@ obj-$(CONFIG_INFINIBAND) += infiniband/ obj-$(CONFIG_SGI_IOC4) += sn/ obj-y += firmware/ obj-$(CONFIG_CRYPTO) += crypto/ +obj-$(CONFIG_CLASS_LEDS) += leds/
drivers/leds/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ + +menu "LED devices" + +config CLASS_LEDS + tristate "LED support" + help + This option provides the generic support for the leds class. + LEDs can be accessed from /sys/class/leds. It will also allow you + to select individual drivers for LED devices. If unsure, say N. + +config LEDS_LOCOMO + tristate "LED Support for Locomo device" + depends CLASS_LEDS && SHARP_LOCOMO + help + This option enables support for the LEDs on Sharp Locomo. + Zaurus models SL-5500 and SL-5600. + +endmenu +
drivers/leds/Makefile new file +4 -0
@@ -0,0 +1,4 @@ + +# Core functionality. +obj-$(CONFIG_CLASS_LEDS) += ledscore.o +obj-$(CONFIG_LEDS_LOCOMO) += locomo.o
drivers/leds/ledscore.c new file +460 -0
460 lines not on this page · raw message
drivers/leds/locomo.c new file +124 -0
124 lines not on this page · raw message
include/linux/leds.h new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
Thanks, Sharp!
Quoted 9 lines · Pavel Machek
Handheld machines have limited number of software-controlled status LEDs. Collie, for example has two of them; one is labeled "charge" and second is labeled "mail".
I think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Is that acceptable, or should some other interface be used?
This has been discussed before and I know there are several differing opinions.
Based upon previous discussion both here, on linux-arm-kernel and in the handhelds community in general I came up with some ideas which I've yet to have time to code. I'll try and describe it though:
The system would be in two sections (classes?), leds themselves and led triggers. The leds would be driven by something similar to John's driver Pavel attached. I think colour and other unchanging properties of the device should be something exported in the device name which could have some format like: device_name-colour-otherprops.
Led triggers would be kernel sources of led on/off events. Some examples:
2Hz Heartbeat - useful for debugging (and/or Generic Timer) CPU Load indicator
Charging indicator
HDD activity (useful for microdrive on handheld) Network activity
no doubt many more
led triggers would be connected to leds via sysfs. Each trigger would probably have a number you could echo into an led's trigger attribute. Sensible default mappings could be had by assigning a default trigger to a device by name in the platform code that declares the led.
A trigger of "0" would mean the led becomes under userspace control via sysfs for whatever userspace wishes to do with it.
The underlying principle would be to keep this class as simple as possible whilst maximising the options open for triggering the leds from both the kernel and userspace.
Does this sound like a sensible way forward?
Richard
Quoted 18 lines · Richard Purdie
Quoted 9 lines · Pavel Machek
Handheld machines have limited number of software-controlled status LEDs. Collie, for example has two of them; one is labeled "charge" and second is labeled "mail".
I think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Is that acceptable, or should some other interface be used?
This has been discussed before and I know there are several differing opinions.
Based upon previous discussion both here, on linux-arm-kernel and in the handhelds community in general I came up with some ideas which I've yet to have time to code. I'll try and describe it though:
Quoted 5 lines
The system would be in two sections (classes?), leds themselves and led triggers. The leds would be driven by something similar to John's driver Pavel attached. I think colour and other unchanging properties of the device should be something exported in the device name which could have some format like: device_name-colour-otherprops.
I believe that this can be built on top of my patch. If you take a look at the led patch Pavel posted, it allows for in kernel code to acquire the led by calling leds_acquire. Once a led is acquired through leds_acquire function, any input from userspace is ignored.
Any interested kernel code can also register an interface to watch for led additions and removals.
Quoted 5 lines
Led triggers would be kernel sources of led on/off events. Some examples:
2Hz Heartbeat - useful for debugging (and/or Generic Timer)
This is included already in the leds driver part, although it could be removed I guess...
Quoted 5 lines
CPU Load indicator
Charging indicator
HDD activity (useful for microdrive on handheld)
Network activity
no doubt many more
All these are great ideas for triggers.
Quoted 5 lines
led triggers would be connected to leds via sysfs. Each trigger would probably have a number you could echo into an led's trigger attribute. Sensible default mappings could be had by assigning a default trigger to a device by name in the platform code that declares the led.
This would be part of the triggers module... passing the right stuff into those sysfs options would cause the triggers module to call leds_acquire on the right led_properties structure.
Quoted 3 lines
A trigger of "0" would mean the led becomes under userspace control via sysfs for whatever userspace wishes to do with it.
A trigger of "0" would call leds_release, which would cause the input from userspace in the leds driver to be accepted again.
Quoted 7 lines
The underlying principle would be to keep this class as simple as possible whilst maximising the options open for triggering the leds from both the kernel and userspace.
Does this sound like a sensible way forward?
I think it can already be done from my patch... all the functions are already there for in kernel manipulation.
John
Quoted 7 lines · Richard Purdie
led triggers would be connected to leds via sysfs. Each trigger would probably have a number you could echo into an led's trigger attribute. Sensible default mappings could be had by assigning a default trigger to a device by name in the platform code that declares the led.
A trigger of "0" would mean the led becomes under userspace control via sysfs for whatever userspace wishes to do with it.
Any reason to represent the triggers as numbers in sysfs? I'm a fan of how the IO scheduler is chosen on a block device. The file looks like:
noop [anticipatory] deadline cfq
You get a list of all available triggers, which one is active (and it's easy enough for user space code to parse). Obviously, to select a trigger, you just write its name to the file. Instead of 0, you say user, etc...
Cheers,
Chase Venters
Hi!
Quoted 10 lines
Led triggers would be kernel sources of led on/off events. Some examples:
2Hz Heartbeat - useful for debugging (and/or Generic Timer) CPU Load indicator
Charging indicator
HDD activity (useful for microdrive on handheld) Network activity
no doubt many more
Quoted 4 lines
led triggers would be connected to leds via sysfs. Each trigger would probably have a number you could echo into an led's trigger attribute. Sensible default mappings could be had by assigning a default trigger to a device by name in the platform code that declares the led.
Perhaps I'd keep it simple and leave it at
* do hardcoded kernel action for this led
or
* do whatever userspace tells you.
That way you will not be able to remap charger LED onto hard disk indicator, but we can support that on ibm-acpi too. (Where hw controls LEDs like "sleep", but lets you control them. You can't remap, though).
Pavel
Signature · 1 line
Thanks, Sharp!
Quoted 19 lines · Pavel Machek
Quoted 10 lines
Led triggers would be kernel sources of led on/off events. Some examples:
2Hz Heartbeat - useful for debugging (and/or Generic Timer) CPU Load indicator
Charging indicator
HDD activity (useful for microdrive on handheld) Network activity
no doubt many moreQuoted 4 lines
led triggers would be connected to leds via sysfs. Each trigger would probably have a number you could echo into an led's trigger attribute. Sensible default mappings could be had by assigning a default trigger to a device by name in the platform code that declares the led.
Perhaps I'd keep it simple and leave it at
* do hardcoded kernel action for this led
Quoted 8 lines
or
* do whatever userspace tells you.
That way you will not be able to remap charger LED onto hard disk indicator, but we can support that on ibm-acpi too. (Where hw controls LEDs like "sleep", but lets you control them. You can't remap, though).
Then the arguments start about which function should be hardcoded to which leds and why can't userspace access these triggers?
I'd prefer a totally flexible system and it doesn't really add much complexity once you have a trigger framework which we're going to need to handle mutiple led trigger sources sanely anyway.
Richard
Hi!
Quoted 8 lines
Quoted 8 lines
Perhaps I'd keep it simple and leave it at
* do hardcoded kernel action for this led
or
* do whatever userspace tells you.
Quoted 7 lines
Quoted 4 lines
That way you will not be able to remap charger LED onto hard disk indicator, but we can support that on ibm-acpi too. (Where hw controls LEDs like "sleep", but lets you control them. You can't remap, though).
Then the arguments start about which function should be hardcoded to which leds and why can't userspace access these triggers?
Because there are some machines (IBM thinkpad) where LEDs are either driven by userspace, or driven by hardware. I'd like to export that functionality using same interface.
Quoted 3 lines
I'd prefer a totally flexible system and it doesn't really add much complexity once you have a trigger framework which we're going to need to handle mutiple led trigger sources sanely anyway.
Unfortunately hardware can not do that, at least for IBM thinkpad. Plus, remapping harddisk indicator on battery led is not something I'd like to support :-).
Pavel
Signature · 1 line
Thanks, Sharp!
Quoted 13 lines · Pavel Machek
Quoted 13 lines
Quoted 12 lines
Perhaps I'd keep it simple and leave it at
* do hardcoded kernel action for this led
or
* do whatever userspace tells you.
That way you will not be able to remap charger LED onto hard disk indicator, but we can support that on ibm-acpi too. (Where hw controls LEDs like "sleep", but lets you control them. You can't remap, though).
Quoted 6 lines
Quoted 2 lines
Then the arguments start about which function should be hardcoded to which leds and why can't userspace access these triggers?
Because there are some machines (IBM thinkpad) where LEDs are either driven by userspace, or driven by hardware. I'd like to export that functionality using same interface.
A specific limitation of ACPI LEDs shouldn't constrain the interface and spoil things for everything that can support generic triggers.
Quoted 6 lines
Quoted 3 lines
I'd prefer a totally flexible system and it doesn't really add much complexity once you have a trigger framework which we're going to need to handle mutiple led trigger sources sanely anyway.
Unfortunately hardware can not do that, at least for IBM thinkpad.
So we need to find a way of providing this functionality, maybe by allowing leds to provide their own specific triggers. Thinking about this limitation, I think it can be handled by the trigger implementation.
Quoted 2 lines
Plus, remapping harddisk indicator on battery led is not something I'd like to support :-).
It wouldn't do that be default but I see no reason to constrain any interface to stop this. The kernel isn't supposed to set policy (or in my view put unnecessary constraints on interfaces).
Richard
Quoted 1 line · In article <[email protected]> you wrote:
+static
ssize_tleds_store_frequency(struct class_device *dev, const char *buf, size_t size)
how about using a on and a off timer, so you can set up 50,50 or 10,90 or stuff like that to make different pulse.
I know the TI avalanch platform has a quite complicated led driver, which I think is much overworked since it allows led settings based on logical states. This should all be in userspace.
Gruss
Bernd
Quoted 5 lines · root
Quoted 1 line · In article <[email protected]> you wrote:
+static
ssize_tleds_store_frequency(struct class_device *dev, const char *buf, size_t size)how about using a on and a off timer, so you can set up 50,50 or 10,90 or stuff like that to make different pulse.
Or the heartbeat that goes faster if load average increases, as is already implemented on some archs?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 14 lines · Pavel Machek
Hi!
Handheld machines have limited number of software-controlled status LEDs. Collie, for example has two of them; one is labeled "charge" and second is labeled "mail".
At least the "mail" led should be handled from userspace, and it would be nice if (at least) different speeds of blinking could be used -- original Sharp ROM uses at least:
yellow off: not charging
yellow on: charging
yellow fast blink: charge error
Quoted 5 lines
I think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Is that acceptable, or should some other interface be used?
there is already an LED interface for linux-arm, which is used by a number of the extant machines in the sa11x0 and pxa range.
Signature · 3 lines
Ben ([email protected], http://www.fluff.org/) 'a smiley only costs 4 bytes'
Quoted 9 lines · On Wed, 2 Nov 2005 02:47:55 +0000 Ben Dooks <[email protected]> wrote:
Quoted 5 lines
I think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Is that acceptable, or should some other interface be used?
there is already an LED interface for linux-arm, which is used by a number of the extant machines in the sa11x0 and pxa range.
Hello,
the current interface is very low-level, while the proposal
from Pavel/John has a much different scope, imho.
I'm working on a led driver for the ixp4xx/NSLU2 which
has 2 leds plus a multi-coloured one.
We would benefit a lot from such an implementation so,
FWIW, I express my personal support and the one of the whole nslu2-linux community.
Once this patch is upstream, the linux-arm interface could easily
be adapted to use it or cooperate nicely.
Signature · 6 lines
Best regards, Alessandro Zummo, Tower Technologies - Turin, Italy http://www.towertech.it
Hi!
Quoted 9 lines
Quoted 5 lines
I think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Is that acceptable, or should some other interface be used?
there is already an LED interface for linux-arm, which is used by a number of the extant machines in the sa11x0 and pxa range.
Where is that interface? I think that making collie use it is obvious first step...
Pavel
Signature · 1 line
Thanks, Sharp!
Quoted 8 lines · Pavel Machek
Hi!
Quoted 6 lines
Quoted 5 lines
I think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Is that acceptable, or should some other interface be used?
Quoted 8 lines
Quoted 3 lines
there is already an LED interface for linux-arm, which is used by a number of the extant machines in the sa11x0 and pxa range.
Where is that interface? I think that making collie use it is obvious first step...
Pavel
I originally wrote the collie led code to use that interface, and you might look at some of the old versions of the patch on my web site. The actual code is in arch/arm/kernel/time.c, but this code calls out to an individual machine function through say arch/arm/mach-sa1100/leds.c... The problem for collie was that the device model for locomo did not allow an easy way to do it... as you can see, in my patch it implements a driver for those leds and the driver model takes care of it.
I just looked, and
http://www.cs.wisc.edu/~lenz/zaurus/files/patch-2.6.7-jl2.diff.gz contins the implementation of the arm led interface for collie.... not sure if it will still work anymore, but...
I then grew the led code to support more than four leds, multi color leds, more than just the arm architecture, etc... Russell has been very critical of my patch on the "waste" of memory (a struct device for each led, along with a bunch of struct attributes for each led), where by contrast the arm one has a single attribute.
But this led interface and the one arm provides can almost not even be compared. My patch correctly implements the sysfs model of one attribute, one file (instead of all leds controlled through a single file). My patch also is more flexible and provides needed options for many leds. The downside is, it makes the leds hard to use for debugging, which is the primary purpose of the original arm led code.
For debugging, the arm specific led code is a great tool, and I am not meaning to replace it. For debugging, you can just specifiy CONFIG_CLASS_LEDS=n.
John
Hi!
Quoted 21 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Is that acceptable, or should some other interface be used?
there is already an LED interface for linux-arm, which is used by a number of the extant machines in the sa11x0 and pxa range.
Where is that interface? I think that making collie use it is obvious first step...
I originally wrote the collie led code to use that interface, and you might look at some of the old versions of the patch on my web site. The actual code is in
arch/arm/kernel/time.c, but this code calls out to an individual machine function through sayarch/arm/mach-sa1100/leds.c... The problem for collie was that the device model for locomo did not allow an easy way to do it... as you can see, in my patch it implements a driver for those leds and the driver model takes care of it.
Quoted 4 lines
I just looked, and
http://www.cs.wisc.edu/~lenz/zaurus/files/patch-2.6.7-jl2.diff.gz contins the implementation of the arm led interface for collie.... not sure if it will still work anymore, but...
It does, after kconfig fixups. Do you think we could get that merged? Some led driver is better than none at all.
---
Simple collie LED driver, by John Lenz.
arch/arm/Kconfig +6 -3
@@ -408,7 +408,8 @@ config LEDS ARCH_EBSA285 || ARCH_IMX || ARCH_INTEGRATOR || \ ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_NETWINDER || \ ARCH_OMAP || ARCH_P720T || ARCH_PXA_IDP || \ - ARCH_SA1100 || ARCH_SHARK || ARCH_VERSATILE + ARCH_SA1100 || ARCH_SHARK || ARCH_VERSATILE || \ + SA1100_COLLIE help If you say Y here, the LEDs on your machine will be used to provide useful information about your current system status.
@@ -422,7 +423,8 @@ config LEDS config LEDS_TIMER bool "Timer LED" if (!ARCH_CDB89712 && !ARCH_OMAP) || \ - MACH_OMAP_H2 || MACH_OMAP_PERSEUS2 + MACH_OMAP_H2 || MACH_OMAP_PERSEUS2 || \\ + SA1100_COLLIE depends on LEDS default y if ARCH_EBSA110 help
@@ -438,7 +440,8 @@ config LEDS_TIMER config LEDS_CPU bool "CPU usage LED" if (!ARCH_CDB89712 && !ARCH_EBSA110 && \ - !ARCH_OMAP) || MACH_OMAP_H2 || MACH_OMAP_PERSEUS2 + !ARCH_OMAP) || MACH_OMAP_H2 || MACH_OMAP_PERSEUS2 || \ + SA1100_COLLIE depends on LEDS help If you say Y here, the red LED will be used to give a good real
arch/arm/mach-sa1100/Makefile +1 -0
@@ -26,6 +26,7 @@ led-$(CONFIG_SA1100_CERF) += leds-cerf. obj-$(CONFIG_SA1100_COLLIE) += collie.o #obj-$(CONFIG_SA1100_COLLIE) += battery-collie.o obj-$(CONFIG_SA1100_COLLIE) += collie_batswitch.o +obj-$(CONFIG_SA1100_COLLIE) += leds-collie.o obj-$(CONFIG_SA1100_H3600) += h3600.o
arch/arm/mach-sa1100/leds-collie.c new file +126 -0
126 lines not on this page · raw message
arch/arm/mach-sa1100/leds.c +2 -0
@@ -26,6 +26,8 @@ sa1100_leds_init(void) leds_event = brutus_leds_event;if (machine_is_cerf ()) leds_event = cerf_leds_event; +if (machine_is_collie ()) + leds_event = collie_leds_event;if (machine_is_flexanet ()) leds_event = flexanet_leds_event;if (machine_is_graphicsclient ())
arch/arm/mach-sa1100/leds.h +1 -0
@@ -3,6 +3,7 @@ extern void badge4_leds_event(led_event_extern void consus_leds_event (led_event_t evt);extern void brutus_leds_event (led_event_t evt);extern void cerf_leds_event (led_event_t evt); +extern void collie_leds_event (led_event_t evt);extern void flexanet_leds_event (led_event_t evt);extern void graphicsclient_leds_event (led_event_t evt);extern void hackkit_leds_event (led_event_t evt);
Signature · 1 line
Thanks, Sharp!
Quoted 34 lines · Pavel Machek
Hi!
Quoted 25 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
I think even slow blinking was used somewhere. I have some code
from
Quoted 1 line
Quoted 1 line
Quoted 1 line
John Lenz (attached); it uses sysfs interface, exports led collor,
and
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
allows setting different frequencies.
Is that acceptable, or should some other interface be used?
there is already an LED interface for linux-arm, which is used by a number of the extant machines in the sa11x0 and pxa range.
Where is that interface? I think that making collie use it is obvious first step...
I originally wrote the collie led code to use that interface, and you might look at some of the old versions of the patch on my web site. The actual code is in
arch/arm/kernel/time.c, but this code calls out to an individual machine function through sayarch/arm/mach-sa1100/leds.c... The problem for collie was that the device model for locomo did not allow
an easy way to do it... as you can see, in my patch it implements a driver
for those leds and the driver model takes care of it.Quoted 6 lines
I just looked, and
http://www.cs.wisc.edu/~lenz/zaurus/files/patch-2.6.7-jl2.diff.gz
contins
the implementation of the arm led interface for collie.... not sure if it
will still work anymore, but...
Quoted 2 lines
It does, after kconfig fixups. Do you think we could get that merged? Some led driver is better than none at all.
I wonder, because we are exporting an API to userspace. I don't think the openembedded people want to use this API, and will hold off doing anything with the leds till we get something else straigtend out. If we have this API now, we will have issues breaking it later (or we will have to do some wierd locking scheme to allow both interfaces control, and crap like that).
Secondly, leds aren't that importent unless they are supported by the userspace programs (to do things like blink when email shows up). And before the userspace starts using leds, I think they might want to clear up the interface API issue first.
John
Hi!
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines
I just looked, and
http://www.cs.wisc.edu/~lenz/zaurus/files/patch-2.6.7-jl2.diff.gz
contins
the implementation of the arm led interface for collie.... not sure if it
will still work anymore, but...It does, after kconfig fixups. Do you think we could get that merged? Some led driver is better than none at all.
Quoted 6 lines
I wonder, because we are exporting an API to userspace. I don't think the openembedded people want to use this API, and will hold off doing anything with the leds till we get something else straigtend out. If we have this API now, we will have issues breaking it later (or we will have to do some wierd locking scheme to allow both interfaces control, and crap like that).
* they are 9 users of "old" interface already, one more does not seem like a big deal.
* arm maintainer does not want anything more complex than "old" interface. And I can see his point. It is not clear if "new" interface will get into mainline.
* there are very little users of collie, currently. Changing LED API on myself does not seem like a big deal. [I'm trying hard to get _two more_ users :-)]
* if openembedded people do not like current interface, they should a) convince rmk API needs to change and b) convert all the drivers.
Quoted 4 lines
Secondly, leds aren't that importent unless they are supported by the userspace programs (to do things like blink when email shows up). And before the userspace starts using leds, I think they might want to clear up the interface API issue first.
I'd say charger LED is somehow important, and I liked CPU usage LED a lot.
Pavel
Signature · 1 line
Thanks, Sharp!
Quoted 14 lines · Pavel Machek
* they are 9 users of "old" interface already, one more does not seem like a big deal.
* arm maintainer does not want anything more complex than "old" interface. And I can see his point. It is not clear if "new" interface will get into mainline.
* there are very little users of collie, currently. Changing LED API on myself does not seem like a big deal. [I'm trying hard to get
_twomore_users :-)]* if openembedded people do not like current interface, they should a) convince rmk API needs to change and b) convert all the drivers.
Quoted 6 lines
Quoted 4 lines
Secondly, leds aren't that importent unless they are supported by the userspace programs (to do things like blink when email shows up). And before the userspace starts using leds, I think they might want to clear up the interface API issue first.
I'd say charger LED is somehow important, and I liked CPU usage LED a lot.
You can implement the charger LED without needing to implement any led interface, as the sharpsl_pm charger code does. For now the charge led is hard coded (but easily changed later to become a trigger).
My rough plan is to implement the led trigger code and present this along with a modified version of John's sysfs class code to LKML. If accepted, great (and there was a demand for a standard interface from various quarters). If not, I'll offer it as a patch series outside of the kernel as openembedded, opie, gpe and handhelds.org are likely to use it regardless of what LKML thinks. We can then see how its usage becomes. The only change I will ask for is that the CONFIG_LEDS namespace as used by ARM is reconsidered.
Both John and myself have resisted putting any LED code into mainline as we don't feel the existing interfaces match Zaurus developer's and user's needs. To submit such patches would suggest we planned to support the existing interfaces which we do not.
I agree with John's point about changing API's as if LED code gets added, developers and users may start using it which we don't want to happen until we have an API we're happy with.
Richard
Hi!
Quoted 19 lines
Quoted 19 lines
* they are 9 users of "old" interface already, one more does not seem like a big deal.
* arm maintainer does not want anything more complex than "old" interface. And I can see his point. It is not clear if "new" interface will get into mainline.
* there are very little users of collie, currently. Changing LED API on myself does not seem like a big deal. [I'm trying hard to get
_twomore_users :-)]* if openembedded people do not like current interface, they should a) convince rmk API needs to change and b) convert all the drivers.
Quoted 4 lines
Secondly, leds aren't that importent unless they are supported by the userspace programs (to do things like blink when email shows up). And before the userspace starts using leds, I think they might want to clear up the interface API issue first.
Quoted 5 lines
Quoted 1 line
I'd say charger LED is somehow important, and I liked CPU usage LED a lot.
You can implement the charger LED without needing to implement any led interface, as the
sharpsl_pmcharger code does. For now the charge led is hard coded (but easily changed later to become a trigger).
Yes, it can be done.
Quoted 8 lines
My rough plan is to implement the led trigger code and present this along with a modified version of John's sysfs class code to LKML. If accepted, great (and there was a demand for a standard interface from various quarters). If not, I'll offer it as a patch series outside of the kernel as openembedded, opie, gpe and handhelds.org are likely to use it regardless of what LKML thinks. We can then see how its usage becomes. The only change I will ask for is that the
CONFIG_LEDSnamespace as used by ARM is reconsidered.
Well, if it is accepted by LKML, fine. [I did not realize someone is actually working on it].
If it is rejected, tough, I believe openembedded etc. should just use official interface.
Quoted 4 lines
Both John and myself have resisted putting any LED code into mainline as we don't feel the existing interfaces match Zaurus developer's and user's needs. To submit such patches would suggest we planned to support the existing interfaces which we do not.
Ok, I guess it all depends on LMKL and rmk's reaction. If LED layer is rejected, I'd rather have something that can handle the simple case. Hopefully enough cases (handhelds, IBM special leds, ...) are there and LED layer gets accepted.
Pavel
Signature · 1 line
Thanks, Sharp!
Quoted 12 lines · Pavel Machek
Handheld machines have limited number of software-controlled status LEDs. Collie, for example has two of them; one is labeled "charge" and second is labeled "mail".
At least the "mail" led should be handled from userspace, and it would be nice if (at least) different speeds of blinking could be used -- original Sharp ROM uses at least:
yellow off: not charging
yellow on: charging
yellow fast blink: charge error
Quoted 6 lines
I think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Is that acceptable, or should some other interface be used?
I would also be in favour of having a more generic interface for something like this (as opposed to each architecture rolling their own).
For example, sh currently has a very simplistic framework in place where LED manipulation is done via a heartbeat callback in the machvec for each timer tick, so it would be nice to have things somewhat more flexible in this regard (especially for boards with multi-coloured LEDs, and for userspace input).
Quoted 12 lines · Pavel Machek
Handheld machines have limited number of software-controlled status LEDs. Collie, for example has two of them; one is labeled "charge" and second is labeled "mail".
At least the "mail" led should be handled from userspace, and it would be nice if (at least) different speeds of blinking could be used -- original Sharp ROM uses at least:
yellow off: not charging
yellow on: charging
yellow fast blink: charge error
Quoted 5 lines
I think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Is that acceptable, or should some other interface be used?
IMHO reducing digital outputs to LEDs goes not far enough. All System- on-Chip CPUs have General Purpose I/O pins today, which can act as inputs or outputs and may be used for LEDs, matrix keyboard lines, we even use them as shutdown lines for DC/DC converters in Linux based power controllers for autonomous measurement systems. I think a framework for LEDs should be based upon a low level infrastrucutre for GPIOs. I've written such a thing some time ago, it has been discussed in
http://marc.theaimsgroup.com/?l=linux-kernel&m=109419621428925&w=2
Unfortunately, I didn't have time to take care of that stuff yet and port them to recent kernels :-(
Robert
Signature · 5 lines
Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
Pengutronix - Linux Solutions for Science and Industry
Handelsregister: Amtsgericht Hildesheim, HRA 2686
Hannoversche Str. 2, 31134 Hildesheim, Germany
Phone: +49-5121-206917-0 | Fax: +49-5121-206917-9Hi!
Quoted 8 lines
Quoted 8 lines
yellow off: not charging
yellow on: charging
yellow fast blink: charge errorI think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Quoted 5 lines
Quoted 1 line
Is that acceptable, or should some other interface be used?
IMHO reducing digital outputs to LEDs goes not far enough. All System- on-Chip CPUs have General Purpose I/O pins today, which can act as inputs or outputs and may be used for LEDs, matrix keyboard lines,
We have some leds that are *not* on GPIO pins (like driven by ACPI). We'd like to support those, too.
Pavel
Signature · 1 line
Thanks, Sharp!
Quoted 2 lines · Pavel Machek
We have some leds that are *not* on GPIO pins (like driven by ACPI). We'd like to support those, too.
One more argument to have a LED framework which sits ontop of a lowlevel one.
Robert
Signature · 5 lines
Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
Pengutronix - Linux Solutions for Science and Industry
Handelsregister: Amtsgericht Hildesheim, HRA 2686
Hannoversche Str. 2, 31134 Hildesheim, Germany
Phone: +49-5121-206917-0 | Fax: +49-5121-206917-9Quoted 7 lines · Robert Schwebel
Quoted 2 lines · Pavel Machek
We have some leds that are *not* on GPIO pins (like driven by ACPI). We'd like to support those, too.
One more argument to have a LED framework which sits ontop of a lowlevel one.
Except the led code that is being proposed CAN sit on top of a generic GPIO layer. If a generic GPIO layer is created, you can create a led driver that calls out to that GPIO layer.
You just need to fill in the following functions with some that raise and lower the GPIO on the correct line....
int (*color_get)(struct device *, struct led_properties *props); void (*color_set)(struct device *, struct led_properties *props, int value);
int (*brightness_get)(struct device *, struct led_properties *props); void (*brightness_set)(struct device *, struct led_properties *props, int value);
John
Quoted 7 lines · John Lenz
Except the led code that is being proposed CAN sit on top of a generic GPIO layer. If a generic GPIO layer is created, you can create a led driver that calls out to that GPIO layer.
You just need to fill in the following functions with some that raise and lower the GPIO on the correct line....
Quoted 6 lines
int (*color_get)(struct device *, struct
led_properties*props); void (*color_set)(struct device *, structled_properties*props, int value);int (*brightness_get)(struct device *, struct
led_properties*props); void (*brightness_set)(struct device *, structled_properties*props, int value);
Ok, great! I'll see that I update my patch for 2.6.14.
Robert
Signature · 5 lines
Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
Pengutronix - Linux Solutions for Science and Industry
Handelsregister: Amtsgericht Hildesheim, HRA 2686
Hannoversche Str. 2, 31134 Hildesheim, Germany
Phone: +49-5121-206917-0 | Fax: +49-5121-206917-9Quoted 11 lines · John Lenz
Quoted 7 lines · Robert Schwebel
Quoted 2 lines · Pavel Machek
We have some leds that are *not* on GPIO pins (like driven by ACPI). We'd like to support those, too.
One more argument to have a LED framework which sits ontop of a lowlevel one.
Except the led code that is being proposed CAN sit on top of a generic GPIO layer.
I also have issues with a generic GPIO layer. As I mentioned in the past, there's serious locking issues with any generic abstraction of GPIOs.
1. You want to be able to change GPIO state from interrupts. This implies you can not sleep in GPIO state changing functions.
2. Some GPIOs are implemented on I2C devices. This means that to change state, you must sleep.
(1) and (2) are incompatible requirements, so you can not offer a generic interface for these GPIOs which has a consistent behaviour - where users of the interface know whether the function may sleep or may be used from interrupt context.
If you also consider that LEDs may be connected to these GPIOs, and you may wish to change their state from interrupt context, you also run into these same issues - you have an interface which has ill- defined behaviour and ill-defined calling requirements.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Hi!
Quoted 7 lines
Quoted 2 lines
Except the led code that is being proposed CAN sit on top of a generic GPIO layer.
I also have issues with a generic GPIO layer. As I mentioned in the past, there's serious locking issues with any generic abstraction of GPIOs.
Quoted 5 lines
1. You want to be able to change GPIO state from interrupts. This implies you can not sleep in GPIO state changing functions.
2. Some GPIOs are implemented on I2C devices. This means that to change state, you must sleep.
Can't you just busywait? Yes, it is ugly in general, but perhaps it is better than alternatives...
Signature · 1 line
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms
Quoted 9 lines · Pavel Machek
Hi!
Quoted 7 lines
Quoted 2 lines
Except the led code that is being proposed CAN sit on top of a generic GPIO layer.
I also have issues with a generic GPIO layer. As I mentioned in the past, there's serious locking issues with any generic abstraction of GPIOs.
Quoted 8 lines
Quoted 5 lines
1. You want to be able to change GPIO state from interrupts. This implies you can not sleep in GPIO state changing functions.
2. Some GPIOs are implemented on I2C devices. This means that to change state, you must sleep.
Can't you just busywait? Yes, it is ugly in general, but perhaps it is better than alternatives...
Does the i2c layer support busy waiting or are you suggesting something else?
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Quoted 13 lines · Russell King
Quoted 12 lines · Pavel Machek
Hi!
Quoted 10 lines
Quoted 2 lines
Except the led code that is being proposed CAN sit on top of a generic GPIO layer.
I also have issues with a generic GPIO layer. As I mentioned in the past, there's serious locking issues with any generic abstraction of GPIOs.
1. You want to be able to change GPIO state from interrupts. This implies you can not sleep in GPIO state changing functions.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
2. Some GPIOs are implemented on I2C devices. This means that to change state, you must sleep.
Can't you just busywait? Yes, it is ugly in general, but perhaps it is better than alternatives...
Does the i2c layer support busy waiting or are you suggesting something else?
It usually doesn't support anything else. At least on the controllers I've seen the drivers for.
Signature · 2 lines
Vojtech Pavlik SuSE Labs, SuSE CR
Quoted 17 lines · Vojtech Pavlik
Quoted 16 lines · Russell King
Quoted 15 lines · Pavel Machek
Hi!
Quoted 12 lines
Quoted 2 lines
Except the led code that is being proposed CAN sit on top of a generic GPIO layer.
I also have issues with a generic GPIO layer. As I mentioned in the past, there's serious locking issues with any generic abstraction of GPIOs.
1. You want to be able to change GPIO state from interrupts. This implies you can not sleep in GPIO state changing functions.
2. Some GPIOs are implemented on I2C devices. This means that to change state, you must sleep.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Can't you just busywait? Yes, it is ugly in general, but perhaps it is better than alternatives...
Does the i2c layer support busy waiting or are you suggesting something else?
It usually doesn't support anything else. At least on the controllers I've seen the drivers for.
I think you misunderstand me. Please read:
http://dictionary.reference.com/search?q=busywait
Since the i2c transfer functions allow drivers to sleep (and some do) you can't "just busywait" without modifying the i2c layer to tell drivers to busy wait instead of sleeping.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Quoted 7 lines · Russell King
I think you misunderstand me. Please read:
http://dictionary.reference.com/search?q=busywait
Since the i2c transfer functions allow drivers to sleep (and some do) you can't "just busywait" without modifying the i2c layer to tell drivers to busy wait instead of sleeping.
Agreed.
Signature · 2 lines
Vojtech Pavlik SuSE Labs, SuSE CR
Quoted 31 lines · Russell King
Quoted 17 lines · Vojtech Pavlik
Quoted 16 lines · Russell King
Quoted 15 lines · Pavel Machek
Hi!
Quoted 12 lines
Quoted 2 lines
Except the led code that is being proposed CAN sit on top of a generic GPIO layer.
I also have issues with a generic GPIO layer. As I mentioned in the past, there's serious locking issues with any generic abstraction of GPIOs.
1. You want to be able to change GPIO state from interrupts. This implies you can not sleep in GPIO state changing functions.
2. Some GPIOs are implemented on I2C devices. This means that to change state, you must sleep.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Can't you just busywait? Yes, it is ugly in general, but perhaps it is better than alternatives...
Does the i2c layer support busy waiting or are you suggesting something else?
It usually doesn't support anything else. At least on the controllers I've seen the drivers for.
I think you misunderstand me. Please read:
Quoted 8 lines
Since the i2c transfer functions allow drivers to sleep (and some do) you can't "just busywait" without modifying the i2c layer to tell drivers to busy wait instead of sleeping.
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
The whole thing is pretty easy. The interrupt code just signals a task to do whatever...
For example:
Interrupt service routine or anything else, sets the value in 'what' and 'which'. It then executes (in demo code) wake_up_interruptible(info->twait); ... and coutinues whatever it was doing. The daemon wakes up (whenever) and, in process-context does whatever was you wanted it to do.
extern void turn_led_on(int led); // Can sleep
extern void turn_len_off(int len); // Can sleep
enum WHAT {
TURN_LED_ON,
TURN_LED_OFF,
FLASH_LED,
STOP_FLASH };static WHAT what;
static int which;
static int local_kernel_thread(void *unused) {
daemonize(name);
for(;;) {
set_current_state(TASK_INTERRUPTIBLE);
if(signal_pending(current))
complete_and_exit(&info->quit, 0);
interruptible_sleep_on(&info->twait);
set_current_state(TASK_RUNNING);
preempt_disable(); // So we get this done soon
switch(what) {
case TURN_LED_ON:
turn_led_on(which);
break;
case TURN_LEN_OFF:
turn_led_off(which);
break;
case FLASH_LED:
start_timer_queue_for_flashing_led(which); // Can sleep
break;
case STOP_FLASH:
stop_timer_queue_for_flashing_led(which); // Can sleep
break;
default:
printk("Brain fart\n");
}
preempt_enable();
}
return 0;
}You never want to busy-wait for some "bells and whistles". You just make a bells-and-whistles kernel daemon that does whatever you want.
Cheers,
Dick Johnson
Penguin : Linux version 2.6.13.4 on an i686 machine (5589.55 BogoMips). Warning : 98.36% of all statistics are fiction.
.
****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.
Thank you.
Hi!
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
Except the led code that is being proposed CAN sit on top of a generic GPIO layer.
I also have issues with a generic GPIO layer. As I mentioned in the past, there's serious locking issues with any generic abstraction of GPIOs.
1. You want to be able to change GPIO state from interrupts. This implies you can not sleep in GPIO state changing functions.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
2. Some GPIOs are implemented on I2C devices. This means that to change state, you must sleep.
Can't you just busywait? Yes, it is ugly in general, but perhaps it is better than alternatives...
Does the i2c layer support busy waiting or are you suggesting something else?
I'm suggesting that adding busy wait support to i2c is probably good idea. GPIOs are on many small machines, and there are machine (spitz/akita?) that differ mainly in "where GPIO lines are connected". That cries for GPIO layer.
Pavel
Signature · 1 line
Thanks, Sharp!
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 23 lines · Pavel Machek
Hi!
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
Except the led code that is being proposed CAN sit on top of a generic GPIO layer.
I also have issues with a generic GPIO layer. As I mentioned in the past, there's serious locking issues with any generic abstraction of GPIOs.
1. You want to be able to change GPIO state from interrupts. This implies you can not sleep in GPIO state changing functions.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
2. Some GPIOs are implemented on I2C devices. This means that to change state, you must sleep.
Can't you just busywait? Yes, it is ugly in general, but perhaps it is better than alternatives...
Does the i2c layer support busy waiting or are you suggesting something else?
Quoted 5 lines
I'm suggesting that adding busy wait support to i2c is probably good idea. GPIOs are on many small machines, and there are machine (spitz/akita?) that differ mainly in "where GPIO lines are connected". That cries for GPIO layer.
Pavel
Wouldn't it make sense to make either two register functions or one that takes an extra argument?
register_led(.., .., ..)
andregister_led_irq(.., .., ..)
?
Then register_led() will call register_gpio() andregister_led_irq() will call register_gpio_irq().
If the low level driver (and everything else) can't be put into busywaiting mode the register_gpio_irq() will fail which will make register_led_irq() fail.
Naturally it can beregister_led(.., .., ..., use_irq)
andregister_gpio(.., .., .., use_irq)
I haven't looked at the API's so this is just theoretical on my behalf, but it should solve some issues.
If a driver really really can't be busywait for some reason then it will fail, otherwise it will switch to busywaiting instead of sleeping.
Or am I just talking out of my ass?
// Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFDaq4yBrn2kJu9P78RAuh7AJ4wK/+xoMYyfdOXEtY0+LqMNxYuuACgtuDH GhjBeXxbnW2SaQ4x7hlZg6w=
=hl/m
-----END PGP SIGNATURE-----
Quoted 8 lines · Russell King
I also have issues with a generic GPIO layer. As I mentioned in the past, there's serious locking issues with any generic abstraction of GPIOs.
1. You want to be able to change GPIO state from interrupts. This implies you can not sleep in GPIO state changing functions.
Quoted 8 lines
2. Some GPIOs are implemented on I2C devices. This means that to change state, you must sleep.
(1) and (2) are incompatible requirements, so you can not offer a generic interface for these GPIOs which has a consistent behaviour - where users of the interface know whether the function may sleep or may be used from interrupt context.
So you have a request_gpio API, where you specify usage characteristics and get back a handle?
cheers, Rich.
Signature · 4 lines
rich walker | Shadow Robot Company | [email protected] technical director 251 Liverpool Road | need a Hand? London N1 1LX | +UK 20 7700 2487 www.shadow.org.uk/products/newhand.shtml
Quoted 6 lines · Robert Schwebel
Quoted 2 lines · Pavel Machek
We have some leds that are *not* on GPIO pins (like driven by ACPI). We'd like to support those, too.
One more argument to have a LED framework which sits ontop of a lowlevel one.
In which case, why not submit the standalone LED framework now and shoehorn the low-level one underneath later. From a userspace API perspective, it really shouldn't matter...
Rob
Quoted 8 lines · Pavel Machek
Quoted 8 lines
Quoted 8 lines
yellow off: not charging
yellow on: charging
yellow fast blink: charge errorI think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Is that acceptable, or should some other interface be used?
IMHO reducing digital outputs to LEDs goes not far enough. All System- on-Chip CPUs have General Purpose I/O pins today, which can act as inputs or outputs and may be used for LEDs, matrix keyboard lines,
We have some leds that are *not* on GPIO pins (like driven by ACPI). We'd like to support those, too.
I though ACPI was software? These LEDs have to be driven by some hardware, right?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi!
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 9 lines
yellow off: not charging
yellow on: charging
yellow fast blink: charge errorI think even slow blinking was used somewhere. I have some code from John Lenz (attached); it uses sysfs interface, exports led collor, and allows setting different frequencies.
Is that acceptable, or should some other interface be used?
IMHO reducing digital outputs to LEDs goes not far enough. All System- on-Chip CPUs have General Purpose I/O pins today, which can act as inputs or outputs and may be used for LEDs, matrix keyboard lines,
Quoted 5 lines
Quoted 2 lines
We have some leds that are *not* on GPIO pins (like driven by ACPI). We'd like to support those, too.
I though ACPI was software? These LEDs have to be driven by some hardware, right?
Right, but you don't know by *which* hardware. Only ACPI AML code knows. So from linux POW, they are handled by ACPI.
It may even trap to SMM BIOS.
Signature · 1 line
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms