blob: 8d512e0329ce05ef7b6460fad4d3245ebab9b2da [file] [log] [blame]
Ulf Samuelssoncb82a532009-03-27 23:26:43 +01001/*
2 * (C) Copyright 2006
3 * Atmel Nordic AB <www.atmel.com>
4 * Ulf Samuelsson <ulf@atmel.com>
5 *
Andreas Bießmann99fa97e2010-10-18 22:58:29 +02006 * (C) Copyright 2010
7 * Andreas Bießmann <andreas.devel@gmail.com>
8 *
Ulf Samuelssoncb82a532009-03-27 23:26:43 +01009 * 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ßmann99fa97e2010-10-18 22:58:29 +020029#include <asm/arch/gpio.h>
30#include <asm/arch/at91_pmc.h>
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010031
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020032/* 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 Samuelssoncb82a532009-03-27 23:26:43 +010036
37void green_LED_on(void)
38{
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020039 at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
40 writel(GREEN_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010041}
42
43void yellow_LED_on(void)
44{
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020045 at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
46 writel(YELLOW_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010047}
48
49void red_LED_on(void)
50{
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020051 at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
52 writel(RED_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010053}
54
55void green_LED_off(void)
56{
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020057 at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
58 writel(GREEN_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010059}
60
61void yellow_LED_off(void)
62{
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020063 at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
64 writel(YELLOW_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010065}
66
67void red_LED_off(void)
68{
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020069 at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
70 writel(RED_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010071}
72
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010073void coloured_LED_init (void)
74{
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020075 at91_pmc_t *pmc = (at91_pmc_t *)AT91_PMC_BASE;
76 at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010077
78 /* Enable PIOB clock */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020079 writel(1 << AT91_ID_PIOB, &pmc->pcer);
80
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010081 /* Disable peripherals on LEDs */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020082 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010083 /* Enable pins as outputs */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020084 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010085 /* Turn all LEDs OFF */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020086 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010087}