summaryrefslogtreecommitdiff
path: root/xpp/parport_debug.c
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-05-17 19:34:32 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-05-17 19:34:32 +0000
commit5b68efc40a339a8ae3d9d137c7b9af809c3f5519 (patch)
tree365f4c82a3123daebaf9a8d41817916c1dd74bf4 /xpp/parport_debug.c
parent5174fc292d1a6184271a39aea2826b57f177454e (diff)
* Tested with zaptel-1.2.17.1
* Add D-Channel TX, RX and BAD frames count in /proc/xpp/XBUS-*/XPD-*/bri_info * Adjust output of xpp_sync script. Pad for 8 port BRI. * Added a debugging module parport_debug (not compiled by default). * Added an optional patch to zaptel: - compiles only if ZAPTEL_SYNC_TICK is defined - Allow interested driver to register for "sync" notification. - Does not affect drivers that do not use this feature. * Added external synchronization feature: - Only if ZAPTEL_SYNC_TICK feature is compiled in - Than XPP may be synchronized by another card (e.g: an Astribank with FXS can be synchronized by a Digium PRI card). - May be enabled/disabled in runtime via the 'sync_tick_active' module parameter to the xpp.ko module. * Fixed a potential bug in D-Channel hexdump printing. * New visual indications in BRI leds: - Constant ON RED/GREEN: Shows the port type -- NT/TE. - Very fast "double blink": Layer1 work, no D-Channel yet. - Steady blinking (1/2 sec): D-Channel trafic detected. * xpp_fxloader moved to /usr/share/zaptel . * adj_clock removed: never really used. * Debugfs code now disabled by default. * Now we have Zaptel::Hardware and a sample zaptel_hardware script (not (installed by default). * We also have a sample perl zapconf (not installed by default) which aims at replacing genzaptelconf (sans the modules detection). git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2529 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/parport_debug.c')
-rw-r--r--xpp/parport_debug.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/xpp/parport_debug.c b/xpp/parport_debug.c
new file mode 100644
index 0000000..93049ef
--- /dev/null
+++ b/xpp/parport_debug.c
@@ -0,0 +1,113 @@
+/*
+ * Written by Oron Peled <oron@actcom.co.il>
+ * Copyright (C) 2007, 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 <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+# warning "This module is tested only with 2.6 kernels"
+#endif
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/parport.h>
+#include "parport_debug.h"
+
+static struct parport *debug_sync_parport = NULL;
+static int parport_toggles[8]; /* 8 bit flip-flop */
+
+void flip_parport_bit(unsigned char bitnum)
+{
+ static unsigned char last_value;
+ spinlock_t lock = SPIN_LOCK_UNLOCKED;
+ unsigned long flags;
+ unsigned char mask;
+ unsigned char value;
+
+ if(!debug_sync_parport) {
+ if(printk_ratelimit()) {
+ printk(KERN_NOTICE "%s: no debug parallel port\n",
+ THIS_MODULE->name);
+ }
+ return;
+ }
+ BUG_ON(bitnum > 7);
+ mask = 1 << bitnum;
+ spin_lock_irqsave(&lock, flags);
+ value = last_value & ~mask;
+ if(parport_toggles[bitnum] % 2) /* square wave */
+ value |= mask;
+ last_value = value;
+ parport_toggles[bitnum]++;
+ spin_unlock_irqrestore(&lock, flags);
+ parport_write_data(debug_sync_parport, value);
+}
+EXPORT_SYMBOL(flip_parport_bit);
+
+static void parport_attach(struct parport *port)
+{
+ printk(KERN_INFO "%s: Using %s for debugging\n", THIS_MODULE->name, port->name);
+ if(debug_sync_parport) {
+ printk(KERN_ERR "%s: Using %s, ignore new attachment %s\n",
+ THIS_MODULE->name, debug_sync_parport->name, port->name);
+ return;
+ }
+ parport_get_port(port);
+ debug_sync_parport = port;
+}
+
+static void parport_detach(struct parport *port)
+{
+ printk(KERN_INFO "%s: Releasing %s\n", THIS_MODULE->name, port->name);
+ if(debug_sync_parport != port) {
+ printk(KERN_ERR "%s: Using %s, ignore new detachment %s\n",
+ THIS_MODULE->name, debug_sync_parport->name, port->name);
+ return;
+ }
+ parport_put_port(debug_sync_parport);
+ debug_sync_parport = NULL;
+}
+
+static struct parport_driver debug_parport_driver = {
+ .name = "parport_debug",
+ .attach = parport_attach,
+ .detach = parport_detach,
+};
+
+int __init parallel_dbg_init(void)
+{
+ int ret;
+
+ ret = parport_register_driver(&debug_parport_driver);
+ return ret;
+}
+
+void __exit parallel_dbg_cleanup(void)
+{
+ parport_unregister_driver(&debug_parport_driver);
+}
+
+MODULE_DESCRIPTION("Use parallel port to debug drivers");
+MODULE_AUTHOR("Oron Peled <oron@actcom.co.il>");
+MODULE_LICENSE("GPL");
+MODULE_VERSION("$Id:");
+
+module_init(parallel_dbg_init);
+module_exit(parallel_dbg_cleanup);