From patchwork Thu Oct 10 20:29:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 175856 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2802831ill; Thu, 10 Oct 2019 13:36:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPifDURhe54UQF6TsGMe681gH6/JCPpLH9XCvE2louTa5zPY1MyUMIR+NxlW734aXQ09G+ X-Received: by 2002:a17:906:1505:: with SMTP id b5mr10344049ejd.195.1570739793724; Thu, 10 Oct 2019 13:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570739793; cv=none; d=google.com; s=arc-20160816; b=Q/fyr+gECuEFeSfGJNTp50MpZ3dJKybc87Wpi1rlNm//ADwdLZZfN+wLJYx/ZwSe0v yAtQ0iGFGtsLadlucOdkuOzUU2gv13Ae6qrqwvSlYHKd/1Q0JRIvO2lLo3pshJrEHZBb rA6jk0jRZH4lvciC6auzQRW5l38BFMlEAg6O8q/cxlZrIgYv5uRpWpLcsk9FO1FV8DmH q0N2IDkLikUjkbjfmDNBi4TkkrzX6Px5rb3MPUOxdxvWb47k8546X2+mH/30By6rkbYY tBAhJ7/9Ck5bB5lYzPiUxzFxVFFA+BGioiZeOEuBCnkOjThHJQ5gCDfhe1Tercpdozp5 7j3A== 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; bh=nZH1izDDB43K7yz1aAjYBlmHO5E4Tl7sjwelwy7xdDw=; b=LKOQC3cDHPsqMWElbTmnpCwBKALjnlf7j6IByMb6c/LIM1+vQg+Ie7Mrb3gwRkPqfb mcNMYPR2XoPmWz14wSbQW8AWUpYCwpczeAJWOteZeQ5vZQu2a9IC+3OfAb2RJgGmxG8/ G9/9bnX/FHrs2D59+LVInqCvB/Zug3wDMjfH0Q3Xp75981ISmZvbv8MS5w7+M1aI3BIo Q7tzj8qASZEm1tpGqg2zxq6PfhBvh9nBh/P0oVEjYz/rUMt/UgLxkM95mtaw46VtZ2FZ LQIFRZtXjiPykGjwc+xsnvBpuFUYFScPgy+mgNCGmh7htQjkqck1TE725bMbqsON8d1f z9ZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z15si4523340edd.431.2019.10.10.13.36.33; Thu, 10 Oct 2019 13:36:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727161AbfJJUgd (ORCPT + 3 others); Thu, 10 Oct 2019 16:36:33 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:42067 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726533AbfJJUgd (ORCPT ); Thu, 10 Oct 2019 16:36:33 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MYLqs-1ieCBJ1q2k-00VSwa; Thu, 10 Oct 2019 22:36:15 +0200 From: Arnd Bergmann To: Kukjin Kim , Krzysztof Kozlowski , Kyungmin Park Cc: linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linus.walleij@linaro.org, Arnd Bergmann , Tomasz Figa , linux-kernel@vger.kernel.org Subject: [PATCH 10/36] ARM: s5pv210: use private pm save/restore Date: Thu, 10 Oct 2019 22:29:54 +0200 Message-Id: <20191010203043.1241612-10-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191010203043.1241612-1-arnd@arndb.de> References: <20191010202802.1132272-1-arnd@arndb.de> <20191010203043.1241612-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:t06pj45vMcSDoEbxSCss3f5CI4Q0mCvmon4HXQKdFVgc3CZE2SZ 6GDEv57UdL2pMT9oYaML5s6k6H4an0hD0vSPqL1TK9QhIqAiZ3JXJGQRYiLA10kdPybEDLM LkmdsIkBh+fEfuZ4qKsBYg1p1Ya6B3jCBopYbIsgcd7xLrXfT9D/yReO3ELSeGlzG11eU+v IdbSm0rP+MzyF0ya7wCxQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:XV+MPK70w7E=:BhQ4bhqXydFKuIa+TPbyId A5KmTH4/XxVCeHb+3+T5c/+c9wqtBBLomtafNUtbfL7geLlXVDKW10N4L6+AuH1WBjanj7LvJ dUFJ4oNaE75ImwWCooDU1IX6BtFBbqMzAypBLcYxMKc7pEA7se7MiEXiGET8BD7NWCYy+Gm4v xo32t0jwcI1xZ2hc4rrG7kLEvVfDZ2YUZsJI8Ad4oolmeZVJy//p5Cv5VLW6KYTXCG2TrDC67 LoQVDf0jAV616OOAAF+jKJIsMqu6Cq2rlSVykk2ZZbKHmByhbdRjqPiUhVpY+ffdMkC7yHUgx YLgRrU20ShewwEukIpbl+B7KfZ0zmaawX8Z9CdSYrRKnru5ohJTg3S4SxjyE2WnxZGOBRtFot p6i+CXENZsa4rgfp6x9GEoNZj4Rof+xn0WxjqpNP7dNHQECpVls3CHZj7rzGc8TIPzzSqq+1I xVHhIuSLdGsq8xL6n8JaiwDD6yqNVPhfeFiSF0SA9MyJulhLZF6n0cQ3zCSauqUSDR7w8XIzf O+QLobMdBq81IEEue1nmPN8WlMjIgCZxSjj1H7V2a1hBItJcRp5uCwDjv1vhqM/Yvbj1qkKEt lwPpFZ7VPrCtQYmHXOiSDZVRplbPgeD8reNkF4ylUttAds+sCpXi7XwkW/amkRCCjLH5K3bsw iksEKWMxTuKZznLo8ThpwcjNdmN6ylK+eBLvmzhHhiW50uLoKZ4wk3YHFRG5ZZyiVoTN++Hji IxFdNsp/402JjDicaaBR3WlWnjX586w7YTzQ1x9LvCYrPuIJ8TclTw1NYrMFqu9I8qwXxzJBn S3rdkwTgwAzhDmBBaDAvDU72X8nw5Z3tHJ4YIHgDtsFRGEnslYRbRuv+aPzqpybQqwnBOsODv 44eaAD7nyQxBDF6tZyig== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org The pm save/restore code is fairly small, so in order to separate the s3c and s5p platforms, adding an s5p specific copy instead of sharing it is actually easier. Signed-off-by: Arnd Bergmann --- arch/arm/mach-s5pv210/Makefile | 7 ----- arch/arm/mach-s5pv210/pm.c | 45 ++++++++++++++++++++++++++++-- arch/arm/mach-s5pv210/regs-clock.h | 2 +- arch/arm/mach-s5pv210/s5pv210.c | 2 -- arch/arm/plat-samsung/Makefile | 4 +-- 5 files changed, 45 insertions(+), 15 deletions(-) -- 2.20.0 diff --git a/arch/arm/mach-s5pv210/Makefile b/arch/arm/mach-s5pv210/Makefile index e7b551e18e5c..aa0a1f091daf 100644 --- a/arch/arm/mach-s5pv210/Makefile +++ b/arch/arm/mach-s5pv210/Makefile @@ -3,12 +3,5 @@ # Copyright (c) 2010 Samsung Electronics Co., Ltd. # http://www.samsung.com/ -ccflags-$(CONFIG_ARCH_MULTIPLATFORM) += -I$(srctree)/arch/arm/plat-samsung/include - -# Core - obj-$(CONFIG_PM_SLEEP) += pm.o sleep.o - -# machine support - obj-y += s5pv210.o diff --git a/arch/arm/mach-s5pv210/pm.c b/arch/arm/mach-s5pv210/pm.c index efdb5a27c060..d59c094cdea8 100644 --- a/arch/arm/mach-s5pv210/pm.c +++ b/arch/arm/mach-s5pv210/pm.c @@ -13,15 +13,56 @@ #include #include #include +#include #include #include -#include - #include "common.h" #include "regs-clock.h" +/* helper functions to save and restore register state */ +struct sleep_save { + void __iomem *reg; + unsigned long val; +}; + +#define SAVE_ITEM(x) \ + { .reg = (x) } + +/** + * s3c_pm_do_save() - save a set of registers for restoration on resume. + * @ptr: Pointer to an array of registers. + * @count: Size of the ptr array. + * + * Run through the list of registers given, saving their contents in the + * array for later restoration when we wakeup. + */ +static void s3c_pm_do_save(struct sleep_save *ptr, int count) +{ + for (; count > 0; count--, ptr++) { + ptr->val = readl_relaxed(ptr->reg); + S3C_PMDBG("saved %p value %08lx\n", ptr->reg, ptr->val); + } +} + +/** + * s3c_pm_do_restore() - restore register values from the save list. + * @ptr: Pointer to an array of registers. + * @count: Size of the ptr array. + * + * Restore the register values saved from s3c_pm_do_save(). + * + * WARNING: Do not put any debug in here that may effect memory or use + * peripherals, as things may be changing! +*/ + +static void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count) +{ + for (; count > 0; count--, ptr++) + writel_relaxed(ptr->val, ptr->reg); +} + static struct sleep_save s5pv210_core_save[] = { /* Clock ETC */ SAVE_ITEM(S5P_MDNIE_SEL), diff --git a/arch/arm/mach-s5pv210/regs-clock.h b/arch/arm/mach-s5pv210/regs-clock.h index 2a35c831a9b0..8c7530614e37 100644 --- a/arch/arm/mach-s5pv210/regs-clock.h +++ b/arch/arm/mach-s5pv210/regs-clock.h @@ -9,7 +9,7 @@ #ifndef __ASM_ARCH_REGS_CLOCK_H #define __ASM_ARCH_REGS_CLOCK_H __FILE__ -#include +#define S3C_VA_SYS ((void __iomem __force *)0xF6100000) #define S5P_CLKREG(x) (S3C_VA_SYS + (x)) diff --git a/arch/arm/mach-s5pv210/s5pv210.c b/arch/arm/mach-s5pv210/s5pv210.c index 868f9c20419d..a21ed3bb992a 100644 --- a/arch/arm/mach-s5pv210/s5pv210.c +++ b/arch/arm/mach-s5pv210/s5pv210.c @@ -13,8 +13,6 @@ #include #include -#include - #include "common.h" #include "regs-clock.h" diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile index d88b9b84f3a9..025ce22876c1 100644 --- a/arch/arm/plat-samsung/Makefile +++ b/arch/arm/plat-samsung/Makefile @@ -24,9 +24,7 @@ obj-$(CONFIG_GPIO_SAMSUNG) += gpio-samsung.o # PM support -obj-$(CONFIG_PM_SLEEP) += pm-common.o -obj-$(CONFIG_EXYNOS_CPU_SUSPEND) += pm-common.o -obj-$(CONFIG_SAMSUNG_PM) += pm.o +obj-$(CONFIG_SAMSUNG_PM) += pm.o pm-common.o obj-$(CONFIG_SAMSUNG_PM_GPIO) += pm-gpio.o obj-$(CONFIG_SAMSUNG_WAKEMASK) += wakeup-mask.o