wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
Robert P. J. Day | 8d56db9 | 2016-07-15 13:44:45 -0400 | [diff] [blame] | 10 | /* if not overridden */ |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 11 | #ifndef CONFIG_BOARD_SPECIFIC_LED |
| 12 | # if defined(CONFIG_8xx) |
| 13 | # include <mpc8xx.h> |
Masahiro Yamada | 5a2bf98 | 2014-03-05 17:40:10 +0900 | [diff] [blame] | 14 | # elif defined(CONFIG_MPC8260) |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 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 */ |
| 23 | typedef unsigned long led_id_t; |
| 24 | |
| 25 | static inline void __led_init (led_id_t mask, int state) |
| 26 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 27 | volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 28 | |
| 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 | |
| 52 | static inline void __led_toggle (led_id_t mask) |
| 53 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 54 | ((immap_t *) CONFIG_SYS_IMMR)->STATUS_LED_DAT ^= mask; |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | static inline void __led_set (led_id_t mask, int state) |
| 58 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 59 | volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 60 | |
| 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__ */ |