blob: facba2488d0f37e87c28e5b8a45d9306331684cd [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>
Jens Scharsig80733992011-02-19 06:17:02 +000029#include <asm/io.h>
30#include <asm/arch/hardware.h>
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020031#include <asm/arch/at91_pmc.h>
Jens Scharsig80733992011-02-19 06:17:02 +000032#include <asm/arch/at91_pio.h>
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010033
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020034/* 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 Samuelssoncb82a532009-03-27 23:26:43 +010038
Jason Kridner2d3be7c2011-09-04 14:40:16 -040039void green_led_on(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010040{
Jens Scharsig80733992011-02-19 06:17:02 +000041 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020042 writel(GREEN_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010043}
44
Jason Kridner2d3be7c2011-09-04 14:40:16 -040045void yellow_led_on(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010046{
Jens Scharsig80733992011-02-19 06:17:02 +000047 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020048 writel(YELLOW_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010049}
50
Jason Kridner2d3be7c2011-09-04 14:40:16 -040051void red_led_on(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010052{
Jens Scharsig80733992011-02-19 06:17:02 +000053 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020054 writel(RED_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010055}
56
Jason Kridner2d3be7c2011-09-04 14:40:16 -040057void green_led_off(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010058{
Jens Scharsig80733992011-02-19 06:17:02 +000059 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020060 writel(GREEN_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010061}
62
Jason Kridner2d3be7c2011-09-04 14:40:16 -040063void yellow_led_off(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010064{
Jens Scharsig80733992011-02-19 06:17:02 +000065 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020066 writel(YELLOW_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010067}
68
Jason Kridner2d3be7c2011-09-04 14:40:16 -040069void red_led_off(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010070{
Jens Scharsig80733992011-02-19 06:17:02 +000071 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020072 writel(RED_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010073}
74
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010075void coloured_LED_init (void)
76{
Jens Scharsig80733992011-02-19 06:17:02 +000077 at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
78 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010079
80 /* Enable PIOB clock */
Jens Scharsig80733992011-02-19 06:17:02 +000081 writel(1 << ATMEL_ID_PIOB, &pmc->pcer);
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020082
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010083 /* Disable peripherals on LEDs */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020084 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010085 /* Enable pins as outputs */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020086 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010087 /* Turn all LEDs OFF */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020088 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010089}