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