staging: comedi: ni_stc.h: tidy up the cs5529_configuration_bits
For aesthetics, convert the enum into defines and the inline functions into macros. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ee3e21ac4b
commit
b738aa3a13
@ -4581,19 +4581,19 @@ static void cs5529_config_write(struct comedi_device *dev, unsigned int value,
|
||||
|
||||
static int init_cs5529(struct comedi_device *dev)
|
||||
{
|
||||
unsigned int config_bits =
|
||||
CSCFG_PORT_MODE | CSCFG_WORD_RATE_2180_CYCLES;
|
||||
unsigned int config_bits = CS5529_CFG_PORT_FLAG |
|
||||
CS5529_CFG_WORD_RATE_2180;
|
||||
|
||||
#if 1
|
||||
/* do self-calibration */
|
||||
cs5529_config_write(dev, config_bits | CSCFG_SELF_CAL_OFFSET_GAIN,
|
||||
cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_BOTH_SELF,
|
||||
CSCMD_CONFIG_REGISTER);
|
||||
/* need to force a conversion for calibration to run */
|
||||
cs5529_do_conversion(dev, NULL);
|
||||
#else
|
||||
/* force gain calibration to 1 */
|
||||
cs5529_config_write(dev, 0x400000, CSCMD_GAIN_REGISTER);
|
||||
cs5529_config_write(dev, config_bits | CSCFG_SELF_CAL_OFFSET,
|
||||
cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_OFFSET_SELF,
|
||||
CSCMD_CONFIG_REGISTER);
|
||||
if (cs5529_wait_for_idle(dev))
|
||||
dev_err(dev->class_dev,
|
||||
|
@ -676,39 +676,33 @@ static inline unsigned int DACx_Direct_Data_671x(int channel)
|
||||
enum AO_Misc_611x_Bits {
|
||||
CLEAR_WG = 1,
|
||||
};
|
||||
enum cs5529_configuration_bits {
|
||||
CSCFG_CAL_CONTROL_MASK = 0x7,
|
||||
CSCFG_SELF_CAL_OFFSET = 0x1,
|
||||
CSCFG_SELF_CAL_GAIN = 0x2,
|
||||
CSCFG_SELF_CAL_OFFSET_GAIN = 0x3,
|
||||
CSCFG_SYSTEM_CAL_OFFSET = 0x5,
|
||||
CSCFG_SYSTEM_CAL_GAIN = 0x6,
|
||||
CSCFG_DONE = 1 << 3,
|
||||
CSCFG_POWER_SAVE_SELECT = 1 << 4,
|
||||
CSCFG_PORT_MODE = 1 << 5,
|
||||
CSCFG_RESET_VALID = 1 << 6,
|
||||
CSCFG_RESET = 1 << 7,
|
||||
CSCFG_UNIPOLAR = 1 << 12,
|
||||
CSCFG_WORD_RATE_2180_CYCLES = 0x0 << 13,
|
||||
CSCFG_WORD_RATE_1092_CYCLES = 0x1 << 13,
|
||||
CSCFG_WORD_RATE_532_CYCLES = 0x2 << 13,
|
||||
CSCFG_WORD_RATE_388_CYCLES = 0x3 << 13,
|
||||
CSCFG_WORD_RATE_324_CYCLES = 0x4 << 13,
|
||||
CSCFG_WORD_RATE_17444_CYCLES = 0x5 << 13,
|
||||
CSCFG_WORD_RATE_8724_CYCLES = 0x6 << 13,
|
||||
CSCFG_WORD_RATE_4364_CYCLES = 0x7 << 13,
|
||||
CSCFG_WORD_RATE_MASK = 0x7 << 13,
|
||||
CSCFG_LOW_POWER = 1 << 16,
|
||||
};
|
||||
static inline unsigned int CS5529_CONFIG_DOUT(int output)
|
||||
{
|
||||
return 1 << (18 + output);
|
||||
}
|
||||
|
||||
static inline unsigned int CS5529_CONFIG_AOUT(int output)
|
||||
{
|
||||
return 1 << (22 + output);
|
||||
}
|
||||
#define CS5529_CFG_AOUT(x) BIT(22 + (x))
|
||||
#define CS5529_CFG_DOUT(x) BIT(18 + (x))
|
||||
#define CS5529_CFG_LOW_PWR_MODE BIT(16)
|
||||
#define CS5529_CFG_WORD_RATE(x) (((x) & 0x7) << 13)
|
||||
#define CS5529_CFG_WORD_RATE_MASK CS5529_CFG_WORD_RATE(0x7)
|
||||
#define CS5529_CFG_WORD_RATE_2180 CS5529_CFG_WORD_RATE(0)
|
||||
#define CS5529_CFG_WORD_RATE_1092 CS5529_CFG_WORD_RATE(1)
|
||||
#define CS5529_CFG_WORD_RATE_532 CS5529_CFG_WORD_RATE(2)
|
||||
#define CS5529_CFG_WORD_RATE_388 CS5529_CFG_WORD_RATE(3)
|
||||
#define CS5529_CFG_WORD_RATE_324 CS5529_CFG_WORD_RATE(4)
|
||||
#define CS5529_CFG_WORD_RATE_17444 CS5529_CFG_WORD_RATE(5)
|
||||
#define CS5529_CFG_WORD_RATE_8724 CS5529_CFG_WORD_RATE(6)
|
||||
#define CS5529_CFG_WORD_RATE_4364 CS5529_CFG_WORD_RATE(7)
|
||||
#define CS5529_CFG_UNIPOLAR BIT(12)
|
||||
#define CS5529_CFG_RESET BIT(7)
|
||||
#define CS5529_CFG_RESET_VALID BIT(6)
|
||||
#define CS5529_CFG_PORT_FLAG BIT(5)
|
||||
#define CS5529_CFG_PWR_SAVE_SEL BIT(4)
|
||||
#define CS5529_CFG_DONE_FLAG BIT(3)
|
||||
#define CS5529_CFG_CALIB(x) (((x) & 0x7) << 0)
|
||||
#define CS5529_CFG_CALIB_NONE CS5529_CFG_CALIB(0)
|
||||
#define CS5529_CFG_CALIB_OFFSET_SELF CS5529_CFG_CALIB(1)
|
||||
#define CS5529_CFG_CALIB_GAIN_SELF CS5529_CFG_CALIB(2)
|
||||
#define CS5529_CFG_CALIB_BOTH_SELF CS5529_CFG_CALIB(3)
|
||||
#define CS5529_CFG_CALIB_OFFSET_SYS CS5529_CFG_CALIB(5)
|
||||
#define CS5529_CFG_CALIB_GAIN_SYS CS5529_CFG_CALIB(6)
|
||||
|
||||
enum cs5529_command_bits {
|
||||
CSCMD_POWER_SAVE = 0x1,
|
||||
|
Loading…
Reference in New Issue
Block a user