dbus-sdr: ipmiSetSensorReading handles discrete event for VR

Add the functionality for setting Voltage Regulator Mode as a writable
discrete sensor. Move sensor related helper functions into the namespace
of sensor.

The VR Controller is distinguished as having an interface of
xyz.openbmc_project.Control.VoltageRegulatorMode:
https://github.com/openbmc/phosphor-dbus-interfaces/blob/a7a6db3f770f5a1a5fd660ba3f6a611c435db616/xyz/openbmc_project/Control/VoltageRegulatorMode.interface.yaml

Tested = integrate-tested with VR daemon and ipmitool:

Example Tests,

// Setting to profileB (4)
$ ipmitool raw 0x4 0x30 0xb4 0 0 4 0 0 0 0 0 0 -v
Running Get PICMG Properties my_addr 0x20, transit 0, target 0
Error response 0xc1 from Get PICMG Properities
Running Get VSO Capabilities my_addr 0x20, transit 0, target 0
Invalid completion code received: Invalid command
Discovered IPMB address 0x0
RAW REQ (channel=0x0 netfn=0x4 lun=0x0 cmd=0x30 data_len=10)
RAW REQUEST (10 bytes)
 b4 00 00 04 00 00 00 00 00 00
RAW RSP (0 bytes)

// Setting to profileA (2)
$ ipmitool raw 0x4 0x30 0xb4 0 0 2 0 0 0 0 0 0 -v
Running Get PICMG Properties my_addr 0x20, transit 0, target 0
Error response 0xc1 from Get PICMG Properities
Running Get VSO Capabilities my_addr 0x20, transit 0, target 0
Invalid completion code received: Invalid command
Discovered IPMB address 0x0
RAW REQ (channel=0x0 netfn=0x4 lun=0x0 cmd=0x30 data_len=10)
RAW REQUEST (10 bytes)
 b4 00 00 02 00 00 00 00 00 00
RAW RSP (0 bytes)

$ journalctl -u vr_sensor_profiled.service --since "1 min ago" |  tee
-- Logs begin at Thu 1970-01-01 00:00:25 UTC, end at Thu 1970-01-01 00:49:52 UTC. --
Jan 01 00:49:11 $HOST vr_sensor_profiled[4195]: Info: Transition VR Sensor 0 profile from profileA to profileB
Jan 01 00:49:52 $HOST vr_sensor_profiled[4195]: Info: Transition VR Sensor 0 profile from profileB to profileA

Signed-off-by: Hao Jiang <jianghao@google.com>
Change-Id: I9d6d2e8e5fa6b2be804a2657c6db079562247d90
Signed-off-by: Willy Tu <wltu@google.com>
3 files changed