xref: /openbmc/u-boot/board/atmel/at91rm9200ek/led.c (revision 730d2544)
1 /*
2  * (C) Copyright 2006
3  * Atmel Nordic AB <www.atmel.com>
4  * Ulf Samuelsson <ulf@atmel.com>
5  *
6  * (C) Copyright 2010
7  * Andreas Bießmann <andreas@biessmann.org>
8  *
9  * SPDX-License-Identifier:	GPL-2.0+
10  */
11 
12 #include <common.h>
13 #include <asm/io.h>
14 #include <asm/arch/hardware.h>
15 #include <asm/arch/clk.h>
16 #include <asm/arch/at91_pio.h>
17 #include <status_led.h>
18 
19 /* bit mask in PIO port B */
20 #define	GREEN_LED	(1<<0)
21 #define	YELLOW_LED	(1<<1)
22 #define	RED_LED		(1<<2)
23 
24 void	green_led_on(void)
25 {
26 	at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
27 	writel(GREEN_LED, &pio->piob.codr);
28 }
29 
30 void	 yellow_led_on(void)
31 {
32 	at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
33 	writel(YELLOW_LED, &pio->piob.codr);
34 }
35 
36 void	 red_led_on(void)
37 {
38 	at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
39 	writel(RED_LED, &pio->piob.codr);
40 }
41 
42 void	green_led_off(void)
43 {
44 	at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
45 	writel(GREEN_LED, &pio->piob.sodr);
46 }
47 
48 void	yellow_led_off(void)
49 {
50 	at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
51 	writel(YELLOW_LED, &pio->piob.sodr);
52 }
53 
54 void	red_led_off(void)
55 {
56 	at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
57 	writel(RED_LED, &pio->piob.sodr);
58 }
59 
60 void coloured_LED_init (void)
61 {
62 	at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
63 
64 	at91_periph_clk_enable(ATMEL_ID_PIOB);
65 
66 	/* Disable peripherals on LEDs */
67 	writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
68 	/* Enable pins as outputs */
69 	writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer);
70 	/* Turn all LEDs OFF */
71 	writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr);
72 }
73