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 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 7 | */ |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 8 | |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 9 | #include <common.h> |
| 10 | #include <status_led.h> |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 11 | #include <asm/gpio.h> |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 12 | |
| 13 | static unsigned int leds[] = { GREEN_LED_GPIO }; |
| 14 | |
| 15 | void __led_init(led_id_t mask, int state) |
| 16 | { |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 17 | if (gpio_request(leds[mask], "") != 0) { |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 18 | printf("%s: failed requesting GPIO%u\n", __func__, leds[mask]); |
| 19 | return; |
| 20 | } |
| 21 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 22 | gpio_direction_output(leds[mask], 0); |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | void __led_set(led_id_t mask, int state) |
| 26 | { |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 27 | gpio_set_value(leds[mask], state == STATUS_LED_ON); |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | void __led_toggle(led_id_t mask) |
| 31 | { |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 32 | gpio_set_value(leds[mask], !gpio_get_value(leds[mask])); |
Igor Grinberg | d2367bc | 2011-04-18 17:54:33 -0400 | [diff] [blame] | 33 | } |