Received: by 10.223.176.5 with SMTP id f5csp2605082wra; Mon, 29 Jan 2018 00:39:41 -0800 (PST) X-Google-Smtp-Source: AH8x224JZUOz3dRHO2o5tlNJ+wmLz+kA1uwocZmxWCVdyUOiz7zfyikksFzecWKUk+ZBqmDyDywF X-Received: by 10.98.107.71 with SMTP id g68mr25783720pfc.96.1517215181619; Mon, 29 Jan 2018 00:39:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517215181; cv=none; d=google.com; s=arc-20160816; b=kRnXk/9jC8OmZK56hIRO6gXEHD8gOrafc6OgUr7qi5NEu/CJ1ZOtkZmk1R6jN1p/E7 mCzFm6U9OT2TXXTAC/uDkmOsIaSIh7t65H/P1DaiE/oxorkE0g611cY2UnLOJgoyuu+t Nhgbt9x56ACg+DAIFAJhdzjtW/AFPDRjLCHF111hii3zb+fqTwX6ekwOA5PNeJUXqXVK KzVDeZtKD2qAmZPEhURHDJZKq2pMogmHnWx2sxHvTQTbDBOaTioXWz/F9QRRSEds+JmK L4yWYwiNheoAadrlgngupLMo+7IR77U2dX5/Xad/drEukjP3bGYmvdTTHKj7G/NNeXdK arLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=TPSeHhX6VNvCM1gcf49unTEKbGPJxuDc6lVG381prXE=; b=Lpl9gpRaOVhLhJF1QQyGEi4ad8wO7/fv39eC2d/NiBrqpDbW6KCZc0ZhpcEqo08qhK TdlPnDuKQznQIm4I9vyXuOJ7AqYDHiTU//6cQWsn7s8+tre/2s2zv77Ng5Qc8BCNc+qM uLnR6yIqd4rejJlW9hLdWy5CHlziw/8Pi4L3hWH7mqzGtPK9Xy7qVOl4nM0pKoqYeTDn iCgRG8k/HaezD3FOTOFEOz9vpHrjN2JBpCNv9Cn7tSPv9AuFISg3e4LsKrib/z9uhHeA 3HYZj7vSZpBCv90YzZYmYP4bf2STu/ahT3p+U87e98Az99tb5JPEYfwYRbKmlcEBr620 ez4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K/9tw2ed; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5-v6si8877084plt.284.2018.01.29.00.39.04; Mon, 29 Jan 2018 00:39:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K/9tw2ed; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751509AbeA2IhN (ORCPT + 99 others); Mon, 29 Jan 2018 03:37:13 -0500 Received: from mail-oi0-f66.google.com ([209.85.218.66]:38481 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbeA2IhL (ORCPT ); Mon, 29 Jan 2018 03:37:11 -0500 Received: by mail-oi0-f66.google.com with SMTP id j15so1311634oii.5 for ; Mon, 29 Jan 2018 00:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=TPSeHhX6VNvCM1gcf49unTEKbGPJxuDc6lVG381prXE=; b=K/9tw2edkyYf3SYxYONr2jJyytn1lMEx5EDyZxL2WssIBv4PrlAbvsBe4JzctAcMsW LdV57dB8ZzWpJ3fWy6vy6M76H6sc/BbhJa1BKVKNW4ed9OKeXmjl2qH5RfV3aCTWzQv1 Qfg1oEncD+HZ/AYMANkzWxhmQPSvHlDSl6hYs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=TPSeHhX6VNvCM1gcf49unTEKbGPJxuDc6lVG381prXE=; b=uVYyQqcjN10wwnSbPZxbBgrm+9p+LH4mW2nvHXAlDJqDKIH8OwBJtlD8gVNCVhQdAG h15JzuK542XSpbBADbKuGfTJ+zM7rppJLhFBEg7CAE1du5MoxmsWtIjy/O2dYVza31kG vHHf1MWsoBBLVXV8rT9u8bVTV16hHCYO/Z9E2rzjlMkHiN2j9disLrvxnVWi99EmCTQb X/9uHB/jRzWJPNhoRvaWjb17VVSIajkgMD66hJqHlBRNlf+aTgWxAkKC3cN9MvejNwLQ LiLYe4hySDddYtNpIR+/SADw1aWiUDqxTuq12tI8A3I9UvLYhIQkLLQFviKGFTH1XszZ ghiw== X-Gm-Message-State: AKwxytej8yuq9IW6cChSZxSYWat3dyfBMbqtcA7jqN7GOSoLDfDIf8e2 8fPzmjcShA9MdrjFMOhYGdNKqZ9p4JEn3ooB5yan5H60 X-Received: by 10.202.95.6 with SMTP id t6mr12491239oib.57.1517215031303; Mon, 29 Jan 2018 00:37:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.28.174 with HTTP; Mon, 29 Jan 2018 00:37:10 -0800 (PST) In-Reply-To: <5822b56a4e65e27183f8bf712d5889b11f90111e.1515118527.git.baolin.wang@linaro.org> References: <5822b56a4e65e27183f8bf712d5889b11f90111e.1515118527.git.baolin.wang@linaro.org> From: Baolin Wang Date: Mon, 29 Jan 2018 16:37:10 +0800 Message-ID: Subject: Re: [PATCH] power: reset: Add Spreadtrum SC27xx PMIC power off support To: Sebastian Reichel Cc: Arnd Bergmann , Mark Brown , Baolin Wang , LKML , Linux PM list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sebastian, On 15 January 2018 at 15:58, Baolin Wang wrote: > On Spreadtrum platform, we need power off system through external SC27xx > series PMICs including the SC2720, SC2721, SC2723, SC2730 and SC2731 chips. > Thus this patch adds SC27xx series PMICs power-off support. > > Signed-off-by: Baolin Wang Do you have any comments for this patch? Thanks. > --- > drivers/power/reset/Kconfig | 9 +++++ > drivers/power/reset/Makefile | 1 + > drivers/power/reset/sc27xx-poweroff.c | 65 +++++++++++++++++++++++++++++++++ > 3 files changed, 75 insertions(+) > create mode 100644 drivers/power/reset/sc27xx-poweroff.c > > diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig > index ca0de1a..611ae56 100644 > --- a/drivers/power/reset/Kconfig > +++ b/drivers/power/reset/Kconfig > @@ -227,5 +227,14 @@ config SYSCON_REBOOT_MODE > register, then the bootloader can read it to take different > action according to the mode. > > +config POWER_RESET_SC27XX > + tristate "Spreadtrum SC27xx PMIC power-off driver" > + depends on MFD_SC27XX_PMIC || COMPILE_TEST > + help > + This driver supports powering off a system through > + Spreadtrum SC27xx series PMICs. The SC27xx series > + PMICs includes the SC2720, SC2721, SC2723, SC2730 > + and SC2731 chips. > + > endif > > diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile > index aeb65ed..225d645 100644 > --- a/drivers/power/reset/Makefile > +++ b/drivers/power/reset/Makefile > @@ -27,3 +27,4 @@ obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o > obj-$(CONFIG_POWER_RESET_ZX) += zx-reboot.o > obj-$(CONFIG_REBOOT_MODE) += reboot-mode.o > obj-$(CONFIG_SYSCON_REBOOT_MODE) += syscon-reboot-mode.o > +obj-$(CONFIG_POWER_RESET_SC27XX) += sc27xx-poweroff.o > diff --git a/drivers/power/reset/sc27xx-poweroff.c b/drivers/power/reset/sc27xx-poweroff.c > new file mode 100644 > index 0000000..8e4b6a0 > --- /dev/null > +++ b/drivers/power/reset/sc27xx-poweroff.c > @@ -0,0 +1,65 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (C) 2017 Spreadtrum Communications Inc. > + * Copyright (c) 2017 Linaro Ltd. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define SC27XX_PWR_PD_HW 0xc2c > +#define SC27XX_PWR_OFF_EN BIT(0) > + > +static struct regmap *regmap; > + > +/* > + * On Spreadtrum platform, we need power off system through external SC27xx > + * series PMICs, and it is one similar SPI bus mapped by regmap to access PMIC, > + * which is not fast io access. > + * > + * So before stopping other cores, we need release other cores' resource by > + * taking cpus down to avoid racing regmap or spi mutex lock when poweroff > + * system through PMIC. > + */ > +void sc27xx_poweroff_shutdown(void) > +{ > + int cpu = smp_processor_id(); > + > + freeze_secondary_cpus(cpu); > +} > + > +static struct syscore_ops poweroff_syscore_ops = { > + .shutdown = sc27xx_poweroff_shutdown, > +}; > + > +static void sc27xx_poweroff_do_poweroff(void) > +{ > + regmap_write(regmap, SC27XX_PWR_PD_HW, SC27XX_PWR_OFF_EN); > +} > + > +static int sc27xx_poweroff_probe(struct platform_device *pdev) > +{ > + regmap = dev_get_regmap(pdev->dev.parent, NULL); > + if (!regmap) > + return -ENODEV; > + > + pm_power_off = sc27xx_poweroff_do_poweroff; > + register_syscore_ops(&poweroff_syscore_ops); > + return 0; > +} > + > +static struct platform_driver sc27xx_poweroff_driver = { > + .probe = sc27xx_poweroff_probe, > + .driver = { > + .name = "sc27xx-poweroff", > + }, > +}; > +module_platform_driver(sc27xx_poweroff_driver); > + > +MODULE_DESCRIPTION("Spreadtrum SC27xx PMIC Poweroff Driver"); > +MODULE_LICENSE("GPL v2"); > -- > 1.7.9.5 > -- Baolin.wang Best Regards