[PATCH v3 2/8] firmware: scmi: mailbox/smt agent device

Etienne Carriere etienne.carriere at linaro.org
Wed Sep 9 11:33:54 CEST 2020


On Tue, 8 Sep 2020 at 17:21, Simon Glass <sjg at chromium.org> wrote:
>
> Hi Etienne,
>
> On Mon, 7 Sep 2020 at 08:50, Etienne Carriere
> <etienne.carriere at linaro.org> wrote:
> >
> > This change implements a mailbox transport using SMT format for SCMI
> > exchanges. This implementation follows the Linux kernel and
> > SCP-firmware [1] as references implementation for SCMI message
> > processing using SMT format for communication channel meta-data.
> >
> > Use of mailboxes in SCMI FDT bindings are defined in the Linux kernel
> > DT bindings since v4.17.
> >
> > Links: [1] https://github.com/ARM-software/SCP-firmware
> > Signed-off-by: Etienne Carriere <etienne.carriere at linaro.org>
> > Cc: Simon Glass <sjg at chromium.org>
> > Cc: Peng Fan <peng.fan at nxp.com>
> > Cc: Sudeep Holla <sudeep.holla at arm.com>
> > ---
> >
> > Changes in v3:
> > - This is a followup of the SCMI agent patches posted in
> >   https://patchwork.ozlabs.org/project/uboot/list/?series=196253
> >   The v3 splits commits and introduces a new uclass as requested.
> > - This patch implements the same mailbox SCMI agent proposed in v2
> >   but split over few source files.
> > ---
> >  drivers/firmware/scmi/Kconfig         |   6 +-
> >  drivers/firmware/scmi/Makefile        |   2 +
> >  drivers/firmware/scmi/mailbox_agent.c | 107 ++++++++++++++++++++
> >  drivers/firmware/scmi/smt.c           | 139 ++++++++++++++++++++++++++
> >  drivers/firmware/scmi/smt.h           |  86 ++++++++++++++++
> >  5 files changed, 338 insertions(+), 2 deletions(-)
> >  create mode 100644 drivers/firmware/scmi/mailbox_agent.c
> >  create mode 100644 drivers/firmware/scmi/smt.c
> >  create mode 100644 drivers/firmware/scmi/smt.h
>
> Reviewed-by: Simon Glass <sjg at chromium.org>


Thanks for the reviews.


> > diff --git a/drivers/firmware/scmi/smt.c b/drivers/firmware/scmi/smt.c
> > new file mode 100644
> > index 0000000000..afe95a4736
> > --- /dev/null
> > +++ b/drivers/firmware/scmi/smt.c
> > @@ -0,0 +1,139 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
> > + * Copyright (C) 2019-2020 Linaro Limited.
> > + */
> > +
> > +#include <common.h>
> > +#include <cpu_func.h>
> > +#include <dm.h>
> > +#include <errno.h>
> > +#include <scmi_agent.h>
> > +#include <asm/cache.h>
> > +#include <asm/system.h>
> > +#include <dm/ofnode.h>
> > +#include <linux/compat.h>
> > +#include <linux/io.h>
> > +#include <linux/ioport.h>
> > +
> > +#include "smt.h"
> > +
> > +/**
> > + * Get shared memory configuration defined by the referred DT phandle
> > + * Return with a errno compliant value.
> > + */
> > +int scmi_dt_get_smt_buffer(struct udevice *dev, struct scmi_smt *smt)
> > +{
> > +       int ret;
> > +       struct ofnode_phandle_args args;
> > +       struct resource resource;
> > +       fdt32_t faddr;
> > +       phys_addr_t paddr;
> > +
> > +       ret = dev_read_phandle_with_args(dev, "shmem", NULL, 0, 0, &args);
> > +       if (ret)
> > +               return ret;
> > +
> > +       ret = ofnode_read_resource(args.node, 0, &resource);
> > +       if (ret)
> > +               return ret;
> > +
> > +       faddr = cpu_to_fdt32(resource.start);
> > +       paddr = ofnode_translate_address(args.node, &faddr);
> > +
> > +       smt->size = resource_size(&resource);
> > +       if (smt->size < sizeof(struct scmi_smt_header)) {
> > +               dev_err(dev, "Shared memory buffer too small\n");
> > +               return -EINVAL;
> > +       }
> > +
> > +       smt->buf = devm_ioremap(dev, paddr, smt->size);
> > +       if (!smt->buf)
> > +               return -ENOMEM;
> > +
> > +#ifdef __arm__
>
> Should that be CONFIG_ARM ?

Would covers CONFIG_ARM and CONFIG_ARM64, so OK. I'll send a patch v4.

etienne

>
> > +       if (dcache_status())
> > +               mmu_set_region_dcache_behaviour((uintptr_t)smt->buf,
> > +                                               smt->size, DCACHE_OFF);
> > +#endif
> > +
> > +       return 0;
> > +}
> > +
> [..]
>
> Regards,
> Simon


More information about the U-Boot mailing list