From 47bcd1d6d884db6f92c68772aad712579f1c3b16 Mon Sep 17 00:00:00 2001 From: tzafrir Date: Sun, 29 Apr 2007 19:48:03 +0000 Subject: Beginning commit of rev. 3814: renaming xpd init scripts, as the protocol version has changed. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2473 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- xpp/init_card_3_24 | 185 ------------------------ xpp/init_card_3_26 | 185 ++++++++++++++++++++++++ xpp/init_card_4_24 | 172 ---------------------- xpp/init_card_4_26 | 172 ++++++++++++++++++++++ xpp/init_card_6_24 | 415 ----------------------------------------------------- xpp/init_card_6_26 | 415 +++++++++++++++++++++++++++++++++++++++++++++++++++++ xpp/init_card_7_24 | 415 ----------------------------------------------------- xpp/init_card_7_26 | 415 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 1187 insertions(+), 1187 deletions(-) delete mode 100755 xpp/init_card_3_24 create mode 100755 xpp/init_card_3_26 delete mode 100755 xpp/init_card_4_24 create mode 100755 xpp/init_card_4_26 delete mode 100755 xpp/init_card_6_24 create mode 100755 xpp/init_card_6_26 delete mode 100755 xpp/init_card_7_24 create mode 100755 xpp/init_card_7_26 (limited to 'xpp') diff --git a/xpp/init_card_3_24 b/xpp/init_card_3_24 deleted file mode 100755 index 3f07578..0000000 --- a/xpp/init_card_3_24 +++ /dev/null @@ -1,185 +0,0 @@ -#! /bin/sh -# -# Written by Oron Peled -# Copyright (C) 2006, Xorcom -# -# All rights reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# See the file LICENSE in the top level of this tarball. -# - -# -# $Id$ -# -# Data format: -# - A comment start with ';' or '#' until the end of line -# - Blank lines are ignored -# - Fields are whitespace separated (spaces or tabs) -# -# The fields are (in command line order): -# 1. SLIC select in decimal (range 0-7). -# 31 is a special value which means ALL SLICS (only some registers -# accept settings for ALL SLICS). -# 2. Command word: -# - RD Read Direct register. -# - RI Read Indirect register. -# - WD Write Direct register. -# - WI Write Indirect register. -# 3. Register number in hexadecimal. -# 4. Low data byte in hexadecimal. (for WD and WI commands). -# 5. High data byte in hexadecimal. (for WI command only). -# -# - -# ----------------------------------==== 8-channel FXS unit initialization ===----------------------------------------- - -set -e - -me=`basename $0` -INIT_DIR=`dirname $0` -XPP_BASE=/proc/xpp -export XPP_BASE -LOGGER="logger -s -t $me" - -ZAPTEL_BOOT_DEBIAN=${ZAPTEL_BOOT_DEBIAN:-/etc/default/zaptel} -ZAPTEL_BOOT_FEDORA=${ZAPTEL_BOOT_FEDORA:-/etc/sysconfig/zaptel} - -# read default configuration from /etc/default/zaptel -if [ -r $ZAPTEL_BOOT_DEBIAN ]; then . $ZAPTEL_BOOT_DEBIAN; fi -if [ -r $ZAPTEL_BOOT_FEDORA ]; then . $ZAPTEL_BOOT_FEDORA; fi - -if [ "$DEBUG_CALIBRATION"=1 ]; then - LOGGER=":" -fi - -# Always redirect stderr somewhere, otherwise the shell script will die -# when it tries to do I/O related stuff on closed file descriptor. -# Our default is to throw it down the bit-bucket. -exec 2> /dev/console -## If you wish to trace this script: -#exec 2> /tmp/xpp_init_$XPD_NAME -## Altenativly, if you have multiple XBUS'es: -#exec 2> /tmp/xpp_init_$XBUS_NAME_$XPD_NAME -#set -x - -# redirect script output to the "slics" (registers command) file: -exec 1> "$XPP_BASE/$XPD_BUS/$XPD_NAME/slics" - -$LOGGER -p kern.info "$XPD_BUS/$XPD_NAME: Calibrating '$0'" - -"$INIT_DIR/calibrate_slics" - -$LOGGER -p kern.info "$XPD_BUS/$XPD_NAME: Continue '$0'" - -echo " -# Change SLICs states to "Open state"s (Off,all transfers tristated to avoid data collision), Voltage sense -31 WD 40 00 - -# Flush out energy accumulators -31 WI 58 00 00 -31 WI 59 00 00 -31 WI 5A 00 00 -31 WI 5B 00 00 -31 WI 5C 00 00 -31 WI 5D 00 00 -31 WI 5E 00 00 -31 WI 5F 00 00 -31 WI 61 00 00 -31 WI 58 00 00 -31 WI C1 00 00 -31 WI C2 00 00 -31 WI C3 00 00 -31 WI C4 00 00 -31 WI C5 00 00 -31 WI C6 00 00 -31 WI C7 00 00 -31 WI C8 00 00 -31 WI C9 00 00 -31 WI CA 00 00 -31 WI CB 00 00 -31 WI CC 00 00 -31 WI CD 00 00 -31 WI CE 00 00 -31 WI CF 00 00 -31 WI D0 00 00 -31 WI D1 00 00 -31 WI D2 00 00 -31 WI D3 00 00 - -# Setting of SLICs offsets -# New card initialization -0 WD 02 00 -0 WD 04 00 -1 WD 02 08 -1 WD 04 08 -2 WD 02 10 -2 WD 04 10 -3 WD 02 18 -3 WD 04 18 -4 WD 02 20 -4 WD 04 20 -5 WD 02 28 -5 WD 04 28 -6 WD 02 30 -6 WD 04 30 -7 WD 02 38 -7 WD 04 38 -31 WD 03 00 -31 WD 05 00 - -# Audio path. (also initialize 0A and 0B here if necessary) -31 WD 08 00 -31 WD 09 00 - -31 WD 17 00 - -# Automatic/Manual Control: defaults - Cancel Power Alarm -31 WD 43 1E - -# Loop Closure Debounce Interval -31 WD 45 0A - -# Ring Detect Debounce Interval -31 WD 46 0B - -# Battery Feed Control: Battery low (DCSW low) -31 WD 42 00 - -# Loop Current Limit -31 WD 47 00 - -31 WD 6C 01 - -31 WI 23 00 80 -31 WI 24 20 03 -31 WI 25 8C 08 -31 WI 26 00 01 -31 WI 27 10 00 - - -# ------------------------------------- Initialization of direct registers -------------------------------------------- - -# Mode(8-bit,u-Law,1 PCLK ) setting, Loopbacks and Interrupts clear - -31 WD 01 29 -#31 WD 0E 00 - -#31 WD 15 00 -#31 WD 16 03 - -# Clear pending interrupts -31 WD 12 FF -31 WD 13 FF -31 WD 14 FF - -#31 WD 4A 34 -#31 WD 4B 10 -" | sed -e 's/[;#].*$//' -e '/^[ ]*$/d' - -$LOGGER -p kern.info "$XPD_BUS/$XPD_NAME: Ending '$0'" -exit 0 diff --git a/xpp/init_card_3_26 b/xpp/init_card_3_26 new file mode 100755 index 0000000..3f07578 --- /dev/null +++ b/xpp/init_card_3_26 @@ -0,0 +1,185 @@ +#! /bin/sh +# +# Written by Oron Peled +# Copyright (C) 2006, Xorcom +# +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# See the file LICENSE in the top level of this tarball. +# + +# +# $Id$ +# +# Data format: +# - A comment start with ';' or '#' until the end of line +# - Blank lines are ignored +# - Fields are whitespace separated (spaces or tabs) +# +# The fields are (in command line order): +# 1. SLIC select in decimal (range 0-7). +# 31 is a special value which means ALL SLICS (only some registers +# accept settings for ALL SLICS). +# 2. Command word: +# - RD Read Direct register. +# - RI Read Indirect register. +# - WD Write Direct register. +# - WI Write Indirect register. +# 3. Register number in hexadecimal. +# 4. Low data byte in hexadecimal. (for WD and WI commands). +# 5. High data byte in hexadecimal. (for WI command only). +# +# + +# ----------------------------------==== 8-channel FXS unit initialization ===----------------------------------------- + +set -e + +me=`basename $0` +INIT_DIR=`dirname $0` +XPP_BASE=/proc/xpp +export XPP_BASE +LOGGER="logger -s -t $me" + +ZAPTEL_BOOT_DEBIAN=${ZAPTEL_BOOT_DEBIAN:-/etc/default/zaptel} +ZAPTEL_BOOT_FEDORA=${ZAPTEL_BOOT_FEDORA:-/etc/sysconfig/zaptel} + +# read default configuration from /etc/default/zaptel +if [ -r $ZAPTEL_BOOT_DEBIAN ]; then . $ZAPTEL_BOOT_DEBIAN; fi +if [ -r $ZAPTEL_BOOT_FEDORA ]; then . $ZAPTEL_BOOT_FEDORA; fi + +if [ "$DEBUG_CALIBRATION"=1 ]; then + LOGGER=":" +fi + +# Always redirect stderr somewhere, otherwise the shell script will die +# when it tries to do I/O related stuff on closed file descriptor. +# Our default is to throw it down the bit-bucket. +exec 2> /dev/console +## If you wish to trace this script: +#exec 2> /tmp/xpp_init_$XPD_NAME +## Altenativly, if you have multiple XBUS'es: +#exec 2> /tmp/xpp_init_$XBUS_NAME_$XPD_NAME +#set -x + +# redirect script output to the "slics" (registers command) file: +exec 1> "$XPP_BASE/$XPD_BUS/$XPD_NAME/slics" + +$LOGGER -p kern.info "$XPD_BUS/$XPD_NAME: Calibrating '$0'" + +"$INIT_DIR/calibrate_slics" + +$LOGGER -p kern.info "$XPD_BUS/$XPD_NAME: Continue '$0'" + +echo " +# Change SLICs states to "Open state"s (Off,all transfers tristated to avoid data collision), Voltage sense +31 WD 40 00 + +# Flush out energy accumulators +31 WI 58 00 00 +31 WI 59 00 00 +31 WI 5A 00 00 +31 WI 5B 00 00 +31 WI 5C 00 00 +31 WI 5D 00 00 +31 WI 5E 00 00 +31 WI 5F 00 00 +31 WI 61 00 00 +31 WI 58 00 00 +31 WI C1 00 00 +31 WI C2 00 00 +31 WI C3 00 00 +31 WI C4 00 00 +31 WI C5 00 00 +31 WI C6 00 00 +31 WI C7 00 00 +31 WI C8 00 00 +31 WI C9 00 00 +31 WI CA 00 00 +31 WI CB 00 00 +31 WI CC 00 00 +31 WI CD 00 00 +31 WI CE 00 00 +31 WI CF 00 00 +31 WI D0 00 00 +31 WI D1 00 00 +31 WI D2 00 00 +31 WI D3 00 00 + +# Setting of SLICs offsets +# New card initialization +0 WD 02 00 +0 WD 04 00 +1 WD 02 08 +1 WD 04 08 +2 WD 02 10 +2 WD 04 10 +3 WD 02 18 +3 WD 04 18 +4 WD 02 20 +4 WD 04 20 +5 WD 02 28 +5 WD 04 28 +6 WD 02 30 +6 WD 04 30 +7 WD 02 38 +7 WD 04 38 +31 WD 03 00 +31 WD 05 00 + +# Audio path. (also initialize 0A and 0B here if necessary) +31 WD 08 00 +31 WD 09 00 + +31 WD 17 00 + +# Automatic/Manual Control: defaults - Cancel Power Alarm +31 WD 43 1E + +# Loop Closure Debounce Interval +31 WD 45 0A + +# Ring Detect Debounce Interval +31 WD 46 0B + +# Battery Feed Control: Battery low (DCSW low) +31 WD 42 00 + +# Loop Current Limit +31 WD 47 00 + +31 WD 6C 01 + +31 WI 23 00 80 +31 WI 24 20 03 +31 WI 25 8C 08 +31 WI 26 00 01 +31 WI 27 10 00 + + +# ------------------------------------- Initialization of direct registers -------------------------------------------- + +# Mode(8-bit,u-Law,1 PCLK ) setting, Loopbacks and Interrupts clear + +31 WD 01 29 +#31 WD 0E 00 + +#31 WD 15 00 +#31 WD 16 03 + +# Clear pending interrupts +31 WD 12 FF +31 WD 13 FF +31 WD 14 FF + +#31 WD 4A 34 +#31 WD 4B 10 +" | sed -e 's/[;#].*$//' -e '/^[ ]*$/d' + +$LOGGER -p kern.info "$XPD_BUS/$XPD_NAME: Ending '$0'" +exit 0 diff --git a/xpp/init_card_4_24 b/xpp/init_card_4_24 deleted file mode 100755 index 884923e..0000000 --- a/xpp/init_card_4_24 +++ /dev/null @@ -1,172 +0,0 @@ -#! /bin/sh -# -# Written by Oron Peled -# Copyright (C) 2006, Xorcom -# -# All rights reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# See the file LICENSE in the top level of this tarball. -# - -# -# $Id$ -# -# Data format: -# - A comment start with ';' or '#' until the end of line -# - Blank lines are ignored -# - Fields are whitespace separated (spaces or tabs) -# -# The fields are (in command line order): -# 1. DAA select in decimal (range 0-7). -# 31 is a special value which means ALL DAAs (only some registers -# accept settings for ALL DAAs). -# 2. Command word: -# - RD Read Direct register. -# - WD Write Direct register. -# 3. Register number in hexadecimal. -# 4. Data byte in hexadecimal. (for WD command). -# - -# ----------------------------------==== 8-channel FXO unit initialization ===----------------------------------------- - -set -e - -opermode='FCC' - -me=`basename $0` -INIT_DIR=`dirname $0` -XPP_BASE=/proc/xpp -export XPP_BASE -LOGGER="logger -s -t $me" - -ZAPTEL_BOOT_DEBIAN=${ZAPTEL_BOOT_DEBIAN:-/etc/default/zaptel} -ZAPTEL_BOOT_FEDORA=${ZAPTEL_BOOT_FEDORA:-/etc/sysconfig/zaptel} - -# read default configuration from /etc/default/zaptel -if [ -r $ZAPTEL_BOOT_DEBIAN ]; then . $ZAPTEL_BOOT_DEBIAN; fi -if [ -r $ZAPTEL_BOOT_FEDORA ]; then . $ZAPTEL_BOOT_FEDORA; fi - -if [ "$DEBUG_CALIBRATION"=1 ]; then - LOGGER=":" -fi - -# Always redirect stderr somewhere, otherwise the shell script will die -# when it tries to do I/O related stuff on closed file descriptor. -# Our default is to throw it down the bit-bucket. -exec 2> /dev/console -## If you wish to trace this script: -#exec 2> /tmp/xpp_init_$XPD_NAME -## Altenativly, if you have multiple XBUS'es: -#exec 2> /tmp/xpp_init_$XBUS_NAME_$XPD_NAME -#set -x - -# redirect script output to the "slics" (registers command) file: -exec 1> "$XPP_BASE/$XPD_BUS/$XPD_NAME/slics" - -$LOGGER -p kern.info "$XPD_BUS/$XPD_NAME: Initializing '$0'" - -set_daa_country_params() { - # based on fxo_modes from wctdm.c . TODO: more decent calculation? - reg16=00; reg26=00; reg30=00; reg31=A3; ring_osc=; ring_x=; - mode="$1" - # TODO: a saner fall-back in case of an unknown mode - if [ "$mode" = '' ]; then mode='FCC'; fi - if [ -r $INIT_DIR/init_fxo_modes ]; then - . $INIT_DIR/init_fxo_modes - fi - # Our register numbers are HEXADECIMAL! - echo " -31 WD 10 $reg16 -31 WD 1A $reg26 -31 WD 1E $reg30 -31 WD 1F $reg31 -" - # for the FXS: - #if [ "$ring_osc" != '' ]; then - # /bin/echo "31 WI __ $ring_osc" - #fi - #if [ "$ring_x" != '' ]; then - # /bin/echo "31 WI __ $ring_x" - #fi -} - -# Several countries (South Africa, UAE, anybody else) -# require a shorter delay: -case "$opermode" in -SOUTHAFRICA|UAE) echo 31 WD 17 2B;; -esac - -# Remove empty lines and commets. Not strictly necessary -# but works around some limitations of the proc interface: -echo " - - -31 WD 21 28 -31 WD 18 99 -31 WD 06 00 - -# ----------- DAA PCM start offset ---------- - -0 WD 22 00 -0 WD 23 00 -0 WD 24 00 -0 WD 25 00 - -1 WD 22 08 -1 WD 23 00 -1 WD 24 08 -1 WD 25 00 - -2 WD 22 10 -2 WD 23 00 -2 WD 24 10 -2 WD 25 00 - -3 WD 22 18 -3 WD 23 00 -3 WD 24 18 -3 WD 25 00 - -4 WD 22 20 -4 WD 23 00 -4 WD 24 20 -4 WD 25 00 - -5 WD 22 28 -5 WD 23 00 -5 WD 24 28 -5 WD 25 00 - -6 WD 22 30 -6 WD 23 00 -6 WD 24 30 -6 WD 25 00 - -7 WD 22 38 -7 WD 23 00 -7 WD 24 38 -7 WD 25 00 - -# ----------- DAA ONHOOK -------------------- -31 WD 05 00 - -# Set tip to ring voltage to 3.5 volts while off-hook -# instead of default of 3.1 -31 WD 1A C0 -" | sed -e 's/[;#].*$//' -e '/^[ ]*$/d' - -# Turning off red LEDs -# Warning: do not send WD 31 20 A0 ! -for i in `seq 0 7`; do - echo "$i WD 20 A0"; -done; - -set_daa_country_params "$opermode" - -$LOGGER -p kern.info "$XPD_BUS/$XPD_NAME: Ending '$0'" -exit 0 diff --git a/xpp/init_card_4_26 b/xpp/init_card_4_26 new file mode 100755 index 0000000..884923e --- /dev/null +++ b/xpp/init_card_4_26 @@ -0,0 +1,172 @@ +#! /bin/sh +# +# Written by Oron Peled +# Copyright (C) 2006, Xorcom +# +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# See the file LICENSE in the top level of this tarball. +# + +# +# $Id$ +# +# Data format: +# - A comment start with ';' or '#' until the end of line +# - Blank lines are ignored +# - Fields are whitespace separated (spaces or tabs) +# +# The fields are (in command line order): +# 1. DAA select in decimal (range 0-7). +# 31 is a special value which means ALL DAAs (only some registers +# accept settings for ALL DAAs). +# 2. Command word: +# - RD Read Direct register. +# - WD Write Direct register. +# 3. Register number in hexadecimal. +# 4. Data byte in hexadecimal. (for WD command). +# + +# ----------------------------------==== 8-channel FXO unit initialization ===----------------------------------------- + +set -e + +opermode='FCC' + +me=`basename $0` +INIT_DIR=`dirname $0` +XPP_BASE=/proc/xpp +export XPP_BASE +LOGGER="logger -s -t $me" + +ZAPTEL_BOOT_DEBIAN=${ZAPTEL_BOOT_DEBIAN:-/etc/default/zaptel} +ZAPTEL_BOOT_FEDORA=${ZAPTEL_BOOT_FEDORA:-/etc/sysconfig/zaptel} + +# read default configuration from /etc/default/zaptel +if [ -r $ZAPTEL_BOOT_DEBIAN ]; then . $ZAPTEL_BOOT_DEBIAN; fi +if [ -r $ZAPTEL_BOOT_FEDORA ]; then . $ZAPTEL_BOOT_FEDORA; fi + +if [ "$DEBUG_CALIBRATION"=1 ]; then + LOGGER=":" +fi + +# Always redirect stderr somewhere, otherwise the shell script will die +# when it tries to do I/O related stuff on closed file descriptor. +# Our default is to throw it down the bit-bucket. +exec 2> /dev/console +## If you wish to trace this script: +#exec 2> /tmp/xpp_init_$XPD_NAME +## Altenativly, if you have multiple XBUS'es: +#exec 2> /tmp/xpp_init_$XBUS_NAME_$XPD_NAME +#set -x + +# redirect script output to the "slics" (registers command) file: +exec 1> "$XPP_BASE/$XPD_BUS/$XPD_NAME/slics" + +$LOGGER -p kern.info "$XPD_BUS/$XPD_NAME: Initializing '$0'" + +set_daa_country_params() { + # based on fxo_modes from wctdm.c . TODO: more decent calculation? + reg16=00; reg26=00; reg30=00; reg31=A3; ring_osc=; ring_x=; + mode="$1" + # TODO: a saner fall-back in case of an unknown mode + if [ "$mode" = '' ]; then mode='FCC'; fi + if [ -r $INIT_DIR/init_fxo_modes ]; then + . $INIT_DIR/init_fxo_modes + fi + # Our register numbers are HEXADECIMAL! + echo " +31 WD 10 $reg16 +31 WD 1A $reg26 +31 WD 1E $reg30 +31 WD 1F $reg31 +" + # for the FXS: + #if [ "$ring_osc" != '' ]; then + # /bin/echo "31 WI __ $ring_osc" + #fi + #if [ "$ring_x" != '' ]; then + # /bin/echo "31 WI __ $ring_x" + #fi +} + +# Several countries (South Africa, UAE, anybody else) +# require a shorter delay: +case "$opermode" in +SOUTHAFRICA|UAE) echo 31 WD 17 2B;; +esac + +# Remove empty lines and commets. Not strictly necessary +# but works around some limitations of the proc interface: +echo " + + +31 WD 21 28 +31 WD 18 99 +31 WD 06 00 + +# ----------- DAA PCM start offset ---------- + +0 WD 22 00 +0 WD 23 00 +0 WD 24 00 +0 WD 25 00 + +1 WD 22 08 +1 WD 23 00 +1 WD 24 08 +1 WD 25 00 + +2 WD 22 10 +2 WD 23 00 +2 WD 24 10 +2 WD 25 00 + +3 WD 22 18 +3 WD 23 00 +3 WD 24 18 +3 WD 25 00 + +4 WD 22 20 +4 WD 23 00 +4 WD 24 20 +4 WD 25 00 + +5 WD 22 28 +5 WD 23 00 +5 WD 24 28 +5 WD 25 00 + +6 WD 22 30 +6 WD 23 00 +6 WD 24 30 +6 WD 25 00 + +7 WD 22 38 +7 WD 23 00 +7 WD 24 38 +7 WD 25 00 + +# ----------- DAA ONHOOK -------------------- +31 WD 05 00 + +# Set tip to ring voltage to 3.5 volts while off-hook +# instead of default of 3.1 +31 WD 1A C0 +" | sed -e 's/[;#].*$//' -e '/^[ ]*$/d' + +# Turning off red LEDs +# Warning: do not send WD 31 20 A0 ! +for i in `seq 0 7`; do + echo "$i WD 20 A0"; +done; + +set_daa_country_params "$opermode" + +$LOGGER -p kern.info "$XPD_BUS/$XPD_NAME: Ending '$0'" +exit 0 diff --git a/xpp/init_card_6_24 b/xpp/init_card_6_24 deleted file mode 100755 index 7219707..0000000 --- a/xpp/init_card_6_24 +++ /dev/null @@ -1,415 +0,0 @@ -#! /usr/bin/perl -w -use strict; - -# -# $Id$ -# - -# -# Written by Oron Peled -# Copyright (C) 2006, Xorcom -# -# All rights reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# See the file LICENSE in the top level of this tarball. -# - -# This script is run from the xpp kernel module upon detection -# of a new XPD. -# -# Expects the following environment variables to be set: -# XPD_BUS - bus name -# XPD_NAME - xpd name -# XPD_UNIT - xpd unit number -# XPD_SUBUNIT - xpd subunit number -# XPD_TYPE - xpd type number (from protocol reply): -# 3 - FXS -# 4 - FXO -# 6 - BRI_TE -# 7 - BRI_NT -# XPD_REVISION - xpd revision number -# -# Output data format: -# - An optional comment start with ';' or '#' until the end of line -# - Optional Blank lines are ignored -# - Fields are whitespace separated (spaces or tabs) -# -# The fields are (in command line order): -# 1. CHIP select in decimal (ignored, taken from 3 LSB's of subunit number) -# 2. Command word: -# - RD Read Direct register. -# - RS Read Sub-register. -# - WD Write Direct register. -# - WS Write Sub-register. -# 3. Register number in hexadecimal. -# 4. Subregister number in hexadecimal. (for RS and WS commands). -# 5. Data byte in hexadecimal. (for WD and WS commands only). -# - -package main; -use File::Basename; - -my $program = basename("$0"); -my $init_dir = dirname("$0"); -my $unit_id; - -sub logit { - print STDERR "$unit_id: @_\n"; -} - -# Arrange for error logging -if (-t STDERR) { - $unit_id = 'Interactive'; - logit "Interactive startup\n"; -} else { - $unit_id = "$ENV{XPD_BUS}/$ENV{XPD_NAME}"; - open (STDERR, "| /usr/bin/logger -t $program -p kern.info") || die; - logit "Non Interactive startup\n"; -} - -package BRI; - -sub gen { - my $fmt = shift; - $| = 1; - printf "$fmt\n", @_; -} - -package BRI::Port; - -sub new { - my $pack = shift; - my $port = { @_ }; - bless $port, $pack; -} - -# zap_xhfc_su.c:995 -sub init_su { - my $port = shift; - my $portnum = $port->{PORT_NUM}; - my $port_mode_up = $port->{PORT_MODE_UP}; - my $port_mode_exch = $port->{PORT_MODE_EXCH}; - my $bri_nt = $port->{BRI_NT}; - #logit "init_su(portnum=$portnum, port_mode_up=$port_mode_up, bri_nt=$bri_nt)"; - - # Setting PLL - # R_PLL_CTRL = 0 (V_PLL_M = 0, Reset PLL, Disable PLL_ - # R_CLK_CFG = 05 (PLL clock as system clock, output it to CLK_OUT pin) - # R_PLL_P = 1 - # R_PLL_N = 6 - # R_PLL_S = 1 - # R_PLL_CTRL = 1 (V_PLL_M) - - BRI::gen "#--------------------------- init_su($portnum, $bri_nt, $port_mode_up, $port_mode_exch)"; - BRI::gen "0 WD 02 04"; - BRI::gen "0 WD 50 00"; # disable PLL - BRI::gen "0 WD 51 02"; - BRI::gen "0 WD 52 06"; - BRI::gen "0 WD 53 04"; - BRI::gen "0 WD 50 01"; # Enable PLL - BRI::gen "0 WD 02 05"; # Enable PLL - - su_sel($portnum); # select port - if ("$port_mode_up" == 1) { - $port->{CTRL3} = 0x01; # A_ST_CTRL3: V_ST_SEL = 1 - $port->{CTRL0} = 0x10; # A_SU_CTRL0: V_ST_SQ_EN = 1 - BRI::gen "0 WD 34 0F"; # A_MS_TX: - # (multiframe/superframe transmit register) - } else { - $port->{CTRL3} = 0x00; # A_ST_CTRL3: V_ST_SEL = 0 - $port->{CTRL0} = 0x00; # A_SU_CTRL0: V_ST_SQ_EN = 0 - } - if ("$bri_nt" == 1) { - $port->{CTRL0} |= 0x04; # V_SU_MD - } - # ((V_SU_EXCH)?0x80:00) (change polarity) - if($port_mode_exch) { - $port->{CTRL2} = 0x80; - } else { - $port->{CTRL2} = 0x00; - } - BRI::gen "0 WD 35 %02X", $port->{CTRL3}; # A_ST_CTRL3 - BRI::gen "0 WD 31 %02X", $port->{CTRL0}; # A_SU_CTRL0 - BRI::gen "0 WD 35 F8"; # A_ST_CTRL3 = set end of pulse control to 0xF8 - BRI::gen "0 WD 32 08"; # A_SU_CTRL1 = Ignore E-channel data - BRI::gen "0 WD 33 %02X", $port->{CTRL2}; # A_SU_CTRL2 - - # zap_xhfc_su.c:1030 in init_su() - # A_SU_CLK_DLY - my $clk_dly; - if ("$bri_nt" == 1) { - $clk_dly = 0x6C; - } else { - $clk_dly = 0x0E; - } - #logit "clk_dly=$clk_dly"; - BRI::gen "0 WD 37 %02X", "$clk_dly"; -} - -sub su_sel { - if (@_ != 1 ) { - main::logit "ERROR: su_sel() called with " . scalar(@_) . " parameters"; - exit 1; - } - my $portnum = shift; - BRI::gen "0 WD 16 %02X", $portnum; # R_SU_SEL -} - -# zap_xhfc_su.c:281 -sub xhfc_selfifo { - if (@_ != 1 ) { - main::logit "ERROR: xhfc_selfifo() called with " . scalar(@_) . " parameters"; - exit 1; - } - my $fifonum = shift; - #logit "xhfc_selfifo($fifonum)"; - BRI::gen "0 WD 0F %02X", $fifonum; - # --> WAIT UNTIL (R_STATUS & M_BUSY) == 0 -} - -# zap_xhfc_su.c:295 -sub xhfc_resetfifo() { - #logit "xhfc_resetfifo()"; - # A_INC_RES_FIFO = M_RES_FIFO | M_RES_FIFO_ERR - BRI::gen "0 WD 0E 0A"; - # --> WAIT UNTIL (R_STATUS & M_BUSY) == 0 -} - -# zap_xhfc_su.c:1040 -# Initialize fifo (called for each portnum, channel, direction) -sub setup_fifo { - my $port = shift; - my $chan = shift; - my $direction = shift; - my $conhdlc = shift; - my $subcfg = shift; - my $fifoctrl = shift; - - my $portnum = $port->{PORT_NUM}; - my $port_mode_up = $port->{PORT_MODE_UP}; - my $port_mode_exch = $port->{PORT_MODE_EXCH}; - my $bri_nt = $port->{BRI_NT}; - - BRI::gen "#--------------------------- setup_fifo($portnum, $chan, $direction)"; - # my $fifonum = 0x80 | ($portnum << 3) | ($chan << 1) | ($direction); # # MSB first - my $fifonum = ($portnum << 3) | ($chan << 1) | ($direction); # # MSB first - my $r_slot = ($portnum << 3) | ($chan << 1) | ($direction); - # receive data from STIO2, transmit to STIO1 - my $a_sl_cfg = (0x80 | ($portnum << 3) | ($chan << 1) | ($direction)); - - #logit "setup_fifo($fifonum)"; - xhfc_selfifo $fifonum; - # A_CON_HDLC: transparent mode selection - BRI::gen "0 WD FA %02X", $conhdlc; - # A_SUBCH_CFG: subchnl params - BRI::gen "0 WD FB %02X", $subcfg; - # A_FIFO_CTRL: FIFO Control Register - BRI::gen "0 WD FF %02X", $fifoctrl; - xhfc_resetfifo; - xhfc_selfifo $fifonum; # wait for busy is builtin in this command - BRI::gen "0 WD 10 %02X", $r_slot; # R_SLOT - BRI::gen "0 WD D0 %02X", $a_sl_cfg; # A_SL_CFG -} - -# zap_xhfc_su.c:1071 -sub setup_su { - my $port = shift; - my $bchan = shift; - my $portnum = $port->{PORT_NUM}; - my $port_mode_exch = $port->{PORT_MODE_EXCH}; - my $bri_nt = $port->{BRI_NT}; - - BRI::gen "#--------------------------- setup_su($portnum, $bchan)"; - #logit "setup_su(portnum=$portnum, bchan=$bchan, port_mode_exch=$port_mode_exch, bri_nt=$bri_nt)"; - $port->{CTRL0} |= (1 << $bchan) | $bri_nt; - $port->{CTRL2} |= ($port_mode_exch << 7) | (1 << $bchan); - su_sel($portnum); # Select port - BRI::gen "0 WD 31 %02X", $port->{CTRL0}; # A_SU_CTRL0: V_B1_TX_EN | V_SU_MD | (NT/TE) - BRI::gen "0 WD 33 %02X", $port->{CTRL2}; # A_SU_CTRL2: V_B1_RX_EN -} - -sub xhfc_ph_command { - my $port = shift; - my $cmd = shift; - my $portnum = $port->{PORT_NUM}; - #logit "xhfc_ph_command(portnum=$portnum)"; - if ("$cmd" eq "HFC_L1_ACTIVATE_TE") { - su_sel($portnum); # Select port - BRI::gen "0 WD 30 60"; # A_SU_WR_STA = (M_SU_ACT & 0x03) - # (set activation) - } elsif ("$cmd" eq "HFC_L1_FORCE_DEACTIVATE_TE") { - su_sel($portnum); # Select port - BRI::gen "0 WD 30 40"; # A_SU_WR_STA = (M_SU_ACT & 0x02) - # (set deactivation) - } elsif ("$cmd" eq "HFC_L1_ACTIVATE_NT") { - su_sel($portnum); # Select port - BRI::gen "0 WD 30 E0"; # A_SU_WR_STA = (M_SU_ACT & 0x03) | 0x80 - # (set activation + NT) - } elsif ("$cmd" eq "HFC_L1_DEACTIVATE_NT") { - su_sel($portnum); # Select port - BRI::gen "0 WD 30 40"; # A_SU_WR_STA = (M_SU_ACT & 0x02) - # (set deactivation) - } -} - - -sub zthfc_startup { - my $port = shift; - my $portnum = $port->{PORT_NUM}; - my $port_mode_exch = $port->{PORT_MODE_EXCH}; - my $bri_nt = $port->{BRI_NT}; - #logit "zthfc_startup(portnum=$portnum, port_mode_exch=$port_mode_exch, bri_nt=$bri_nt)"; - - # PCM <-> ST/Up Configuration - foreach my $chan ( 0, 1 ) { - $port->setup_fifo($chan, 0, 0xFE, 0, 0);# Transparent mode, FIFO EN, ST->PCM - $port->setup_fifo($chan, 1, 0xFE, 0, 0);# Transparent mode, FIFO EN, ST->PCM - $port->setup_su($chan); # zap_xhfc_su.c:194 - } - - # Zaptel chan 2 used as HDLC D-Channel - $port->setup_fifo(2, 0, 0x05, 2, 0); # D-TX: zap_xhfc_su.c:205 - $port->setup_fifo(2, 1, 0x05, 2, 0); # D-RX: zap_xhfc_su.c:206 - # E-chan, Echo channel is ignored - - - # enable this port's state machine - su_sel($portnum); # Select port - # A_SU_WR_STA: reset port state machine - BRI::gen "0 WD 30 00"; - if ("$bri_nt" == 0) { - $port->xhfc_ph_command("HFC_L1_ACTIVATE_TE"); - } else { - $port->xhfc_ph_command("HFC_L1_ACTIVATE_NT"); - } -} - - -package main; -use Getopt::Std; - -my %opts; -getopts('o:', \%opts); - -$ENV{XPP_BASE} = '/proc/xpp'; -my $output; -if ($opts{o}) { - $output = $opts{o}; -} else { - $ENV{XPD_BUS} || die "Missing XPD_BUS environment variable\n"; - $ENV{XPD_NAME} || die "Missing XPD_NAME environment variable\n"; - $ENV{XPD_TYPE} || die "Missing XPD_TYPE environment variable\n"; - $ENV{XPD_REVISION} || die "Missing XPD_REVISION environment variable\n"; - $output = "$ENV{XPP_BASE}/$ENV{XPD_BUS}/$ENV{XPD_NAME}/slics"; -} - -open(REG, ">$output") || die "Failed to open '$output': $!\n"; -select REG; - -logit "Starting '$0'"; - -#------------------------------------------- Instance detection - -# zap_xhfc_su.c:895 -sub init_xhfc() { - #logit "init_xhfc()"; - BRI::gen "#--------------------------- init_xhfc"; - BRI::gen "0 WD 0D 00"; # r_FIFO_MD: 16 fifos, - # 64 bytes for TX and RX each (FIFO mode config) - - # software reset to enable R_FIFO_MD setting - BRI::gen "0 WD 00 08"; # R_CIRM = M_SRES (soft reset) - # --> WAIT 5u - BRI::gen "0 WD 00 00"; # R_CIRM = 0 (zero it to deactivate reset) - - # amplitude - BRI::gen "0 WD 46 80"; # R_PWM_MD: (PWM output mode register) - # PWM push to zero only - BRI::gen "0 WD 39 18"; # R_PWM1: (modulator register for PWM1) - # set duty cycle - - BRI::gen "0 WD 0C 11"; # R_FIFO_THRES: (FIFO fill lvl control register) - # RX/TX threshold = 16 bytes - - # --> Wait until (R_STATUS & (M_BUSY | M_PCM_INIT)) - # M_BUSY status will be checked after fifo selection - BRI::gen "0 WD 0F 80"; - # set PCM !master mode - BRI::gen "0 WD 14 08"; # R_PCM_MD0 = PCM slave mode, F0IO duration is 2 HFC_PCLK's - - # (C4IO, F0IO are inputs) - - # set pll adjust - # WD 14 90 # R_PCM_MD0: Index value to select - # the register at address 15 - # WD 15 2C # R_PCM_MD1: V_PLL_ADJ (DPLL adjust speed), C4IO is 16.384MHz(128 time slots) - # in the last slot of PCM frame - BRI::gen "0 WS 14 98 20"; # R_PCM_MD1: V_PLL_ADJ - # (DPLL adjust speed) in the - # last slot of PCM frame -} - -my %port_type = ( - 6 => { 'BRI_NT' => 0 }, - 7 => { 'BRI_NT' => 1 } - ); - -# zap_xhfc_su.c:175 -sub main() { - #logit "main(): XPD_TYPE=$ENV{XPD_TYPE}"; - - $ENV{XPD_TYPE} || die "Missing XPD_TYPE environment variable\n"; - my $type = $port_type{$ENV{XPD_TYPE}}; - die "Bad XPD_TYPE=$ENV{XPD_TYPE}\n" unless $type; - die "Missing XPD_SUBUNIT information\n" unless defined($ENV{XPD_SUBUNIT}); - - # We must first turn off packet reception. - # - # Otherwise we mess with registers while the FPGA firmware tries to - # send us packets. - BRI::gen "0 Wm"; - - # Common initialization - if($ENV{XPD_SUBUNIT} eq '0') { - # Turn off multi-byte packet reception before initialization started - system("/bin/echo \"0A 00 0F 00 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - system("/bin/echo \"0A 00 0F 08 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - system("/bin/echo \"0A 00 0F 10 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - system("/bin/echo \"0A 00 0F 18 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - - init_xhfc; # zap_xhfc_su.c:1173 in setup_instance() - } - - # Port initialization - my $p = BRI::Port->new( - 'PORT_NUM' => $ENV{XPD_SUBUNIT}, - 'BRI_NT' => $type->{BRI_NT}, - 'PORT_MODE_UP' => 0, - 'PORT_MODE_EXCH' => 0 - ); - # zap_XHfc_su.c:1186 in setup_instance() - $p->init_su; - - $p->zthfc_startup; - - if($ENV{XPD_SUBUNIT} eq 3) { - # Turn on multi-byte packet reception when ports initialization finished - system("/bin/echo \"0A 00 0F 00 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - system("/bin/echo \"0A 00 0F 08 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - system("/bin/echo \"0A 00 0F 10 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - system("/bin/echo \"0A 00 0F 18 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - } -} - -main; - -logit "Ending '$0'"; - -close REG; -close STDERR; -exit 0; diff --git a/xpp/init_card_6_26 b/xpp/init_card_6_26 new file mode 100755 index 0000000..7219707 --- /dev/null +++ b/xpp/init_card_6_26 @@ -0,0 +1,415 @@ +#! /usr/bin/perl -w +use strict; + +# +# $Id$ +# + +# +# Written by Oron Peled +# Copyright (C) 2006, Xorcom +# +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# See the file LICENSE in the top level of this tarball. +# + +# This script is run from the xpp kernel module upon detection +# of a new XPD. +# +# Expects the following environment variables to be set: +# XPD_BUS - bus name +# XPD_NAME - xpd name +# XPD_UNIT - xpd unit number +# XPD_SUBUNIT - xpd subunit number +# XPD_TYPE - xpd type number (from protocol reply): +# 3 - FXS +# 4 - FXO +# 6 - BRI_TE +# 7 - BRI_NT +# XPD_REVISION - xpd revision number +# +# Output data format: +# - An optional comment start with ';' or '#' until the end of line +# - Optional Blank lines are ignored +# - Fields are whitespace separated (spaces or tabs) +# +# The fields are (in command line order): +# 1. CHIP select in decimal (ignored, taken from 3 LSB's of subunit number) +# 2. Command word: +# - RD Read Direct register. +# - RS Read Sub-register. +# - WD Write Direct register. +# - WS Write Sub-register. +# 3. Register number in hexadecimal. +# 4. Subregister number in hexadecimal. (for RS and WS commands). +# 5. Data byte in hexadecimal. (for WD and WS commands only). +# + +package main; +use File::Basename; + +my $program = basename("$0"); +my $init_dir = dirname("$0"); +my $unit_id; + +sub logit { + print STDERR "$unit_id: @_\n"; +} + +# Arrange for error logging +if (-t STDERR) { + $unit_id = 'Interactive'; + logit "Interactive startup\n"; +} else { + $unit_id = "$ENV{XPD_BUS}/$ENV{XPD_NAME}"; + open (STDERR, "| /usr/bin/logger -t $program -p kern.info") || die; + logit "Non Interactive startup\n"; +} + +package BRI; + +sub gen { + my $fmt = shift; + $| = 1; + printf "$fmt\n", @_; +} + +package BRI::Port; + +sub new { + my $pack = shift; + my $port = { @_ }; + bless $port, $pack; +} + +# zap_xhfc_su.c:995 +sub init_su { + my $port = shift; + my $portnum = $port->{PORT_NUM}; + my $port_mode_up = $port->{PORT_MODE_UP}; + my $port_mode_exch = $port->{PORT_MODE_EXCH}; + my $bri_nt = $port->{BRI_NT}; + #logit "init_su(portnum=$portnum, port_mode_up=$port_mode_up, bri_nt=$bri_nt)"; + + # Setting PLL + # R_PLL_CTRL = 0 (V_PLL_M = 0, Reset PLL, Disable PLL_ + # R_CLK_CFG = 05 (PLL clock as system clock, output it to CLK_OUT pin) + # R_PLL_P = 1 + # R_PLL_N = 6 + # R_PLL_S = 1 + # R_PLL_CTRL = 1 (V_PLL_M) + + BRI::gen "#--------------------------- init_su($portnum, $bri_nt, $port_mode_up, $port_mode_exch)"; + BRI::gen "0 WD 02 04"; + BRI::gen "0 WD 50 00"; # disable PLL + BRI::gen "0 WD 51 02"; + BRI::gen "0 WD 52 06"; + BRI::gen "0 WD 53 04"; + BRI::gen "0 WD 50 01"; # Enable PLL + BRI::gen "0 WD 02 05"; # Enable PLL + + su_sel($portnum); # select port + if ("$port_mode_up" == 1) { + $port->{CTRL3} = 0x01; # A_ST_CTRL3: V_ST_SEL = 1 + $port->{CTRL0} = 0x10; # A_SU_CTRL0: V_ST_SQ_EN = 1 + BRI::gen "0 WD 34 0F"; # A_MS_TX: + # (multiframe/superframe transmit register) + } else { + $port->{CTRL3} = 0x00; # A_ST_CTRL3: V_ST_SEL = 0 + $port->{CTRL0} = 0x00; # A_SU_CTRL0: V_ST_SQ_EN = 0 + } + if ("$bri_nt" == 1) { + $port->{CTRL0} |= 0x04; # V_SU_MD + } + # ((V_SU_EXCH)?0x80:00) (change polarity) + if($port_mode_exch) { + $port->{CTRL2} = 0x80; + } else { + $port->{CTRL2} = 0x00; + } + BRI::gen "0 WD 35 %02X", $port->{CTRL3}; # A_ST_CTRL3 + BRI::gen "0 WD 31 %02X", $port->{CTRL0}; # A_SU_CTRL0 + BRI::gen "0 WD 35 F8"; # A_ST_CTRL3 = set end of pulse control to 0xF8 + BRI::gen "0 WD 32 08"; # A_SU_CTRL1 = Ignore E-channel data + BRI::gen "0 WD 33 %02X", $port->{CTRL2}; # A_SU_CTRL2 + + # zap_xhfc_su.c:1030 in init_su() + # A_SU_CLK_DLY + my $clk_dly; + if ("$bri_nt" == 1) { + $clk_dly = 0x6C; + } else { + $clk_dly = 0x0E; + } + #logit "clk_dly=$clk_dly"; + BRI::gen "0 WD 37 %02X", "$clk_dly"; +} + +sub su_sel { + if (@_ != 1 ) { + main::logit "ERROR: su_sel() called with " . scalar(@_) . " parameters"; + exit 1; + } + my $portnum = shift; + BRI::gen "0 WD 16 %02X", $portnum; # R_SU_SEL +} + +# zap_xhfc_su.c:281 +sub xhfc_selfifo { + if (@_ != 1 ) { + main::logit "ERROR: xhfc_selfifo() called with " . scalar(@_) . " parameters"; + exit 1; + } + my $fifonum = shift; + #logit "xhfc_selfifo($fifonum)"; + BRI::gen "0 WD 0F %02X", $fifonum; + # --> WAIT UNTIL (R_STATUS & M_BUSY) == 0 +} + +# zap_xhfc_su.c:295 +sub xhfc_resetfifo() { + #logit "xhfc_resetfifo()"; + # A_INC_RES_FIFO = M_RES_FIFO | M_RES_FIFO_ERR + BRI::gen "0 WD 0E 0A"; + # --> WAIT UNTIL (R_STATUS & M_BUSY) == 0 +} + +# zap_xhfc_su.c:1040 +# Initialize fifo (called for each portnum, channel, direction) +sub setup_fifo { + my $port = shift; + my $chan = shift; + my $direction = shift; + my $conhdlc = shift; + my $subcfg = shift; + my $fifoctrl = shift; + + my $portnum = $port->{PORT_NUM}; + my $port_mode_up = $port->{PORT_MODE_UP}; + my $port_mode_exch = $port->{PORT_MODE_EXCH}; + my $bri_nt = $port->{BRI_NT}; + + BRI::gen "#--------------------------- setup_fifo($portnum, $chan, $direction)"; + # my $fifonum = 0x80 | ($portnum << 3) | ($chan << 1) | ($direction); # # MSB first + my $fifonum = ($portnum << 3) | ($chan << 1) | ($direction); # # MSB first + my $r_slot = ($portnum << 3) | ($chan << 1) | ($direction); + # receive data from STIO2, transmit to STIO1 + my $a_sl_cfg = (0x80 | ($portnum << 3) | ($chan << 1) | ($direction)); + + #logit "setup_fifo($fifonum)"; + xhfc_selfifo $fifonum; + # A_CON_HDLC: transparent mode selection + BRI::gen "0 WD FA %02X", $conhdlc; + # A_SUBCH_CFG: subchnl params + BRI::gen "0 WD FB %02X", $subcfg; + # A_FIFO_CTRL: FIFO Control Register + BRI::gen "0 WD FF %02X", $fifoctrl; + xhfc_resetfifo; + xhfc_selfifo $fifonum; # wait for busy is builtin in this command + BRI::gen "0 WD 10 %02X", $r_slot; # R_SLOT + BRI::gen "0 WD D0 %02X", $a_sl_cfg; # A_SL_CFG +} + +# zap_xhfc_su.c:1071 +sub setup_su { + my $port = shift; + my $bchan = shift; + my $portnum = $port->{PORT_NUM}; + my $port_mode_exch = $port->{PORT_MODE_EXCH}; + my $bri_nt = $port->{BRI_NT}; + + BRI::gen "#--------------------------- setup_su($portnum, $bchan)"; + #logit "setup_su(portnum=$portnum, bchan=$bchan, port_mode_exch=$port_mode_exch, bri_nt=$bri_nt)"; + $port->{CTRL0} |= (1 << $bchan) | $bri_nt; + $port->{CTRL2} |= ($port_mode_exch << 7) | (1 << $bchan); + su_sel($portnum); # Select port + BRI::gen "0 WD 31 %02X", $port->{CTRL0}; # A_SU_CTRL0: V_B1_TX_EN | V_SU_MD | (NT/TE) + BRI::gen "0 WD 33 %02X", $port->{CTRL2}; # A_SU_CTRL2: V_B1_RX_EN +} + +sub xhfc_ph_command { + my $port = shift; + my $cmd = shift; + my $portnum = $port->{PORT_NUM}; + #logit "xhfc_ph_command(portnum=$portnum)"; + if ("$cmd" eq "HFC_L1_ACTIVATE_TE") { + su_sel($portnum); # Select port + BRI::gen "0 WD 30 60"; # A_SU_WR_STA = (M_SU_ACT & 0x03) + # (set activation) + } elsif ("$cmd" eq "HFC_L1_FORCE_DEACTIVATE_TE") { + su_sel($portnum); # Select port + BRI::gen "0 WD 30 40"; # A_SU_WR_STA = (M_SU_ACT & 0x02) + # (set deactivation) + } elsif ("$cmd" eq "HFC_L1_ACTIVATE_NT") { + su_sel($portnum); # Select port + BRI::gen "0 WD 30 E0"; # A_SU_WR_STA = (M_SU_ACT & 0x03) | 0x80 + # (set activation + NT) + } elsif ("$cmd" eq "HFC_L1_DEACTIVATE_NT") { + su_sel($portnum); # Select port + BRI::gen "0 WD 30 40"; # A_SU_WR_STA = (M_SU_ACT & 0x02) + # (set deactivation) + } +} + + +sub zthfc_startup { + my $port = shift; + my $portnum = $port->{PORT_NUM}; + my $port_mode_exch = $port->{PORT_MODE_EXCH}; + my $bri_nt = $port->{BRI_NT}; + #logit "zthfc_startup(portnum=$portnum, port_mode_exch=$port_mode_exch, bri_nt=$bri_nt)"; + + # PCM <-> ST/Up Configuration + foreach my $chan ( 0, 1 ) { + $port->setup_fifo($chan, 0, 0xFE, 0, 0);# Transparent mode, FIFO EN, ST->PCM + $port->setup_fifo($chan, 1, 0xFE, 0, 0);# Transparent mode, FIFO EN, ST->PCM + $port->setup_su($chan); # zap_xhfc_su.c:194 + } + + # Zaptel chan 2 used as HDLC D-Channel + $port->setup_fifo(2, 0, 0x05, 2, 0); # D-TX: zap_xhfc_su.c:205 + $port->setup_fifo(2, 1, 0x05, 2, 0); # D-RX: zap_xhfc_su.c:206 + # E-chan, Echo channel is ignored + + + # enable this port's state machine + su_sel($portnum); # Select port + # A_SU_WR_STA: reset port state machine + BRI::gen "0 WD 30 00"; + if ("$bri_nt" == 0) { + $port->xhfc_ph_command("HFC_L1_ACTIVATE_TE"); + } else { + $port->xhfc_ph_command("HFC_L1_ACTIVATE_NT"); + } +} + + +package main; +use Getopt::Std; + +my %opts; +getopts('o:', \%opts); + +$ENV{XPP_BASE} = '/proc/xpp'; +my $output; +if ($opts{o}) { + $output = $opts{o}; +} else { + $ENV{XPD_BUS} || die "Missing XPD_BUS environment variable\n"; + $ENV{XPD_NAME} || die "Missing XPD_NAME environment variable\n"; + $ENV{XPD_TYPE} || die "Missing XPD_TYPE environment variable\n"; + $ENV{XPD_REVISION} || die "Missing XPD_REVISION environment variable\n"; + $output = "$ENV{XPP_BASE}/$ENV{XPD_BUS}/$ENV{XPD_NAME}/slics"; +} + +open(REG, ">$output") || die "Failed to open '$output': $!\n"; +select REG; + +logit "Starting '$0'"; + +#------------------------------------------- Instance detection + +# zap_xhfc_su.c:895 +sub init_xhfc() { + #logit "init_xhfc()"; + BRI::gen "#--------------------------- init_xhfc"; + BRI::gen "0 WD 0D 00"; # r_FIFO_MD: 16 fifos, + # 64 bytes for TX and RX each (FIFO mode config) + + # software reset to enable R_FIFO_MD setting + BRI::gen "0 WD 00 08"; # R_CIRM = M_SRES (soft reset) + # --> WAIT 5u + BRI::gen "0 WD 00 00"; # R_CIRM = 0 (zero it to deactivate reset) + + # amplitude + BRI::gen "0 WD 46 80"; # R_PWM_MD: (PWM output mode register) + # PWM push to zero only + BRI::gen "0 WD 39 18"; # R_PWM1: (modulator register for PWM1) + # set duty cycle + + BRI::gen "0 WD 0C 11"; # R_FIFO_THRES: (FIFO fill lvl control register) + # RX/TX threshold = 16 bytes + + # --> Wait until (R_STATUS & (M_BUSY | M_PCM_INIT)) + # M_BUSY status will be checked after fifo selection + BRI::gen "0 WD 0F 80"; + # set PCM !master mode + BRI::gen "0 WD 14 08"; # R_PCM_MD0 = PCM slave mode, F0IO duration is 2 HFC_PCLK's + + # (C4IO, F0IO are inputs) + + # set pll adjust + # WD 14 90 # R_PCM_MD0: Index value to select + # the register at address 15 + # WD 15 2C # R_PCM_MD1: V_PLL_ADJ (DPLL adjust speed), C4IO is 16.384MHz(128 time slots) + # in the last slot of PCM frame + BRI::gen "0 WS 14 98 20"; # R_PCM_MD1: V_PLL_ADJ + # (DPLL adjust speed) in the + # last slot of PCM frame +} + +my %port_type = ( + 6 => { 'BRI_NT' => 0 }, + 7 => { 'BRI_NT' => 1 } + ); + +# zap_xhfc_su.c:175 +sub main() { + #logit "main(): XPD_TYPE=$ENV{XPD_TYPE}"; + + $ENV{XPD_TYPE} || die "Missing XPD_TYPE environment variable\n"; + my $type = $port_type{$ENV{XPD_TYPE}}; + die "Bad XPD_TYPE=$ENV{XPD_TYPE}\n" unless $type; + die "Missing XPD_SUBUNIT information\n" unless defined($ENV{XPD_SUBUNIT}); + + # We must first turn off packet reception. + # + # Otherwise we mess with registers while the FPGA firmware tries to + # send us packets. + BRI::gen "0 Wm"; + + # Common initialization + if($ENV{XPD_SUBUNIT} eq '0') { + # Turn off multi-byte packet reception before initialization started + system("/bin/echo \"0A 00 0F 00 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + system("/bin/echo \"0A 00 0F 08 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + system("/bin/echo \"0A 00 0F 10 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + system("/bin/echo \"0A 00 0F 18 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + + init_xhfc; # zap_xhfc_su.c:1173 in setup_instance() + } + + # Port initialization + my $p = BRI::Port->new( + 'PORT_NUM' => $ENV{XPD_SUBUNIT}, + 'BRI_NT' => $type->{BRI_NT}, + 'PORT_MODE_UP' => 0, + 'PORT_MODE_EXCH' => 0 + ); + # zap_XHfc_su.c:1186 in setup_instance() + $p->init_su; + + $p->zthfc_startup; + + if($ENV{XPD_SUBUNIT} eq 3) { + # Turn on multi-byte packet reception when ports initialization finished + system("/bin/echo \"0A 00 0F 00 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + system("/bin/echo \"0A 00 0F 08 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + system("/bin/echo \"0A 00 0F 10 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + system("/bin/echo \"0A 00 0F 18 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + } +} + +main; + +logit "Ending '$0'"; + +close REG; +close STDERR; +exit 0; diff --git a/xpp/init_card_7_24 b/xpp/init_card_7_24 deleted file mode 100755 index 7219707..0000000 --- a/xpp/init_card_7_24 +++ /dev/null @@ -1,415 +0,0 @@ -#! /usr/bin/perl -w -use strict; - -# -# $Id$ -# - -# -# Written by Oron Peled -# Copyright (C) 2006, Xorcom -# -# All rights reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# See the file LICENSE in the top level of this tarball. -# - -# This script is run from the xpp kernel module upon detection -# of a new XPD. -# -# Expects the following environment variables to be set: -# XPD_BUS - bus name -# XPD_NAME - xpd name -# XPD_UNIT - xpd unit number -# XPD_SUBUNIT - xpd subunit number -# XPD_TYPE - xpd type number (from protocol reply): -# 3 - FXS -# 4 - FXO -# 6 - BRI_TE -# 7 - BRI_NT -# XPD_REVISION - xpd revision number -# -# Output data format: -# - An optional comment start with ';' or '#' until the end of line -# - Optional Blank lines are ignored -# - Fields are whitespace separated (spaces or tabs) -# -# The fields are (in command line order): -# 1. CHIP select in decimal (ignored, taken from 3 LSB's of subunit number) -# 2. Command word: -# - RD Read Direct register. -# - RS Read Sub-register. -# - WD Write Direct register. -# - WS Write Sub-register. -# 3. Register number in hexadecimal. -# 4. Subregister number in hexadecimal. (for RS and WS commands). -# 5. Data byte in hexadecimal. (for WD and WS commands only). -# - -package main; -use File::Basename; - -my $program = basename("$0"); -my $init_dir = dirname("$0"); -my $unit_id; - -sub logit { - print STDERR "$unit_id: @_\n"; -} - -# Arrange for error logging -if (-t STDERR) { - $unit_id = 'Interactive'; - logit "Interactive startup\n"; -} else { - $unit_id = "$ENV{XPD_BUS}/$ENV{XPD_NAME}"; - open (STDERR, "| /usr/bin/logger -t $program -p kern.info") || die; - logit "Non Interactive startup\n"; -} - -package BRI; - -sub gen { - my $fmt = shift; - $| = 1; - printf "$fmt\n", @_; -} - -package BRI::Port; - -sub new { - my $pack = shift; - my $port = { @_ }; - bless $port, $pack; -} - -# zap_xhfc_su.c:995 -sub init_su { - my $port = shift; - my $portnum = $port->{PORT_NUM}; - my $port_mode_up = $port->{PORT_MODE_UP}; - my $port_mode_exch = $port->{PORT_MODE_EXCH}; - my $bri_nt = $port->{BRI_NT}; - #logit "init_su(portnum=$portnum, port_mode_up=$port_mode_up, bri_nt=$bri_nt)"; - - # Setting PLL - # R_PLL_CTRL = 0 (V_PLL_M = 0, Reset PLL, Disable PLL_ - # R_CLK_CFG = 05 (PLL clock as system clock, output it to CLK_OUT pin) - # R_PLL_P = 1 - # R_PLL_N = 6 - # R_PLL_S = 1 - # R_PLL_CTRL = 1 (V_PLL_M) - - BRI::gen "#--------------------------- init_su($portnum, $bri_nt, $port_mode_up, $port_mode_exch)"; - BRI::gen "0 WD 02 04"; - BRI::gen "0 WD 50 00"; # disable PLL - BRI::gen "0 WD 51 02"; - BRI::gen "0 WD 52 06"; - BRI::gen "0 WD 53 04"; - BRI::gen "0 WD 50 01"; # Enable PLL - BRI::gen "0 WD 02 05"; # Enable PLL - - su_sel($portnum); # select port - if ("$port_mode_up" == 1) { - $port->{CTRL3} = 0x01; # A_ST_CTRL3: V_ST_SEL = 1 - $port->{CTRL0} = 0x10; # A_SU_CTRL0: V_ST_SQ_EN = 1 - BRI::gen "0 WD 34 0F"; # A_MS_TX: - # (multiframe/superframe transmit register) - } else { - $port->{CTRL3} = 0x00; # A_ST_CTRL3: V_ST_SEL = 0 - $port->{CTRL0} = 0x00; # A_SU_CTRL0: V_ST_SQ_EN = 0 - } - if ("$bri_nt" == 1) { - $port->{CTRL0} |= 0x04; # V_SU_MD - } - # ((V_SU_EXCH)?0x80:00) (change polarity) - if($port_mode_exch) { - $port->{CTRL2} = 0x80; - } else { - $port->{CTRL2} = 0x00; - } - BRI::gen "0 WD 35 %02X", $port->{CTRL3}; # A_ST_CTRL3 - BRI::gen "0 WD 31 %02X", $port->{CTRL0}; # A_SU_CTRL0 - BRI::gen "0 WD 35 F8"; # A_ST_CTRL3 = set end of pulse control to 0xF8 - BRI::gen "0 WD 32 08"; # A_SU_CTRL1 = Ignore E-channel data - BRI::gen "0 WD 33 %02X", $port->{CTRL2}; # A_SU_CTRL2 - - # zap_xhfc_su.c:1030 in init_su() - # A_SU_CLK_DLY - my $clk_dly; - if ("$bri_nt" == 1) { - $clk_dly = 0x6C; - } else { - $clk_dly = 0x0E; - } - #logit "clk_dly=$clk_dly"; - BRI::gen "0 WD 37 %02X", "$clk_dly"; -} - -sub su_sel { - if (@_ != 1 ) { - main::logit "ERROR: su_sel() called with " . scalar(@_) . " parameters"; - exit 1; - } - my $portnum = shift; - BRI::gen "0 WD 16 %02X", $portnum; # R_SU_SEL -} - -# zap_xhfc_su.c:281 -sub xhfc_selfifo { - if (@_ != 1 ) { - main::logit "ERROR: xhfc_selfifo() called with " . scalar(@_) . " parameters"; - exit 1; - } - my $fifonum = shift; - #logit "xhfc_selfifo($fifonum)"; - BRI::gen "0 WD 0F %02X", $fifonum; - # --> WAIT UNTIL (R_STATUS & M_BUSY) == 0 -} - -# zap_xhfc_su.c:295 -sub xhfc_resetfifo() { - #logit "xhfc_resetfifo()"; - # A_INC_RES_FIFO = M_RES_FIFO | M_RES_FIFO_ERR - BRI::gen "0 WD 0E 0A"; - # --> WAIT UNTIL (R_STATUS & M_BUSY) == 0 -} - -# zap_xhfc_su.c:1040 -# Initialize fifo (called for each portnum, channel, direction) -sub setup_fifo { - my $port = shift; - my $chan = shift; - my $direction = shift; - my $conhdlc = shift; - my $subcfg = shift; - my $fifoctrl = shift; - - my $portnum = $port->{PORT_NUM}; - my $port_mode_up = $port->{PORT_MODE_UP}; - my $port_mode_exch = $port->{PORT_MODE_EXCH}; - my $bri_nt = $port->{BRI_NT}; - - BRI::gen "#--------------------------- setup_fifo($portnum, $chan, $direction)"; - # my $fifonum = 0x80 | ($portnum << 3) | ($chan << 1) | ($direction); # # MSB first - my $fifonum = ($portnum << 3) | ($chan << 1) | ($direction); # # MSB first - my $r_slot = ($portnum << 3) | ($chan << 1) | ($direction); - # receive data from STIO2, transmit to STIO1 - my $a_sl_cfg = (0x80 | ($portnum << 3) | ($chan << 1) | ($direction)); - - #logit "setup_fifo($fifonum)"; - xhfc_selfifo $fifonum; - # A_CON_HDLC: transparent mode selection - BRI::gen "0 WD FA %02X", $conhdlc; - # A_SUBCH_CFG: subchnl params - BRI::gen "0 WD FB %02X", $subcfg; - # A_FIFO_CTRL: FIFO Control Register - BRI::gen "0 WD FF %02X", $fifoctrl; - xhfc_resetfifo; - xhfc_selfifo $fifonum; # wait for busy is builtin in this command - BRI::gen "0 WD 10 %02X", $r_slot; # R_SLOT - BRI::gen "0 WD D0 %02X", $a_sl_cfg; # A_SL_CFG -} - -# zap_xhfc_su.c:1071 -sub setup_su { - my $port = shift; - my $bchan = shift; - my $portnum = $port->{PORT_NUM}; - my $port_mode_exch = $port->{PORT_MODE_EXCH}; - my $bri_nt = $port->{BRI_NT}; - - BRI::gen "#--------------------------- setup_su($portnum, $bchan)"; - #logit "setup_su(portnum=$portnum, bchan=$bchan, port_mode_exch=$port_mode_exch, bri_nt=$bri_nt)"; - $port->{CTRL0} |= (1 << $bchan) | $bri_nt; - $port->{CTRL2} |= ($port_mode_exch << 7) | (1 << $bchan); - su_sel($portnum); # Select port - BRI::gen "0 WD 31 %02X", $port->{CTRL0}; # A_SU_CTRL0: V_B1_TX_EN | V_SU_MD | (NT/TE) - BRI::gen "0 WD 33 %02X", $port->{CTRL2}; # A_SU_CTRL2: V_B1_RX_EN -} - -sub xhfc_ph_command { - my $port = shift; - my $cmd = shift; - my $portnum = $port->{PORT_NUM}; - #logit "xhfc_ph_command(portnum=$portnum)"; - if ("$cmd" eq "HFC_L1_ACTIVATE_TE") { - su_sel($portnum); # Select port - BRI::gen "0 WD 30 60"; # A_SU_WR_STA = (M_SU_ACT & 0x03) - # (set activation) - } elsif ("$cmd" eq "HFC_L1_FORCE_DEACTIVATE_TE") { - su_sel($portnum); # Select port - BRI::gen "0 WD 30 40"; # A_SU_WR_STA = (M_SU_ACT & 0x02) - # (set deactivation) - } elsif ("$cmd" eq "HFC_L1_ACTIVATE_NT") { - su_sel($portnum); # Select port - BRI::gen "0 WD 30 E0"; # A_SU_WR_STA = (M_SU_ACT & 0x03) | 0x80 - # (set activation + NT) - } elsif ("$cmd" eq "HFC_L1_DEACTIVATE_NT") { - su_sel($portnum); # Select port - BRI::gen "0 WD 30 40"; # A_SU_WR_STA = (M_SU_ACT & 0x02) - # (set deactivation) - } -} - - -sub zthfc_startup { - my $port = shift; - my $portnum = $port->{PORT_NUM}; - my $port_mode_exch = $port->{PORT_MODE_EXCH}; - my $bri_nt = $port->{BRI_NT}; - #logit "zthfc_startup(portnum=$portnum, port_mode_exch=$port_mode_exch, bri_nt=$bri_nt)"; - - # PCM <-> ST/Up Configuration - foreach my $chan ( 0, 1 ) { - $port->setup_fifo($chan, 0, 0xFE, 0, 0);# Transparent mode, FIFO EN, ST->PCM - $port->setup_fifo($chan, 1, 0xFE, 0, 0);# Transparent mode, FIFO EN, ST->PCM - $port->setup_su($chan); # zap_xhfc_su.c:194 - } - - # Zaptel chan 2 used as HDLC D-Channel - $port->setup_fifo(2, 0, 0x05, 2, 0); # D-TX: zap_xhfc_su.c:205 - $port->setup_fifo(2, 1, 0x05, 2, 0); # D-RX: zap_xhfc_su.c:206 - # E-chan, Echo channel is ignored - - - # enable this port's state machine - su_sel($portnum); # Select port - # A_SU_WR_STA: reset port state machine - BRI::gen "0 WD 30 00"; - if ("$bri_nt" == 0) { - $port->xhfc_ph_command("HFC_L1_ACTIVATE_TE"); - } else { - $port->xhfc_ph_command("HFC_L1_ACTIVATE_NT"); - } -} - - -package main; -use Getopt::Std; - -my %opts; -getopts('o:', \%opts); - -$ENV{XPP_BASE} = '/proc/xpp'; -my $output; -if ($opts{o}) { - $output = $opts{o}; -} else { - $ENV{XPD_BUS} || die "Missing XPD_BUS environment variable\n"; - $ENV{XPD_NAME} || die "Missing XPD_NAME environment variable\n"; - $ENV{XPD_TYPE} || die "Missing XPD_TYPE environment variable\n"; - $ENV{XPD_REVISION} || die "Missing XPD_REVISION environment variable\n"; - $output = "$ENV{XPP_BASE}/$ENV{XPD_BUS}/$ENV{XPD_NAME}/slics"; -} - -open(REG, ">$output") || die "Failed to open '$output': $!\n"; -select REG; - -logit "Starting '$0'"; - -#------------------------------------------- Instance detection - -# zap_xhfc_su.c:895 -sub init_xhfc() { - #logit "init_xhfc()"; - BRI::gen "#--------------------------- init_xhfc"; - BRI::gen "0 WD 0D 00"; # r_FIFO_MD: 16 fifos, - # 64 bytes for TX and RX each (FIFO mode config) - - # software reset to enable R_FIFO_MD setting - BRI::gen "0 WD 00 08"; # R_CIRM = M_SRES (soft reset) - # --> WAIT 5u - BRI::gen "0 WD 00 00"; # R_CIRM = 0 (zero it to deactivate reset) - - # amplitude - BRI::gen "0 WD 46 80"; # R_PWM_MD: (PWM output mode register) - # PWM push to zero only - BRI::gen "0 WD 39 18"; # R_PWM1: (modulator register for PWM1) - # set duty cycle - - BRI::gen "0 WD 0C 11"; # R_FIFO_THRES: (FIFO fill lvl control register) - # RX/TX threshold = 16 bytes - - # --> Wait until (R_STATUS & (M_BUSY | M_PCM_INIT)) - # M_BUSY status will be checked after fifo selection - BRI::gen "0 WD 0F 80"; - # set PCM !master mode - BRI::gen "0 WD 14 08"; # R_PCM_MD0 = PCM slave mode, F0IO duration is 2 HFC_PCLK's - - # (C4IO, F0IO are inputs) - - # set pll adjust - # WD 14 90 # R_PCM_MD0: Index value to select - # the register at address 15 - # WD 15 2C # R_PCM_MD1: V_PLL_ADJ (DPLL adjust speed), C4IO is 16.384MHz(128 time slots) - # in the last slot of PCM frame - BRI::gen "0 WS 14 98 20"; # R_PCM_MD1: V_PLL_ADJ - # (DPLL adjust speed) in the - # last slot of PCM frame -} - -my %port_type = ( - 6 => { 'BRI_NT' => 0 }, - 7 => { 'BRI_NT' => 1 } - ); - -# zap_xhfc_su.c:175 -sub main() { - #logit "main(): XPD_TYPE=$ENV{XPD_TYPE}"; - - $ENV{XPD_TYPE} || die "Missing XPD_TYPE environment variable\n"; - my $type = $port_type{$ENV{XPD_TYPE}}; - die "Bad XPD_TYPE=$ENV{XPD_TYPE}\n" unless $type; - die "Missing XPD_SUBUNIT information\n" unless defined($ENV{XPD_SUBUNIT}); - - # We must first turn off packet reception. - # - # Otherwise we mess with registers while the FPGA firmware tries to - # send us packets. - BRI::gen "0 Wm"; - - # Common initialization - if($ENV{XPD_SUBUNIT} eq '0') { - # Turn off multi-byte packet reception before initialization started - system("/bin/echo \"0A 00 0F 00 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - system("/bin/echo \"0A 00 0F 08 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - system("/bin/echo \"0A 00 0F 10 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - system("/bin/echo \"0A 00 0F 18 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - - init_xhfc; # zap_xhfc_su.c:1173 in setup_instance() - } - - # Port initialization - my $p = BRI::Port->new( - 'PORT_NUM' => $ENV{XPD_SUBUNIT}, - 'BRI_NT' => $type->{BRI_NT}, - 'PORT_MODE_UP' => 0, - 'PORT_MODE_EXCH' => 0 - ); - # zap_XHfc_su.c:1186 in setup_instance() - $p->init_su; - - $p->zthfc_startup; - - if($ENV{XPD_SUBUNIT} eq 3) { - # Turn on multi-byte packet reception when ports initialization finished - system("/bin/echo \"0A 00 0F 00 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - system("/bin/echo \"0A 00 0F 08 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - system("/bin/echo \"0A 00 0F 10 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - system("/bin/echo \"0A 00 0F 18 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); - } -} - -main; - -logit "Ending '$0'"; - -close REG; -close STDERR; -exit 0; diff --git a/xpp/init_card_7_26 b/xpp/init_card_7_26 new file mode 100755 index 0000000..7219707 --- /dev/null +++ b/xpp/init_card_7_26 @@ -0,0 +1,415 @@ +#! /usr/bin/perl -w +use strict; + +# +# $Id$ +# + +# +# Written by Oron Peled +# Copyright (C) 2006, Xorcom +# +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# See the file LICENSE in the top level of this tarball. +# + +# This script is run from the xpp kernel module upon detection +# of a new XPD. +# +# Expects the following environment variables to be set: +# XPD_BUS - bus name +# XPD_NAME - xpd name +# XPD_UNIT - xpd unit number +# XPD_SUBUNIT - xpd subunit number +# XPD_TYPE - xpd type number (from protocol reply): +# 3 - FXS +# 4 - FXO +# 6 - BRI_TE +# 7 - BRI_NT +# XPD_REVISION - xpd revision number +# +# Output data format: +# - An optional comment start with ';' or '#' until the end of line +# - Optional Blank lines are ignored +# - Fields are whitespace separated (spaces or tabs) +# +# The fields are (in command line order): +# 1. CHIP select in decimal (ignored, taken from 3 LSB's of subunit number) +# 2. Command word: +# - RD Read Direct register. +# - RS Read Sub-register. +# - WD Write Direct register. +# - WS Write Sub-register. +# 3. Register number in hexadecimal. +# 4. Subregister number in hexadecimal. (for RS and WS commands). +# 5. Data byte in hexadecimal. (for WD and WS commands only). +# + +package main; +use File::Basename; + +my $program = basename("$0"); +my $init_dir = dirname("$0"); +my $unit_id; + +sub logit { + print STDERR "$unit_id: @_\n"; +} + +# Arrange for error logging +if (-t STDERR) { + $unit_id = 'Interactive'; + logit "Interactive startup\n"; +} else { + $unit_id = "$ENV{XPD_BUS}/$ENV{XPD_NAME}"; + open (STDERR, "| /usr/bin/logger -t $program -p kern.info") || die; + logit "Non Interactive startup\n"; +} + +package BRI; + +sub gen { + my $fmt = shift; + $| = 1; + printf "$fmt\n", @_; +} + +package BRI::Port; + +sub new { + my $pack = shift; + my $port = { @_ }; + bless $port, $pack; +} + +# zap_xhfc_su.c:995 +sub init_su { + my $port = shift; + my $portnum = $port->{PORT_NUM}; + my $port_mode_up = $port->{PORT_MODE_UP}; + my $port_mode_exch = $port->{PORT_MODE_EXCH}; + my $bri_nt = $port->{BRI_NT}; + #logit "init_su(portnum=$portnum, port_mode_up=$port_mode_up, bri_nt=$bri_nt)"; + + # Setting PLL + # R_PLL_CTRL = 0 (V_PLL_M = 0, Reset PLL, Disable PLL_ + # R_CLK_CFG = 05 (PLL clock as system clock, output it to CLK_OUT pin) + # R_PLL_P = 1 + # R_PLL_N = 6 + # R_PLL_S = 1 + # R_PLL_CTRL = 1 (V_PLL_M) + + BRI::gen "#--------------------------- init_su($portnum, $bri_nt, $port_mode_up, $port_mode_exch)"; + BRI::gen "0 WD 02 04"; + BRI::gen "0 WD 50 00"; # disable PLL + BRI::gen "0 WD 51 02"; + BRI::gen "0 WD 52 06"; + BRI::gen "0 WD 53 04"; + BRI::gen "0 WD 50 01"; # Enable PLL + BRI::gen "0 WD 02 05"; # Enable PLL + + su_sel($portnum); # select port + if ("$port_mode_up" == 1) { + $port->{CTRL3} = 0x01; # A_ST_CTRL3: V_ST_SEL = 1 + $port->{CTRL0} = 0x10; # A_SU_CTRL0: V_ST_SQ_EN = 1 + BRI::gen "0 WD 34 0F"; # A_MS_TX: + # (multiframe/superframe transmit register) + } else { + $port->{CTRL3} = 0x00; # A_ST_CTRL3: V_ST_SEL = 0 + $port->{CTRL0} = 0x00; # A_SU_CTRL0: V_ST_SQ_EN = 0 + } + if ("$bri_nt" == 1) { + $port->{CTRL0} |= 0x04; # V_SU_MD + } + # ((V_SU_EXCH)?0x80:00) (change polarity) + if($port_mode_exch) { + $port->{CTRL2} = 0x80; + } else { + $port->{CTRL2} = 0x00; + } + BRI::gen "0 WD 35 %02X", $port->{CTRL3}; # A_ST_CTRL3 + BRI::gen "0 WD 31 %02X", $port->{CTRL0}; # A_SU_CTRL0 + BRI::gen "0 WD 35 F8"; # A_ST_CTRL3 = set end of pulse control to 0xF8 + BRI::gen "0 WD 32 08"; # A_SU_CTRL1 = Ignore E-channel data + BRI::gen "0 WD 33 %02X", $port->{CTRL2}; # A_SU_CTRL2 + + # zap_xhfc_su.c:1030 in init_su() + # A_SU_CLK_DLY + my $clk_dly; + if ("$bri_nt" == 1) { + $clk_dly = 0x6C; + } else { + $clk_dly = 0x0E; + } + #logit "clk_dly=$clk_dly"; + BRI::gen "0 WD 37 %02X", "$clk_dly"; +} + +sub su_sel { + if (@_ != 1 ) { + main::logit "ERROR: su_sel() called with " . scalar(@_) . " parameters"; + exit 1; + } + my $portnum = shift; + BRI::gen "0 WD 16 %02X", $portnum; # R_SU_SEL +} + +# zap_xhfc_su.c:281 +sub xhfc_selfifo { + if (@_ != 1 ) { + main::logit "ERROR: xhfc_selfifo() called with " . scalar(@_) . " parameters"; + exit 1; + } + my $fifonum = shift; + #logit "xhfc_selfifo($fifonum)"; + BRI::gen "0 WD 0F %02X", $fifonum; + # --> WAIT UNTIL (R_STATUS & M_BUSY) == 0 +} + +# zap_xhfc_su.c:295 +sub xhfc_resetfifo() { + #logit "xhfc_resetfifo()"; + # A_INC_RES_FIFO = M_RES_FIFO | M_RES_FIFO_ERR + BRI::gen "0 WD 0E 0A"; + # --> WAIT UNTIL (R_STATUS & M_BUSY) == 0 +} + +# zap_xhfc_su.c:1040 +# Initialize fifo (called for each portnum, channel, direction) +sub setup_fifo { + my $port = shift; + my $chan = shift; + my $direction = shift; + my $conhdlc = shift; + my $subcfg = shift; + my $fifoctrl = shift; + + my $portnum = $port->{PORT_NUM}; + my $port_mode_up = $port->{PORT_MODE_UP}; + my $port_mode_exch = $port->{PORT_MODE_EXCH}; + my $bri_nt = $port->{BRI_NT}; + + BRI::gen "#--------------------------- setup_fifo($portnum, $chan, $direction)"; + # my $fifonum = 0x80 | ($portnum << 3) | ($chan << 1) | ($direction); # # MSB first + my $fifonum = ($portnum << 3) | ($chan << 1) | ($direction); # # MSB first + my $r_slot = ($portnum << 3) | ($chan << 1) | ($direction); + # receive data from STIO2, transmit to STIO1 + my $a_sl_cfg = (0x80 | ($portnum << 3) | ($chan << 1) | ($direction)); + + #logit "setup_fifo($fifonum)"; + xhfc_selfifo $fifonum; + # A_CON_HDLC: transparent mode selection + BRI::gen "0 WD FA %02X", $conhdlc; + # A_SUBCH_CFG: subchnl params + BRI::gen "0 WD FB %02X", $subcfg; + # A_FIFO_CTRL: FIFO Control Register + BRI::gen "0 WD FF %02X", $fifoctrl; + xhfc_resetfifo; + xhfc_selfifo $fifonum; # wait for busy is builtin in this command + BRI::gen "0 WD 10 %02X", $r_slot; # R_SLOT + BRI::gen "0 WD D0 %02X", $a_sl_cfg; # A_SL_CFG +} + +# zap_xhfc_su.c:1071 +sub setup_su { + my $port = shift; + my $bchan = shift; + my $portnum = $port->{PORT_NUM}; + my $port_mode_exch = $port->{PORT_MODE_EXCH}; + my $bri_nt = $port->{BRI_NT}; + + BRI::gen "#--------------------------- setup_su($portnum, $bchan)"; + #logit "setup_su(portnum=$portnum, bchan=$bchan, port_mode_exch=$port_mode_exch, bri_nt=$bri_nt)"; + $port->{CTRL0} |= (1 << $bchan) | $bri_nt; + $port->{CTRL2} |= ($port_mode_exch << 7) | (1 << $bchan); + su_sel($portnum); # Select port + BRI::gen "0 WD 31 %02X", $port->{CTRL0}; # A_SU_CTRL0: V_B1_TX_EN | V_SU_MD | (NT/TE) + BRI::gen "0 WD 33 %02X", $port->{CTRL2}; # A_SU_CTRL2: V_B1_RX_EN +} + +sub xhfc_ph_command { + my $port = shift; + my $cmd = shift; + my $portnum = $port->{PORT_NUM}; + #logit "xhfc_ph_command(portnum=$portnum)"; + if ("$cmd" eq "HFC_L1_ACTIVATE_TE") { + su_sel($portnum); # Select port + BRI::gen "0 WD 30 60"; # A_SU_WR_STA = (M_SU_ACT & 0x03) + # (set activation) + } elsif ("$cmd" eq "HFC_L1_FORCE_DEACTIVATE_TE") { + su_sel($portnum); # Select port + BRI::gen "0 WD 30 40"; # A_SU_WR_STA = (M_SU_ACT & 0x02) + # (set deactivation) + } elsif ("$cmd" eq "HFC_L1_ACTIVATE_NT") { + su_sel($portnum); # Select port + BRI::gen "0 WD 30 E0"; # A_SU_WR_STA = (M_SU_ACT & 0x03) | 0x80 + # (set activation + NT) + } elsif ("$cmd" eq "HFC_L1_DEACTIVATE_NT") { + su_sel($portnum); # Select port + BRI::gen "0 WD 30 40"; # A_SU_WR_STA = (M_SU_ACT & 0x02) + # (set deactivation) + } +} + + +sub zthfc_startup { + my $port = shift; + my $portnum = $port->{PORT_NUM}; + my $port_mode_exch = $port->{PORT_MODE_EXCH}; + my $bri_nt = $port->{BRI_NT}; + #logit "zthfc_startup(portnum=$portnum, port_mode_exch=$port_mode_exch, bri_nt=$bri_nt)"; + + # PCM <-> ST/Up Configuration + foreach my $chan ( 0, 1 ) { + $port->setup_fifo($chan, 0, 0xFE, 0, 0);# Transparent mode, FIFO EN, ST->PCM + $port->setup_fifo($chan, 1, 0xFE, 0, 0);# Transparent mode, FIFO EN, ST->PCM + $port->setup_su($chan); # zap_xhfc_su.c:194 + } + + # Zaptel chan 2 used as HDLC D-Channel + $port->setup_fifo(2, 0, 0x05, 2, 0); # D-TX: zap_xhfc_su.c:205 + $port->setup_fifo(2, 1, 0x05, 2, 0); # D-RX: zap_xhfc_su.c:206 + # E-chan, Echo channel is ignored + + + # enable this port's state machine + su_sel($portnum); # Select port + # A_SU_WR_STA: reset port state machine + BRI::gen "0 WD 30 00"; + if ("$bri_nt" == 0) { + $port->xhfc_ph_command("HFC_L1_ACTIVATE_TE"); + } else { + $port->xhfc_ph_command("HFC_L1_ACTIVATE_NT"); + } +} + + +package main; +use Getopt::Std; + +my %opts; +getopts('o:', \%opts); + +$ENV{XPP_BASE} = '/proc/xpp'; +my $output; +if ($opts{o}) { + $output = $opts{o}; +} else { + $ENV{XPD_BUS} || die "Missing XPD_BUS environment variable\n"; + $ENV{XPD_NAME} || die "Missing XPD_NAME environment variable\n"; + $ENV{XPD_TYPE} || die "Missing XPD_TYPE environment variable\n"; + $ENV{XPD_REVISION} || die "Missing XPD_REVISION environment variable\n"; + $output = "$ENV{XPP_BASE}/$ENV{XPD_BUS}/$ENV{XPD_NAME}/slics"; +} + +open(REG, ">$output") || die "Failed to open '$output': $!\n"; +select REG; + +logit "Starting '$0'"; + +#------------------------------------------- Instance detection + +# zap_xhfc_su.c:895 +sub init_xhfc() { + #logit "init_xhfc()"; + BRI::gen "#--------------------------- init_xhfc"; + BRI::gen "0 WD 0D 00"; # r_FIFO_MD: 16 fifos, + # 64 bytes for TX and RX each (FIFO mode config) + + # software reset to enable R_FIFO_MD setting + BRI::gen "0 WD 00 08"; # R_CIRM = M_SRES (soft reset) + # --> WAIT 5u + BRI::gen "0 WD 00 00"; # R_CIRM = 0 (zero it to deactivate reset) + + # amplitude + BRI::gen "0 WD 46 80"; # R_PWM_MD: (PWM output mode register) + # PWM push to zero only + BRI::gen "0 WD 39 18"; # R_PWM1: (modulator register for PWM1) + # set duty cycle + + BRI::gen "0 WD 0C 11"; # R_FIFO_THRES: (FIFO fill lvl control register) + # RX/TX threshold = 16 bytes + + # --> Wait until (R_STATUS & (M_BUSY | M_PCM_INIT)) + # M_BUSY status will be checked after fifo selection + BRI::gen "0 WD 0F 80"; + # set PCM !master mode + BRI::gen "0 WD 14 08"; # R_PCM_MD0 = PCM slave mode, F0IO duration is 2 HFC_PCLK's + + # (C4IO, F0IO are inputs) + + # set pll adjust + # WD 14 90 # R_PCM_MD0: Index value to select + # the register at address 15 + # WD 15 2C # R_PCM_MD1: V_PLL_ADJ (DPLL adjust speed), C4IO is 16.384MHz(128 time slots) + # in the last slot of PCM frame + BRI::gen "0 WS 14 98 20"; # R_PCM_MD1: V_PLL_ADJ + # (DPLL adjust speed) in the + # last slot of PCM frame +} + +my %port_type = ( + 6 => { 'BRI_NT' => 0 }, + 7 => { 'BRI_NT' => 1 } + ); + +# zap_xhfc_su.c:175 +sub main() { + #logit "main(): XPD_TYPE=$ENV{XPD_TYPE}"; + + $ENV{XPD_TYPE} || die "Missing XPD_TYPE environment variable\n"; + my $type = $port_type{$ENV{XPD_TYPE}}; + die "Bad XPD_TYPE=$ENV{XPD_TYPE}\n" unless $type; + die "Missing XPD_SUBUNIT information\n" unless defined($ENV{XPD_SUBUNIT}); + + # We must first turn off packet reception. + # + # Otherwise we mess with registers while the FPGA firmware tries to + # send us packets. + BRI::gen "0 Wm"; + + # Common initialization + if($ENV{XPD_SUBUNIT} eq '0') { + # Turn off multi-byte packet reception before initialization started + system("/bin/echo \"0A 00 0F 00 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + system("/bin/echo \"0A 00 0F 08 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + system("/bin/echo \"0A 00 0F 10 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + system("/bin/echo \"0A 00 0F 18 C0 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + + init_xhfc; # zap_xhfc_su.c:1173 in setup_instance() + } + + # Port initialization + my $p = BRI::Port->new( + 'PORT_NUM' => $ENV{XPD_SUBUNIT}, + 'BRI_NT' => $type->{BRI_NT}, + 'PORT_MODE_UP' => 0, + 'PORT_MODE_EXCH' => 0 + ); + # zap_XHfc_su.c:1186 in setup_instance() + $p->init_su; + + $p->zthfc_startup; + + if($ENV{XPD_SUBUNIT} eq 3) { + # Turn on multi-byte packet reception when ports initialization finished + system("/bin/echo \"0A 00 0F 00 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + system("/bin/echo \"0A 00 0F 08 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + system("/bin/echo \"0A 00 0F 10 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + system("/bin/echo \"0A 00 0F 18 80 00 00 00 00 00\" >/proc/xpp/$ENV{XPD_BUS}/command"); + } +} + +main; + +logit "Ending '$0'"; + +close REG; +close STDERR; +exit 0; -- cgit v1.2.3