Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 2 | /* |
3 | * (C) Copyright 2006 | ||||
4 | * Atmel Nordic AB <www.atmel.com> | ||||
5 | * Ulf Samuelsson <ulf@atmel.com> | ||||
6 | * | ||||
Andreas Bießmann | 65c6567 | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 7 | * (C) Copyright 2010 |
Andreas Bießmann | 07dafdb | 2016-05-01 03:46:16 +0200 | [diff] [blame] | 8 | * Andreas Bießmann <andreas@biessmann.org> |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 9 | */ |
10 | |||||
11 | #include <common.h> | ||||
Jens Scharsig | 58aa563 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 12 | #include <asm/io.h> |
13 | #include <asm/arch/hardware.h> | ||||
Wenyou Yang | 78f8976 | 2016-02-03 10:16:50 +0800 | [diff] [blame] | 14 | #include <asm/arch/clk.h> |
Jens Scharsig | 58aa563 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 15 | #include <asm/arch/at91_pio.h> |
Jeroen Hofstee | 74a08bc | 2014-10-08 22:57:53 +0200 | [diff] [blame] | 16 | #include <status_led.h> |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 17 | |
Andreas Bießmann | 65c6567 | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 18 | /* 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 Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 22 | |
Jason Kridner | aff0aa8 | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 23 | void green_led_on(void) |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 24 | { |
Jens Scharsig | 58aa563 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 25 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 65c6567 | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 26 | writel(GREEN_LED, &pio->piob.codr); |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 27 | } |
28 | |||||
Jason Kridner | aff0aa8 | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 29 | void yellow_led_on(void) |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 30 | { |
Jens Scharsig | 58aa563 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 31 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 65c6567 | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 32 | writel(YELLOW_LED, &pio->piob.codr); |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 33 | } |
34 | |||||
Jason Kridner | aff0aa8 | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 35 | void red_led_on(void) |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 36 | { |
Jens Scharsig | 58aa563 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 37 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 65c6567 | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 38 | writel(RED_LED, &pio->piob.codr); |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 39 | } |
40 | |||||
Jason Kridner | aff0aa8 | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 41 | void green_led_off(void) |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 42 | { |
Jens Scharsig | 58aa563 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 43 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 65c6567 | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 44 | writel(GREEN_LED, &pio->piob.sodr); |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 45 | } |
46 | |||||
Jason Kridner | aff0aa8 | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 47 | void yellow_led_off(void) |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 48 | { |
Jens Scharsig | 58aa563 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 49 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 65c6567 | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 50 | writel(YELLOW_LED, &pio->piob.sodr); |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 51 | } |
52 | |||||
Jason Kridner | aff0aa8 | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 53 | void red_led_off(void) |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 54 | { |
Jens Scharsig | 58aa563 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 55 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 65c6567 | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 56 | writel(RED_LED, &pio->piob.sodr); |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 57 | } |
58 | |||||
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 59 | void coloured_LED_init (void) |
60 | { | ||||
Jens Scharsig | 58aa563 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 61 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 62 | |
Wenyou Yang | 78f8976 | 2016-02-03 10:16:50 +0800 | [diff] [blame] | 63 | at91_periph_clk_enable(ATMEL_ID_PIOB); |
Andreas Bießmann | 65c6567 | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 64 | |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 65 | /* Disable peripherals on LEDs */ |
Andreas Bießmann | 65c6567 | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 66 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per); |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 67 | /* Enable pins as outputs */ |
Andreas Bießmann | 65c6567 | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 68 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer); |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 69 | /* Turn all LEDs OFF */ |
Andreas Bießmann | 65c6567 | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 70 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr); |
Ulf Samuelsson | 07f9b4e | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 71 | } |