2 * Copyright (C) 2010, 2009 Matthias Kaehlcke <matthias@kaehlcke.net>
4 * SPDX-License-Identifier: GPL-2.0+
8 #include <asm/arch/ep93xx.h>
10 #include <status_led.h>
12 static uint8_t saved_state[2] = {CONFIG_LED_STATUS_OFF, CONFIG_LED_STATUS_OFF};
13 static uint32_t gpio_pin[2] = {1 << CONFIG_LED_STATUS_GREEN,
14 1 << CONFIG_LED_STATUS_RED};
16 static inline void switch_LED_on(uint8_t led)
18 register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
20 writel(readl(&gpio->pedr) | gpio_pin[led], &gpio->pedr);
21 saved_state[led] = CONFIG_LED_STATUS_ON;
24 static inline void switch_LED_off(uint8_t led)
26 register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
28 writel(readl(&gpio->pedr) & ~gpio_pin[led], &gpio->pedr);
29 saved_state[led] = CONFIG_LED_STATUS_OFF;
34 switch_LED_on(CONFIG_LED_STATUS_RED);
37 void red_led_off(void)
39 switch_LED_off(CONFIG_LED_STATUS_RED);
42 void green_led_on(void)
44 switch_LED_on(CONFIG_LED_STATUS_GREEN);
47 void green_led_off(void)
49 switch_LED_off(CONFIG_LED_STATUS_GREEN);
52 void __led_init(led_id_t mask, int state)
54 __led_set(mask, state);
57 void __led_toggle(led_id_t mask)
59 if (CONFIG_LED_STATUS_RED == mask) {
60 if (CONFIG_LED_STATUS_ON == saved_state[CONFIG_LED_STATUS_RED])
64 } else if (CONFIG_LED_STATUS_GREEN == mask) {
65 if (CONFIG_LED_STATUS_ON ==
66 saved_state[CONFIG_LED_STATUS_GREEN])
73 void __led_set(led_id_t mask, int state)
75 if (CONFIG_LED_STATUS_RED == mask) {
76 if (CONFIG_LED_STATUS_ON == state)
80 } else if (CONFIG_LED_STATUS_GREEN == mask) {
81 if (CONFIG_LED_STATUS_ON == state)