mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-17 23:25:46 +08:00
hwmon: (lm70) Add support for LM71 and LM74
Add support for LM74 and LM71 to LM70 driver. Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
367eb2ee8a
commit
a86e94dc94
@ -6,6 +6,10 @@ Supported chips:
|
|||||||
Datasheet: http://www.national.com/pf/LM/LM70.html
|
Datasheet: http://www.national.com/pf/LM/LM70.html
|
||||||
* Texas Instruments TMP121/TMP123
|
* Texas Instruments TMP121/TMP123
|
||||||
Information: http://focus.ti.com/docs/prod/folders/print/tmp121.html
|
Information: http://focus.ti.com/docs/prod/folders/print/tmp121.html
|
||||||
|
* National Semiconductor LM71
|
||||||
|
Datasheet: http://www.ti.com/product/LM71
|
||||||
|
* National Semiconductor LM74
|
||||||
|
Datasheet: http://www.ti.com/product/LM74
|
||||||
|
|
||||||
Author:
|
Author:
|
||||||
Kaiwan N Billimoria <kaiwan@designergraphix.com>
|
Kaiwan N Billimoria <kaiwan@designergraphix.com>
|
||||||
@ -31,8 +35,11 @@ As a real (in-tree) example of this "SPI protocol driver" interfacing
|
|||||||
with a "SPI master controller driver", see drivers/spi/spi_lm70llp.c
|
with a "SPI master controller driver", see drivers/spi/spi_lm70llp.c
|
||||||
and its associated documentation.
|
and its associated documentation.
|
||||||
|
|
||||||
The TMP121/TMP123 are very similar; main difference is 13-bit temperature
|
The LM74 and TMP121/TMP123 are very similar; main difference is 13-bit
|
||||||
data (0.0625 degrees celsius resolution).
|
temperature data (0.0625 degrees celsius resolution).
|
||||||
|
|
||||||
|
The LM71 is also very similar; main difference is 14-bit temperature
|
||||||
|
data (0.03125 degrees celsius resolution).
|
||||||
|
|
||||||
Thanks to
|
Thanks to
|
||||||
---------
|
---------
|
||||||
|
@ -560,12 +560,12 @@ config SENSORS_LM63
|
|||||||
will be called lm63.
|
will be called lm63.
|
||||||
|
|
||||||
config SENSORS_LM70
|
config SENSORS_LM70
|
||||||
tristate "National Semiconductor LM70 / Texas Instruments TMP121"
|
tristate "National Semiconductor LM70 and compatibles"
|
||||||
depends on SPI_MASTER
|
depends on SPI_MASTER
|
||||||
help
|
help
|
||||||
If you say yes here you get support for the National Semiconductor
|
If you say yes here you get support for the National Semiconductor
|
||||||
LM70 and Texas Instruments TMP121/TMP123 digital temperature
|
LM70, LM71, LM74 and Texas Instruments TMP121/TMP123 digital tempera-
|
||||||
sensor chips.
|
ture sensor chips.
|
||||||
|
|
||||||
This driver can also be built as a module. If so, the module
|
This driver can also be built as a module. If so, the module
|
||||||
will be called lm70.
|
will be called lm70.
|
||||||
|
@ -43,6 +43,8 @@
|
|||||||
|
|
||||||
#define LM70_CHIP_LM70 0 /* original NS LM70 */
|
#define LM70_CHIP_LM70 0 /* original NS LM70 */
|
||||||
#define LM70_CHIP_TMP121 1 /* TI TMP121/TMP123 */
|
#define LM70_CHIP_TMP121 1 /* TI TMP121/TMP123 */
|
||||||
|
#define LM70_CHIP_LM71 2 /* NS LM71 */
|
||||||
|
#define LM70_CHIP_LM74 3 /* NS LM74 */
|
||||||
|
|
||||||
struct lm70 {
|
struct lm70 {
|
||||||
struct device *hwmon_dev;
|
struct device *hwmon_dev;
|
||||||
@ -88,9 +90,13 @@ static ssize_t lm70_sense_temp(struct device *dev,
|
|||||||
* Celsius.
|
* Celsius.
|
||||||
* So it's equivalent to multiplying by 0.25 * 1000 = 250.
|
* So it's equivalent to multiplying by 0.25 * 1000 = 250.
|
||||||
*
|
*
|
||||||
* TMP121/TMP123:
|
* LM74 and TMP121/TMP123:
|
||||||
* 13 bits of 2's complement data, discard LSB 3 bits,
|
* 13 bits of 2's complement data, discard LSB 3 bits,
|
||||||
* resolution 0.0625 degrees celsius.
|
* resolution 0.0625 degrees celsius.
|
||||||
|
*
|
||||||
|
* LM71:
|
||||||
|
* 14 bits of 2's complement data, discard LSB 2 bits,
|
||||||
|
* resolution 0.0312 degrees celsius.
|
||||||
*/
|
*/
|
||||||
switch (p_lm70->chip) {
|
switch (p_lm70->chip) {
|
||||||
case LM70_CHIP_LM70:
|
case LM70_CHIP_LM70:
|
||||||
@ -98,8 +104,13 @@ static ssize_t lm70_sense_temp(struct device *dev,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LM70_CHIP_TMP121:
|
case LM70_CHIP_TMP121:
|
||||||
|
case LM70_CHIP_LM74:
|
||||||
val = ((int)raw / 8) * 625 / 10;
|
val = ((int)raw / 8) * 625 / 10;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LM70_CHIP_LM71:
|
||||||
|
val = ((int)raw / 4) * 3125 / 100;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */
|
status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */
|
||||||
@ -123,6 +134,12 @@ static ssize_t lm70_show_name(struct device *dev, struct device_attribute
|
|||||||
case LM70_CHIP_TMP121:
|
case LM70_CHIP_TMP121:
|
||||||
ret = sprintf(buf, "tmp121\n");
|
ret = sprintf(buf, "tmp121\n");
|
||||||
break;
|
break;
|
||||||
|
case LM70_CHIP_LM71:
|
||||||
|
ret = sprintf(buf, "lm71\n");
|
||||||
|
break;
|
||||||
|
case LM70_CHIP_LM74:
|
||||||
|
ret = sprintf(buf, "lm74\n");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
@ -139,7 +156,7 @@ static int __devinit lm70_probe(struct spi_device *spi)
|
|||||||
struct lm70 *p_lm70;
|
struct lm70 *p_lm70;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
/* signaling is SPI_MODE_0 for both LM70 and TMP121 */
|
/* signaling is SPI_MODE_0 */
|
||||||
if (spi->mode & (SPI_CPOL | SPI_CPHA))
|
if (spi->mode & (SPI_CPOL | SPI_CPHA))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
@ -196,6 +213,8 @@ static int __devexit lm70_remove(struct spi_device *spi)
|
|||||||
static const struct spi_device_id lm70_ids[] = {
|
static const struct spi_device_id lm70_ids[] = {
|
||||||
{ "lm70", LM70_CHIP_LM70 },
|
{ "lm70", LM70_CHIP_LM70 },
|
||||||
{ "tmp121", LM70_CHIP_TMP121 },
|
{ "tmp121", LM70_CHIP_TMP121 },
|
||||||
|
{ "lm71", LM70_CHIP_LM71 },
|
||||||
|
{ "lm74", LM70_CHIP_LM74 },
|
||||||
{ },
|
{ },
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(spi, lm70_ids);
|
MODULE_DEVICE_TABLE(spi, lm70_ids);
|
||||||
@ -213,5 +232,5 @@ static struct spi_driver lm70_driver = {
|
|||||||
module_spi_driver(lm70_driver);
|
module_spi_driver(lm70_driver);
|
||||||
|
|
||||||
MODULE_AUTHOR("Kaiwan N Billimoria");
|
MODULE_AUTHOR("Kaiwan N Billimoria");
|
||||||
MODULE_DESCRIPTION("NS LM70 / TI TMP121/TMP123 Linux driver");
|
MODULE_DESCRIPTION("NS LM70 and compatibles Linux driver");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
Loading…
Reference in New Issue
Block a user