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