blob: 5986ac08f981d1c99b22311885d06822747f9ce3 [file] [log] [blame]
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +01001/*
2 * (C) Copyright 2006
3 * Atmel Nordic AB <www.atmel.com>
4 * Ulf Samuelsson <ulf@atmel.com>
5 *
Andreas Bießmann65c65672010-10-18 22:58:29 +02006 * (C) Copyright 2010
Andreas Bießmann07dafdb2016-05-01 03:46:16 +02007 * Andreas Bießmann <andreas@biessmann.org>
Andreas Bießmann65c65672010-10-18 22:58:29 +02008 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010010 */
11
12#include <common.h>
Jens Scharsig58aa5632011-02-19 06:17:02 +000013#include <asm/io.h>
14#include <asm/arch/hardware.h>
Wenyou Yang78f89762016-02-03 10:16:50 +080015#include <asm/arch/clk.h>
Jens Scharsig58aa5632011-02-19 06:17:02 +000016#include <asm/arch/at91_pio.h>
Jeroen Hofstee74a08bc2014-10-08 22:57:53 +020017#include <status_led.h>
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010018
Andreas Bießmann65c65672010-10-18 22:58:29 +020019/* bit mask in PIO port B */
20#define GREEN_LED (1<<0)
21#define YELLOW_LED (1<<1)
22#define RED_LED (1<<2)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010023
Jason Kridneraff0aa82011-09-04 14:40:16 -040024void green_led_on(void)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010025{
Jens Scharsig58aa5632011-02-19 06:17:02 +000026 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann65c65672010-10-18 22:58:29 +020027 writel(GREEN_LED, &pio->piob.codr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010028}
29
Jason Kridneraff0aa82011-09-04 14:40:16 -040030void yellow_led_on(void)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010031{
Jens Scharsig58aa5632011-02-19 06:17:02 +000032 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann65c65672010-10-18 22:58:29 +020033 writel(YELLOW_LED, &pio->piob.codr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010034}
35
Jason Kridneraff0aa82011-09-04 14:40:16 -040036void red_led_on(void)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010037{
Jens Scharsig58aa5632011-02-19 06:17:02 +000038 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann65c65672010-10-18 22:58:29 +020039 writel(RED_LED, &pio->piob.codr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010040}
41
Jason Kridneraff0aa82011-09-04 14:40:16 -040042void green_led_off(void)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010043{
Jens Scharsig58aa5632011-02-19 06:17:02 +000044 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann65c65672010-10-18 22:58:29 +020045 writel(GREEN_LED, &pio->piob.sodr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010046}
47
Jason Kridneraff0aa82011-09-04 14:40:16 -040048void yellow_led_off(void)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010049{
Jens Scharsig58aa5632011-02-19 06:17:02 +000050 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann65c65672010-10-18 22:58:29 +020051 writel(YELLOW_LED, &pio->piob.sodr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010052}
53
Jason Kridneraff0aa82011-09-04 14:40:16 -040054void red_led_off(void)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010055{
Jens Scharsig58aa5632011-02-19 06:17:02 +000056 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann65c65672010-10-18 22:58:29 +020057 writel(RED_LED, &pio->piob.sodr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010058}
59
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010060void coloured_LED_init (void)
61{
Jens Scharsig58aa5632011-02-19 06:17:02 +000062 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010063
Wenyou Yang78f89762016-02-03 10:16:50 +080064 at91_periph_clk_enable(ATMEL_ID_PIOB);
Andreas Bießmann65c65672010-10-18 22:58:29 +020065
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010066 /* Disable peripherals on LEDs */
Andreas Bießmann65c65672010-10-18 22:58:29 +020067 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010068 /* Enable pins as outputs */
Andreas Bießmann65c65672010-10-18 22:58:29 +020069 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010070 /* Turn all LEDs OFF */
Andreas Bießmann65c65672010-10-18 22:58:29 +020071 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010072}