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