From patchwork Fri Sep 27 13:34:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168513 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="kbrZ+xxp"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ftBF56Jkz9sDB for ; Fri, 27 Sep 2019 23:36:53 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4A791C21FBE; Fri, 27 Sep 2019 13:35:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id EB243C21FBA; Fri, 27 Sep 2019 13:35:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A247FC21F0F; Fri, 27 Sep 2019 13:35:15 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by lists.denx.de (Postfix) with ESMTPS id EEED5C21F19 for ; Fri, 27 Sep 2019 13:35:12 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id n14so2755472wrw.9 for ; Fri, 27 Sep 2019 06:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=eVmBgRVkbPVeFU+RMQb7Fq89NSklUnrWR8PwPKZFOV8=; b=kbrZ+xxp1m04aI5atQof99ojBqBHyS4EXiUGuW0Pmk/4U8RRESqK3695h4S7Eb1Ku0 BYWgake+wLMNjwhyXMrD3a6Jk2iMFfv5pIBKUfBU70x58yLDFR2z1mgsMW2XjBwnbkoN cuRPWALg/tO4v0HjESZgZ8zSqRZdpyW+nOb3/wqg1SbIItDAy47hE8Jk+iYb5h9SWsb4 tpJGm1B4mFl2lj76KItnZhrl54dI1jHsi7h2GvVicePKXKlIy9areO35i6x3h6aXLl+j DpdN7pjBHIp5zWJelH7x06BMHFCOADZQD+NZ20MvM0H95dBoni+qqDDU9g321l1V3MEg xzOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=eVmBgRVkbPVeFU+RMQb7Fq89NSklUnrWR8PwPKZFOV8=; b=RQZ2o7cgSZbVESxXdtCvYfe2wxpUeOOOJ907F1AjUZp5QvUB1QMbNDDN5xTeqf451F aoB/mv5zHm2RXnzV1eaYPYw1ZXLlNObTp6p2wFE1rNh+UtLprgUFnweyRu/NZQ12NmMI qGABHHfiYjegwpkLc3UImjET8kJwh6SI8yrRNerIbbgtu/6UenRAgs0km6b5M5t7T4Vr cVIl1xVGNUJyZt5lkzF0q9tPjxuiATB3FKWiI27FRh5zXpiZoXwmptkGL1GcTBJPYadb s+CcdpCfERL98BT86SGkUP41IYnKH2CP+a9k+kIfkmI7uGYAxMbaq1OMLy9MA1ia8kR/ v5MQ== X-Gm-Message-State: APjAAAVYesry3yeIwKvR3YDVYsqCWRjj1MSXgYrJtke0EkDxS+Pd//Dc khdP6ulDZCff/cMwfUsoG67suSdiPpzeNg== X-Google-Smtp-Source: APXvYqxxKlmW78hUx/BnsLXz9mhZDGduBo8waRl44zXbjEuWLL4NCV+YvCbie1F+ud3Zgfk/J2l4Mw== X-Received: by 2002:adf:f1d1:: with SMTP id z17mr2945899wro.330.1569591312303; Fri, 27 Sep 2019 06:35:12 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id x6sm7829533wmf.35.2019.09.27.06.35.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:11 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:34:52 +0200 Message-Id: <300f8ca074d22481ec299ddfa29c23887148633e.1569591296.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: ibai.erkiaga-elorza@xilinx.com, luca@lucaceresoli.net Subject: [U-Boot] [PATCH 01/13] mailbox: check ops prior calling X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Ibai Erkiaga Check if request and free operations are present prior calling to the functions. Signed-off-by: Ibai Erkiaga Signed-off-by: Michal Simek --- drivers/mailbox/mailbox-uclass.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mailbox/mailbox-uclass.c b/drivers/mailbox/mailbox-uclass.c index 1b4a5863c9e5..809f26b20258 100644 --- a/drivers/mailbox/mailbox-uclass.c +++ b/drivers/mailbox/mailbox-uclass.c @@ -63,7 +63,8 @@ int mbox_get_by_index(struct udevice *dev, int index, struct mbox_chan *chan) return ret; } - ret = ops->request(chan); + if (ops->request) + ret = ops->request(chan); if (ret) { debug("ops->request() failed: %d\n", ret); return ret; @@ -94,7 +95,10 @@ int mbox_free(struct mbox_chan *chan) debug("%s(chan=%p)\n", __func__, chan); - return ops->free(chan); + if (ops->free) + return ops->free(chan); + + return 0; } int mbox_send(struct mbox_chan *chan, const void *data) From patchwork Fri Sep 27 13:34:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168512 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="U+5gCU8H"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ft9v50vXz9sDB for ; Fri, 27 Sep 2019 23:36:35 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 5AEB9C21FA5; Fri, 27 Sep 2019 13:35:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 88275C21FAC; Fri, 27 Sep 2019 13:35:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1FFA4C21E7F; Fri, 27 Sep 2019 13:35:17 +0000 (UTC) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by lists.denx.de (Postfix) with ESMTPS id 096D9C21F91 for ; Fri, 27 Sep 2019 13:35:15 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id p7so6652692wmp.4 for ; Fri, 27 Sep 2019 06:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=LVToznQuFcaBwMTMFvavpB/N4Y+YWPMzPMFO6heNYr0=; b=U+5gCU8HyMkOO+Z/BdNJlzSDIGcrxHHIBaF+VWB/VM4m3Y6m0M1mHVNq5KHI7HDQIg h6tZ9pq+lI1M2BVdXk23fjpVewAV6Oawv/QtYsFj6OWWAfpqAUoi7hD6HMN1nhdGOJQS 6OeSntOIQjaUDD3T3PK7KgANsAm8pYdK04u3QZKz04ubU5hXTtaVfLgRmYHVzWPcNyE0 a1xC/tnx7WaoBmWA8fNL2s9q75eSvp/jyhgE/c+AcqpZfaPZO4/HduZWGs5M3QmVq+WQ vPs6CdcNRJLZxgLhagTlGFK0Q0Es18wWv98mZSgWK66r9xxgGQyp6jN5oqb2hoHIF5ND B58g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=LVToznQuFcaBwMTMFvavpB/N4Y+YWPMzPMFO6heNYr0=; b=JIv4MyQbtntcIhFkJ++lQohML/kJGDa+27HsHjWA49Lgs3q8aTHBSrB9+ACG8t8sik s/XuURRVj5hFnyyb+nLwBriEtO4XxLvIIIxpv/w/flHnAxWl1AC1HB0KVotP4Tbwi74o HSDJ7NCNB4tfcTiLEPwGJNR4ggwra6elINcI3aFdKfwizekEslvr0ZFayLopDGJtzwlH yj8BBruw4rEyNzLByiRyZlYOfUv/4Nv2C3JCvoC6pwNSmOyTolmolxpl3hDLZUtZCSit AMCWimioDKJRfUpkQsDI+ZfMaqzLXXcFToYQ6JoBK5/BZFBNCDj+089Hp/IliKIbkwuw aVVg== X-Gm-Message-State: APjAAAXWJlIVp1pE6I/fG9YGW+DhINtN1PYxQeGK3Qogdt7wrV1phrAe ile09HI3yI+hSvUqMhBFwhOyAlP3FQEuRQ== X-Google-Smtp-Source: APXvYqz0YcpbJe6AYCJ71d7FYiCRYjekyhHdNtx+HjEMEZ3vjArAWq+lgmzxxnNRIvY91+rXDqLKIw== X-Received: by 2002:a05:600c:118a:: with SMTP id i10mr398242wmf.80.1569591314415; Fri, 27 Sep 2019 06:35:14 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id e30sm5461209wra.48.2019.09.27.06.35.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:13 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:34:53 +0200 Message-Id: <916fdafa5a736a57066de4de733b1ab9d8621fb6.1569591296.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: ibai.erkiaga-elorza@xilinx.com, luca@lucaceresoli.net Subject: [U-Boot] [PATCH 02/13] mailbox: allow subnode for mbox regs X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Ibai Erkiaga The following patch allows the mailbox node in DT to host subnodes with mailbox definitions. If the client phandle to the mailbox is not the mailbox driver node, just checks parents as well. Signed-off-by: Ibai Erkiaga Signed-off-by: Michal Simek --- drivers/mailbox/mailbox-uclass.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/mailbox/mailbox-uclass.c b/drivers/mailbox/mailbox-uclass.c index 809f26b20258..9fdb6279e4f3 100644 --- a/drivers/mailbox/mailbox-uclass.c +++ b/drivers/mailbox/mailbox-uclass.c @@ -49,7 +49,16 @@ int mbox_get_by_index(struct udevice *dev, int index, struct mbox_chan *chan) if (ret) { debug("%s: uclass_get_device_by_of_offset failed: %d\n", __func__, ret); - return ret; + + /* Test with parent node */ + ret = uclass_get_device_by_ofnode(UCLASS_MAILBOX, + ofnode_get_parent(args.node), + &dev_mbox); + if (ret) { + debug("%s: mbox node from parent failed: %d\n", + __func__, ret); + return ret; + }; } ops = mbox_dev_ops(dev_mbox); From patchwork Fri Sep 27 13:34:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168514 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="a3+1WYCC"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ftDF4kM6z9sDB for ; Fri, 27 Sep 2019 23:38:37 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1CF38C21FC1; Fri, 27 Sep 2019 13:36:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2D9B9C21FAF; Fri, 27 Sep 2019 13:36:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7E772C21F79; Fri, 27 Sep 2019 13:35:19 +0000 (UTC) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by lists.denx.de (Postfix) with ESMTPS id 3601EC21F6A for ; Fri, 27 Sep 2019 13:35:17 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id r19so6641175wmh.2 for ; Fri, 27 Sep 2019 06:35:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=mrUjDvUYQ1O4ztS77WlAXsNxP37OoHOqLBpA/IV5deA=; b=a3+1WYCCzGXZznfQ3bpRUYPAu6EHw66pvXmTdt7S06OvNDWXFCg1KlnCfM4RI5Ejjs 06qYKqFFUSrvJEA70akUnRNsZ3dECP++rAN5wnt7NMazGTS3fen2b23frISo9heUZ7lC VrQlPdyd4Ac6nf98PICi3mNLPF9DyrDV7cruAjdi7Op+etB0l7ko1L0t8Kq/7fL3xlq3 bHEWNmxOIpbKZgi3+p18EgY2u5w+POyp+AjLoQ96pKhOTAeAjR99q6JspktaIj/itbae NzMvjqHi7+u1kVvknVmNkYyOpYaZFYdWelzIJoM3ysjQeSTaHsrD3D6R+fYSZquGc7GK rLVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=mrUjDvUYQ1O4ztS77WlAXsNxP37OoHOqLBpA/IV5deA=; b=isx6idZl4QnKHaYP9VU3EUa1dEGYtPS+TOJB0un8VE5LP7sblSZ1Qn5nKTuV+GP5D6 fxWRmhaiBLPDEfCGR07gRrVNbIIy2QH54PEMSeF3e+dce9U+03O/CWIN7P3hHeqaq4xj 6lqGww10STHqoS5bkZy6d2DyMoOfNPvreBxvLnSU6Q9dgykXFh5uWOA3ytSRVlf//w8V P5KLBTs4JaDnBM4oMT7KaixL7Iv/EWF/hAtUy8cDclCw4v2Nd+qhpOa8UGiDtBHqwj2A 8BB99YEhkf8hWdo3vH9Y0Me4N3iPkCCa9rfqPXQ1GgwaondTHfbnakEPhZAKyiDQK1V5 ceYA== X-Gm-Message-State: APjAAAXIQjTJRs855FpQYodH06KrqFGrXJAp+vQVW3RbMzN8Qh45bBi7 R1Gkm7NgiBR/iK6QYuRSFYd9gDzUPu860A== X-Google-Smtp-Source: APXvYqynGbBzakAEZwowzR9REEE2fWtbNMYRB9Ailikt2rz+Jp1KP2nUkDWLd34OmsFqVChrMKH3zg== X-Received: by 2002:a1c:9a4a:: with SMTP id c71mr6751385wme.99.1569591316474; Fri, 27 Sep 2019 06:35:16 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id y186sm16667140wmb.41.2019.09.27.06.35.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:15 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:34:54 +0200 Message-Id: <24ef30e5932b53eb817e39acbb60e6ff7d516113.1569591296.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: Krzysztof Kozlowski , Loic Pallardy , Stefan Roese , Heinrich Schuchardt , Fabien Dessenne , luca@lucaceresoli.net, Ryder Lee , ibai.erkiaga-elorza@xilinx.com Subject: [U-Boot] [PATCH 03/13] mailbox: zynqmp: ipi mailbox driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Ibai Erkiaga ZynqMP mailbox driver implementing IPI communication with PMU. This would allow U-Boot SPL to communicate with PMUFW to request privileged operations. Signed-off-by: Ibai Erkiaga Signed-off-by: Michal Simek --- MAINTAINERS | 1 + arch/arm/mach-zynqmp/include/mach/sys_proto.h | 5 + drivers/mailbox/Kconfig | 6 + drivers/mailbox/Makefile | 1 + drivers/mailbox/zynqmp-ipi.c | 134 ++++++++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 drivers/mailbox/zynqmp-ipi.c diff --git a/MAINTAINERS b/MAINTAINERS index f448c5f19e00..f5feb89ac3e9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -448,6 +448,7 @@ F: drivers/gpio/zynq_gpio.c F: drivers/i2c/i2c-cdns.c F: drivers/i2c/muxes/pca954x.c F: drivers/i2c/zynq_i2c.c +F: drivers/mailbox/zynqmp-ipi.c F: drivers/mmc/zynq_sdhci.c F: drivers/mtd/nand/raw/zynq_nand.c F: drivers/net/phy/xilinx_phy.c diff --git a/arch/arm/mach-zynqmp/include/mach/sys_proto.h b/arch/arm/mach-zynqmp/include/mach/sys_proto.h index 915badc6fbee..f25d414dcb1e 100644 --- a/arch/arm/mach-zynqmp/include/mach/sys_proto.h +++ b/arch/arm/mach-zynqmp/include/mach/sys_proto.h @@ -54,6 +54,11 @@ enum { TCM_SPLIT, }; +struct zynqmp_ipi_msg { + size_t len; + u32 *buf; +}; + int zynq_board_read_rom_ethaddr(unsigned char *ethaddr); unsigned int zynqmp_get_silicon_version(void); diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 11bf5522db53..85c2a829aed8 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -41,4 +41,10 @@ config K3_SEC_PROXY Select this driver if your platform has support for this hardware block. +config ZYNQMP_IPI + bool "Xilinx ZynqMP IPI controller support" + depends on DM_MAILBOX && ARCH_ZYNQMP + help + This enables support for the Xilinx ZynqMP Inter Processor Interrupt + communication controller. endmenu diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile index a753cc4e6806..d2ace8cd212e 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -9,3 +9,4 @@ obj-$(CONFIG_SANDBOX_MBOX) += sandbox-mbox-test.o obj-$(CONFIG_STM32_IPCC) += stm32-ipcc.o obj-$(CONFIG_TEGRA_HSP) += tegra-hsp.o obj-$(CONFIG_K3_SEC_PROXY) += k3-sec-proxy.o +obj-$(CONFIG_ZYNQMP_IPI) += zynqmp-ipi.o diff --git a/drivers/mailbox/zynqmp-ipi.c b/drivers/mailbox/zynqmp-ipi.c new file mode 100644 index 000000000000..c181a7b81768 --- /dev/null +++ b/drivers/mailbox/zynqmp-ipi.c @@ -0,0 +1,134 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Xilinx Zynq MPSoC Mailbox driver + * + * Copyright (C) 2018-2019 Xilinx, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* IPI bitmasks, register base */ +/* TODO: move reg base to DT */ +#define IPI_BIT_MASK_PMU0 0x10000 +#define IPI_INT_REG_BASE_APU 0xFF300000 + +struct ipi_int_regs { + u32 trig; /* 0x0 */ + u32 obs; /* 0x4 */ + u32 ist; /* 0x8 */ + u32 imr; /* 0xC */ + u32 ier; /* 0x10 */ + u32 idr; /* 0x14 */ +}; + +#define ipi_int_apu ((struct ipi_int_regs *)IPI_INT_REG_BASE_APU) + +struct zynqmp_ipi { + void __iomem *local_req_regs; + void __iomem *local_res_regs; + void __iomem *remote_req_regs; + void __iomem *remote_res_regs; +}; + +static int zynqmp_ipi_send(struct mbox_chan *chan, const void *data) +{ + const struct zynqmp_ipi_msg *msg = (struct zynqmp_ipi_msg *)data; + struct zynqmp_ipi *zynqmp = dev_get_priv(chan->dev); + u32 ret; + u32 *mbx = (u32 *)zynqmp->local_req_regs; + + for (size_t i = 0; i < msg->len; i++) + writel(msg->buf[i], &mbx[i]); + + /* Write trigger interrupt */ + writel(IPI_BIT_MASK_PMU0, &ipi_int_apu->trig); + + /* Wait until observation bit is cleared */ + ret = wait_for_bit_le32(&ipi_int_apu->obs, IPI_BIT_MASK_PMU0, false, + 100, false); + + debug("%s, send %ld bytes\n", __func__, msg->len); + return ret; +}; + +static int zynqmp_ipi_recv(struct mbox_chan *chan, void *data) +{ + struct zynqmp_ipi_msg *msg = (struct zynqmp_ipi_msg *)data; + struct zynqmp_ipi *zynqmp = dev_get_priv(chan->dev); + u32 *mbx = (u32 *)zynqmp->local_res_regs; + + for (size_t i = 0; i < msg->len; i++) + msg->buf[i] = readl(&mbx[i]); + + debug("%s, recv %ld bytes\n", __func__, msg->len); + return 0; +}; + +static int zynqmp_ipi_probe(struct udevice *dev) +{ + struct zynqmp_ipi *zynqmp = dev_get_priv(dev); + struct resource res; + ofnode node; + + debug("%s(dev=%p)\n", __func__, dev); + + /* Get subnode where the regs are defined */ + /* Note IPI mailbox node needs to be the first one in DT */ + node = ofnode_first_subnode(dev_ofnode(dev)); + + if (ofnode_read_resource_byname(node, "local_request_region", &res)) { + dev_err(dev, "No reg property for local_request_region\n"); + return -EINVAL; + }; + zynqmp->local_req_regs = devm_ioremap(dev, res.start, + (res.start - res.end)); + + if (ofnode_read_resource_byname(node, "local_response_region", &res)) { + dev_err(dev, "No reg property for local_response_region\n"); + return -EINVAL; + }; + zynqmp->local_res_regs = devm_ioremap(dev, res.start, + (res.start - res.end)); + + if (ofnode_read_resource_byname(node, "remote_request_region", &res)) { + dev_err(dev, "No reg property for remote_request_region\n"); + return -EINVAL; + }; + zynqmp->remote_req_regs = devm_ioremap(dev, res.start, + (res.start - res.end)); + + if (ofnode_read_resource_byname(node, "remote_response_region", &res)) { + dev_err(dev, "No reg property for remote_response_region\n"); + return -EINVAL; + }; + zynqmp->remote_res_regs = devm_ioremap(dev, res.start, + (res.start - res.end)); + + return 0; +}; + +static const struct udevice_id zynqmp_ipi_ids[] = { + { .compatible = "xlnx,zynqmp-ipi-mailbox" }, + { } +}; + +struct mbox_ops zynqmp_ipi_mbox_ops = { + .send = zynqmp_ipi_send, + .recv = zynqmp_ipi_recv, +}; + +U_BOOT_DRIVER(zynqmp_ipi) = { + .name = "zynqmp-ipi", + .id = UCLASS_MAILBOX, + .of_match = zynqmp_ipi_ids, + .probe = zynqmp_ipi_probe, + .priv_auto_alloc_size = sizeof(struct zynqmp_ipi), + .ops = &zynqmp_ipi_mbox_ops, +}; From patchwork Fri Sep 27 13:34:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168523 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="hIn1UBAM"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ftHW49z7z9sDB for ; Fri, 27 Sep 2019 23:41:26 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A0F08C22037; Fri, 27 Sep 2019 13:37:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 78E7BC21FC6; Fri, 27 Sep 2019 13:36:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 87604C21FC0; Fri, 27 Sep 2019 13:35:21 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by lists.denx.de (Postfix) with ESMTPS id 452ABC21FA1 for ; Fri, 27 Sep 2019 13:35:19 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id w12so2772630wro.5 for ; Fri, 27 Sep 2019 06:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=pgrVd2l/+ejhn0rLoroH4AprExNBwBOF9m9t1OMOeVU=; b=hIn1UBAMZADUgH/gBfBOEIDCnOe13es8L+EEXy3HsK6/8879tR0/otbX/H1u0gt35a qmpyTKYyI7iXmr1C2PhELA4ZROCjbuMeROOM6vN48myYyZ8d1xUMAO1wXKfLd0GVHBc0 h6CLMsQn0zsiX6POnsofZb/COF0KM7yp8e3JwLKfuaTjJ7/coo7aK45f5gLtQESSRsq7 YiQcHyiGY8hdXJwDjw6U47sH40ihegfevJmGf8efskpGiiyyvzD1pxC5BUTQAruUH2va IRQaLZRcdX5BaOsVBUyfF3vxaQIprUxCSUmBO4uCouaINRtXkHdw3Cj3b7oRNiYHBkLa FsiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=pgrVd2l/+ejhn0rLoroH4AprExNBwBOF9m9t1OMOeVU=; b=dLzdgEL0oqapnSfY8Z3OGlLuXbAW3l7q7oZmlspfAEbY7h4GRdrK5MLSBZADiexO1x bwiC1D2CfyxmElcCKvzHxgXmwJ9tT8rVPoxnuHqmreCeMc/D7nKAVQ+wfV4l4i9BwyzA t2MXCsNQSd5yLTZUOk3ww1QKQfoJ7keQJd/vbPpOL+bFqdqGVmS3nCqPX991SvAWcpc2 bX+LJhNKAsD9XY2WAkKW6dTPzv3vBWeDq969fvuxms/i4dJmnC8yHaepIED6WmsztZxt GxJjvHK75jS+uvKEeOXrCY9/fgxm3knzSyO7yQAbOCVYN3hXWd72TrlyIPrTQZ+XOFYz 1OhA== X-Gm-Message-State: APjAAAXa6ShQy2hnJZjScAGOw/pa1uezn+4g/IOdap7yA6KPu/gaJQ7o FUt3fG+6jwJeuAPKnfESqGQ5fhUJ6R7/6g== X-Google-Smtp-Source: APXvYqxWE/Dbr5WBcUvBFymxdZ8uPVj3Ra/Qppm5xuW4GPvmK3cZmIXA/cBz3toipr7F56dJDoUm7A== X-Received: by 2002:a5d:5592:: with SMTP id i18mr2978589wrv.316.1569591318559; Fri, 27 Sep 2019 06:35:18 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id h7sm2577053wrt.17.2019.09.27.06.35.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:17 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:34:55 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: Rajan Vaja , luca@lucaceresoli.net, ibai.erkiaga-elorza@xilinx.com Subject: [U-Boot] [PATCH 04/13] firmware: zynqmp: Add zynqmp-power support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Ibai Erkiaga zynqmp-power driver for ZynqMP to handle the communication with the PMU firmware. Firmware driver just probes subnodes and power driver handles communication with PMU using the IPI mailbox driver. Signed-off-by: Ibai Erkiaga Signed-off-by: Michal Simek --- drivers/firmware/Kconfig | 2 ++ drivers/firmware/firmware-zynqmp.c | 40 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index b70a2063551c..9596ec16c7f7 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -30,6 +30,8 @@ config TI_SCI_PROTOCOL config ZYNQMP_FIRMWARE bool "ZynqMP Firmware interface" select FIRMWARE + select ZYNQMP_IPI + select DM_MAILBOX help Firmware interface driver is used by different drivers to communicate with the firmware for diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c index 6644a7166ca0..b0930447b988 100644 --- a/drivers/firmware/firmware-zynqmp.c +++ b/drivers/firmware/firmware-zynqmp.c @@ -1,6 +1,46 @@ // SPDX-License-Identifier: GPL-2.0 +/* + * Xilinx Zynq MPSoC Firmware driver + * + * Copyright (C) 2018-2019 Xilinx, Inc. + */ +#include #include +#include +#include + +struct zynqmp_power { + struct mbox_chan tx_chan; + struct mbox_chan rx_chan; +} zynqmp_power; + +static int zynqmp_power_probe(struct udevice *dev) +{ + int ret = 0; + + debug("%s, (dev=%p)\n", __func__, dev); + + ret |= mbox_get_by_name(dev, "tx", &zynqmp_power.tx_chan); + ret |= mbox_get_by_name(dev, "rx", &zynqmp_power.rx_chan); + + if (ret) + debug("%s, cannot get mailboxes\n", __func__); + + return ret; +}; + +static const struct udevice_id zynqmp_power_ids[] = { + { .compatible = "xlnx,zynqmp-power" }, + { } +}; + +U_BOOT_DRIVER(zynqmp_power) = { + .name = "zynqmp_power", + .id = UCLASS_FIRMWARE, + .of_match = zynqmp_power_ids, + .probe = zynqmp_power_probe, +}; static const struct udevice_id zynqmp_firmware_ids[] = { { .compatible = "xlnx,zynqmp-firmware" }, From patchwork Fri Sep 27 13:34:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="WQ73DPH3"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ftFz4HHSz9sDB for ; Fri, 27 Sep 2019 23:40:07 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 14873C21FEE; Fri, 27 Sep 2019 13:36:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 39597C21F91; Fri, 27 Sep 2019 13:36:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3DEE4C21F34; Fri, 27 Sep 2019 13:35:22 +0000 (UTC) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by lists.denx.de (Postfix) with ESMTPS id F328CC21FAB for ; Fri, 27 Sep 2019 13:35:20 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id p7so6653003wmp.4 for ; Fri, 27 Sep 2019 06:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=yuW8o6DgIxqfvKVChVMiuAOd4Vsxq6U1kT9SriBaMU0=; b=WQ73DPH3ou8MH4DaKtLJgqlMfiDvTbxB2glr6Yo1s8gT/vP774Fldq1Ya69FuO4U0h AbiCtViRVx7kmFsGqtPoR4uAKLhO3hpEFKsYIkFCNEY0zbqfX1WmD/9nSPKFYDWyKdSf 2LzHSgQGMQO7+BbzyqzqdMaD23FcNH56phq2sBsB2x0w8SnOWk/B/iDS5CKbuyV2c7uQ Hxi6VMVzO6GRwKJvNDNR9qh4hBkoy6dssZlwNA/WNwZ41WMIalVa/dOULJuacIA7IAD8 yEE2I8zkB+J3uZxtRNLxaobuKH38DYqd8MQju5z1/Vwgsk1BxfEzbrzFvAJJkVbg2ty6 US9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=yuW8o6DgIxqfvKVChVMiuAOd4Vsxq6U1kT9SriBaMU0=; b=Y483fJN5livBeF3dwbMnO4jZlKBIIscRwtVtPTfRjP7tTF6UfWT8ZDishAoQlWmcnJ HO6NIW/n6SzmA12a74RhV3CMYX+/uzHS0/nAK17Idvgrbvq8bqQ21xjrU4rxTLtqiyml 69oIw9N212bZf00TLAToMAKbOyReEslRYSUqnPz2JV2HZr4Ae2oUg6XyTJeHRiNZP2fR 4FG5oNfzwFqFALx+jshD2R1dej1T1MOnnRf3IbPlZKnRLp5fhzLlrSWYG8ALf9L1r3AP 1AIA8GrYNSdE82JxxkJIzvEDYi17+NbtRkSbl0Lk5NTxEBrZJEYNrQor3WDQBfG5v5Oy vwgA== X-Gm-Message-State: APjAAAUxD5vkSS3PIvW4QGPWEuWnJduPGvi4X8TMRhIXYdqmrI2tCnK2 LX7bslI9IYvQ38UdV5L9ee2QzSgp1K+/jg== X-Google-Smtp-Source: APXvYqzbiRp5w33lSR37dgXjaZGIXR/5zQHlpzrqbN2yLpPtPlIavybFp6BPa3J4ubY6wv924xiFrg== X-Received: by 2002:a1c:c506:: with SMTP id v6mr6770757wmf.160.1569591320323; Fri, 27 Sep 2019 06:35:20 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id a71sm7507642wme.11.2019.09.27.06.35.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:19 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:34:56 +0200 Message-Id: <80acbadf89b95ea527bbba5c8cce1808cc31bff7.1569591296.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: Amit Kucheria , Li Yang , luca@lucaceresoli.net, Mounika Grace Akula , ibai.erkiaga-elorza@xilinx.com Subject: [U-Boot] [PATCH 05/13] arm64: zynqmp: add firmware and mailbox node to DT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Ibai Erkiaga The following patch adds a mailbox node and firmware node to following the mainline DT. Signed-off-by: Ibai Erkiaga Signed-off-by: Michal Simek --- arch/arm/dts/zynqmp.dtsi | 44 +++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/arch/arm/dts/zynqmp.dtsi b/arch/arm/dts/zynqmp.dtsi index dfb6ebc64ce5..8e35171dd01d 100644 --- a/arch/arm/dts/zynqmp.dtsi +++ b/arch/arm/dts/zynqmp.dtsi @@ -96,6 +96,29 @@ }; }; + zynqmp_ipi { + u-boot,dm-pre-reloc; + compatible = "xlnx,zynqmp-ipi-mailbox"; + interrupt-parent = <&gic>; + interrupts = <0 35 4>; + xlnx,ipi-id = <0>; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + ipi_mailbox_pmu1: mailbox@ff990400 { + u-boot,dm-pre-reloc; + reg = <0x0 0xff9905c0 0x0 0x20>, + <0x0 0xff9905e0 0x0 0x20>, + <0x0 0xff990e80 0x0 0x20>, + <0x0 0xff990ea0 0x0 0x20>; + reg-names = "local_request_region" , "local_response_region", + "remote_request_region", "remote_response_region"; + #mbox-cells = <1>; + xlnx,ipi-id = <4>; + }; + }; + dcc: dcc { compatible = "arm,dcc"; status = "disabled"; @@ -116,11 +139,22 @@ method = "smc"; }; - pmufw: firmware { - compatible = "xlnx,zynqmp-pm"; - method = "smc"; - interrupt-parent = <&gic>; - interrupts = <0 35 4>; + firmware { + zynqmp-firmware { + compatible = "xlnx,zynqmp-firmware"; + method = "smc"; + #power-domain-cells = <0x1>; + u-boot,dm-pre-reloc; + + zynqmp_power: zynqmp-power { + u-boot,dm-pre-reloc; + compatible = "xlnx,zynqmp-power"; + interrupt-parent = <&gic>; + interrupts = <0 35 4>; + mboxes = <&ipi_mailbox_pmu1 0>, <&ipi_mailbox_pmu1 1>; + mbox-names = "tx", "rx"; + }; + }; }; timer { From patchwork Fri Sep 27 13:34:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="Qn66iduQ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ftFs3vK0z9sDB for ; Fri, 27 Sep 2019 23:40:01 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 2B9D7C22011; Fri, 27 Sep 2019 13:36:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 96E79C21EF1; Fri, 27 Sep 2019 13:35:52 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5CC79C21FBB; Fri, 27 Sep 2019 13:35:23 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by lists.denx.de (Postfix) with ESMTPS id E5F53C21FB7 for ; Fri, 27 Sep 2019 13:35:22 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id l3so2767791wru.7 for ; Fri, 27 Sep 2019 06:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=IDhEZy+hXNON6Kk0KYs76Tu+wZmVAyBcFqTK8gurAyw=; b=Qn66iduQ2FsAOBzSVwSueRzgn8xA0bU3e7nM4SSohOIcAhQfXOg9LYXEfpacsHu6Ki GvU9zpAckWllQ91YtCgzu+Q34htFAxg9UeFIqLhf5KZ00N6fpp5xnJfU6j3ZkyHUeOmS ioiXzXKkvKXMYnYploK8YBU3K+qTxAJ4YWGY6+kHNgRGhl+S6PetPvyapEMGaQdmFd3f i72g0BXXOE2HXdvnTaRi4xpuCgzwPArU186Ac+hPfutcEoD1T1KHgWQdIONdxLn48LFr 2NkSWYVTXWdw8E1tRIPDGuOKra99aMiP9cXDItg+BIdD/0yG7Ax705mCQXX7miaqqn/v Qbjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=IDhEZy+hXNON6Kk0KYs76Tu+wZmVAyBcFqTK8gurAyw=; b=S7MjF7C5KqW4b87qN4f7oRF9erIP4fwxF5cjZz4C+lJxb8I9yGnQoZVVTED35PvMlq q6HQ6DB3hQTjRA1Hp6gehI4lF0CwceqJNrxnOlcQ4Fm7r9jMFv/ZOeue31jlgEDZZtaG JiMreayn8uIMJtyZ4CaMZn5BY2v7GMywjO+e3puKRVGMcT3HG2HdcUw+LrlahpBDEWzj t+qsR9FpJaVBmIOVztTHV/zJBBsYnEvAnNyM/WTQyziMBX0Uwj0qwLs80CdMN5Z5pf4o pSyrv4+UxSC3DP45Vmii8O07ioi3Emd61nGbToGlLQy5lacwhULuf8ha+/eMnHBO6GBL L4QQ== X-Gm-Message-State: APjAAAXKadIPC1YiA8JIHjQnYiepyOsd3IntmHaw4UYz8CJw1iaCqOS1 YaUMjiBAUCl2ay8lmVGnoTl6gp1T5rQDgQ== X-Google-Smtp-Source: APXvYqxAbEBn23CCgM5O/LLmgi3vW8uvuXjVvleFg7BD/3SeGuNu8wYMtR5qscWVlDC2irBywRRQ0g== X-Received: by 2002:a5d:49c2:: with SMTP id t2mr2881243wrs.351.1569591322279; Fri, 27 Sep 2019 06:35:22 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id y186sm10405099wmd.26.2019.09.27.06.35.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:21 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:34:57 +0200 Message-Id: <4efe8e4ab6b3d4389746a2080cf93bc24ba7293d.1569591296.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: ibai.erkiaga-elorza@xilinx.com, luca@lucaceresoli.net Subject: [U-Boot] [PATCH 06/13] arm64: zynqmp: Cleanup PM SMC macro composition X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Cleanup PM ID handling by using enum values. Signed-off-by: Michal Simek Signed-off-by: Ibai Erkiaga --- arch/arm/mach-zynqmp/include/mach/sys_proto.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-zynqmp/include/mach/sys_proto.h b/arch/arm/mach-zynqmp/include/mach/sys_proto.h index f25d414dcb1e..573c4ffceed9 100644 --- a/arch/arm/mach-zynqmp/include/mach/sys_proto.h +++ b/arch/arm/mach-zynqmp/include/mach/sys_proto.h @@ -10,7 +10,8 @@ #define PAYLOAD_ARG_CNT 5 #define ZYNQMP_CSU_SILICON_VER_MASK 0xF -#define ZYNQMP_SIP_SVC_PM_SECURE_IMG_LOAD 0xC200002D +#define ZYNQMP_SIP_SVC_PM_SECURE_IMG_LOAD \ + (PM_SIP_SVC + PM_SECURE_IMAGE) #define KEY_PTR_LEN 32 #define ZYNQMP_FPGA_BIT_AUTH_DDR 1 @@ -21,7 +22,8 @@ #define ZYNQMP_FPGA_AUTH_DDR 1 -#define ZYNQMP_SIP_SVC_GET_API_VERSION 0xC2000001 +#define ZYNQMP_SIP_SVC_GET_API_VERSION \ + (PM_SIP_SVC + PM_GET_API_VERSION) #define ZYNQMP_PM_VERSION_MAJOR 1 #define ZYNQMP_PM_VERSION_MINOR 0 @@ -36,6 +38,13 @@ #define PMUFW_V1_0 ((1 << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | 0) +#define PM_SIP_SVC 0xc2000000 + +enum pm_api_id { + PM_GET_API_VERSION = 1, + PM_SECURE_IMAGE = 45, +}; + enum { IDCODE, VERSION, From patchwork Fri Sep 27 13:34:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168515 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="yUyA6a9W"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ftDM5Cv7z9sDB for ; Fri, 27 Sep 2019 23:38:43 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 6A73DC21FD0; Fri, 27 Sep 2019 13:36:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 02BD9C21FB9; Fri, 27 Sep 2019 13:36:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5FA30C21EB4; Fri, 27 Sep 2019 13:35:25 +0000 (UTC) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by lists.denx.de (Postfix) with ESMTPS id E4434C21F34 for ; Fri, 27 Sep 2019 13:35:24 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id h7so2767414wrw.8 for ; Fri, 27 Sep 2019 06:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=QC0aaTV6EnnThXXscL63B22/lmR/rlbOzFTbnTJjrVY=; b=yUyA6a9Wtw6J6BnW236I0D+BdlhKDsWfgSSjgPFGhP9gZcC8LpGUKrhLmEQUT+y8w7 J67+y6Q678st4J02E0RArfr51fJmx9tJYo3cJ5hDIy5YzNaqTZ7AkSBweMSt8l4bMR/R 4hmRVN2+f0KUk3Mu0sF9BPx6ZxIqpIw2Y2tFyTZFOJyYBbGvmXfJhQ3WDRqIRvZiTfxD wExLdRAy/0Iw3j3fjqiRLk3hwxmoJwRlfK8VFw9UNKobPSaAv/ydgliMd+pBqQSSmWui zo2WzJkCEKQgs3lBreNQrYU2dCkoiX0FM602ZbfYBmjO185u8/UX1CXMLmOmTTeeQD38 RRMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=QC0aaTV6EnnThXXscL63B22/lmR/rlbOzFTbnTJjrVY=; b=bPjcHaMw5x1Z5L/1dBlzlJYTIiq78ZPylMQ15M8siOTA9UvlmL3ziNmxoqhAh6tHzE 7vUt0FlGv1mXa2R780r9l68YoyfHuAkZe3ADxOQ+sdecbDkfMcS4maUMmrwMxGQl554i s2c6GWptmbmi8pOAfDujcE/BT1Byxh19UNWxM7Stjqdn+rtNw+Pk2WkeYeC0PAsmgyjL EpA3t+T1lv/TwwKxgWy2id/wl6wTB8kS1968TTtXPp4h7fjMKl12SVpa5sm0qpJZU6+D H4zVG6+e9iLeq5Xa7jI65L/5CFNxGEOl/A/5keSXUY8zoxfwsze9ZXV9hcGehMkMgrZ2 1K7g== X-Gm-Message-State: APjAAAWdXbrcHEjC/QlEoQOOW6jxmU45fsalZvHXxkldAFSZ2IHuiLZV irGJI+FJt34vdbDg4qF27R+7eSBox1AgWg== X-Google-Smtp-Source: APXvYqwOqc+u3sHnkOoiQQdzuJotKu0Vm5TQbxBfGaafuG/U+z4Z3Euv4cekVtrjCQGmEHOTGriHyw== X-Received: by 2002:adf:fc05:: with SMTP id i5mr3172235wrr.134.1569591324202; Fri, 27 Sep 2019 06:35:24 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id g24sm2895771wrb.35.2019.09.27.06.35.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:23 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:34:58 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: ibai.erkiaga-elorza@xilinx.com, luca@lucaceresoli.net, Rajan Vaja Subject: [U-Boot] [PATCH 07/13] firmware: zynqmp: get fw version with mailbox driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Ibai Erkiaga Implements the function to get PMU Firmware version using the mailbox driver or smc call based on if running SPL or not. Additionally gets version as part of the ZynqMP Firmware driver probing Signed-off-by: Ibai Erkiaga Signed-off-by: Michal Simek --- drivers/firmware/firmware-zynqmp.c | 69 +++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c index b0930447b988..f4d9fd9569e2 100644 --- a/drivers/firmware/firmware-zynqmp.c +++ b/drivers/firmware/firmware-zynqmp.c @@ -10,11 +10,69 @@ #include #include +#define PMUFW_PAYLOAD_ARG_CNT 8 + struct zynqmp_power { struct mbox_chan tx_chan; struct mbox_chan rx_chan; } zynqmp_power; +static int ipi_req(const u32 *req, size_t req_len, u32 *res, size_t res_maxlen) +{ + struct zynqmp_ipi_msg msg; + + if (req_len > PMUFW_PAYLOAD_ARG_CNT || + res_maxlen > PMUFW_PAYLOAD_ARG_CNT) + return -EINVAL; + + if (!(zynqmp_power.tx_chan.dev) || !(&zynqmp_power.rx_chan.dev)) + return -EINVAL; + + msg.buf = (u32 *)req; + msg.len = req_len; + mbox_send(&zynqmp_power.tx_chan, &msg); + + msg.buf = res; + msg.len = res_maxlen; + mbox_recv(&zynqmp_power.rx_chan, &msg, 100); + + return 0; +} + +unsigned int zynqmp_firmware_version(void) +{ + int ret; + u32 ret_payload[PAYLOAD_ARG_CNT]; + static u32 pm_api_version = ZYNQMP_PM_VERSION_INVALID; + + /* + * Get PMU version only once and later + * just return stored values instead of + * asking PMUFW again. + **/ + if (pm_api_version == ZYNQMP_PM_VERSION_INVALID) { + if (IS_ENABLED(CONFIG_SPL_BUILD)) { + const u32 request[] = { PM_GET_API_VERSION }; + + ret = ipi_req(request, ARRAY_SIZE(request), + ret_payload, 2); + } else { + ret = invoke_smc(ZYNQMP_SIP_SVC_GET_API_VERSION, 0, 0, + 0, 0, ret_payload); + }; + + if (ret) + panic("PMUFW is not found - Please load it!\n"); + + pm_api_version = ret_payload[1]; + if (pm_api_version < ZYNQMP_PM_VERSION) + panic("PMUFW version error. Expected: v%d.%d\n", + ZYNQMP_PM_VERSION_MAJOR, ZYNQMP_PM_VERSION_MINOR); + } + + return pm_api_version; +}; + static int zynqmp_power_probe(struct udevice *dev) { int ret = 0; @@ -24,10 +82,17 @@ static int zynqmp_power_probe(struct udevice *dev) ret |= mbox_get_by_name(dev, "tx", &zynqmp_power.tx_chan); ret |= mbox_get_by_name(dev, "rx", &zynqmp_power.rx_chan); - if (ret) + if (ret) { debug("%s, cannot get mailboxes\n", __func__); + return ret; + } + + ret = zynqmp_firmware_version(); + printf("PMUFW:\tv%d.%d\n", + ret >> ZYNQMP_PM_VERSION_MAJOR_SHIFT, + ret & ZYNQMP_PM_VERSION_MINOR_MASK); - return ret; + return 0; }; static const struct udevice_id zynqmp_power_ids[] = { From patchwork Fri Sep 27 13:34:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168522 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="0AdVhpm8"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ftHN4WLlz9sPS for ; Fri, 27 Sep 2019 23:41:20 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id B9C2DC21FE2; Fri, 27 Sep 2019 13:37:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 346D7C21F34; Fri, 27 Sep 2019 13:36:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A7A45C21EF1; Fri, 27 Sep 2019 13:35:29 +0000 (UTC) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by lists.denx.de (Postfix) with ESMTPS id 23272C21E2B for ; Fri, 27 Sep 2019 13:35:27 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id b24so6184674wmj.5 for ; Fri, 27 Sep 2019 06:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=W9hxkzQdnVAeKFcV4FwXK3iM89R0/QG8ft4o5fwaasQ=; b=0AdVhpm8QqLK50VnExnt1x5KbVVGf/HqlTxBVafwq6iblPck0q/+VTmnZ1CIhX0rWr HQ/T7Xpc+ZEv7LsOn4jEtTjOGAnBktuFzZRU8ucgTBYbtwGf38TS945im38unPIrYJ4J +V696qqPaKMXCtXuQN9ZlpxVtpGe7gbmWh+TYWrYkqh5oUkSA+H1/peGjZiomAZMRjYt jF0efKcfXm88AWinrbNjsZdN8IxAlIb0HreTgalR80OyDuoUqP2xx7mHY+f0cYlkJ4iE nmnEGCg3eyhEZusVFxxATYxWuWUtJzpHd5aSaxty36cHCSBcTm0BBt0s8uqIRGgV2zy7 pocQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=W9hxkzQdnVAeKFcV4FwXK3iM89R0/QG8ft4o5fwaasQ=; b=XS3Pbi8QeAVc8IuDM/PNQ8lsdyrdzK3wru+HGDHtuAq6pC7lskip0TgvhTe6n+tWAo 2QVqK0zyY+1xMUz608kEp9jrUS9hTzqDkjssGBlZLtNejgruwMLg8GZpPEflhWzfQ3wH sznCGAzqV/cXfAMRmCTy3cZKKwQxsp89s02d8zlPlrXiI+PsfiDHbJKKpfTXEMG/f4RK uJnHK2Qbk3PWVeOH5hbv/diw7GH2DOJ71RLNof2lr9L8IqMchpfCHXgWxBU9kigkYIWq 3+UFqKf7BJ30qYKr4/4rXEY9oSELT6OESgOtG8y+ZOlBY5r00P8gPWMy1FnUjzcXl++C rbnw== X-Gm-Message-State: APjAAAUnaO/NceovTbJzigjDIKo/mzMdI255KT2PuTIPr7QUs4+dDgh8 0ysw3dwEuAdWnUIHo4Tp7xtEgwHwxkyCkQ== X-Google-Smtp-Source: APXvYqzBmkaU2ANS68YoY2Hfa47LArRReCiD++u7oiZQyd+TYAOfMsgd13g/jh/zecJ4Q9LKuBRJUg== X-Received: by 2002:a1c:cf05:: with SMTP id f5mr7191376wmg.131.1569591326448; Fri, 27 Sep 2019 06:35:26 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id g24sm2895922wrb.35.2019.09.27.06.35.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:25 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:34:59 +0200 Message-Id: <903a7187a9cb58463280f054522a2ff7554734e1.1569591296.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: Ryder Lee , Rajan Vaja , Heinrich Schuchardt , Stefan Roese , Krzysztof Kozlowski , luca@lucaceresoli.net, ibai.erkiaga-elorza@xilinx.com Subject: [U-Boot] [PATCH 08/13] firmware: zynqmp: create firmware header X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Ibai Erkiaga New firmware header to place firmware specific macro and function declarations. The patch also moves the macros defining PM operations as well as some helper macros. Signed-off-by: Ibai Erkiaga Signed-off-by: Michal Simek --- MAINTAINERS | 1 + arch/arm/mach-zynqmp/cpu.c | 1 + arch/arm/mach-zynqmp/include/mach/sys_proto.h | 25 ------------ board/xilinx/zynqmp/cmds.c | 1 + board/xilinx/zynqmp/zynqmp.c | 1 + drivers/firmware/firmware-zynqmp.c | 1 + drivers/fpga/zynqmppl.c | 1 + include/zynqmp_firmware.h | 38 +++++++++++++++++++ 8 files changed, 44 insertions(+), 25 deletions(-) create mode 100644 include/zynqmp_firmware.h diff --git a/MAINTAINERS b/MAINTAINERS index f5feb89ac3e9..5d5c0fc61f03 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -460,6 +460,7 @@ F: drivers/timer/cadence-ttc.c F: drivers/usb/host/ehci-zynq.c F: drivers/watchdog/cdns_wdt.c F: include/zynqmppl.h +F: include/zynqmp_firmware.h F: tools/zynqmp* N: ultra96 N: zynqmp diff --git a/arch/arm/mach-zynqmp/cpu.c b/arch/arm/mach-zynqmp/cpu.c index 5ef1a52862c0..f28b964a1560 100644 --- a/arch/arm/mach-zynqmp/cpu.c +++ b/arch/arm/mach-zynqmp/cpu.c @@ -9,6 +9,7 @@ #include #include #include +#include #define ZYNQ_SILICON_VER_MASK 0xF000 #define ZYNQ_SILICON_VER_SHIFT 12 diff --git a/arch/arm/mach-zynqmp/include/mach/sys_proto.h b/arch/arm/mach-zynqmp/include/mach/sys_proto.h index 573c4ffceed9..658974445417 100644 --- a/arch/arm/mach-zynqmp/include/mach/sys_proto.h +++ b/arch/arm/mach-zynqmp/include/mach/sys_proto.h @@ -10,8 +10,6 @@ #define PAYLOAD_ARG_CNT 5 #define ZYNQMP_CSU_SILICON_VER_MASK 0xF -#define ZYNQMP_SIP_SVC_PM_SECURE_IMG_LOAD \ - (PM_SIP_SVC + PM_SECURE_IMAGE) #define KEY_PTR_LEN 32 #define ZYNQMP_FPGA_BIT_AUTH_DDR 1 @@ -22,29 +20,6 @@ #define ZYNQMP_FPGA_AUTH_DDR 1 -#define ZYNQMP_SIP_SVC_GET_API_VERSION \ - (PM_SIP_SVC + PM_GET_API_VERSION) - -#define ZYNQMP_PM_VERSION_MAJOR 1 -#define ZYNQMP_PM_VERSION_MINOR 0 -#define ZYNQMP_PM_VERSION_MAJOR_SHIFT 16 -#define ZYNQMP_PM_VERSION_MINOR_MASK 0xFFFF - -#define ZYNQMP_PM_VERSION \ - ((ZYNQMP_PM_VERSION_MAJOR << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | \ - ZYNQMP_PM_VERSION_MINOR) - -#define ZYNQMP_PM_VERSION_INVALID ~0 - -#define PMUFW_V1_0 ((1 << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | 0) - -#define PM_SIP_SVC 0xc2000000 - -enum pm_api_id { - PM_GET_API_VERSION = 1, - PM_SECURE_IMAGE = 45, -}; - enum { IDCODE, VERSION, diff --git a/board/xilinx/zynqmp/cmds.c b/board/xilinx/zynqmp/cmds.c index ed7ba58c6475..f53a1b63bea6 100644 --- a/board/xilinx/zynqmp/cmds.c +++ b/board/xilinx/zynqmp/cmds.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 6524badf299c..d9186f463f20 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c index f4d9fd9569e2..d70f34f24388 100644 --- a/drivers/firmware/firmware-zynqmp.c +++ b/drivers/firmware/firmware-zynqmp.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #define PMUFW_PAYLOAD_ARG_CNT 8 diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c index f6d9d50ef15f..6168626aeef3 100644 --- a/drivers/fpga/zynqmppl.c +++ b/drivers/fpga/zynqmppl.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h new file mode 100644 index 000000000000..c522cae8399b --- /dev/null +++ b/include/zynqmp_firmware.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Xilinx Zynq MPSoC Firmware driver + * + * Copyright (C) 2018-2019 Xilinx, Inc. + */ + +#ifndef _ZYNQM_FIRMWARE_H_ +#define _ZYNQM_FIRMWARE_H_ + +#define PM_SIP_SVC 0xc2000000 +#define ZYNQMP_SIP_SVC_GET_API_VERSION \ + (PM_SIP_SVC + PM_GET_API_VERSION) +#define ZYNQMP_SIP_SVC_PM_SECURE_IMG_LOAD \ + (PM_SIP_SVC + PM_SECURE_IMAGE) + +#define ZYNQMP_PM_VERSION_MAJOR 1 +#define ZYNQMP_PM_VERSION_MINOR 0 +#define ZYNQMP_PM_VERSION_MAJOR_SHIFT 16 +#define ZYNQMP_PM_VERSION_MINOR_MASK 0xFFFF + +#define ZYNQMP_PM_VERSION \ + ((ZYNQMP_PM_VERSION_MAJOR << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | \ + ZYNQMP_PM_VERSION_MINOR) + +#define ZYNQMP_PM_VERSION_INVALID ~0 + +#define PMUFW_V1_0 ((1 << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | 0) + +enum pm_api_id { + PM_GET_API_VERSION = 1, + PM_SET_CONFIGURATION, + PM_SECURE_IMAGE = 45, +}; + +unsigned int zynqmp_firmware_version(void); + +#endif /* _ZYNQMPPL_H_ */ From patchwork Fri Sep 27 13:35:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168520 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="gbLD2Eb6"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ftGp1Fkcz9sPK for ; Fri, 27 Sep 2019 23:40:50 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C4156C22056; Fri, 27 Sep 2019 13:35:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D258DC21FA5; Fri, 27 Sep 2019 13:35:47 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A47BCC21F34; Fri, 27 Sep 2019 13:35:31 +0000 (UTC) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by lists.denx.de (Postfix) with ESMTPS id 1E974C21FAC for ; Fri, 27 Sep 2019 13:35:29 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id r19so6641870wmh.2 for ; Fri, 27 Sep 2019 06:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=yWfkAlXsQs5cHEJC3+GFT4EXzadwBL85n6mY/O5cNC4=; b=gbLD2Eb6ujtdEguHuUVsTAjORIdBDF6A2yYQodTR0D9Uy0zN7xhgUXXn2pTw9buYX9 XfYoDX17VDk+K97EgrF9DcMWUtK+mUHygqsr98ZqP7wZKNjaXNfRyzZDElGspXyyTRWt ndgm05PF6GPWhVVE78RjzCvQ6tEPPjyp7xjoqi/UGpohaFdkwgXmo6Qf6wXor9touAaE IpqLnkWJ3pg9A6JDeLKtcJpaJjSYGz0GX6oR0rfQ4ueXVq+L7UXGvoY3tDGmi5GPxott +FCOtsnwWRNQRo+wOkiZyr6uOuAxhUXNVDvm/OxsXOmR8nxdkzqwb1Yv9IFhzWEKkySz oIsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=yWfkAlXsQs5cHEJC3+GFT4EXzadwBL85n6mY/O5cNC4=; b=iqhARBKqJfJCy2DQClyU5Cdm+VSUM3Yrusu7OVPDUC+194zpA4QS6TUpjp2GsRSk13 zas1hNRW4pQa8aYay3iiBTILkwiYAHV+oJCSarii+FXOEhvpK4GczH5Tmku+F0sRIY+n rh0ZCEGDOqnoT2uHpX3DNGuGjcNOaE0kSTEk6DH1hSiINYNwlciw7fFTKCD/hlJJwKWW AF0SYjrpg0r+V0/YKVZUSFbMM3F+gfhWlLBn8ZRY1DppfeldroV1BXT5RSRXVfH2TGj8 /QA4bSiZtYX14LFz4mZ/pFx+Cv0YCBD3PGaCreUxsNjPpgYqAUCa18MSqEFdjiIlZZ1h k8Xg== X-Gm-Message-State: APjAAAX1LV4rMRTuh/l4bquJv7V4wDyTukzqSMqLb5E+6853c6RGCOHA DSXDj++lu3XWt04wPI9PEriX34i9VZ9fCw== X-Google-Smtp-Source: APXvYqwexiBem81TX79pBHtFPDyhPbpCb4YPCzKigVsFj4lhz9t+n2sZwcejryVqtSyCMKecgIVkXw== X-Received: by 2002:a1c:cf05:: with SMTP id f5mr7191501wmg.131.1569591328453; Fri, 27 Sep 2019 06:35:28 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id z13sm2828793wrq.51.2019.09.27.06.35.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:27 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:35:00 +0200 Message-Id: <86a013f5480c5f811075dc4d218f8fa7fd2df6cf.1569591296.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: ibai.erkiaga-elorza@xilinx.com, luca@lucaceresoli.net Subject: [U-Boot] [PATCH 09/13] arm64: zynqmp: use firmware driver to get version X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Ibai Erkiaga Use the new function from firmware version to get the firmware version. Signed-off-by: Ibai Erkiaga Signed-off-by: Michal Simek --- board/xilinx/zynqmp/zynqmp.c | 2 +- drivers/fpga/zynqmppl.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index d9186f463f20..8a66d3e50aad 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -321,7 +321,7 @@ int board_early_init_f(void) #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_CLK_ZYNQMP) u32 pm_api_version; - pm_api_version = zynqmp_pmufw_version(); + pm_api_version = zynqmp_firmware_version(); printf("PMUFW:\tv%d.%d\n", pm_api_version >> ZYNQMP_PM_VERSION_MAJOR_SHIFT, pm_api_version & ZYNQMP_PM_VERSION_MINOR_MASK); diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c index 6168626aeef3..c2670271c8ea 100644 --- a/drivers/fpga/zynqmppl.c +++ b/drivers/fpga/zynqmppl.c @@ -152,7 +152,7 @@ static ulong zynqmp_align_dma_buffer(u32 *buf, u32 len, u32 swap) buf = new_buf; } else if ((swap != SWAP_DONE) && - (zynqmp_pmufw_version() <= PMUFW_V1_0)) { + (zynqmp_firmware_version() <= PMUFW_V1_0)) { /* For bitstream which are aligned */ new_buf = buf; @@ -205,7 +205,7 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize, u32 ret_payload[PAYLOAD_ARG_CNT]; bool xilfpga_old = false; - if (zynqmp_pmufw_version() <= PMUFW_V1_0) { + if (zynqmp_firmware_version() <= PMUFW_V1_0) { puts("WARN: PMUFW v1.0 or less is detected\n"); puts("WARN: Not all bitstream formats are supported\n"); puts("WARN: Please upgrade PMUFW\n"); From patchwork Fri Sep 27 13:35:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168521 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="nb9yA00N"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ftH63K2tz9sPY for ; Fri, 27 Sep 2019 23:41:06 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id CD036C21FDE; Fri, 27 Sep 2019 13:35:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 42C12C21FC1; Fri, 27 Sep 2019 13:35:47 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BAB6FC21FC0; Fri, 27 Sep 2019 13:35:33 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by lists.denx.de (Postfix) with ESMTPS id 5EDB4C21FB9 for ; Fri, 27 Sep 2019 13:35:31 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id i18so2744085wru.11 for ; Fri, 27 Sep 2019 06:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=KXJaJOL3MXV+1LbiKWDkkTlqaOHESTui3pUW6KalQoM=; b=nb9yA00Neug0erLzU09w2xDcI+dlYYdr/k5RzdtnWCzaJFabp2GdWFiJhqlNaE0Lix 9I8fs7JtnmPPi9PaGqwkYmqVqZYdmKbigB4ryNiB44kjO1OdPFLiEZUfXAQQh3IG8FUa NsNjtRzZPk4nhB8/tZ1NDottstTjZzGl9H9hODQvsXd0khyn7kkot8H5dZApP+nQgVLN V50egcVlBWbvJ60bfS7sEe2AQ4/2mu+dIgdf99gndSZANKITiKEBO4JgSDy/qVtAczfI J+KlUXjQmIBi9YDrqV8g5srTNYEbOSZI7Y5fP6h1BY1M0buZaJmcX/v8N2E3lBltS7oY KI1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=KXJaJOL3MXV+1LbiKWDkkTlqaOHESTui3pUW6KalQoM=; b=lyDrTNI1fBC99PNlKYNEh9PwPg2QhfehLA7l3c4zBzlCovgu3Oz8IgrzQ2/xKO2IZz 2p7tCWDJwwcfeXWolijSgJuQo68WuucaCR+aay3LR5rvbugq1FHRkAghaby1q2juldaa PWT/Kdat3O09fsMSIuSHD68Ki9qHpvG6StU9+iUkKdqui8asvw1o20n7XMK+kYOx49uF 5sQc5behXNUnfXpO9x2WM8c3/ZKdWjzrKUdMJsxKSn51ylT/Lg1yh0BvBPOVkhprmyPe KzrjUs2HljUA9YxODmS8S6+BzyY4PLBQvPux/M2CJU2Ptdb56MldpOIm98mJBrkpsi8A FkSA== X-Gm-Message-State: APjAAAUvRj7abMwnnGbk7Sj7k+25eq/E2DGDm4ZpKvqemRh0EfQ2pxX6 FqjOUCXma37wPe400Try52dWBDzJZfekYw== X-Google-Smtp-Source: APXvYqy6FAKs9L8cju9LO7TFILoGIEExnikem9rN6clY2Nw1JU4AKuBpgrHj7X317MVu837CNvYVcw== X-Received: by 2002:adf:ec44:: with SMTP id w4mr2892206wrn.251.1569591330492; Fri, 27 Sep 2019 06:35:30 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id t6sm10592499wmf.8.2019.09.27.06.35.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:29 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:35:01 +0200 Message-Id: <2650fcd70e642a1ea02e160d1aca11f65f8a7955.1569591296.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: ibai.erkiaga-elorza@xilinx.com, luca@lucaceresoli.net Subject: [U-Boot] [PATCH 10/13] arm64: zynqmp: remove old fw version function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Ibai Erkiaga Removes the old function to get the firmware version. Signed-off-by: Ibai Erkiaga Signed-off-by: Michal Simek --- arch/arm/mach-zynqmp/cpu.c | 23 ------------------- arch/arm/mach-zynqmp/include/mach/sys_proto.h | 1 - 2 files changed, 24 deletions(-) diff --git a/arch/arm/mach-zynqmp/cpu.c b/arch/arm/mach-zynqmp/cpu.c index f28b964a1560..bb21cbcadf69 100644 --- a/arch/arm/mach-zynqmp/cpu.c +++ b/arch/arm/mach-zynqmp/cpu.c @@ -180,29 +180,6 @@ int __maybe_unused invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, return regs.regs[0]; } -unsigned int __maybe_unused zynqmp_pmufw_version(void) -{ - int ret; - u32 ret_payload[PAYLOAD_ARG_CNT]; - static u32 pm_api_version = ZYNQMP_PM_VERSION_INVALID; - - /* - * Get PMU version only once and later - * just return stored values instead of - * asking PMUFW again. - */ - if (pm_api_version == ZYNQMP_PM_VERSION_INVALID) { - ret = invoke_smc(ZYNQMP_SIP_SVC_GET_API_VERSION, 0, 0, 0, 0, - ret_payload); - pm_api_version = ret_payload[1]; - - if (ret) - panic("PMUFW is not found - Please load it!\n"); - } - - return pm_api_version; -} - static int zynqmp_mmio_rawwrite(const u32 address, const u32 mask, const u32 value) diff --git a/arch/arm/mach-zynqmp/include/mach/sys_proto.h b/arch/arm/mach-zynqmp/include/mach/sys_proto.h index 658974445417..27603a60ff8f 100644 --- a/arch/arm/mach-zynqmp/include/mach/sys_proto.h +++ b/arch/arm/mach-zynqmp/include/mach/sys_proto.h @@ -48,7 +48,6 @@ unsigned int zynqmp_get_silicon_version(void); void handoff_setup(void); -unsigned int zynqmp_pmufw_version(void); int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 value); int zynqmp_mmio_read(const u32 address, u32 *value); int invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3, From patchwork Fri Sep 27 13:35:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168517 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="BZj1rBS/"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ftFq3467z9s4Y for ; Fri, 27 Sep 2019 23:39:57 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 391DBC22016; Fri, 27 Sep 2019 13:36:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 77936C21E2B; Fri, 27 Sep 2019 13:35:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C943CC21FB7; Fri, 27 Sep 2019 13:35:35 +0000 (UTC) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by lists.denx.de (Postfix) with ESMTPS id 231E0C21FA1 for ; Fri, 27 Sep 2019 13:35:33 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id r19so6642139wmh.2 for ; Fri, 27 Sep 2019 06:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=gABPeRFi+lQUn5RuqJEmVeS095KMBp2V7ctCA7i9UuU=; b=BZj1rBS/MwV3ouFsHjvAUfnG97SWNyjFi5vfUDNp6J6KGpsdetgdDfiRzUNVvS6n+f YYyHAmT0kZ4egNcM4Yi9+fwn2v8uMbvpJ6p1vkV6e1tnm2ftRD4cxAKRDT/qmZ+d1BZC 5G6MoAFoDhRbg65LH4V/NBih+sBNY6fetH9Xy8Ap8LCZLJiYfhyqkW+sA6HOX5GLbUqm 681Qn8hLVG3qxw2CW1lINwyNlFyi37eJ68mlU0TEFOGrhF8HvVmlfuFQh9WXPO+4/t5K ErSjUwB9IowI68o8U6sZpMQgTuI+hVLIZi2a0cJ0tf3uzicNrOGm/YDlLgmmI5BodpKr crfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=gABPeRFi+lQUn5RuqJEmVeS095KMBp2V7ctCA7i9UuU=; b=EqBQh3Tt/e6MUw+0gsCr3qiiHTlDvh5j/xmjliqCuVtoFOGRIHC33/ifs/X7prXhZR 8VyAqwWSLf5uTjmwGfoIJpjZU2oyzXL1qrUV5P7VLAZwINIFH36bgByTCe71/m19gCjz qNbbY93XxAkb9O8icivAqhC/r3KPeyF+Y1qZ/z6WZm5ZhAFj5E7RQ8P24+GL5BauCQ66 X4wKSLnj0I3MEaJD7K+fGU6obw8jf7FC/0LHUmB4FnTqb974+j3AItE0nKCQDsUlwMxP A7aZCRkRtiE7XL79qhk3VAZKNFIFb2NK5RkCOXVivtBOY3+v/+Bk+7bUFKgsBhwtElbj zyNg== X-Gm-Message-State: APjAAAX5CFIy34HiqU9jgi5xqUn3ar6/fa7xhqL1eBMN/UvOeZMMDjuA eYgrSpMJmYJILEuHLp9+LJqfjnYC8ajqlw== X-Google-Smtp-Source: APXvYqx9RNrNxPuLiC2wAymD3s9uklr+WfPLb1bUdj+KRVt0HxkzU6Rnh5H7UkkCeJ/nbT3NsxSOxQ== X-Received: by 2002:a05:600c:2246:: with SMTP id a6mr7421788wmm.95.1569591332508; Fri, 27 Sep 2019 06:35:32 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id t203sm9818540wmf.42.2019.09.27.06.35.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:31 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:35:02 +0200 Message-Id: <64411c9e35d017fe79aa04cfa41a64aef5fbb932.1569591296.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: ibai.erkiaga-elorza@xilinx.com, luca@lucaceresoli.net Subject: [U-Boot] [PATCH 11/13] arm64: zynqmp: probe firmware driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Ibai Erkiaga Probe ZynqMP firmware driver on the board initialization phase and ensure that firmware is in place to continue execution. The probing is done on board_init so it can be used for both SPL and U-Boot proper. Signed-off-by: Ibai Erkiaga Signed-off-by: Michal Simek --- arch/arm/Kconfig | 3 +++ board/xilinx/zynqmp/zynqmp.c | 18 ++++++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 257a98d795e5..e4ec703139de 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1056,9 +1056,12 @@ config ARCH_ZYNQMP select DM_SPI if SPI select DM_SPI_FLASH if DM_SPI select DM_USB if USB + select FIRMWARE select OF_CONTROL select SPL_BOARD_INIT if SPL select SPL_CLK if SPL + select SPL_DM_MAILBOX if SPL + select SPL_FIRMWARE if SPL select SPL_SEPARATE_BSS if SPL select SUPPORT_SPL imply BOARD_LATE_INIT diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 8a66d3e50aad..b94936474d7e 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -318,18 +318,6 @@ static char *zynqmp_get_silicon_idcode_name(void) int board_early_init_f(void) { int ret = 0; -#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_CLK_ZYNQMP) - u32 pm_api_version; - - pm_api_version = zynqmp_firmware_version(); - printf("PMUFW:\tv%d.%d\n", - pm_api_version >> ZYNQMP_PM_VERSION_MAJOR_SHIFT, - pm_api_version & ZYNQMP_PM_VERSION_MINOR_MASK); - - if (pm_api_version < ZYNQMP_PM_VERSION) - panic("PMUFW version error. Expected: v%d.%d\n", - ZYNQMP_PM_VERSION_MAJOR, ZYNQMP_PM_VERSION_MINOR); -#endif #if defined(CONFIG_ZYNQMP_PSU_INIT_ENABLED) ret = psu_init(); @@ -340,6 +328,12 @@ int board_early_init_f(void) int board_init(void) { + struct udevice *dev; + + uclass_get_device_by_name(UCLASS_FIRMWARE, "zynqmp-power", &dev); + if (!dev) + panic("PMU Firmware device not found - Enable it"); + #if defined(CONFIG_SPL_BUILD) /* Check *at build time* if the filename is an non-empty string */ if (sizeof(CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE) > 1) From patchwork Fri Sep 27 13:35:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168525 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="TFaG2aAq"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ftJQ3cvfz9sDB for ; Fri, 27 Sep 2019 23:42:14 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1D479C21FAB; Fri, 27 Sep 2019 13:40:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5B5D2C21FDE; Fri, 27 Sep 2019 13:40:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DB0D2C22032; Fri, 27 Sep 2019 13:35:37 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by lists.denx.de (Postfix) with ESMTPS id 2F016C21FB7 for ; Fri, 27 Sep 2019 13:35:35 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id y19so2792402wrd.3 for ; Fri, 27 Sep 2019 06:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=km9+6fzVK2OwWg/oeFsMDBUnO52rn5MaZMAT6ePwWvE=; b=TFaG2aAqX46SN7NSkmi9XICbxxa+h7KS2rikv2POF7sdXdfoXG3rQptesfv8z2MMJX /kis1LRPzg8xoi5X/ExAi6S3hAiikDB1ODt5ZT6jw50Qde4m8cNk/m8KnvS/yOJWHZU5 VeD6H3yu2laIBhOp7M6ZrEv3Je91hk3TYj792ywNk/50SSav+OZknbY97VjcBdwDMO/H 8QFi9lLlXALX5kctDrwIzZDfQdXQJS5om7DLj9OZl5hLNfVzg/5AfK3sAlfqOYKYfJWM Xh5SjPmfW/Jz+r9MYu6dvalmNc3wgl/w7DR7V5QI4//WbFch1tbVyNCTgfWhb36TwCf/ XEwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=km9+6fzVK2OwWg/oeFsMDBUnO52rn5MaZMAT6ePwWvE=; b=MuD7dNgIHgHqf0Wpp/QI0hfFWVilnx9CSFWVpMBGF7COKogSv39ghNCqEPveA4gsUz 23q2EIGnMMm/GVp9M7dP2DplqSSZ2kmUIh6BX8LjyvIQ2Cyw5h0dzL2aJeUrHlfpz5Yk nGlxAEhCc9gbkdEGtv3jg8hL1eKqSz0LDIe0h0xHtgVUrKzweWTlXY/ttLiA4N6+nqKO 5jj0DACrIw7ymYXwX61RmWpGuyhIiKkOtIhCyyWltzDx3Fni2uvWL7kicq8a9KFaWXfZ /uTzvao4x4ZD5bmLQsTt4Gyuh/gN6rWCgKE74EDn9rwwvSEzOTWjVjCJKeD0Pbk55HTQ QsCQ== X-Gm-Message-State: APjAAAUPGfyCPUkkLChr+6UC8sheUlH937/ZahWbI/rpip12AiOUexOH jqi0nXJKe+KMDRmHqtJ3//EfflD4743YsQ== X-Google-Smtp-Source: APXvYqzpMOHlslZ0aHI2/GbpvrxcKAaBoQuf7VZZRkJVDtYpVWeyQMRfa/ZpJuysKVxRJ+pSm5RWoA== X-Received: by 2002:a05:6000:1002:: with SMTP id a2mr3037785wrx.272.1569591334534; Fri, 27 Sep 2019 06:35:34 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id g185sm12628031wme.10.2019.09.27.06.35.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:33 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:35:03 +0200 Message-Id: <3bf20ccc54d5d8fa1951cfa7546fd1f0113727dd.1569591296.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: ibai.erkiaga-elorza@xilinx.com, luca@lucaceresoli.net, Rajan Vaja Subject: [U-Boot] [PATCH 12/13] firmware: zynqmp: Separate function for sending message via mailbox X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" U-Boot running in EL3 can't use SMC that's why there is a need to talk to PMUFW directly via mailbox. The same logic is applied to all functions which need to talk to PMUFW that's why move this logic to separate function to avoid code duplication. Also SMC request ID can be composed from PM_SIP_SVC offset that's why ZYNQMP_SIP_SVC_GET_API_VERSION macro can be removed completely. Signed-off-by: Michal Simek --- drivers/firmware/firmware-zynqmp.c | 19 ++++++++++--------- include/zynqmp_firmware.h | 2 -- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c index d70f34f24388..b7e3039c8337 100644 --- a/drivers/firmware/firmware-zynqmp.c +++ b/drivers/firmware/firmware-zynqmp.c @@ -40,6 +40,14 @@ static int ipi_req(const u32 *req, size_t req_len, u32 *res, size_t res_maxlen) return 0; } +static int send_req(const u32 *req, size_t req_len, u32 *res, size_t res_maxlen) +{ + if (IS_ENABLED(CONFIG_SPL_BUILD)) + return ipi_req(req, req_len, res, 2); + + return invoke_smc(req[0] + PM_SIP_SVC, 0, 0, 0, 0, res); +} + unsigned int zynqmp_firmware_version(void) { int ret; @@ -52,16 +60,9 @@ unsigned int zynqmp_firmware_version(void) * asking PMUFW again. **/ if (pm_api_version == ZYNQMP_PM_VERSION_INVALID) { - if (IS_ENABLED(CONFIG_SPL_BUILD)) { - const u32 request[] = { PM_GET_API_VERSION }; - - ret = ipi_req(request, ARRAY_SIZE(request), - ret_payload, 2); - } else { - ret = invoke_smc(ZYNQMP_SIP_SVC_GET_API_VERSION, 0, 0, - 0, 0, ret_payload); - }; + const u32 request[] = { PM_GET_API_VERSION }; + ret = send_req(request, ARRAY_SIZE(request), ret_payload, 2); if (ret) panic("PMUFW is not found - Please load it!\n"); diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h index c522cae8399b..1fbc82414ab5 100644 --- a/include/zynqmp_firmware.h +++ b/include/zynqmp_firmware.h @@ -9,8 +9,6 @@ #define _ZYNQM_FIRMWARE_H_ #define PM_SIP_SVC 0xc2000000 -#define ZYNQMP_SIP_SVC_GET_API_VERSION \ - (PM_SIP_SVC + PM_GET_API_VERSION) #define ZYNQMP_SIP_SVC_PM_SECURE_IMG_LOAD \ (PM_SIP_SVC + PM_SECURE_IMAGE) From patchwork Fri Sep 27 13:35:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1168524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="0WsJfJhn"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ftJ06MGtz9sDB for ; Fri, 27 Sep 2019 23:41:52 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4283CC21FEF; Fri, 27 Sep 2019 13:40:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 74868C21FDE; Fri, 27 Sep 2019 13:40:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CD1BCC22044; Fri, 27 Sep 2019 13:35:39 +0000 (UTC) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by lists.denx.de (Postfix) with ESMTPS id 5F2B4C21EF1 for ; Fri, 27 Sep 2019 13:35:37 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id i18so2744480wru.11 for ; Fri, 27 Sep 2019 06:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=EqF7sU8FJdSj5eCYoupJYrCXPwh4JjnwrlUe4qjZnnc=; b=0WsJfJhnMLg/UEg/b+Hdb+J3BOGHKVeEVL/hyxWjVtiUCjF2p60RKtg0gEIT1K2U4m huJk0QP0AlICYCal1lICx2haIZUEv9vFsdOtL+j7vR1m4lg5SOEqDXeb2NioNoFWJeZr S3TvThh2sPmo7eBv49MU5hI7LQoNEn6ofrxcaHM0p1i+VRwBeBGAaeR2OwV+VrsIWvXM R1j1r9pd/G95Tvvf/Xzkxetzrpkv3G4gxFAjxGEuSxOLQyNqR9UhXuqzD6eZc6vbrvK7 BELD5MSmKqA5zzKNOYgE8+N6KEYUNWi7A/OGkkFBvjMfPEA/FQcqEOI3C6igEEVapD+O N0Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=EqF7sU8FJdSj5eCYoupJYrCXPwh4JjnwrlUe4qjZnnc=; b=Z0U4dkMCEkcf+edyu0yJm/wR1pqPqugaNuBL3YWbPelu9QdxTecAeDx473dPnvLpV+ JhjM4yfe04kV4jb5d1QvAZHcuWx1x3VsF9HcVbKYqmjx8XlEfvSX+sAEmnQ1kdRpq1zb VzoY8srFf/mJczWWW1TIma+aA/ukW0lfV2dbF1CU9moMAfGgPqs1+H4qSCRWYQjeWWFc vPTwP3Ii18L2xsdSR4DNxMLV1TAdK+JhJY+QRhzNRgr9DgjI9KFxZPt01uRQaiXakA5I 9JtuvF/lGr/Q7Gxo/ztWF4TubOlH1w3pM41byTyAiubqFzEJfVJDofQuOxGU7P9c5xoY ravw== X-Gm-Message-State: APjAAAVOKdOFt8anRYsEg/TSRXoSYGgpIq6sSZzOE31i8/g0YEG7QcsX gtPcMk272HSAMoEEJImV6K5n3VFCU/lOGA== X-Google-Smtp-Source: APXvYqwOwRvCUbKbheKnxGIRN+KymJRXdzLRky6n95Wk2bYAV9tKbNpf0oxVf7ptFqTxH2A7c6unkQ== X-Received: by 2002:a05:6000:1184:: with SMTP id g4mr3044753wrx.361.1569591336587; Fri, 27 Sep 2019 06:35:36 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id e3sm7368525wme.39.2019.09.27.06.35.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2019 06:35:35 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 27 Sep 2019 15:35:04 +0200 Message-Id: <08486860a74cfe89b1d017621b36043b26e995c8.1569591296.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: Rajan Vaja , luca@lucaceresoli.net, ibai.erkiaga-elorza@xilinx.com Subject: [U-Boot] [PATCH 13/13] arm64: zynqmp: Use mailbox driver for PMUFW config loading X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" With new mailbox driver PMUFW configuration object can be loaded via the same interface and there is no need to have pmu_ipc.c completely. Signed-off-by: Michal Simek Reviewed-by: Luca Ceresoli --- arch/arm/mach-zynqmp/Makefile | 4 - arch/arm/mach-zynqmp/include/mach/sys_proto.h | 2 - arch/arm/mach-zynqmp/pmu_ipc.c | 112 ------------------ drivers/firmware/firmware-zynqmp.c | 24 ++++ include/zynqmp_firmware.h | 1 + 5 files changed, 25 insertions(+), 118 deletions(-) delete mode 100644 arch/arm/mach-zynqmp/pmu_ipc.c diff --git a/arch/arm/mach-zynqmp/Makefile b/arch/arm/mach-zynqmp/Makefile index f3765e45b1b9..8a3b0747244a 100644 --- a/arch/arm/mach-zynqmp/Makefile +++ b/arch/arm/mach-zynqmp/Makefile @@ -8,7 +8,3 @@ obj-y += cpu.o obj-$(CONFIG_MP) += mp.o obj-$(CONFIG_SPL_BUILD) += spl.o handoff.o obj-$(CONFIG_ZYNQMP_PSU_INIT_ENABLED) += psu_spl_init.o - -ifneq ($(CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE),"") -obj-$(CONFIG_SPL_BUILD) += pmu_ipc.o -endif diff --git a/arch/arm/mach-zynqmp/include/mach/sys_proto.h b/arch/arm/mach-zynqmp/include/mach/sys_proto.h index 27603a60ff8f..69e729fb7625 100644 --- a/arch/arm/mach-zynqmp/include/mach/sys_proto.h +++ b/arch/arm/mach-zynqmp/include/mach/sys_proto.h @@ -60,6 +60,4 @@ int chip_id(unsigned char id); void tcm_init(u8 mode); #endif -void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size); - #endif /* _ASM_ARCH_SYS_PROTO_H */ diff --git a/arch/arm/mach-zynqmp/pmu_ipc.c b/arch/arm/mach-zynqmp/pmu_ipc.c deleted file mode 100644 index d8858ea3ff99..000000000000 --- a/arch/arm/mach-zynqmp/pmu_ipc.c +++ /dev/null @@ -1,112 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Inter-Processor Communication with the Platform Management Unit (PMU) - * firmware. - * - * (C) Copyright 2019 Luca Ceresoli - * Luca Ceresoli - */ - -#include -#include -#include - -/* IPI bitmasks, register base and register offsets */ -#define IPI_BIT_MASK_APU 0x00001 -#define IPI_BIT_MASK_PMU0 0x10000 -#define IPI_REG_BASE_APU 0xFF300000 -#define IPI_REG_BASE_PMU0 0xFF330000 -#define IPI_REG_OFFSET_TRIG 0x00 -#define IPI_REG_OFFSET_OBR 0x04 - -/* IPI mailbox buffer offsets */ -#define IPI_BUF_BASE_APU 0xFF990400 -#define IPI_BUF_OFFSET_TARGET_PMU 0x1C0 -#define IPI_BUF_OFFSET_REQ 0x00 -#define IPI_BUF_OFFSET_RESP 0x20 - -#define PMUFW_PAYLOAD_ARG_CNT 8 - -/* PMUFW commands */ -#define PMUFW_CMD_SET_CONFIGURATION 2 - -static void pmu_ipc_send_request(const u32 *req, size_t req_len) -{ - u32 *mbx = (u32 *)(IPI_BUF_BASE_APU + - IPI_BUF_OFFSET_TARGET_PMU + - IPI_BUF_OFFSET_REQ); - size_t i; - - for (i = 0; i < req_len; i++) - writel(req[i], &mbx[i]); -} - -static void pmu_ipc_read_response(unsigned int *value, size_t count) -{ - u32 *mbx = (u32 *)(IPI_BUF_BASE_APU + - IPI_BUF_OFFSET_TARGET_PMU + - IPI_BUF_OFFSET_RESP); - size_t i; - - for (i = 0; i < count; i++) - value[i] = readl(&mbx[i]); -} - -/** - * Send request to PMU and get the response. - * - * @req: Request buffer. Byte 0 is the API ID, other bytes are optional - * parameters. - * @req_len: Request length in number of 32-bit words. - * @res: Response buffer. Byte 0 is the error code, other bytes are - * optional parameters. Optional, if @res_maxlen==0 the parameters - * will not be read. - * @res_maxlen: Space allocated for the response in number of 32-bit words. - * - * @return Error code returned by the PMU (i.e. the first word of the response) - */ -static int pmu_ipc_request(const u32 *req, size_t req_len, - u32 *res, size_t res_maxlen) -{ - u32 status; - - if (req_len > PMUFW_PAYLOAD_ARG_CNT || - res_maxlen > PMUFW_PAYLOAD_ARG_CNT) - return -EINVAL; - - pmu_ipc_send_request(req, req_len); - - /* Raise Inter-Processor Interrupt to PMU and wait for response */ - writel(IPI_BIT_MASK_PMU0, IPI_REG_BASE_APU + IPI_REG_OFFSET_TRIG); - do { - status = readl(IPI_REG_BASE_APU + IPI_REG_OFFSET_OBR); - } while (status & IPI_BIT_MASK_PMU0); - - pmu_ipc_read_response(res, res_maxlen); - - return 0; -} - -/** - * Send a configuration object to the PMU firmware. - * - * @cfg_obj: Pointer to the configuration object - * @size: Size of @cfg_obj in bytes - */ -void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size) -{ - const u32 request[] = { - PMUFW_CMD_SET_CONFIGURATION, - (u32)((u64)cfg_obj) - }; - u32 response; - int err; - - printf("Loading PMUFW cfg obj (%ld bytes)\n", size); - - err = pmu_ipc_request(request, ARRAY_SIZE(request), &response, 1); - if (err) - panic("Cannot load PMUFW configuration object (%d)\n", err); - if (response != 0) - panic("PMUFW returned 0x%08x status!\n", response); -} diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c index b7e3039c8337..7712019ec69c 100644 --- a/drivers/firmware/firmware-zynqmp.c +++ b/drivers/firmware/firmware-zynqmp.c @@ -75,6 +75,30 @@ unsigned int zynqmp_firmware_version(void) return pm_api_version; }; +/** + * Send a configuration object to the PMU firmware. + * + * @cfg_obj: Pointer to the configuration object + * @size: Size of @cfg_obj in bytes + */ +void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size) +{ + const u32 request[] = { + PM_SET_CONFIGURATION, + (u32)((u64)cfg_obj) + }; + u32 response; + int err; + + printf("Loading new PMUFW cfg obj (%ld bytes)\n", size); + + err = send_req(request, ARRAY_SIZE(request), &response, 1); + if (err) + panic("Cannot load PMUFW configuration object (%d)\n", err); + if (response != 0) + panic("PMUFW returned 0x%08x status!\n", response); +} + static int zynqmp_power_probe(struct udevice *dev) { int ret = 0; diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h index 1fbc82414ab5..2622a57e681e 100644 --- a/include/zynqmp_firmware.h +++ b/include/zynqmp_firmware.h @@ -32,5 +32,6 @@ enum pm_api_id { }; unsigned int zynqmp_firmware_version(void); +void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size); #endif /* _ZYNQMPPL_H_ */