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 | * |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 25 | * MA 02111-1307 USA |
| 26 | */ |
| 27 | |
| 28 | #include <common.h> |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 29 | #include <asm/io.h> |
| 30 | #include <asm/arch/hardware.h> |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 31 | #include <asm/arch/at91_pmc.h> |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 32 | #include <asm/arch/at91_pio.h> |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 33 | |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 34 | /* bit mask in PIO port B */ |
| 35 | #define GREEN_LED (1<<0) |
| 36 | #define YELLOW_LED (1<<1) |
| 37 | #define RED_LED (1<<2) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 38 | |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 39 | void green_led_on(void) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 40 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 41 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 42 | writel(GREEN_LED, &pio->piob.codr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 43 | } |
| 44 | |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 45 | void yellow_led_on(void) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 46 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 47 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 48 | writel(YELLOW_LED, &pio->piob.codr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 49 | } |
| 50 | |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 51 | void red_led_on(void) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 52 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 53 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 54 | writel(RED_LED, &pio->piob.codr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 55 | } |
| 56 | |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 57 | void green_led_off(void) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 58 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 59 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 60 | writel(GREEN_LED, &pio->piob.sodr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 61 | } |
| 62 | |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 63 | void yellow_led_off(void) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 64 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 65 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 66 | writel(YELLOW_LED, &pio->piob.sodr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 67 | } |
| 68 | |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 69 | void red_led_off(void) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 70 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 71 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 72 | writel(RED_LED, &pio->piob.sodr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 73 | } |
| 74 | |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 75 | void coloured_LED_init (void) |
| 76 | { |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 77 | at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC; |
| 78 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 79 | |
| 80 | /* Enable PIOB clock */ |
Jens Scharsig | 8073399 | 2011-02-19 06:17:02 +0000 | [diff] [blame] | 81 | writel(1 << ATMEL_ID_PIOB, &pmc->pcer); |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 82 | |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 83 | /* Disable peripherals on LEDs */ |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 84 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 85 | /* Enable pins as outputs */ |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 86 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 87 | /* Turn all LEDs OFF */ |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 88 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 89 | } |