Commit dd269473 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: ni_65xx: fix digital output reset during attach

During the attach of this driver, the digital output ports are all
initialized to a known state. Some of the boards supported by this
driver have output ports that are inverted from the comedi view of
the output state. For these boards the values written to the ports
needs to be inverted.

Currently, only bit 0 of each port is inverted when the boardinfo
indicates that the outputs are inverted. This results in channels
0, 8, 16, etc. being set to '0' and all other channels being set
to '1'. If the boardinfo does not indicate that the outputs are
inverted, all the channels are set to '0'.

This initialization is unnecessary for the input only ports. The
input/output ports also do not need to be initialized since they
are configured as inputs during the attach.

Move the output port initialization so it occurs when the digital
output subdevice is setup. Use the 's->io_bits' value to initialize
the ports so that the correct inverted/non-inverted state is used
for the comedi '0' value.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 800453dc
......@@ -659,6 +659,13 @@ static int ni_65xx_auto_attach(struct comedi_device *dev,
/* use the io_bits to handle the inverted outputs */
s->io_bits = (board->invert_outputs) ? 0xff : 0x00;
/* reset all output ports to comedi '0' */
for (i = 0; i < board->num_do_ports; ++i) {
writeb(s->io_bits, /* inverted if necessary */
devpriv->mmio +
NI_65XX_IO_DATA_REG(board->num_di_ports + i));
}
} else {
s->type = COMEDI_SUBD_UNUSED;
}
......@@ -702,13 +709,8 @@ static int ni_65xx_auto_attach(struct comedi_device *dev,
s->cancel = ni_65xx_intr_cancel;
}
for (i = 0; i < ni_65xx_total_num_ports(board); ++i) {
for (i = 0; i < ni_65xx_total_num_ports(board); ++i)
writeb(0x00, devpriv->mmio + NI_65XX_FILTER_ENA(i));
if (board->invert_outputs)
writeb(0x01, devpriv->mmio + NI_65XX_IO_DATA_REG(i));
else
writeb(0x00, devpriv->mmio + NI_65XX_IO_DATA_REG(i));
}
/* Set filter interval to 0 (32bit reg) */
writel(0x00000000, devpriv->mmio + NI_65XX_FILTER_REG);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment