summaryrefslogtreecommitdiff
path: root/xpp/astribank_usb.h
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-04-02 20:56:42 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-04-02 20:56:42 +0000
commitcb01267f42eba7bc5a572235e5d2571cc9b60303 (patch)
tree421d7509698c604a76499fdc95432642f323d9ad /xpp/astribank_usb.h
parent8c29f87f0fe6465a171644f1d916481d0d2def4f (diff)
Support for Astribanks 116x: tools part
* New USB firmware loading mechanism. - Incompatible with previous one: upgrade using fxload or hard reset - astribank_hexload is the new low-level loading tool - fpga_load remains for backward compatibility. - xpp/astribank_upgrade: automate upgrading using fxload * Much enhanced control protocol ("MPP") - astribank_tool is the low-level tool for that. * Support for the TwinStar (dual USB port) - Managed through astribank_tool - Wrapper perl modules and scripts provided * Allow explicit ordering of Astribanks - /etc/dahdi/xpp_order - explicit order of Astribanks on the system - The default sorter is now to use those and fall back to connectors (previous default). - An option to dahdi_registration to change sorting. git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@6313 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'xpp/astribank_usb.h')
-rw-r--r--xpp/astribank_usb.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/xpp/astribank_usb.h b/xpp/astribank_usb.h
new file mode 100644
index 0000000..6f9a429
--- /dev/null
+++ b/xpp/astribank_usb.h
@@ -0,0 +1,102 @@
+#ifndef ASTRIBANK_USB_H
+#define ASTRIBANK_USB_H
+/*
+ * Written by Oron Peled <oron@actcom.co.il>
+ * Copyright (C) 2008, 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <usb.h>
+#include "mpp.h"
+
+/*
+ * Astribank handling
+ */
+
+#define PACKET_SIZE 512
+
+/* USB Endpoints */
+#define MP_EP_OUT 0x04 /* Managment processor */
+#define MP_EP_IN 0x88 /* Managment processor */
+
+#define XPP_EP_OUT 0x02 /* XPP */
+#define XPP_EP_IN 0x86 /* XPP */
+
+/* USB firmware types */
+#define USB_11xx 0
+#define USB_FIRMWARE_II 1
+#define USB_PIC 2
+
+struct interface_type {
+ int type_code;
+ int num_interfaces;
+ int my_interface_num;
+ int num_endpoints;
+ int my_ep_out;
+ int my_ep_in;
+ char *name;
+ int endpoints[4]; /* for matching */
+};
+
+enum eeprom_burn_state {
+ BURN_STATE_NONE = 0,
+ BURN_STATE_STARTED = 1,
+ BURN_STATE_ENDED = 2,
+ BURN_STATE_FAILED = 3,
+};
+
+struct astribank_device {
+ struct usb_device *dev;
+ usb_dev_handle *handle;
+ int my_interface_num;
+ int my_ep_out;
+ int my_ep_in;
+ char iManufacturer[BUFSIZ];
+ char iProduct[BUFSIZ];
+ char iSerialNumber[BUFSIZ];
+ char iInterface[BUFSIZ];
+ int is_usb2;
+ enum eeprom_type eeprom_type;
+ enum eeprom_burn_state burn_state;
+ uint8_t status;
+ uint8_t mpp_proto_version;
+ struct eeprom_table *eeprom;
+ const struct interface_type *fwtype;
+ uint16_t tx_sequenceno;
+};
+
+/*
+ * Prototypes
+ */
+struct astribank_device *astribank_open(const char devpath[], int iface_num);
+void astribank_close(struct astribank_device *astribank, int disconnected);
+void show_astribank_info(const struct astribank_device *astribank);
+int send_usb(struct astribank_device *astribank, char *buf, int len, int timeout);
+int recv_usb(struct astribank_device *astribank, char *buf, size_t len, int timeout);
+int flush_read(struct astribank_device *astribank);
+int eeprom_fill(struct eeprom_table *eprm,
+ const char *vendor,
+ const char *product,
+ const char *release,
+ const char *label);
+int astribank_has_twinstar(struct astribank_device *astribank);
+int label_isvalid(const char *label);
+
+#endif /* ASTRIBANK_USB_H */