blob: 3fedddc8b5a10829e43db3625108773d4933ffc5 [file] [log] [blame]
Thomas Chou3e6b86b2010-04-30 11:34:14 +08001/*
2 * Status LED driver based on GPIO access conventions of Linux
3 *
4 * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
Thomas Chouec3b4982010-06-09 13:32:46 +08005 * Licensed under the GPL-2 or later.
Thomas Chou3e6b86b2010-04-30 11:34:14 +08006 */
7
8#include <common.h>
9#include <status_led.h>
10#include <asm/gpio.h>
11
Thomas Chou3e6b86b2010-04-30 11:34:14 +080012void __led_init(led_id_t mask, int state)
13{
Thomas Chouec3b4982010-06-09 13:32:46 +080014 gpio_request(mask, "gpio_led");
15 gpio_direction_output(mask, state == STATUS_LED_ON);
Thomas Chou3e6b86b2010-04-30 11:34:14 +080016}
17
18void __led_set(led_id_t mask, int state)
19{
Thomas Chouec3b4982010-06-09 13:32:46 +080020 gpio_set_value(mask, state == STATUS_LED_ON);
Thomas Chou3e6b86b2010-04-30 11:34:14 +080021}
22
23void __led_toggle(led_id_t mask)
24{
25 gpio_set_value(mask, !gpio_get_value(mask));
26}