From 53e678d75e7c22b251c6981ff8364b5c42c5eac4 Mon Sep 17 00:00:00 2001 From: "Peter A. Bigot" Date: Sat, 24 Dec 2016 07:22:44 -0600 Subject: hwmon: (sht21) Add Electronic Identification Code retrieval Expose the per-chip unique identifier so it can be used to identify the sensor producing the measurements. Signed-off-by: Peter A. Bigot Signed-off-by: Guenter Roeck --- Documentation/hwmon/sht21 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Documentation') diff --git a/Documentation/hwmon/sht21 b/Documentation/hwmon/sht21 index db17fda45c3e..47f4765db256 100644 --- a/Documentation/hwmon/sht21 +++ b/Documentation/hwmon/sht21 @@ -35,6 +35,7 @@ sysfs-Interface temp1_input - temperature input humidity1_input - humidity input +eic - Electronic Identification Code Notes ----- @@ -45,5 +46,5 @@ humidity and 66 ms for temperature. To keep self heating below 0.1 degree Celsius, the device should not be active for more than 10% of the time, e.g. maximum two measurements per second at the given resolution. -Different resolutions, the on-chip heater, using the CRC checksum and reading -the serial number are not supported yet. +Different resolutions, the on-chip heater, and using the CRC checksum +are not supported yet. -- cgit v1.2.3 From bbcf37d73c2d3b4fa1a5781c992289b9a90c1480 Mon Sep 17 00:00:00 2001 From: Alexander Koch Date: Fri, 6 Jan 2017 11:38:14 +0100 Subject: devicetree: hwmon: Add bindings for ADC128D818 Add bindings documentation for the ADC128D818 driver, featuring default I2C properties along with the optional 'mode' property for chip operation mode selection (see datasheet, sec. 8.4.1). Signed-off-by: Alexander Koch Acked-by: Michael Hornung Acked-by: Rob Herring [groeck: Fixed whitespace error] Signed-off-by: Guenter Roeck --- .../devicetree/bindings/hwmon/adc128d818.txt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/adc128d818.txt (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/hwmon/adc128d818.txt b/Documentation/devicetree/bindings/hwmon/adc128d818.txt new file mode 100644 index 000000000000..08bab0e94d25 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/adc128d818.txt @@ -0,0 +1,38 @@ +TI ADC128D818 ADC System Monitor With Temperature Sensor +-------------------------------------------------------- + +Operation modes: + + - Mode 0: 7 single-ended voltage readings (IN0-IN6), + 1 temperature reading (internal) + - Mode 1: 8 single-ended voltage readings (IN0-IN7), + no temperature + - Mode 2: 4 pseudo-differential voltage readings + (IN0-IN1, IN3-IN2, IN4-IN5, IN7-IN6), + 1 temperature reading (internal) + - Mode 3: 4 single-ended voltage readings (IN0-IN3), + 2 pseudo-differential voltage readings + (IN4-IN5, IN7-IN6), + 1 temperature reading (internal) + +If no operation mode is configured via device tree, the driver keeps the +currently active chip operation mode (default is mode 0). + + +Required node properties: + + - compatible: must be set to "ti,adc128d818" + - reg: I2C address of the device + +Optional node properties: + + - ti,mode: Operation mode (see above). + + +Example (operation mode 2): + + adc128d818@1d { + compatible = "ti,adc128d818"; + reg = <0x1d>; + ti,mode = <2>; + }; -- cgit v1.2.3 From 68f0c8c923951eef2cde1d9ab6bc598aceecfc27 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Sat, 21 Jan 2017 11:20:10 -0800 Subject: hwmon: (lm70) Add support for TI TMP122/124 Add support for Texas Instruments TMP122/124 which are nearly identical to their TMP121/123 except that they also support programmable temperature thresholds. Signed-off-by: Florian Fainelli Signed-off-by: Guenter Roeck --- Documentation/devicetree/bindings/hwmon/lm70.txt | 1 + Documentation/hwmon/lm70 | 8 ++++++-- drivers/hwmon/lm70.c | 9 ++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/hwmon/lm70.txt b/Documentation/devicetree/bindings/hwmon/lm70.txt index e7fd921aa4f1..ea417a0d32af 100644 --- a/Documentation/devicetree/bindings/hwmon/lm70.txt +++ b/Documentation/devicetree/bindings/hwmon/lm70.txt @@ -4,6 +4,7 @@ Required properties: - compatible: one of "ti,lm70" "ti,tmp121" + "ti,tmp122" "ti,lm71" "ti,lm74" diff --git a/Documentation/hwmon/lm70 b/Documentation/hwmon/lm70 index 1bb2db440671..c3a1f2ea017d 100644 --- a/Documentation/hwmon/lm70 +++ b/Documentation/hwmon/lm70 @@ -6,6 +6,8 @@ Supported chips: Datasheet: http://www.national.com/pf/LM/LM70.html * Texas Instruments TMP121/TMP123 Information: http://focus.ti.com/docs/prod/folders/print/tmp121.html + * Texas Instruments TMP122/TMP124 + Information: http://www.ti.com/product/tmp122 * National Semiconductor LM71 Datasheet: http://www.ti.com/product/LM71 * National Semiconductor LM74 @@ -35,8 +37,10 @@ As a real (in-tree) example of this "SPI protocol driver" interfacing with a "SPI master controller driver", see drivers/spi/spi_lm70llp.c and its associated documentation. -The LM74 and TMP121/TMP123 are very similar; main difference is 13-bit -temperature data (0.0625 degrees celsius resolution). +The LM74 and TMP121/TMP122/TMP123/TMP124 are very similar; main difference is +13-bit temperature data (0.0625 degrees celsius resolution). + +The TMP122/TMP124 also feature configurable temperature thresholds. The LM71 is also very similar; main difference is 14-bit temperature data (0.03125 degrees celsius resolution). diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c index 52c5cdd00448..543556dc563b 100644 --- a/drivers/hwmon/lm70.c +++ b/drivers/hwmon/lm70.c @@ -46,6 +46,7 @@ #define LM70_CHIP_TMP121 1 /* TI TMP121/TMP123 */ #define LM70_CHIP_LM71 2 /* NS LM71 */ #define LM70_CHIP_LM74 3 /* NS LM74 */ +#define LM70_CHIP_TMP122 4 /* TI TMP122/TMP124 */ struct lm70 { struct spi_device *spi; @@ -92,7 +93,7 @@ static ssize_t temp1_input_show(struct device *dev, * Celsius. * So it's equivalent to multiplying by 0.25 * 1000 = 250. * - * LM74 and TMP121/TMP123: + * LM74 and TMP121/TMP122/TMP123/TMP124: * 13 bits of 2's complement data, discard LSB 3 bits, * resolution 0.0625 degrees celsius. * @@ -106,6 +107,7 @@ static ssize_t temp1_input_show(struct device *dev, break; case LM70_CHIP_TMP121: + case LM70_CHIP_TMP122: case LM70_CHIP_LM74: val = ((int)raw / 8) * 625 / 10; break; @@ -142,6 +144,10 @@ static const struct of_device_id lm70_of_ids[] = { .compatible = "ti,tmp121", .data = (void *) LM70_CHIP_TMP121, }, + { + .compatible = "ti,tmp122", + .data = (void *) LM70_CHIP_TMP122, + }, { .compatible = "ti,lm71", .data = (void *) LM70_CHIP_LM71, @@ -191,6 +197,7 @@ static int lm70_probe(struct spi_device *spi) static const struct spi_device_id lm70_ids[] = { { "lm70", LM70_CHIP_LM70 }, { "tmp121", LM70_CHIP_TMP121 }, + { "tmp122", LM70_CHIP_TMP122 }, { "lm71", LM70_CHIP_LM71 }, { "lm74", LM70_CHIP_LM74 }, { }, -- cgit v1.2.3 From f172841573c41428b422b541bd5f50af0144c330 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Tue, 24 Jan 2017 20:24:36 -0800 Subject: hwmon: Update documentation to clarify rules for the 'name' attribute Clarify that the name attribute must report a valid name, and the rules for valid names. Also clarify that the name parameter must be provided for all supported API functions. Reviewed-by: Jean Delvare Signed-off-by: Guenter Roeck --- Documentation/hwmon/hwmon-kernel-api.txt | 4 ++++ Documentation/hwmon/sysfs-interface | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'Documentation') diff --git a/Documentation/hwmon/hwmon-kernel-api.txt b/Documentation/hwmon/hwmon-kernel-api.txt index 2505ae67e2b6..53a806696c64 100644 --- a/Documentation/hwmon/hwmon-kernel-api.txt +++ b/Documentation/hwmon/hwmon-kernel-api.txt @@ -89,6 +89,10 @@ the call to devm_hwmon_device_register_with_groups or hwmon_device_register_with_info and if the automatic (device managed) removal would be too late. +All supported hwmon device registration functions only accept valid device +names. Device names including invalid characters (whitespace, '*', or '-') +will be rejected. The 'name' parameter is mandatory. + Using devm_hwmon_device_register_with_info() -------------------------------------------- diff --git a/Documentation/hwmon/sysfs-interface b/Documentation/hwmon/sysfs-interface index 2cc95ad46604..fc337c317c67 100644 --- a/Documentation/hwmon/sysfs-interface +++ b/Documentation/hwmon/sysfs-interface @@ -86,8 +86,9 @@ given driver if the chip has the feature. name The chip name. This should be a short, lowercase string, not containing - spaces nor dashes, representing the chip name. This is - the only mandatory attribute. + whitespace, dashes, or the wildcard character '*'. + This attribute represents the chip name. It is the only + mandatory attribute. I2C devices get this attribute created automatically. RO -- cgit v1.2.3 From 646933284e46bcb1476907a2e1fe5125f30e3415 Mon Sep 17 00:00:00 2001 From: "andrea.merello" Date: Thu, 2 Feb 2017 08:44:04 +0100 Subject: DT: add binding documentation for STTS751 Signed-off-by: Andrea Merello Signed-off-by: Guenter Roeck --- Documentation/devicetree/bindings/hwmon/stts751.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/stts751.txt (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/hwmon/stts751.txt b/Documentation/devicetree/bindings/hwmon/stts751.txt new file mode 100644 index 000000000000..3ee1dc30e72f --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/stts751.txt @@ -0,0 +1,15 @@ +* STTS751 thermometer. + +Required node properties: +- compatible: "stts751" +- reg: I2C bus address of the device + +Optional properties: +- smbus-timeout-disable: when set, the smbus timeout function will be disabled + +Example stts751 node: + +temp-sensor { + compatible = "stts751"; + reg = <0x48>; +} -- cgit v1.2.3 From 87d08b11b1616cbc70c28c9d3601bd1a3642bae5 Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Fri, 10 Feb 2017 17:12:29 +0100 Subject: devicetree: add lm90 thermal_zone sensor support This patch updates the LM90's devicetree definition to include the #thermal-sensor-cells property as well as the sensor constants in include/dt-bindings/thermal/lm90.h. Cc: Wei Ni Acked-by: Rob Herring Signed-off-by: Christian Lamparter Signed-off-by: Guenter Roeck --- Documentation/devicetree/bindings/hwmon/lm90.txt | 6 ++++++ MAINTAINERS | 1 + include/dt-bindings/thermal/lm90.h | 12 ++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 include/dt-bindings/thermal/lm90.h (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/hwmon/lm90.txt b/Documentation/devicetree/bindings/hwmon/lm90.txt index e8632486b9ef..97581266e329 100644 --- a/Documentation/devicetree/bindings/hwmon/lm90.txt +++ b/Documentation/devicetree/bindings/hwmon/lm90.txt @@ -33,6 +33,11 @@ Optional properties: LM90 "-ALERT" pin output. See interrupt-controller/interrupts.txt for the format. +- #thermal-sensor-cells: should be set to 1. See thermal/thermal.txt for + details. See for the + definition of the local, remote and 2nd remote sensor index + constants. + Example LM90 node: temp-sensor { @@ -41,4 +46,5 @@ temp-sensor { vcc-supply = <&palmas_ldo6_reg>; interrupt-parent = <&gpio>; interrupts = ; + #thermal-sensor-cells = <1>; } diff --git a/MAINTAINERS b/MAINTAINERS index cfff2c9e3d94..ad5bfb441dec 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7527,6 +7527,7 @@ S: Maintained F: Documentation/hwmon/lm90 F: Documentation/devicetree/bindings/hwmon/lm90.txt F: drivers/hwmon/lm90.c +F: include/dt-bindings/thermal/lm90.h LM95234 HARDWARE MONITOR DRIVER M: Guenter Roeck diff --git a/include/dt-bindings/thermal/lm90.h b/include/dt-bindings/thermal/lm90.h new file mode 100644 index 000000000000..8c2e3095f704 --- /dev/null +++ b/include/dt-bindings/thermal/lm90.h @@ -0,0 +1,12 @@ +/* + * This header provides constants for the LM90 thermal bindings. + */ + +#ifndef _DT_BINDINGS_THERMAL_LM90_H_ +#define _DT_BINDINGS_THERMAL_LM90_H_ + +#define LM90_LOCAL_TEMPERATURE 0 +#define LM90_REMOTE_TEMPERATURE 1 +#define LM90_REMOTE2_TEMPERATURE 2 + +#endif -- cgit v1.2.3 From 2f1736ff0664937636f8c0a4994c4a5a23da2090 Mon Sep 17 00:00:00 2001 From: Marco Franchi Date: Thu, 16 Feb 2017 10:23:43 -0200 Subject: hwmon: (sht15) Add device tree support Allow the driver to work with device tree support. Based on initial patch submission from Peter Fox. Tested on a imx7d-sdb board connected to a SHT15 board via Mikro Bus. Signed-off-by: Marco Franchi Reviewed-by: Fabio Estevam Signed-off-by: Guenter Roeck --- Documentation/devicetree/bindings/hwmon/sht15.txt | 19 +++++++ drivers/hwmon/sht15.c | 64 +++++++++++++++++++++-- 2 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/hwmon/sht15.txt (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/hwmon/sht15.txt b/Documentation/devicetree/bindings/hwmon/sht15.txt new file mode 100644 index 000000000000..6a80277cc426 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/sht15.txt @@ -0,0 +1,19 @@ +Sensirion SHT15 Humidity and Temperature Sensor + +Required properties: + + - "compatible": must be "sensirion,sht15". + - "data-gpios": GPIO connected to the data line. + - "clk-gpios": GPIO connected to the clock line. + - "vcc-supply": regulator that drives the VCC pin. + +Example: + + sensor { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_sensor>; + compatible = "sensirion,sht15"; + clk-gpios = <&gpio4 12 0>; + data-gpios = <&gpio4 13 0>; + vcc-supply = <®_sht15>; + }; diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c index f16687c64fc8..e4d642b673c6 100644 --- a/drivers/hwmon/sht15.c +++ b/drivers/hwmon/sht15.c @@ -34,6 +34,7 @@ #include #include #include +#include /* Commands */ #define SHT15_MEASURE_TEMP 0x03 @@ -911,6 +912,54 @@ static int sht15_invalidate_voltage(struct notifier_block *nb, return NOTIFY_OK; } +#ifdef CONFIG_OF +static const struct of_device_id sht15_dt_match[] = { + { .compatible = "sensirion,sht15" }, + { }, +}; +MODULE_DEVICE_TABLE(of, sht15_dt_match); + +/* + * This function returns NULL if pdev isn't a device instatiated by dt, + * a pointer to pdata if it could successfully get all information + * from dt or a negative ERR_PTR() on error. + */ +static struct sht15_platform_data *sht15_probe_dt(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct sht15_platform_data *pdata; + + /* no device tree device */ + if (!np) + return NULL; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + pdata->gpio_data = of_get_named_gpio(np, "data-gpios", 0); + if (pdata->gpio_data < 0) { + if (pdata->gpio_data != -EPROBE_DEFER) + dev_err(dev, "data-gpios not found\n"); + return ERR_PTR(pdata->gpio_data); + } + + pdata->gpio_sck = of_get_named_gpio(np, "clk-gpios", 0); + if (pdata->gpio_sck < 0) { + if (pdata->gpio_sck != -EPROBE_DEFER) + dev_err(dev, "clk-gpios not found\n"); + return ERR_PTR(pdata->gpio_sck); + } + + return pdata; +} +#else +static inline struct sht15_platform_data *sht15_probe_dt(struct device *dev) +{ + return NULL; +} +#endif + static int sht15_probe(struct platform_device *pdev) { int ret; @@ -928,11 +977,17 @@ static int sht15_probe(struct platform_device *pdev) data->dev = &pdev->dev; init_waitqueue_head(&data->wait_queue); - if (dev_get_platdata(&pdev->dev) == NULL) { - dev_err(&pdev->dev, "no platform data supplied\n"); - return -EINVAL; + data->pdata = sht15_probe_dt(&pdev->dev); + if (IS_ERR(data->pdata)) + return PTR_ERR(data->pdata); + if (data->pdata == NULL) { + data->pdata = dev_get_platdata(&pdev->dev); + if (data->pdata == NULL) { + dev_err(&pdev->dev, "no platform data supplied\n"); + return -EINVAL; + } } - data->pdata = dev_get_platdata(&pdev->dev); + data->supply_uv = data->pdata->supply_mv * 1000; if (data->pdata->checksum) data->checksumming = true; @@ -1075,6 +1130,7 @@ MODULE_DEVICE_TABLE(platform, sht15_device_ids); static struct platform_driver sht15_driver = { .driver = { .name = "sht15", + .of_match_table = of_match_ptr(sht15_dt_match), }, .probe = sht15_probe, .remove = sht15_remove, -- cgit v1.2.3