dsl_control 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2012 OpenWrt.org
  3. # needs to start before the atm layer which starts at 50
  4. START=48
  5. EXTRA_COMMANDS="status lucistat"
  6. EXTRA_HELP=" status Get DSL status information
  7. lucistat Get status information if lua friendly format"
  8. SERVICE_DAEMONIZE=1
  9. SERVICE_WRITE_PID=1
  10. [ -f /lib/functions/lantiq_dsl.sh ] && . /lib/functions/lantiq_dsl.sh
  11. XDSL_CTRL=vdsl_cpe_control
  12. # G.992.1 Annex A
  13. # G.992.2 Annex A
  14. # G.992.3 Annex A
  15. # G.992.4 Annex A
  16. # G.992.5 Annex A
  17. # G.993.2 Annex A/B/C
  18. xtse_adsl_a="04 01 04 01 00 01 00 00"
  19. # G.992.1 Annex B
  20. # G.992.3 Annex B
  21. # G.992.5 Annex B
  22. # G.993.2 Annex A/B/C
  23. xtse_adsl_b="10 00 10 00 00 04 00 00"
  24. # G.992.1 Annex B
  25. # G.992.3 Annex B
  26. # G.992.3 Annex J
  27. # G.992.5 Annex B
  28. # G.992.5 Annex J
  29. # G.993.2 Annex A/B/C
  30. xtse_adsl_j="10 00 10 40 00 04 01 00"
  31. xtse_vdsl="00 00 00 00 00 00 00 07"
  32. xdsl_scr() {
  33. val=`echo $2 | sed "s/ / 0x/g"`
  34. echo "[WaitForConfiguration]={
  35. #G997XTUSEC_g997xtusecs 0x$val
  36. }
  37. [WaitForLinkActivate]={
  38. }
  39. [WaitForRestart]={
  40. }
  41. [Common]={
  42. }" > /tmp/$1.scr
  43. }
  44. # A43
  45. tone_adsl_a="0x142"
  46. tone_vdsl_a="0x142"
  47. # A43 + V43
  48. tone_adsl_av="0x142"
  49. tone_vdsl_av="0x146"
  50. # B43
  51. tone_adsl_b="0x1"
  52. tone_vdsl_b="0x1"
  53. # B43 + V43
  54. tone_adsl_bv="0x1"
  55. tone_vdsl_bv="0x5"
  56. lowlevel_cfg() {
  57. echo "# VRX Low Level Configuration File
  58. #
  59. # Parameters must be separated by tabs or spaces.
  60. # Empty lines and comments will be ignored.
  61. #
  62. # nFilter
  63. #
  64. # NA = -1
  65. # OFF = 0
  66. # ISDN = 1
  67. # POTS = 2
  68. # POTS_2 = 3
  69. # POTS_3 = 4
  70. #
  71. # (dec)
  72. -1
  73. # nHsToneGroupMode nHsToneGroup_A nHsToneGroup_V nHsToneGroup_AV
  74. #
  75. # NA = -1 NA = -1 see see
  76. # AUTO = 0 VDSL2_B43 = 0x0001 nHsToneGroup_A nHsToneGroup_A
  77. # MANUAL = 1 VDSL2_A43 = 0x0002
  78. # VDSL2_V43 = 0x0004
  79. # VDSL1_V43P = 0x0008
  80. # VDSL1_V43I = 0x0010
  81. # ADSL1_C43 = 0x0020
  82. # ADSL2_J43 = 0x0040
  83. # ADSL2_B43C = 0x0080
  84. # ADSL2_A43C = 0x0100
  85. #
  86. # (dec) (hex) (hex) (hex)
  87. 1 $1 $2 0x0
  88. # nBaseAddr nIrqNum
  89. #
  90. # (hex) (dec)
  91. 0x1e116000 63
  92. # nUtopiaPhyAdr nUtopiaBusWidth nPosPhyParity
  93. # default(16b) = 0 NA = -1
  94. # 8-bit = 1 ODD = 0
  95. # 16-bit = 2
  96. #
  97. #
  98. # (hex) (dec) (dec)
  99. 0xFF 0 0
  100. # bNtrEnable
  101. #
  102. # (dec)
  103. 0" > /tmp/lowlevel.cfg
  104. }
  105. start() {
  106. local annex
  107. local firmware
  108. local tone
  109. local tone_adsl
  110. local tone_vdsl
  111. local xtse
  112. local xtse_adsl
  113. local mode
  114. config_load network
  115. config_get tone dsl tone
  116. config_get annex dsl annex
  117. config_get firmware dsl firmware
  118. config_get xfer_mode dsl xfer_mode
  119. [ -z "${xfer_mode}" ] && xfer_mode=ptm
  120. case "${xfer_mode}" in
  121. atm)
  122. insmod ltq_atm_vr9
  123. mode=1
  124. ;;
  125. *)
  126. insmod ltq_ptm_vr9
  127. mode=2
  128. ;;
  129. esac
  130. eval "xtse_adsl=\"\${xtse_adsl_$annex}\""
  131. if [ "${xtse_adsl}" ]; then
  132. xtse=$xtse_adsl
  133. else
  134. xtse_adsl=$xtse_adsl_a
  135. xtse=$xtse_vdsl
  136. fi
  137. eval "tone_adsl=\"\${tone_adsl_$tone}\""
  138. [ -z "${tone_adsl}" ] && tone_adsl=$tone_adsl_av
  139. eval "tone_vdsl=\"\${tone_vdsl_$tone}\""
  140. [ -z "${tone_vdsl}" ] && tone_vdsl=$tone_vdsl_av
  141. [ -z "${firmware}" ] && firmware=/lib/firmware/vdsl.bin
  142. [ -f "${firmware}" ] || {
  143. echo failed to find $firmware
  144. return 1
  145. }
  146. xdsl_scr adsl "${xtse_adsl}"
  147. xdsl_scr vdsl "${xtse_vdsl}"
  148. lowlevel_cfg "${tone_adsl}" "${tone_vdsl}"
  149. service_start /sbin/vdsl_cpe_control \
  150. -i `echo $xtse | sed "s/ /_/g"` \
  151. -n /sbin/dsl_notify.sh \
  152. -f ${firmware} \
  153. -a /tmp/adsl.scr \
  154. -A /tmp/vdsl.scr \
  155. -l /tmp/lowlevel.cfg \
  156. -M ${mode}
  157. }
  158. stop() {
  159. DSL_NOTIFICATION_TYPE="DSL_INTERFACE_STATUS" \
  160. DSL_INTERFACE_STATUS="DOWN" \
  161. /sbin/dsl_notify.sh
  162. service_stop /sbin/vdsl_cpe_control
  163. }