1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2010, 2009 Matthias Kaehlcke <matthias@kaehlcke.net>
7 #include <asm/arch/ep93xx.h>
9 #include <status_led.h>
11 static uint8_t saved_state[2] = {CONFIG_LED_STATUS_OFF, CONFIG_LED_STATUS_OFF};
12 static uint32_t gpio_pin[2] = {1 << CONFIG_LED_STATUS_GREEN,
13 1 << CONFIG_LED_STATUS_RED};
15 static inline void switch_LED_on(uint8_t led)
17 register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
19 writel(readl(&gpio->pedr) | gpio_pin[led], &gpio->pedr);
20 saved_state[led] = CONFIG_LED_STATUS_ON;
23 static inline void switch_LED_off(uint8_t led)
25 register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
27 writel(readl(&gpio->pedr) & ~gpio_pin[led], &gpio->pedr);
28 saved_state[led] = CONFIG_LED_STATUS_OFF;
33 switch_LED_on(CONFIG_LED_STATUS_RED);
36 void red_led_off(void)
38 switch_LED_off(CONFIG_LED_STATUS_RED);
41 void green_led_on(void)
43 switch_LED_on(CONFIG_LED_STATUS_GREEN);
46 void green_led_off(void)
48 switch_LED_off(CONFIG_LED_STATUS_GREEN);
51 void __led_init(led_id_t mask, int state)
53 __led_set(mask, state);
56 void __led_toggle(led_id_t mask)
58 if (CONFIG_LED_STATUS_RED == mask) {
59 if (CONFIG_LED_STATUS_ON == saved_state[CONFIG_LED_STATUS_RED])
63 } else if (CONFIG_LED_STATUS_GREEN == mask) {
64 if (CONFIG_LED_STATUS_ON ==
65 saved_state[CONFIG_LED_STATUS_GREEN])
72 void __led_set(led_id_t mask, int state)
74 if (CONFIG_LED_STATUS_RED == mask) {
75 if (CONFIG_LED_STATUS_ON == state)
79 } else if (CONFIG_LED_STATUS_GREEN == mask) {
80 if (CONFIG_LED_STATUS_ON == state)