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"); From patchwork Mon Jun 18 14:35:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 138978 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4029746lji; Mon, 18 Jun 2018 07:36:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKSKI1z0fGa9z68Cz+DTMBkKTOOy2eInft3YnLvFY60Ecv8oOHWzBaRlZKa9fEbwoih+IBz X-Received: by 2002:a63:931c:: with SMTP id b28-v6mr11398341pge.167.1529332583033; Mon, 18 Jun 2018 07:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529332583; cv=none; d=google.com; s=arc-20160816; b=R+GDOXwX3E6bLYlhL1Doecv+1Mgs116i0Jnz8HMPHM8GrMiGiOMrAl9kDY9XAqdbC6 04OkryTK/D5Gtn3YwSez/CVgkACCUVisXZrkhI3HRKfjlcXku7OsaBhaHcZ4p/GqHcIy pNuqhcn/eFk7q+ngkbihrd3FHXstnjoPaQQWqX9mpNtYetYL4nolDqnDUl+PInA/Gc9G eQUSuGDUl5XfWW6O0yeG0WxzcJPKy5bu59N/tB4OKNQibq1vGFJbXw/xUp0JCnLTkisq GDlEmRpqi4FKkmjfD/RNNk6iA/+AzSJAp2i+2KT6ut2UHDo1rgok13e4kJCKsuq1zTeW ouvw== 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=oYSIsCwO8SWQrz0fOiEPMtefubDM77N/TEx3ExOnd04=; b=FpuRzW6W253PVmUoWkmVNf0kNebw4nsqQFsH4MTMejsY9d+L53wVKjsrd4SGTL+fF/ G5mWTgHJVED6NVnB7DPuy5U5Iq0GV0e16s99zFWfCdR8hLA6koDypQ4YHbrG8wn8cKtn miCfEiHuimQog+uNkMberRSY9WqG1Vpw83dCHHC+BxFjVhUypgL9nefRtlBWdAOLC50O rLvTmPf7p8l1WD282GgL9p/DtseyskQj20gLhYDFbVC8Ar1FWl41cc6N0M31iplSnRZN sc6CAPP8q7L9sLQmCpBV2Nd4oHo1lODIcbUfYEcfR6AqWDkgx8pGLldBdDDng1dFWrQW AuCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Vb7j1L1M; 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 d2-v6si15409058plo.42.2018.06.18.07.36.22; Mon, 18 Jun 2018 07:36:23 -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=Vb7j1L1M; 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 S934731AbeFROgV (ORCPT + 13 others); Mon, 18 Jun 2018 10:36:21 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:46472 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934556AbeFROgT (ORCPT ); Mon, 18 Jun 2018 10:36:19 -0400 Received: by mail-pg0-f65.google.com with SMTP id d2-v6so7616632pga.13 for ; Mon, 18 Jun 2018 07:36:19 -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=EPkZc+nDD8WorWc97gJveY1wE318d7gWEoVEFw/ZLJE=; b=Vb7j1L1M6RtU5KrBqAdFI2yZznJqVKph5RW6XLHo4P37y7sPW2hCfR71ZXdeydst0J QjOXvHWQvOZH+myVLgj52R44nZvH4E1vpA8Ht0X7hl4nSJ2j2RY/w8iBwWqgeQW3mXtq oJshjU3sZYmRv4gAyYquawdCF7F/ZEH2OZnW8= 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=EPkZc+nDD8WorWc97gJveY1wE318d7gWEoVEFw/ZLJE=; b=EDnmXattCVlEz/V6eGcBG37qNZvx3XPISTyW9Z2MpZU4Nkj/Jxo1/jANkZaOFnhFgz SoLN9HHQXyp1X/hlIDbi7+h/uK8p73Rud/kCUMi7LaLYCXC9BwHYQv0G0lBqZzebCQOO WU/tUcMdYuq5z8V0qK9KyngNBk6h0tCyvOVg2ZUxnbtLpbFKAAcd9T1cpOElfneMQwBa km6ODnzzkMn1Ym+8PCP8IeGEz5wN8tK05U4r/jwXjIMkt4RIFrqvoftAzPQpw4QJ76tk U/7NkapX3LcbEAzacxcqJcwEyQB83fQHf2JHym3808+fgtOqxERBXxTuxDi6ay7Xs2vN jKMw== X-Gm-Message-State: APt69E2vjvaMVi3QktrZZPUsCkbXuTR4G8kyZnnPMG9eUWbbo+7f0OZS EyK9fWfZy39m1fQvpH5jnr6TTA== X-Received: by 2002:a65:4545:: with SMTP id x5-v6mr11250411pgr.4.1529332579234; Mon, 18 Jun 2018 07:36:19 -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.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 07:36:18 -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 Subject: [PATCH 4/5] input: pm8941-pwrkey: Abstract register offsets and event code Date: Mon, 18 Jun 2018 20:05:47 +0530 Message-Id: <20180618143548.29900-5-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 In order to support resin thru the pwrkey driver (they are very similar in nature) we need to abstract the handling in this driver. First we abstract pull_up_bit and status_bit along in driver data. The event code sent for key events is quiried from DT. Since the device can be child of pon lookup regmap and reg from parent if lookup fails (we are child). Signed-off-by: Vinod Koul --- drivers/input/misc/pm8941-pwrkey.c | 56 +++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 10 deletions(-) -- 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/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c index 18ad956454f1..aedb6ea2b50a 100644 --- a/drivers/input/misc/pm8941-pwrkey.c +++ b/drivers/input/misc/pm8941-pwrkey.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,10 @@ #define PON_DBC_CTL 0x71 #define PON_DBC_DELAY_MASK 0x7 +struct pm8941_data { + unsigned int pull_up_bit; + unsigned int status_bit; +}; struct pm8941_pwrkey { struct device *dev; @@ -52,6 +57,9 @@ struct pm8941_pwrkey { unsigned int revision; struct notifier_block reboot_notifier; + + unsigned int code; + const struct pm8941_data *data; }; static int pm8941_reboot_notify(struct notifier_block *nb, @@ -124,7 +132,8 @@ static irqreturn_t pm8941_pwrkey_irq(int irq, void *_data) if (error) return IRQ_HANDLED; - input_report_key(pwrkey->input, KEY_POWER, !!(sts & PON_KPDPWR_N_SET)); + input_report_key(pwrkey->input, pwrkey->code, + !!(sts & pwrkey->data->status_bit)); input_sync(pwrkey->input); return IRQ_HANDLED; @@ -157,6 +166,7 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev) { struct pm8941_pwrkey *pwrkey; bool pull_up; + struct device *parent; u32 req_delay; int error; @@ -175,11 +185,20 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev) return -ENOMEM; pwrkey->dev = &pdev->dev; + pwrkey->data = of_device_get_match_data(&pdev->dev); - pwrkey->regmap = dev_get_regmap(pdev->dev.parent, NULL); + parent = pdev->dev.parent; + pwrkey->regmap = dev_get_regmap(parent, NULL); if (!pwrkey->regmap) { - dev_err(&pdev->dev, "failed to locate regmap\n"); - return -ENODEV; + /* + * we failed to get regmap for parent, check if + * parent->parent has it (device would be child of pon) + */ + pwrkey->regmap = dev_get_regmap(parent->parent, NULL); + if (!pwrkey->regmap) { + dev_err(&pdev->dev, "failed to locate regmap\n"); + return -ENODEV; + } } pwrkey->irq = platform_get_irq(pdev, 0); @@ -190,8 +209,13 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev) error = of_property_read_u32(pdev->dev.of_node, "reg", &pwrkey->baseaddr); - if (error) - return error; + if (error) { + /* check if parent has reg before bailing */ + error = of_property_read_u32(pdev->dev.parent->of_node, + "reg", &pwrkey->baseaddr); + if (error) + return error; + } error = regmap_read(pwrkey->regmap, pwrkey->baseaddr + PON_REV2, &pwrkey->revision); @@ -200,13 +224,20 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev) return error; } + error = of_property_read_u32(pdev->dev.of_node, "linux,code", + &pwrkey->code); + if (error) { + dev_err(&pdev->dev, "no linux,code assuming power%d\n", error); + pwrkey->code = KEY_POWER; + } + pwrkey->input = devm_input_allocate_device(&pdev->dev); if (!pwrkey->input) { dev_dbg(&pdev->dev, "unable to allocate input device\n"); return -ENOMEM; } - input_set_capability(pwrkey->input, EV_KEY, KEY_POWER); + input_set_capability(pwrkey->input, EV_KEY, pwrkey->code); pwrkey->input->name = "pm8941_pwrkey"; pwrkey->input->phys = "pm8941_pwrkey/input0"; @@ -225,8 +256,8 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev) error = regmap_update_bits(pwrkey->regmap, pwrkey->baseaddr + PON_PULL_CTL, - PON_KPDPWR_PULL_UP, - pull_up ? PON_KPDPWR_PULL_UP : 0); + pwrkey->data->pull_up_bit, + pull_up ? pwrkey->data->pull_up_bit : 0); if (error) { dev_err(&pdev->dev, "failed to set pull: %d\n", error); return error; @@ -271,8 +302,13 @@ static int pm8941_pwrkey_remove(struct platform_device *pdev) return 0; } +static const struct pm8941_data pwrkey_data = { + .pull_up_bit = PON_KPDPWR_PULL_UP, + .status_bit = PON_KPDPWR_N_SET, +}; + static const struct of_device_id pm8941_pwr_key_id_table[] = { - { .compatible = "qcom,pm8941-pwrkey" }, + { .compatible = "qcom,pm8941-pwrkey", .data = &pwrkey_data }, { } }; MODULE_DEVICE_TABLE(of, pm8941_pwr_key_id_table); From patchwork Mon Jun 18 14:35:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 138979 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4029889lji; Mon, 18 Jun 2018 07:36:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLcKg+salrluaLizDokqV9KWnvmuIEZtbvr2sH95cwsKfgrX1biIU/KZafV6WPURnycJyCE X-Received: by 2002:a17:902:981:: with SMTP id 1-v6mr14515334pln.11.1529332589290; Mon, 18 Jun 2018 07:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529332589; cv=none; d=google.com; s=arc-20160816; b=CT+oHFilERLqAzD75zEtbEBWPLUINW0i6QkN5JbjVIQNz8W53I3VJiaUrgCWG2spHa MM1ke7BgleL7P1l74RdB+SPzwvbNsH3a/541CtOuz7pn+7DRTRwRw7a3tCQAQdlf46Fa 7yMQ+uSakTCr7Wh767A3i5xzbxQaI6tl3sTn0VqszM7nSkHZdMjndLLVlll1yDEd6uGE jfxo5B1ouJvcNsGBpd4EXJ+joolXwcl6FaZqXkiRVQYxwjckJf9Cv7bXD8VIJ0xxyMLU UP+f5C8+qyx+VNvlUax/x3Ssv10kHBwjBzMs1Yq1N8usQPhIcaLHiSfBIvE7ZXPi+FmX y8ow== 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=xq/mmP3YM5b6TYnQuPdZvJoYeNIY2Et6Ay4tl96/FBI=; b=SpvOlHP/dJM0DOET+NfP3QbYgqpUuARkuy4EKuc84uNI8Y8A1tGqc994UwhVLuBKqt ZLSbz+cChvcwdr2nmDYp3k4kWYyn4r1wEj2hiWm0gxLP5J1O49YK/JA+zLWr5RSrMlP+ ZBG3kyfLBlyBSH0aSdcOEpMLr0sr6OAljfhGF4AvOOMqq5HxHoLXWE1bs8L6VSuhq7u5 /8nSCy54rQTIGrdhWS/lgRKbQmUrzTFKsC3FQWPXxcvdwUUBbEpotpWAqRElzhtIluwZ KaSOK3W8qyY6cVzkpdOthKK6QQ0ZdgIXOxyU3LvUgwXieQKVZKv4uPRWrr3vXd+KhKId 9aBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=PuYNmg4m; 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 j189-v6si13741056pfg.351.2018.06.18.07.36.29; Mon, 18 Jun 2018 07:36:29 -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=PuYNmg4m; 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 S934667AbeFROgZ (ORCPT + 13 others); Mon, 18 Jun 2018 10:36:25 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:43971 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934711AbeFROgX (ORCPT ); Mon, 18 Jun 2018 10:36:23 -0400 Received: by mail-pl0-f68.google.com with SMTP id c41-v6so9138798plj.10 for ; Mon, 18 Jun 2018 07:36:23 -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=sxHOaIOKDL0C9xkCvI3V+zEaAB0OrpFLYwGIYL9Hok8=; b=PuYNmg4m7DnodfTD1e+1WhTC9aCVZmly85e18xcL8elrgelyuZU1v0OUdJbsUOAfIb IxGjJY4ffcRf8DpPaKWkX++2Gd0pAgeexi98SHGBdNb14OH8iyOYdjSE2Z+9vIhuxWGF G+PxJzZG1+QopB8OX+tZOyYnplMtDqZrjCHCE= 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=sxHOaIOKDL0C9xkCvI3V+zEaAB0OrpFLYwGIYL9Hok8=; b=mHajsPIZyjFetzC8fBYaO8eH5kiujcMN0W9fRd8aFwcsOIhzYBBn/LbnVupdfkx2AV vuZmqhLjM2YcMWQfdss/ABu0GzuMBX/1aea/HljhSxhU60sqr2rOK7aTfxPDGFLSTMRt PjpCzE9JMvOyuaByZk5BvmqCiMZo4Aw4L+idTx7ji2E7lm4k9JvRo7OrhSkMvYgA7f/+ a3jK5n7JLh5Oijdvjh3j+LIUSg3AYqwlFclAZjfK53wKUVhQoO1rEz9XmtrDO0gaIxZo 5g5Z/WhT4EP2BcxkWhKlKiwuCgbbkHP4WmIhh8GDVmrlxpqlZlJatw8BcQEBOvuRXAeI dkfA== X-Gm-Message-State: APt69E0pRlctXeGQasxY3cqeGOCJeUwvdZqBN7qmHNYGrmt3bb6Qk9mR xGYVlUaB7WkDBtF/C1cCQrxFJg== X-Received: by 2002:a17:902:be0d:: with SMTP id r13-v6mr14358236pls.299.1529332582704; Mon, 18 Jun 2018 07:36:22 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 07:36:22 -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 Subject: [PATCH 5/5] input: pm8941-pwrkey: Add resin entry Date: Mon, 18 Jun 2018 20:05:48 +0530 Message-Id: <20180618143548.29900-6-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 Since handling is abstracted in this driver, we need to add resin entry in id table along with pwrkey_data. Signed-off-by: Vinod Koul --- drivers/input/misc/pm8941-pwrkey.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 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 Reviewed-by: Bjorn Andersson diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c index aedb6ea2b50a..913405404a92 100644 --- a/drivers/input/misc/pm8941-pwrkey.c +++ b/drivers/input/misc/pm8941-pwrkey.c @@ -29,6 +29,7 @@ #define PON_RT_STS 0x10 #define PON_KPDPWR_N_SET BIT(0) +#define PON_RESIN_N_SET BIT(1) #define PON_PS_HOLD_RST_CTL 0x5a #define PON_PS_HOLD_RST_CTL2 0x5b @@ -39,6 +40,7 @@ #define PON_PULL_CTL 0x70 #define PON_KPDPWR_PULL_UP BIT(1) +#define PON_RESIN_PULL_UP BIT(0) #define PON_DBC_CTL 0x71 #define PON_DBC_DELAY_MASK 0x7 @@ -307,8 +309,14 @@ static const struct pm8941_data pwrkey_data = { .status_bit = PON_KPDPWR_N_SET, }; +static const struct pm8941_data resin_data = { + .pull_up_bit = PON_RESIN_PULL_UP, + .status_bit = PON_RESIN_N_SET, +}; + static const struct of_device_id pm8941_pwr_key_id_table[] = { { .compatible = "qcom,pm8941-pwrkey", .data = &pwrkey_data }, + { .compatible = "qcom,pm8941-resin", .data = &resin_data }, { } }; MODULE_DEVICE_TABLE(of, pm8941_pwr_key_id_table);