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: 690880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-wm0-x240.google.com (mail-wm0-x240.google.com [IPv6:2a00:1450:400c:c09::240]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t8nRL3nndz9vDl for ; Fri, 4 Nov 2016 01:29:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b=JomBcfQ5; dkim-atps=neutral Received: by mail-wm0-x240.google.com with SMTP id p190sf3933717wmp.1 for ; Thu, 03 Nov 2016 07:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=FLzKdktmU9c3Yx0xIItqnAmp/txfYQ/7KbNT/+QbVrk=; b=JomBcfQ5kTqKkpIqceCVQSaG9pStnNIXhLVtyrRyQuD7Oio8c5y8gm3YPMPLIZRiHb Ol3GP1s+XRi20YUtmyP3RCe/5iCD2zKLGWNRj2c5Dn1GPhcLaJCuzpgUukhhzI9X4GQn ZEaFrnIeB6C5BlEUSizWfjl+PcpkL/9IjuAQqx8tpfFf6/hsXvfED+cGTN/2RvaxqQ6Z SxAfuUGB7JQUFEXBnL66RMVVPhKXQIx+8CAd2rCK7jZarCaS5ebtqhbVAkiYPx3q4S+e jiK3yjVfBt1BYr5cMxW0lyt0qtMUA+sieKtzSgX9A1UqtlSKrxWwgZzi2h3EN6AL5mSF hPNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=FLzKdktmU9c3Yx0xIItqnAmp/txfYQ/7KbNT/+QbVrk=; b=AJspPKGEC03lqr43p12p4KYHKuevD70t1pGvir7Xo3kzDMbV1FZkqlUHfDLx6V6N+h 0ghiNLbjZQHSE8je9cXOE6UaDkP2b4RoXgx/Ih7VA7LxpFza/JpvuZX2iwV6+GSedlX1 pxj0TDyiwErTQjaZJ49JdhaGMnAM1MaKMoqY0RZDn8SJLI08HaatB1aZE1cCsrfpVX/O gJG3wvXJVMerh2pILbVIm6OACT+inY7HjSYekA2ujfC3BVWIxybLpIjgavQ4jjL3Nwq/ fvuEVdENViUF3GIx3k0mw5w0DuasoDhEcxmzq8Ew3Xf3n5f6DjLuYu61e5ZCHQ5XENfj khzQ== Sender: rtc-linux@googlegroups.com X-Gm-Message-State: ABUngvdAaQIdAetryicmRIKDVW9VmM6d31PXtDtbRhIzTZ3ivPESvrfMJ4wF7KojXFHNfg== X-Received: by 10.28.88.211 with SMTP id m202mr134057wmb.17.1478183371970; Thu, 03 Nov 2016 07:29:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.28.132.202 with SMTP id g193ls476387wmd.18.gmail; Thu, 03 Nov 2016 07:29:31 -0700 (PDT) X-Received: by 10.28.20.7 with SMTP id 7mr303274wmu.11.1478183371664; Thu, 03 Nov 2016 07:29:31 -0700 (PDT) Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com. [2a00:1450:400c:c09::22e]) by gmr-mx.google.com with ESMTPS id g142si2832043wmd.2.2016.11.03.07.29.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Nov 2016 07:29:31 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning narmstrong@baylibre.com does not designate 2a00:1450:400c:c09::22e as permitted sender) client-ip=2a00:1450:400c:c09::22e; Received: by mail-wm0-x22e.google.com with SMTP id p190so336944919wmp.1 for ; Thu, 03 Nov 2016 07:29:31 -0700 (PDT) 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 Cc: Neil Armstrong , rtc-linux@googlegroups.com, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [rtc-linux] [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-Original-Sender: narmstrong@baylibre.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com; spf=softfail (google.com: domain of transitioning narmstrong@baylibre.com does not designate 2a00:1450:400c:c09::22e as permitted sender) smtp.mailfrom=narmstrong@baylibre.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: rtc-linux@googlegroups.com X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , 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");