Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp816143ybg; Fri, 12 Jun 2020 15:52:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZ3ev+EMv6Blu/uZbV6nDEvn4hF444eiDS29yLNEv/Iqgj1eLoMAFzlMiQNRlj/BCIwNQp X-Received: by 2002:a17:906:22cc:: with SMTP id q12mr15980588eja.485.1592002329148; Fri, 12 Jun 2020 15:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592002329; cv=none; d=google.com; s=arc-20160816; b=iJ0RnmvB53uo6uepum02PaIvjp8NGF4VPVO3n2zVPNEu8obpHqPLDikmCHIXXUdEBK TFtXHAcxz0HGofwbBK07EbCYLSTD+hjAfzC9XROgvlgNAOwkW/9i+kFVuy6BUQUuLcFH SD1+BeGUGqRNY4JW6f8hsMwbO9oD+LNjQHlkTESDSMp5V1MfuXgOEebXIsG+0uzUz1uq ubcNZCoJvoaLzyo7NbvbApJ9SHcBjMWknsyznnzMd1WyFmZ5uF7UJsnXDCqJdWm96z6u 6To5A+C8EopKVsIN2pZLifzRrvBSkcqv8dKbkwcuL5Mv5F7eitcHnyqTPoStJsCwq8oF x4KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dJfNet5z/jwMk1KyTLxkDrBpDH/7oBNjz2rfy7DYy2k=; b=z6sKt+uiEqdOdGRsSWspluGVx5/xZ+r7hFSigs0Yrkxl8gFuPIw5TNTXINC/IWlE8Y SOZd8w8tz3nZM/sZY1S6feDK4XCpS3PRFPebp2f7OBNh0OOwT3AcOf2JSxzwV9bFnIED l4+CCTn0k7u44BYHdTAlnveypdPUntdFoQkmmSzYUvOzL+j3147QBXOFi2V9itHFfLG8 G6i2nZOqWr8JiPO+GEb5XVMnuuBE/B/YVNOGWBfKnSc/5v1Uc3c87byA5qxhJfeeTqYH cgc6MIgYGbIP5/MyhIBnIh0ezYV4oV7yi9KR9o6z/gove7Jy86pQmQN/dIquDocVEfRo TjsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=lR6+haSK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u21si4268456edq.299.2020.06.12.15.51.47; Fri, 12 Jun 2020 15:52:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=lR6+haSK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726483AbgFLWtu (ORCPT + 99 others); Fri, 12 Jun 2020 18:49:50 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:49212 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbgFLWti (ORCPT ); Fri, 12 Jun 2020 18:49:38 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 05CMnW69103516; Fri, 12 Jun 2020 17:49:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1592002172; bh=dJfNet5z/jwMk1KyTLxkDrBpDH/7oBNjz2rfy7DYy2k=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=lR6+haSK7Q96LT+l3dgEHmT3JM9s7Op/GiuFx8ZW0aTA16ULzKblbmVpmdDyeCdAk 4EigFPgX5On2KBpD8NSdXG1yR+MvWFDgVSL99Y8INp7b89h5stoYQE4Vxrud0aAjc2 jef3So1ghR/1D0Z4x6xsneilteNme/evCfQlwOTc= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 05CMnW1f119692 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Jun 2020 17:49:32 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Fri, 12 Jun 2020 17:49:32 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Fri, 12 Jun 2020 17:49:32 -0500 Received: from fllv0103.dal.design.ti.com (fllv0103.dal.design.ti.com [10.247.120.73]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 05CMnW0e112307; Fri, 12 Jun 2020 17:49:32 -0500 Received: from localhost ([10.250.48.148]) by fllv0103.dal.design.ti.com (8.14.7/8.14.7) with ESMTP id 05CMnWtG062201; Fri, 12 Jun 2020 17:49:32 -0500 From: Suman Anna To: Bjorn Andersson , Rob Herring , Mathieu Poirier CC: Lokesh Vutla , Grzegorz Jaszczyk , , , , , Suman Anna Subject: [PATCH v3 6/6] remoteproc: k3-dsp: Add support for L2RAM loading on C66x DSPs Date: Fri, 12 Jun 2020 17:49:14 -0500 Message-ID: <20200612224914.7634-7-s-anna@ti.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200612224914.7634-1-s-anna@ti.com> References: <20200612224914.7634-1-s-anna@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The resets for the DSP processors on K3 SoCs are managed through the Power and Sleep Controller (PSC) module. Each DSP typically has two resets - a global module reset for powering on the device, and a local reset that affects only the CPU while allowing access to the other sub-modules within the DSP processor sub-systems. The C66x DSPs have two levels of internal RAMs that can be used to boot from, and the firmware loading into these RAMs require the local reset to be asserted with the device powered on/enabled using the module reset. Enhance the K3 DSP remoteproc driver to add support for loading into the internal RAMs. The local reset is deasserted on SoC power-on-reset, so logic has to be added in probe in remoteproc mode to balance the remoteproc state-machine. Note that the local resets are a no-op on C71x cores, and the hardware does not supporting loading into its internal RAMs. Signed-off-by: Suman Anna Reviewed-by: Bjorn Andersson Reviewed-by: Mathieu Poirier --- v3: No code changes, picked up review tags, switched to : in patch title v2: https://patchwork.kernel.org/patch/11561785/ drivers/remoteproc/ti_k3_dsp_remoteproc.c | 72 +++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 2f8b3ff5427d..668bb45b3fe8 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -175,6 +175,9 @@ static int k3_dsp_rproc_reset(struct k3_dsp_rproc *kproc) return ret; } + if (kproc->data->uses_lreset) + return ret; + ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, kproc->ti_sci_id); if (ret) { @@ -192,6 +195,9 @@ static int k3_dsp_rproc_release(struct k3_dsp_rproc *kproc) struct device *dev = kproc->dev; int ret; + if (kproc->data->uses_lreset) + goto lreset; + ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, kproc->ti_sci_id); if (ret) { @@ -199,6 +205,7 @@ static int k3_dsp_rproc_release(struct k3_dsp_rproc *kproc) return ret; } +lreset: ret = reset_control_deassert(kproc->reset); if (ret) { dev_err(dev, "local-reset deassert failed, ret = %d\n", ret); @@ -210,6 +217,53 @@ static int k3_dsp_rproc_release(struct k3_dsp_rproc *kproc) return ret; } +/* + * The C66x DSP cores have a local reset that affects only the CPU, and a + * generic module reset that powers on the device and allows the DSP internal + * memories to be accessed while the local reset is asserted. This function is + * used to release the global reset on C66x DSPs to allow loading into the DSP + * internal RAMs. The .prepare() ops is invoked by remoteproc core before any + * firmware loading, and is followed by the .start() ops after loading to + * actually let the C66x DSP cores run. + */ +static int k3_dsp_rproc_prepare(struct rproc *rproc) +{ + struct k3_dsp_rproc *kproc = rproc->priv; + struct device *dev = kproc->dev; + int ret; + + ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, + kproc->ti_sci_id); + if (ret) + dev_err(dev, "module-reset deassert failed, cannot enable internal RAM loading, ret = %d\n", + ret); + + return ret; +} + +/* + * This function implements the .unprepare() ops and performs the complimentary + * operations to that of the .prepare() ops. The function is used to assert the + * global reset on applicable C66x cores. This completes the second portion of + * powering down the C66x DSP cores. The cores themselves are only halted in the + * .stop() callback through the local reset, and the .unprepare() ops is invoked + * by the remoteproc core after the remoteproc is stopped to balance the global + * reset. + */ +static int k3_dsp_rproc_unprepare(struct rproc *rproc) +{ + struct k3_dsp_rproc *kproc = rproc->priv; + struct device *dev = kproc->dev; + int ret; + + ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, + kproc->ti_sci_id); + if (ret) + dev_err(dev, "module-reset assert failed, ret = %d\n", ret); + + return ret; +} + /* * Power up the DSP remote processor. * @@ -353,6 +407,8 @@ static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len) } static const struct rproc_ops k3_dsp_rproc_ops = { + .prepare = k3_dsp_rproc_prepare, + .unprepare = k3_dsp_rproc_unprepare, .start = k3_dsp_rproc_start, .stop = k3_dsp_rproc_stop, .kick = k3_dsp_rproc_kick, @@ -615,6 +671,22 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) goto release_tsp; } + /* + * ensure the DSP local reset is asserted to ensure the DSP doesn't + * execute bogus code in .prepare() when the module reset is released. + */ + if (data->uses_lreset) { + ret = reset_control_status(kproc->reset); + if (ret < 0) { + dev_err(dev, "failed to get reset status, status = %d\n", + ret); + goto release_mem; + } else if (ret == 0) { + dev_warn(dev, "local reset is deasserted for device\n"); + k3_dsp_rproc_reset(kproc); + } + } + ret = rproc_add(rproc); if (ret) { dev_err(dev, "failed to add register device with remoteproc core, status = %d\n", -- 2.26.0