]>
Commit | Line | Data |
---|---|---|
9cc83378 SM |
1 | /* |
2 | * (C) Copyright 2004, Psyent Corporation <www.psyent.com> | |
3 | * Scott McNutt <smcnutt@psyent.com> | |
4 | * | |
1a459660 | 5 | * SPDX-License-Identifier: GPL-2.0+ |
9cc83378 SM |
6 | */ |
7 | ||
8 | #include <common.h> | |
9 | #include <asm/io.h> | |
10 | #include <nios2-io.h> | |
11 | #include <status_led.h> | |
12 | ||
13 | /* The LED port is configured as output only, so we | |
14 | * must track the state manually. | |
15 | */ | |
16 | static led_id_t val = 0; | |
17 | ||
18 | void __led_init (led_id_t mask, int state) | |
19 | { | |
6d0f6bcf | 20 | nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR; |
9cc83378 SM |
21 | |
22 | if (state == STATUS_LED_ON) | |
23 | val &= ~mask; | |
24 | else | |
25 | val |= mask; | |
3ea0037f | 26 | writel (val, &pio->data); |
9cc83378 SM |
27 | } |
28 | ||
29 | void __led_set (led_id_t mask, int state) | |
30 | { | |
6d0f6bcf | 31 | nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR; |
9cc83378 SM |
32 | |
33 | if (state == STATUS_LED_ON) | |
34 | val &= ~mask; | |
35 | else | |
36 | val |= mask; | |
3ea0037f | 37 | writel (val, &pio->data); |
9cc83378 SM |
38 | } |
39 | ||
40 | void __led_toggle (led_id_t mask) | |
41 | { | |
6d0f6bcf | 42 | nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR; |
9cc83378 SM |
43 | |
44 | val ^= mask; | |
3ea0037f | 45 | writel (val, &pio->data); |
9cc83378 | 46 | } |