blob: 5986ac08f981d1c99b22311885d06822747f9ce3 [file] [log] [blame]
Ulf Samuelssoncb82a532009-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ßmann99fa97e2010-10-18 22:58:29 +02006 * (C) Copyright 2010
Andreas Bießmann09c2b8f2016-05-01 03:46:16 +02007 * Andreas Bießmann <andreas@biessmann.org>
Andreas Bießmann99fa97e2010-10-18 22:58:29 +02008 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010010 */
11
12#include <common.h>
Jens Scharsig80733992011-02-19 06:17:02 +000013#include <asm/io.h>
14#include <asm/arch/hardware.h>
Wenyou Yang70341e22016-02-03 10:16:50 +080015#include <asm/arch/clk.h>
Jens Scharsig80733992011-02-19 06:17:02 +000016#include <asm/arch/at91_pio.h>
Jeroen Hofstee52422e32014-10-08 22:57:53 +020017#include <status_led.h>
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010018
Andreas Bießmann99fa97e2010-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 Samuelssoncb82a532009-03-27 23:26:43 +010023
Jason Kridner2d3be7c2011-09-04 14:40:16 -040024void green_led_on(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010025{
Jens Scharsig80733992011-02-19 06:17:02 +000026 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020027 writel(GREEN_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010028}
29
Jason Kridner2d3be7c2011-09-04 14:40:16 -040030void yellow_led_on(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010031{
Jens Scharsig80733992011-02-19 06:17:02 +000032 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020033 writel(YELLOW_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010034}
35
Jason Kridner2d3be7c2011-09-04 14:40:16 -040036void red_led_on(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010037{
Jens Scharsig80733992011-02-19 06:17:02 +000038 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020039 writel(RED_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010040}
41
Jason Kridner2d3be7c2011-09-04 14:40:16 -040042void green_led_off(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010043{
Jens Scharsig80733992011-02-19 06:17:02 +000044 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020045 writel(GREEN_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010046}
47
Jason Kridner2d3be7c2011-09-04 14:40:16 -040048void yellow_led_off(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010049{
Jens Scharsig80733992011-02-19 06:17:02 +000050 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020051 writel(YELLOW_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010052}
53
Jason Kridner2d3be7c2011-09-04 14:40:16 -040054void red_led_off(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010055{
Jens Scharsig80733992011-02-19 06:17:02 +000056 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020057 writel(RED_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010058}
59
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010060void coloured_LED_init (void)
61{
Jens Scharsig80733992011-02-19 06:17:02 +000062 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010063
Wenyou Yang70341e22016-02-03 10:16:50 +080064 at91_periph_clk_enable(ATMEL_ID_PIOB);
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020065
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010066 /* Disable peripherals on LEDs */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020067 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010068 /* Enable pins as outputs */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020069 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010070 /* Turn all LEDs OFF */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020071 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010072}