All of lore.kernel.org
 help / color / mirror / Atom feed
* How do I add a PMBus sensor that will show up in webui Sensors?
@ 2020-07-28 22:52 Mike Jones
  2020-07-28 23:50 ` Milton Miller II
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Jones @ 2020-07-28 22:52 UTC (permalink / raw)
  To: openbmc

I need help configuring a sensor. The goal is for a PMBus Voltage Regulator to display sensor information, like load current, in the webui under Health/Sensors.

Some background:

- Rasp Pi 4
- meta-phosphor 
- bmcweb/webui working and can log in
- pmbus/ltc2978.c driver working
- hwmon working

In this case, we have this path:

/sys/bus/i2c/devices/i2c-1

Which has a new_device file. I can add my sensor with:

echo ltc3880 0x30 > new_device

This populates all the files with telemetry data here:

/sys/bus/i2c/devices/i2c01/1-0030/hwmon/hwmon1

Such as in1_input, in2_input, in3_input, which are VIN, VOUT0, VOUT1.

I assume there has to be a file that maps the path to inN_input to a d-bus object, some way to register the sensor with the chassis or similar concept, and some file with the label and warns, and other things you can do with it.

From a yocto recipe point of view, it would also have to do the equivalent of the “echo” into the new_device so that /sys/… gets populated. Perhaps part of some systemd based service.

I have looked at meta-ibm and see a tree under omjc/hwmon/ahb… i2c-bus@200…

I do not know what these numbers are referring to. Perhaps these are paths in the sys tree for an ahb type architecture? And what is the number before .conf?

Then I see phosphor-hwmon_%.bbappend with more configuration in there.

Can someone explain how this recipe system works? The architecture doc was more than confusing. Perhaps just sketch out what I need to do for this case, and what files it will generate, so I can build and go look at the generated files, etc.

Or perhaps there is a completely different approach?

Mike

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re:  How do I add a PMBus sensor that will show up in webui Sensors?
  2020-07-28 22:52 How do I add a PMBus sensor that will show up in webui Sensors? Mike Jones
@ 2020-07-28 23:50 ` Milton Miller II
  0 siblings, 0 replies; 2+ messages in thread
From: Milton Miller II @ 2020-07-28 23:50 UTC (permalink / raw)
  To: Mike Jones; +Cc: openbmc


On July 28, 2020 aroud 05:53PM in some timezone, Mike Jones wrote:

>I need help configuring a sensor. The goal is for a PMBus Voltage
>Regulator to display sensor information, like load current, in the
>webui under Health/Sensors.

Hi Mike, welcome to OpenBMC.

>
>Some background:
>
>- Rasp Pi 4
>- meta-phosphor 
>- bmcweb/webui working and can log in
>- pmbus/ltc2978.c driver working
>- hwmon working
>
>In this case, we have this path:
>
>/sys/bus/i2c/devices/i2c-1
>
>Which has a new_device file. I can add my sensor with:
>
>echo ltc3880 0x30 > new_device

The other way is to add this device to your device tree 
via a dts fragment.  This way the kernel will look for 
the device because you told it to expect it there.  
Probably something like

&i2c-1 {
  regulator {
     reg  = <30>
     compatible = <"adi,lltc3880", "lltc,ltc3880">;
  };
};

Assuming your vendor is analog devices (see 
vendor-prefixes.yaml and 
Documentation/devicetree/bindings/vendor-prefixes.yaml)
and your i2c controller has label i2c-1: assigned to
its bus-1 node.

>
>This populates all the files with telemetry data here:
>
>/sys/bus/i2c/devices/i2c01/1-0030/hwmon/hwmon1
>
>Such as in1_input, in2_input, in3_input, which are VIN, VOUT0, VOUT1.
>
>I assume there has to be a file that maps the path to inN_input to a
>d-bus object, some way to register the sensor with the chassis or
>similar concept, and some file with the label and warns, and other
>things you can do with it.
>
From a yocto recipe point of view, it would also have to do the
>equivalent of the “echo” into the new_device so that /sys/… gets
>populated. Perhaps part of some systemd based service.
>
>I have looked at meta-ibm and see a tree under omjc/hwmon/ahb…
>i2c-bus@200…
>
>I do not know what these numbers are referring to. Perhaps these are
>paths in the sys tree for an ahb type architecture? And what is the
>number before .conf?

Yes the hwmon daemon finds its configuration based on a partial 
trailing match of the sysfs path to the hwmon device.  It has to 
account that the actual hwmon instance numbers are not fixed but 
usually we lock the i2c bus numbering down by specifing an alias 
in the device tree to the bus controller which we know the device 
path in sysfs.

i2c01
This part is your i2c bus controller path

/1-0030/
This says the i2c device with address 30 on i2c bus 1, which can
be selected by the alias label to the bus device (possibly elsewhere 
in the device tree or more likely dtsi for the SOC).



>
>Then I see phosphor-hwmon_%.bbappend with more configuration in
>there.
>

This is where the phosphor-hwmon program learns that it should export 
sensors on the hwmon device.   The % is a wildcard for the recipe that
will be extended.  In the file system in the file name gets expanded 
via %I to become the device instance variable by systemd / udevd.

>Can someone explain how this recipe system works? The architecture
>doc was more than confusing. Perhaps just sketch out what I need to
>do for this case, and what files it will generate, so I can build and
>go look at the generated files, etc.
>
>Or perhaps there is a completely different approach?
>
>Mike


I think you found a lot of it.  There is our documntation repository
https://github.com/openbmc/docs/ and under development tutorials is
Adding a new system which starts down this path at

https://github.com/openbmc/docs/blob/master/development/add-new-system.md#hwmon-sensors

I've only watched others adjust their configurations I don't have a 
system to play with myself.

If you find documentation missing please propose a patch for what you 
learned.

milton

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-28 23:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28 22:52 How do I add a PMBus sensor that will show up in webui Sensors? Mike Jones
2020-07-28 23:50 ` Milton Miller II

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.