From patchwork Tue Apr 2 13:37:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 161627 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1758626jan; Tue, 2 Apr 2019 06:38:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZOjzzj9Lh+Ks0ztOvkpbUbguaT1sQVajr7l8SOkVGHYcWaJW2r4ceTV4H8eQvrtO+Pgzu X-Received: by 2002:a63:1064:: with SMTP id 36mr39266495pgq.155.1554212292206; Tue, 02 Apr 2019 06:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554212292; cv=none; d=google.com; s=arc-20160816; b=k4DRmpPYwBzfW/Pbi1b9eci34nyi5ArKS2AcENLgGRKDEa8LwcOWe03NQieepzH6zr OULj4oh71JidKEWiEBBw0E+DvV9bBQl+3GpQwHcB4P7RHv/Cllt6YH2TbeIKrzr+Zyvj /aMOo61ceGUqSFizC8QnjctTQdDBuVajKG+Mdy/25WEXr1ouuE/kc3FT3r4o4iie558e fmZnVp7G2CwwNAPoaKTrIR24rB4O4hbt8zwhghm6msfcpq6Su/N4btCqo8Pgpcin6rRg DYqB8x8ByCNmm9enIfhy3IVwTsADwXhVsgUrdzAetAQhgtX3psYgZvC2rCG/kd8G7ivB jV1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=0/edQbd/JCK6PPPftxF7RTw4Vc6XeooZElbDVEEf+4M=; b=H6RxOMGGf+tLwhwsQeyt3zZiXzlXoo/b5A3s/8Gh0SN6JxVWd3D0hTJT1viBvE0qOl ZZpd7HpBu/vGk5J1DGF9ZWUhM7FC8/A64UIXn9jMWaRVXCUmVGieGOnqvmWXuPn3hl8q whLG8oz+K/dr5YH3U+42KbhdwpZYXFnILHhJsdEBTXbulMDORiGTly79dfktlzO8s6gt lOF5dnPn0gvqF5P9s7X9na1ms82ZahfXJAtVE/GOtf1E0ghhHWXG9uMVMKIxNIXJWV9M r5DLMfRi309mdpBMxXPZiaxM89Ml6xr/7+iVzTsHczOFbhiKCFjhja1YZndSCCrntqJ4 P2SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CxGlve3a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id f11si11113345pgf.406.2019.04.02.06.38.11; Tue, 02 Apr 2019 06:38:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CxGlve3a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730738AbfDBNiK (ORCPT + 31 others); Tue, 2 Apr 2019 09:38:10 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:43754 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730639AbfDBNiG (ORCPT ); Tue, 2 Apr 2019 09:38:06 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x32Dc48Z103113; Tue, 2 Apr 2019 08:38:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1554212284; bh=0/edQbd/JCK6PPPftxF7RTw4Vc6XeooZElbDVEEf+4M=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=CxGlve3ad1ndAlgnnA5HpOyNoWvx5q36UgCdY02/5rypkxJduvMbcOVECDP5s2vIq Lr7wZ0uhhfOZAVsgqJMQKl/xGKG6Zt5qEEDmqmpTdlcJtranzstWHmkfVdZ56vORkD vdueFcxlIY518odHKBVFTEr8AxkTYif6I3I9Fn4Y= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x32Dc4uf098759 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 2 Apr 2019 08:38:04 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 2 Apr 2019 08:38:03 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 2 Apr 2019 08:38:03 -0500 Received: from lta0400828d.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x32DbsU2051551; Tue, 2 Apr 2019 08:38:02 -0500 From: Roger Quadros To: CC: , , , Roger Quadros Subject: [RFC PATCH 4/4] bus: ti-sysc: Ensure PRU-ICSS doesn't break suspend/resume Date: Tue, 2 Apr 2019 16:37:52 +0300 Message-ID: <20190402133752.6912-5-rogerq@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190402133752.6912-1-rogerq@ti.com> References: <20190402133752.6912-1-rogerq@ti.com> MIME-Version: 1.0 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 PRU-ICSS subsystem's SYSCONFIG register is similar to omap4-simple but has 2 special bits STANDBY_INIT and SUB_MWAIT. The STANDBY_INIT bit initiates a Standby sequence (when set) and triggers a MStandby request to the SoC's PRCM module. This same bit is also used to enable the OCP master ports (when cleared). Some PRU applications require the OCP master port access to be enabled thus keeping it out of standby. During sustem suspend/resume we must ensure that the PRUSS is in standby else it will break resume. NOTE: 1. This patch only adds the PM callbacks with code to fix the System Suspend/Resume hang issue on AM33xx/AM437x SoCs, but does not implement the full context save and restore required for the PRUSS drivers to work across system suspend/resume when the power domain is switched off (L4PER domain is switched OFF on AM335x/AM437x during system suspend/resume, so PRUSS modules do lose context). 2. The PRUSS driver functionality on AM57xx SoCs is not affected that much because the PER power domain to which the PRUSS IPs belong is not switched OFF during suspend/resume. Based on work by Suman Anna. Cc: Suman Anna Signed-off-by: Roger Quadros --- drivers/bus/ti-sysc.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c index e4ab4d422ea5..9c94ce08dd36 100644 --- a/drivers/bus/ti-sysc.c +++ b/drivers/bus/ti-sysc.c @@ -71,6 +71,7 @@ static const char * const clock_names[SYSC_MAX_CLOCKS] = { * @name: name if available * @revision: interconnect target module revision * @needs_resume: runtime resume needed on resume from suspend + * @in_standby: flag used by PRUSS type during suspend/resume */ struct sysc { struct device *dev; @@ -92,6 +93,7 @@ struct sysc { bool enabled; bool needs_resume; bool child_needs_resume; + bool in_standby; struct delayed_work idle_work; }; @@ -1023,6 +1025,21 @@ static int __maybe_unused sysc_noirq_suspend(struct device *dev) if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) return 0; + if (ddata->cap->type == TI_SYSC_PRUSS) { + u32 reg, mask; + const struct sysc_regbits *regbits = ddata->cap->regbits; + + mask = BIT(regbits->standby_init_shift); + reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); + ddata->in_standby = reg & mask; + + /* initiate MStandby */ + if (!ddata->in_standby) { + reg |= mask; + sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], reg); + } + } + return pm_runtime_force_suspend(dev); } @@ -1035,6 +1052,25 @@ static int __maybe_unused sysc_noirq_resume(struct device *dev) if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) return 0; + if (ddata->cap->type == TI_SYSC_PRUSS && !ddata->in_standby) { + u32 reg; + const struct sysc_regbits *regbits = ddata->cap->regbits; + + /* re-enable OCP master ports/disable MStandby */ + reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); + reg &= ~BIT(regbits->standby_init_shift); + sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], reg); + ddata->in_standby = 0; + + /* wait till ready for transactions - delay is arbitrary */ + usleep_range(50, 100); + reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); + if (reg & BIT(regbits->sub_mwait_shift)) { + dev_err(dev, "timeout waiting for SUB_MWAIT_READY\n"); + return -ETIMEDOUT; + } + } + return pm_runtime_force_resume(dev); }