blob: 037570993ac17541671999774775e437b3547008 [file] [log] [blame]
wdenk7539dea2003-06-19 23:01:32 +00001/*
2 * asm/status_led.h
3 *
4 * MPC8xx/MPC8260/MPC5xx based status led support functions
5 */
6
7#ifndef __ASM_STATUS_LED_H__
8#define __ASM_STATUS_LED_H__
9
10/* if not overriden */
11#ifndef CONFIG_BOARD_SPECIFIC_LED
12# if defined(CONFIG_8xx)
13# include <mpc8xx.h>
14# elif defined(CONFIG_8260)
15# include <mpc8260.h>
16# elif defined(CONFIG_5xx)
17# include <mpc5xx.h>
18# else
19# error CPU specific Status LED header file missing.
20#endif
21
22/* led_id_t is unsigned long mask */
23typedef unsigned long led_id_t;
24
25static inline void __led_init (led_id_t mask, int state)
26{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020027 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
wdenk7539dea2003-06-19 23:01:32 +000028
29#ifdef STATUS_LED_PAR
30 immr->STATUS_LED_PAR &= ~mask;
31#endif
32#ifdef STATUS_LED_ODR
33 immr->STATUS_LED_ODR &= ~mask;
34#endif
35
36#if (STATUS_LED_ACTIVE == 0)
37 if (state == STATUS_LED_ON)
38 immr->STATUS_LED_DAT &= ~mask;
39 else
40 immr->STATUS_LED_DAT |= mask;
41#else
42 if (state == STATUS_LED_ON)
43 immr->STATUS_LED_DAT |= mask;
44 else
45 immr->STATUS_LED_DAT &= ~mask;
46#endif
47#ifdef STATUS_LED_DIR
48 immr->STATUS_LED_DIR |= mask;
49#endif
50}
51
52static inline void __led_toggle (led_id_t mask)
53{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020054 ((immap_t *) CONFIG_SYS_IMMR)->STATUS_LED_DAT ^= mask;
wdenk7539dea2003-06-19 23:01:32 +000055}
56
57static inline void __led_set (led_id_t mask, int state)
58{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020059 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
wdenk7539dea2003-06-19 23:01:32 +000060
61#if (STATUS_LED_ACTIVE == 0)
62 if (state == STATUS_LED_ON)
63 immr->STATUS_LED_DAT &= ~mask;
64 else
65 immr->STATUS_LED_DAT |= mask;
66#else
67 if (state == STATUS_LED_ON)
68 immr->STATUS_LED_DAT |= mask;
69 else
70 immr->STATUS_LED_DAT &= ~mask;
71#endif
72
73}
74
75#endif
76
77#endif /* __ASM_STATUS_LED_H__ */