2011-04-19 06:54:33 +09:00
|
|
|
/*
|
2013-04-22 10:06:53 +09:00
|
|
|
* (C) Copyright 2011 - 2013 CompuLab, Ltd. <www.compulab.co.il>
|
2011-04-19 06:54:33 +09:00
|
|
|
*
|
|
|
|
* Author: Igor Grinberg <grinberg@compulab.co.il>
|
|
|
|
*
|
2013-07-08 16:37:19 +09:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2011-04-19 06:54:33 +09:00
|
|
|
*/
|
2013-07-08 16:37:19 +09:00
|
|
|
|
2011-04-19 06:54:33 +09:00
|
|
|
#include <common.h>
|
|
|
|
#include <status_led.h>
|
2011-09-08 23:51:01 +09:00
|
|
|
#include <asm/gpio.h>
|
2011-04-19 06:54:33 +09:00
|
|
|
|
|
|
|
static unsigned int leds[] = { GREEN_LED_GPIO };
|
|
|
|
|
|
|
|
void __led_init(led_id_t mask, int state)
|
|
|
|
{
|
2011-09-08 23:51:01 +09:00
|
|
|
if (gpio_request(leds[mask], "") != 0) {
|
2011-04-19 06:54:33 +09:00
|
|
|
printf("%s: failed requesting GPIO%u\n", __func__, leds[mask]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-09-08 23:51:01 +09:00
|
|
|
gpio_direction_output(leds[mask], 0);
|
2011-04-19 06:54:33 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
void __led_set(led_id_t mask, int state)
|
|
|
|
{
|
2011-09-08 23:51:01 +09:00
|
|
|
gpio_set_value(leds[mask], state == STATUS_LED_ON);
|
2011-04-19 06:54:33 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
void __led_toggle(led_id_t mask)
|
|
|
|
{
|
2011-09-08 23:51:01 +09:00
|
|
|
gpio_set_value(leds[mask], !gpio_get_value(leds[mask]));
|
2011-04-19 06:54:33 +09:00
|
|
|
}
|