]>
Commit | Line | Data |
---|---|---|
cb82a532 US |
1 | /* |
2 | * (C) Copyright 2006 | |
3 | * Atmel Nordic AB <www.atmel.com> | |
4 | * Ulf Samuelsson <ulf@atmel.com> | |
5 | * | |
99fa97e9 AB |
6 | * (C) Copyright 2010 |
7 | * Andreas Bießmann <andreas.devel@gmail.com> | |
8 | * | |
1a459660 | 9 | * SPDX-License-Identifier: GPL-2.0+ |
cb82a532 US |
10 | */ |
11 | ||
12 | #include <common.h> | |
80733994 JS |
13 | #include <asm/io.h> |
14 | #include <asm/arch/hardware.h> | |
99fa97e9 | 15 | #include <asm/arch/at91_pmc.h> |
80733994 | 16 | #include <asm/arch/at91_pio.h> |
cb82a532 | 17 | |
99fa97e9 AB |
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) | |
cb82a532 | 22 | |
2d3be7c4 | 23 | void green_led_on(void) |
cb82a532 | 24 | { |
80733994 | 25 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
99fa97e9 | 26 | writel(GREEN_LED, &pio->piob.codr); |
cb82a532 US |
27 | } |
28 | ||
2d3be7c4 | 29 | void yellow_led_on(void) |
cb82a532 | 30 | { |
80733994 | 31 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
99fa97e9 | 32 | writel(YELLOW_LED, &pio->piob.codr); |
cb82a532 US |
33 | } |
34 | ||
2d3be7c4 | 35 | void red_led_on(void) |
cb82a532 | 36 | { |
80733994 | 37 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
99fa97e9 | 38 | writel(RED_LED, &pio->piob.codr); |
cb82a532 US |
39 | } |
40 | ||
2d3be7c4 | 41 | void green_led_off(void) |
cb82a532 | 42 | { |
80733994 | 43 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
99fa97e9 | 44 | writel(GREEN_LED, &pio->piob.sodr); |
cb82a532 US |
45 | } |
46 | ||
2d3be7c4 | 47 | void yellow_led_off(void) |
cb82a532 | 48 | { |
80733994 | 49 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
99fa97e9 | 50 | writel(YELLOW_LED, &pio->piob.sodr); |
cb82a532 US |
51 | } |
52 | ||
2d3be7c4 | 53 | void red_led_off(void) |
cb82a532 | 54 | { |
80733994 | 55 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; |
99fa97e9 | 56 | writel(RED_LED, &pio->piob.sodr); |
cb82a532 US |
57 | } |
58 | ||
cb82a532 US |
59 | void coloured_LED_init (void) |
60 | { | |
80733994 JS |
61 | at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC; |
62 | at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO; | |
cb82a532 US |
63 | |
64 | /* Enable PIOB clock */ | |
80733994 | 65 | writel(1 << ATMEL_ID_PIOB, &pmc->pcer); |
99fa97e9 | 66 | |
cb82a532 | 67 | /* Disable peripherals on LEDs */ |
99fa97e9 | 68 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per); |
cb82a532 | 69 | /* Enable pins as outputs */ |
99fa97e9 | 70 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer); |
cb82a532 | 71 | /* Turn all LEDs OFF */ |
99fa97e9 | 72 | writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr); |
cb82a532 | 73 | } |