From nobody Fri Nov 29 03:40:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1652162740; cv=none; d=zohomail.com; s=zohoarc; b=aNnd7gPCLc29bJo+oZvI2tXFYYGB+b/XESWsVXFVuGvzwhBJTofoxDNBjlSgip8NzXcr3SV+LuahKlqAWGaCkUgzUItKRhSyIKgMCsONcMn8ECRwmgy3b/KE0XsUte8TeWKBuNb1kEUSbnhhsi6JhEeSazQJnX71N07mzzbeyRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652162740; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LdUL/a7ibfgZJBH8Cwv9KTcb3UJUgKsljFq91lvqCvU=; b=lHjlL9lmYMWKB6Z8jKNR7pHe6r6D+l5wSoUvZhFOO0poX/95bPSp0DTAjo6C8Uz66IFzdY+QanVhPFp7inb0kdT5avx543kRkXuk/8zyqpEU7KxDqp2DHw8KsAo8q32bLE4dJuunlYcgBvpgCfJACORqAn3gad8yaj6R5+6dZSY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1652162740378738.7230437974719; Mon, 9 May 2022 23:05:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.325182.547692 (Exim 4.92) (envelope-from ) id 1noIzn-00019b-7a; Tue, 10 May 2022 06:05:19 +0000 Received: by outflank-mailman (output) from mailman id 325182.547692; Tue, 10 May 2022 06:05:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1noIzn-00019P-3p; Tue, 10 May 2022 06:05:19 +0000 Received: by outflank-mailman (input) for mailman id 325182; Tue, 10 May 2022 06:05:18 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1noIzm-0007z7-44 for xen-devel@lists.xen.org; Tue, 10 May 2022 06:05:18 +0000 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [2607:f8b0:4864:20::1029]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 232c783a-d027-11ec-8fc4-03012f2f19d4; Tue, 10 May 2022 08:05:06 +0200 (CEST) Received: by mail-pj1-x1029.google.com with SMTP id w17-20020a17090a529100b001db302efed6so1258812pjh.4 for ; Mon, 09 May 2022 23:05:17 -0700 (PDT) Received: from localhost ([122.162.234.2]) by smtp.gmail.com with ESMTPSA id i63-20020a636d42000000b003c14af5062esm9489879pgc.70.2022.05.09.23.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 23:05:15 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 232c783a-d027-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LdUL/a7ibfgZJBH8Cwv9KTcb3UJUgKsljFq91lvqCvU=; b=k181qsg4Qqs42nA6b8nsKIeuG8Fdeh1LZm41PT3KKx6dGkeV/r8YFGCtyV57yQuzjo kIptadhPH57dwBQtf0tn1kRKYhyF+sC+KZvhttghy8dnvrYJAA0A1v93+Ovo28q34zvS cRhJFtZh4Fn015Q9ZING6/pjkd9+PBoKa9vaYQzXm1hkOqrVS2ACRbwKNts1dVD1z4KR hOzxtV7WYkIHKmgTbJwg7DkSfa7EKdrNqf60YoeJItsYva2LqK2puY+vy9S/pdxYSfrB YWLg1q8SjkmLT9ZUp74vAzgRJJd9HUrhVd/hLn2sSDCEXOeKnHoCihy8S7gK1in4dNWL ZOMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LdUL/a7ibfgZJBH8Cwv9KTcb3UJUgKsljFq91lvqCvU=; b=gzoozIml9x0MjzhbJ4PpqUYaaFlJVkAsb4r5X8U5R5Z4TbLBMA+Zr9RarJ6ZN6XN6j vWdi+X0pwfQ2ypDlNaX41nzBY2IzEPzZz/8NoIvgcNiuOU2KOwSSc9j2LQfsl0Rzbl7B 6ic4sB2+03ylata/CVWszOiZhVzMOJf0yvz2SqBTE38KXw84ugbqP/FsjW3lvnJ5SLo6 /pXP6L7IRmeNC8h7VSGes+B1h+PIDHsSalqB4hMHznOUKh/Z9BT+pGQPuZiXWSWmlTmj SwnkQTw1uAJsg185gL1MPux24uMP6FQWN0v3U4EfTp0DD5oSofYMntZfjq7Eg59sazWz BJkQ== X-Gm-Message-State: AOAM533XgfFtaAnDZcVBT+NOMAQG+qSn8mP/t9U91hRJjCcqCTmgHWzi EIH9Yi9E+29EfOkB8FYTtiZzXIiyFmM1ZQ== X-Google-Smtp-Source: ABdhPJw/ICaJJRhvcX/HWYXMOuOkkNrEi+Qx5x4tMRG+zUNhqhq33zc7z7WNf7qxwb1Sgq1hPehPuw== X-Received: by 2002:a17:902:70c9:b0:15f:a78:fd15 with SMTP id l9-20020a17090270c900b0015f0a78fd15mr9855184plt.12.1652162715940; Mon, 09 May 2022 23:05:15 -0700 (PDT) From: Viresh Kumar To: xen-devel@lists.xen.org Cc: Viresh Kumar , Vincent Guittot , stratos-dev@op-lists.linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefano Stabellini , Mathieu Poirier , Mike Holmes , Oleksandr Tyshchenko , Wei Liu , Juergen Gross , Julien Grall Subject: [PATCH V2 6/6] libxl: Allocate MMIO params for GPIO device and update DT Date: Tue, 10 May 2022 11:34:51 +0530 Message-Id: <5bae7f1e7fe2415f075e71353e3ca12f8f662b05.1652162646.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1652162741763100005 Content-Type: text/plain; charset="utf-8" This patch allocates Virtio MMIO params (IRQ and memory region) and pass them to the backend, also update Guest device-tree based on Virtio GPIO DT bindings [1]. [1] https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio-= virtio.yaml Signed-off-by: Viresh Kumar --- tools/libs/light/libxl_arm.c | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index d085c7cf4dbd..2f23430a3ea3 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -119,6 +119,15 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, return rc; } =20 + for (i =3D 0; i < d_config->num_gpios; i++) { + libxl_device_gpio *gpio =3D &d_config->gpios[i]; + + int rc =3D alloc_virtio_mmio_params(gc, &gpio->base, &gpio->irq, + &virtio_mmio_base, &virtio_mmio_irq); + if (rc) + return rc; + } + if (virtio_mmio_irq !=3D GUEST_VIRTIO_MMIO_SPI_FIRST) { virtio_irq =3D virtio_mmio_irq - 1; nr_spis +=3D (virtio_irq - 32) + 1; @@ -938,6 +947,38 @@ static int make_virtio_mmio_node_i2c(libxl__gc *gc, vo= id *fdt, return fdt_end_node(fdt); } =20 +static int make_virtio_mmio_node_gpio(libxl__gc *gc, void *fdt, + uint64_t base, uint32_t irq) +{ + int res; + + res =3D make_virtio_mmio_node_common(gc, fdt, base, irq); + if (res) return res; + + res =3D fdt_begin_node(fdt, "gpio"); + if (res) return res; + + res =3D fdt_property_compat(gc, fdt, 1, "virtio,device29"); + if (res) return res; + + res =3D fdt_property(fdt, "gpio-controller", NULL, 0); + if (res) return res; + + res =3D fdt_property_cell(fdt, "#gpio-cells", 2); + if (res) return res; + + res =3D fdt_property(fdt, "interrupt-controller", NULL, 0); + if (res) return res; + + res =3D fdt_property_cell(fdt, "#interrupt-cells", 2); + if (res) return res; + + res =3D fdt_end_node(fdt); + if (res) return res; + + return fdt_end_node(fdt); +} + static const struct arch_info *get_arch_info(libxl__gc *gc, const struct xc_dom_image *do= m) { @@ -1253,6 +1294,11 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_d= omain_config *d_config, FDT( make_virtio_mmio_node_simple(gc, fdt, disk->base, dis= k->irq) ); } =20 + for (i =3D 0; i < d_config->num_gpios; i++) { + libxl_device_gpio *gpio =3D &d_config->gpios[i]; + FDT( make_virtio_mmio_node_gpio(gc, fdt, gpio->base, gpio->irq= ) ); + } + for (i =3D 0; i < d_config->num_i2cs; i++) { libxl_device_i2c *i2c =3D &d_config->i2cs[i]; FDT( make_virtio_mmio_node_i2c(gc, fdt, i2c->base, i2c->irq) ); --=20 2.31.1.272.g89b43f80a514