Received: by 10.213.65.68 with SMTP id h4csp383812imn; Tue, 13 Mar 2018 07:25:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELt7F+x/dE5dgMDTbT/xU2FXXv+3j4l8hL8DekyqYCl0EwoqZw4Y2PFYwQL4jK7Y3EpP+jU1 X-Received: by 2002:a17:902:bd8c:: with SMTP id q12-v6mr767086pls.364.1520951146171; Tue, 13 Mar 2018 07:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520951146; cv=none; d=google.com; s=arc-20160816; b=qY2CgRy6ddo2306JpTuHTBKZHI2dPYnMYiHrfnkFFbDBZI2AnAxjZ9TO2uTxNZCu5w raArvWiMP8x117/Lix8ix3B8hbbOsvlUK/dHUEXZ386GUQyHuTXrjJZPf7WgV+QZuF5Q PSu9mimOfrJwkoJxsWMNCq9P4tbfFqjOrDOZWCRPu0F4Xsodsvrqs3aOHiw8eEuC8cTk FsgOU05s7SzNNRsIBpCXolv8phREu5J5IWkO6I4lgk15i1pUNanZ+VRmJyjMhf3ikyMO 8dfajEPQhpOViOdAJ4ncrBPV+TqUQiLjcV4KSazdWTFvKDNrfbRYA/9NW3UmJ7WbQD+M UKIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=SpIyNn64lrUc0g4HEy7qR6gEiQdAP3lM6LH64F2xhO0=; b=taSFlzUpTI95Pf4r4j7iBH8jYykiFukE+t7Bz7Eu49YwGJ5OrI27IAnPKkVtg+T8eE L9K+4Vo+8c1BdBKXXCUT2yaSEd5WgZvtVxJNXRzetMZbKW47pGWBYHZV6a0oNtj4Bg1r 0TWWkUmAqtpKfwv+cEDFiCnk8mw8sogcyEiQDr1CIJWkJAwcYdjQcbGSgQLO49cSfghl qQePZJOuFWMP+iZyjPq/JxTN1VLbB0yq34rq+tMBIX5UNTqG1lWsJ2mD5VmCnzk0u3DA +Jm0Lrb3lIsysO9Xs4ynxQNK43AzVz1ROfdeCuWiZdEvKUyfqYz7bP303EkxP0TU+XHQ M3Eg== 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 v68si171764pgv.722.2018.03.13.07.25.31; Tue, 13 Mar 2018 07:25:46 -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 S932443AbeCMOX5 (ORCPT + 99 others); Tue, 13 Mar 2018 10:23:57 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:56104 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751869AbeCMOX4 (ORCPT ); Tue, 13 Mar 2018 10:23:56 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2DEIhq9017790; Tue, 13 Mar 2018 15:23:25 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gpc5s9c1r-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 13 Mar 2018 15:23:25 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B9DCF38; Tue, 13 Mar 2018 14:23:24 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 94DAB576D; Tue, 13 Mar 2018 14:23:24 +0000 (GMT) Received: from localhost (10.75.127.49) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 13 Mar 2018 15:23:14 +0100 From: Fabrice Gasnier To: CC: , , , , , , , , , , Subject: [PATCH 2/2] iio: adc: stm32-dfsdm: fix sample rate for div2 spi clock Date: Tue, 13 Mar 2018 15:23:06 +0100 Message-ID: <1520950986-23116-3-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520950986-23116-1-git-send-email-fabrice.gasnier@st.com> References: <1520950986-23116-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG4NODE3.st.com (10.75.127.12) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-13_07:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When channel clk source is set to "CLKOUT_F" or "CLKOUT_R" (e.g. div2), sample rate is currently set to half the requested value. Fixes: eca949800d2d ("IIO: ADC: add stm32 DFSDM support for PDM microphone") Signed-off-by: Fabrice Gasnier --- drivers/iio/adc/stm32-dfsdm-adc.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index dc911b6..b28a716 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -771,7 +771,7 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev, struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; struct stm32_dfsdm_channel *ch = &adc->dfsdm->ch_list[chan->channel]; - unsigned int spi_freq = adc->spi_freq; + unsigned int spi_freq; int ret = -EINVAL; switch (mask) { @@ -785,8 +785,18 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SAMP_FREQ: if (!val) return -EINVAL; - if (ch->src != DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL) + + switch (ch->src) { + case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL: spi_freq = adc->dfsdm->spi_master_freq; + break; + case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_FALLING: + case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_RISING: + spi_freq = adc->dfsdm->spi_master_freq / 2; + break; + default: + spi_freq = adc->spi_freq; + } if (spi_freq % val) dev_warn(&indio_dev->dev, -- 1.9.1