blob: 580d590f2a7068dbc0848772156beb92cd4ac4d4 [file] [log] [blame]
wdenk5c952cf2004-10-10 21:27:30 +00001/*
2 * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
3 * Scott McNutt <smcnutt@psyent.com>
4 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenk5c952cf2004-10-10 21:27:30 +00006 */
7
8#include <common.h>
Scott McNutt3d22d0b2006-06-08 12:03:21 -04009#include <asm/io.h>
wdenk5c952cf2004-10-10 21:27:30 +000010#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 */
16static led_id_t val = 0;
17
18void __led_init (led_id_t mask, int state)
19{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020020 nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR;
wdenk5c952cf2004-10-10 21:27:30 +000021
22 if (state == STATUS_LED_ON)
23 val &= ~mask;
24 else
25 val |= mask;
Scott McNutt3ea00372010-03-21 21:24:43 -040026 writel (val, &pio->data);
wdenk5c952cf2004-10-10 21:27:30 +000027}
28
29void __led_set (led_id_t mask, int state)
30{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020031 nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR;
wdenk5c952cf2004-10-10 21:27:30 +000032
33 if (state == STATUS_LED_ON)
34 val &= ~mask;
35 else
36 val |= mask;
Scott McNutt3ea00372010-03-21 21:24:43 -040037 writel (val, &pio->data);
wdenk5c952cf2004-10-10 21:27:30 +000038}
39
40void __led_toggle (led_id_t mask)
41{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020042 nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR;
wdenk5c952cf2004-10-10 21:27:30 +000043
44 val ^= mask;
Scott McNutt3ea00372010-03-21 21:24:43 -040045 writel (val, &pio->data);
wdenk5c952cf2004-10-10 21:27:30 +000046}