Received: by 10.223.185.116 with SMTP id b49csp659200wrg; Fri, 23 Feb 2018 04:55:07 -0800 (PST) X-Google-Smtp-Source: AH8x226IttIIWpOIlG0AFGnaJYlRFvf9a8fmgj7Agzqvbajt3XVn2V+3roLrMGLKieN3TdKQPT7F X-Received: by 10.98.205.140 with SMTP id o134mr1725585pfg.34.1519390507610; Fri, 23 Feb 2018 04:55:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519390507; cv=none; d=google.com; s=arc-20160816; b=UgT/aM7HneavOikBsx93ZaEq8iyyiD2/2ISWQzjkZwMwPCtNCeXKX3lu3Z0CI9CwMM fL+sb6MbO4Dm+h6FmWZXuuZugdVz+YDrQ6KvmbdMVmeY3VoWtkHbNL9pDxau/uuy7T0D QhOqV3BrxX0/sFUc2+C1FTEHSRJNrGZ73Yfd+7zI9YOigEZjbXxZF+E5g/0TOHMEX4EI aMGuk2q/25dBQyWcy77v6tilv5VMavPh8RJZIl98T9t7RhyuxurJmkVMd9qcwyU8FgD1 mKNJ3nF/DSAD6F4HasFUwt0LDAmKFyMMxiIIBRb4a/5wqnx4XntljXbOnApQmBwZflc0 ZuSg== 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=Si3YqjAhCJW/m4Uxqv9aFODCt7iBO3MnyuRwuFIg9hQ=; b=S1z7nuGUVn0GWRk5BThBx6JIEp+QhFWWXPAi7MORUyXcleuZObx67mpYeovL2k3rCx hBErY0pw3pvblunLVwnX4ncCyZA5W1Tnz3J47RzEBmPUKXGQYziH39y8JAq1AKOznZxM +NOYfDJLPEtAL4MsZKJ/8jXDIB/WHQ9033vTRuWPDRVLfDLpv96SYKKiA0RixN0t7yH+ LBBnOXAWaXqXMJhWO3kpP4M6xqyccvVA8t+vz7cSE/MPy/dIKMtK2Apf/Ika3MWh922K wSqJJQ9nDniwEZNf05929JzzP007MZZa8FoHGLF8p7pPNQttJTINftB4JDXy26Qy9fVw 9Ujw== 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 m1-v6si1720937plt.295.2018.02.23.04.54.53; Fri, 23 Feb 2018 04:55:07 -0800 (PST) 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 S1751675AbeBWMwm (ORCPT + 99 others); Fri, 23 Feb 2018 07:52:42 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:41962 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751432AbeBWMwE (ORCPT ); Fri, 23 Feb 2018 07:52:04 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w1NCmeAB017166; Fri, 23 Feb 2018 13:51:21 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2g9bqd221v-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 23 Feb 2018 13:51:21 +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 4BC0543; Fri, 23 Feb 2018 12:51:20 +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 17EFF4DBB; Fri, 23 Feb 2018 12:51:20 +0000 (GMT) Received: from localhost (10.75.127.48) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 23 Feb 2018 13:51:19 +0100 From: Fabrice Gasnier To: CC: , , , , , , , , , , Subject: [PATCH 3/7] iio: adc: stm32-dfsdm: fix clock source selection Date: Fri, 23 Feb 2018 13:50:57 +0100 Message-ID: <1519390261-25453-4-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519390261-25453-1-git-send-email-fabrice.gasnier@st.com> References: <1519390261-25453-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-23_04:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add missing clock source selection. In case "audio" clock is provided, it's unused currently: "dfsdm" clock is wrongly used by default. Fixes: bed73904e76f ("IIO: ADC: add stm32 DFSDM core support") Signed-off-by: Fabrice Gasnier --- drivers/iio/adc/stm32-dfsdm-core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c index 0635f93..e50efdc 100644 --- a/drivers/iio/adc/stm32-dfsdm-core.c +++ b/drivers/iio/adc/stm32-dfsdm-core.c @@ -83,7 +83,7 @@ int stm32_dfsdm_start_dfsdm(struct stm32_dfsdm *dfsdm) { struct dfsdm_priv *priv = container_of(dfsdm, struct dfsdm_priv, dfsdm); struct device *dev = &priv->pdev->dev; - unsigned int clk_div = priv->spi_clk_out_div; + unsigned int clk_div = priv->spi_clk_out_div, clk_src; int ret; if (atomic_inc_return(&priv->n_active_ch) == 1) { @@ -100,6 +100,14 @@ int stm32_dfsdm_start_dfsdm(struct stm32_dfsdm *dfsdm) } } + /* select clock source, e.g. 0 for "dfsdm" or 1 for "audio" */ + clk_src = priv->aclk ? 1 : 0; + ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), + DFSDM_CHCFGR1_CKOUTSRC_MASK, + DFSDM_CHCFGR1_CKOUTSRC(clk_src)); + if (ret < 0) + goto disable_aclk; + /* Output the SPI CLKOUT (if clk_div == 0 clock if OFF) */ ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), DFSDM_CHCFGR1_CKOUTDIV_MASK, -- 1.9.1