Ulf Samuelsson | cb82a53 | 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 | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 6 | * (C) Copyright 2010 |
| 7 | * Andreas Bießmann <andreas.devel@gmail.com> |
| 8 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <common.h> |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 13 | #include <asm/io.h> |
| 14 | #include <asm/arch/hardware.h> |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 15 | #include <asm/arch/at91_pmc.h> |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 16 | #include <asm/arch/at91_pio.h> |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 17 | |
Andreas Bießmann | 99fa97e | 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 | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 22 | |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 23 | void green_led_on(void) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 24 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 25 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 26 | writel(GREEN_LED, &pio->piob.codr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 27 | } |
| 28 | |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 29 | void yellow_led_on(void) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 30 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 31 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 32 | writel(YELLOW_LED, &pio->piob.codr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 33 | } |
| 34 | |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 35 | void red_led_on(void) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 36 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 37 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 38 | writel(RED_LED, &pio->piob.codr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 39 | } |
| 40 | |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 41 | void green_led_off(void) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 42 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 43 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 44 | writel(GREEN_LED, &pio->piob.sodr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 45 | } |
| 46 | |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 47 | void yellow_led_off(void) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 48 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 49 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 50 | writel(YELLOW_LED, &pio->piob.sodr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 51 | } |
| 52 | |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 53 | void red_led_off(void) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 54 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 55 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 56 | writel(RED_LED, &pio->piob.sodr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 57 | } |
| 58 | |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 59 | void coloured_LED_init (void) |
| 60 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 61 | at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC; |
| 62 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 63 | |
| 64 | /* Enable PIOB clock */ |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 65 | writel(1 << ATMEL_ID_PIOB, &pmc->pcer); |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 66 | |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 67 | /* Disable peripherals on LEDs */ |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 68 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 69 | /* Enable pins as outputs */ |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 70 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 71 | /* Turn all LEDs OFF */ |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 72 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 73 | } |