Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp322686ybl; Thu, 12 Dec 2019 19:10:07 -0800 (PST) X-Google-Smtp-Source: APXvYqwbv8Wrq8kMtsoRij63tntEQvMt54V8y8qI9LQjbu/LO2qBuB+e/DvY8i49ybUeabsxerCj X-Received: by 2002:a9d:6a92:: with SMTP id l18mr12065783otq.37.1576206607475; Thu, 12 Dec 2019 19:10:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576206607; cv=none; d=google.com; s=arc-20160816; b=OPiAvCc9d4MRHcMeF6aUJzZfnwVxjEs2lbx3ZMK1+Pd/wrE9lrXQc0jn8OZs7FBbSz n73QaQmzykRaJc9LItX1CH7MAQzT0qoC9EkiT/IQrUqU5Z6KhJ0CUpoVd6jLdQ9SNzpo AhVWTXd7liiLTP0l+UkNvrifsgBLCciTZmTyf4OjgdVRHf3EQW63SFsut7hnZPQLdMNv 4zgVXCTTrb+z5I3IE5CN0aebWMKjfsStSnm01T6RJl9Atd4R9Nhf2Um/tf4XWvUfltmR 1lSP8F7QOoJtX/8H0v3dErj87huQbukSKx+37iycAzgj+O7XPRTnn7aHgJQ+Z6lRseja q4uw== 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=j9L7757lr3G0ZzPmdcesLX61vOAVroRZ/5blbJOuMGo=; b=eQw9laqHA909hZia7PHjZN3V75buOGY6qGvBEklNY6sMAzOJvoVq/+/Ro50/87t2Dz X/WsiTk2lq9p6bcb0tJVyC2xnQ5iAgibktnlAlaUuxpfqIOidWgO5JP3EbzMJGddMeXF 75ofzu/8D5mNfSxpbkVsJvBMsiT1K6w7uwUsNSBEW96QhNrMAm0PPUGdCP1quwZszs0u knediWEYuUbTwUZ4LwARf25XBNoxPJiK2NpbDPZZD3HK++dj9kxFcue68rMIo5K064Zi tsH/CqrtDvV0v8xmzXjzNcFUPMilKSf46WU8Or9kmBc5k/6bAPFLI5ICqUk9UYmfdAnW 3WHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=l4OW2V99; 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 q6si4302462oti.173.2019.12.12.19.09.56; Thu, 12 Dec 2019 19:10:07 -0800 (PST) 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=l4OW2V99; 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 S1732003AbfLMDHT (ORCPT + 99 others); Thu, 12 Dec 2019 22:07:19 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:36468 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731943AbfLMDHQ (ORCPT ); Thu, 12 Dec 2019 22:07:16 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xBD37823088025; Thu, 12 Dec 2019 21:07:08 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1576206428; bh=j9L7757lr3G0ZzPmdcesLX61vOAVroRZ/5blbJOuMGo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=l4OW2V99nvcFerUEIaSv43rBm8sWc3+N9dsoRkTHPpOv+KCKHGv09+Mf+R3/kWmbJ Qp1IqgA7RlfWTSOSyka2odQiitRqlDcytsh8jpcfDjsjhqMyjeWWm04Y+o0AEgxqhD HIAwP8DYhg1m+a4fD9KobZtHrE7nCUomOGLDQfEQ= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBD3785N026655; Thu, 12 Dec 2019 21:07:08 -0600 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Thu, 12 Dec 2019 21:07:08 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) 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.1847.3 via Frontend Transport; Thu, 12 Dec 2019 21:07:08 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBD378au004077; Thu, 12 Dec 2019 21:07:08 -0600 From: Dave Gerlach To: Tony Lindgren , Santosh Shilimkar CC: , , , , Dave Gerlach Subject: [PATCH 4/5] soc: ti: pm33xx: Add base cpuidle support Date: Thu, 12 Dec 2019 21:07:54 -0600 Message-ID: <20191213030755.16096-5-d-gerlach@ti.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191213030755.16096-1-d-gerlach@ti.com> References: <20191213030755.16096-1-d-gerlach@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 Some cpuidle C-states supported on am335x and am437x, like C1 on am335x, require the use of the wkup_m3_ipc driver, and all C-states beyond C0 on both platforms require the use of the SRAM sleep code. Pass am33xx_do_sram_idle as the idle function to the platform pm core to be used by the cpuidle-arm driver when entering cpuidle states. am33xx_do_sram_idle will detect when the wkup_m3 is needed and ping it if necessary before calling the final cpu_suspend op which will execute the SRAM code to put the cpu into idle. Finally, use the begin_suspend and finish_suspend platform ops to be called at the beginning and end of suspend path to allow use of cpu_idle_poll_ctrl. This prevents races between cpuidle and suspend paths trying to communicate with the wkup_m3, as during suspend we only want it configured for entry to suspend. Signed-off-by: Dave Gerlach --- drivers/soc/ti/pm33xx.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/soc/ti/pm33xx.c b/drivers/soc/ti/pm33xx.c index 19bdcaca1f21..de0123ec8ad6 100644 --- a/drivers/soc/ti/pm33xx.c +++ b/drivers/soc/ti/pm33xx.c @@ -130,6 +130,19 @@ static int am33xx_push_sram_idle(void) return 0; } +static int am33xx_do_sram_idle(u32 wfi_flags) +{ + int ret = 0; + + if (!m3_ipc || !pm_ops) + return 0; + + if (wfi_flags & WFI_FLAG_WAKE_M3) + ret = m3_ipc->ops->prepare_low_power(m3_ipc, WKUP_M3_IDLE); + + return pm_ops->cpu_suspend(am33xx_do_wfi_sram, wfi_flags); +} + static int __init am43xx_map_gic(void) { gic_dist_base = ioremap(AM43XX_GIC_DIST_BASE, SZ_4K); @@ -260,6 +273,8 @@ static int am33xx_pm_begin(suspend_state_t state) rtc_only_idle = 0; } + pm_ops->begin_suspend(); + switch (state) { case PM_SUSPEND_MEM: ret = m3_ipc->ops->prepare_low_power(m3_ipc, WKUP_M3_DEEPSLEEP); @@ -301,6 +316,8 @@ static void am33xx_pm_end(void) } rtc_only_idle = 0; + + pm_ops->finish_suspend(); } static int am33xx_pm_valid(suspend_state_t state) @@ -503,7 +520,7 @@ static int am33xx_pm_probe(struct platform_device *pdev) suspend_wfi_flags |= WFI_FLAG_WAKE_M3; #endif /* CONFIG_SUSPEND */ - ret = pm_ops->init(NULL); + ret = pm_ops->init(am33xx_do_sram_idle); if (ret) { dev_err(dev, "Unable to call core pm init!\n"); ret = -ENODEV; @@ -522,6 +539,8 @@ static int am33xx_pm_probe(struct platform_device *pdev) static int am33xx_pm_remove(struct platform_device *pdev) { + if (pm_ops->deinit) + pm_ops->deinit(); suspend_set_ops(NULL); wkup_m3_ipc_put(m3_ipc); am33xx_pm_free_sram(); -- 2.20.1