From patchwork Mon Jul 17 09:53:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 107880 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp4351338obm; Mon, 17 Jul 2017 02:54:09 -0700 (PDT) X-Received: by 10.84.140.235 with SMTP id 98mr28745670plt.26.1500285249809; Mon, 17 Jul 2017 02:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500285249; cv=none; d=google.com; s=arc-20160816; b=O5Ql3WOrcBNH7oNP7QtwzGVWVN25kQbTBBinKJUufDJAk4zG5lngwN61eLXJmU1X29 ZGaeFHfsvQF4dwyrWokqhmtXVNfR1/PIs5VYWSjkt8BOY9EOAtWx6Zyh+9qz3RJsOrKI 9jFV0oKS9U9qplzkl7O2ZwmR9P70dFYv+24lAYAhHMxz7xco+LL88fcvxpR3hUfvUrgI qkD7/kADR6MfaGlTxpUWPMu6tHibZVfc0nh5ywdZrUE0FiEnQCpJF3NqY9wJSzyeYK8I nH9tR5XX3f1UNNEO/+71InyXmQeuObSEZeiu7BXOxDtoouCGpR5Do58dO2aXqWX8thPV z+pQ== 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:arc-authentication-results; bh=yOBftGJqDquZZ2C+3MNC84TaQ0I3M4v9Z45s23k6WP8=; b=kVVLfxjrekhURsffe5QuNLSwZ0Orfo1l3b2sXpWKCONRr5Q2/yyE9Vw9t+otVh5+3d 1itBXnbzP5ivfKdzg+JkVSZ+1xfEHk9e2Qp5BPPK0iHzkcl+Khu1B/HfippjIgsSuEyD H8ELNHq6ZnqNP9PbelZ4/gSGW6CYyaKYnSprUzgmCFIlRfx4Qo3LedOhHUy7VDzIlGDl Ga/ohQM0yOTQLUA5OmNl7LaOjixn2+favM1DPTEiw5cJ4wcjUuKOf95yseN+e2VxwkI8 iJ2UnxLf4tZXryZfJFfiWApUSSRJqmfeMt2S88Gb2mki1McBFOX7YugGvlgdC84oe6gB h//Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c125si12272862pfg.322.2017.07.17.02.54.09; Mon, 17 Jul 2017 02:54:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751406AbdGQJxy (ORCPT + 25 others); Mon, 17 Jul 2017 05:53:54 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:45547 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751303AbdGQJxv (ORCPT ); Mon, 17 Jul 2017 05:53:51 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 70410208DE; Mon, 17 Jul 2017 11:53:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 38853208AA; Mon, 17 Jul 2017 11:53:48 +0200 (CEST) From: Quentin Schulz To: dmitry.torokhov@gmail.com, wens@csie.org, lee.jones@linaro.org Cc: Quentin Schulz , hdegoede@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@free-electrons.com, maxime.ripard@free-electrons.com Subject: [PATCH 1/2] Input: axp20x-pek: add support for AXP221 PEK Date: Mon, 17 Jul 2017 11:53:06 +0200 Message-Id: <20170717095307.15986-2-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170717095307.15986-1-quentin.schulz@free-electrons.com> References: <20170717095307.15986-1-quentin.schulz@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The AXP221 has different values for startup time bits from the AXP20X. This patch introduces a different platform_device_id to the driver and adds the necessary code to handle the different platform_device_ids. Signed-off-by: Quentin Schulz --- drivers/input/misc/axp20x-pek.c | 62 ++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 10 deletions(-) -- 2.11.0 diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c index 38c79ebff033..3efa1de51569 100644 --- a/drivers/input/misc/axp20x-pek.c +++ b/drivers/input/misc/axp20x-pek.c @@ -32,6 +32,7 @@ struct axp20x_pek { struct axp20x_dev *axp20x; struct input_dev *input; + struct attribute_group *attribute_group; int irq_dbr; int irq_dbf; }; @@ -41,14 +42,21 @@ struct axp20x_time { unsigned int idx; }; -static const struct axp20x_time startup_time[] = { +static const struct axp20x_time axp20x_startup_time[] = { { .time = 128, .idx = 0 }, { .time = 1000, .idx = 2 }, { .time = 3000, .idx = 1 }, { .time = 2000, .idx = 3 }, }; -static const struct axp20x_time shutdown_time[] = { +static const struct axp20x_time axp221_startup_time[] = { + { .time = 128, .idx = 0 }, + { .time = 1000, .idx = 1 }, + { .time = 2000, .idx = 2 }, + { .time = 3000, .idx = 3 }, +}; + +static const struct axp20x_time axp20x_shutdown_time[] = { { .time = 4000, .idx = 0 }, { .time = 6000, .idx = 1 }, { .time = 8000, .idx = 2 }, @@ -61,15 +69,20 @@ struct axp20x_pek_ext_attr { }; static struct axp20x_pek_ext_attr axp20x_pek_startup_ext_attr = { - .p_time = startup_time, + .p_time = axp20x_startup_time, .mask = AXP20X_PEK_STARTUP_MASK, }; static struct axp20x_pek_ext_attr axp20x_pek_shutdown_ext_attr = { - .p_time = shutdown_time, + .p_time = axp20x_shutdown_time, .mask = AXP20X_PEK_SHUTDOWN_MASK, }; +static struct axp20x_pek_ext_attr axp221_pek_startup_ext_attr = { + .p_time = axp221_startup_time, + .mask = AXP20X_PEK_STARTUP_MASK, +}; + static struct axp20x_pek_ext_attr *get_axp_ext_attr(struct device_attribute *attr) { return container_of(attr, struct dev_ext_attribute, attr)->var; @@ -148,6 +161,11 @@ static struct dev_ext_attribute axp20x_dev_attr_startup = { .var = &axp20x_pek_startup_ext_attr, }; +static struct dev_ext_attribute axp221_dev_attr_startup = { + .attr = __ATTR(startup, 0644, axp20x_show_ext_attr, axp20x_store_ext_attr), + .var = &axp221_pek_startup_ext_attr, +}; + static struct dev_ext_attribute axp20x_dev_attr_shutdown = { .attr = __ATTR(shutdown, 0644, axp20x_show_ext_attr, axp20x_store_ext_attr), .var = &axp20x_pek_shutdown_ext_attr, @@ -159,10 +177,20 @@ static struct attribute *axp20x_attributes[] = { NULL, }; +static struct attribute *axp221_attributes[] = { + &axp221_dev_attr_startup.attr.attr, + &axp20x_dev_attr_shutdown.attr.attr, + NULL, +}; + static const struct attribute_group axp20x_attribute_group = { .attrs = axp20x_attributes, }; +static const struct attribute_group axp221_attribute_group = { + .attrs = axp221_attributes, +}; + static irqreturn_t axp20x_pek_irq(int irq, void *pwr) { struct input_dev *idev = pwr; @@ -184,9 +212,10 @@ static irqreturn_t axp20x_pek_irq(int irq, void *pwr) static void axp20x_remove_sysfs_group(void *_data) { - struct device *dev = _data; + struct platform_device *pdev = _data; + struct axp20x_pek *axp_pek = platform_get_drvdata(pdev); - sysfs_remove_group(&dev->kobj, &axp20x_attribute_group); + sysfs_remove_group(&pdev->dev.kobj, axp_pek->attribute_group); } static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek, @@ -313,17 +342,19 @@ static int axp20x_pek_probe(struct platform_device *pdev) return error; } - error = sysfs_create_group(&pdev->dev.kobj, &axp20x_attribute_group); + axp20x_pek->attribute_group = (struct attribute_group *)platform_get_device_id(pdev)->driver_data; + + error = sysfs_create_group(&pdev->dev.kobj, + axp20x_pek->attribute_group); if (error) { dev_err(&pdev->dev, "Failed to create sysfs attributes: %d\n", error); return error; } - error = devm_add_action(&pdev->dev, - axp20x_remove_sysfs_group, &pdev->dev); + error = devm_add_action(&pdev->dev, axp20x_remove_sysfs_group, pdev); if (error) { - axp20x_remove_sysfs_group(&pdev->dev); + axp20x_remove_sysfs_group(pdev); dev_err(&pdev->dev, "Failed to add sysfs cleanup action: %d\n", error); return error; @@ -358,8 +389,19 @@ static const struct dev_pm_ops axp20x_pek_pm_ops = { #endif }; +static const struct platform_device_id axp_pek_id_match[] = { + { + .name = "axp20x-pek", + .driver_data = (kernel_ulong_t)&axp20x_attribute_group, + }, { + .name = "axp221-pek", + .driver_data = (kernel_ulong_t)&axp221_attribute_group, + }, +}; + static struct platform_driver axp20x_pek_driver = { .probe = axp20x_pek_probe, + .id_table = axp_pek_id_match, .driver = { .name = "axp20x-pek", .pm = &axp20x_pek_pm_ops, From patchwork Mon Jul 17 09:53:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 107879 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp4351214obm; Mon, 17 Jul 2017 02:54:00 -0700 (PDT) X-Received: by 10.98.138.204 with SMTP id o73mr10767862pfk.5.1500285240220; Mon, 17 Jul 2017 02:54:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500285240; cv=none; d=google.com; s=arc-20160816; b=Y4s2iyQw01xoUi1xSkEQUEtbB4rVaGN2kanpIQbUsOoU1p2LBIDJZ01cUdnlTzgFVp E7IZio52SZxz0n2OsbZN8VTg5VUjPQ7Ke+Mf0awY0ye9U8xKZmYts/dlFc8uV4KLZGV/ heHCrzRb+GXi5fc1t6If2ATSrhymyLAfmSNu2WeWMIJyw7yVje0DhiHom3aHWQPmVFX2 pM0FwznqY+JSavkHAaQEDDihlWcyrZ+1AxCkRxt7HYEwav/cd9eqjAPvhg1npphDXZx2 jq2p/aezq9xLqHZIVvBUzE4VIHTULw/unA+RVD1Y5ApFq3H0vPn20lDQ6/vuBWZIARn9 IPnw== 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:arc-authentication-results; bh=KOE/XjJFXKmku1Ayf7No+r3pwiuXcWNMxy6SSMGHCwE=; b=PE64lay2h7eCw/m0Szij9HBJ9I8iR50wW1QaupdTj2cB27xPVY+xXPIwBouJk2twVb XPCuKFYpfk8wSnPjtjanfJWX63wD2fTSpN/N0gtWYi7snmPCrb3DFeXkOWWMD+62RQYY 73wEuDEucbv/os+16FZmiBHIrRfqwK5PgtxiewSg15T086+Ti8TS3Rp9CoKhqyK3Q4CA hkeSn5u/nG3fRHsltjS88gAYW/ee3ssEcRZ1zZr9cOLPqeuQzO0O5jMacMQSVcVjvtfF 9jkkND6O58FD8NKLRtq9/r+EIf2kRqrpZcKMUyW43+GlWiR9cpACTUpww2RCl4dTiZFV w5lA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c125si12272862pfg.322.2017.07.17.02.53.59; Mon, 17 Jul 2017 02:54:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751422AbdGQJx4 (ORCPT + 25 others); Mon, 17 Jul 2017 05:53:56 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:45554 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751306AbdGQJxv (ORCPT ); Mon, 17 Jul 2017 05:53:51 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id A48E8208BA; Mon, 17 Jul 2017 11:53:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 6D3E1207FE; Mon, 17 Jul 2017 11:53:48 +0200 (CEST) From: Quentin Schulz To: dmitry.torokhov@gmail.com, wens@csie.org, lee.jones@linaro.org Cc: Quentin Schulz , hdegoede@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@free-electrons.com, maxime.ripard@free-electrons.com Subject: [PATCH 2/2] mfd: axp20x: use correct platform device id for many PEK Date: Mon, 17 Jul 2017 11:53:07 +0200 Message-Id: <20170717095307.15986-3-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170717095307.15986-1-quentin.schulz@free-electrons.com> References: <20170717095307.15986-1-quentin.schulz@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According to their datasheets, the AXP221, AXP223, AXP288, AXP803, AXP809 and AXP813 PEK have different values for startup time bits from the AXP20X, let's use the platform device id with the correct values. Signed-off-by: Quentin Schulz --- drivers/mfd/axp20x.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.11.0 diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index ec4271ca065c..336de66ca408 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -677,7 +677,7 @@ static struct mfd_cell axp20x_cells[] = { static struct mfd_cell axp221_cells[] = { { - .name = "axp20x-pek", + .name = "axp221-pek", .num_resources = ARRAY_SIZE(axp22x_pek_resources), .resources = axp22x_pek_resources, }, { @@ -702,7 +702,7 @@ static struct mfd_cell axp221_cells[] = { static struct mfd_cell axp223_cells[] = { { - .name = "axp20x-pek", + .name = "axp221-pek", .num_resources = ARRAY_SIZE(axp22x_pek_resources), .resources = axp22x_pek_resources, }, { @@ -835,7 +835,7 @@ static struct mfd_cell axp288_cells[] = { .resources = axp288_fuel_gauge_resources, }, { - .name = "axp20x-pek", + .name = "axp221-pek", .num_resources = ARRAY_SIZE(axp288_power_button_resources), .resources = axp288_power_button_resources, }, @@ -846,7 +846,7 @@ static struct mfd_cell axp288_cells[] = { static struct mfd_cell axp803_cells[] = { { - .name = "axp20x-pek", + .name = "axp221-pek", .num_resources = ARRAY_SIZE(axp803_pek_resources), .resources = axp803_pek_resources, }, @@ -862,7 +862,7 @@ static struct mfd_cell axp806_cells[] = { static struct mfd_cell axp809_cells[] = { { - .name = "axp20x-pek", + .name = "axp221-pek", .num_resources = ARRAY_SIZE(axp809_pek_resources), .resources = axp809_pek_resources, }, { @@ -873,7 +873,7 @@ static struct mfd_cell axp809_cells[] = { static struct mfd_cell axp813_cells[] = { { - .name = "axp20x-pek", + .name = "axp221-pek", .num_resources = ARRAY_SIZE(axp803_pek_resources), .resources = axp803_pek_resources, }