From patchwork Thu Nov 3 14:29:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 9410925 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 1D0306022E for ; Thu, 3 Nov 2016 14:30:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E0CD2ABFD for ; Thu, 3 Nov 2016 14:30:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02B1E2AC00; Thu, 3 Nov 2016 14:30:33 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8BE8C2ABFD for ; Thu, 3 Nov 2016 14:30:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c2J29-0001FA-2C; Thu, 03 Nov 2016 14:30:25 +0000 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c2J1d-00007Y-Fk for linux-amlogic@lists.infradead.org; Thu, 03 Nov 2016 14:29:56 +0000 Received: by mail-wm0-x229.google.com with SMTP id a197so208992275wmd.0 for ; Thu, 03 Nov 2016 07:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FdGSepzNMzl4KPQWAkr1g2/XGfpgRsTHoSrIHSZS/HM=; b=jrW8sr0h+vnpmly8r/I4agRQ6XnNKrJMhVP+AeGPywSN/hAxHeY29UUa3HoVFD2vE3 LlYuPp7ayvnzmxVyaydhSh5y7CM+PPISfcR43VkGSuUrRUp5bD8no5I0O1kV6iSSBt8j zYhUqdsauVHH33kWrEL0cBS5cuSwBz7GhsTlRJkN6CsSsp30ypeQVeEP/n5a2Eudc1N2 zLy+usjp5LIDyoypvVDKaYWQvhF9V98DI1y3srAkilRbGekn468KDU3dVhp363ecuxsx vzS+smdkf6ZCi97RSxq1d4LSxmKBcBGKC912F1BEQelTOwvt/qZdvoPjxgCe9snuMdLH K+Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FdGSepzNMzl4KPQWAkr1g2/XGfpgRsTHoSrIHSZS/HM=; b=XCpXBPiKrqgA5Gs7e1AJl4jFn64SAbEmZtKWX/aFl2L735Crgx/I9qfJXWyw3FPbYM hygdVx8KQGg6oiKzfipM5NkWs+Oq68siOXj5s68eWXIi8aD03FQX3+UncdwyMsX13J8Q bB+QuMUg+KvDq3PHWC9bFluTkNkHG568js/YwZeQ3mO5BEUe/cmHHok5Ts7lxfEz9dFg 7M7QZGhH8RnC548VHePfPIfQmylLaKzN2crrjNQFXHynSpkN/S6kntJ9+2G3toj5/EAT kk6p4yRVe7MhB3kl/6wu+zv+YQtE/DC6qglygp8kVxUbJ9hqXLhCRu8c4LawXHlKHdzv dIiA== X-Gm-Message-State: ABUngvcsNKWs5sKUKY0P2Lahh/f4ng/zMjeJ37mQEgLg/xtKhQ9T2SMdCRNSk35dtlkzBViS X-Received: by 10.28.62.141 with SMTP id l135mr8296059wma.121.1478183371333; Thu, 03 Nov 2016 07:29:31 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id vr9sm2970585wjc.35.2016.11.03.07.29.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Nov 2016 07:29:30 -0700 (PDT) From: Neil Armstrong To: khilman@baylibre.com, carlo@caione.org, a.zummo@towertech.it, alexandre.belloni@free-electrons.com Subject: [RFC PATCH 1/3] ARM64: meson: Add Amlogic Meson GX PM Suspend Date: Thu, 3 Nov 2016 15:29:23 +0100 Message-Id: <1478183365-23708-2-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1478183365-23708-1-git-send-email-narmstrong@baylibre.com> References: <1478183365-23708-1-git-send-email-narmstrong@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161103_072953_950308_359F6EFA X-CRM114-Status: GOOD ( 17.53 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rtc-linux@googlegroups.com, Neil Armstrong MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The Amlogic Meson GX SoCs uses a non-standard argument to the PSCI CPU_SUSPEND call to enter system suspend. Implement such call within platform_suspend_ops. Signed-off-by: Neil Armstrong --- drivers/firmware/meson/Kconfig | 6 +++ drivers/firmware/meson/Makefile | 1 + drivers/firmware/meson/meson_gx_pm.c | 86 ++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 drivers/firmware/meson/meson_gx_pm.c diff --git a/drivers/firmware/meson/Kconfig b/drivers/firmware/meson/Kconfig index 170d7e8..5b3fea3 100644 --- a/drivers/firmware/meson/Kconfig +++ b/drivers/firmware/meson/Kconfig @@ -7,3 +7,9 @@ config MESON_SM depends on ARM64_4K_PAGES help Say y here to enable the Amlogic secure monitor driver + +config MESON_GX_PM + bool + default ARCH_MESON if ARM64 + help + Say y here to enable the Amlogic GX SoC Power Management diff --git a/drivers/firmware/meson/Makefile b/drivers/firmware/meson/Makefile index 9ab3884..b6e285d 100644 --- a/drivers/firmware/meson/Makefile +++ b/drivers/firmware/meson/Makefile @@ -1 +1,2 @@ obj-$(CONFIG_MESON_SM) += meson_sm.o +obj-$(CONFIG_MESON_GX_PM) += meson_gx_pm.o diff --git a/drivers/firmware/meson/meson_gx_pm.c b/drivers/firmware/meson/meson_gx_pm.c new file mode 100644 index 0000000..c104c2e --- /dev/null +++ b/drivers/firmware/meson/meson_gx_pm.c @@ -0,0 +1,86 @@ +/* + * Amlogic Meson GX Power Management + * + * Copyright (c) 2016 Baylibre, SAS. + * Author: Neil Armstrong + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include + +#include + +#include + +/* + * The Amlogic GX SoCs uses a special argument value to the + * PSCI CPU_SUSPEND method to enter SUSPEND_MEM. + */ + +#define MESON_SUSPEND_PARAM 0x0010000 +#define PSCI_FN_NATIVE(version, name) PSCI_##version##_FN64_##name + +static int meson_gx_suspend_finish(unsigned long arg) +{ + struct arm_smccc_res res; + + arm_smccc_smc(PSCI_FN_NATIVE(0_2, CPU_SUSPEND), arg, + virt_to_phys(cpu_resume), 0, 0, 0, 0, 0, &res); + + return res.a0; +} + +static int meson_gx_suspend_enter(suspend_state_t state) +{ + switch (state) { + case PM_SUSPEND_MEM: + return cpu_suspend(MESON_SUSPEND_PARAM, + meson_gx_suspend_finish); + } + + return -EINVAL; +} + +static const struct platform_suspend_ops meson_gx_pm_ops = { + .enter = meson_gx_suspend_enter, + .valid = suspend_valid_only_mem, +}; + +static const struct of_device_id meson_gx_pm_match[] = { + { .compatible = "amlogic,meson-gx-pm", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, meson_gx_pm_match); + +static int meson_gx_pm_probe(struct platform_device *pdev) +{ + suspend_set_ops(&meson_gx_pm_ops); + + return 0; +} + +static struct platform_driver meson_gx_pm_driver = { + .probe = meson_gx_pm_probe, + .driver = { + .name = "meson-gx-pm", + .of_match_table = meson_gx_pm_match, + }, +}; + +module_platform_driver(meson_gx_pm_driver); + +MODULE_AUTHOR("Neil Armstrong "); +MODULE_DESCRIPTION("Amlogic Meson GX PM driver"); +MODULE_LICENSE("GPL v2");