xref: /openbmc/u-boot/board/atmel/at91rm9200ek/led.c (revision ac1058fd)
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.devel@gmail.com>
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/at91_pmc.h>
16 #include <asm/arch/at91_pio.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_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
62 	at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
63 
64 	/* Enable PIOB clock */
65 	writel(1 << ATMEL_ID_PIOB, &pmc->pcer);
66 
67 	/* Disable peripherals on LEDs */
68 	writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
69 	/* Enable pins as outputs */
70 	writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer);
71 	/* Turn all LEDs OFF */
72 	writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr);
73 }
74