add SDHC support in mmc driver
[u-boot-openmoko/mini2440.git] / include / asm-nios / status_led.h
blob241c9176889c7523b280e6f13695b5435f57df27
1 /*
2 * (C) Copyright 2003, Li-Pro.Net <www.li-pro.net>
3 * Stephan Linz <linz@li-pro.net>
5 * See file CREDITS for list of people who contributed to this
6 * project.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
23 * asm-nios/status_led.h
25 * NIOS PIO based status led support functions
28 #ifndef __ASM_STATUS_LED_H__
29 #define __ASM_STATUS_LED_H__
31 #include <nios-io.h>
33 /* led_id_t is unsigned int mask */
34 typedef unsigned int led_id_t;
36 #ifdef STATUS_LED_WRONLY /* emulate read access */
37 static led_id_t __led_portval = 0;
38 #endif
40 static inline void __led_init (led_id_t mask, int state)
42 nios_pio_t *piop = (nios_pio_t*)STATUS_LED_BASE;
44 #ifdef STATUS_LED_WRONLY /* emulate read access */
46 #if (STATUS_LED_ACTIVE == 0)
47 if (state == STATUS_LED_ON)
48 __led_portval &= ~mask;
49 else
50 __led_portval |= mask;
51 #else
52 if (state == STATUS_LED_ON)
53 __led_portval |= mask;
54 else
55 __led_portval &= ~mask;
56 #endif
58 piop->data = __led_portval;
60 #else /* !STATUS_LED_WRONLY */
62 #if (STATUS_LED_ACTIVE == 0)
63 if (state == STATUS_LED_ON)
64 piop->data &= ~mask;
65 else
66 piop->data |= mask;
67 #else
68 if (state == STATUS_LED_ON)
69 piop->data |= mask;
70 else
71 piop->data &= ~mask;
72 #endif
74 piop->direction |= mask;
76 #endif /* STATUS_LED_WRONLY */
79 static inline void __led_toggle (led_id_t mask)
81 nios_pio_t *piop = (nios_pio_t*)STATUS_LED_BASE;
83 #ifdef STATUS_LED_WRONLY /* emulate read access */
85 __led_portval ^= mask;
86 piop->data = __led_portval;
88 #else /* !STATUS_LED_WRONLY */
90 piop->data ^= mask;
92 #endif /* STATUS_LED_WRONLY */
95 static inline void __led_set (led_id_t mask, int state)
97 nios_pio_t *piop = (nios_pio_t*)STATUS_LED_BASE;
99 #ifdef STATUS_LED_WRONLY /* emulate read access */
101 #if (STATUS_LED_ACTIVE == 0)
102 if (state == STATUS_LED_ON)
103 __led_portval &= ~mask;
104 else
105 __led_portval |= mask;
106 #else
107 if (state == STATUS_LED_ON)
108 __led_portval |= mask;
109 else
110 __led_portval &= ~mask;
111 #endif
113 piop->data = __led_portval;
115 #else /* !STATUS_LED_WRONLY */
117 #if (STATUS_LED_ACTIVE == 0)
118 if (state == STATUS_LED_ON)
119 piop->data &= ~mask;
120 else
121 piop->data |= mask;
122 #else
123 if (state == STATUS_LED_ON)
124 piop->data |= mask;
125 else
126 piop->data &= ~mask;
127 #endif
129 #endif /* STATUS_LED_WRONLY */
132 #endif /* __ASM_STATUS_LED_H__ */