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
|
|
|
|
* Andreas Bießmann <andreas.devel@gmail.com>
|
|
|
|
*
|
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>
|
2010-10-18 20:58:29 +00:00
|
|
|
#include <asm/arch/at91_pmc.h>
|
2011-02-19 06:17:02 +00:00
|
|
|
#include <asm/arch/at91_pio.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_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
|
|
|
|
at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
|
2009-03-27 22:26:43 +00:00
|
|
|
|
|
|
|
/* Enable PIOB clock */
|
2011-02-19 06:17:02 +00:00
|
|
|
writel(1 << ATMEL_ID_PIOB, &pmc->pcer);
|
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
|
|
|
}
|