hwctl.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * hwctl.c
  3. *
  4. * LinkStation HW Control Driver
  5. *
  6. * Copyright (C) 2001-2004 BUFFALO INC.
  7. *
  8. * This software may be used and distributed according to the terms of
  9. * the GNU General Public License (GPL), incorporated herein by reference.
  10. * Drivers based on or derived from this code fall under the GPL and must
  11. * retain the authorship, copyright and license notice. This file is not
  12. * a complete program and may only be used when the entire operating
  13. * system is licensed under the GPL.
  14. *
  15. */
  16. #include <config.h>
  17. #include <common.h>
  18. #include <command.h>
  19. #include <asm/io.h>
  20. #define mdelay(n) udelay((n)*1000)
  21. #define AVR_PORT CONFIG_SYS_NS16550_COM2
  22. /* 2005.5.10 BUFFALO add */
  23. /*--------------------------------------------------------------*/
  24. static inline void miconCntl_SendUart(unsigned char dat)
  25. {
  26. out_8((unsigned char *)AVR_PORT, dat);
  27. mdelay(1);
  28. }
  29. /*--------------------------------------------------------------*/
  30. void miconCntl_SendCmd(unsigned char dat)
  31. {
  32. int i;
  33. for (i=0; i<4; i++){
  34. miconCntl_SendUart(dat);
  35. }
  36. }
  37. /*--------------------------------------------------------------*/
  38. void miconCntl_FanLow(void)
  39. {
  40. #ifdef CONFIG_HTGL
  41. miconCntl_SendCmd(0x5C);
  42. #endif
  43. }
  44. /*--------------------------------------------------------------*/
  45. void miconCntl_FanHigh(void)
  46. {
  47. #ifdef CONFIG_HTGL
  48. miconCntl_SendCmd(0x5D);
  49. #endif
  50. }
  51. /*--------------------------------------------------------------*/
  52. /* 1000Mbps */
  53. void miconCntl_Eth1000M(int up)
  54. {
  55. #ifdef CONFIG_HTGL
  56. if (up)
  57. miconCntl_SendCmd(0x93);
  58. else
  59. miconCntl_SendCmd(0x92);
  60. #else
  61. if (up)
  62. miconCntl_SendCmd(0x5D);
  63. else
  64. miconCntl_SendCmd(0x5C);
  65. #endif
  66. }
  67. /*--------------------------------------------------------------*/
  68. /* 100Mbps */
  69. void miconCntl_Eth100M(int up)
  70. {
  71. #ifdef CONFIG_HTGL
  72. if (up)
  73. miconCntl_SendCmd(0x91);
  74. else
  75. miconCntl_SendCmd(0x90);
  76. #else
  77. if (up)
  78. miconCntl_SendCmd(0x5C);
  79. #endif
  80. }
  81. /*--------------------------------------------------------------*/
  82. /* 10Mbps */
  83. void miconCntl_Eth10M(int up)
  84. {
  85. #ifdef CONFIG_HTGL
  86. if (up)
  87. miconCntl_SendCmd(0x8F);
  88. else
  89. miconCntl_SendCmd(0x8E);
  90. #else
  91. if (up)
  92. miconCntl_SendCmd(0x5C);
  93. #endif
  94. }
  95. /*--------------------------------------------------------------*/
  96. /* */
  97. void miconCntl_5f(void)
  98. {
  99. miconCntl_SendCmd(0x5F);
  100. mdelay(100);
  101. }
  102. /*--------------------------------------------------------------*/
  103. /* "reboot start" signal */
  104. void miconCntl_Reboot(void)
  105. {
  106. miconCntl_SendCmd(0x43);
  107. }
  108. /*--------------------------------------------------------------*/
  109. /* Disable watchdog timer */
  110. void miconCntl_DisWDT(void)
  111. {
  112. miconCntl_SendCmd(0x41); /* A */
  113. miconCntl_SendCmd(0x46); /* F */
  114. miconCntl_SendCmd(0x4A); /* J */
  115. miconCntl_SendCmd(0x3E); /* > */
  116. miconCntl_SendCmd(0x56); /* V */
  117. miconCntl_SendCmd(0x3E); /* > */
  118. miconCntl_SendCmd(0x5A); /* Z */
  119. miconCntl_SendCmd(0x56); /* V */
  120. miconCntl_SendCmd(0x4B); /* K */
  121. }