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