28 #define REG_PGA_VALID 2
29 #define REG_AD_CONTROL 3
30 #define REG_GAIN_MUX 4
31 #define REG_IO_STATE 5
32 #define REG_IO_CONTROL 6
33 #define REG_OSC_CONTROL 7
34 #define REG_SER_CONTROL 24
43 #define INST_MODE_bm (1<<7)
44 #define INST_READ_bm (1<<6)
45 #define INST_16BIT_bm (1<<5)
50 #define MUX_CNV_bm (1<<MUX_CNV_bv)
51 #define MUX_M3_bm (1<<3)
56 #define OSC_OSCR_bm (1<<5)
57 #define OSC_OSCE_bm (1<<4)
58 #define OSC_REFE_bm (1<<3)
59 #define OSC_BUFE_bm (1<<2)
60 #define OSC_R2V_bm (1<<1)
61 #define OSC_RBG_bm (1<<0)
63 #include <linux/module.h>
72 #define DEVICE_NAME "ads7871"
83 ret = spi_w8r8(spi, reg);
91 ret = spi_w8r16(spi, reg);
98 return spi_write(spi, tmp,
sizeof(tmp));
109 channel = attr->
index;
125 while ((i < 2) && mux_cnv) {
135 val = ((val>>2) * 25000) / 8192;
136 return sprintf(buf,
"%d\n", val);
145 return sprintf(buf,
"%s\n", to_spi_device(dev)->modalias);
159 static struct attribute *ads7871_attributes[] = {
160 &sensor_dev_attr_in0_input.dev_attr.attr,
161 &sensor_dev_attr_in1_input.dev_attr.attr,
162 &sensor_dev_attr_in2_input.dev_attr.attr,
163 &sensor_dev_attr_in3_input.dev_attr.attr,
164 &sensor_dev_attr_in4_input.dev_attr.attr,
165 &sensor_dev_attr_in5_input.dev_attr.attr,
166 &sensor_dev_attr_in6_input.dev_attr.attr,
167 &sensor_dev_attr_in7_input.dev_attr.attr,
173 .attrs = ads7871_attributes,
196 dev_dbg(&spi->
dev,
"REG_OSC_CONTROL write:%x, read:%x\n", val, ret);
213 spi_set_drvdata(spi, pdata);
243 .probe = ads7871_probe,