fc100cfb0eb128226d55a53d7287261623454ec0
[openwrt/openwrt.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 USE_PROCD=1
7
8 EXTRA_COMMANDS="status lucistat"
9 EXTRA_HELP=" status Get DSL status information
10 lucistat Get status information if lua friendly format"
11
12 [ -f /lib/functions/lantiq_dsl.sh ] && . /lib/functions/lantiq_dsl.sh
13
14 #
15 # ITU-T G.997.1 (06/2012) - Section 7.3.1.1.1 (xTU transmission system enabling (XTSE))
16 # ITU-T G.997.1 Amendment 2 (04/2013) - Section 2.1 - (Vectoring mode enable (VECTORMODE_ENABLE))
17 #
18 # G.992.1 Annex A
19 # G.992.3 Annex A / L-US1 / L_US-2 / M
20 # G.992.5 Annex A / M
21 # G.993.2 Annex A/B/C
22 # G.993.5 Annex A/B/C
23 xtse_xdsl_a="05_00_04_00_4C_01_04_0F"
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 # G.993.5 Annex A/B/C
30 xtse_xdsl_b="10_00_10_00_00_04_00_0F"
31
32 # G.992.1 Annex B
33 # G.992.3 Annex B
34 # G.992.3 Annex J
35 # G.992.5 Annex B
36 # G.992.5 Annex J
37 # G.993.2 Annex A/B/C
38 # G.993.5 Annex A/B/C
39 xtse_xdsl_j="10_00_10_40_00_04_01_0F"
40
41 #
42 # ITU-T G.994.1 (06/2012) - Table 2 (Mandatory carrier sets)
43 #
44
45 # A43
46 tone_adsl_a="0x142" # A43C + J43 + A43
47 tone_vdsl_a="0x142" # A43C + J43 + A43
48
49 # A43 + V43
50 tone_adsl_av="0x142" # A43C + J43 + A43
51 tone_vdsl_av="0x146" # A43C + J43 + A43 + V43
52
53 # B43
54 tone_adsl_b="0x81" # B43 + B43c
55 tone_vdsl_b="0x1" # B43
56
57 # B43 + V43
58 tone_adsl_bv="0x81" # B43 + B43c
59 tone_vdsl_bv="0x5" # B43 + V43
60
61 lowlevel_cfg() {
62 echo "# VRX Low Level Configuration File
63 #
64 # Parameters must be separated by tabs or spaces.
65 # Empty lines and comments will be ignored.
66 #
67
68 # nFilter
69 #
70 # NA = -1
71 # OFF = 0
72 # ISDN = 1
73 # POTS = 2
74 # POTS_2 = 3
75 # POTS_3 = 4
76 #
77 # (dec)
78 -1
79
80 # nHsToneGroupMode nHsToneGroup_A nHsToneGroup_V nHsToneGroup_AV
81 #
82 # NA = -1 NA = -1 see see
83 # AUTO = 0 VDSL2_B43 = 0x0001 nHsToneGroup_A nHsToneGroup_A
84 # MANUAL = 1 VDSL2_A43 = 0x0002
85 # VDSL2_V43 = 0x0004
86 # VDSL1_V43P = 0x0008
87 # VDSL1_V43I = 0x0010
88 # ADSL1_C43 = 0x0020
89 # ADSL2_J43 = 0x0040
90 # ADSL2_B43C = 0x0080
91 # ADSL2_A43C = 0x0100
92 #
93 # (dec) (hex) (hex) (hex)
94 1 $1 $2 0x0
95
96 # nBaseAddr nIrqNum
97 #
98 # (hex) (dec)
99 0x1e116000 63
100
101 # nUtopiaPhyAdr nUtopiaBusWidth nPosPhyParity
102 # default(16b) = 0 NA = -1
103 # 8-bit = 1 ODD = 0
104 # 16-bit = 2
105 #
106 #
107 # (hex) (dec) (dec)
108 0xFF 0 0
109
110 # bNtrEnable
111 #
112 # (dec)
113 0" > /tmp/lowlevel.cfg
114 }
115
116 service_triggers() {
117 procd_add_reload_trigger network
118 }
119
120 start_service() {
121 local annex
122 local firmware
123 local tone
124 local tone_adsl
125 local tone_vdsl
126 local xtse
127 local mode
128 local lowlevel
129
130 config_load network
131 config_get tone dsl tone
132 config_get annex dsl annex
133 config_get firmware dsl firmware
134 config_get xfer_mode dsl xfer_mode
135
136 eval "xtse=\"\${xtse_xdsl_$annex}\""
137
138 [ -z "${xfer_mode}" ] && xfer_mode=ptm
139
140 case "${xfer_mode}" in
141 atm)
142 LOAD=ltq_atm_vr9
143 UNLOAD=ltq_ptm_vr9
144 mode=1
145
146 # mask out VDSL bits when ATM is requested
147 xtse="${xtse%_*}_00"
148 ;;
149 *)
150 LOAD=ltq_ptm_vr9
151 UNLOAD=ltq_atm_vr9
152 mode=2
153 ;;
154 esac
155
156 [ -z "${firmware}" ] && firmware=/lib/firmware/vdsl.bin
157 [ -f "${firmware}" ] || {
158 echo failed to find $firmware
159 return 1
160 }
161
162 eval "tone_adsl=\"\${tone_adsl_$tone}\""
163 eval "tone_vdsl=\"\${tone_vdsl_$tone}\""
164 [ -n "${tone_adsl}" ] && [ -n "${tone_vdsl}" ] && {
165 lowlevel_cfg "${tone_adsl}" "${tone_vdsl}"
166 lowlevel="-l /tmp/lowlevel.cfg"
167 }
168
169 procd_open_instance
170 procd_set_param command /sbin/vdsl_cpe_control_wrapper \
171 -i$xtse \
172 -n /sbin/dsl_notify.sh \
173 -f ${firmware} \
174 $lowlevel \
175 -M ${mode}
176 procd_append_param env "LOAD=$LOAD" "UNLOAD=$UNLOAD"
177 procd_close_instance
178 }
179
180 stop_service() {
181 DSL_NOTIFICATION_TYPE="DSL_INTERFACE_STATUS" \
182 DSL_INTERFACE_STATUS="DOWN" \
183 /sbin/dsl_notify.sh
184 }