blob: 6327022ccf124b72dd69d0ecc0c45a93ab23e1f4 [file] [log] [blame]
Mike Frysinger0c31ddf2008-10-12 21:30:48 -04001/*
2 * U-boot - status leds
3 *
4 * Copyright (c) 2005-2009 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <common.h>
10#include <config.h>
11#include <command.h>
12#include <status_led.h>
13
14static void set_led_f(int pf, int state)
15{
16 switch (state) {
17 case STATUS_LED_OFF: bfin_write_PORTFIO_CLEAR(pf); break;
18 case STATUS_LED_BLINKING: bfin_write_PORTFIO_TOGGLE(pf); break;
19 case STATUS_LED_ON: bfin_write_PORTFIO_SET(pf); break;
20 }
21}
22static void set_led_g(int pf, int state)
23{
24 switch (state) {
25 case STATUS_LED_OFF: bfin_write_PORTGIO_CLEAR(pf); break;
26 case STATUS_LED_BLINKING: bfin_write_PORTGIO_TOGGLE(pf); break;
27 case STATUS_LED_ON: bfin_write_PORTGIO_SET(pf); break;
28 }
29}
30
31static void set_leds(led_id_t mask, int state)
32{
33 if (mask & 0x1) set_led_f(PF8, state);
34 if (mask & 0x2) set_led_g(PG11, state);
35 if (mask & 0x4) set_led_g(PG12, state);
36}
37
38void __led_init(led_id_t mask, int state)
39{
40 bfin_write_PORTF_FER(bfin_read_PORTF_FER() & ~(PF8));
41 bfin_write_PORTG_FER(bfin_read_PORTG_FER() & ~(PG11 | PG12));
42 bfin_write_PORTFIO_INEN(bfin_read_PORTFIO_INEN() & ~(PF8));
43 bfin_write_PORTGIO_INEN(bfin_read_PORTGIO_INEN() & ~(PG11 | PG12));
44 bfin_write_PORTFIO_DIR(bfin_read_PORTFIO_DIR() | (PF8));
45 bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() | (PG11 | PG12));
46}
47
48void __led_set(led_id_t mask, int state)
49{
50 set_leds(mask, state);
51}
52
53void __led_toggle(led_id_t mask)
54{
55 set_leds(mask, STATUS_LED_BLINKING);
56}