From patchwork Mon Mar 9 08:18:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11426213 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26AB513A4 for ; Mon, 9 Mar 2020 08:19:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EECCE20828 for ; Mon, 9 Mar 2020 08:19:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GWFO1xvX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726403AbgCIITJ (ORCPT ); Mon, 9 Mar 2020 04:19:09 -0400 Received: from mail-pj1-f68.google.com ([209.85.216.68]:55154 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725796AbgCIITJ (ORCPT ); Mon, 9 Mar 2020 04:19:09 -0400 Received: by mail-pj1-f68.google.com with SMTP id np16so4035990pjb.4; Mon, 09 Mar 2020 01:19:08 -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 :in-reply-to:references; bh=0dwzfZBdNlOZMuJhJ5m0U1KGetNN67/bhUzuOF6YkZk=; b=GWFO1xvXViZGSxx6IuIEj+83xa59xbFeYUTUPtEHlRzAfU1UOsdwdT36XBZpifD1Ek uRA7Pu4Q7O7JQk8rg0Gfv2dtrJJfI9QGZHBVa23IeE24HZbestU81oNR8PDB32/XUpxV AHp+8QlixL3ZNiiVGTDngidzn3OupWGCCm2KxTlTJMB3MA8Hhc7W1McqxaRaBJCCPQhb 2C8e1tHhcQ1IWZi7MeCdhCvDpoWuposU7gDauj9lf7F3QvJTuo8TaGAqPgF+Aeflv69m O5QHU0TfnyN7GOM4v8Q2bLz7SU2Ib6IsQoM+mkGTodq93blD9E6s7CbZWPpAO5Ngiqgb Q2hQ== 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:in-reply-to:references; bh=0dwzfZBdNlOZMuJhJ5m0U1KGetNN67/bhUzuOF6YkZk=; b=S79e7G35jCZdxoV4vjMVm7kUdp1w7DdB4Fa01wj9VxvkT0kk+puop6jEbt4muX5+P3 lGeKJg1DBv+mL7szpyAveFUfj2HY8uZgMC2S5+fBR28B0xfgQXa8oSU3N7pAVDKnNWoz PWTjXN8rIusZJNy/hn7kyXFSWb5ps/JaTpZXUD1wJEm5jOThzKhtaASDSgwQADcR2Xj0 8l1Hd6412o4uNuglbfjjS2iVabwr0qOWT9P+1BilTcnK6KT4FeVz3lvfLfL1JFwl8cLP lbD2c72qkIPxRPWEOF5NslnuwHi3V8l6JP8lBxNYEbUD19LhHqJ2nGP2lFVVhI7fy8TU 49hA== X-Gm-Message-State: ANhLgQ0q2AwMYSZUed2aHuPU2LVpFDZ0GjAPUiZFDEUCvtXbj8eQanKV 1ozMz1ruc1zyKddkNQu87uQ= X-Google-Smtp-Source: ADFU+vuoXTBMNKKmBuHT08cyyk8tD50wxzgrbD0pn0R1YewfUM/GY4EexBDxX8A+R5gg6rHwNlGIEA== X-Received: by 2002:a17:90a:a786:: with SMTP id f6mr1883293pjq.169.1583741947919; Mon, 09 Mar 2020 01:19:07 -0700 (PDT) Received: from sh03840pcu.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 193sm21862277pfu.181.2020.03.09.01.19.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Mar 2020 01:19:07 -0700 (PDT) From: Baolin Wang To: sre@kernel.org Cc: baolin.wang7@gmail.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, kernel-team@android.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] power: reset: sc27xx: Power off the external subsystems' connection Date: Mon, 9 Mar 2020 16:18:44 +0800 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Sherry Zong When powering off the whole system, we should power off some external subsystems' connection firstly, otherwise some external subsystems will hold some power and result in powering down abnormally. Signed-off-by: Sherry Zong Signed-off-by: Baolin Wang --- drivers/power/reset/sc27xx-poweroff.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/power/reset/sc27xx-poweroff.c b/drivers/power/reset/sc27xx-poweroff.c index 29fb08b..2bedd4c 100644 --- a/drivers/power/reset/sc27xx-poweroff.c +++ b/drivers/power/reset/sc27xx-poweroff.c @@ -13,6 +13,8 @@ #define SC27XX_PWR_PD_HW 0xc2c #define SC27XX_PWR_OFF_EN BIT(0) +#define SC27XX_SLP_CTRL 0xdf0 +#define SC27XX_LDO_XTL_EN BIT(3) static struct regmap *regmap; @@ -40,6 +42,9 @@ static void sc27xx_poweroff_shutdown(void) static void sc27xx_poweroff_do_poweroff(void) { + /* Disable the external subsys connection's power firstly */ + regmap_write(regmap, SC27XX_SLP_CTRL, SC27XX_LDO_XTL_EN); + regmap_write(regmap, SC27XX_PWR_PD_HW, SC27XX_PWR_OFF_EN); } From patchwork Mon Mar 9 08:18:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11426215 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 429151580 for ; Mon, 9 Mar 2020 08:19:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2393320848 for ; Mon, 9 Mar 2020 08:19:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="o6vHURSt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726491AbgCIITN (ORCPT ); Mon, 9 Mar 2020 04:19:13 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38889 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726426AbgCIITL (ORCPT ); Mon, 9 Mar 2020 04:19:11 -0400 Received: by mail-pf1-f194.google.com with SMTP id g21so4487380pfb.5; Mon, 09 Mar 2020 01:19:10 -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 :in-reply-to:references; bh=97j+BQwnuA+j+MznOuDwPM3YlR+ybya1ELeecHUKr6c=; b=o6vHURStjOFlNogoA+m7kXFMgXCSI0+B+vjpdzWletwOAIa2x1gDX0Q34D1j0yukop P3zmTBbmzPH926MQHFxaRaJGmZXDJX0bDszVqvhVL7/55FJFkbGE6MH0Nv0qbcgAoKQI EPYoClOa1NqGfOtRwClOqKARB2xoLGh3jrPwoo3NGeefvpvI9JaSju5qwd6X9DaUzofv jaMpwT7TNYO5LUX/X514o7xAOBpLHSMqM8v5VPYbVDqRIjXNetmNEZF2EG6Uq1mo9wmC o4oN20ln9Bm9z8KUj7imNLliyDxiV1Xjj5Tijnihgsf5OHAgwWwrPy9tHMeOZIkLRZb1 WwxA== 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:in-reply-to:references; bh=97j+BQwnuA+j+MznOuDwPM3YlR+ybya1ELeecHUKr6c=; b=mNOG9aLQZYsZpp1AlD4fA+RqHcoBPWKIDSxf80R8iCOYP4XMaMdDccVc/oQuckRjbO pw2MUq8fVDxaTaee89MhyvTc9wbWJXij1JoJe2f7gko6YHVKAn//Aen5aUOkeOrBGnDN J1pVF9X3wQLYm/vGogTmIe7YTU08CrvjymkuKmjKkG1hALRBxwV3aztPvR5SjvXlMO63 JwX5b3R0nnaqIAETd/U+NaNR541o+16f4dq4+fIakoLh4mybBrnM7bV66iHeGD7NFIfq HP2k52wGcfhA+06LwFZMr2lUz06a8aWIdzmsFMI3ljV8TIbGkFAkSQsp2eUpONCnLaKh jQVw== X-Gm-Message-State: ANhLgQ065CoM0lPgZl4D2LxIuOVuIAOxYbigq4XsVCVdKYMr4ZzrOnT9 EnDRcSMdjzJSKTlktSnDswCMx3MA X-Google-Smtp-Source: ADFU+vtU4P6HR9nKkXyeLE033oBehzmN7R1hjg1TrbrGg4P3tRbrlzMuwhtFFR2mE3ITk+V2AdKkaA== X-Received: by 2002:a63:67c5:: with SMTP id b188mr15193467pgc.111.1583741950320; Mon, 09 Mar 2020 01:19:10 -0700 (PDT) Received: from sh03840pcu.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 193sm21862277pfu.181.2020.03.09.01.19.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Mar 2020 01:19:09 -0700 (PDT) From: Baolin Wang To: sre@kernel.org Cc: baolin.wang7@gmail.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, kernel-team@android.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] power: reset: sc27xx: Change to use cpu_down() Date: Mon, 9 Mar 2020 16:18:45 +0800 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org To allow the SC27XX driver can be built as a module, and the freeze_secondary_cpus() symbol is not exported, thus we can change to use the exported cpu_down() API to shut down other cpus to avoid racing, which is same as the freeze_secondary_cpus(). Signed-off-by: Baolin Wang --- drivers/power/reset/sc27xx-poweroff.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/power/reset/sc27xx-poweroff.c b/drivers/power/reset/sc27xx-poweroff.c index 2bedd4c..91b5ece 100644 --- a/drivers/power/reset/sc27xx-poweroff.c +++ b/drivers/power/reset/sc27xx-poweroff.c @@ -29,10 +29,13 @@ */ static void sc27xx_poweroff_shutdown(void) { -#ifdef CONFIG_PM_SLEEP_SMP - int cpu = smp_processor_id(); +#ifdef CONFIG_HOTPLUG_CPU + int cpu; - freeze_secondary_cpus(cpu); + for_each_online_cpu(cpu) { + if (cpu != smp_processor_id()) + cpu_down(cpu); + } #endif } From patchwork Mon Mar 9 08:18:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11426217 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07AA314B4 for ; Mon, 9 Mar 2020 08:19:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DC70F2084E for ; Mon, 9 Mar 2020 08:19:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T8JfBJxZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726514AbgCIITP (ORCPT ); Mon, 9 Mar 2020 04:19:15 -0400 Received: from mail-pj1-f66.google.com ([209.85.216.66]:53958 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbgCIITO (ORCPT ); Mon, 9 Mar 2020 04:19:14 -0400 Received: by mail-pj1-f66.google.com with SMTP id l36so1266317pjb.3; Mon, 09 Mar 2020 01:19:13 -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 :in-reply-to:references; bh=IVmmUD2LX/XKO2jYcRB3hPlqs1LzccGE0vVFCynCeIQ=; b=T8JfBJxZhiNslsh1cb88g0iyg5Q3MO7I8FbcK7sDEiY+HOhUV1r6ZjD9yFzTbVowZ0 yhAajULCJsCJDzfGvl+IBZr6CtwW3P/vDya2QGwsZl1NF2F1md+R00gz2G1sV3wveeu0 x2SBI3zwsF+yTfEYUWs+tT3vEc1gSGt5QmTjJKd8N+ru3PyGRjN/MbLvZ9n0J21vVUeG hcTgpMqNnN2CBhlHVmfFEj0QazxS8MKT9jlUu6yFmorOjrjF3huvF+DZowAJJbuS/Nuo fi5+0k4GUR7ZA6XKv+Gaw79IVQfaAZKO/Xi5HGTszOZ2Bn8o1AfrGkb0p6IDqROi2kXq VKmQ== 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:in-reply-to:references; bh=IVmmUD2LX/XKO2jYcRB3hPlqs1LzccGE0vVFCynCeIQ=; b=AJTENxVKyBBjCeUHowjqkWQwkUAY3IUx72kJvZ2l+4g6cavPydrp0mA7UXALB0kqbJ Y+NMNOhTrX78rF6lniwgqFsH4SsGjH6932Rq2SbB5Ut/7LDiMyEFEXNqEaEGA1eQAmrB u46C41fdDZRSbBuJ/tis54IrqTSSNsjd5SjUed6oTB8FZV82moFsmnSbAg27Mtcirpb+ vB3S/bvTUXaN5RhCGW7uNjJscNpqulT21J3jJFRsAHvS85R0gDYjkp1JbB7z0KNoK3ow Waa0hh7yJuXmBioI+yxfe+QnhiflVZXLLRis9ATv8m2qsWog2HGT8WQg573btzK9Li0E mm4g== X-Gm-Message-State: ANhLgQ364kVCp02gs5Tq7dVC0gBUSxma5B7rOU3Ll1wIO7L0vPChA5+4 XHhE61iEDNOJmQOgCwkJ2kUZ0MGM X-Google-Smtp-Source: ADFU+vt07ko5Ux+nhpJGcf/tTP4BM2pXWm5admO9dpIzsxJRVA5Fr5ezWQDfTL6XroDkJdOu+BrHvg== X-Received: by 2002:a17:90a:a483:: with SMTP id z3mr12870263pjp.43.1583741952723; Mon, 09 Mar 2020 01:19:12 -0700 (PDT) Received: from sh03840pcu.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 193sm21862277pfu.181.2020.03.09.01.19.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Mar 2020 01:19:12 -0700 (PDT) From: Baolin Wang To: sre@kernel.org Cc: baolin.wang7@gmail.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, kernel-team@android.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] power: reset: sc27xx: Allow the SC27XX poweroff driver building into a module Date: Mon, 9 Mar 2020 16:18:46 +0800 Message-Id: <12b6c11ec62956173fcd84581720b4e0aed54a11.1583740881.git.baolin.wang7@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Change the config to 'tristate' and use module_platform_driver() to allow the SC27XX poweroff driver building into a module, as well as adding some mudule information. Signed-off-by: Baolin Wang --- drivers/power/reset/Kconfig | 2 +- drivers/power/reset/sc27xx-poweroff.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index 513efe8..8903803 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -248,7 +248,7 @@ config SYSCON_REBOOT_MODE action according to the mode. config POWER_RESET_SC27XX - bool "Spreadtrum SC27xx PMIC power-off driver" + tristate "Spreadtrum SC27xx PMIC power-off driver" depends on MFD_SC27XX_PMIC || COMPILE_TEST help This driver supports powering off a system through diff --git a/drivers/power/reset/sc27xx-poweroff.c b/drivers/power/reset/sc27xx-poweroff.c index 91b5ece..6986307 100644 --- a/drivers/power/reset/sc27xx-poweroff.c +++ b/drivers/power/reset/sc27xx-poweroff.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -71,4 +72,8 @@ static int sc27xx_poweroff_probe(struct platform_device *pdev) .name = "sc27xx-poweroff", }, }; -builtin_platform_driver(sc27xx_poweroff_driver); +module_platform_driver(sc27xx_poweroff_driver); + +MODULE_DESCRIPTION("Power off driver for SC27XX PMIC Device"); +MODULE_AUTHOR("Baolin Wang "); +MODULE_LICENSE("GPL v2");