forked from Minki/linux
orion/kirkwood: create a generic function for gpio led blinking
dns323 and (at least) iconnect platforms are using hw led blinking, so, instead of having 2 identicals .gpio_blink_set gpio-led hooks, move dns323 code into gpio.c Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org> Tested-By: Adam Baker <linux@baker-net.org.uk> Signed-off-by: Jason Cooper <jason@lakedaemon.net>
This commit is contained in:
parent
92a486eabe
commit
ff3e660b5a
@ -253,27 +253,6 @@ error_fail:
|
|||||||
* GPIO LEDs (simple - doesn't use hardware blinking support)
|
* GPIO LEDs (simple - doesn't use hardware blinking support)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ORION_BLINK_HALF_PERIOD 100 /* ms */
|
|
||||||
|
|
||||||
static int dns323_gpio_blink_set(unsigned gpio, int state,
|
|
||||||
unsigned long *delay_on, unsigned long *delay_off)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (delay_on && delay_off && !*delay_on && !*delay_off)
|
|
||||||
*delay_on = *delay_off = ORION_BLINK_HALF_PERIOD;
|
|
||||||
|
|
||||||
switch(state) {
|
|
||||||
case GPIO_LED_NO_BLINK_LOW:
|
|
||||||
case GPIO_LED_NO_BLINK_HIGH:
|
|
||||||
orion_gpio_set_blink(gpio, 0);
|
|
||||||
gpio_set_value(gpio, state);
|
|
||||||
break;
|
|
||||||
case GPIO_LED_BLINK:
|
|
||||||
orion_gpio_set_blink(gpio, 1);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct gpio_led dns323ab_leds[] = {
|
static struct gpio_led dns323ab_leds[] = {
|
||||||
{
|
{
|
||||||
.name = "power:blue",
|
.name = "power:blue",
|
||||||
@ -312,13 +291,13 @@ static struct gpio_led dns323c_leds[] = {
|
|||||||
static struct gpio_led_platform_data dns323ab_led_data = {
|
static struct gpio_led_platform_data dns323ab_led_data = {
|
||||||
.num_leds = ARRAY_SIZE(dns323ab_leds),
|
.num_leds = ARRAY_SIZE(dns323ab_leds),
|
||||||
.leds = dns323ab_leds,
|
.leds = dns323ab_leds,
|
||||||
.gpio_blink_set = dns323_gpio_blink_set,
|
.gpio_blink_set = orion_gpio_led_blink_set,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct gpio_led_platform_data dns323c_led_data = {
|
static struct gpio_led_platform_data dns323c_led_data = {
|
||||||
.num_leds = ARRAY_SIZE(dns323c_leds),
|
.num_leds = ARRAY_SIZE(dns323c_leds),
|
||||||
.leds = dns323c_leds,
|
.leds = dns323c_leds,
|
||||||
.gpio_blink_set = dns323_gpio_blink_set,
|
.gpio_blink_set = orion_gpio_led_blink_set,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct platform_device dns323_gpio_leds = {
|
static struct platform_device dns323_gpio_leds = {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio.h>
|
||||||
|
#include <linux/leds.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPIO unit register offsets.
|
* GPIO unit register offsets.
|
||||||
@ -295,6 +296,28 @@ void orion_gpio_set_blink(unsigned pin, int blink)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(orion_gpio_set_blink);
|
EXPORT_SYMBOL(orion_gpio_set_blink);
|
||||||
|
|
||||||
|
#define ORION_BLINK_HALF_PERIOD 100 /* ms */
|
||||||
|
|
||||||
|
int orion_gpio_led_blink_set(unsigned gpio, int state,
|
||||||
|
unsigned long *delay_on, unsigned long *delay_off)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (delay_on && delay_off && !*delay_on && !*delay_off)
|
||||||
|
*delay_on = *delay_off = ORION_BLINK_HALF_PERIOD;
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case GPIO_LED_NO_BLINK_LOW:
|
||||||
|
case GPIO_LED_NO_BLINK_HIGH:
|
||||||
|
orion_gpio_set_blink(gpio, 0);
|
||||||
|
gpio_set_value(gpio, state);
|
||||||
|
break;
|
||||||
|
case GPIO_LED_BLINK:
|
||||||
|
orion_gpio_set_blink(gpio, 1);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(orion_gpio_led_blink_set);
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Orion GPIO IRQ
|
* Orion GPIO IRQ
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
*/
|
*/
|
||||||
void orion_gpio_set_unused(unsigned pin);
|
void orion_gpio_set_unused(unsigned pin);
|
||||||
void orion_gpio_set_blink(unsigned pin, int blink);
|
void orion_gpio_set_blink(unsigned pin, int blink);
|
||||||
|
int orion_gpio_led_blink_set(unsigned gpio, int state,
|
||||||
|
unsigned long *delay_on, unsigned long *delay_off);
|
||||||
|
|
||||||
#define GPIO_INPUT_OK (1 << 0)
|
#define GPIO_INPUT_OK (1 << 0)
|
||||||
#define GPIO_OUTPUT_OK (1 << 1)
|
#define GPIO_OUTPUT_OK (1 << 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user