summaryrefslogtreecommitdiff
path: root/kernel/xpp/utils/zconf/Zaptel/Hardware/USB.pm
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2009-05-27 10:01:24 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2009-05-27 10:01:24 +0000
commit18c6813f2c788b603dab363b9138d65d24252167 (patch)
tree92402484268f2bc1d5e4e55f7321b9204ad47c5f /kernel/xpp/utils/zconf/Zaptel/Hardware/USB.pm
parent2a73224819e867eaf56371d6055e2ca4d36396b6 (diff)
Big dump of newer xpp code.
For finer details and separate commits, you are advised to look into the commit log of dahdi-{linux,tools}. xpp.r7150 * 116x Astribanks: - Support for the TwinStar capability and for FXO and (BRI|PRI) on same device. - New control protocol ("MPP"). - astribank_hextool - a low-level firmware loading tool instead of fpga_load . - astribank_tool - Other MPP activities . - Can still reset (but just that) through older protocol. - astribank_hexload is required for loading FPGA firmware for USB_FW.hex rev > 6885. - USB_FW rev. 7071 . - More modular FPGA firmware (1161 only). - FPGA_1161.hex rev. 7131. PIC_TYPE_* rev. 7107. - software-settings of some capabilities with astribank_allow . * XPP: - init_card_* script are less verbose. - Reduced rate of "Is a DAHDI sync master" message. - Replace member bus_id with dev_name() and set_dev_name() for building with 2.6.30. - Conditionally remove 'owner' property of procfs was dropped in 2.6.30. - astribank_hook now enabled by default. - Has an optional hook for TwinStar. * BRI: - hardhdlc support: The bri_dchan patch is no longer needed. - If bri_dchan patch applied: old code is used, and "dchan" is used. - If not: new code and "hardhdlc" is used. - zapconf will generate the right configuration, depending on the new sysfs driver attribute bri_hardhdlc, but default to "dchan" as before if not explicitly told. - Bugfix: explicitly turn off leds on startup. * FXS: - Initialization and calibration fixes. - Notify the user just one about wrong VMWI config * Dahdi-perl: - Fix detection of empty slots in wctdm. - Fix working with ethmf's extra file in /proc/zaptel - Improved detection of Rhino cards. - dahdi_genconf's generated text better explains files are generated. - /etc/xpp_order - allow specifiying an explicit order for Astribanks to register with Zaptel. - Dahdi::Xpp::Mpp - A wrapper around astribank_tool . * dahdi.init: - A separate waitfor_xpds script. May now have a wait-loop in some cases. - xpp_sync needs to only be called after dahdi_cfg . (for the PRI module). git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4641 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'kernel/xpp/utils/zconf/Zaptel/Hardware/USB.pm')
-rw-r--r--kernel/xpp/utils/zconf/Zaptel/Hardware/USB.pm88
1 files changed, 62 insertions, 26 deletions
diff --git a/kernel/xpp/utils/zconf/Zaptel/Hardware/USB.pm b/kernel/xpp/utils/zconf/Zaptel/Hardware/USB.pm
index a2dc08f..4ac0c17 100644
--- a/kernel/xpp/utils/zconf/Zaptel/Hardware/USB.pm
+++ b/kernel/xpp/utils/zconf/Zaptel/Hardware/USB.pm
@@ -10,8 +10,7 @@ package Zaptel::Hardware::USB;
use strict;
use Zaptel::Utils;
use Zaptel::Hardware;
-use Zaptel::Xpp;
-use Zaptel::Xpp::Xbus;
+use Zaptel::Xpp::Mpp;
our @ISA = qw(Zaptel::Hardware);
@@ -34,46 +33,83 @@ my %usb_ids = (
'e4e4:1160' => { DRIVER => 'xpp_usb', DESCRIPTION => 'Astribank-modular no-firmware' },
'e4e4:1161' => { DRIVER => 'xpp_usb', DESCRIPTION => 'Astribank-modular USB-firmware' },
'e4e4:1162' => { DRIVER => 'xpp_usb', DESCRIPTION => 'Astribank-modular FPGA-firmware' },
+
+ # Sangoma USB FXO:
+ '10c4:8461' => { DRIVER => 'wanpipe', DESCRIPTION => 'Sangoma WANPIPE USB-FXO Device' },
);
$ENV{PATH} .= ":/usr/sbin:/sbin:/usr/bin:/bin";
-my @xbuses = Zaptel::Xpp::xbuses('SORT_CONNECTOR');
-
sub usb_sorter() {
return $a->hardware_name cmp $b->hardware_name;
}
-sub xbus_of_usb($) {
- my $priv_device_name = shift;
- my $dev = shift;
+sub mpp_addinfo($) {
+ my $self = shift || die;
- my ($wanted) = grep {
- defined($_->usb_devname) &&
- $priv_device_name eq $_->usb_devname
- } @xbuses;
- return $wanted;
+ my $mppinfo = Zaptel::Xpp::Mpp->new($self);
+ $self->{MPPINFO} = $mppinfo if defined $mppinfo;
}
-sub new($$) {
+sub new($@) {
my $pack = shift or die "Wasn't called as a class method\n";
- my $self = { @_ };
+ my %attr = @_;
+ my $name = sprintf("usb:%s", $attr{PRIV_DEVICE_NAME});
+ my $self = Zaptel::Hardware->new($name, 'USB');
+ %{$self} = (%{$self}, %attr);
bless $self, $pack;
- my $xbus = xbus_of_usb($self->priv_device_name);
- if(defined $xbus) {
- $self->{XBUS} = $xbus;
- $self->{LOADED} = 'xpp_usb';
- } else {
- $self->{XBUS} = undef;
- $self->{LOADED} = undef;
- }
- Zaptel::Hardware::device_detected($self,
- sprintf("usb:%s", $self->{PRIV_DEVICE_NAME}));
return $self;
}
-sub devices($) {
+sub readval($) {
+ my $fname = shift || warn;
+ open(F, $fname) || warn "Failed opening '$fname': $!";
+ my $val = <F>;
+ close F;
+ chomp $val;
+ warn "$fname is empty" unless defined $val and $val;
+ return $val;
+}
+
+sub set_transport($$) {
+ my $pack = shift || die;
+ my $xbus = shift || die;
+ my $xbus_dir = shift;
+ my $transportdir = "$xbus_dir/transport";
+ my $hwdev;
+ if(! -e "$transportdir/ep_00") {
+ warn "A trasnport in '$transportdir' is not USB";
+ return undef;
+ }
+ my ($usbdev) = glob("$transportdir/usb_device:*");
+ my $busnum;
+ my $devnum;
+ # Different kernels...
+ if(defined $usbdev) { # It's USB
+ if($usbdev =~ /.*usb_device:usbdev(\d+)\.(\d+)/) {
+ $busnum = $1;
+ $devnum = $2;
+ } else {
+ warn "Bad USB transportdir='$transportdir' usbdev='$usbdev'\n";
+ }
+ } elsif(-d "$transportdir/usb_endpoint") {
+ $busnum = readval("$transportdir/busnum");
+ $devnum = readval("$transportdir/devnum");
+ }
+ my $usbname = sprintf("%03d/%03d", $busnum, $devnum);
+ #printf STDERR "DEBUG: %03d/%03d\n", $busnum, $devnum;
+ $xbus->{USB_DEVNAME} = $usbname;
+ $hwdev = Zaptel::Hardware->device_by_hwname("usb:$usbname");
+ #print "set_transport: ", $hwdev, "\n";
+ $xbus->{TRANSPORT} = $hwdev;
+ $hwdev->{XBUS} = $xbus;
+ $hwdev->{LOADED} = 'xpp_usb';
+ $xbus->{IS_TWINSTAR} = $hwdev->is_twinstar;
+ return $hwdev;
+}
+
+sub scan_devices($) {
my $pack = shift || die;
my $usb_device_list = "/proc/bus/usb/devices";
return unless (-r $usb_device_list);
@@ -99,7 +135,6 @@ sub devices($) {
next unless defined $model;
my $d = Zaptel::Hardware::USB->new(
IS_ASTRIBANK => ($model->{DRIVER} eq 'xpp_usb')?1:0,
- BUS_TYPE => 'USB',
PRIV_DEVICE_NAME => $devname,
VENDOR => $vendor,
PRODUCT => $product,
@@ -111,6 +146,7 @@ sub devices($) {
}
close F;
@devices = sort usb_sorter @devices;
+ return @devices;
}
1;