[PATCH qemu aspeed-3.1 1/2] aspeed: Add syscon-poweroff to system

Cédric Le Goater clg at kaod.org
Tue Nov 13 18:36:35 AEDT 2018


On 11/13/18 4:04 AM, Joel Stanley wrote:
> Signed-off-by: Joel Stanley <joel at jms.id.au>
> ---
>  hw/arm/aspeed.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index e7b87e355f12..66d6e9ed4551 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -21,8 +21,10 @@
>  #include "hw/i2c/smbus.h"
>  #include "qemu/log.h"
>  #include "sysemu/block-backend.h"
> +#include "sysemu/device_tree.h"
>  #include "hw/loader.h"
>  #include "qemu/error-report.h"
> +#include <libfdt.h>
>  
>  static struct arm_boot_info aspeed_board_binfo = {
>      .board_id = -1, /* device-tree-only board */
> @@ -126,6 +128,38 @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size,
>      g_free(storage);
>  }
>  
> +static void fdt_add_shutdown_node(void *fdt)
> +{
> +    /* TODO: Support 2400 */

You could add a 'const char* property' parameter to fdt_add_shutdown_node()
and use a AspeedBoardConfig.modify_dtb() method to call it.

> +    const char *scu = "aspeed,ast2500-scu";
> +    const char *nodename = "/syscon-poweroff";
> +    uint32_t phandle;
> +    int offset;
> +
> +    /* Find the scu phandle */
> +    offset = fdt_node_offset_by_compatible(fdt, -1, scu);
> +    if (offset < 0) {
> +        error_report("%s couldn't find %s, guest shutdown unavailable: %s",
> +                     __func__, scu, fdt_strerror(offset));
> +        return;
> +    }
> +    phandle = fdt_get_phandle(fdt, offset);
> +
> +    /* Add syscon-poweroff node and use 0x1A0, an un-used SCU register */
> +    qemu_fdt_add_subnode(fdt, nodename);
> +    qemu_fdt_setprop_string(fdt, nodename, "compatible", "syscon-poweroff");
> +    qemu_fdt_setprop_cells(fdt, nodename, "regmap", phandle);
> +    qemu_fdt_setprop_cells(fdt, nodename, "offset", 0x1A0);
> +    qemu_fdt_setprop_cells(fdt, nodename, "value", 1);
> +}
> +
> +static void aspeed_board_modify_dtb(const struct arm_boot_info *binfo,
> +                                    void *fdt)
> +{
> +    fdt_add_shutdown_node(fdt);
> +}
> +
> +
>  static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
>                                        Error **errp)
>  {
> @@ -235,6 +269,7 @@ static void aspeed_board_init(MachineState *machine,
>      aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline;
>      aspeed_board_binfo.ram_size = ram_size;
>      aspeed_board_binfo.loader_start = sc->info->sdram_base;
> +    aspeed_board_binfo.modify_dtb = aspeed_board_modify_dtb;
>  
>      if (cfg->i2c_init) {
>          cfg->i2c_init(bmc);
> 



More information about the openbmc mailing list