Merge tag 'hwmon-for-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon updates from Guenter Roeck:
 "New drivers:

   - Renesas HS3001

  Chip support added to existing drivers:

   - pmbus/mp2975 driver now supports MP2971 and MP2973

  Functional improvements:

   - Additional voltage and temperature sensor support for
     NCT6798/NCT6799 in nt6755 driver

   - it87 driver now detects AMDTSI sensor type

   - dimmtemp now supports more than 32 DIMMs

  Driver removals:

   - sm665 driver removed as unsupportable and long since obsolete

  .. and minor fixes, cleanups, and simplifications in several drivers"

* tag 'hwmon-for-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (57 commits)
  hwmon: (tmp513) Simplify probe()
  hwmon: (tmp513) Fix the channel number in tmp51x_is_visible()
  hwmon: (mlxreg-fan) Extend number of supported fans
  hwmon: (sis5595) Do PCI error checks on own line
  hwmon: (vt8231) Do PCI error checks on own line
  hwmon: (via686a) Do PCI error checks on own line
  hwmon: pmbus: Fix -EIO seen on pli1209
  hwmon: pmbus: Drop unnecessary clear fault page
  hwmon: pmbus: Reduce clear fault page invocations
  hwmon: (nsa320-hwmon) Remove redundant of_match_ptr()
  hwmon: (pmbus/ucd9200) fix Wvoid-pointer-to-enum-cast warning
  hwmon: (pmbus/ucd9000) fix Wvoid-pointer-to-enum-cast warning
  hwmon: (pmbus/tps53679) fix Wvoid-pointer-to-enum-cast warning
  hwmon: (pmbus/ibm-cffps) fix Wvoid-pointer-to-enum-cast warning
  hwmon: (tmp513) fix Wvoid-pointer-to-enum-cast warning
  hwmon: (max6697) fix Wvoid-pointer-to-enum-cast warning
  hwmon: (max20730) fix Wvoid-pointer-to-enum-cast warning
  hwmon: (lm90) fix Wvoid-pointer-to-enum-cast warning
  hwmon: (lm85) fix Wvoid-pointer-to-enum-cast warning
  hwmon: (lm75) fix Wvoid-pointer-to-enum-cast warning
  ...
This commit is contained in:
Linus Torvalds
2023-08-29 10:02:35 -07:00
70 changed files with 1452 additions and 1498 deletions
@@ -119,6 +119,10 @@ properties:
- fsl,mpr121
# Monolithic Power Systems Inc. multi-phase controller mp2888
- mps,mp2888
# Monolithic Power Systems Inc. multi-phase controller mp2971
- mps,mp2971
# Monolithic Power Systems Inc. multi-phase controller mp2973
- mps,mp2973
# Monolithic Power Systems Inc. multi-phase controller mp2975
- mps,mp2975
# Honeywell Humidicon HIH-6130 humidity/temperature sensor
@@ -315,6 +319,8 @@ properties:
- plx,pex8648
# Pulsedlight LIDAR range-finding sensor
- pulsedlight,lidar-lite-v2
# Renesas HS3001 Temperature and Relative Humidity Sensors
- renesas,hs3001
# Renesas ISL29501 time-of-flight sensor
- renesas,isl29501
# Rohm DH2228FV
+37
View File
@@ -0,0 +1,37 @@
.. SPDX-License-Identifier: GPL-2.0-or-later
Kernel driver HS3001
====================
Supported chips:
* Renesas HS3001, HS3002, HS3003, HS3004
Prefix: 'hs3001'
Addresses scanned: -
Datasheet: https://www.renesas.com/us/en/document/dst/hs300x-datasheet?r=417401
Author:
- Andre Werner <andre.werner@systec-electronic.com>
Description
-----------
This driver implements support for the Renesas HS3001 chips, a humidity
and temperature family. Temperature is measured in degrees celsius, relative
humidity is expressed as a percentage. In the sysfs interface, all values are
scaled by 1000, i.e. the value for 31.5 degrees celsius is 31500.
The device communicates with the I2C protocol. Sensors have the I2C
address 0x44 by default.
sysfs-Interface
---------------
=================== =================
temp1_input: temperature input
humidity1_input: humidity input
=================== =================
+1 -1
View File
@@ -78,6 +78,7 @@ Hardware Monitoring Kernel Drivers
gxp-fan-ctrl
hih6130
hp-wmi-sensors
hs3001
ibmaem
ibm-cffps
ibmpowernv
@@ -195,7 +196,6 @@ Hardware Monitoring Kernel Drivers
shtc1
sis5595
sl28cpld
smm665
smpro-hwmon
smsc47b397
smsc47m192
+10 -1
View File
@@ -80,7 +80,13 @@ Supported chips:
Datasheet: Available from Nuvoton upon request
* Nuvoton NCT6796D-S/NCT6799D-R
Prefix: 'nct6799'
Addresses scanned: ISA address retrieved from Super I/O registers
Datasheet: Available from Nuvoton upon request
Authors:
@@ -277,4 +283,7 @@ will not reflect a usable value. It often reports unreasonably high
temperatures, and in some cases the reported temperature declines if the actual
temperature increases (similar to the raw PECI temperature value - see PECI
specification for details). CPUTIN should therefore be ignored on ASUS
boards. The CPU temperature on ASUS boards is reported from PECI 0.
boards. The CPU temperature on ASUS boards is reported from PECI 0 or TSI 0.
NCT6796D-S and NCT6799D-R chips are very similar and their chip_id indicates
they are different versions. This driver treats them the same way.
+1 -1
View File
@@ -163,7 +163,7 @@ Emerson DS1200 power modules might look as follows::
.driver = {
.name = "ds1200",
},
.probe_new = ds1200_probe,
.probe = ds1200_probe,
.id_table = ds1200_id,
};
-187
View File
@@ -1,187 +0,0 @@
Kernel driver smm665
====================
Supported chips:
* Summit Microelectronics SMM465
Prefix: 'smm465'
Addresses scanned: -
Datasheet:
http://www.summitmicro.com/prod_select/summary/SMM465/SMM465DS.pdf
* Summit Microelectronics SMM665, SMM665B
Prefix: 'smm665'
Addresses scanned: -
Datasheet:
http://www.summitmicro.com/prod_select/summary/SMM665/SMM665B_2089_20.pdf
* Summit Microelectronics SMM665C
Prefix: 'smm665c'
Addresses scanned: -
Datasheet:
http://www.summitmicro.com/prod_select/summary/SMM665C/SMM665C_2125.pdf
* Summit Microelectronics SMM764
Prefix: 'smm764'
Addresses scanned: -
Datasheet:
http://www.summitmicro.com/prod_select/summary/SMM764/SMM764_2098.pdf
* Summit Microelectronics SMM766, SMM766B
Prefix: 'smm766'
Addresses scanned: -
Datasheets:
http://www.summitmicro.com/prod_select/summary/SMM766/SMM766_2086.pdf
http://www.summitmicro.com/prod_select/summary/SMM766B/SMM766B_2122.pdf
Author: Guenter Roeck <linux@roeck-us.net>
Module Parameters
-----------------
* vref: int
Default: 1250 (mV)
Reference voltage on VREF_ADC pin in mV. It should not be necessary to set
this parameter unless a non-default reference voltage is used.
Description
-----------
[From datasheet] The SMM665 is an Active DC Output power supply Controller
that monitors, margins and cascade sequences power. The part monitors six
power supply channels as well as VDD, 12V input, two general-purpose analog
inputs and an internal temperature sensor using a 10-bit ADC.
Each monitored channel has its own high and low limits, plus a critical
limit.
Support for SMM465, SMM764, and SMM766 has been implemented but is untested.
Usage Notes
-----------
This driver does not probe for devices, since there is no register which
can be safely used to identify the chip. You will have to instantiate
the devices explicitly. When instantiating the device, you have to specify
its configuration register address.
Example: the following will load the driver for an SMM665 at address 0x57
on I2C bus #1::
$ modprobe smm665
$ echo smm665 0x57 > /sys/bus/i2c/devices/i2c-1/new_device
Sysfs entries
-------------
This driver uses the values in the datasheet to convert ADC register values
into the values specified in the sysfs-interface document. All attributes are
read only.
Min, max, lcrit, and crit values are used by the chip to trigger external signals
and/or other activity. Triggered signals can include HEALTHY, RST, Power Off,
or Fault depending on the chip configuration. The driver reports values as lcrit
or crit if exceeding the limits triggers RST, Power Off, or Fault, and as min or
max otherwise. For details please see the SMM665 datasheet.
For SMM465 and SMM764, values for Channel E and F are reported but undefined.
======================= =======================================================
in1_input 12V input voltage (mV)
in2_input 3.3V (VDD) input voltage (mV)
in3_input Channel A voltage (mV)
in4_input Channel B voltage (mV)
in5_input Channel C voltage (mV)
in6_input Channel D voltage (mV)
in7_input Channel E voltage (mV)
in8_input Channel F voltage (mV)
in9_input AIN1 voltage (mV)
in10_input AIN2 voltage (mV)
in1_min 12v input minimum voltage (mV)
in2_min 3.3V (VDD) input minimum voltage (mV)
in3_min Channel A minimum voltage (mV)
in4_min Channel B minimum voltage (mV)
in5_min Channel C minimum voltage (mV)
in6_min Channel D minimum voltage (mV)
in7_min Channel E minimum voltage (mV)
in8_min Channel F minimum voltage (mV)
in9_min AIN1 minimum voltage (mV)
in10_min AIN2 minimum voltage (mV)
in1_max 12v input maximum voltage (mV)
in2_max 3.3V (VDD) input maximum voltage (mV)
in3_max Channel A maximum voltage (mV)
in4_max Channel B maximum voltage (mV)
in5_max Channel C maximum voltage (mV)
in6_max Channel D maximum voltage (mV)
in7_max Channel E maximum voltage (mV)
in8_max Channel F maximum voltage (mV)
in9_max AIN1 maximum voltage (mV)
in10_max AIN2 maximum voltage (mV)
in1_lcrit 12v input critical minimum voltage (mV)
in2_lcrit 3.3V (VDD) input critical minimum voltage (mV)
in3_lcrit Channel A critical minimum voltage (mV)
in4_lcrit Channel B critical minimum voltage (mV)
in5_lcrit Channel C critical minimum voltage (mV)
in6_lcrit Channel D critical minimum voltage (mV)
in7_lcrit Channel E critical minimum voltage (mV)
in8_lcrit Channel F critical minimum voltage (mV)
in9_lcrit AIN1 critical minimum voltage (mV)
in10_lcrit AIN2 critical minimum voltage (mV)
in1_crit 12v input critical maximum voltage (mV)
in2_crit 3.3V (VDD) input critical maximum voltage (mV)
in3_crit Channel A critical maximum voltage (mV)
in4_crit Channel B critical maximum voltage (mV)
in5_crit Channel C critical maximum voltage (mV)
in6_crit Channel D critical maximum voltage (mV)
in7_crit Channel E critical maximum voltage (mV)
in8_crit Channel F critical maximum voltage (mV)
in9_crit AIN1 critical maximum voltage (mV)
in10_crit AIN2 critical maximum voltage (mV)
in1_crit_alarm 12v input critical alarm
in2_crit_alarm 3.3V (VDD) input critical alarm
in3_crit_alarm Channel A critical alarm
in4_crit_alarm Channel B critical alarm
in5_crit_alarm Channel C critical alarm
in6_crit_alarm Channel D critical alarm
in7_crit_alarm Channel E critical alarm
in8_crit_alarm Channel F critical alarm
in9_crit_alarm AIN1 critical alarm
in10_crit_alarm AIN2 critical alarm
temp1_input Chip temperature
temp1_min Minimum chip temperature
temp1_max Maximum chip temperature
temp1_crit Critical chip temperature
temp1_crit_alarm Temperature critical alarm
======================= =======================================================
+6 -7
View File
@@ -9509,6 +9509,12 @@ S: Maintained
W: http://artax.karlin.mff.cuni.cz/~mikulas/vyplody/hpfs/index-e.cgi
F: fs/hpfs/
HS3001 Hardware Temperature and Humidity Sensor
M: Andre Werner <andre.werner@systec-electronic.com>
L: linux-hwmon@vger.kernel.org
S: Maintained
F: drivers/hwmon/hs3001.c
HSI SUBSYSTEM
M: Sebastian Reichel <sre@kernel.org>
S: Maintained
@@ -19625,13 +19631,6 @@ M: Nicolas Pitre <nico@fluxnic.net>
S: Odd Fixes
F: drivers/net/ethernet/smsc/smc91x.*
SMM665 HARDWARE MONITOR DRIVER
M: Guenter Roeck <linux@roeck-us.net>
L: linux-hwmon@vger.kernel.org
S: Maintained
F: Documentation/hwmon/smm665.rst
F: drivers/hwmon/smm665.c
SMSC EMC2103 HARDWARE MONITOR DRIVER
M: Steve Glendinning <steve.glendinning@shawell.net>
L: linux-hwmon@vger.kernel.org
+10 -14
View File
@@ -734,6 +734,16 @@ config SENSORS_HIH6130
This driver can also be built as a module. If so, the module
will be called hih6130.
config SENSORS_HS3001
tristate "Renesas HS3001 humidity and temperature sensors"
depends on I2C
help
If you say yes here you get support for the Renesas HS3001,
to HS3004 humidity and temperature sensors.
This driver can also be built as a module. If so, the module
will be called hs3001.
config SENSORS_IBMAEM
tristate "IBM Active Energy Manager temperature/power sensors and control"
select IPMI_SI
@@ -1951,20 +1961,6 @@ config SENSORS_SFCTEMP
This driver can also be built as a module. If so, the module
will be called sfctemp.
config SENSORS_SMM665
tristate "Summit Microelectronics SMM665"
depends on I2C
help
If you say yes here you get support for the hardware monitoring
features of the Summit Microelectronics SMM665/SMM665B Six-Channel
Active DC Output Controller / Monitor.
Other supported chips are SMM465, SMM665C, SMM764, and SMM766.
Support for those chips is untested.
This driver can also be built as a module. If so, the module will
be called smm665.
config SENSORS_ADC128D818
tristate "Texas Instruments ADC128D818"
depends on I2C
+1 -1
View File
@@ -86,6 +86,7 @@ obj-$(CONFIG_SENSORS_GSC) += gsc-hwmon.o
obj-$(CONFIG_SENSORS_GPIO_FAN) += gpio-fan.o
obj-$(CONFIG_SENSORS_GXP_FAN_CTRL) += gxp-fan-ctrl.o
obj-$(CONFIG_SENSORS_HIH6130) += hih6130.o
obj-$(CONFIG_SENSORS_HS3001) += hs3001.o
obj-$(CONFIG_SENSORS_ULTRA45) += ultra45_env.o
obj-$(CONFIG_SENSORS_I5500) += i5500_temp.o
obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o
@@ -191,7 +192,6 @@ obj-$(CONFIG_SENSORS_SHT3x) += sht3x.o
obj-$(CONFIG_SENSORS_SHT4x) += sht4x.o
obj-$(CONFIG_SENSORS_SHTC1) += shtc1.o
obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o
obj-$(CONFIG_SENSORS_SMM665) += smm665.o
obj-$(CONFIG_SENSORS_SMPRO) += smpro-hwmon.o
obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
+2 -2
View File
@@ -16,7 +16,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/delay.h>
#include <linux/slab.h>
@@ -253,7 +253,7 @@ static int ad7418_probe(struct i2c_client *client)
mutex_init(&data->lock);
data->client = client;
if (dev->of_node)
data->type = (enum chips)of_device_get_match_data(dev);
data->type = (uintptr_t)of_device_get_match_data(dev);
else
data->type = i2c_match_id(ad7418_id, client)->driver_data;
+2 -3
View File
@@ -18,7 +18,7 @@
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/platform_data/ads7828.h>
#include <linux/regmap.h>
#include <linux/slab.h>
@@ -139,8 +139,7 @@ static int ads7828_probe(struct i2c_client *client)
}
if (client->dev.of_node)
chip = (enum ads7828_chips)
of_device_get_match_data(&client->dev);
chip = (uintptr_t)of_device_get_match_data(&client->dev);
else
chip = i2c_match_id(ads7828_device_ids, client)->driver_data;
+1 -2
View File
@@ -10,7 +10,6 @@
*/
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
@@ -1653,7 +1652,7 @@ static int adt7475_probe(struct i2c_client *client)
i2c_set_clientdata(client, data);
if (client->dev.of_node)
chip = (enum chips)of_device_get_match_data(&client->dev);
chip = (uintptr_t)of_device_get_match_data(&client->dev);
else
chip = id->driver_data;
+2 -1
View File
@@ -11,7 +11,8 @@
#include <linux/init.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#define CTRL 0x0
#define PD BIT(0)
+1 -2
View File
@@ -12,8 +12,7 @@
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/reset.h>
+1 -1
View File
@@ -340,7 +340,7 @@ static const struct ec_board_info board_info_crosshair_x670e_hero = {
.sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE |
SENSOR_TEMP_MB | SENSOR_TEMP_VRM |
SENSOR_SET_TEMP_WATER,
.mutex_path = ASUS_HW_ACCESS_MUTEX_RMTW_ASMX,
.mutex_path = ACPI_GLOBAL_LOCK_PSEUDO_PATH,
.family = family_amd_600_series,
};
+1 -8
View File
@@ -891,15 +891,8 @@ static struct pvt_hwmon *pvt_create_data(struct platform_device *pdev)
static int pvt_request_regs(struct pvt_hwmon *pvt)
{
struct platform_device *pdev = to_platform_device(pvt->dev);
struct resource *res;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(pvt->dev, "Couldn't find PVT memresource\n");
return -EINVAL;
}
pvt->regs = devm_ioremap_resource(pvt->dev, res);
pvt->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(pvt->regs))
return PTR_ERR(pvt->regs);
-1
View File
@@ -39,7 +39,6 @@
#include <linux/kernel.h>
#include <linux/clk.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_data/g762.h>
#define DRVNAME "g762"
+1 -1
View File
@@ -6,7 +6,7 @@
#include <linux/hwmon.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#define OFS_FAN_INST 0 /* Is 0 because plreg base will be set at INST */
+4 -18
View File
@@ -435,25 +435,11 @@ static union acpi_object *hp_wmi_get_wobj(const char *guid, u8 instance)
/* hp_wmi_wobj_instance_count - find count of WMI object instances */
static u8 hp_wmi_wobj_instance_count(const char *guid)
{
u8 hi = HP_WMI_MAX_INSTANCES;
union acpi_object *wobj;
u8 lo = 0;
u8 mid;
int count;
while (lo < hi) {
mid = (lo + hi) / 2;
count = wmi_instance_count(guid);
wobj = hp_wmi_get_wobj(guid, mid);
if (!wobj) {
hi = mid;
continue;
}
lo = mid + 1;
kfree(wobj);
}
return lo;
return clamp(count, 0, (int)HP_WMI_MAX_INSTANCES);
}
static int check_wobj(const union acpi_object *wobj,
@@ -1927,7 +1913,7 @@ static bool add_event_handler(struct hp_wmi_sensors *state)
static int hp_wmi_sensors_init(struct hp_wmi_sensors *state)
{
struct hp_wmi_info *connected[HP_WMI_MAX_INSTANCES];
struct hp_wmi_platform_events *pevents;
struct hp_wmi_platform_events *pevents = NULL;
struct device *dev = &state->wdev->dev;
struct hp_wmi_info *info;
struct device *hwdev;
+242
View File
@@ -0,0 +1,242 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* This is a non-complete driver implementation for the
* HS3001 humidity and temperature sensor and compatibles. It does not include
* the configuration possibilities, where it needs to be set to 'programming mode'
* during power-up.
*
*
* Copyright (C) 2023 SYS TEC electronic AG
* Author: Andre Werner <andre.werner@systec-electronic.com>
*/
#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/hwmon.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/slab.h>
#include <linux/types.h>
/* Measurement times */
#define HS3001_WAKEUP_TIME 100 /* us */
#define HS3001_8BIT_RESOLUTION 550 /* us */
#define HS3001_10BIT_RESOLUTION 1310 /* us */
#define HS3001_12BIT_RESOLUTION 4500 /* us */
#define HS3001_14BIT_RESOLUTION 16900 /* us */
#define HS3001_RESPONSE_LENGTH 4
#define HS3001_FIXPOINT_ARITH 1000U
#define HS3001_MASK_HUMIDITY_0X3FFF GENMASK(13, 0)
#define HS3001_MASK_STATUS_0XC0 GENMASK(7, 6)
/* Definitions for Status Bits of A/D Data */
#define HS3001_DATA_VALID 0x00 /* Valid Data */
#define HS3001_DATA_STALE 0x01 /* Stale Data */
struct hs3001_data {
struct i2c_client *client;
struct mutex i2c_lock; /* lock for sending i2c commands */
u32 wait_time; /* in us */
int temperature; /* in milli degree */
u32 humidity; /* in milli % */
};
static int hs3001_extract_temperature(u16 raw)
{
/* fixpoint arithmetic 1 digit */
u32 temp = (raw >> 2) * HS3001_FIXPOINT_ARITH * 165;
temp /= (1 << 14) - 1;
return (int)temp - 40 * HS3001_FIXPOINT_ARITH;
}
static u32 hs3001_extract_humidity(u16 raw)
{
u32 hum = (raw & HS3001_MASK_HUMIDITY_0X3FFF) * HS3001_FIXPOINT_ARITH * 100;
return hum /= (1 << 14) - 1;
}
static int hs3001_data_fetch_command(struct i2c_client *client,
struct hs3001_data *data)
{
int ret;
u8 buf[HS3001_RESPONSE_LENGTH];
u8 hs3001_status;
ret = i2c_master_recv(client, buf, HS3001_RESPONSE_LENGTH);
if (ret != HS3001_RESPONSE_LENGTH) {
ret = ret < 0 ? ret : -EIO;
dev_dbg(&client->dev,
"Error in i2c communication. Error code: %d.\n", ret);
return ret;
}
hs3001_status = FIELD_GET(HS3001_MASK_STATUS_0XC0, buf[0]);
if (hs3001_status == HS3001_DATA_STALE) {
dev_dbg(&client->dev, "Sensor busy.\n");
return -EBUSY;
}
if (hs3001_status != HS3001_DATA_VALID) {
dev_dbg(&client->dev, "Data invalid.\n");
return -EIO;
}
data->humidity =
hs3001_extract_humidity(be16_to_cpup((__be16 *)&buf[0]));
data->temperature =
hs3001_extract_temperature(be16_to_cpup((__be16 *)&buf[2]));
return 0;
}
static umode_t hs3001_is_visible(const void *data, enum hwmon_sensor_types type,
u32 attr, int channel)
{
/* Both, humidity and temperature can only be read. */
return 0444;
}
static int hs3001_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{
struct hs3001_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
int ret;
mutex_lock(&data->i2c_lock);
ret = i2c_master_send(client, NULL, 0);
if (ret < 0) {
mutex_unlock(&data->i2c_lock);
return ret;
}
/*
* Sensor needs some time to process measurement depending on
* resolution (ref. datasheet)
*/
fsleep(data->wait_time);
ret = hs3001_data_fetch_command(client, data);
mutex_unlock(&data->i2c_lock);
if (ret < 0)
return ret;
switch (type) {
case hwmon_temp:
switch (attr) {
case hwmon_temp_input:
*val = data->temperature;
break;
default:
return -EINVAL;
}
break;
case hwmon_humidity:
switch (attr) {
case hwmon_humidity_input:
*val = data->humidity;
break;
default:
return -EINVAL;
}
break;
default:
return -EINVAL;
}
return 0;
}
static const struct hwmon_channel_info *hs3001_info[] = {
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT),
HWMON_CHANNEL_INFO(humidity, HWMON_H_INPUT),
NULL
};
static const struct hwmon_ops hs3001_hwmon_ops = {
.is_visible = hs3001_is_visible,
.read = hs3001_read,
};
static const struct hwmon_chip_info hs3001_chip_info = {
.ops = &hs3001_hwmon_ops,
.info = hs3001_info,
};
/* device ID table */
static const struct i2c_device_id hs3001_ids[] = {
{ "hs3001", 0 },
{ },
};
MODULE_DEVICE_TABLE(i2c, hs3001_ids);
static const struct of_device_id hs3001_of_match[] = {
{.compatible = "renesas,hs3001"},
{ },
};
MODULE_DEVICE_TABLE(of, hs3001_of_match);
static int hs3001_probe(struct i2c_client *client)
{
struct hs3001_data *data;
struct device *hwmon_dev;
struct device *dev = &client->dev;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -EOPNOTSUPP;
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->client = client;
/*
* Measurement time = wake-up time + measurement time temperature
* + measurement time humidity. This is currently static, because
* enabling programming mode is not supported, yet.
*/
data->wait_time = (HS3001_WAKEUP_TIME + HS3001_14BIT_RESOLUTION +
HS3001_14BIT_RESOLUTION);
mutex_init(&data->i2c_lock);
hwmon_dev = devm_hwmon_device_register_with_info(dev,
client->name,
data,
&hs3001_chip_info,
NULL);
if (IS_ERR(hwmon_dev))
return dev_err_probe(dev, PTR_ERR(hwmon_dev),
"Unable to register hwmon device.\n");
return 0;
}
static struct i2c_driver hs3001_i2c_driver = {
.driver = {
.name = "hs3001",
.of_match_table = hs3001_of_match,
},
.probe = hs3001_probe,
.id_table = hs3001_ids,
};
module_i2c_driver(hs3001_i2c_driver);
MODULE_AUTHOR("Andre Werner <andre.werner@systec-electronic.com>");
MODULE_DESCRIPTION("HS3001 humidity and temperature sensor base driver");
MODULE_LICENSE("GPL");

Some files were not shown because too many files have changed in this diff Show More