2 comedi/drivers/mpc8260.c
3 driver for digital I/O pins on the MPC 8260 CPM module
5 COMEDI - Linux Control and Measurement Device Interface
6 Copyright (C) 2000,2001 David A. Schleef <ds@schleef.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 Description: MPC8260 CPM module generic digital I/O lines
26 Devices: [Motorola] MPC8260 CPM (mpc8260cpm)
29 Updated: Sat, 16 Mar 2002 17:34:48 -0800
31 This driver is specific to the Motorola MPC8260 processor, allowing
32 you to access the processor's generic digital I/O lines.
34 It is apparently missing some code.
37 #include "../comedidev.h"
39 extern unsigned long mpc8260_dio_reserved[4];
41 struct mpc8260cpm_private {
47 #define devpriv ((struct mpc8260cpm_private *)dev->private)
49 static int mpc8260cpm_attach(struct comedi_device *dev, struct comedi_devconfig *it);
50 static int mpc8260cpm_detach(struct comedi_device *dev);
51 static struct comedi_driver driver_mpc8260cpm = {
52 driver_name:"mpc8260cpm",
54 attach:mpc8260cpm_attach,
55 detach:mpc8260cpm_detach,
58 COMEDI_INITCLEANUP(driver_mpc8260cpm);
60 static int mpc8260cpm_dio_config(struct comedi_device *dev, struct comedi_subdevice *s,
61 struct comedi_insn *insn, unsigned int *data);
62 static int mpc8260cpm_dio_bits(struct comedi_device *dev, struct comedi_subdevice *s,
63 struct comedi_insn *insn, unsigned int *data);
65 static int mpc8260cpm_attach(struct comedi_device *dev, struct comedi_devconfig *it)
67 struct comedi_subdevice *s;
70 printk("comedi%d: mpc8260cpm: ", dev->minor);
72 dev->board_ptr = mpc8260cpm_boards + dev->board;
74 dev->board_name = thisboard->name;
76 if (alloc_private(dev, sizeof(struct mpc8260cpm_private)) < 0)
79 if (alloc_subdevices(dev, 4) < 0)
82 for (i = 0; i < 4; i++) {
83 s = dev->subdevices + i;
84 s->type = COMEDI_SUBD_DIO;
85 s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
88 s->range_table = &range_digital;
89 s->insn_config = mpc8260cpm_dio_config;
90 s->insn_bits = mpc8260cpm_dio_bits;
96 static int mpc8260cpm_detach(struct comedi_device *dev)
98 printk("comedi%d: mpc8260cpm: remove\n", dev->minor);
103 static unsigned long *cpm_pdat(int port)
107 return &io->iop_pdata;
109 return &io->iop_pdatb;
111 return &io->iop_pdatc;
113 return &io->iop_pdatd;
117 static int mpc8260cpm_dio_config(struct comedi_device *dev, struct comedi_subdevice *s,
118 struct comedi_insn *insn, unsigned int *data)
125 port = (int)s->private;
126 mask = 1 << CR_CHAN(insn->chanspec);
127 if (mask & cpm_reserved_bits[port]) {
132 case INSN_CONFIG_DIO_OUTPUT:
135 case INSN_CONFIG_DIO_INPUT:
138 case INSN_CONFIG_DIO_QUERY:
139 data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT;
148 return &io->iop_pdira;
150 return &io->iop_pdirb;
152 return &io->iop_pdirc;
154 return &io->iop_pdird;
160 static int mpc8260cpm_dio_bits(struct comedi_device *dev, struct comedi_subdevice *s,
161 struct comedi_insn *insn, unsigned int *data)
166 p = cpm_pdat((int)s->private);