Re: Registering GPIO LEDs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/08/2013 09:08 PM, Kim, Milo wrote:
> From the viewpoint of a GPIO consumer, we don't care the base GPIO number.
> That is required when a GPIO controller is added.
> Just check '/sys/kernel/debug/gpio' and use available GPIOs for LEDs.

Hmm.  I'm using leds-gpio, and it certainly does seem to care about GPIO
numbers.  As a point of reference, here's what I'm doing to set up my
drive activity LEDs:

#define N5550_ICH_GPIO_BASE     195

#define N5550_DISK_ACT_0_GPIO   (N5550_ICH_GPIO_BASE + 0)
#define N5550_DISK_ACT_1_GPIO   (N5550_ICH_GPIO_BASE + 2)
#define N5550_DISK_ACT_2_GPIO   (N5550_ICH_GPIO_BASE + 3)
#define N5550_DISK_ACT_3_GPIO   (N5550_ICH_GPIO_BASE + 4)
#define N5550_DISK_ACT_4_GPIO   (N5550_ICH_GPIO_BASE + 5)

static struct gpio_led n5550_disk_act_leds[5] = {
        {
                .name                   = "n5550:green:disk-act-0",
                .default_trigger        = "thecus-ahci-0",
                .gpio                   = N5550_DISK_ACT_0_GPIO,
                .active_low             = 1,
                .default_state          = LEDS_GPIO_DEFSTATE_OFF,
        },
        {
                .name                   = "n5550:green:disk-act-1",
                .default_trigger        = "thecus-ahci-1",
                .gpio                   = N5550_DISK_ACT_1_GPIO,
                .active_low             = 1,
                .default_state          = LEDS_GPIO_DEFSTATE_OFF,
        },
        {
                .name                   = "n5550:green:disk-act-2",
                .default_trigger        = "thecus-ahci-2",
                .gpio                   = N5550_DISK_ACT_2_GPIO,
                .active_low             = 1,
                .default_state          = LEDS_GPIO_DEFSTATE_OFF,
        },
        {
                .name                   = "n5550:green:disk-act-3",
                .default_trigger        = "thecus-ahci-3",
                .gpio                   = N5550_DISK_ACT_3_GPIO,
                .active_low             = 1,
                .default_state          = LEDS_GPIO_DEFSTATE_OFF,
        },
        {
                .name                   = "n5550:green:disk-act-4",
                .default_trigger        = "thecus-ahci-4",
                .gpio                   = N5550_DISK_ACT_4_GPIO,
                .active_low             = 1,
                .default_state          = LEDS_GPIO_DEFSTATE_OFF,
        },
};

As you can see, every LED has a GPIO number (.gpio), which comes from
the chip's GPIO base, and that number gets hardcoded into the setup
code.  If the ich_gpio driver ever "dynamically" selects a base other
than 195, the LEDs won't work.

I just seems very fragile, and I can't help thinking that there must be
a better way.  Maybe a module parameter ...

Thanks!

-- 
========================================================================
Ian Pilcher                                         arequipeno@xxxxxxxxx
Sometimes there's nothing left to do but crash and burn...or die trying.
========================================================================
--
To unsubscribe from this list: send the line "unsubscribe linux-leds" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux