Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4260173pxb; Tue, 31 Aug 2021 00:16:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1EPvqO+FNF97Q7CeLwVPF8semU9kPJGG7zLkBdw1AfHER/hymv1/VpGJ6lOmHwErGTD+O X-Received: by 2002:a02:1cc5:: with SMTP id c188mr1560604jac.46.1630394208623; Tue, 31 Aug 2021 00:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630394208; cv=none; d=google.com; s=arc-20160816; b=NHKD/GLXOxakxPExRlNe6Ms7wqniBs49QC3pCI0kjJXNbN1dZdraCkkfhXjtAp7rnm vvygJHeSdVvPLQXk5/Luykq9uLwOe15X/9BLe2UIQauOBfWi9m+LdwbapNxRHcy1V1qQ Pvsg9N++c6dAHcYBofCYEIhhdd2FUL+MvfjegpNyzHGq48Kq0xgvL8KBZn0us0zI3KFd sGUFq8ftbT76YAJQ+Dfdh9JrcnlCp0xRmkMA+3XXpuEW5v8zZe0lwY+aMVGMLsmlxYl8 Mbd+kkPP+7+l/ops1XhEX7SC9dwvQgbE4viqdT0JWJHFXENLHdgCxwEQrNgbWSxd/CI5 UQ3Q== 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=UttXrBYclkDLLLPVPzFHB5gsndhN4jjMYxKCoQilIHY=; b=IC/51OU89K3Z44PesaUKA4MkuzAKWgAVp8+9b313aF5q0BA7haMLqN2YKyHd1NcGGe E1kCrtAsWSIvIgmbZ1m5H3nO8gN3+qlGWS82/bCkAAWvdc7suUAmdDLUrxyr29R37BTN y437UTv7bR7f/U7QQU0bNLY9Kd9AjeCJtgX8i0aBpPvsDTk56VOrbmPREzxUaer2ctt4 jMjEK38jlaifvOc5ObIJQycgpJnCGzMhAmhxnniLhW47fFte/Nydfl3crS5M8cWju03c 3QjxmRxlDa6lAC6lPN8HjTDqEuyItcXe8NUcuL8MLz+uS1troYKlz4zmNXAe3GFivY7l vaLg== 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 v7si19080124ilu.137.2021.08.31.00.16.35; Tue, 31 Aug 2021 00:16:48 -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 S239688AbhHaHQp (ORCPT + 99 others); Tue, 31 Aug 2021 03:16:45 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:61748 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239503AbhHaHQ0 (ORCPT ); Tue, 31 Aug 2021 03:16:26 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 17V6sbOx028265; Tue, 31 Aug 2021 14:54:37 +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, 31 Aug 2021 15:13:35 +0800 From: Billy Tsai To: , , , , , , , , , , , , , CC: Subject: [v5 06/15] iio: adc: aspeed: Add vref config function Date: Tue, 31 Aug 2021 15:14:49 +0800 Message-ID: <20210831071458.2334-7-billy_tsai@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210831071458.2334-1-billy_tsai@aspeedtech.com> References: <20210831071458.2334-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 17V6sbOx028265 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 6ce2f676c54a..01df24f6d3f1 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