aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2009-09-21 15:48:33 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-10-09 16:47:25 -0400
commit5044a2c0e0e951afeb4dce87e18e10036635410a (patch)
treeb13948648554df3458378d1f29dc8d4ba7e0a19a
parent2b0318a600989ed85fe020079fa20132f8aebaf3 (diff)
Staging: comedi: s526: fixes for pulse generator
Some changes and corrections to handling of INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR, and INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR, so they interpret insn->data[] as per the comments in the code. Signed-off-by: Frank Mori Hess <fmhess@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/comedi/drivers/s526.c50
1 files changed, 19 insertions, 31 deletions
diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c
index 9a8ebbe9699..07c21e686f2 100644
--- a/drivers/staging/comedi/drivers/s526.c
+++ b/drivers/staging/comedi/drivers/s526.c
@@ -453,11 +453,11 @@ static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it)
453 udelay(1000); 453 udelay(1000);
454 printk("Read back mode reg=0x%04x\n", inw(ADDR_CHAN_REG(REG_C0M, n))); 454 printk("Read back mode reg=0x%04x\n", inw(ADDR_CHAN_REG(REG_C0M, n)));
455 455
456 /* Load the pre-laod register high word */ 456 /* Load the pre-load register high word */
457/* value = (short) (0x55); */ 457/* value = (short) (0x55); */
458/* outw(value, ADDR_CHAN_REG(REG_C0H, n)); */ 458/* outw(value, ADDR_CHAN_REG(REG_C0H, n)); */
459 459
460 /* Load the pre-laod register low word */ 460 /* Load the pre-load register low word */
461/* value = (short)(0xaa55); */ 461/* value = (short)(0xaa55); */
462/* outw(value, ADDR_CHAN_REG(REG_C0L, n)); */ 462/* outw(value, ADDR_CHAN_REG(REG_C0L, n)); */
463 463
@@ -587,19 +587,8 @@ static int s526_gpct_insn_config(struct comedi_device *dev,
587 587
588#if 1 588#if 1
589 /* Set Counter Mode Register */ 589 /* Set Counter Mode Register */
590 cmReg.reg.coutSource = 0; /* out RCAP */ 590 cmReg.value = insn->data[1] & 0xFFFF;
591 cmReg.reg.coutPolarity = 0; /* Polarity inverted */
592 cmReg.reg.autoLoadResetRcap = 0; /* Auto load disabled */
593 cmReg.reg.hwCtEnableSource = 2; /* NOT RCAP */
594 cmReg.reg.ctEnableCtrl = 1; /* 1: Software, >1 : Hardware */
595 cmReg.reg.clockSource = 3; /* x4 */
596 cmReg.reg.countDir = 0; /* up */
597 cmReg.reg.countDirCtrl = 0; /* quadrature */
598 cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */
599 cmReg.reg.preloadRegSel = 0; /* PR0 */
600 cmReg.reg.reserved = 0;
601 591
602 /* Set Counter Mode Register */
603/* printk("s526: Counter Mode register=%x\n", cmReg.value); */ 592/* printk("s526: Counter Mode register=%x\n", cmReg.value); */
604 outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); 593 outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
605 594
@@ -634,11 +623,11 @@ static int s526_gpct_insn_config(struct comedi_device *dev,
634 cmReg.value = (short)(insn->data[1] & 0xFFFF); 623 cmReg.value = (short)(insn->data[1] & 0xFFFF);
635 outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); 624 outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
636 625
637 /* Load the pre-laod register high word */ 626 /* Load the pre-load register high word */
638 value = (short)((insn->data[2] >> 16) & 0xFFFF); 627 value = (short)((insn->data[2] >> 16) & 0xFFFF);
639 outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel)); 628 outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
640 629
641 /* Load the pre-laod register low word */ 630 /* Load the pre-load register low word */
642 value = (short)(insn->data[2] & 0xFFFF); 631 value = (short)(insn->data[2] & 0xFFFF);
643 outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel)); 632 outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
644 633
@@ -672,11 +661,11 @@ static int s526_gpct_insn_config(struct comedi_device *dev,
672 cmReg.reg.preloadRegSel = 0; /* PR0 */ 661 cmReg.reg.preloadRegSel = 0; /* PR0 */
673 outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); 662 outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
674 663
675 /* Load the pre-laod register 0 high word */ 664 /* Load the pre-load register 0 high word */
676 value = (short)((insn->data[2] >> 16) & 0xFFFF); 665 value = (short)((insn->data[2] >> 16) & 0xFFFF);
677 outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel)); 666 outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
678 667
679 /* Load the pre-laod register 0 low word */ 668 /* Load the pre-load register 0 low word */
680 value = (short)(insn->data[2] & 0xFFFF); 669 value = (short)(insn->data[2] & 0xFFFF);
681 outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel)); 670 outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
682 671
@@ -685,17 +674,17 @@ static int s526_gpct_insn_config(struct comedi_device *dev,
685 cmReg.reg.preloadRegSel = 1; /* PR1 */ 674 cmReg.reg.preloadRegSel = 1; /* PR1 */
686 outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); 675 outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
687 676
688 /* Load the pre-laod register 1 high word */ 677 /* Load the pre-load register 1 high word */
689 value = (short)((insn->data[3] >> 16) & 0xFFFF); 678 value = (short)((insn->data[3] >> 16) & 0xFFFF);
690 outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel)); 679 outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
691 680
692 /* Load the pre-laod register 1 low word */ 681 /* Load the pre-load register 1 low word */
693 value = (short)(insn->data[3] & 0xFFFF); 682 value = (short)(insn->data[3] & 0xFFFF);
694 outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel)); 683 outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
695 684
696 /* Write the Counter Control Register */ 685 /* Write the Counter Control Register */
697 if (insn->data[3] != 0) { 686 if (insn->data[4] != 0) {
698 value = (short)(insn->data[3] & 0xFFFF); 687 value = (short)(insn->data[4] & 0xFFFF);
699 outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel)); 688 outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel));
700 } 689 }
701 break; 690 break;
@@ -717,11 +706,11 @@ static int s526_gpct_insn_config(struct comedi_device *dev,
717 cmReg.reg.preloadRegSel = 0; /* PR0 */ 706 cmReg.reg.preloadRegSel = 0; /* PR0 */
718 outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); 707 outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
719 708
720 /* Load the pre-laod register 0 high word */ 709 /* Load the pre-load register 0 high word */
721 value = (short)((insn->data[2] >> 16) & 0xFFFF); 710 value = (short)((insn->data[2] >> 16) & 0xFFFF);
722 outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel)); 711 outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
723 712
724 /* Load the pre-laod register 0 low word */ 713 /* Load the pre-load register 0 low word */
725 value = (short)(insn->data[2] & 0xFFFF); 714 value = (short)(insn->data[2] & 0xFFFF);
726 outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel)); 715 outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
727 716
@@ -730,17 +719,17 @@ static int s526_gpct_insn_config(struct comedi_device *dev,
730 cmReg.reg.preloadRegSel = 1; /* PR1 */ 719 cmReg.reg.preloadRegSel = 1; /* PR1 */
731 outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); 720 outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
732 721
733 /* Load the pre-laod register 1 high word */ 722 /* Load the pre-load register 1 high word */
734 value = (short)((insn->data[3] >> 16) & 0xFFFF); 723 value = (short)((insn->data[3] >> 16) & 0xFFFF);
735 outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel)); 724 outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
736 725
737 /* Load the pre-laod register 1 low word */ 726 /* Load the pre-load register 1 low word */
738 value = (short)(insn->data[3] & 0xFFFF); 727 value = (short)(insn->data[3] & 0xFFFF);
739 outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel)); 728 outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
740 729
741 /* Write the Counter Control Register */ 730 /* Write the Counter Control Register */
742 if (insn->data[3] != 0) { 731 if (insn->data[4] != 0) {
743 value = (short)(insn->data[3] & 0xFFFF); 732 value = (short)(insn->data[4] & 0xFFFF);
744 outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel)); 733 outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel));
745 } 734 }
746 break; 735 break;
@@ -795,9 +784,8 @@ static int s526_gpct_winsn(struct comedi_device *dev,
795 (devpriv->s526_gpct_config[subdev_channel]).data[1] = 784 (devpriv->s526_gpct_config[subdev_channel]).data[1] =
796 insn->data[1]; 785 insn->data[1];
797 } else { 786 } else {
798 printk("%d \t %d\n", insn->data[1], insn->data[2]); 787 printk("s526: INSN_WRITE: PTG: Problem with Pulse params -> %d %d\n",
799 printk 788 insn->data[0], insn->data[1]);
800 ("s526: INSN_WRITE: PTG: Problem with Pulse params\n");
801 return -EINVAL; 789 return -EINVAL;
802 } 790 }
803 791