From patchwork Wed Jun 24 09:21:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 50258 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4E1CA21575 for ; Wed, 24 Jun 2015 09:26:53 +0000 (UTC) Received: by laar3 with SMTP id r3sf9512995laa.1 for ; Wed, 24 Jun 2015 02:26:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=IJw0Oc8Da9h9honzwcEarpEctWsQVujmPhdVKdarIg8=; b=CZmeylbhs6nZmuE/k85fyeVAZ1rpTCFdRsWGuQFTDs/mC7fFpRlyY7hD65+wfuOB2Y 4+4ga1zou+ib9SgIfy5TIpfHVEu7Vv6LCzF+JmJVvzOafXlh/u/My33/6UYwvsaz9Eau 2NMxSZtV4jpf2QHn2Qxbh4cv5Z8O25ZnMlPXj1fW5sIgRI4Hwt6SDGT5HKuDO0TUTsWq F0CUgXck1Je+bOsj/zR1U9IjXx+iSlQj6bw2Svlw5eNdFuEiKQTInm4xEsZDmtF4U2r8 SFEWkxGNoAYLC/75fzY9jRXs/ZT27BS92evdp6bw8nwx4ieFTfIFiDH9sA25KEM4GK+G r0vQ== X-Gm-Message-State: ALoCoQmW5UJvwSpGeU/JiBuDguCvoo+xAbF+6uvMKQONTUSPpZ+mbb8AJ9kW64LSAspfdfScILPE X-Received: by 10.112.255.66 with SMTP id ao2mr29291831lbd.15.1435138012247; Wed, 24 Jun 2015 02:26:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.70 with SMTP id be6ls162136lab.103.gmail; Wed, 24 Jun 2015 02:26:52 -0700 (PDT) X-Received: by 10.112.50.148 with SMTP id c20mr38593889lbo.27.1435138012100; Wed, 24 Jun 2015 02:26:52 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id ji5si15357380lbb.149.2015.06.24.02.26.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jun 2015 02:26:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by laka10 with SMTP id a10so22356179lak.0 for ; Wed, 24 Jun 2015 02:26:52 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr39246810lbc.19.1435138011989; Wed, 24 Jun 2015 02:26:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3655973lbb; Wed, 24 Jun 2015 02:26:50 -0700 (PDT) X-Received: by 10.70.102.11 with SMTP id fk11mr77877347pdb.144.1435138010060; Wed, 24 Jun 2015 02:26:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ft7si39040850pdb.150.2015.06.24.02.26.49; Wed, 24 Jun 2015 02:26:50 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752030AbbFXJ0o (ORCPT + 8 others); Wed, 24 Jun 2015 05:26:44 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:32995 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751055AbbFXJ0Z (ORCPT ); Wed, 24 Jun 2015 05:26:25 -0400 Received: by padev16 with SMTP id ev16so25660850pad.0 for ; Wed, 24 Jun 2015 02:26:24 -0700 (PDT) X-Received: by 10.66.190.228 with SMTP id gt4mr78940745pac.72.1435137984608; Wed, 24 Jun 2015 02:26:24 -0700 (PDT) Received: from localhost.localdomain ([202.62.77.106]) by mx.google.com with ESMTPSA id t2sm26032717pdo.81.2015.06.24.02.26.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Jun 2015 02:26:23 -0700 (PDT) From: Vaibhav Hiremath To: linux-arm-kernel@lists.infradead.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lee.jones@linaro.org, robh+dt@kernel.org, Vaibhav Hiremath , Zhao Ye Subject: [PATCH-v3 2/3] mfd: 88pm800: Allow configuration of interrupt clear method Date: Wed, 24 Jun 2015 14:51:12 +0530 Message-Id: <1435137673-1629-3-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435137673-1629-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1435137673-1629-1-git-send-email-vaibhav.hiremath@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vaibhav.hiremath@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , As per the spec, bit 1 (INT_CLEAR_MODE) of reg addr 0xe (page 0) controls the method of clearing interrupt status of 88pm800 family of devices; 0: clear on read 1: clear on write This patch allows to configure this field, through DT. Also, as suggested by "Lee Jones" renaming DT property and variable field to appropriate name. Signed-off-by: Zhao Ye Signed-off-by: Vaibhav Hiremath --- drivers/mfd/88pm800.c | 15 ++++++++++----- include/linux/mfd/88pm80x.h | 6 ++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c index 059f01a..c1a6306 100644 --- a/drivers/mfd/88pm800.c +++ b/drivers/mfd/88pm800.c @@ -376,7 +376,7 @@ static int device_irq_init_800(struct pm80x_chip *chip) { struct regmap *map = chip->regmap; unsigned long flags = IRQF_ONESHOT; - int data, mask, ret = -EINVAL; + int irq_clr_mode, mask, ret = -EINVAL; if (!map || !chip->irq) { dev_err(chip->dev, "incorrect parameters\n"); @@ -384,15 +384,16 @@ static int device_irq_init_800(struct pm80x_chip *chip) } /* - * irq_mode defines the way of clearing interrupt. it's read-clear by - * default. + * irq_clr_on_wr defines the way of clearing interrupt by + * read/write(0/1). It's read-clear by default. */ mask = PM800_WAKEUP2_INV_INT | PM800_WAKEUP2_INT_CLEAR | PM800_WAKEUP2_INT_MASK; - data = PM800_WAKEUP2_INT_CLEAR; - ret = regmap_update_bits(map, PM800_WAKEUP2, mask, data); + irq_clr_mode = (chip->irq_clr_on_wr) ? + PM800_WAKEUP2_INT_WRITE_CLEAR : PM800_WAKEUP2_INT_READ_CLEAR; + ret = regmap_update_bits(map, PM800_WAKEUP2, mask, irq_clr_mode); if (ret < 0) goto out; @@ -514,6 +515,7 @@ static int device_800_init(struct pm80x_chip *chip, } chip->regmap_irq_chip = &pm800_irq_chip; + chip->irq_clr_on_wr = pdata->irq_clr_on_wr; ret = device_irq_init_800(chip); if (ret < 0) { @@ -568,6 +570,9 @@ static int pm800_probe(struct i2c_client *client, dev_err(&client->dev, "failed to allocaate memory\n"); return -ENOMEM; } + + pdata->irq_clr_on_wr = of_property_read_bool(np, + "marvell,irq-clr-on-write"); } ret = pm80x_init(client); diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h index 97cb283..94b3dcd 100644 --- a/include/linux/mfd/88pm80x.h +++ b/include/linux/mfd/88pm80x.h @@ -77,6 +77,8 @@ enum { #define PM800_WAKEUP2 (0x0E) #define PM800_WAKEUP2_INV_INT (1 << 0) #define PM800_WAKEUP2_INT_CLEAR (1 << 1) +#define PM800_WAKEUP2_INT_READ_CLEAR (0 << 1) +#define PM800_WAKEUP2_INT_WRITE_CLEAR (1 << 1) #define PM800_WAKEUP2_INT_MASK (1 << 2) #define PM800_POWER_UP_LOG (0x10) @@ -300,7 +302,7 @@ struct pm80x_chip { struct regmap_irq_chip_data *irq_data; int type; int irq; - int irq_mode; + int irq_clr_on_wr; /* '1': Clear on write, '0': Clear on read*/ unsigned long wu_flag; spinlock_t lock; }; @@ -315,7 +317,7 @@ struct pm80x_platform_data { */ struct regulator_init_data *regulators[PM800_ID_RG_MAX]; unsigned int num_regulators; - int irq_mode; /* Clear interrupt by read/write(0/1) */ + int irq_clr_on_wr; /* Clear interrupt by read/write(0/1) */ int batt_det; /* enable/disable */ int (*plat_config)(struct pm80x_chip *chip, struct pm80x_platform_data *pdata);