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