Page MenuHomeFreeBSD

TMP461: Add thermal sensor driver

Authored by on Nov 3 2021, 11:57 AM.
Referenced Files
Thu, Jun 20, 6:17 PM
Unknown Object (File)
Wed, Jun 19, 2:32 PM
Unknown Object (File)
Wed, Jun 19, 12:38 PM
Unknown Object (File)
Sat, Jun 15, 11:23 AM
Unknown Object (File)
Sat, Jun 15, 11:02 AM
Unknown Object (File)
Sat, Jun 15, 10:23 AM
Unknown Object (File)
Wed, May 29, 10:10 PM
Unknown Object (File)
Thu, May 23, 5:10 PM



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

rG FreeBSD src repository
Lint Not Applicable
Tests Not Applicable

Event Timeline added inline comments.

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.
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.