16a5c8664766b82b36ec50bd2de9e72d3eae0dfbbIan Abbott/*
28485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * comedi/drivers/amplc_pc236.c
34cb60db2eabd275649b3305cc488a9794de8e463Ian Abbott * Driver for Amplicon PC36AT DIO boards.
48485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott *
58485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * Copyright (C) 2002 MEV Ltd. <http://www.mev.co.uk/>
68485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott *
78485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * COMEDI - Linux Control and Measurement Device Interface
88485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * Copyright (C) 2000 David A. Schleef <ds@schleef.org>
98485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott *
108485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * This program is free software; you can redistribute it and/or modify
118485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * it under the terms of the GNU General Public License as published by
128485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * the Free Software Foundation; either version 2 of the License, or
138485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * (at your option) any later version.
148485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott *
158485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * This program is distributed in the hope that it will be useful,
168485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * but WITHOUT ANY WARRANTY; without even the implied warranty of
178485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
188485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * GNU General Public License for more details.
198485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott */
206a5c8664766b82b36ec50bd2de9e72d3eae0dfbbIan Abbott/*
218485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * Driver: amplc_pc236
224cb60db2eabd275649b3305cc488a9794de8e463Ian Abbott * Description: Amplicon PC36AT
238485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * Author: Ian Abbott <abbotti@mev.co.uk>
244cb60db2eabd275649b3305cc488a9794de8e463Ian Abbott * Devices: [Amplicon] PC36AT (pc36at)
254cb60db2eabd275649b3305cc488a9794de8e463Ian Abbott * Updated: Fri, 25 Jul 2014 15:32:40 +0000
268485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * Status: works
278485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott *
288485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * Configuration options - PC36AT:
298485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott *   [0] - I/O port base address
308485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott *   [1] - IRQ (optional)
318485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott *
324cb60db2eabd275649b3305cc488a9794de8e463Ian Abbott * The PC36AT board has a single 8255 appearing as subdevice 0.
338485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott *
348485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * Subdevice 1 pretends to be a digital input device, but it always returns
358485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * 0 when read. However, if you run a command with scan_begin_src=TRIG_EXT,
368485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * a rising edge on port C bit 3 acts as an external trigger, which can be
378485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * used to wake up tasks.  This is like the comedi_parport device, but the
388485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * only way to physically disable the interrupt on the PC36AT is to remove
398485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * the IRQ jumper.  If no interrupt is connected, then subdevice 1 is
408485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott * unused.
418485e4f04a5dcb4d51b46f65e984ce3b22599967Ian Abbott */
426a5c8664766b82b36ec50bd2de9e72d3eae0dfbbIan Abbott
43ce157f8032bbd46d9427034c335b0afd751da25dH Hartley Sweeten#include <linux/module.h>
4470265d24e3404fe798b6edd55a02016b1edb49d7Jiri Slaby
456a5c8664766b82b36ec50bd2de9e72d3eae0dfbbIan Abbott#include "../comedidev.h"
466a5c8664766b82b36ec50bd2de9e72d3eae0dfbbIan Abbott
474cb60db2eabd275649b3305cc488a9794de8e463Ian Abbott#include "amplc_pc236.h"
487bd06f69f3f52fcd04999790a2a9d66f1a8cd0c9Ian Abbott
4918e41de083075b3b6a0bd55e00f1662d045efb49Ian Abbottstatic int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
5018e41de083075b3b6a0bd55e00f1662d045efb49Ian Abbott{
519a1a6cf8ae5ca58171e117335b9983e3cfa2185cH Hartley Sweeten	struct pc236_private *devpriv;
5218e41de083075b3b6a0bd55e00f1662d045efb49Ian Abbott	int ret;
5318e41de083075b3b6a0bd55e00f1662d045efb49Ian Abbott
540bdab509bf9c6d838dc0a3b1d68bbf841fc20b5aH Hartley Sweeten	devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
55c34fa261b0ac3a862ccd3f71ee55a16b920dfc83H Hartley Sweeten	if (!devpriv)
56c34fa261b0ac3a862ccd3f71ee55a16b920dfc83H Hartley Sweeten		return -ENOMEM;
579a1a6cf8ae5ca58171e117335b9983e3cfa2185cH Hartley Sweeten
58ffe2d9fd49af6461972201eeaa8012e71fe40c97Ian Abbott	ret = comedi_request_region(dev, it->options[0], 0x4);
59ffe2d9fd49af6461972201eeaa8012e71fe40c97Ian Abbott	if (ret)
60ffe2d9fd49af6461972201eeaa8012e71fe40c97Ian Abbott		return ret;
61c3ba2678d01e983ab47b970bc80ea8e5b3444c54H Hartley Sweeten
624cb60db2eabd275649b3305cc488a9794de8e463Ian Abbott	return amplc_pc236_common_attach(dev, dev->iobase, it->options[1], 0);
637bd06f69f3f52fcd04999790a2a9d66f1a8cd0c9Ian Abbott}
647bd06f69f3f52fcd04999790a2a9d66f1a8cd0c9Ian Abbott
654cb60db2eabd275649b3305cc488a9794de8e463Ian Abbottstatic const struct pc236_board pc236_boards[] = {
666f929b4e5a022c3ca806c1675ccb833c42086853Ian Abbott	{
676f929b4e5a022c3ca806c1675ccb833c42086853Ian Abbott		.name = "pc36at",
686f929b4e5a022c3ca806c1675ccb833c42086853Ian Abbott	},
696f929b4e5a022c3ca806c1675ccb833c42086853Ian Abbott};
706f929b4e5a022c3ca806c1675ccb833c42086853Ian Abbott
717bd06f69f3f52fcd04999790a2a9d66f1a8cd0c9Ian Abbottstatic struct comedi_driver amplc_pc236_driver = {
723d03cfcaf6cde186f439ca1a318423007570760aH Hartley Sweeten	.driver_name = "amplc_pc236",
737bd06f69f3f52fcd04999790a2a9d66f1a8cd0c9Ian Abbott	.module = THIS_MODULE,
747bd06f69f3f52fcd04999790a2a9d66f1a8cd0c9Ian Abbott	.attach = pc236_attach,
754cb60db2eabd275649b3305cc488a9794de8e463Ian Abbott	.detach = comedi_legacy_detach,
764cb60db2eabd275649b3305cc488a9794de8e463Ian Abbott	.board_name = &pc236_boards[0].name,
777bd06f69f3f52fcd04999790a2a9d66f1a8cd0c9Ian Abbott	.offset = sizeof(struct pc236_board),
784cb60db2eabd275649b3305cc488a9794de8e463Ian Abbott	.num_names = ARRAY_SIZE(pc236_boards),
797bd06f69f3f52fcd04999790a2a9d66f1a8cd0c9Ian Abbott};
807bd06f69f3f52fcd04999790a2a9d66f1a8cd0c9Ian Abbott
817bd06f69f3f52fcd04999790a2a9d66f1a8cd0c9Ian Abbottmodule_comedi_driver(amplc_pc236_driver);
827bd06f69f3f52fcd04999790a2a9d66f1a8cd0c9Ian Abbott
8390f703d30dd3e0c16ff80f35e34e511385a05ad5Arun ThomasMODULE_AUTHOR("Comedi http://www.comedi.org");
844cb60db2eabd275649b3305cc488a9794de8e463Ian AbbottMODULE_DESCRIPTION("Comedi driver for Amplicon PC36AT DIO boards");
8590f703d30dd3e0c16ff80f35e34e511385a05ad5Arun ThomasMODULE_LICENSE("GPL");
86