Page MenuHomeFreeBSD

TMP461: Add thermal sensor driver
ClosedPublic

Authored by hum_semihalf.com on Nov 3 2021, 11:57 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 22, 4:44 PM
Unknown Object (File)
Fri, Apr 19, 6:20 PM
Unknown Object (File)
Wed, Apr 17, 7:52 AM
Unknown Object (File)
Sat, Apr 6, 6:25 PM
Unknown Object (File)
Feb 24 2024, 5:58 AM
Unknown Object (File)
Feb 16 2024, 5:10 PM
Unknown Object (File)
Jan 24 2024, 11:37 PM
Unknown Object (File)
Dec 13 2023, 8:43 AM

Details

Summary

Add driver for TMP461 thermal sensor. Register new sysctl node
of integer type for device. Read register and fill sysctl with
valid temperature.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

contact_artur-rojek.eu added inline comments.
sys/dev/iicbus/tmp461.c
194

This is a good opportunity to create a system global helper for integer sign extend, instead of creating yet another duplicate local implementation.
As per discussion on #freebsd-dev, sys/sys/libkern.h seems like an appropriate place for such a helper.

As discussed on IRC, I propose that such a helper should have three arguments:

  • the bitfield to extract from (32/64 bit?)
  • the index of the least significant bit of the field to extract
  • the number of bits in the field.

This roughly corresponds to the sbfx and ufbx instructions on ARM and is as flexible as needed. Both signed and unsigned versions should be provided.

Maybe a corresponding narrowing/insertion function (corresponding to the bfi instruction) would be nice, too.

Move signed -> unsigned helper function to libkern.h.

@hum_semihalf.com
What Robert has in mind is something more akin to this (I allowed myself to replace the number of bits with an index to the most significant bit):

static __inline int32_t
signed_extend32(uint32_t bitmap, int msb, int lsb)
{

	return ((int32_t)(bitmap << (31 - msb)) >> (31 - msb + lsb));
}

This way we cover situations where the embedded value does not start at the beginning of the bit field.
Please also provide the remaining versions of those helpers.
On another note, these should go into a separate commit.

Remove conversion helper function, as it is separate commit.

This revision was not accepted when it landed; it landed in state Needs Review.Dec 2 2021, 9:00 AM
This revision was automatically updated to reflect the committed changes.