Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7337338ybp; Wed, 16 Oct 2019 07:21:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrc9fKmI9MQmbkbpsGAiVn/EVBS8PsBxJW4Ar2qeUPsB8seqqKuGjHFyOf4y1h5zwMgzP9 X-Received: by 2002:a50:fb84:: with SMTP id e4mr39391591edq.181.1571235679182; Wed, 16 Oct 2019 07:21:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571235679; cv=none; d=google.com; s=arc-20160816; b=TrH4KqFuZYjSmxgtGwmeXNr5mfBAzCQMdgtGD8WguI3RTrwSP83/8xSDpRgeXZXIsC lD9svHQHszcYi6Oezud/zQZYLDQ9EXk4s8UE1wcoxBIKgweNjbi3Xq7Sf/vKKU0m+Gld GM8rsj7f3Wt5s7XyzQ0Il39hyhfWPrCgawHajGAuDoKvy+71NfG/teOwQ5rrBc87QkVu Sl0lY2xaQTLZS6rm+IjlnYAkDMa1uUlrnOURGjX6hpscrTR7lddlUsOW5amSqrvRhUm1 /S9Zt8iUmig8JVJmc1DhtpIImK8uVMwPZzAcjr9hSNXHd4xKx7KHBfPRn9QbtigZrOGT kSEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=T5807SHMfE0Fu6KZHnolvLp47fnSirXFWtKM1W/C2XI=; b=jG/8Wx7ErQbc922dYmY8PuQJPy/h5FFgetmmurMY5NiyfV/FMEDvQU08hOyEmbPIyl RYnSiEAaAPeWOEjja2DBFnlM6IMG3oH4ynj/HKwFeEzsxp/FMK5Cd6i7S8vxU8XYaGk0 olUbQakn3x6w32TO07EvYXPK9zMHtMFkKXjsPD17TveMELKSkQzrBC2wF5f4FBunWZtq FmckafAJdw1NiIP4J8sTrOiDjsC0QeIowPpVQi17EYa44pAMV4JcD+kr4FA7V0zZJ1zA NzqAboW72nXesNj9JM0fJP+nut0py+qBZN9A3V8aY4GmIzwWp7bpKN5MZ0kWqqGlLq8l D9mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oz25si14878879ejb.175.2019.10.16.07.20.55; Wed, 16 Oct 2019 07:21:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392377AbfJPKXm (ORCPT + 99 others); Wed, 16 Oct 2019 06:23:42 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:35599 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388923AbfJPKXm (ORCPT ); Wed, 16 Oct 2019 06:23:42 -0400 Received: from uno.localdomain (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay10.mail.gandi.net (Postfix) with ESMTPSA id CAB1124000F; Wed, 16 Oct 2019 10:23:39 +0000 (UTC) From: Jacopo Mondi To: geert+renesas@glider.be Cc: Jacopo Mondi , linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] iio: adc: max9611: Defer probe on POR read Date: Wed, 16 Oct 2019 12:25:20 +0200 Message-Id: <20191016102520.124370-1-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The max9611 driver tests communications with the chip by reading the die temperature during the probe function. If the temperature register POR (power-on reset) value is returned from the test read, defer probe to give the chip a bit more time to properly exit from reset. Reported-by: Geert Uytterhoeven Signed-off-by: Jacopo Mondi --- Geert, I've not been able to reproduce the issue on my boards (M3-N Salvator-XS and M3-W Salvator-X). As you reported the issue you might be able to reproduce it, could you please test this? Also, I opted for deferring probe instead of arbitrary repeat the temperature read. What's your opinion? Thanks j --- drivers/iio/adc/max9611.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c index da073d72f649..30ae5879252c 100644 --- a/drivers/iio/adc/max9611.c +++ b/drivers/iio/adc/max9611.c @@ -80,6 +80,7 @@ * The complete formula to calculate temperature is: * ((adc_read >> 7) * 1000) / (1 / 480 * 1000) */ +#define MAX9611_TEMP_POR 0x8000 #define MAX9611_TEMP_MAX_POS 0x7f80 #define MAX9611_TEMP_MAX_NEG 0xff80 #define MAX9611_TEMP_MIN_NEG 0xd980 @@ -480,8 +481,10 @@ static int max9611_init(struct max9611_dev *max9611) if (ret) return ret; - regval &= MAX9611_TEMP_MASK; + if (regval == MAX9611_TEMP_POR) + return -EPROBE_DEFER; + regval &= MAX9611_TEMP_MASK; if ((regval > MAX9611_TEMP_MAX_POS && regval < MAX9611_TEMP_MIN_NEG) || regval > MAX9611_TEMP_MAX_NEG) { -- 2.23.0