xref: /openbmc/u-boot/board/atmel/at91rm9200ek/led.c (revision a89c33db)
1 /*
2  * (C) Copyright 2006
3  * Atmel Nordic AB <www.atmel.com>
4  * Ulf Samuelsson <ulf@atmel.com>
5  *
6  * See file CREDITS for list of people who contributed to this
7  * project.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22  * MA 02111-1307 USA
23  */
24 
25 #include <common.h>
26 #include <asm/arch/AT91RM9200.h>
27 #include <asm/io.h>
28 
29 #define	GREEN_LED	AT91C_PIO_PB0
30 #define	YELLOW_LED	AT91C_PIO_PB1
31 #define	RED_LED		AT91C_PIO_PB2
32 
33 void	green_LED_on(void)
34 {
35 	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
36 
37 	writel(GREEN_LED, PIOB->PIO_CODR);
38 }
39 
40 void	 yellow_LED_on(void)
41 {
42 	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
43 
44 	writel(YELLOW_LED, PIOB->PIO_CODR);
45 }
46 
47 void	 red_LED_on(void)
48 {
49 	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
50 
51 	writel(RED_LED, PIOB->PIO_CODR);
52 }
53 
54 void	green_LED_off(void)
55 {
56 	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
57 
58 	writel(GREEN_LED, PIOB->PIO_SODR);
59 }
60 
61 void	yellow_LED_off(void)
62 {
63 	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
64 
65 	writel(YELLOW_LED, PIOB->PIO_SODR);
66 }
67 
68 void	red_LED_off(void)
69 {
70 	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
71 
72 	writel(RED_LED, PIOB->PIO_SODR);
73 }
74 
75 
76 void coloured_LED_init (void)
77 {
78 	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
79 	AT91PS_PMC	PMC	= AT91C_BASE_PMC;
80 
81 	/* Enable PIOB clock */
82 	writel((1 << AT91C_ID_PIOB), PMC->PMC_PCER);
83 	/* Disable peripherals on LEDs */
84 	writel(AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0, PIOB->PIO_PER);
85 	/* Enable pins as outputs */
86 	writel(AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0, PIOB->PIO_OER);
87 	/* Turn all LEDs OFF */
88 	writel(AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0, PIOB->PIO_SODR);
89 }
90