4 * Copyright (c) 2005-2009 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
12 #include <status_led.h>
14 static void set_led_f(int pf, int 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;
22 static void set_led_g(int pf, int 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;
31 static void set_leds(led_id_t mask, int state)
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);
38 void __led_init(led_id_t mask, int state)
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));
48 void __led_set(led_id_t mask, int state)
50 set_leds(mask, state);
53 void __led_toggle(led_id_t mask)
55 set_leds(mask, STATUS_LED_BLINKING);