]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/bf526-ezbrd/status-led.c
imported Ka-Ro specific additions to U-Boot 2009.08 for TX28
[karo-tx-uboot.git] / board / bf526-ezbrd / status-led.c
1 /*
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
14 static 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 }
22 static 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
31 static 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
38 void __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
48 void __led_set(led_id_t mask, int state)
49 {
50         set_leds(mask, state);
51 }
52
53 void __led_toggle(led_id_t mask)
54 {
55         set_leds(mask, STATUS_LED_BLINKING);
56 }