Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp673978rdb; Sun, 3 Sep 2023 05:46:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtB8bZEm3vcZBR9pmcwCOPLpcjb3jlGISIMe0hZVkCGYNvEmdR1u5VpoVNj6DYWoS4Plo1 X-Received: by 2002:a17:907:2bf7:b0:9a1:b528:d0f6 with SMTP id gv55-20020a1709072bf700b009a1b528d0f6mr7386231ejc.27.1693745217122; Sun, 03 Sep 2023 05:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693745217; cv=none; d=google.com; s=arc-20160816; b=F9NU1z/QYBfGAA5q5pZvim/0Gp4l1AcnyuB7S2tUxc6dWTvCJwfE10K3PPqJDV5jKp Ya1qwphdLC3d1FMu0/DNc+hT2bl4YjYGfSnlnYq9Nl0HDdQHzyYHHUjuPWdG4nBwD1/F hrzQERu4MVH2/ouhqgYYxfLuKdUzBA7UqfDpidSaJ93fMvEA5Eq//Q+Fuwe5U7Fa3xuP 0We47aQIKfMnKVG5pbUKBY8hMkW2XMfyQUUMeV0AYOD3hiCKMuIrM38CR9+FfMVAxQde a+8exM+2BRTDeLG2PnSkS/qb/hd34pfQmO+N+zsQSOiSmvETwLF+9QTulqhBcc0gbkx4 6f8Q== 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=KVLDmAZ7s6NNMybHyQAISeaZOig0SgIwemxkTOPWc4M=; fh=pnZF6rzA50VQ06Ks8UUSgsDCVUaPEFlTI8rdPUngd8k=; b=bxrF2vbklifDlHM0Ed8oTe0vafEjSof+HjOgKGFirLLDkt/mKZmI10AtIc1WWQDkCc EPwDRdvajmrMOD/tBCriYYkwQql/pecR8jkskEkWCpLogeJiqb7pfG4RAJ29yR0mYKxR /J/g8kJqdjGIOrmw/iPIkgNrpIHmR27WeabooN7z9nDo8wzmtZfP1QoLnrmyz3iEIAF7 HYSVufkfjWQfBucgwznen3yEw286zyunyZoS5la7619MsGO3cX054gZAMafW1rcTRRPr YBkRC0ho1BAn67TjLbOLaKVtxKQbtCnd4p7PwC7TzASsCCo+izQtQQRBzxolWKUQ6W8N wv+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g3-20020a170906594300b0099b7f483374si4801821ejr.183.2023.09.03.05.46.28; Sun, 03 Sep 2023 05:46:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236713AbjICL4M (ORCPT + 99 others); Sun, 3 Sep 2023 07:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236941AbjICL4L (ORCPT ); Sun, 3 Sep 2023 07:56:11 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 23138131; Sun, 3 Sep 2023 04:56:05 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.02,224,1688396400"; d="scan'208";a="178550481" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 03 Sep 2023 20:56:04 +0900 Received: from localhost.localdomain (unknown [10.226.92.30]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 149AE41C3085; Sun, 3 Sep 2023 20:56:01 +0900 (JST) From: Biju Das To: Jonathan Cameron Cc: Biju Das , Lars-Peter Clausen , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Marek Vasut , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Biju Das Subject: [PATCH v3 3/4] iio: dac: mcp4725: Add use_ext_ref_voltage to struct mcp4725_chip_info Date: Sun, 3 Sep 2023 12:55:47 +0100 Message-Id: <20230903115548.59306-4-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230903115548.59306-1-biju.das.jz@bp.renesas.com> References: <20230903115548.59306-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The MCP4725 has external voltage reference compared MCP4725 which has reference embeedded in eeprom. Add use_ext_ref_voltage variable to struct mcp4725_chip_info to handle this difference. Signed-off-by: Biju Das --- v3: * New patch --- drivers/iio/dac/mcp4725.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index fe8981ec7923..9cbea6f223e4 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c @@ -33,6 +33,7 @@ struct mcp4725_chip_info { const struct iio_chan_spec *chan_spec; unsigned int chip_id; + bool use_ext_ref_voltage; }; struct mcp4725_data { @@ -416,7 +417,7 @@ static int mcp4725_probe(struct i2c_client *client) pdata = &pdata_dt; } - if (info->chip_id == MCP4725 && pdata->use_vref) { + if (info->use_ext_ref_voltage && pdata->use_vref) { dev_err(&client->dev, "external reference is unavailable on MCP4725"); return -EINVAL; @@ -472,10 +473,10 @@ static int mcp4725_probe(struct i2c_client *client) data->powerdown = pd > 0; data->powerdown_mode = pd ? pd - 1 : 2; /* largest resistor to gnd */ data->dac_value = (inbuf[1] << 4) | (inbuf[2] >> 4); - if (info->chip_id == MCP4726) + if (!info->use_ext_ref_voltage) ref = (inbuf[3] >> 3) & 0x3; - if (info->chip_id == MCP4726 && ref != data->ref_mode) { + if (!info->use_ext_ref_voltage && ref != data->ref_mode) { dev_info(&client->dev, "voltage reference mode differs (conf: %u, eeprom: %u), setting %u", data->ref_mode, ref, data->ref_mode); @@ -515,6 +516,7 @@ static void mcp4725_remove(struct i2c_client *client) static const struct mcp4725_chip_info mcp4725 = { .chan_spec = &mcp472x_channel[MCP4725], .chip_id = MCP4725, + .use_ext_ref_voltage = true, }; static const struct mcp4725_chip_info mcp4726 = { -- 2.25.1