linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Some optimization for SC27XX poweroff driver
@ 2020-03-09  8:18 Baolin Wang
  2020-03-09  8:18 ` [PATCH 1/3] power: reset: sc27xx: Power off the external subsystems' connection Baolin Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Baolin Wang @ 2020-03-09  8:18 UTC (permalink / raw)
  To: sre
  Cc: baolin.wang7, orsonzhai, zhang.lyra, kernel-team, linux-pm, linux-kernel

This patch set fixes external subsystems' power issue and allows
the SC27XX poweroff driver building into a module.

Baolin Wang (2):
  power: reset: sc27xx: Change to use cpu_down()
  power: reset: sc27xx: Allow the SC27XX poweroff driver building into a
    module

Sherry Zong (1):
  power: reset: sc27xx: Power off the external subsystems' connection

 drivers/power/reset/Kconfig           |  2 +-
 drivers/power/reset/sc27xx-poweroff.c | 21 +++++++++++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] power: reset: sc27xx: Power off the external subsystems' connection
  2020-03-09  8:18 [PATCH 0/3] Some optimization for SC27XX poweroff driver Baolin Wang
@ 2020-03-09  8:18 ` Baolin Wang
  2020-03-09  8:18 ` [PATCH 2/3] power: reset: sc27xx: Change to use cpu_down() Baolin Wang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Baolin Wang @ 2020-03-09  8:18 UTC (permalink / raw)
  To: sre
  Cc: baolin.wang7, orsonzhai, zhang.lyra, kernel-team, linux-pm, linux-kernel

From: Sherry Zong <sherry.zong@unisoc.com>

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 <sherry.zong@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
---
 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);
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] power: reset: sc27xx: Change to use cpu_down()
  2020-03-09  8:18 [PATCH 0/3] Some optimization for SC27XX poweroff driver Baolin Wang
  2020-03-09  8:18 ` [PATCH 1/3] power: reset: sc27xx: Power off the external subsystems' connection Baolin Wang
@ 2020-03-09  8:18 ` Baolin Wang
  2020-03-09  8:18 ` [PATCH 3/3] power: reset: sc27xx: Allow the SC27XX poweroff driver building into a module Baolin Wang
  2020-03-11 22:34 ` [PATCH 0/3] Some optimization for SC27XX poweroff driver Sebastian Reichel
  3 siblings, 0 replies; 5+ messages in thread
From: Baolin Wang @ 2020-03-09  8:18 UTC (permalink / raw)
  To: sre
  Cc: baolin.wang7, orsonzhai, zhang.lyra, kernel-team, linux-pm, linux-kernel

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 <baolin.wang7@gmail.com>
---
 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
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] power: reset: sc27xx: Allow the SC27XX poweroff driver building into a module
  2020-03-09  8:18 [PATCH 0/3] Some optimization for SC27XX poweroff driver Baolin Wang
  2020-03-09  8:18 ` [PATCH 1/3] power: reset: sc27xx: Power off the external subsystems' connection Baolin Wang
  2020-03-09  8:18 ` [PATCH 2/3] power: reset: sc27xx: Change to use cpu_down() Baolin Wang
@ 2020-03-09  8:18 ` Baolin Wang
  2020-03-11 22:34 ` [PATCH 0/3] Some optimization for SC27XX poweroff driver Sebastian Reichel
  3 siblings, 0 replies; 5+ messages in thread
From: Baolin Wang @ 2020-03-09  8:18 UTC (permalink / raw)
  To: sre
  Cc: baolin.wang7, orsonzhai, zhang.lyra, kernel-team, linux-pm, linux-kernel

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 <baolin.wang7@gmail.com>
---
 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 <linux/cpu.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/regmap.h>
@@ -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 <baolin.wang@unisoc.com>");
+MODULE_LICENSE("GPL v2");
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] Some optimization for SC27XX poweroff driver
  2020-03-09  8:18 [PATCH 0/3] Some optimization for SC27XX poweroff driver Baolin Wang
                   ` (2 preceding siblings ...)
  2020-03-09  8:18 ` [PATCH 3/3] power: reset: sc27xx: Allow the SC27XX poweroff driver building into a module Baolin Wang
@ 2020-03-11 22:34 ` Sebastian Reichel
  3 siblings, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2020-03-11 22:34 UTC (permalink / raw)
  To: Baolin Wang; +Cc: orsonzhai, zhang.lyra, kernel-team, linux-pm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 688 bytes --]

Hi,

On Mon, Mar 09, 2020 at 04:18:43PM +0800, Baolin Wang wrote:
> This patch set fixes external subsystems' power issue and allows
> the SC27XX poweroff driver building into a module.

Thanks, queued.

-- Sebastian

> Baolin Wang (2):
>   power: reset: sc27xx: Change to use cpu_down()
>   power: reset: sc27xx: Allow the SC27XX poweroff driver building into a
>     module
> 
> Sherry Zong (1):
>   power: reset: sc27xx: Power off the external subsystems' connection
> 
>  drivers/power/reset/Kconfig           |  2 +-
>  drivers/power/reset/sc27xx-poweroff.c | 21 +++++++++++++++++----
>  2 files changed, 18 insertions(+), 5 deletions(-)
> 
> -- 
> 1.9.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-11 22:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-09  8:18 [PATCH 0/3] Some optimization for SC27XX poweroff driver Baolin Wang
2020-03-09  8:18 ` [PATCH 1/3] power: reset: sc27xx: Power off the external subsystems' connection Baolin Wang
2020-03-09  8:18 ` [PATCH 2/3] power: reset: sc27xx: Change to use cpu_down() Baolin Wang
2020-03-09  8:18 ` [PATCH 3/3] power: reset: sc27xx: Allow the SC27XX poweroff driver building into a module Baolin Wang
2020-03-11 22:34 ` [PATCH 0/3] Some optimization for SC27XX poweroff driver Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).