From patchwork Wed Jun 27 11:52:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 141549 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp765460ljj; Wed, 27 Jun 2018 04:53:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL5ZNJmHPU7PsmWwxrRTz2I9mHS6gSeAe6wRmog1NU1UUihllLrIwx9+oWiTwQpCj4OxywX X-Received: by 2002:a65:448a:: with SMTP id l10-v6mr4906223pgq.382.1530100429356; Wed, 27 Jun 2018 04:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530100429; cv=none; d=google.com; s=arc-20160816; b=DwC2X65DdmiTO3w5w4P/xgFhXx72I2dP+3PcFFmpnQdlT4jqQFu/j4W2QQU1Ax1xn5 RkBYY7uEC9VkBH9ew5AennpgJEOi/0SZKgQSCLuL0sCVpbqg8LbHTw4F/L6EAOnzN7CV qHeI+Ie5DxQrJoP38czMq1uNrVjLlOKLPeFifQWqNbDSre/6dQQDnpfPoqPKU39qP1ZW AIzxhmbMoTSchA9c2VslOw7mRoIlZd8m/nmw0al6zNZTjiguEGkImIji/6v9i8xkZC5r jjuCVqz+Ns8FDW7tIdWZ3qXFNByK4IvkUYfE1wgysM+DYRmXSwgUb9qyQv1QDfcdPIhb pjKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=OvZC+iAk90+3pa9pj8b6XSCL3EwRDiVMa/jXFWEGz1I=; b=zt8n3mnA5vBVCHGNTDxcQ5n/eJy9r9dl2dnTviVMqg69DR23h8RL3ph6OippUvp5AZ egU3W4i4UpUSzTlWGDch5tEqNthQR2dPA5J3fiQEGNW12qh23Qhrh6aCBSMSxLBcFzDJ hPtm/8FBfmV4l1iXmTlsKyulFUSltmoGpydg6/F/A1AMHzKbM6HBWwYG5j/TuEoBPHCy DYO1y33OU8q/4R/XHxTiFZuvwfvJSCBJI01r5Zp3RAPOqiu+3ET/U1tjXDJnw0Dri18N nLQMpP69PTJw4Oi4AveVSuhefYdeeCrRhRzQ2sa9xVO/cYp3cjJKaua4Fnnh8vYX7FUW dVcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tFivQGel; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t21-v6si3384540pgb.553.2018.06.27.04.53.49; Wed, 27 Jun 2018 04:53:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=@kernel.org header.s=default header.b=tFivQGel; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933821AbeF0Lxr (ORCPT + 10 others); Wed, 27 Jun 2018 07:53:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:35612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934087AbeF0Lxp (ORCPT ); Wed, 27 Jun 2018 07:53:45 -0400 Received: from localhost.localdomain (unknown [106.201.61.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C8A3622BE8; Wed, 27 Jun 2018 11:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530100425; bh=/GSncg3M8JeUlgk0r6PrYNFBFlPETQ8H/q9nek68cKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tFivQGelC6By8zdnSC53lJti9sAro7r+rlAUroLS7J9CSkFvmPpwEFtWaB0y5J9z+ A9ChEA2vTb08DVLeT8Cf7qBSxU8cFQwwc2HSu5n2AtXRA8bgv3uxQtfGgbllZZJ4PB 9vsdei6jyAmsBo2w3k4RAahANBjHqp9zLDqfeEBk= 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 v4 2/6] power: reset: qcom-pon: Add Qcom PON driver Date: Wed, 27 Jun 2018 17:22:57 +0530 Message-Id: <20180627115301.21330-3-vkoul@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180627115301.21330-1-vkoul@kernel.org> References: <20180627115301.21330-1-vkoul@kernel.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 -- 2.14.4 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");