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> |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 29 | #include <asm/arch/gpio.h> |
| 30 | #include <asm/arch/at91_pmc.h> |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 31 | |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 32 | /* bit mask in PIO port B */ |
| 33 | #define GREEN_LED (1<<0) |
| 34 | #define YELLOW_LED (1<<1) |
| 35 | #define RED_LED (1<<2) |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 36 | |
| 37 | void green_LED_on(void) |
| 38 | { |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 39 | at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE; |
| 40 | writel(GREEN_LED, &pio->piob.codr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | void yellow_LED_on(void) |
| 44 | { |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 45 | at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE; |
| 46 | writel(YELLOW_LED, &pio->piob.codr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void red_LED_on(void) |
| 50 | { |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 51 | at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE; |
| 52 | writel(RED_LED, &pio->piob.codr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | void green_LED_off(void) |
| 56 | { |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 57 | at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE; |
| 58 | writel(GREEN_LED, &pio->piob.sodr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | void yellow_LED_off(void) |
| 62 | { |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 63 | at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE; |
| 64 | writel(YELLOW_LED, &pio->piob.sodr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | void red_LED_off(void) |
| 68 | { |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 69 | at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE; |
| 70 | writel(RED_LED, &pio->piob.sodr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 71 | } |
| 72 | |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 73 | void coloured_LED_init (void) |
| 74 | { |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 75 | at91_pmc_t *pmc = (at91_pmc_t *)AT91_PMC_BASE; |
| 76 | at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE; |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 77 | |
| 78 | /* Enable PIOB clock */ |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 79 | writel(1 << AT91_ID_PIOB, &pmc->pcer); |
| 80 | |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 81 | /* Disable peripherals on LEDs */ |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 82 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 83 | /* Enable pins as outputs */ |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 84 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 85 | /* Turn all LEDs OFF */ |
Andreas Bießmann | 99fa97e | 2010-10-18 22:58:29 +0200 | [diff] [blame] | 86 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr); |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 87 | } |