blob: 2298e3619c4ee0d4e2ff9b9aebc4ed7f785ecac5 [file] [log] [blame]
Ulf Samuelssoncb82a532009-03-27 23:26:43 +01001/*
2 * (C) Copyright 2006
3 * Atmel Nordic AB <www.atmel.com>
4 * Ulf Samuelsson <ulf@atmel.com>
5 *
Andreas Bießmann99fa97e2010-10-18 22:58:29 +02006 * (C) Copyright 2010
7 * Andreas Bießmann <andreas.devel@gmail.com>
8 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010010 */
11
12#include <common.h>
Jens Scharsig80733992011-02-19 06:17:02 +000013#include <asm/io.h>
14#include <asm/arch/hardware.h>
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020015#include <asm/arch/at91_pmc.h>
Jens Scharsig80733992011-02-19 06:17:02 +000016#include <asm/arch/at91_pio.h>
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010017
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020018/* bit mask in PIO port B */
19#define GREEN_LED (1<<0)
20#define YELLOW_LED (1<<1)
21#define RED_LED (1<<2)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010022
Jason Kridner2d3be7c2011-09-04 14:40:16 -040023void green_led_on(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010024{
Jens Scharsig80733992011-02-19 06:17:02 +000025 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020026 writel(GREEN_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010027}
28
Jason Kridner2d3be7c2011-09-04 14:40:16 -040029void yellow_led_on(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010030{
Jens Scharsig80733992011-02-19 06:17:02 +000031 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020032 writel(YELLOW_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010033}
34
Jason Kridner2d3be7c2011-09-04 14:40:16 -040035void red_led_on(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010036{
Jens Scharsig80733992011-02-19 06:17:02 +000037 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020038 writel(RED_LED, &pio->piob.codr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010039}
40
Jason Kridner2d3be7c2011-09-04 14:40:16 -040041void green_led_off(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010042{
Jens Scharsig80733992011-02-19 06:17:02 +000043 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020044 writel(GREEN_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010045}
46
Jason Kridner2d3be7c2011-09-04 14:40:16 -040047void yellow_led_off(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010048{
Jens Scharsig80733992011-02-19 06:17:02 +000049 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020050 writel(YELLOW_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010051}
52
Jason Kridner2d3be7c2011-09-04 14:40:16 -040053void red_led_off(void)
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010054{
Jens Scharsig80733992011-02-19 06:17:02 +000055 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020056 writel(RED_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010057}
58
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010059void coloured_LED_init (void)
60{
Jens Scharsig80733992011-02-19 06:17:02 +000061 at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
62 at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010063
64 /* Enable PIOB clock */
Jens Scharsig80733992011-02-19 06:17:02 +000065 writel(1 << ATMEL_ID_PIOB, &pmc->pcer);
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020066
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010067 /* Disable peripherals on LEDs */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020068 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010069 /* Enable pins as outputs */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020070 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010071 /* Turn all LEDs OFF */
Andreas Bießmann99fa97e2010-10-18 22:58:29 +020072 writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr);
Ulf Samuelssoncb82a532009-03-27 23:26:43 +010073}