From patchwork Fri Apr 25 10:14:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Krishna Chatradhi X-Patchwork-Id: 4058991 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 147C0BFF02 for ; Fri, 25 Apr 2014 10:23:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4393D2039E for ; Fri, 25 Apr 2014 10:23:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E1F3D203AC for ; Fri, 25 Apr 2014 10:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752580AbaDYKSk (ORCPT ); Fri, 25 Apr 2014 06:18:40 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:51849 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752888AbaDYKQn (ORCPT ); Fri, 25 Apr 2014 06:16:43 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N4L00G550JUBF50@mailout2.samsung.com>; Fri, 25 Apr 2014 19:16:42 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.122]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 1E.64.11120.A063A535; Fri, 25 Apr 2014 19:16:42 +0900 (KST) X-AuditID: cbfee68f-b7eff6d000002b70-62-535a360ab1d5 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id D2.07.27725.9063A535; Fri, 25 Apr 2014 19:16:42 +0900 (KST) Received: from chnaveen-ubuntu.sisodomain.com ([107.108.83.161]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N4L00LYZ0JCQJ30@mmp2.samsung.com>; Fri, 25 Apr 2014 19:16:41 +0900 (KST) From: Naveen Krishna Chatradhi To: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, dianders@chromium.org, gregkh@linuxfoundation.org, naveenkrishna.ch@gmail.com, lars@metafoo.de, cpgs@samsung.com, grundler@chromium.org Subject: [PATCH 4/5] iio: exynos_adc: do a soft reset in case of timeout Date: Fri, 25 Apr 2014 15:44:46 +0530 Message-id: <1398420888-5506-5-git-send-email-ch.naveen@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1398420888-5506-1-git-send-email-ch.naveen@samsung.com> References: <1398420888-5506-1-git-send-email-ch.naveen@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeLIzCtJLcpLzFFi42JZI2JSpctlFhVssHodj8XLQ5oWZ5cdZLNo XryezeLVkR9MFksmz2e1mHfkHYvF5V1z2CxmnN/HZLFo239mB06P2Q0XWTx2zrrL7rF/7hp2 jyVvDrF69G1ZxejxeZNcAFsUl01Kak5mWWqRvl0CV8aiU7/ZC46IVkxtP8PWwHhHsIuRk0NC wESi5fVuRghbTOLCvfVsXYxcHEICSxklfh87wwxTNH/HD1aIxHRGiYW3djBDOP1MEld7p4BV sQmYSRxctJq9i5GDQ0RAVmJmtx5IDbPABUaJn18msILUCAt4SHx4fhDMZhFQlXi7ZyMTiM0r 4CLx9U4rM0ivhICCxJxJNiBhTgFXifW7j4GVCwGV3N/yB+wICYFd7BKnz5xjg5gjIPFt8iEW iF5ZiU0HoI6WlDi44gbLBEbhBYwMqxhFUwuSC4qT0ouM9YoTc4tL89L1kvNzNzECY+D0v2f9 Oxj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7T7vx58OxDP/nHL/KM1eQjjF7cWnDr9dlM id3Jd+bwldxMO29xvPfR7d5tz+Y+/u299K/jWetE/eXTN37K9PsQYP9HqfXuccXki8pRtS8i ryixFGckGmoxFxUnAgBhYB0D9AIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Do a soft reset software if a timeout happens. This is applicable only for ADC_V2. Change-Id: I939eaa06254e0b246dd636df9470f2eb392c2be1 Signed-off-by: Naveen Krishna Chatradhi Reviewed-by: Doug Anderson --- This change is a part of the patch reviewed at https://lkml.org/lkml/2013/11/5/92 drivers/iio/adc/exynos_adc.c | 50 ++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index 4d2467a..805c9f6 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -112,6 +112,30 @@ static inline unsigned int exynos_adc_get_version(struct platform_device *pdev) return (unsigned int)match->data; } +static void exynos_adc_hw_init(struct exynos_adc *info) +{ + u32 con1, con2; + + if (info->version == ADC_V2) { + con1 = ADC_V2_CON1_SOFT_RESET; + writel(con1, ADC_V2_CON1(info->regs)); + + con2 = ADC_V2_CON2_OSEL | ADC_V2_CON2_ESEL | + ADC_V2_CON2_HIGHF | ADC_V2_CON2_C_TIME(0); + writel(con2, ADC_V2_CON2(info->regs)); + + /* Enable interrupts */ + writel(1, ADC_V2_INT_EN(info->regs)); + } else { + /* set default prescaler values and Enable prescaler */ + con1 = ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN; + + /* Enable 12-bit ADC resolution */ + con1 |= ADC_V1_CON_RES; + writel(con1, ADC_V1_CON(info->regs)); + } +} + static int exynos_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, @@ -149,6 +173,8 @@ static int exynos_read_raw(struct iio_dev *indio_dev, timeout = wait_for_completion_timeout (&info->completion, EXYNOS_ADC_TIMEOUT); if (timeout == 0) { + dev_warn(&indio_dev->dev, "Conversion timed out! Resetting\n"); + exynos_adc_hw_init(info); ret = -ETIMEDOUT; } else { *val = info->value; @@ -230,30 +256,6 @@ static int exynos_adc_remove_devices(struct device *dev, void *c) return 0; } -static void exynos_adc_hw_init(struct exynos_adc *info) -{ - u32 con1, con2; - - if (info->version == ADC_V2) { - con1 = ADC_V2_CON1_SOFT_RESET; - writel(con1, ADC_V2_CON1(info->regs)); - - con2 = ADC_V2_CON2_OSEL | ADC_V2_CON2_ESEL | - ADC_V2_CON2_HIGHF | ADC_V2_CON2_C_TIME(0); - writel(con2, ADC_V2_CON2(info->regs)); - - /* Enable interrupts */ - writel(1, ADC_V2_INT_EN(info->regs)); - } else { - /* set default prescaler values and Enable prescaler */ - con1 = ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN; - - /* Enable 12-bit ADC resolution */ - con1 |= ADC_V1_CON_RES; - writel(con1, ADC_V1_CON(info->regs)); - } -} - static int exynos_adc_probe(struct platform_device *pdev) { struct exynos_adc *info = NULL;