blob: 6761b141fb82fd42a51f5e47896d1b9bfaed1b7d [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
7 * Andreas Bießmann <andreas.devel@gmail.com>
8 *
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>
Andreas Bießmann65c65672010-10-18 22:58:29 +020015#include <asm/arch/at91_pmc.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_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
63 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010064
65 /* Enable PIOB clock */
Jens Scharsig58aa5632011-02-19 06:17:02 +000066 writel(1 << ATMEL_ID_PIOB, &pmc->pcer);
Andreas Bießmann65c65672010-10-18 22:58:29 +020067
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010068 /* Disable peripherals on LEDs */
Andreas Bießmann65c65672010-10-18 22:58:29 +020069 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010070 /* Enable pins as outputs */
Andreas Bießmann65c65672010-10-18 22:58:29 +020071 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010072 /* Turn all LEDs OFF */
Andreas Bießmann65c65672010-10-18 22:58:29 +020073 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010074}