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