Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 1 | /* |
Igor Grinberg | e83d229 | 2013-04-22 01:06:53 +0000 | [diff] [blame] | 2 | * (C) Copyright 2011 - 2013 CompuLab, Ltd. <www.compulab.co.il> |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 3 | * |
| 4 | * Author: Igor Grinberg <grinberg@compulab.co.il> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; either version 2 of |
| 9 | * the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc. |
| 19 | */ |
| 20 | #include <common.h> |
| 21 | #include <status_led.h> |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 22 | #include <asm/gpio.h> |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 23 | |
| 24 | static unsigned int leds[] = { GREEN_LED_GPIO }; |
| 25 | |
| 26 | void __led_init(led_id_t mask, int state) |
| 27 | { |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 28 | if (gpio_request(leds[mask], "") != 0) { |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 29 | printf("%s: failed requesting GPIO%u\n", __func__, leds[mask]); |
| 30 | return; |
| 31 | } |
| 32 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 33 | gpio_direction_output(leds[mask], 0); |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | void __led_set(led_id_t mask, int state) |
| 37 | { |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 38 | gpio_set_value(leds[mask], state == STATUS_LED_ON); |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | void __led_toggle(led_id_t mask) |
| 42 | { |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 43 | gpio_set_value(leds[mask], !gpio_get_value(leds[mask])); |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 44 | } |