blob: a6b4d1fb651cf928b8dfc7a6c6d3ba2b3c982751 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Ulf Samuelssoncb82a532009-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ßmann99fa97e2010-10-18 22:58:29 +02007 * (C) Copyright 2010
Andreas Bießmann09c2b8f2016-05-01 03:46:16 +02008 * Andreas Bießmann <andreas@biessmann.org>
Ulf Samuelssoncb82a532009-03-27 23:26:43 +01009 */
10
11#include <common.h>
Jens Scharsig80733992011-02-19 06:17:02 +000012#include <asm/io.h>
13#include <asm/arch/hardware.h>
Wenyou Yang70341e22016-02-03 10:16:50 +080014#include <asm/arch/clk.h>
Jens Scharsig80733992011-02-19 06:17:02 +000015#include <asm/arch/at91_pio.h>
Jeroen Hofstee52422e32014-10-08 22:57:53 +020016#include <status_led.h>
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010017
Andreas Bießmann99fa97e2010-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 Samuelssoncb82a532009-03-27 23:26:43 +010022
Jason Kridner2d3be7c2011-09-04 14:40:16 -040023void green_led_on(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010024{
Jens Scharsig80733992011-02-19 06:17:02 +000025 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020026 writel(GREEN_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010027}
28
Jason Kridner2d3be7c2011-09-04 14:40:16 -040029void yellow_led_on(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010030{
Jens Scharsig80733992011-02-19 06:17:02 +000031 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020032 writel(YELLOW_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010033}
34
Jason Kridner2d3be7c2011-09-04 14:40:16 -040035void red_led_on(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010036{
Jens Scharsig80733992011-02-19 06:17:02 +000037 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020038 writel(RED_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010039}
40
Jason Kridner2d3be7c2011-09-04 14:40:16 -040041void green_led_off(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010042{
Jens Scharsig80733992011-02-19 06:17:02 +000043 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020044 writel(GREEN_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010045}
46
Jason Kridner2d3be7c2011-09-04 14:40:16 -040047void yellow_led_off(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010048{
Jens Scharsig80733992011-02-19 06:17:02 +000049 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020050 writel(YELLOW_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010051}
52
Jason Kridner2d3be7c2011-09-04 14:40:16 -040053void red_led_off(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010054{
Jens Scharsig80733992011-02-19 06:17:02 +000055 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020056 writel(RED_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010057}
58
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010059void coloured_LED_init (void)
60{
Jens Scharsig80733992011-02-19 06:17:02 +000061 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010062
Wenyou Yang70341e22016-02-03 10:16:50 +080063 at91_periph_clk_enable(ATMEL_ID_PIOB);
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020064
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010065 /* Disable peripherals on LEDs */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020066 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010067 /* Enable pins as outputs */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020068 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010069 /* Turn all LEDs OFF */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020070 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010071}