2009-03-27 22:26:43 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2006
|
|
|
|
* Atmel Nordic AB <www.atmel.com>
|
|
|
|
* Ulf Samuelsson <ulf@atmel.com>
|
|
|
|
*
|
2010-10-18 20:58:29 +00:00
|
|
|
* (C) Copyright 2010
|
2016-05-01 01:46:16 +00:00
|
|
|
* Andreas Bießmann <andreas@biessmann.org>
|
2010-10-18 20:58:29 +00:00
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2009-03-27 22:26:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2011-02-19 06:17:02 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/hardware.h>
|
2016-02-03 02:16:50 +00:00
|
|
|
#include <asm/arch/clk.h>
|
2011-02-19 06:17:02 +00:00
|
|
|
#include <asm/arch/at91_pio.h>
|
2014-10-08 20:57:53 +00:00
|
|
|
#include <status_led.h>
|
2009-03-27 22:26:43 +00:00
|
|
|
|
2010-10-18 20:58:29 +00:00
|
|
|
/* bit mask in PIO port B */
|
|
|
|
#define GREEN_LED (1<<0)
|
|
|
|
#define YELLOW_LED (1<<1)
|
|
|
|
#define RED_LED (1<<2)
|
2009-03-27 22:26:43 +00:00
|
|
|
|
2011-09-04 18:40:16 +00:00
|
|
|
void green_led_on(void)
|
2009-03-27 22:26:43 +00:00
|
|
|
{
|
2011-02-19 06:17:02 +00:00
|
|
|
at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
|
2010-10-18 20:58:29 +00:00
|
|
|
writel(GREEN_LED, &pio->piob.codr);
|
2009-03-27 22:26:43 +00:00
|
|
|
}
|
|
|
|
|
2011-09-04 18:40:16 +00:00
|
|
|
void yellow_led_on(void)
|
2009-03-27 22:26:43 +00:00
|
|
|
{
|
2011-02-19 06:17:02 +00:00
|
|
|
at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
|
2010-10-18 20:58:29 +00:00
|
|
|
writel(YELLOW_LED, &pio->piob.codr);
|
2009-03-27 22:26:43 +00:00
|
|
|
}
|
|
|
|
|
2011-09-04 18:40:16 +00:00
|
|
|
void red_led_on(void)
|
2009-03-27 22:26:43 +00:00
|
|
|
{
|
2011-02-19 06:17:02 +00:00
|
|
|
at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
|
2010-10-18 20:58:29 +00:00
|
|
|
writel(RED_LED, &pio->piob.codr);
|
2009-03-27 22:26:43 +00:00
|
|
|
}
|
|
|
|
|
2011-09-04 18:40:16 +00:00
|
|
|
void green_led_off(void)
|
2009-03-27 22:26:43 +00:00
|
|
|
{
|
2011-02-19 06:17:02 +00:00
|
|
|
at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
|
2010-10-18 20:58:29 +00:00
|
|
|
writel(GREEN_LED, &pio->piob.sodr);
|
2009-03-27 22:26:43 +00:00
|
|
|
}
|
|
|
|
|
2011-09-04 18:40:16 +00:00
|
|
|
void yellow_led_off(void)
|
2009-03-27 22:26:43 +00:00
|
|
|
{
|
2011-02-19 06:17:02 +00:00
|
|
|
at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
|
2010-10-18 20:58:29 +00:00
|
|
|
writel(YELLOW_LED, &pio->piob.sodr);
|
2009-03-27 22:26:43 +00:00
|
|
|
}
|
|
|
|
|
2011-09-04 18:40:16 +00:00
|
|
|
void red_led_off(void)
|
2009-03-27 22:26:43 +00:00
|
|
|
{
|
2011-02-19 06:17:02 +00:00
|
|
|
at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
|
2010-10-18 20:58:29 +00:00
|
|
|
writel(RED_LED, &pio->piob.sodr);
|
2009-03-27 22:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void coloured_LED_init (void)
|
|
|
|
{
|
2011-02-19 06:17:02 +00:00
|
|
|
at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
|
2009-03-27 22:26:43 +00:00
|
|
|
|
2016-02-03 02:16:50 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_PIOB);
|
2010-10-18 20:58:29 +00:00
|
|
|
|
2009-03-27 22:26:43 +00:00
|
|
|
/* Disable peripherals on LEDs */
|
2010-10-18 20:58:29 +00:00
|
|
|
writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
|
2009-03-27 22:26:43 +00:00
|
|
|
/* Enable pins as outputs */
|
2010-10-18 20:58:29 +00:00
|
|
|
writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer);
|
2009-03-27 22:26:43 +00:00
|
|
|
/* Turn all LEDs OFF */
|
2010-10-18 20:58:29 +00:00
|
|
|
writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr);
|
2009-03-27 22:26:43 +00:00
|
|
|
}
|