Hello everyone - I am developing an embedded ppc system using a 2.4 series kernel and I have a question regarding hardware drivers. I have 4 LEDs connected to a GPIO port. Each LED is controlled by a bit on the I/O port - set a bit to zero to turn the LED on, set the bit to one to turn the LED off. The state of the bits are readable, so read-modify-write works. The GPIO port is implemented with a Xilinx IP module and I have a driver available. The Xilinx driver supports multiple GPIO ports. I have a driver available for the heartbeat LED ('status_led' by Wolfgang Denk) that works. Now to the question: I wish to use one of the four LEDs as a 'heartbeat' and the remainder as user LEDs. Since all LEDs are accessed using the same hardware resource, the Linux heartbeat driver and the user GPIO driver will have to arbitrate. I would like to separate the status led (heartbeat) driver from the GPIO driver as much as I can. Is there an effective approach for doing this? I think I could brute-force things by simply combining the GPIO and status LED drivers and then tell the 'unified' driver which LED to use as the heartbeat, but that approach eliminates the benefits of using existing drivers 'as-is', among other things. I'm thinking that what I need to be able to do is give each driver access to a mutex that the drivers can then use to coordinate access to the hardware, but I'm not sure how to set up the mutex or where to put the code that does the initialization and mapping for the hardware access.
Keith