[PARPORT] Parport IRQ triggering (rising or falling)?

From: Petter Reinholdtsen (pere@hungry.com)
Date: Thu Apr 06 2000 - 23:02:57 EDT

  • Next message: Tim Waugh: "Re: [PARPORT] inb (problems)"

    Do all parallel ports trigger on the same edge? My Compaq Armada
    7380DMT running RedHat 6.2 trigger on the logically rising edge (0->1)
    of ACK. Is this the same for all PCs? Is it different on other
    platforms?

    I wrote the following small module to test the triggering direction.
    I would be very pleased if anyone would test it on other PCs and
    non-PCs to check the ACK trigger edge.

    /*
     * Author: Petter Reinholdtsen <pere@td.org.uit.no>
     * Date: 2000-04-05
     *
     * Parport IRQ triggering test module for Linux. Connect parport
     * STROBE (pin 1) and ACK (pin 10) with a wire, and load this module.
     * Loading will fail, but the module will report the IRQ triggering to
     * syslog.
     */

    #include <linux/module.h>
    #include <linux/init.h>
    #include <linux/kernel.h>
    #include <linux/parport.h>

    struct testinfo
    {
      struct parport *pport;
      struct pardevice *pdev;
      int transitions;
      int irq_count;
      int ack_set;
    };

    static void __init
    test_irq_handler(int irq, void *dev, struct pt_regs *regs)
    {
      struct testinfo *info = (struct testinfo *)dev;
      info->irq_count++;
      if (parport_read_status(info->pport) & PARPORT_STATUS_ACK)
        info->ack_set++;
    }

    static void __init
    error(struct testinfo *info)
    {
        printk(KERN_ERR "pptest: Unknown triggering on %s: "
               "#edges=%d #irq=%d #ack_set=%d \n",
               info->pport->name, info->transitions, info->irq_count, info->ack_set);
        printk(KERN_ERR "pptest: Did you forget to connect STROBE (pin 1) "
               "and ACK (pin 10)\n");
    }

    static void __init
    test_parport(struct parport *port)
    {
      int i;
      struct testinfo info;

      info.transitions = 10;
      info.irq_count = 0;
      info.ack_set = 0;
      info.pport = port;
      info.pdev = parport_register_device(port, "Parport IRQ test", NULL, NULL,
                                     test_irq_handler, 0, &info);
      if (NULL == info.pdev)
        {
          printk(KERN_ERR "pptest: couldn't register for %s.\n", port->name);
          return;
        }
      parport_claim_or_block(info.pdev);

      info.pport->ops->enable_irq(info.pport);

      for (i = 0 ; i < info.transitions; i++)
        {
          parport_frob_control(info.pport, PARPORT_CONTROL_STROBE,
                               i % 2 ? PARPORT_CONTROL_STROBE : 0);
        }

      if (info.irq_count == info.transitions/2)
        {
          if (info.irq_count == info.ack_set)
            printk(KERN_ERR "pptest: %s trigger on rising ACK (0->1)\n",
                   info.pport->name);
          else if (info.irq_count == info.transitions/2 - info.ack_set)
            printk(KERN_ERR "pptest: %s trigger on falling ACK (1->0)\n",
                   info.pport->name);
          else
            error(&info);
        }
      else
        error(&info);

      parport_release(info.pdev);
      parport_unregister_device(info.pdev);
    }

    static void __init
    test_parports(void)
    {
      struct parport *port;
      for (port = parport_enumerate(); port; port=port->next)
        test_parport(port);
    }

    #ifdef MODULE

    #if LINUX_VERSION_CODE >= 0x020117
    MODULE_AUTHOR("Petter Reinholdtsen <pere@td.org.uit.no>");
    MODULE_DESCRIPTION("Test if parport interrupts trigger on rising or falling ACK.");
    #endif

    EXPORT_NO_SYMBOLS;

    int __init
    init_module(void)
    {
      test_parports();
      return -ENODEV;
    }

    void
    cleanup_module(void)
    {
    }
    #endif

    -- 
    ##>  Petter Reinholdtsen  <##  |  pere@td.org.uit.no
    

    -- To unsubscribe, send mail to: linux-parport-request@torque.net -- -- with the single word "unsubscribe" in the body of the message. --



    This archive was generated by hypermail 2b29 : Thu Apr 06 2000 - 23:02:19 EDT