aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ads7871.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/ads7871.c')
-rw-r--r--drivers/hwmon/ads7871.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
index 04450f8bf5da..e65c6e45d36b 100644
--- a/drivers/hwmon/ads7871.c
+++ b/drivers/hwmon/ads7871.c
@@ -34,9 +34,11 @@
34#define REG_SER_CONTROL 24 /*Serial Interface Control Register*/ 34#define REG_SER_CONTROL 24 /*Serial Interface Control Register*/
35#define REG_ID 31 /*ID Register*/ 35#define REG_ID 31 /*ID Register*/
36 36
37/*From figure 17 in the datasheet 37/*
38* These bits get ORed with the address to form 38 * From figure 17 in the datasheet
39* the instruction byte */ 39 * These bits get ORed with the address to form
40 * the instruction byte
41 */
40/*Instruction Bit masks*/ 42/*Instruction Bit masks*/
41#define INST_MODE_bm (1<<7) 43#define INST_MODE_bm (1<<7)
42#define INST_READ_bm (1<<6) 44#define INST_READ_bm (1<<6)
@@ -105,8 +107,10 @@ static ssize_t show_voltage(struct device *dev,
105 uint8_t channel, mux_cnv; 107 uint8_t channel, mux_cnv;
106 108
107 channel = attr->index; 109 channel = attr->index;
108 /*TODO: add support for conversions 110 /*
109 *other than single ended with a gain of 1*/ 111 * TODO: add support for conversions
112 * other than single ended with a gain of 1
113 */
110 /*MUX_M3_bm forces single ended*/ 114 /*MUX_M3_bm forces single ended*/
111 /*This is also where the gain of the PGA would be set*/ 115 /*This is also where the gain of the PGA would be set*/
112 ads7871_write_reg8(spi, REG_GAIN_MUX, 116 ads7871_write_reg8(spi, REG_GAIN_MUX,
@@ -114,8 +118,10 @@ static ssize_t show_voltage(struct device *dev,
114 118
115 ret = ads7871_read_reg8(spi, REG_GAIN_MUX); 119 ret = ads7871_read_reg8(spi, REG_GAIN_MUX);
116 mux_cnv = ((ret & MUX_CNV_bm)>>MUX_CNV_bv); 120 mux_cnv = ((ret & MUX_CNV_bm)>>MUX_CNV_bv);
117 /*on 400MHz arm9 platform the conversion 121 /*
118 *is already done when we do this test*/ 122 * on 400MHz arm9 platform the conversion
123 * is already done when we do this test
124 */
119 while ((i < 2) && mux_cnv) { 125 while ((i < 2) && mux_cnv) {
120 i++; 126 i++;
121 ret = ads7871_read_reg8(spi, REG_GAIN_MUX); 127 ret = ads7871_read_reg8(spi, REG_GAIN_MUX);
@@ -179,8 +185,10 @@ static int __devinit ads7871_probe(struct spi_device *spi)
179 ret = ads7871_read_reg8(spi, REG_OSC_CONTROL); 185 ret = ads7871_read_reg8(spi, REG_OSC_CONTROL);
180 186
181 dev_dbg(&spi->dev, "REG_OSC_CONTROL write:%x, read:%x\n", val, ret); 187 dev_dbg(&spi->dev, "REG_OSC_CONTROL write:%x, read:%x\n", val, ret);
182 /*because there is no other error checking on an SPI bus 188 /*
183 we need to make sure we really have a chip*/ 189 * because there is no other error checking on an SPI bus
190 * we need to make sure we really have a chip
191 */
184 if (val != ret) { 192 if (val != ret) {
185 err = -ENODEV; 193 err = -ENODEV;
186 goto exit; 194 goto exit;
@@ -234,18 +242,7 @@ static struct spi_driver ads7871_driver = {
234 .remove = __devexit_p(ads7871_remove), 242 .remove = __devexit_p(ads7871_remove),
235}; 243};
236 244
237static int __init ads7871_init(void) 245module_spi_driver(ads7871_driver);
238{
239 return spi_register_driver(&ads7871_driver);
240}
241
242static void __exit ads7871_exit(void)
243{
244 spi_unregister_driver(&ads7871_driver);
245}
246
247module_init(ads7871_init);
248module_exit(ads7871_exit);
249 246
250MODULE_AUTHOR("Paul Thomas <pthomas8589@gmail.com>"); 247MODULE_AUTHOR("Paul Thomas <pthomas8589@gmail.com>");
251MODULE_DESCRIPTION("TI ADS7871 A/D driver"); 248MODULE_DESCRIPTION("TI ADS7871 A/D driver");