From patchwork Mon Jun 25 05:09:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 10485027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 453A760230 for ; Mon, 25 Jun 2018 05:10:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 373D128783 for ; Mon, 25 Jun 2018 05:10:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C2E4288ED; Mon, 25 Jun 2018 05:10:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF5CA288E7 for ; Mon, 25 Jun 2018 05:10:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752094AbeFYFKV (ORCPT ); Mon, 25 Jun 2018 01:10:21 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33498 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751231AbeFYFKS (ORCPT ); Mon, 25 Jun 2018 01:10:18 -0400 Received: by mail-pf0-f196.google.com with SMTP id b17-v6so5909380pfi.0 for ; Sun, 24 Jun 2018 22:10:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OvZC+iAk90+3pa9pj8b6XSCL3EwRDiVMa/jXFWEGz1I=; b=SfM5TdNGUnrcAkTb9u2Z2pxvd4uS1x4+TQ7CpdYe25ar5kRC60AnEOagmMJI7PiZAN T8VxnNSL0rIFwWTCfb+sVQaOR791P+jIsTKEEFNWrkwutCO9D7upeEjuqZBt4DR6ee4p xzLQ/l9RKeAT8zGEJIFNI1Z9MSDThfVgoN8uI= 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; bh=OvZC+iAk90+3pa9pj8b6XSCL3EwRDiVMa/jXFWEGz1I=; b=RUM2NHEVOvq5fDk28BTsbun6faAAOvg2sI7W0zTKkvaoTOMKMX6wTvhVapuJBjshqA HiVcEKl8AkXNqCHZO/TMf+1IOUd8EbzsnD/UcfQKGwJZjKxM5JBUY9Jv4nLrd9QyQcx0 7CWRFqAZ/ohlyMAlj4ku3VzEm2NBV1PrffQklI25hGgvAcTYf48Liucrqz/MK/j3ANlM w9yGNvZW7v52vTT8Jrq/7Dkc0+AjcIolHknJwCJsTboPbCVEXFYFQng0qax2DFL7d4Em AOm2KyjzDHuAMjCFHT/4c8pdz8RSxiARROPqp3ar4tqrLxpdx6dVcesm6qIXgChfdwv8 YaNQ== X-Gm-Message-State: APt69E3ctHbzdyWON6YYKmGTPdszhFhoCZhrI+uTagjWCRKLlEjbhLjT 4zGFHmZbDe7wnLXTZ8CUzfEqMw== X-Google-Smtp-Source: ADUXVKKdsRITRJPfoxO0WzaxH6K6nCkbgGGWFNMGUKGJLdIiojEA32jU+FfFuA8Is/g0Mu85aiFSOA== X-Received: by 2002:a62:5d48:: with SMTP id r69-v6mr11372220pfb.84.1529903418363; Sun, 24 Jun 2018 22:10:18 -0700 (PDT) Received: from localhost.localdomain ([223.226.41.70]) by smtp.gmail.com with ESMTPSA id h16-v6sm20272308pfn.80.2018.06.24.22.10.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Jun 2018 22:10:17 -0700 (PDT) From: Vinod Koul X-Google-Original-From: Vinod Koul To: linux-input@vger.kernel.org, linux-pm@vger.kernel.org Cc: Bjorn Andersson , Dmitry Torokhov , Rob Herring , Sebastian Reichel , devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vinod Koul Subject: [PATCH v2 2/5] power: reset: qcom-pon: Add Qcom PON driver Date: Mon, 25 Jun 2018 10:39:35 +0530 Message-Id: <20180625050938.4700-3-vkoul@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180625050938.4700-1-vkoul@kernel.org> References: <20180625050938.4700-1-vkoul@kernel.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support Qualcomm PM8xxx PON which is responsible for reboot mode support. Co-developed-by: Bjorn Andersson Signed-off-by: Bjorn Andersson Signed-off-by: Vinod Koul --- drivers/power/reset/Kconfig | 8 ++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/qcom-pon.c | 91 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 drivers/power/reset/qcom-pon.c diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index df58fc878b3e..1572b2d3ad3d 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -104,6 +104,14 @@ config POWER_RESET_MSM help Power off and restart support for Qualcomm boards. +config POWER_RESET_QCOM_PON + bool "Qualcomm power-on driver" + depends on ARCH_QCOM + depends on MFD_SPMI_PMIC + select REBOOT_MODE + help + Power On support for Qualcomm boards. + config POWER_RESET_OCELOT_RESET bool "Microsemi Ocelot reset driver" depends on MSCC_OCELOT || COMPILE_TEST diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index 7778c7485cf1..0aebee954ac1 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o +obj-$(CONFIG_POWER_RESET_QCOM_PON) += qcom-pon.o obj-$(CONFIG_POWER_RESET_OCELOT_RESET) += ocelot-reset.o obj-$(CONFIG_POWER_RESET_PIIX4_POWEROFF) += piix4-poweroff.o obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o diff --git a/drivers/power/reset/qcom-pon.c b/drivers/power/reset/qcom-pon.c new file mode 100644 index 000000000000..0c4caaa7e88f --- /dev/null +++ b/drivers/power/reset/qcom-pon.c @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2017-18 Linaro Limited + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PON_SOFT_RB_SPARE 0x8f + +struct pm8916_pon { + struct device *dev; + struct regmap *regmap; + u32 baseaddr; + struct reboot_mode_driver reboot_mode; +}; + +static int pm8916_reboot_mode_write(struct reboot_mode_driver *reboot, + unsigned int magic) +{ + struct pm8916_pon *pon = container_of + (reboot, struct pm8916_pon, reboot_mode); + int ret; + + ret = regmap_update_bits(pon->regmap, + pon->baseaddr + PON_SOFT_RB_SPARE, + 0xfc, magic << 2); + if (ret < 0) + dev_err(pon->dev, "update reboot mode bits failed\n"); + + return ret; +} + +static int pm8916_pon_probe(struct platform_device *pdev) +{ + struct pm8916_pon *pon; + int error; + + pon = devm_kzalloc(&pdev->dev, sizeof(*pon), GFP_KERNEL); + if (!pon) + return -ENOMEM; + + pon->dev = &pdev->dev; + + pon->regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!pon->regmap) { + dev_err(&pdev->dev, "failed to locate regmap\n"); + return -ENODEV; + } + + error = of_property_read_u32(pdev->dev.of_node, "reg", + &pon->baseaddr); + if (error) + return error; + + pon->reboot_mode.dev = &pdev->dev; + pon->reboot_mode.write = pm8916_reboot_mode_write; + error = devm_reboot_mode_register(&pdev->dev, &pon->reboot_mode); + if (error) { + dev_err(&pdev->dev, "can't register reboot mode\n"); + return error; + } + + platform_set_drvdata(pdev, pon); + + return devm_of_platform_populate(&pdev->dev); +} + +static const struct of_device_id pm8916_pon_id_table[] = { + { .compatible = "qcom,pm8916-pon" }, + { } +}; +MODULE_DEVICE_TABLE(of, pm8916_pon_id_table); + +static struct platform_driver pm8916_pon_driver = { + .probe = pm8916_pon_probe, + .driver = { + .name = "pm8916-pon", + .of_match_table = of_match_ptr(pm8916_pon_id_table), + }, +}; +module_platform_driver(pm8916_pon_driver); + +MODULE_DESCRIPTION("pm8916 Power On driver"); +MODULE_LICENSE("GPL v2");