From patchwork Mon Jun 25 05:09:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 139802 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3546907lji; Sun, 24 Jun 2018 22:10:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJt79l4kKVvDuLBUmB1yoOe2SCKrOBwpqJUJcjXays0qHD7wW1tlqmUE9iIapqfN+Qv887u X-Received: by 2002:a63:42c7:: with SMTP id p190-v6mr9579417pga.142.1529903430637; Sun, 24 Jun 2018 22:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529903430; cv=none; d=google.com; s=arc-20160816; b=VQsexgVuLqOye2Wlq6+xWN9hHRkAHisgTBhxBzT//AKwklA2kkpOcynR8lq9ZKBIs4 2V7R0ZFXbVw9fjdVe9fiQ4vyzkb1ld6boeiUHIWR546AmZI9vTq65CQfP0H7CH9hvTG0 AHB74rVVrPHQdVmpsKdJYTA5/8ir+WcD84MI5/Kt6ms/rFgSLONoqxYDtgbqoL3OkyXo Nfmk+1Yog1u/Vkd932U4BIs8vnUUxK0wQYGbg/77JmUroNoLIQbOAMyGe7nrFqUKpO+8 z7aHuAtXFOLjjJe5dE32drLC4kYcVrncGs48z3S0WzEv+/yo5VbsqhmYlLR7gloy/FtG EqzQ== 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=5AjH04+CEeLwvwQkN6YjA/SZD4w4ZwN8RwY33LLEtRE=; b=k2WFck4ruvcWef7wZMeYaLHn9YoCCwyuhf27Q+59oJ5EaEodPKO/NZW8JKbEzvfP0m juaCU9/h0APEE25oknU3UKmDxP3Qeq6YYoUcZjOnh6xJH6okmF009LYiMA7pHzHJqoS4 2VMamKWe4DYgAfyESy/CZf1PD617LhCqqKPcumM45F+tWIqO0inG5HX9VcG6JcwoNOGk F8nLgwTg+6KRyrP5BIF+hNpATz5LQHZEbGOIAGCYxJj+ffmGk/enta7FHV8I1yJuqyMz 6JY8GtWRT4z05Nwoha5NCZMigfrte3yJ5ZMENxL4U9xu6lBf4VXbWG4cPUh+9/ni0KpC gLLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Wp1aduv0; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-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 w21-v6si13702917pll.96.2018.06.24.22.10.30 for ; Sun, 24 Jun 2018 22:10:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-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=Wp1aduv0; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-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 S1752129AbeFYFK1 (ORCPT ); Mon, 25 Jun 2018 01:10:27 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:34025 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752104AbeFYFKZ (ORCPT ); Mon, 25 Jun 2018 01:10:25 -0400 Received: by mail-pl0-f67.google.com with SMTP id g20-v6so6266023plq.1 for ; Sun, 24 Jun 2018 22:10:24 -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=nY8YPaOI78tC3cwGQEO9l6o4Tycg6dI0yaPZCmaQV7g=; b=Wp1aduv0EVeRWLRtT9z/+K57dX6Ix9WLh7+MB2C+3KipCOBhPMR35dcV6g+H8ISEYw ro3EtXyZl8v74pQ2iOxARQ3kfXmFkqjVjcOnK4vtdc47ZKRDh/Wyh/XYAWp7SXmRQTls NKf6QSEWOg/iJvl3JR9zv2INTljKicbgqimK4= 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=nY8YPaOI78tC3cwGQEO9l6o4Tycg6dI0yaPZCmaQV7g=; b=tqZu7mfOzAXH0mwV/W2S+3WGRAk3TfVdejMm7x+0P8i1M7TP/KA0L772zNmuLwQYLU jvzY8bdSzvXtPfCkNAZSui5ra+SvzJf5CYCDQBEeSrG/+BpUZKCYWqfycNoOMl98CK04 UoO/+EV1cp+Q2NNdWk9HC+7zaexiHxLMxinG1LIk025LYbkNcsSlbUHpIpNgQlmxAkkM 4CvU+GZqpRbO4fKNXSr+ubmtoQndp9sEF5IqlhPQXvTRyFnHkXfnGUUB4Er61ykV5DZM vE/chAEo8eHINgh5LtpWfIVAsHwQpiV6izoBH483ggf1gz1XnOrvnnIpOBw8UQyen+Jl 62+g== X-Gm-Message-State: APt69E2NIC4mHqLNN6I50FCgeA/eomd5osS4qIElBQZEWMFGDHZ1WBGk b3EYjZ3gP0SDUMUutOxZVHwlRLmGZlM= X-Received: by 2002:a17:902:9a06:: with SMTP id v6-v6mr10884934plp.21.1529903424300; Sun, 24 Jun 2018 22:10:24 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Jun 2018 22:10:23 -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 4/5] input: pm8941-pwrkey: Abstract register offsets and event code Date: Mon, 25 Jun 2018 10:39:37 +0530 Message-Id: <20180625050938.4700-5-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-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@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 | 61 ++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 13 deletions(-) -- 2.14.4 -- To unsubscribe from this list: send the line "unsubscribe linux-input" 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..b2c1093f7d62 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,12 +185,30 @@ 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 we are child on pon and read regmap and reg from + * parent + */ + pwrkey->regmap = dev_get_regmap(parent->parent, NULL); + if (!pwrkey->regmap) { + dev_err(&pdev->dev, "failed to locate regmap\n"); + return -ENODEV; + } + + error = of_property_read_u32(parent->of_node, + "reg", &pwrkey->baseaddr); + } else { + error = of_property_read_u32(pdev->dev.of_node, "reg", + &pwrkey->baseaddr); } + if (error) + return error; pwrkey->irq = platform_get_irq(pdev, 0); if (pwrkey->irq < 0) { @@ -188,11 +216,6 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev) return pwrkey->irq; } - error = of_property_read_u32(pdev->dev.of_node, "reg", - &pwrkey->baseaddr); - if (error) - return error; - error = regmap_read(pwrkey->regmap, pwrkey->baseaddr + PON_REV2, &pwrkey->revision); if (error) { @@ -200,13 +223,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_info(&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 +255,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 +301,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 25 05:09:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 139803 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3546919lji; Sun, 24 Jun 2018 22:10:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLpc/gjDEo/H71gBXT5LxAeKEPQ4Z1RLqPw7HuBiWze0cx0u8UZvqwYkrpfuMwzkD7dfAH7 X-Received: by 2002:a62:be0a:: with SMTP id l10-v6mr11264568pff.180.1529903431524; Sun, 24 Jun 2018 22:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529903431; cv=none; d=google.com; s=arc-20160816; b=C3iLby0hpFvR79buu4z1l+7hx2n2ddF+7w93QP2YGosOu7VBl2LrWI2cJm7p0hvepw lfU4MTrykFTKwhEytF09hwOp6Un7lWWWwMaOK/7HMS8skh6UTgsVrkgVJWCCpv3fv5Ui moxu6RCvdZtKYU253Jw/f4EGLrRW89/X0DarNStuEFOwYJva0WXN1esFo2qZnkyk8mqE XhJMZolPJqwx9KTDDwoNMOVmusQNgOVedt3pgUJ6Da/MpN+9GYe5USnk7VVTAkrjKI6J LbjYLcs0htagtXmcR262pHLySlAfvcFdvVoEx5r55fVo8Mb/QyUpCCXjMuCCik0TKBlA Gyuw== 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=Xg6yWDAGJ/DTTIAjzjtU+/p9MgfV8E44AFoHDfxSc6A=; b=cOHb03+1CQ8YUlWrGvUujulHM+Lb4/9tkHU0wqSrq4+cxNpY9cICHQZZpxHmAoHbBM EuXYJX5v+rAA50SpjLXGuHWpli28qxd8Z+5olRT7wnawpeKOSCVJt4vL1+4+t3iCVgsj 0Crnp3ho2kevO1wkOuDw9Qc1q67kfUkRexnCyrQ9TtjUakxSySXfb7NhgOpNLadUSCXg 4D8G1vjV7DP8Vu2yaevj/rBsP9t2RAI27GGXzCdJdV9im+jOFmAdqRFyjYHQuSD/wJ9q Gi3rf2IpNiOoz8JrJJr+TekEdtZdtyWPADmwCRd+VIWMZZ4syOgpWBZOBRIwFpwpiE+g uonw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eDU4M0jU; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-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 w21-v6si13702917pll.96.2018.06.24.22.10.31 for ; Sun, 24 Jun 2018 22:10:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-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=eDU4M0jU; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-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 S1752139AbeFYFKa (ORCPT ); Mon, 25 Jun 2018 01:10:30 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33506 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752135AbeFYFK1 (ORCPT ); Mon, 25 Jun 2018 01:10:27 -0400 Received: by mail-pf0-f195.google.com with SMTP id b17-v6so5909558pfi.0 for ; Sun, 24 Jun 2018 22:10:27 -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=7VOVuZu1f1Bdmt/sz1gKINGq6GdNR1kX+D6p2ujSgmM=; b=eDU4M0jUiqSAviwc+YHVaU+Hs8+JXx6HYC5Qyl+sE1y408wNQRF2w7eKxYcoj6JVK7 2CWyngpUXm5JPCi0Zy3qDjq06u8kON1mFNvrLH/bQlsboZN0J8T63H6EoNYSedUOLLmI p0ZQ+hbSkVNVOMtQPWbYxnhP/obbBn+KlAels= 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=7VOVuZu1f1Bdmt/sz1gKINGq6GdNR1kX+D6p2ujSgmM=; b=txhOsAc4lyvD+y3Rp2X6nIbVU0IxCp9anktH+yx3ZT1TowY31+B8CXrFHY/AJImJhE C6yNKJ2U+4g68cscXpJlHbaQaIQCQ1urFvF4sInm5UsNNseGPJ+8sU70nObIu5Aljklg Xb/DFcbWDzmPs+kZu0v8scGthUrpwwqHrmOx8n6AKGcYLUWY3fFvOnwT8swzjtVPU3Rr bRc4csItMUEeJVkSUkIxyUT3cPY3vLWkzHGKiMJ3Q1HwxRDUAZjiyABs9LYbJseGbmI1 22Jh7chDHCmliYlY585+RdhEFyzA54c0kRzZmTpG75Z9NnPsyon7ylnDJlC2Myiy12PQ E9Hw== X-Gm-Message-State: APt69E0ppS9O7nrQ5UEWn0PJKQe4Z7fbQH21Ko0AJnm6j5e+Oc4h97/b kWyj91mv2K1tqKzbAv8nXxUB921qFDM= X-Received: by 2002:a63:2581:: with SMTP id l123-v6mr9317541pgl.226.1529903427255; Sun, 24 Jun 2018 22:10:27 -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.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Jun 2018 22:10:26 -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 5/5] input: pm8941-pwrkey: Add resin entry Date: Mon, 25 Jun 2018 10:39:38 +0530 Message-Id: <20180625050938.4700-6-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-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Since handling is abstracted in this driver, we need to add resin entry in id table along with pwrkey_data. Reviewed-by: Bjorn Andersson 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-input" 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 b2c1093f7d62..e360b1bd7415 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 @@ -306,8 +308,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);