blob: 1ae1b17e2d1b9024c30938eca1b673bc8b1fed55 [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
Robert P. J. Day8d56db92016-07-15 13:44:45 -040010/* if not overridden */
Uri Mashiach4892d392017-01-19 10:51:45 +020011#ifndef CONFIG_LED_STATUS_BOARD_SPECIFIC
wdenk7539dea2003-06-19 23:01:32 +000012# if defined(CONFIG_8xx)
13# include <mpc8xx.h>
Masahiro Yamada5a2bf982014-03-05 17:40:10 +090014# elif defined(CONFIG_MPC8260)
wdenk7539dea2003-06-19 23:01:32 +000015# 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)
Uri Mashiach4892d392017-01-19 10:51:45 +020037 if (state == CONFIG_LED_STATUS_ON)
wdenk7539dea2003-06-19 23:01:32 +000038 immr->STATUS_LED_DAT &= ~mask;
39 else
40 immr->STATUS_LED_DAT |= mask;
41#else
Uri Mashiach4892d392017-01-19 10:51:45 +020042 if (state == CONFIG_LED_STATUS_ON)
wdenk7539dea2003-06-19 23:01:32 +000043 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)
Uri Mashiach4892d392017-01-19 10:51:45 +020062 if (state == CONFIG_LED_STATUS_ON)
wdenk7539dea2003-06-19 23:01:32 +000063 immr->STATUS_LED_DAT &= ~mask;
64 else
65 immr->STATUS_LED_DAT |= mask;
66#else
Uri Mashiach4892d392017-01-19 10:51:45 +020067 if (state == CONFIG_LED_STATUS_ON)
wdenk7539dea2003-06-19 23:01:32 +000068 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__ */