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