From patchwork Sun Jul 16 02:36:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 9842605 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6A3B760393 for ; Sun, 16 Jul 2017 02:36:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BA3328552 for ; Sun, 16 Jul 2017 02:36:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50693285B9; Sun, 16 Jul 2017 02:36:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3C6F28552 for ; Sun, 16 Jul 2017 02:36:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751253AbdGPCgW (ORCPT ); Sat, 15 Jul 2017 22:36:22 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:33827 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751213AbdGPCgU (ORCPT ); Sat, 15 Jul 2017 22:36:20 -0400 Received: by mail-qt0-f195.google.com with SMTP id m54so14631881qtb.1; Sat, 15 Jul 2017 19:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pqeP8gNvXl1QAnkJvSdXvZtBZVQUif6UPv+RZlQo7zk=; b=ZMUWcMAOYfeblfD581CX8LkC57KXA8hs8POcf/JLnuQWCdJ1ff8/JchLa+VjGpJVvj vbAAJhiqG8qDHGVqtwhaSPff9CM0IQQrvwJwt/tynnP35lDv/OvJI0+naKg5Hn1ZXYl2 x+EIzN1g6xZnm/zKeCniIU6q4ud/mgfXQ64TXkyz4+pGYaZah348s9Es9vgLuAD/qDIZ 1rVRARVlmfiOg88hBeRYPFZGaeQgNTH7fdaJ/waEq0TApuxq1c6CMqqqJecqBdG/QpCJ vaKwhcgSTpi19VTGSFPtEnrmnXfeu5JCdUUvCNckwDbio9yVfkgzYLlRKLa6DFNSAPiv Lfkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pqeP8gNvXl1QAnkJvSdXvZtBZVQUif6UPv+RZlQo7zk=; b=rIMP8z/5MSP1h0blX8Yivfy6eaX5iJFwSE4KF1R1lvPeZkg5xnD/mYY1vcZ3m37OwR 6nITGjMiD3gUBaX54zkcVOFjwU1aD87E7NiBJzFXoxlX+nSCEmTQ2ykwdBN3SaTgz9Wf PQfbwLt5bsQrUjJMdU9AdxX3xQnqeq1S7DkI/7W6lmKIKAoY1YzLBGhRGAcQlYmNKez3 fyU+/eA7WFVFkgYvCUz/NkiwSrlz7hPRmqBZtozZoyTMuGHwLdT904bMweJkoeyiTSV5 H9yU9xFwgY87E+8aAi1+PlayFhVad+mJcPtTAsNq0/aRAWBIpqzCdpmv3Al9hAXjQ5eL 3O+g== X-Gm-Message-State: AIVw112mAlFfx5Gly1g+YOvZzDeUOf4msmnJ43Bp++EtNLOlwUiMf4K7 xyR4M/py8uvOwBZUX84= X-Received: by 10.200.41.172 with SMTP id 41mr19678363qts.85.1500172579383; Sat, 15 Jul 2017 19:36:19 -0700 (PDT) Received: from fainelli-desktop.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id x40sm10856966qta.66.2017.07.15.19.36.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Jul 2017 19:36:18 -0700 (PDT) From: Florian Fainelli To: linux-kernel@vger.kernel.org Cc: Florian Fainelli , "Rafael J. Wysocki" , Alexandre Belloni , "Rafael J. Wysocki" , Ulf Hansson , Daniel Lezcano , linux-pm , Thibaud Cornic , JB , Mason , Kevin Hilman , Pavel Machek , Linux ARM Subject: [PATCH 2/2] soc: bcm: brcmstb: PM: Implement target_state callback Date: Sat, 15 Jul 2017 19:36:10 -0700 Message-Id: <20170716023610.4658-3-f.fainelli@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170716023610.4658-1-f.fainelli@gmail.com> References: <20170623010837.11199-1-f.fainelli@gmail.com> <20170716023610.4658-1-f.fainelli@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Provide a target_state callback implementation which just returns the suspend_state_t the system is about to enter. Broadcom STB drivers can utilize platform_suspend_target_state() to retrieve that and take appropriate actions (e.g: full vs. partial re-initialization). Two states are implemented: PLATFORM_STATE_WORKING and PLATFORM_STATE_BRCMSTB_S3MEM to that end. Signed-off-by: Florian Fainelli --- drivers/soc/bcm/brcmstb/pm/pm-arm.c | 22 ++++++++++++++++++++++ include/linux/suspend.h | 1 + 2 files changed, 23 insertions(+) diff --git a/drivers/soc/bcm/brcmstb/pm/pm-arm.c b/drivers/soc/bcm/brcmstb/pm/pm-arm.c index dcf8c8065508..750a74b3fc9d 100644 --- a/drivers/soc/bcm/brcmstb/pm/pm-arm.c +++ b/drivers/soc/bcm/brcmstb/pm/pm-arm.c @@ -104,6 +104,7 @@ struct brcmstb_pm_control { u32 phy_b_standby_ctrl_offs; bool needs_ddr_pad; struct platform_device *pdev; + suspend_state_t pm_state; }; enum bsp_initiate_command { @@ -533,9 +534,30 @@ static int brcmstb_pm_valid(suspend_state_t state) } } +static int brcmstb_pm_begin(suspend_state_t state) +{ + ctrl.pm_state = state; + + return 0; +} + +static enum platform_target_state brcmstb_target_state(void) +{ + switch (ctrl.pm_state) { + case PM_SUSPEND_STANDBY: + return PLATFORM_STATE_WORKING; + case PM_SUSPEND_MEM: + return PLATFORM_STATE_BRCMSTB_S3MEM; + default: + return PLATFORM_STATE_UNKNOWN; + } +} + static const struct platform_suspend_ops brcmstb_pm_ops = { + .begin = brcmstb_pm_begin, .enter = brcmstb_pm_enter, .valid = brcmstb_pm_valid, + .target_state = brcmstb_target_state, }; static const struct of_device_id aon_ctrl_dt_ids[] = { diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 6e6cc0778816..15d21d76e0bf 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -58,6 +58,7 @@ enum platform_target_state { PLATFORM_STATE_ACPI_S3, PLATFORM_STATE_ACPI_S4, /* Add platform specific states here */ + PLATFORM_STATE_BRCMSTB_S3MEM, }; struct suspend_stats {