Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2692420pxv; Sun, 25 Jul 2021 02:24:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoRZ7J9DsDqqyb3UmVJPTcyVryHMXr5kTBs6wAcnZ9FsZEMLPKnBEWN5a9JdQ1xgs4PTRy X-Received: by 2002:a05:6638:2195:: with SMTP id s21mr11625144jaj.15.1627205046862; Sun, 25 Jul 2021 02:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627205046; cv=none; d=google.com; s=arc-20160816; b=ijFUcJSO1uUsC0ZrtvVpoI6zrtgbKm/BH5Li2jWHnHhfIJf9NSdyuAwEJ7E020bG3v uhwqQLOXgtpNe0+q7KS3PBts7lyu121zRC5ixVOi5HQOdZACtgWQNFuVVhPhRddUqXOY z/Uv7elSHvTO7orowoyVmpR23M0ey8wBJ3HifL/BeO6iQtdctKGC6i3SsSDD0Qhkq3/Q P/lM0zTGSrwAZ8Ljlb7kGbI/AlPen3wnh7RkxEY8hGMikd/AUJRk0mI+9w+sF+Qvk9Sn l58llth4SRZq+XZfqd4xTHvwycQyNl0yHZveVntdwY2K/G/uqh8w0/gYFwzVQIuiD9MB k74Q== 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:cc:to:subject:from:date; bh=bBphDB0ZbF4JQr2NxMcc0+YoXOqA2X45Z/UVItakhlc=; b=vIfWPVOJeVoUvxxHuJm07hPW5ycAPxIkcdPrHRGw97kMeqmUdTlczoDsZfawWLZIKk kX1GJfHLRvV2m/sznlEevrIvFuorC1zgaDypiNzNpJ1qqeH3Fu9WLhz9/JtsSxMc1IVi ic4DXAYYTkxbpuancSZciv4+vdUKP/JL4z4AmGRSSUiFhlXVs2s+8r8x9c6NzD0+/k0l CRcB7Kj4kyTbY7sz+ga8sl+RGejE2QIfjahxFH/H9wZUpg9zPEB2COBzB2fL7Byzw+Yh jh5HovEiiXQpPw7vza5COLqEY+oQ2keMiROq2UWLUSDvwanyyzSlE8uaELrhrA36R99r YWog== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d131si51858801iog.11.2021.07.25.02.23.55; Sun, 25 Jul 2021 02:24:06 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230421AbhGYImO convert rfc822-to-8bit (ORCPT + 99 others); Sun, 25 Jul 2021 04:42:14 -0400 Received: from aposti.net ([89.234.176.197]:44272 "EHLO aposti.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230272AbhGYImO (ORCPT ); Sun, 25 Jul 2021 04:42:14 -0400 Date: Sun, 25 Jul 2021 10:22:34 +0100 From: Paul Cercueil Subject: Re: [PATCH v3 4/5] iio/adc: ingenic: add JZ4760B support to the sadc driver To: Christophe Branchereau Cc: jic23@kernel.org, lars@metafoo.de, linux-mips@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org, linux@roeck-us.net, contact@artur-rojek.eu Message-Id: In-Reply-To: <20210724190449.221894-5-cbranchereau@gmail.com> References: <20210724190449.221894-1-cbranchereau@gmail.com> <20210724190449.221894-5-cbranchereau@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christophe, Where did the + { .compatible = "ingenic,jz4760b-adc", .data = &jz4760_adc_soc_data }, go? Cheers, -Paul Le sam., juil. 24 2021 at 21:04:48 +0200, Christophe Branchereau a ?crit : > The JZ4760B variant differs slightly from the JZ4760: it has a bit > called VBAT_SEL in the CFG register. > > In order to correctly sample the battery voltage on existing > handhelds using this SOC, the bit must be cleared. > > We leave the possibility to set the bit, by using the > "ingenic,use-internal-divider" in the devicetree. > > Signed-off-by: Christophe Branchereau > --- > drivers/iio/adc/ingenic-adc.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/iio/adc/ingenic-adc.c > b/drivers/iio/adc/ingenic-adc.c > index 6b9af0530590..eaa8ab36183c 100644 > --- a/drivers/iio/adc/ingenic-adc.c > +++ b/drivers/iio/adc/ingenic-adc.c > @@ -37,6 +37,7 @@ > #define JZ_ADC_REG_CFG_SAMPLE_NUM(n) ((n) << 10) > #define JZ_ADC_REG_CFG_PULL_UP(n) ((n) << 16) > #define JZ_ADC_REG_CFG_CMD_SEL BIT(22) > +#define JZ_ADC_REG_CFG_VBAT_SEL BIT(30) > #define JZ_ADC_REG_CFG_TOUCH_OPS_MASK (BIT(31) | GENMASK(23, 10)) > #define JZ_ADC_REG_ADCLK_CLKDIV_LSB 0 > #define JZ4725B_ADC_REG_ADCLK_CLKDIV10US_LSB 16 > @@ -879,6 +880,14 @@ static int ingenic_adc_probe(struct > platform_device *pdev) > /* Put hardware in a known passive state. */ > writeb(0x00, adc->base + JZ_ADC_REG_ENABLE); > writeb(0xff, adc->base + JZ_ADC_REG_CTRL); > + > + /* JZ4760B specific */ > + if (device_property_present(dev, "ingenic,use-internal-divider")) > + ingenic_adc_set_config(adc, JZ_ADC_REG_CFG_VBAT_SEL, > + JZ_ADC_REG_CFG_VBAT_SEL); > + else > + ingenic_adc_set_config(adc, JZ_ADC_REG_CFG_VBAT_SEL, 0); > + > usleep_range(2000, 3000); /* Must wait at least 2ms. */ > clk_disable(adc->clk); > > -- > 2.30.2 >