blob: a6b4d1fb651cf928b8dfc7a6c6d3ba2b3c982751 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +01002/*
3 * (C) Copyright 2006
4 * Atmel Nordic AB <www.atmel.com>
5 * Ulf Samuelsson <ulf@atmel.com>
6 *
Andreas Bießmann65c65672010-10-18 22:58:29 +02007 * (C) Copyright 2010
Andreas Bießmann07dafdb2016-05-01 03:46:16 +02008 * Andreas Bießmann <andreas@biessmann.org>
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +01009 */
10
11#include <common.h>
Jens Scharsig58aa5632011-02-19 06:17:02 +000012#include <asm/io.h>
13#include <asm/arch/hardware.h>
Wenyou Yang78f89762016-02-03 10:16:50 +080014#include <asm/arch/clk.h>
Jens Scharsig58aa5632011-02-19 06:17:02 +000015#include <asm/arch/at91_pio.h>
Jeroen Hofstee74a08bc2014-10-08 22:57:53 +020016#include <status_led.h>
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010017
Andreas Bießmann65c65672010-10-18 22:58:29 +020018/* bit mask in PIO port B */
19#define GREEN_LED (1<<0)
20#define YELLOW_LED (1<<1)
21#define RED_LED (1<<2)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010022
Jason Kridneraff0aa82011-09-04 14:40:16 -040023void green_led_on(void)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010024{
Jens Scharsig58aa5632011-02-19 06:17:02 +000025 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann65c65672010-10-18 22:58:29 +020026 writel(GREEN_LED, &pio->piob.codr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010027}
28
Jason Kridneraff0aa82011-09-04 14:40:16 -040029void yellow_led_on(void)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010030{
Jens Scharsig58aa5632011-02-19 06:17:02 +000031 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann65c65672010-10-18 22:58:29 +020032 writel(YELLOW_LED, &pio->piob.codr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010033}
34
Jason Kridneraff0aa82011-09-04 14:40:16 -040035void red_led_on(void)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010036{
Jens Scharsig58aa5632011-02-19 06:17:02 +000037 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann65c65672010-10-18 22:58:29 +020038 writel(RED_LED, &pio->piob.codr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010039}
40
Jason Kridneraff0aa82011-09-04 14:40:16 -040041void green_led_off(void)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010042{
Jens Scharsig58aa5632011-02-19 06:17:02 +000043 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann65c65672010-10-18 22:58:29 +020044 writel(GREEN_LED, &pio->piob.sodr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010045}
46
Jason Kridneraff0aa82011-09-04 14:40:16 -040047void yellow_led_off(void)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010048{
Jens Scharsig58aa5632011-02-19 06:17:02 +000049 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann65c65672010-10-18 22:58:29 +020050 writel(YELLOW_LED, &pio->piob.sodr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010051}
52
Jason Kridneraff0aa82011-09-04 14:40:16 -040053void red_led_off(void)
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010054{
Jens Scharsig58aa5632011-02-19 06:17:02 +000055 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann65c65672010-10-18 22:58:29 +020056 writel(RED_LED, &pio->piob.sodr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010057}
58
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010059void coloured_LED_init (void)
60{
Jens Scharsig58aa5632011-02-19 06:17:02 +000061 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010062
Wenyou Yang78f89762016-02-03 10:16:50 +080063 at91_periph_clk_enable(ATMEL_ID_PIOB);
Andreas Bießmann65c65672010-10-18 22:58:29 +020064
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010065 /* Disable peripherals on LEDs */
Andreas Bießmann65c65672010-10-18 22:58:29 +020066 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010067 /* Enable pins as outputs */
Andreas Bießmann65c65672010-10-18 22:58:29 +020068 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010069 /* Turn all LEDs OFF */
Andreas Bießmann65c65672010-10-18 22:58:29 +020070 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr);
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +010071}