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 #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_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC; 63 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; 64 65 /* Enable PIOB clock */ 66 writel(1 << ATMEL_ID_PIOB, &pmc->pcer); 67 68 /* Disable peripherals on LEDs */ 69 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per); 70 /* Enable pins as outputs */ 71 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer); 72 /* Turn all LEDs OFF */ 73 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr); 74 } 75