status_led.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. /***** GEN860T *********************************************************/
  46. #elif defined(CONFIG_GEN860T)
  47. # define STATUS_LED_PAR im_ioport.iop_papar
  48. # define STATUS_LED_DIR im_ioport.iop_padir
  49. # define STATUS_LED_ODR im_ioport.iop_paodr
  50. # define STATUS_LED_DAT im_ioport.iop_padat
  51. # define STATUS_LED_BIT 0x0800 /* Red LED 0 is on PA.4 */
  52. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 4)
  53. # define STATUS_LED_STATE STATUS_LED_OFF
  54. # define STATUS_LED_BIT1 0x0400 /* Grn LED 1 is on PA.5 */
  55. # define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ / 8)
  56. # define STATUS_LED_STATE1 STATUS_LED_BLINKING
  57. # define STATUS_LED_BIT2 0x0080 /* Red LED 2 is on PA.8 */
  58. # define STATUS_LED_PERIOD2 (CONFIG_SYS_HZ / 4)
  59. # define STATUS_LED_STATE2 STATUS_LED_OFF
  60. # define STATUS_LED_BIT3 0x0040 /* Grn LED 3 is on PA.9 */
  61. # define STATUS_LED_PERIOD3 (CONFIG_SYS_HZ / 4)
  62. # define STATUS_LED_STATE3 STATUS_LED_OFF
  63. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */
  64. # define STATUS_LED_BOOT 1 /* Boot status on LED 1 */
  65. /***** IVMS8 **********************************************************/
  66. #elif defined(CONFIG_IVMS8)
  67. # define STATUS_LED_PAR im_cpm.cp_pbpar
  68. # define STATUS_LED_DIR im_cpm.cp_pbdir
  69. # define STATUS_LED_ODR im_cpm.cp_pbodr
  70. # define STATUS_LED_DAT im_cpm.cp_pbdat
  71. # define STATUS_LED_BIT 0x00000010 /* LED 0 is on PB.27 */
  72. # define STATUS_LED_PERIOD (1 * CONFIG_SYS_HZ)
  73. # define STATUS_LED_STATE STATUS_LED_OFF
  74. # define STATUS_LED_BIT1 0x00000020 /* LED 1 is on PB.26 */
  75. # define STATUS_LED_PERIOD1 (1 * CONFIG_SYS_HZ)
  76. # define STATUS_LED_STATE1 STATUS_LED_OFF
  77. /* IDE LED usable for other purposes, too */
  78. # define STATUS_LED_BIT2 0x00000008 /* LED 2 is on PB.28 */
  79. # define STATUS_LED_PERIOD2 (1 * CONFIG_SYS_HZ)
  80. # define STATUS_LED_STATE2 STATUS_LED_OFF
  81. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */
  82. # define STATUS_ILOCK_SWITCH 0x00800000 /* ILOCK switch in IRQ4 */
  83. # define STATUS_ILOCK_PERIOD (CONFIG_SYS_HZ / 10) /* about every 100 ms */
  84. # define STATUS_LED_YELLOW 0
  85. # define STATUS_LED_GREEN 1
  86. # define STATUS_LED_BOOT 2 /* IDE LED used for boot status */
  87. /***** IVML24 *********************************************************/
  88. #elif defined(CONFIG_IVML24)
  89. # define STATUS_LED_PAR im_cpm.cp_pbpar
  90. # define STATUS_LED_DIR im_cpm.cp_pbdir
  91. # define STATUS_LED_ODR im_cpm.cp_pbodr
  92. # define STATUS_LED_DAT im_cpm.cp_pbdat
  93. # define STATUS_LED_BIT 0x00000010 /* LED 0 is on PB.27 */
  94. # define STATUS_LED_PERIOD (1 * CONFIG_SYS_HZ)
  95. # define STATUS_LED_STATE STATUS_LED_OFF
  96. # define STATUS_LED_BIT1 0x00000020 /* LED 1 is on PB.26 */
  97. # define STATUS_LED_PERIOD1 (1 * CONFIG_SYS_HZ)
  98. # define STATUS_LED_STATE1 STATUS_LED_OFF
  99. /* IDE LED usable for other purposes, too */
  100. # define STATUS_LED_BIT2 0x00000008 /* LED 2 is on PB.28 */
  101. # define STATUS_LED_PERIOD2 (1 * CONFIG_SYS_HZ)
  102. # define STATUS_LED_STATE2 STATUS_LED_OFF
  103. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */
  104. # define STATUS_ILOCK_SWITCH 0x00004000 /* ILOCK is on PB.17 */
  105. # define STATUS_ILOCK_PERIOD (CONFIG_SYS_HZ / 10) /* about every 100 ms */
  106. # define STATUS_LED_YELLOW 0
  107. # define STATUS_LED_GREEN 1
  108. # define STATUS_LED_BOOT 2 /* IDE LED used for boot status */
  109. /***** ICU862 ********************************************************/
  110. #elif defined(CONFIG_ICU862)
  111. # define STATUS_LED_PAR im_ioport.iop_papar
  112. # define STATUS_LED_DIR im_ioport.iop_padir
  113. # define STATUS_LED_ODR im_ioport.iop_paodr
  114. # define STATUS_LED_DAT im_ioport.iop_padat
  115. # define STATUS_LED_BIT 0x4000 /* LED 0 is on PA.1 */
  116. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
  117. # define STATUS_LED_STATE STATUS_LED_BLINKING
  118. # define STATUS_LED_BIT1 0x1000 /* LED 1 is on PA.3 */
  119. # define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ)
  120. # define STATUS_LED_STATE1 STATUS_LED_OFF
  121. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */
  122. # define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  123. /***** Someone else defines these *************************************/
  124. #elif defined(STATUS_LED_PAR)
  125. /*
  126. * ADVICE: Define in your board configuration file rather than
  127. * filling this file up with lots of custom board stuff.
  128. */
  129. /***** NetVia ********************************************************/
  130. #elif defined(CONFIG_NETVIA)
  131. #if !defined(CONFIG_NETVIA_VERSION) || CONFIG_NETVIA_VERSION == 1
  132. #define STATUS_LED_PAR im_ioport.iop_pdpar
  133. #define STATUS_LED_DIR im_ioport.iop_pddir
  134. #undef STATUS_LED_ODR
  135. #define STATUS_LED_DAT im_ioport.iop_pddat
  136. # define STATUS_LED_BIT 0x0080 /* PD.8 */
  137. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
  138. # define STATUS_LED_STATE STATUS_LED_BLINKING
  139. # define STATUS_LED_BIT1 0x0040 /* PD.9 */
  140. # define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ / 2)
  141. # define STATUS_LED_STATE1 STATUS_LED_OFF
  142. # define STATUS_LED_ACTIVE 0 /* LED on for bit == 0 */
  143. # define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  144. #endif
  145. /***** CMI ********************************************************/
  146. #elif defined(CONFIG_CMI)
  147. # define STATUS_LED_DIR im_mios.mios_mpiosm32ddr
  148. # define STATUS_LED_DAT im_mios.mios_mpiosm32dr
  149. # define STATUS_LED_BIT 0x2000 /* Select one of the 16 possible*/
  150. /* MIOS outputs */
  151. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2) /* Blinking periode is 500 ms */
  152. # define STATUS_LED_STATE STATUS_LED_BLINKING
  153. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 0 */
  154. # define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  155. /***** KUP4K, KUP4X ****************************************************/
  156. #elif defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X)
  157. # define STATUS_LED_PAR im_ioport.iop_papar
  158. # define STATUS_LED_DIR im_ioport.iop_padir
  159. # define STATUS_LED_ODR im_ioport.iop_paodr
  160. # define STATUS_LED_DAT im_ioport.iop_padat
  161. # define STATUS_LED_BIT 0x00000300 /* green + red PA[8]=yellow, PA[7]=red, PA[6]=green */
  162. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
  163. # define STATUS_LED_STATE STATUS_LED_BLINKING
  164. # define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */
  165. # define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  166. #elif defined(CONFIG_V38B)
  167. # define STATUS_LED_BIT 0x0010 /* Timer7 GPIO */
  168. # define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
  169. # define STATUS_LED_STATE STATUS_LED_BLINKING
  170. # define STATUS_LED_ACTIVE 0 /* LED on for bit == 0 */
  171. # define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  172. #elif defined(CONFIG_MOTIONPRO)
  173. #define STATUS_LED_BIT ((vu_long *) MPC5XXX_GPT6_ENABLE)
  174. #define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 10)
  175. #define STATUS_LED_STATE STATUS_LED_BLINKING
  176. #define STATUS_LED_BIT1 ((vu_long *) MPC5XXX_GPT7_ENABLE)
  177. #define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ / 10)
  178. #define STATUS_LED_STATE1 STATUS_LED_OFF
  179. #define STATUS_LED_BOOT 0 /* LED 0 used for boot status */
  180. #elif defined(CONFIG_BOARD_SPECIFIC_LED)
  181. /* led_id_t is unsigned long mask */
  182. typedef unsigned long led_id_t;
  183. extern void __led_toggle (led_id_t mask);
  184. extern void __led_init (led_id_t mask, int state);
  185. extern void __led_set (led_id_t mask, int state);
  186. #else
  187. # error Status LED configuration missing
  188. #endif
  189. /************************************************************************/
  190. #ifndef CONFIG_BOARD_SPECIFIC_LED
  191. # include <asm/status_led.h>
  192. #endif
  193. #endif /* CONFIG_STATUS_LED */
  194. /*
  195. * Coloured LEDs API
  196. */
  197. #ifndef __ASSEMBLY__
  198. void coloured_LED_init(void);
  199. void red_led_on(void);
  200. void red_led_off(void);
  201. void green_led_on(void);
  202. void green_led_off(void);
  203. void yellow_led_on(void);
  204. void yellow_led_off(void);
  205. void blue_led_on(void);
  206. void blue_led_off(void);
  207. #else
  208. .extern LED_init
  209. .extern red_led_on
  210. .extern red_led_off
  211. .extern yellow_led_on
  212. .extern yellow_led_off
  213. .extern green_led_on
  214. .extern green_led_off
  215. .extern blue_led_on
  216. .extern blue_led_off
  217. #endif
  218. #endif /* _STATUS_LED_H_ */