-
Notifications
You must be signed in to change notification settings - Fork 905
add max31732 driver #2959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add max31732 driver #2959
Conversation
Add support for Analog Devices MAX31732, a five-channel temperature monitor with per-channel alarms, calibration helpers, optional IRQ handling, and MTP configuration. Signed-off-by: Sinan Divarci <sinan.divarci@analog.com>
Add documentation for the Analog Devices MAX31732 temperature sensor driver under Documentation/hwmon. Signed-off-by: Sinan Divarci <sinan.divarci@analog.com>
Add device tree bindings for the Analog Devices MAX31732 temperature sensor driver under Documentation/devicetree/bindings/hwmon/. Signed-off-by: Sinan Divarci <sinan.divarci@analog.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Sinan,
Just a first high level review. We first need to have this driver using modern hwmon API and have the userspace interface figured.
Also note that the expectation is for this to be first upstreamed (and accepted) before merging it in our tree
|
||
* All temperatures reported via sysfs are in milli-degree Celsius. | ||
* ``stop`` halts conversions but does not power-cycle the part; use ``soft_por`` | ||
to restore all the registers to their default values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this patch can typically be squashed with the one adding the driver
static const struct attribute_group mtp_attr_group = { | ||
.name = "mtp", | ||
.attrs = mtp_attrs, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above needs to be re-thought. The above is not the way to expose the hwmon interface. The below is what you need to be using (an example):
https://elixir.bootlin.com/linux/v6.17/source/drivers/hwmon/ltc4282.c#L1563
Then you need to look at the standard hwmon ABI:
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface
and try to map as much as you can. The reason is that you'll have to justify very carefully why you need some non standard interface to be exposed to userspace. Often we don't really need to expose everything.
s32 ret; | ||
u32 alarm_que; | ||
|
||
if (fwnode_property_read_bool(dev_fwnode(dev), "adi,alarm1-interrupt-mode")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just as an hint for future versions of the patches you have device_property_read_bool(dev, ...). So no need for all of those dev_fwnode()
|
||
ret = devm_device_add_group(dev, &mtp_attr_group); | ||
if (ret) | ||
return dev_err_probe(dev, ret, "failed to create mtp sysfs group\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not how you should be adding attr groups. Needs to be done through the hwmon API (when registering the device)
if (reg_val == 0) | ||
ret = regmap_set_bits(data->regmap, MAX31732_REG_CONF1, MAX31732_CONF1_STOP); | ||
else | ||
ret = regmap_clear_bits(data->regmap, MAX31732_REG_CONF1, MAX31732_CONF1_STOP); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the above you can use regmap_update_bits()
}; | ||
|
||
MODULE_DEVICE_TABLE(i2c, max31732_ids); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
{ .compatible = "adi,max31732", }, | ||
{ }, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
.class = I2C_CLASS_HWMON, | ||
.driver = { | ||
.name = "max31732-driver", | ||
.of_match_table = of_match_ptr(max31732_of_match), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop of_match_ptr()
.driver = { | ||
.name = "max31732-driver", | ||
.of_match_table = of_match_ptr(max31732_of_match), | ||
.pm = &max31732_pm_ops, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use pm_sleep_ptr() together with DEFINE_SIMPLE_DEV_PM_OPS() and then no need of __maybe_unused
MODULE_DESCRIPTION("MAX31732 driver"); | ||
MODULE_LICENSE("GPL"); | ||
MODULE_VERSION("1.0"); | ||
MODULE_SOFTDEP("pre: regmap_i2c"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typically we dont really use the above two but I guess it does not harm
PR Description
Add MAX31732 hwmod driver and documentation.
PR Type
PR Checklist