blob: 7e2803e3b83ec64e82988ed6befd75fdbbb7eca9 [file] [log] [blame]
Igor Grinberg2b8754b2011-04-18 17:54:33 -04001/*
Igor Grinberg811acf92013-04-22 01:06:53 +00002 * (C) Copyright 2011 - 2013 CompuLab, Ltd. <www.compulab.co.il>
Igor Grinberg2b8754b2011-04-18 17:54:33 -04003 *
4 * Author: Igor Grinberg <grinberg@compulab.co.il>
5 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Igor Grinberg2b8754b2011-04-18 17:54:33 -04007 */
Wolfgang Denk1a459662013-07-08 09:37:19 +02008
Igor Grinberg2b8754b2011-04-18 17:54:33 -04009#include <common.h>
10#include <status_led.h>
Sanjeev Premi84c3b632011-09-08 10:51:01 -040011#include <asm/gpio.h>
Igor Grinberg2b8754b2011-04-18 17:54:33 -040012
13static unsigned int leds[] = { GREEN_LED_GPIO };
14
15void __led_init(led_id_t mask, int state)
16{
Sanjeev Premi84c3b632011-09-08 10:51:01 -040017 if (gpio_request(leds[mask], "") != 0) {
Igor Grinberg2b8754b2011-04-18 17:54:33 -040018 printf("%s: failed requesting GPIO%u\n", __func__, leds[mask]);
19 return;
20 }
21
Sanjeev Premi84c3b632011-09-08 10:51:01 -040022 gpio_direction_output(leds[mask], 0);
Igor Grinberg2b8754b2011-04-18 17:54:33 -040023}
24
25void __led_set(led_id_t mask, int state)
26{
Sanjeev Premi84c3b632011-09-08 10:51:01 -040027 gpio_set_value(leds[mask], state == STATUS_LED_ON);
Igor Grinberg2b8754b2011-04-18 17:54:33 -040028}
29
30void __led_toggle(led_id_t mask)
31{
Sanjeev Premi84c3b632011-09-08 10:51:01 -040032 gpio_set_value(leds[mask], !gpio_get_value(leds[mask]));
Igor Grinberg2b8754b2011-04-18 17:54:33 -040033}