Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2572904pxb; Tue, 24 Aug 2021 02:18:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYmOjb08Hsc3uP1FXXFvKzOmr98M7R6eHamKaWvNMghqJBIPym9u1AcXmO3ld1tqdwkoL3 X-Received: by 2002:a05:6402:4cf:: with SMTP id n15mr42704555edw.269.1629796700522; Tue, 24 Aug 2021 02:18:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629796700; cv=none; d=google.com; s=arc-20160816; b=ZCJOOU4vw4JC3GodpmDbiNR4r7vT7akNKljHWFyaPdemLioGyG4frfFaEMyi2vHpQ6 in76HNyL1JnP1wZN/lI8mnBY+tyCiYkk8wSmIaMIAce4xEJ954kq13QFC3dcnak5Pu8U ICpgJDa9R+ZFaWAT4CMjAgpCLtM9ASJ3Am79WvT4yTi427rAjOT4SrDz5JZ8Ka6igEOU DNKUqI9FZjuT6bI9qKkZdG9hL1YNuBCry76gIrMBIBKl7eWJQm+6crwIB/Dm1xboSa/H 9kzuN3caCxNeKaGpkrAlsKJFgYyThefGjk9goagAcV2TxLjigJjijPe1O0jQVOGxb5Ju F++Q== 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=RPCBewxt/P0UF+9mU/zpU9gQQ/IuivtRkRCXOQ+bAEk=; b=CiwrgWvWUzSKUIzlorU8P6jf4RfGjgMDnDbWiFLz5W9ek+QMHwF8OH7W7DhIM6+D9k 08EnT39JkM8VGZHTDnKJJj6EpsX55lLm4PvLW1XOFng3+o64ENcqtnrkGztXLUpe9W6t YgQBY76VUwIbMnrQfe1bH4ZlNSt9psf0XuH0o3RbVPpZ0V0KbgMn6nqjeX3T+tSKXjf7 0J/q24Kb7BVZAJ1Km5zTxLd3EM/tHtBRFJCFsneqcuCnRDMpXTu2onTyTpLTG4zPMGn4 48uMZhPCcNpSjZjwu4te9K70UwcihGxylgURccSZjUWu1Q/Cimkdykbm/TDj7OMXJgtd oG/Q== 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 l17si16012355ejh.84.2021.08.24.02.17.57; Tue, 24 Aug 2021 02:18:20 -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 S235435AbhHXJQF (ORCPT + 99 others); Tue, 24 Aug 2021 05:16:05 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:10959 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235618AbhHXJQC (ORCPT ); Tue, 24 Aug 2021 05:16:02 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 17O8rFHL098385; Tue, 24 Aug 2021 16:53:15 +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; Tue, 24 Aug 2021 17:11:47 +0800 From: Billy Tsai To: , , , , , , , , , , , , , CC: Subject: [RESEND v4 06/15] iio: adc: aspeed: Add vref config function Date: Tue, 24 Aug 2021 17:12:34 +0800 Message-ID: <20210824091243.9393-7-billy_tsai@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824091243.9393-1-billy_tsai@aspeedtech.com> References: <20210824091243.9393-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 17O8rFHL098385 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the function to check the vref_fixed 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 f03c7921d534..f260e40ab9b2 100644 --- a/drivers/iio/adc/aspeed_adc.c +++ b/drivers/iio/adc/aspeed_adc.c @@ -122,7 +122,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; + *val = data->vref; *val2 = ASPEED_RESOLUTION_BITS; return IIO_VAL_FRACTIONAL_LOG2; @@ -187,6 +187,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) { + data->vref = data->model_data->vref_fixed; + return 0; + } + return 0; +} + static int aspeed_adc_probe(struct platform_device *pdev) { struct iio_dev *indio_dev; @@ -242,6 +253,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, @@ -290,6 +305,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