From patchwork Thu Jun 28 15:08:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 141550 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2304302ljj; Thu, 28 Jun 2018 08:09:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJbtIFH9SeMu1JSWONg3fQ4yDQzZvdS4nJEl6fr26fdVSfVtg3HIhQDgmVMlxDxguCMAD2V X-Received: by 2002:a17:902:b589:: with SMTP id a9-v6mr11001593pls.140.1530198574220; Thu, 28 Jun 2018 08:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530198574; cv=none; d=google.com; s=arc-20160816; b=FmIwPBAz8+g4N50upyWijKFMrzu7UKXSZgkwpe1NWvaiQ6DiIafB1toEi+k8ydsFiQ 9wJFWq6slh6XPwd7i3yoXaTjaW/HARy/k4mB5ZUien9kyYgKrGxWK7Uh2+UPMPbRq/vu 2uLDlpyWnyis4x2jprErVKwJTEhI2bQBhVx6q6E+UKKNYp/+L400czYEjpJ1J12JFwlH x0BYQMGZHtVo7AgOYkH7XdsOsvw7cNRP+UW6X2Avgo6Ni49me0Kh365cBedTCF02xpj9 kKfAZwT0LPL/0W6U32VGtWdcDQ6EtGRiDgQwsb3Uqwur+Uhoc3mdJtIYanJuYfziYJIA K82A== 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=89f8VAf9G5wBUCNb19uxhc/MUSlz6uB1Q4psLy13zZs=; b=mJzmi4IXo0zQ5wDcgEzUBowI7tSlcnJpt1AnuAcioLlCdz89XhfuFUXlT5w6cKOizp gVwNHb0DPF0dMH0vrCvoofowJs0Ox76Q+q0URdtzjHYZ2H0X15E6GMAOlSJlLPrjaoYq OsVPUFExwaKwC7i0xSU2rex1zG0VsoKwvdDYLIkBkkb9aadFQ/UJvlJqRWb5mv464Aah TkEnO4coTaAG1rfNYFzue0P5S1B7M2QqDeoEA2CLXxkiGGt+UiKgZSTmLdAFChosbCl7 zWLMh/8OSmr6gFUqAZCcj+dn0WYzmyFmPQWX/cFPQC7xS+gbJLKaWURKrlY5ux+n5vok uyrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=default header.b=Ov60k+DD; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (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 g65-v6si7038647pfc.330.2018.06.28.08.09.34; Thu, 28 Jun 2018 08:09:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=@kernel.org header.s=default header.b=Ov60k+DD; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967013AbeF1PJc (ORCPT + 5 others); Thu, 28 Jun 2018 11:09:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:37734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966685AbeF1PJa (ORCPT ); Thu, 28 Jun 2018 11:09:30 -0400 Received: from localhost.localdomain (unknown [106.201.104.231]) (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 9E8612759C; Thu, 28 Jun 2018 15:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530198570; bh=fq5pRvv7l2RdVMoGeMRUCw4CKuyjgbrAh7ugw5EqUG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ov60k+DDPRE9GxL8cv0KRYBgbYDB9mq5HS1J4nmjFqZUlLwwz0U/Sf0ra3S3UB3tp 6DXAOXfv+dcF2Z0rHMddG7vVsRBm7alSDBRBCy9RAIMw3+KLlSqmZ1WymiYT7I7er+ ONglNZYZfgmlV2zKJuDgJhfgAyytUKsNAZ5DSWhk= 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 v5 2/6] power: reset: qcom-pon: Add Qcom PON driver Date: Thu, 28 Jun 2018 20:38:46 +0530 Message-Id: <20180628150850.15358-3-vkoul@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180628150850.15358-1-vkoul@kernel.org> References: <20180628150850.15358-1-vkoul@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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 | 11 +++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/qcom-pon.c | 91 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 drivers/power/reset/qcom-pon.c -- 2.14.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" 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..6533aa560aa1 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -104,6 +104,17 @@ config POWER_RESET_MSM help Power off and restart support for Qualcomm boards. +config POWER_RESET_QCOM_PON + tristate "Qualcomm power-on driver" + depends on ARCH_QCOM + depends on MFD_SPMI_PMIC + select REBOOT_MODE + help + Power On support for Qualcomm boards. + If you have a Qualcomm platform and need support for + power-on and reboot reason, Say Y. + If unsure, Say N. + 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");