2004-10-10 21:27:30 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2004, Psyent Corporation <www.psyent.com>
|
|
|
|
* Scott McNutt <smcnutt@psyent.com>
|
|
|
|
*
|
2013-10-07 11:07:26 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2004-10-10 21:27:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2006-06-08 16:03:21 +00:00
|
|
|
#include <asm/io.h>
|
2004-10-10 21:27:30 +00:00
|
|
|
#include <nios2-io.h>
|
|
|
|
#include <status_led.h>
|
|
|
|
|
|
|
|
/* The LED port is configured as output only, so we
|
|
|
|
* must track the state manually.
|
|
|
|
*/
|
|
|
|
static led_id_t val = 0;
|
|
|
|
|
|
|
|
void __led_init (led_id_t mask, int state)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR;
|
2004-10-10 21:27:30 +00:00
|
|
|
|
|
|
|
if (state == STATUS_LED_ON)
|
|
|
|
val &= ~mask;
|
|
|
|
else
|
|
|
|
val |= mask;
|
2010-03-22 01:24:43 +00:00
|
|
|
writel (val, &pio->data);
|
2004-10-10 21:27:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void __led_set (led_id_t mask, int state)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR;
|
2004-10-10 21:27:30 +00:00
|
|
|
|
|
|
|
if (state == STATUS_LED_ON)
|
|
|
|
val &= ~mask;
|
|
|
|
else
|
|
|
|
val |= mask;
|
2010-03-22 01:24:43 +00:00
|
|
|
writel (val, &pio->data);
|
2004-10-10 21:27:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void __led_toggle (led_id_t mask)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR;
|
2004-10-10 21:27:30 +00:00
|
|
|
|
|
|
|
val ^= mask;
|
2010-03-22 01:24:43 +00:00
|
|
|
writel (val, &pio->data);
|
2004-10-10 21:27:30 +00:00
|
|
|
}
|