mbox series

[v3,0/5] Add support for PMBus in QEMU

Message ID 20210518184527.1037888-1-titusr@google.com (mailing list archive)
Headers show
Series Add support for PMBus in QEMU | expand

Message

Titus Rwantare May 18, 2021, 6:45 p.m. UTC
Hello,

This patch series adds an interface to start supporting PMBus devices in QEMU.
I’ve included two PMBus devices: MAX34451 and ADM1272.

PMBus is a variant of SMBus meant for digital management of power supplies.
PMBus adds to the SMBus standard by defining a number of constants and commands
used by compliant devices. The specification for PMBus can be found at:

https://pmbus.org/specification-archives/

Currently, the goal for these devices is to emulate basic functionality by
reading and writing registers. Timing, and some logical operation is not
implemented. This implementation supports nearly all available registers for
PMBus including:
   - Voltage inputs and outputs
   - Current inputs and outputs
   - Temperature sensors

Unimplimented registers get passed through to the device model, and device
models can opt out of using the standard registers with flags. The included
devices make use of these fields and illustrate how to interface with the pmbus
class.

Datasheets for sensors:

https://datasheets.maximintegrated.com/en/ds/MAX34451.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/ADM1272.pdf

Since v2:
- bump for feedback
- removed commented out code

Since v1:
- addressed Joel's comments
- split out tests into their own patches

Thanks for reviewing,

Titus Rwantare

Titus Rwantare (5):
  hw/i2c: add support for PMBus
  hw/misc: add ADM1272 device
  tests/qtest: add tests for ADM1272 device model
  hw/misc: add MAX34451 device
  tests/qtest: add tests for MAX34451 device model

 include/hw/i2c/pmbus_device.h |  506 +++++++++++
 hw/i2c/pmbus_device.c         | 1596 +++++++++++++++++++++++++++++++++
 hw/misc/adm1272.c             |  543 +++++++++++
 hw/misc/max34451.c            |  716 +++++++++++++++
 tests/qtest/adm1272-test.c    |  445 +++++++++
 tests/qtest/max34451-test.c   |  336 +++++++
 hw/arm/Kconfig                |    3 +
 hw/i2c/Kconfig                |    4 +
 hw/i2c/meson.build            |    1 +
 hw/misc/Kconfig               |    8 +
 hw/misc/meson.build           |    2 +
 tests/qtest/meson.build       |    2 +
 12 files changed, 4162 insertions(+)
 create mode 100644 include/hw/i2c/pmbus_device.h
 create mode 100644 hw/i2c/pmbus_device.c
 create mode 100644 hw/misc/adm1272.c
 create mode 100644 hw/misc/max34451.c
 create mode 100644 tests/qtest/adm1272-test.c
 create mode 100644 tests/qtest/max34451-test.c

Comments

Corey Minyard May 18, 2021, 7:45 p.m. UTC | #1
On Tue, May 18, 2021 at 11:45:22AM -0700, Titus Rwantare wrote:
> Hello,
> 
> This patch series adds an interface to start supporting PMBus devices in QEMU.
> I’ve included two PMBus devices: MAX34451 and ADM1272.

I've reviewed all these patches, and beyond my one comment, they look
good.

I'm not too excited about putting the device files in misc.  I know some
SMBus sensors are in there, but they really aren't miscellaneous.  They
are really sensors.  But unless we want to create a sensors directory
and move things into that, misc will have to do, I guess.

-corey

> 
> PMBus is a variant of SMBus meant for digital management of power supplies.
> PMBus adds to the SMBus standard by defining a number of constants and commands
> used by compliant devices. The specification for PMBus can be found at:
> 
> https://pmbus.org/specification-archives/
> 
> Currently, the goal for these devices is to emulate basic functionality by
> reading and writing registers. Timing, and some logical operation is not
> implemented. This implementation supports nearly all available registers for
> PMBus including:
>    - Voltage inputs and outputs
>    - Current inputs and outputs
>    - Temperature sensors
> 
> Unimplimented registers get passed through to the device model, and device
> models can opt out of using the standard registers with flags. The included
> devices make use of these fields and illustrate how to interface with the pmbus
> class.
> 
> Datasheets for sensors:
> 
> https://datasheets.maximintegrated.com/en/ds/MAX34451.pdf
> https://www.analog.com/media/en/technical-documentation/data-sheets/ADM1272.pdf
> 
> Since v2:
> - bump for feedback
> - removed commented out code
> 
> Since v1:
> - addressed Joel's comments
> - split out tests into their own patches
> 
> Thanks for reviewing,
> 
> Titus Rwantare
> 
> Titus Rwantare (5):
>   hw/i2c: add support for PMBus
>   hw/misc: add ADM1272 device
>   tests/qtest: add tests for ADM1272 device model
>   hw/misc: add MAX34451 device
>   tests/qtest: add tests for MAX34451 device model
> 
>  include/hw/i2c/pmbus_device.h |  506 +++++++++++
>  hw/i2c/pmbus_device.c         | 1596 +++++++++++++++++++++++++++++++++
>  hw/misc/adm1272.c             |  543 +++++++++++
>  hw/misc/max34451.c            |  716 +++++++++++++++
>  tests/qtest/adm1272-test.c    |  445 +++++++++
>  tests/qtest/max34451-test.c   |  336 +++++++
>  hw/arm/Kconfig                |    3 +
>  hw/i2c/Kconfig                |    4 +
>  hw/i2c/meson.build            |    1 +
>  hw/misc/Kconfig               |    8 +
>  hw/misc/meson.build           |    2 +
>  tests/qtest/meson.build       |    2 +
>  12 files changed, 4162 insertions(+)
>  create mode 100644 include/hw/i2c/pmbus_device.h
>  create mode 100644 hw/i2c/pmbus_device.c
>  create mode 100644 hw/misc/adm1272.c
>  create mode 100644 hw/misc/max34451.c
>  create mode 100644 tests/qtest/adm1272-test.c
>  create mode 100644 tests/qtest/max34451-test.c
> 
> -- 
> 2.31.1.751.gd2f1c929bd-goog
>
Titus Rwantare May 18, 2021, 7:50 p.m. UTC | #2
I would also like a directory for sensors. There are quite a few of
those incoming. Any objections?

-Titus

On Tue, 18 May 2021 at 15:45, Corey Minyard <cminyard@mvista.com> wrote:
>
> On Tue, May 18, 2021 at 11:45:22AM -0700, Titus Rwantare wrote:
> > Hello,
> >
> > This patch series adds an interface to start supporting PMBus devices in QEMU.
> > I’ve included two PMBus devices: MAX34451 and ADM1272.
>
> I've reviewed all these patches, and beyond my one comment, they look
> good.
>
> I'm not too excited about putting the device files in misc.  I know some
> SMBus sensors are in there, but they really aren't miscellaneous.  They
> are really sensors.  But unless we want to create a sensors directory
> and move things into that, misc will have to do, I guess.
>
> -corey
>
> >
> > PMBus is a variant of SMBus meant for digital management of power supplies.
> > PMBus adds to the SMBus standard by defining a number of constants and commands
> > used by compliant devices. The specification for PMBus can be found at:
> >
> > https://pmbus.org/specification-archives/
> >
> > Currently, the goal for these devices is to emulate basic functionality by
> > reading and writing registers. Timing, and some logical operation is not
> > implemented. This implementation supports nearly all available registers for
> > PMBus including:
> >    - Voltage inputs and outputs
> >    - Current inputs and outputs
> >    - Temperature sensors
> >
> > Unimplimented registers get passed through to the device model, and device
> > models can opt out of using the standard registers with flags. The included
> > devices make use of these fields and illustrate how to interface with the pmbus
> > class.
> >
> > Datasheets for sensors:
> >
> > https://datasheets.maximintegrated.com/en/ds/MAX34451.pdf
> > https://www.analog.com/media/en/technical-documentation/data-sheets/ADM1272.pdf
> >
> > Since v2:
> > - bump for feedback
> > - removed commented out code
> >
> > Since v1:
> > - addressed Joel's comments
> > - split out tests into their own patches
> >
> > Thanks for reviewing,
> >
> > Titus Rwantare
> >
> > Titus Rwantare (5):
> >   hw/i2c: add support for PMBus
> >   hw/misc: add ADM1272 device
> >   tests/qtest: add tests for ADM1272 device model
> >   hw/misc: add MAX34451 device
> >   tests/qtest: add tests for MAX34451 device model
> >
> >  include/hw/i2c/pmbus_device.h |  506 +++++++++++
> >  hw/i2c/pmbus_device.c         | 1596 +++++++++++++++++++++++++++++++++
> >  hw/misc/adm1272.c             |  543 +++++++++++
> >  hw/misc/max34451.c            |  716 +++++++++++++++
> >  tests/qtest/adm1272-test.c    |  445 +++++++++
> >  tests/qtest/max34451-test.c   |  336 +++++++
> >  hw/arm/Kconfig                |    3 +
> >  hw/i2c/Kconfig                |    4 +
> >  hw/i2c/meson.build            |    1 +
> >  hw/misc/Kconfig               |    8 +
> >  hw/misc/meson.build           |    2 +
> >  tests/qtest/meson.build       |    2 +
> >  12 files changed, 4162 insertions(+)
> >  create mode 100644 include/hw/i2c/pmbus_device.h
> >  create mode 100644 hw/i2c/pmbus_device.c
> >  create mode 100644 hw/misc/adm1272.c
> >  create mode 100644 hw/misc/max34451.c
> >  create mode 100644 tests/qtest/adm1272-test.c
> >  create mode 100644 tests/qtest/max34451-test.c
> >
> > --
> > 2.31.1.751.gd2f1c929bd-goog
> >
Corey Minyard May 18, 2021, 8:59 p.m. UTC | #3
On Tue, May 18, 2021 at 03:50:57PM -0400, Titus Rwantare wrote:
> I would also like a directory for sensors. There are quite a few of
> those incoming. Any objections?

None from me.  I'll add a patch to move all the sensors from misc into
it, if you like.

-corey

> 
> -Titus
> 
> On Tue, 18 May 2021 at 15:45, Corey Minyard <cminyard@mvista.com> wrote:
> >
> > On Tue, May 18, 2021 at 11:45:22AM -0700, Titus Rwantare wrote:
> > > Hello,
> > >
> > > This patch series adds an interface to start supporting PMBus devices in QEMU.
> > > I’ve included two PMBus devices: MAX34451 and ADM1272.
> >
> > I've reviewed all these patches, and beyond my one comment, they look
> > good.
> >
> > I'm not too excited about putting the device files in misc.  I know some
> > SMBus sensors are in there, but they really aren't miscellaneous.  They
> > are really sensors.  But unless we want to create a sensors directory
> > and move things into that, misc will have to do, I guess.
> >
> > -corey
> >
> > >
> > > PMBus is a variant of SMBus meant for digital management of power supplies.
> > > PMBus adds to the SMBus standard by defining a number of constants and commands
> > > used by compliant devices. The specification for PMBus can be found at:
> > >
> > > https://pmbus.org/specification-archives/
> > >
> > > Currently, the goal for these devices is to emulate basic functionality by
> > > reading and writing registers. Timing, and some logical operation is not
> > > implemented. This implementation supports nearly all available registers for
> > > PMBus including:
> > >    - Voltage inputs and outputs
> > >    - Current inputs and outputs
> > >    - Temperature sensors
> > >
> > > Unimplimented registers get passed through to the device model, and device
> > > models can opt out of using the standard registers with flags. The included
> > > devices make use of these fields and illustrate how to interface with the pmbus
> > > class.
> > >
> > > Datasheets for sensors:
> > >
> > > https://datasheets.maximintegrated.com/en/ds/MAX34451.pdf
> > > https://www.analog.com/media/en/technical-documentation/data-sheets/ADM1272.pdf
> > >
> > > Since v2:
> > > - bump for feedback
> > > - removed commented out code
> > >
> > > Since v1:
> > > - addressed Joel's comments
> > > - split out tests into their own patches
> > >
> > > Thanks for reviewing,
> > >
> > > Titus Rwantare
> > >
> > > Titus Rwantare (5):
> > >   hw/i2c: add support for PMBus
> > >   hw/misc: add ADM1272 device
> > >   tests/qtest: add tests for ADM1272 device model
> > >   hw/misc: add MAX34451 device
> > >   tests/qtest: add tests for MAX34451 device model
> > >
> > >  include/hw/i2c/pmbus_device.h |  506 +++++++++++
> > >  hw/i2c/pmbus_device.c         | 1596 +++++++++++++++++++++++++++++++++
> > >  hw/misc/adm1272.c             |  543 +++++++++++
> > >  hw/misc/max34451.c            |  716 +++++++++++++++
> > >  tests/qtest/adm1272-test.c    |  445 +++++++++
> > >  tests/qtest/max34451-test.c   |  336 +++++++
> > >  hw/arm/Kconfig                |    3 +
> > >  hw/i2c/Kconfig                |    4 +
> > >  hw/i2c/meson.build            |    1 +
> > >  hw/misc/Kconfig               |    8 +
> > >  hw/misc/meson.build           |    2 +
> > >  tests/qtest/meson.build       |    2 +
> > >  12 files changed, 4162 insertions(+)
> > >  create mode 100644 include/hw/i2c/pmbus_device.h
> > >  create mode 100644 hw/i2c/pmbus_device.c
> > >  create mode 100644 hw/misc/adm1272.c
> > >  create mode 100644 hw/misc/max34451.c
> > >  create mode 100644 tests/qtest/adm1272-test.c
> > >  create mode 100644 tests/qtest/max34451-test.c
> > >
> > > --
> > > 2.31.1.751.gd2f1c929bd-goog
> > >
Titus Rwantare May 18, 2021, 9:43 p.m. UTC | #4
That would be great.

On Tue, 18 May 2021, 16:59 Corey Minyard, <cminyard@mvista.com> wrote:
>
> On Tue, May 18, 2021 at 03:50:57PM -0400, Titus Rwantare wrote:
> > I would also like a directory for sensors. There are quite a few of
> > those incoming. Any objections?
>
> None from me.  I'll add a patch to move all the sensors from misc into
> it, if you like.