summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2009-06-12 18:20:09 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2009-06-12 18:20:09 +0000
commit6ab1953ff8d0d3d43208b28545db674d08b1861a (patch)
treedfaa0c38884be167843fb55218b58249fe0d6ce7
parent2da5bef89aeecb790e49b95fd000421b8aaed488 (diff)
astribank_tool: Support 'reset' of old protocol as fallback
If astribank_tool fails to open a device when running a reset command, try to reset the device with the command from the old (pre-MPP) protocol (A single 0x20 byte). No support whatsoever for any other feature of the old protocol. This was accidentally left out of previous commits. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4653 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rw-r--r--kernel/xpp/utils/astribank_tool.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/kernel/xpp/utils/astribank_tool.c b/kernel/xpp/utils/astribank_tool.c
index d5ba667..b9bcaaa 100644
--- a/kernel/xpp/utils/astribank_tool.c
+++ b/kernel/xpp/utils/astribank_tool.c
@@ -31,6 +31,11 @@
#include "debug.h"
#define DBG_MASK 0x80
+/* if enabled, adds support for resetting pre-MPP USB firmware - if we
+ * failed opening a device and we were asked to reset it, try also the
+ * old protocol.
+ */
+#define SUPPORT_OLD_RESET
static char *progname;
@@ -106,6 +111,36 @@ static int show_hardware(struct astribank_device *astribank)
return 0;
}
+#ifdef SUPPORT_OLD_RESET
+/* Try to reset a device using USB_FW.hex, up to Xorcom rev. 6885 */
+int old_reset(const char* devpath)
+{
+ struct astribank_device *astribank;
+ int ret;
+ struct {
+ uint8_t op;
+ } PACKED header = {0x20}; /* PT_RESET */
+ char *buf = (char*) &header;
+
+ /* Note that the function re-opens the connection to the Astribank
+ * as any reference to the previous connection was lost when mpp_open
+ * returned NULL as the astribank reference. */
+ astribank = astribank_open(devpath, 1);
+ if (!astribank) {
+ DBG("Failed re-opening astribank device for old_reset\n");
+ return -ENODEV;
+ }
+ ret = send_usb(astribank, buf, 1, 5000);
+
+ /* If we just had a reenumeration, we may get -ENODEV */
+ if(ret < 0 && ret != -ENODEV)
+ return ret;
+ /* We don't astribank_close(), as it has likely been
+ * reenumerated by now. */
+ return 0;
+}
+#endif /* SUPPORT_OLD_RESET */
+
int main(int argc, char *argv[])
{
char *devpath = NULL;
@@ -164,6 +199,16 @@ int main(int argc, char *argv[])
DBG("Startup %s\n", devpath);
if((astribank = mpp_init(devpath)) == NULL) {
ERR("Failed initializing MPP\n");
+#ifdef SUPPORT_OLD_RESET
+ INFO("opt_reset = %s\n", opt_reset);
+ if (opt_reset) {
+ INFO("Trying old reset method\n");
+ if ((ret = old_reset(devpath)) != 0) {
+ ERR("Old reset method failed as well: %d\n", ret);
+ }
+ }
+#endif /* SUPPORT_OLD_RESET */
+
return 1;
}
show_hardware(astribank);