Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1596773pxb; Mon, 13 Sep 2021 00:57:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5cRAuCTeMnTnEp6qwOFThwGJRvh/y4EVSvcFBuMQ79CrMIBgd0sMBS5F8ryGfeBfXmygD X-Received: by 2002:a17:906:e0d8:: with SMTP id gl24mr2528441ejb.413.1631519824559; Mon, 13 Sep 2021 00:57:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631519824; cv=none; d=google.com; s=arc-20160816; b=WDtJYRaH+iyvL4uR38ZWr52Er7RUE9TjQpH8vOgosMvnxLwDOAaEqF0peSsxYWaABP V2wVLtfeKbfDlie7TxwzN+Ptd5qPjcIG+++Y/hcn5YukzujuYG+V3J7hdYPR0NPAxNmS 1HMuJRsZgEAdfCYQCW4fbS6inehn1jcXvyVgOwhQ+yHyLjkR8OSJqwbkDAZ6a0uNNIZ2 Uf7mCbHfkCTvX6N1yLoKwyRdN+Lq2Yk+hJI7gowTZxvFRyE/z8DIz3u5eQoRdFRwmca1 Xuir1IJevfMDAARfxhxFGFElWoMQIiZCPWkmYek9/tddRH6TMj6MfNUfoii0zGXM4ahe ff1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=A3c1XT2L2TXZaFEoE9jvUzceG7b7N95LNyAZA6Y+Rwc=; b=ZnUh0m9E0AeY6gFlhb8qO4oAUmRtawNBnAh/sgu3R05h7216ee7l6DNr9CBAuXQu4L 1o0KazieqKHCTU3F2L1u/i+LYTQ/bvWi3e1HI/XU/1UeHt+9At6XmZekJoMASTMpvvvB ahdMAEIpVQFI+yavUd+oNV/M9PVJCl1iPox13SrWULyP1Cni0MQknd2fhMgQo7iOWs00 g2Qdn1prkK8VOLNRaROKMfQoOZ0vekIA1Hl57C3ehULcK5ZOAXUezsQcVqVMrjZYm4il 1vG7Rb0OTrmiG+NkfihYTz6OFJDC9wPgrsoUmEUvcWUMfhntFgPx9fywAEiFK3rH2O7G FT7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi20si6581524ejb.575.2021.09.13.00.56.41; Mon, 13 Sep 2021 00:57:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237849AbhIMHyd (ORCPT + 99 others); Mon, 13 Sep 2021 03:54:33 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:3274 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237751AbhIMHyT (ORCPT ); Mon, 13 Sep 2021 03:54:19 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 18D7VLLY004718; Mon, 13 Sep 2021 15:31:21 +0800 (GMT-8) (envelope-from billy_tsai@aspeedtech.com) Received: from BillyTsai-pc.aspeed.com (192.168.2.149) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 13 Sep 2021 15:51:06 +0800 From: Billy Tsai To: , , , , , , , , , , , , , CC: Subject: [v6 03/11] iio: adc: aspeed: Add vref config function Date: Mon, 13 Sep 2021 15:53:29 +0800 Message-ID: <20210913075337.19991-4-billy_tsai@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210913075337.19991-1-billy_tsai@aspeedtech.com> References: <20210913075337.19991-1-billy_tsai@aspeedtech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.2.149] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 18D7VLLY004718 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the function to check the vref_fixed_mv and set the value to driver data. Signed-off-by: Billy Tsai --- drivers/iio/adc/aspeed_adc.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c index cc808ec89a0f..aec335956310 100644 --- a/drivers/iio/adc/aspeed_adc.c +++ b/drivers/iio/adc/aspeed_adc.c @@ -130,7 +130,7 @@ static int aspeed_adc_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: - *val = data->model_data->vref_fixed_mv; + *val = data->vref_mv; *val2 = ASPEED_RESOLUTION_BITS; return IIO_VAL_FRACTIONAL_LOG2; @@ -195,6 +195,17 @@ static const struct iio_info aspeed_adc_iio_info = { .debugfs_reg_access = aspeed_adc_reg_access, }; +static int aspeed_adc_vref_config(struct iio_dev *indio_dev) +{ + struct aspeed_adc_data *data = iio_priv(indio_dev); + + if (data->model_data->vref_fixed_mv) { + data->vref_mv = data->model_data->vref_fixed_mv; + return 0; + } + return 0; +} + static int aspeed_adc_probe(struct platform_device *pdev) { struct iio_dev *indio_dev; @@ -250,6 +261,10 @@ static int aspeed_adc_probe(struct platform_device *pdev) } reset_control_deassert(data->rst); + ret = aspeed_adc_vref_config(indio_dev); + if (ret) + goto vref_config_error; + if (data->model_data->wait_init_sequence) { /* Enable engine in normal mode. */ writel(FIELD_PREP(ASPEED_ADC_OP_MODE, @@ -298,6 +313,7 @@ static int aspeed_adc_probe(struct platform_device *pdev) clk_disable_unprepare(data->clk_scaler->clk); clk_enable_error: poll_timeout_error: +vref_config_error: reset_control_assert(data->rst); reset_error: clk_hw_unregister_divider(data->clk_scaler); -- 2.25.1