From patchwork Thu Sep 20 12:40:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 10607607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37FDB6CB for ; Thu, 20 Sep 2018 12:45:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2696D2D3E5 for ; Thu, 20 Sep 2018 12:45:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19B372D3E9; Thu, 20 Sep 2018 12:45:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C0B142D3E5 for ; Thu, 20 Sep 2018 12:45:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=14aGYYvmZs3TbWCQsguCmxZv4pYr8sY3sOA7uhojhf4=; b=l+FpQuch/Vyvl8 YmOti0Z+T0XrvaRBZwfbjjke421O7dbTbFLemeD9HDCbqph8k+GqV1McwFod5VTNmqo+CkqnecAKe K/09qSkxoVwt2ipD3lP5BM38aoQd6Wch7CYOX8zf/XLRq3D0cJ/XRgyhNIzYqyQk2CZBKVNsnyiXn Q33cQ2WECxDSlFApr66PcJFJOHsoL75vncFLj5lScxFlPWw/JC4OlV0qmwMlu7YwXhy4HcGt13GRN Ot5nTwlo7ggDg6f3lDta9Yc1dMrDYssujFiZmcBIQpdDCKCS/VO8EknffV/Q/xNR3/i1uo7TVwKzY tvtjxUFj63OCBYgjuCDg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2yKc-0004cF-CR; Thu, 20 Sep 2018 12:45:18 +0000 Received: from esa1.microchip.iphmx.com ([68.232.147.91]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2yKX-0003qV-7Y for linux-arm-kernel@lists.infradead.org; Thu, 20 Sep 2018 12:45:14 +0000 X-IronPort-AV: E=Sophos;i="5.53,398,1531810800"; d="scan'208";a="21047112" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 20 Sep 2018 05:44:59 -0700 Received: from eh-station.microchip.com (10.10.76.4) by chn-sv-exch05.mchp-main.com (10.10.76.106) with Microsoft SMTP Server id 14.3.352.0; Thu, 20 Sep 2018 05:44:58 -0700 From: Eugen Hristev To: , , , , Subject: [PATCH 1/2] iio: adc: at91: fix acking DRDY irq on simple conversions Date: Thu, 20 Sep 2018 15:40:37 +0300 Message-ID: <1537447238-18674-1-git-send-email-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180920_054513_302526_CFAA14E0 X-CRM114-Status: UNSURE ( 9.35 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , Eugen Hristev , stable@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When doing simple conversions, the driver did not acknowledge the DRDY irq. If this irq is not acked, it will be left pending, and as soon as a trigger is enabled, the irq handler will be called, it doesn't know why this irq has occurred because no channel is pending, and then we will have irq loop and board will hang. Fixes 0e589d5fb ("ARM: AT91: IIO: Add AT91 ADC driver.") Cc: Maxime Ripard Cc: Signed-off-by: Eugen Hristev --- drivers/iio/adc/at91_adc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 44b5168..e85f859 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -712,6 +712,11 @@ static int at91_adc_read_raw(struct iio_dev *idev, at91_adc_writel(st, AT91_ADC_CHDR, AT91_ADC_CH(chan->channel)); at91_adc_writel(st, AT91_ADC_IDR, BIT(chan->channel)); + /* + * we need to ack the DRDY irq, otherwise it will be + * left pending and irq handler will be confused + */ + at91_adc_readl(st, AT91_ADC_LCDR); st->last_value = 0; st->done = false; From patchwork Thu Sep 20 12:40:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 10607609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 196576CB for ; Thu, 20 Sep 2018 12:46:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 065662D3EA for ; Thu, 20 Sep 2018 12:46:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE7F92D402; Thu, 20 Sep 2018 12:46:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6D6DD2D3EA for ; Thu, 20 Sep 2018 12:46:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=K+Haa6z8MNw+VvG25+QCQudCJ6/BquIuSVEUnNiLevQ=; b=X0BGakZIak0Dkf bN3mibL/3pNblo0YWF7r2Nc+Q1otyT3X3wVgJaInGMFmOxKK1PDBrRl8JRKjAod2LTevYTIb2E16b kJgy2e31rYU8v2nJ/xb/QEGA1rnmkeVCtoYlzJkBQDpRilbQOam4hs7oEtUzuIXC/97AmjGcq2pWe GcZ7GLAirMrTGGxwLuZM9tCZ9uwLDT2oQCtBFTV73D8sErF37D1GTSWn5skveR8dqIrIwE3mNEWYM 3IOQP6AerTsTTwv0/kcWQQ4sixVK3hC+S+FWJOzP0RlazBEaDWAwpTYRL5nQovNPdqUAzkidN5mP4 zlT6LdF4uhaRcLl7B/VQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2yL8-0005HK-HL; Thu, 20 Sep 2018 12:45:50 +0000 Received: from esa2.microchip.iphmx.com ([68.232.149.84]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2yKZ-0003vV-2m for linux-arm-kernel@lists.infradead.org; Thu, 20 Sep 2018 12:45:16 +0000 X-IronPort-AV: E=Sophos;i="5.53,398,1531810800"; d="scan'208";a="20223232" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 20 Sep 2018 05:45:02 -0700 Received: from eh-station.microchip.com (10.10.76.4) by chn-sv-exch05.mchp-main.com (10.10.76.106) with Microsoft SMTP Server id 14.3.352.0; Thu, 20 Sep 2018 05:45:01 -0700 From: Eugen Hristev To: , , , , Subject: [PATCH 2/2] iio: adc: at91: fix wrong channel number in triggered buffer mode Date: Thu, 20 Sep 2018 15:40:38 +0300 Message-ID: <1537447238-18674-2-git-send-email-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537447238-18674-1-git-send-email-eugen.hristev@microchip.com> References: <1537447238-18674-1-git-send-email-eugen.hristev@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180920_054515_193978_14760BF2 X-CRM114-Status: GOOD ( 11.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , Eugen Hristev , stable@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When channels are registered, the hardware channel number is not the actual iio channel number. This is because the driver is probed with a certain number of accessible channels. Some pins are routed and some not, depending on the description of the board in the DT. Because of that, channels 0,1,2,3 can correspond to hardware channels 2,3,4,5 for example. In the buffered triggered case, we need to do the translation accordingly. Fixed the channel number to stop reading the wrong channel. Fixes 0e589d5fb "ARM: AT91: IIO: Add AT91 ADC driver." Cc: Maxime Ripard Cc: Signed-off-by: Eugen Hristev --- drivers/iio/adc/at91_adc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index e85f859..6698804 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -248,12 +248,14 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *idev = pf->indio_dev; struct at91_adc_state *st = iio_priv(idev); + struct iio_chan_spec *chan; int i, j = 0; for (i = 0; i < idev->masklength; i++) { if (!test_bit(i, idev->active_scan_mask)) continue; - st->buffer[j] = at91_adc_readl(st, AT91_ADC_CHAN(st, i)); + chan = idev->channels + i; + st->buffer[j] = at91_adc_readl(st, AT91_ADC_CHAN(st, chan->channel)); j++; }