[PATCH 0/3] Add a host power device

Jian Zhang posted 3 patches 3 years, 4 months ago
Failed in applying to current master (apply log)
MAINTAINERS                  |   2 +
hw/arm/Kconfig               |   1 +
hw/arm/aspeed.c              |  19 +++++++
hw/gpio/aspeed_gpio.c        |  17 ++++++
hw/misc/Kconfig              |   3 +
hw/misc/host_power.c         | 105 +++++++++++++++++++++++++++++++++++
hw/misc/meson.build          |   1 +
include/hw/misc/host_power.h |  41 ++++++++++++++
8 files changed, 189 insertions(+)
create mode 100644 hw/misc/host_power.c
create mode 100644 include/hw/misc/host_power.h
[PATCH 0/3] Add a host power device
Posted by Jian Zhang 3 years, 4 months ago
This patchset adds a host power device and added it into the g220a
mahcine. The BMC have a important is to control the power of the host,
usually it is nessary in a hardware platform.

The BMC(soc) usually had a output pin to control the power of the host,
and a input pin to get the power status of the host.

The host power device is a generic device to simulate the host power,
accept the power control command from the BMC and report the power
status.

Test on the g220a machine, the host power control command can be simply
work.

Jian Zhang (3):
  hw/gpio/aspeed_gpio: Add gpios in/out init
  hw/misc/host_power: Add a simple host power device
  hw/arm/aspeed: g220a: Add host-power device

 MAINTAINERS                  |   2 +
 hw/arm/Kconfig               |   1 +
 hw/arm/aspeed.c              |  19 +++++++
 hw/gpio/aspeed_gpio.c        |  17 ++++++
 hw/misc/Kconfig              |   3 +
 hw/misc/host_power.c         | 105 +++++++++++++++++++++++++++++++++++
 hw/misc/meson.build          |   1 +
 include/hw/misc/host_power.h |  41 ++++++++++++++
 8 files changed, 189 insertions(+)
 create mode 100644 hw/misc/host_power.c
 create mode 100644 include/hw/misc/host_power.h

--
2.25.1
Re: [PATCH 0/3] Add a host power device
Posted by Philippe Mathieu-Daudé via 3 years, 4 months ago
Hi Jian,

On 19/9/22 19:21, Jian Zhang wrote:
> This patchset adds a host power device and added it into the g220a
> mahcine. The BMC have a important is to control the power of the host,
> usually it is nessary in a hardware platform.
> 
> The BMC(soc) usually had a output pin to control the power of the host,
> and a input pin to get the power status of the host.
> 
> The host power device is a generic device to simulate the host power,
> accept the power control command from the BMC and report the power
> status.
> 
> Test on the g220a machine, the host power control command can be simply
> work.
> 
> Jian Zhang (3):
>    hw/gpio/aspeed_gpio: Add gpios in/out init
>    hw/misc/host_power: Add a simple host power device
>    hw/arm/aspeed: g220a: Add host-power device

"power-good" is just a TYPE_LED object, but it doesn't seem you are
really interested in using it.

My understanding of your "power-button" is a latching switch.

This could be indeed useful. I'd name this model TYPE_LATCHING_SWITCH
and put it in hw/misc/latching-switch.c (since it is external to a
SoC). It has one input and one output. Naming them is not particularly
useful IMHO. The triggering edge should be a property (it might have
a default, positive/negative), and the switch state must to be in
vmstate for the object to be migratable.

("power-good"/"power-button" is what this particular board choose to
use the latch switch input/output for).

Do you mind renaming your series accordingly ("latching switch"),
and adding the vmstate?

Also I'd reorder your series as 2,1,3:
- introduce the new device
- prepare aspeed_gpio
- wire aspeed_g220a

Regards,

Phil.
Re: [Phishing Risk] [External] Re: [PATCH 0/3] Add a host power device
Posted by Zhang Jian 3 years, 4 months ago
Hi Philippe,

Thanks for your reply.

On Tue, Sep 20, 2022 at 7:09 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Hi Jian,
>
> On 19/9/22 19:21, Jian Zhang wrote:
> > This patchset adds a host power device and added it into the g220a
> > mahcine. The BMC have a important is to control the power of the host,
> > usually it is nessary in a hardware platform.
> >
> > The BMC(soc) usually had a output pin to control the power of the host,
> > and a input pin to get the power status of the host.
> >
> > The host power device is a generic device to simulate the host power,
> > accept the power control command from the BMC and report the power
> > status.
> >
> > Test on the g220a machine, the host power control command can be simply
> > work.
> >
> > Jian Zhang (3):
> >    hw/gpio/aspeed_gpio: Add gpios in/out init
> >    hw/misc/host_power: Add a simple host power device
> >    hw/arm/aspeed: g220a: Add host-power device
>
> "power-good" is just a TYPE_LED object, but it doesn't seem you are
> really interested in using it.
>
yeah, i'd like to just send an irq when the `switch` status changed.

> My understanding of your "power-button" is a latching switch.
>
yeah, this really like a latching switch.

> This could be indeed useful. I'd name this model TYPE_LATCHING_SWITCH
> and put it in hw/misc/latching-switch.c (since it is external to a
> SoC). It has one input and one output. Naming them is not particularly
> useful IMHO.
ok, it's make sense, using input and output directly.
> The triggering edge should be a property (it might have
> a default, positive/negative), and the switch state must to be in
> vmstate for the object to be migratable.
Ok, i got it.
>
> ("power-good"/"power-button" is what this particular board choose to
> use the latch switch input/output for).
>
> Do you mind renaming your series accordingly ("latching switch"),
> and adding the vmstate?
>
Ok, the name latching switch makes more sense and is more generic.

> Also I'd reorder your series as 2,1,3:
> - introduce the new device
> - prepare aspeed_gpio
> - wire aspeed_g220a
>
okay~
> Regards,
>
> Phil.

Thanks for your reply.

Thanks, Jian.
Re: [Phishing Risk] [External] Re: [PATCH 0/3] Add a host power device
Posted by Philippe Mathieu-Daudé via 3 years, 4 months ago
On 20/9/22 17:17, Zhang Jian wrote:
> Hi Philippe,
> 
> Thanks for your reply.
> 
> On Tue, Sep 20, 2022 at 7:09 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>
>> Hi Jian,
>>
>> On 19/9/22 19:21, Jian Zhang wrote:
>>> This patchset adds a host power device and added it into the g220a
>>> mahcine. The BMC have a important is to control the power of the host,
>>> usually it is nessary in a hardware platform.
>>>
>>> The BMC(soc) usually had a output pin to control the power of the host,
>>> and a input pin to get the power status of the host.
>>>
>>> The host power device is a generic device to simulate the host power,
>>> accept the power control command from the BMC and report the power
>>> status.
>>>
>>> Test on the g220a machine, the host power control command can be simply
>>> work.
>>>
>>> Jian Zhang (3):
>>>     hw/gpio/aspeed_gpio: Add gpios in/out init
>>>     hw/misc/host_power: Add a simple host power device
>>>     hw/arm/aspeed: g220a: Add host-power device
>>
>> "power-good" is just a TYPE_LED object, but it doesn't seem you are
>> really interested in using it.
>>
> yeah, i'd like to just send an irq when the `switch` status changed.

You can do that using feeding the switch latch output to a 2-lines
TYPE_SPLIT_IRQ object, then wire 1 line to the SoC input, and the
other one to the TYPE_LED input.