Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: comedi: 8255_pci: move ni_pcidio 8255 board support

The 8255 based boards in the ni_pcidio driver are all simple
memory mapped 8255 boards that don't require the dma support
provided by the mite driver.

Move the support for these boards from the ni_pcidio driver to
the generic 8255_pci driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

H Hartley Sweeten and committed by
Greg Kroah-Hartman
b37c1aee 77f17d37

+123 -177
+4 -5
drivers/staging/comedi/Kconfig
··· 560 560 ADlink - PCI-7224, PCI-7248, and PCI-7296 561 561 Measurement Computing - PCI-DIO24, PCI-DIO24H, PCI-DIO48H and 562 562 PCI-DIO96H 563 + National Instruments - PCI-DIO-96, PCI-DIO-96B, PXI-6508, PCI-6503, 564 + PCI-6503B, PCI-6503X, and PXI-6503 563 565 564 566 To compile this driver as a module, choose M here: the module will 565 567 be called 8255_pci. ··· 1032 1030 called ni_labpc. 1033 1031 1034 1032 config COMEDI_NI_PCIDIO 1035 - tristate "NI PCI-DIO32HS, PCI-DIO96, PCI-6533, PCI-6503 support" 1033 + tristate "NI PCI-DIO32HS, PCI-6533, PCI-6534 support" 1036 1034 select COMEDI_MITE 1037 1035 select COMEDI_8255 1038 1036 ---help--- 1039 1037 Enable support for National Instruments PCI-DIO-32HS, PXI-6533, 1040 - PCI-DIO-96, PCI-DIO-96B, PXI-6508, PCI-6503, PCI-6503B, PCI-6503X, 1041 - PXI-6503, PCI-6533 and PCI-6534 1042 - The DIO-96 appears as four 8255 subdevices. See the 8255 1043 - driver notes for details. 1038 + PCI-6533 and PCI-6534 1044 1039 1045 1040 To compile this driver as a module, choose M here: the module will be 1046 1041 called ni_pcidio.
+71
drivers/staging/comedi/drivers/8255_pci.c
··· 35 35 (Measurement Computing) PCI-DIO24H [cb_pci-dio24h] - 24 channels 36 36 (Measurement Computing) PCI-DIO48H [cb_pci-dio48h] - 48 channels 37 37 (Measurement Computing) PCI-DIO96H [cb_pci-dio96h] - 96 channels 38 + (National Instruments) PCI-DIO-96 [ni_pci-dio-96] - 96 channels 39 + (National Instruments) PCI-DIO-96B [ni_pci-dio-96b] - 96 channels 40 + (National Instruments) PXI-6508 [ni_pxi-6508] - 96 channels 41 + (National Instruments) PCI-6503 [ni_pci-6503] - 24 channels 42 + (National Instruments) PCI-6503B [ni_pci-6503b] - 24 channels 43 + (National Instruments) PCI-6503X [ni_pci-6503x] - 24 channels 44 + (National Instruments) PXI-6503 [ni_pxi-6503] - 24 channels 38 45 Author: H Hartley Sweeten <hsweeten@visionengravers.com> 39 46 Updated: Wed, 12 Sep 2012 11:52:01 -0700 40 47 Status: untested ··· 72 65 #define PCI_DEVICE_ID_CB_PCIDIO24H 0x0014 73 66 #define PCI_DEVICE_ID_CB_PCIDIO96H 0x0017 74 67 #define PCI_DEVICE_ID_CB_PCIDIO24 0x0028 68 + 69 + #define PCI_DEVICE_ID_NI_PCIDIO96 0x0160 70 + #define PCI_DEVICE_ID_NI_PCI6503 0x0400 71 + #define PCI_DEVICE_ID_NI_PCI6503B 0x1250 72 + #define PCI_DEVICE_ID_NI_PXI6508 0x13c0 73 + #define PCI_DEVICE_ID_NI_PCIDIO96B 0x1630 74 + #define PCI_DEVICE_ID_NI_PCI6503X 0x17d0 75 + #define PCI_DEVICE_ID_NI_PXI_6503 0x1800 75 76 76 77 struct pci_8255_boardinfo { 77 78 const char *name; ··· 133 118 .device = PCI_DEVICE_ID_CB_PCIDIO96H, 134 119 .dio_badr = 2, 135 120 .n_8255 = 4, 121 + }, { 122 + .name = "ni_pci-dio-96", 123 + .vendor = PCI_VENDOR_ID_NI, 124 + .device = PCI_DEVICE_ID_NI_PCIDIO96, 125 + .dio_badr = 1, 126 + .is_mmio = 1, 127 + .n_8255 = 4, 128 + }, { 129 + .name = "ni_pci-dio-96b", 130 + .vendor = PCI_VENDOR_ID_NI, 131 + .device = PCI_DEVICE_ID_NI_PCIDIO96B, 132 + .dio_badr = 1, 133 + .is_mmio = 1, 134 + .n_8255 = 4, 135 + }, { 136 + .name = "ni_pxi-6508", 137 + .vendor = PCI_VENDOR_ID_NI, 138 + .device = PCI_DEVICE_ID_NI_PXI6508, 139 + .dio_badr = 1, 140 + .is_mmio = 1, 141 + .n_8255 = 4, 142 + }, { 143 + .name = "ni_pci-6503", 144 + .vendor = PCI_VENDOR_ID_NI, 145 + .device = PCI_DEVICE_ID_NI_PCI6503, 146 + .dio_badr = 1, 147 + .is_mmio = 1, 148 + .n_8255 = 1, 149 + }, { 150 + .name = "ni_pci-6503b", 151 + .vendor = PCI_VENDOR_ID_NI, 152 + .device = PCI_DEVICE_ID_NI_PCI6503B, 153 + .dio_badr = 1, 154 + .is_mmio = 1, 155 + .n_8255 = 1, 156 + }, { 157 + .name = "ni_pci-6503x", 158 + .vendor = PCI_VENDOR_ID_NI, 159 + .device = PCI_DEVICE_ID_NI_PCI6503X, 160 + .dio_badr = 1, 161 + .is_mmio = 1, 162 + .n_8255 = 1, 163 + }, { 164 + .name = "ni_pxi-6503", 165 + .vendor = PCI_VENDOR_ID_NI, 166 + .device = PCI_DEVICE_ID_NI_PXI_6503, 167 + .dio_badr = 1, 168 + .is_mmio = 1, 169 + .n_8255 = 1, 136 170 }, 137 171 }; 138 172 ··· 329 265 { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_CB_PCIDIO24H) }, 330 266 { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_CB_PCIDIO48H) }, 331 267 { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_CB_PCIDIO96H) }, 268 + { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PCIDIO96) }, 269 + { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PCIDIO96B) }, 270 + { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PXI6508) }, 271 + { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PCI6503) }, 272 + { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PCI6503B) }, 273 + { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PCI6503X) }, 274 + { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PXI_6503) }, 332 275 { 0 } 333 276 }; 334 277 MODULE_DEVICE_TABLE(pci, pci_8255_pci_table);
+48 -172
drivers/staging/comedi/drivers/ni_pcidio.c
··· 1 1 /* 2 2 comedi/drivers/ni_pcidio.c 3 - driver for National Instruments PCI-DIO-96/PCI-6508 4 - National Instruments PCI-DIO-32HS 5 - National Instruments PCI-6503 3 + driver for National Instruments PCI-DIO-32HS 6 4 7 5 COMEDI - Linux Control and Measurement Device Interface 8 6 Copyright (C) 1999,2002 David A. Schleef <ds@schleef.org> ··· 22 24 */ 23 25 /* 24 26 Driver: ni_pcidio 25 - Description: National Instruments PCI-DIO32HS, PCI-DIO96, PCI-6533, PCI-6503 27 + Description: National Instruments PCI-DIO32HS, PCI-6533 26 28 Author: ds 27 29 Status: works 28 - Devices: [National Instruments] PCI-DIO-32HS (ni_pcidio), PXI-6533, 29 - PCI-DIO-96, PCI-DIO-96B, PXI-6508, PCI-6503, PCI-6503B, PCI-6503X, 30 - PXI-6503, PCI-6533, PCI-6534 30 + Devices: [National Instruments] PCI-DIO-32HS (ni_pcidio) 31 + [National Instruments] PXI-6533, PCI-6533 (pxi-6533) 32 + [National Instruments] PCI-6534 (pci-6534) 31 33 Updated: Mon, 09 Jan 2012 14:27:23 +0000 32 - 33 - The DIO-96 appears as four 8255 subdevices. See the 8255 34 - driver notes for details. 35 34 36 35 The DIO32HS board appears as one subdevice, with 32 channels. 37 36 Each channel is individually I/O configurable. The channel order ··· 51 56 comedi_nonfree_firmware tarball available from http://www.comedi.org 52 57 */ 53 58 54 - /* 55 - This driver is for both the NI PCI-DIO-32HS and the PCI-DIO-96, 56 - which have very different architectures. But, since the '96 is 57 - so simple, it is included here. 58 - 59 - Manuals (available from ftp://ftp.natinst.com/support/manuals) 60 - 61 - 320938c.pdf PCI-DIO-96/PXI-6508/PCI-6503 User Manual 62 - 321464b.pdf AT/PCI-DIO-32HS User Manual 63 - 341329A.pdf PCI-6533 Register-Level Programmer Manual 64 - 341330A.pdf DAQ-DIO Technical Reference Manual 65 - 66 - */ 67 - 68 59 #define USE_DMA 69 60 /* #define DEBUG 1 */ 70 61 /* #define DEBUG_FLAGS */ ··· 60 79 #include "../comedidev.h" 61 80 62 81 #include "mite.h" 63 - #include "8255.h" 64 82 65 83 #undef DPRINTK 66 84 #ifdef DEBUG ··· 70 90 71 91 #define PCI_DIO_SIZE 4096 72 92 #define PCI_MITE_SIZE 4096 73 - 74 - /* defines for the PCI-DIO-96 */ 75 - 76 - #define NIDIO_8255_BASE(x) ((x)*4) 77 - #define NIDIO_A 0 78 - #define NIDIO_B 4 79 - #define NIDIO_C 8 80 - #define NIDIO_D 12 81 93 82 94 /* defines for the PCI-DIO-32HS */ 83 95 ··· 269 297 struct comedi_subdevice *s); 270 298 271 299 struct nidio_board { 272 - 273 300 int dev_id; 274 301 const char *name; 275 - int n_8255; 276 - unsigned int is_diodaq:1; 277 302 unsigned int uses_firmware:1; 278 303 }; 279 304 280 305 static const struct nidio_board nidio_boards[] = { 281 306 { 282 - .dev_id = 0x1150, 283 - .name = "pci-dio-32hs", 284 - .n_8255 = 0, 285 - .is_diodaq = 1, 286 - }, 287 - { 288 - .dev_id = 0x1320, 289 - .name = "pxi-6533", 290 - .n_8255 = 0, 291 - .is_diodaq = 1, 292 - }, 293 - { 294 - .dev_id = 0x12b0, 295 - .name = "pci-6534", 296 - .n_8255 = 0, 297 - .is_diodaq = 1, 298 - .uses_firmware = 1, 299 - }, 300 - { 301 - .dev_id = 0x0160, 302 - .name = "pci-dio-96", 303 - .n_8255 = 4, 304 - .is_diodaq = 0, 305 - }, 306 - { 307 - .dev_id = 0x1630, 308 - .name = "pci-dio-96b", 309 - .n_8255 = 4, 310 - .is_diodaq = 0, 311 - }, 312 - { 313 - .dev_id = 0x13c0, 314 - .name = "pxi-6508", 315 - .n_8255 = 4, 316 - .is_diodaq = 0, 317 - }, 318 - { 319 - .dev_id = 0x0400, 320 - .name = "pci-6503", 321 - .n_8255 = 1, 322 - .is_diodaq = 0, 323 - }, 324 - { 325 - .dev_id = 0x1250, 326 - .name = "pci-6503b", 327 - .n_8255 = 1, 328 - .is_diodaq = 0, 329 - }, 330 - { 331 - .dev_id = 0x17d0, 332 - .name = "pci-6503x", 333 - .n_8255 = 1, 334 - .is_diodaq = 0, 335 - }, 336 - { 337 - .dev_id = 0x1800, 338 - .name = "pxi-6503", 339 - .n_8255 = 1, 340 - .is_diodaq = 0, 341 - }, 307 + .dev_id = 0x1150, 308 + .name = "pci-dio-32hs", 309 + }, { 310 + .dev_id = 0x1320, 311 + .name = "pxi-6533", 312 + }, { 313 + .dev_id = 0x12b0, 314 + .name = "pci-6534", 315 + .uses_firmware = 1, 316 + }, 342 317 }; 343 318 344 319 #define n_nidio_boards ARRAY_SIZE(nidio_boards) ··· 359 440 mmiowb(); 360 441 } 361 442 spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); 362 - } 363 - 364 - static int nidio96_8255_cb(int dir, int port, int data, unsigned long iobase) 365 - { 366 - if (dir) { 367 - writeb(data, (void *)(iobase + port)); 368 - return 0; 369 - } else { 370 - return readb((void *)(iobase + port)); 371 - } 372 443 } 373 444 374 445 void ni_pcidio_event(struct comedi_device *dev, struct comedi_subdevice *s) ··· 1116 1207 static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it) 1117 1208 { 1118 1209 struct comedi_subdevice *s; 1119 - int i; 1120 1210 int ret; 1121 - int n_subdevices; 1122 1211 unsigned int irq; 1123 1212 1124 1213 printk(KERN_INFO "comedi%d: nidio:", dev->minor); ··· 1148 1241 if (ret < 0) 1149 1242 return ret; 1150 1243 } 1151 - if (!this_board->is_diodaq) 1152 - n_subdevices = this_board->n_8255; 1153 - else 1154 - n_subdevices = 1; 1155 1244 1156 - ret = comedi_alloc_subdevices(dev, n_subdevices); 1245 + ret = comedi_alloc_subdevices(dev, 1); 1157 1246 if (ret) 1158 1247 return ret; 1159 1248 1160 - if (!this_board->is_diodaq) { 1161 - for (i = 0; i < this_board->n_8255; i++) { 1162 - s = &dev->subdevices[i]; 1163 - subdev_8255_init(dev, s, nidio96_8255_cb, 1164 - (unsigned long)(devpriv->mite-> 1165 - daq_io_addr + 1166 - NIDIO_8255_BASE(i))); 1167 - } 1168 - } else { 1249 + printk(KERN_INFO " rev=%d", 1250 + readb(devpriv->mite->daq_io_addr + Chip_Version)); 1169 1251 1170 - printk(KERN_INFO " rev=%d", 1171 - readb(devpriv->mite->daq_io_addr + Chip_Version)); 1252 + s = &dev->subdevices[0]; 1172 1253 1173 - s = &dev->subdevices[0]; 1254 + dev->read_subdev = s; 1255 + s->type = COMEDI_SUBD_DIO; 1256 + s->subdev_flags = 1257 + SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL | SDF_PACKED | 1258 + SDF_CMD_READ; 1259 + s->n_chan = 32; 1260 + s->range_table = &range_digital; 1261 + s->maxdata = 1; 1262 + s->insn_config = &ni_pcidio_insn_config; 1263 + s->insn_bits = &ni_pcidio_insn_bits; 1264 + s->do_cmd = &ni_pcidio_cmd; 1265 + s->do_cmdtest = &ni_pcidio_cmdtest; 1266 + s->cancel = &ni_pcidio_cancel; 1267 + s->len_chanlist = 32; /* XXX */ 1268 + s->buf_change = &ni_pcidio_change; 1269 + s->async_dma_dir = DMA_BIDIRECTIONAL; 1270 + s->poll = &ni_pcidio_poll; 1174 1271 1175 - dev->read_subdev = s; 1176 - s->type = COMEDI_SUBD_DIO; 1177 - s->subdev_flags = 1178 - SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL | SDF_PACKED | 1179 - SDF_CMD_READ; 1180 - s->n_chan = 32; 1181 - s->range_table = &range_digital; 1182 - s->maxdata = 1; 1183 - s->insn_config = &ni_pcidio_insn_config; 1184 - s->insn_bits = &ni_pcidio_insn_bits; 1185 - s->do_cmd = &ni_pcidio_cmd; 1186 - s->do_cmdtest = &ni_pcidio_cmdtest; 1187 - s->cancel = &ni_pcidio_cancel; 1188 - s->len_chanlist = 32; /* XXX */ 1189 - s->buf_change = &ni_pcidio_change; 1190 - s->async_dma_dir = DMA_BIDIRECTIONAL; 1191 - s->poll = &ni_pcidio_poll; 1272 + writel(0, devpriv->mite->daq_io_addr + Port_IO(0)); 1273 + writel(0, devpriv->mite->daq_io_addr + Port_Pin_Directions(0)); 1274 + writel(0, devpriv->mite->daq_io_addr + Port_Pin_Mask(0)); 1192 1275 1193 - writel(0, devpriv->mite->daq_io_addr + Port_IO(0)); 1194 - writel(0, devpriv->mite->daq_io_addr + Port_Pin_Directions(0)); 1195 - writel(0, devpriv->mite->daq_io_addr + Port_Pin_Mask(0)); 1276 + /* disable interrupts on board */ 1277 + writeb(0x00, 1278 + devpriv->mite->daq_io_addr + 1279 + Master_DMA_And_Interrupt_Control); 1196 1280 1197 - /* disable interrupts on board */ 1198 - writeb(0x00, 1199 - devpriv->mite->daq_io_addr + 1200 - Master_DMA_And_Interrupt_Control); 1281 + ret = request_irq(irq, nidio_interrupt, IRQF_SHARED, 1282 + "ni_pcidio", dev); 1283 + if (ret < 0) 1284 + printk(KERN_WARNING " irq not available"); 1201 1285 1202 - ret = request_irq(irq, nidio_interrupt, IRQF_SHARED, 1203 - "ni_pcidio", dev); 1204 - if (ret < 0) 1205 - printk(KERN_WARNING " irq not available"); 1206 - 1207 - dev->irq = irq; 1208 - } 1286 + dev->irq = irq; 1209 1287 1210 1288 printk("\n"); 1211 1289 ··· 1199 1307 1200 1308 static void nidio_detach(struct comedi_device *dev) 1201 1309 { 1202 - struct comedi_subdevice *s; 1203 - int i; 1204 - 1205 - if (this_board && !this_board->is_diodaq) { 1206 - for (i = 0; i < this_board->n_8255; i++) { 1207 - s = &dev->subdevices[i]; 1208 - subdev_8255_cleanup(dev, s); 1209 - } 1210 - } 1211 1310 if (dev->irq) 1212 1311 free_irq(dev->irq, dev); 1213 1312 if (devpriv) { ··· 1233 1350 { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1150) }, 1234 1351 { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1320) }, 1235 1352 { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x12b0) }, 1236 - { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0160) }, 1237 - { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1630) }, 1238 - { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x13c0) }, 1239 - { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0400) }, 1240 - { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1250) }, 1241 - { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x17d0) }, 1242 - { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1800) }, 1243 1353 { 0 } 1244 1354 }; 1245 1355 MODULE_DEVICE_TABLE(pci, ni_pcidio_pci_table);