status_led.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*
  2. * (C) Copyright 2000-2004
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. /*
  8. * The purpose of this code is to signal the operational status of a
  9. * target which usually boots over the network; while running in
  10. * PCBoot, a status LED is blinking. As soon as a valid BOOTP reply
  11. * message has been received, the LED is turned off. The Linux
  12. * kernel, once it is running, will start blinking the LED again,
  13. * with another frequency.
  14. */
  15. #ifndef _STATUS_LED_H_
  16. #define _STATUS_LED_H_
  17. #ifdef CONFIG_STATUS_LED
  18. #define STATUS_LED_OFF 0
  19. #define STATUS_LED_BLINKING 1
  20. #define STATUS_LED_ON 2
  21. void status_led_tick (unsigned long timestamp);
  22. void status_led_set (int led, int state);
  23. /***** TQM8xxL ********************************************************/
  24. #if defined(CONFIG_TQM8xxL)
  25. # define STATUS_LED_PAR im_cpm.cp_pbpar
  26. # define STATUS_LED_DIR im_cpm.cp_pbdir
  27. # define STATUS_LED_ODR im_cpm.cp_pbodr
  28. # define STATUS_LED_DAT im_cpm.cp_pbdat
  29. # define STATUS_LED_BIT 0x00000001
  30. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
  31. # define STATUS_LED_STATE STATUS_LED_BLINKING
  32. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */
  33. # define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  34. /***** MVS v1 **********************************************************/
  35. #elif (defined(CONFIG_MVS) && CONFIG_MVS < 2)
  36. # define STATUS_LED_PAR im_ioport.iop_pdpar
  37. # define STATUS_LED_DIR im_ioport.iop_pddir
  38. # undef STATUS_LED_ODR
  39. # define STATUS_LED_DAT im_ioport.iop_pddat
  40. # define STATUS_LED_BIT 0x00000001
  41. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
  42. # define STATUS_LED_STATE STATUS_LED_BLINKING
  43. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */
  44. # define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  45. /***** IVMS8 **********************************************************/
  46. #elif defined(CONFIG_IVMS8)
  47. # define STATUS_LED_PAR im_cpm.cp_pbpar
  48. # define STATUS_LED_DIR im_cpm.cp_pbdir
  49. # define STATUS_LED_ODR im_cpm.cp_pbodr
  50. # define STATUS_LED_DAT im_cpm.cp_pbdat
  51. # define STATUS_LED_BIT 0x00000010 /* LED 0 is on PB.27 */
  52. # define STATUS_LED_PERIOD (1 * CONFIG_SYS_HZ)
  53. # define STATUS_LED_STATE STATUS_LED_OFF
  54. # define STATUS_LED_BIT1 0x00000020 /* LED 1 is on PB.26 */
  55. # define STATUS_LED_PERIOD1 (1 * CONFIG_SYS_HZ)
  56. # define STATUS_LED_STATE1 STATUS_LED_OFF
  57. /* IDE LED usable for other purposes, too */
  58. # define STATUS_LED_BIT2 0x00000008 /* LED 2 is on PB.28 */
  59. # define STATUS_LED_PERIOD2 (1 * CONFIG_SYS_HZ)
  60. # define STATUS_LED_STATE2 STATUS_LED_OFF
  61. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */
  62. # define STATUS_ILOCK_SWITCH 0x00800000 /* ILOCK switch in IRQ4 */
  63. # define STATUS_ILOCK_PERIOD (CONFIG_SYS_HZ / 10) /* about every 100 ms */
  64. # define STATUS_LED_YELLOW 0
  65. # define STATUS_LED_GREEN 1
  66. # define STATUS_LED_BOOT 2 /* IDE LED used for boot status */
  67. /***** IVML24 *********************************************************/
  68. #elif defined(CONFIG_IVML24)
  69. # define STATUS_LED_PAR im_cpm.cp_pbpar
  70. # define STATUS_LED_DIR im_cpm.cp_pbdir
  71. # define STATUS_LED_ODR im_cpm.cp_pbodr
  72. # define STATUS_LED_DAT im_cpm.cp_pbdat
  73. # define STATUS_LED_BIT 0x00000010 /* LED 0 is on PB.27 */
  74. # define STATUS_LED_PERIOD (1 * CONFIG_SYS_HZ)
  75. # define STATUS_LED_STATE STATUS_LED_OFF
  76. # define STATUS_LED_BIT1 0x00000020 /* LED 1 is on PB.26 */
  77. # define STATUS_LED_PERIOD1 (1 * CONFIG_SYS_HZ)
  78. # define STATUS_LED_STATE1 STATUS_LED_OFF
  79. /* IDE LED usable for other purposes, too */
  80. # define STATUS_LED_BIT2 0x00000008 /* LED 2 is on PB.28 */
  81. # define STATUS_LED_PERIOD2 (1 * CONFIG_SYS_HZ)
  82. # define STATUS_LED_STATE2 STATUS_LED_OFF
  83. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */
  84. # define STATUS_ILOCK_SWITCH 0x00004000 /* ILOCK is on PB.17 */
  85. # define STATUS_ILOCK_PERIOD (CONFIG_SYS_HZ / 10) /* about every 100 ms */
  86. # define STATUS_LED_YELLOW 0
  87. # define STATUS_LED_GREEN 1
  88. # define STATUS_LED_BOOT 2 /* IDE LED used for boot status */
  89. /***** ICU862 ********************************************************/
  90. #elif defined(CONFIG_ICU862)
  91. # define STATUS_LED_PAR im_ioport.iop_papar
  92. # define STATUS_LED_DIR im_ioport.iop_padir
  93. # define STATUS_LED_ODR im_ioport.iop_paodr
  94. # define STATUS_LED_DAT im_ioport.iop_padat
  95. # define STATUS_LED_BIT 0x4000 /* LED 0 is on PA.1 */
  96. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
  97. # define STATUS_LED_STATE STATUS_LED_BLINKING
  98. # define STATUS_LED_BIT1 0x1000 /* LED 1 is on PA.3 */
  99. # define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ)
  100. # define STATUS_LED_STATE1 STATUS_LED_OFF
  101. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */
  102. # define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  103. /***** Someone else defines these *************************************/
  104. #elif defined(STATUS_LED_PAR)
  105. /*
  106. * ADVICE: Define in your board configuration file rather than
  107. * filling this file up with lots of custom board stuff.
  108. */
  109. /***** NetVia ********************************************************/
  110. #elif defined(CONFIG_NETVIA)
  111. #if !defined(CONFIG_NETVIA_VERSION) || CONFIG_NETVIA_VERSION == 1
  112. #define STATUS_LED_PAR im_ioport.iop_pdpar
  113. #define STATUS_LED_DIR im_ioport.iop_pddir
  114. #undef STATUS_LED_ODR
  115. #define STATUS_LED_DAT im_ioport.iop_pddat
  116. # define STATUS_LED_BIT 0x0080 /* PD.8 */
  117. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
  118. # define STATUS_LED_STATE STATUS_LED_BLINKING
  119. # define STATUS_LED_BIT1 0x0040 /* PD.9 */
  120. # define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ / 2)
  121. # define STATUS_LED_STATE1 STATUS_LED_OFF
  122. # define STATUS_LED_ACTIVE 0 /* LED on for bit == 0 */
  123. # define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  124. #endif
  125. /***** CMI ********************************************************/
  126. #elif defined(CONFIG_CMI)
  127. # define STATUS_LED_DIR im_mios.mios_mpiosm32ddr
  128. # define STATUS_LED_DAT im_mios.mios_mpiosm32dr
  129. # define STATUS_LED_BIT 0x2000 /* Select one of the 16 possible*/
  130. /* MIOS outputs */
  131. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2) /* Blinking periode is 500 ms */
  132. # define STATUS_LED_STATE STATUS_LED_BLINKING
  133. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 0 */
  134. # define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  135. /***** KUP4K, KUP4X ****************************************************/
  136. #elif defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X)
  137. # define STATUS_LED_PAR im_ioport.iop_papar
  138. # define STATUS_LED_DIR im_ioport.iop_padir
  139. # define STATUS_LED_ODR im_ioport.iop_paodr
  140. # define STATUS_LED_DAT im_ioport.iop_padat
  141. # define STATUS_LED_BIT 0x00000300 /* green + red PA[8]=yellow, PA[7]=red, PA[6]=green */
  142. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
  143. # define STATUS_LED_STATE STATUS_LED_BLINKING
  144. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */
  145. # define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  146. #elif defined(CONFIG_V38B)
  147. # define STATUS_LED_BIT 0x0010 /* Timer7 GPIO */
  148. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
  149. # define STATUS_LED_STATE STATUS_LED_BLINKING
  150. # define STATUS_LED_ACTIVE 0 /* LED on for bit == 0 */
  151. # define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  152. #elif defined(CONFIG_MOTIONPRO)
  153. #define STATUS_LED_BIT ((vu_long *) MPC5XXX_GPT6_ENABLE)
  154. #define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 10)
  155. #define STATUS_LED_STATE STATUS_LED_BLINKING
  156. #define STATUS_LED_BIT1 ((vu_long *) MPC5XXX_GPT7_ENABLE)
  157. #define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ / 10)
  158. #define STATUS_LED_STATE1 STATUS_LED_OFF
  159. #define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  160. #elif defined(CONFIG_BOARD_SPECIFIC_LED)
  161. /* led_id_t is unsigned long mask */
  162. typedef unsigned long led_id_t;
  163. extern void __led_toggle (led_id_t mask);
  164. extern void __led_init (led_id_t mask, int state);
  165. extern void __led_set (led_id_t mask, int state);
  166. #else
  167. # error Status LED configuration missing
  168. #endif
  169. /************************************************************************/
  170. #ifndef CONFIG_BOARD_SPECIFIC_LED
  171. # include <asm/status_led.h>
  172. #endif
  173. #endif /* CONFIG_STATUS_LED */
  174. /*
  175. * Coloured LEDs API
  176. */
  177. #ifndef __ASSEMBLY__
  178. void coloured_LED_init(void);
  179. void red_led_on(void);
  180. void red_led_off(void);
  181. void green_led_on(void);
  182. void green_led_off(void);
  183. void yellow_led_on(void);
  184. void yellow_led_off(void);
  185. void blue_led_on(void);
  186. void blue_led_off(void);
  187. #else
  188. .extern LED_init
  189. .extern red_led_on
  190. .extern red_led_off
  191. .extern yellow_led_on
  192. .extern yellow_led_off
  193. .extern green_led_on
  194. .extern green_led_off
  195. .extern blue_led_on
  196. .extern blue_led_off
  197. #endif
  198. #endif /* _STATUS_LED_H_ */