From patchwork Mon Jun 18 14:35:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 138976 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4029616lji; Mon, 18 Jun 2018 07:36:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIkWheFqEC6Afz+SuV4IfO77ThB/my8w3pvsFW5CrVF6dkvi88AoyRcQf9ph/C5HzIUySB2 X-Received: by 2002:a63:7419:: with SMTP id p25-v6mr11507985pgc.24.1529332576095; Mon, 18 Jun 2018 07:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529332576; cv=none; d=google.com; s=arc-20160816; b=fjWdnNCLN8LQyD9TxZNKsx4w1qSqI7JIEJlU/BoOYoRnNtGP41G6uZRST4n8FtIB4y eSd9AUf/amnKu8QIBlhfYvvYYEdXfDQ4KvauCkmclOakSrePIB96hsDPPMA2pxVMSg2x sQCMeT1rqC4Gu/4RSI3ZVtbz4FKLKrErqRfzJnNUZmMmN0mTbm2VVc1/a+e01P0g14EB UCoVR8uDDAnvmjztW1H/hfjGucODTd/qdCMMnXSZo7odfwJwcSjx4yTgstwFhOTshKlr E2B1lCFSDQ69hJSQL1KiPFmXBIunwGnXx53wnESsLQbnnPs2k+vYRgED55SXXHapAiV4 YbzA== 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=7wEb2hM5wFi1rbjyYsDTd0SF/DHrezahdEZKIiVYnB4=; b=DJwsbyBvbI07Unr/sMfWr+Auu3sWBurUEqazrKR+RbULYCRnjwxOeLxa6X2cX0GEHV bTq3hhz2QJoiuIQBKbzsQPmFmQQheboc2tAl5SwT+zwasxBfy/SBVl7+ICjhb69S6FNH nrl6kIs8UVc7QOPYfp6H5o7c4m27jc1/8wjECIkJT2lrCMA5xH8AL8DwHFV/mAyLwgAV K4HUYyY0PVH+8apnGRlfq0/3j0j5i/ItFfuZkVDgR9lXajIN6zlGWYbJtv55d3e2bzI8 zLW+mRtgXF3XNlsdXfjFEZFxNv0srI4sMajvHjW4b1MUOg/MOzbL7rNcaGG+eOj3+Y4B BRMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=JCeXTfBi; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (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 s72-v6si14407546pfa.367.2018.06.18.07.36.15; Mon, 18 Jun 2018 07:36:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=JCeXTfBi; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935083AbeFROgO (ORCPT + 13 others); Mon, 18 Jun 2018 10:36:14 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:40169 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934678AbeFROgN (ORCPT ); Mon, 18 Jun 2018 10:36:13 -0400 Received: by mail-pf0-f193.google.com with SMTP id z24-v6so8275431pfe.7 for ; Mon, 18 Jun 2018 07:36:12 -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=JCeXTfBi+tWxKQ7ZK6+ad9yrmPusE8JZ2OxgZQKCec6ql81rv7bxZHglXAOFMgCJyd 8Asz/jm9aDZuuZm9zY2cfmM0AifwepwHrtzO7Mxq5lgUWLIpFtPEjPY2x31Rxns45xnK sF8LgGmlHI9pzcSsZbskhah2gUEuWOY8HeagY= 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=bYUnRx5lgBQIgmnBZvI4DlWY7B69qE1w+wlcJAbDxQfVM+VrAm1VBFC+bfQQDFIoVl alM6wn99lw4CQKOKYe/ESn35rpXxSHrXvmxDwivrJdAop31hMw8bA5d1rBD5lrbLS1xu 4l0vdtizsajofg29uoR69Kk4g+P7Y8vtByqv6f/I4CGj6vOlMSvL4FlynA5++vmqBtzX j51IfjHIUJPW4NUGk1hAy/CJNpdJYxKqtJ5DZjqMbdoYBrfFH/hJrYH9JOqiYEH7g9Lb emHZsBtRu92b33CmL3UfciGpGNvK01TjB8ceu6R2SpdMciu8//L7DzeqUL2OSlioCw2w WRwQ== X-Gm-Message-State: APt69E271kO0LN2KPXlvVRzCcjsfnzVtEDBsp4DeGdO/BFe46qRiT02d OUvnPy2Q9/jc6Yhznp5tCI0cHg== X-Received: by 2002:a63:ac57:: with SMTP id z23-v6mr10886594pgn.394.1529332572546; Mon, 18 Jun 2018 07:36:12 -0700 (PDT) Received: from localhost.localdomain ([27.59.118.133]) by smtp.gmail.com with ESMTPSA id n10-v6sm28163604pfb.27.2018.06.18.07.36.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 07:36:12 -0700 (PDT) From: Vinod Koul X-Google-Original-From: Vinod Koul To: linux-input@vger.kernel.org, linux-pm@vger.kernel.org Cc: Dmitry Torokhov , Rob Herring , Sebastian Reichel , devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vinod Koul , Bjorn Andersson Subject: [PATCH 2/5] power: reset: qcom-pon: Add Qcom PON driver Date: Mon, 18 Jun 2018 20:05:45 +0530 Message-Id: <20180618143548.29900-3-vkoul@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180618143548.29900-1-vkoul@kernel.org> References: <20180618143548.29900-1-vkoul@kernel.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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");