From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC6D7267F4F; Tue, 8 Apr 2025 11:26:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744111618; cv=none; b=RD7P3F7ZpcibIvmaKc94pU4v58rglNTm6hfPfH3NM794Hq5myqDRNKBqpfTYQ+0UJbCETTyyRXsqcKwyTK+kEt2B+S3UFTrCOb8ihXUbGODwqn1za38oDL6I/MndcYptACLocz9E9xbD77Ph5N/yknJJpD4RYYt2Mk5nYnll6J0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744111618; c=relaxed/simple; bh=fxtpKyWNeTwPxjXXAD4FARtd5Pfdd2oI4HdMDzCO5MI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BEIlS8/MMLPR3IvIVr2ND2/a9wkHsul7z7KTTydtTZF06qlhXGenneYrsQ00+XzwNg8ObGDu63E1xiZ/JRcvKs+4nfgzeK0mIG+Ze2ENuwVO4Kluw7s9Ey5fw1o7qM6ffQZVk9BR0HBj4ONwvRv3FM9tiYidxL2Bj3FZI0jt1go= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dWvmU0NF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="dWvmU0NF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06E9EC4CEE5; Tue, 8 Apr 2025 11:26:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744111617; bh=fxtpKyWNeTwPxjXXAD4FARtd5Pfdd2oI4HdMDzCO5MI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dWvmU0NFNXMUakinozkpzpfsh3kkb3NhWtv4DaR1OFDtW87z3iLyhABxk+vzCqN27 DeV0qqiIPLS4hkRweg3ydjNU1p/pWVODj0yWyvMOqMVq+N/bC8cH42b9ApSuXw2dsL SBLbjBSRkJhlE5aLnME9L3nKn15cWQ4JDSH+IW6E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jonathan Santos , Marcelo Schmitt , Jonathan Cameron , Sasha Levin Subject: [PATCH 6.14 495/731] iio: adc: ad7768-1: set MOSI idle state to prevent accidental reset Date: Tue, 8 Apr 2025 12:46:32 +0200 Message-ID: <20250408104925.788825107@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104914.247897328@linuxfoundation.org> References: <20250408104914.247897328@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jonathan Santos [ Upstream commit 2416cec859299be04d021b4cf98eff814f345af7 ] Datasheet recommends Setting the MOSI idle state to high in order to prevent accidental reset of the device when SCLK is free running. This happens when the controller clocks out a 1 followed by 63 zeros while the CS is held low. Check if SPI controller supports SPI_MOSI_IDLE_HIGH flag and set it. Fixes: a5f8c7da3dbe ("iio: adc: Add AD7768-1 ADC basic support") Signed-off-by: Jonathan Santos Reviewed-by: Marcelo Schmitt Link: https://patch.msgid.link/c2a2b0f3d54829079763a5511359a1fa80516cfb.1741268122.git.Jonathan.Santos@analog.com Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/adc/ad7768-1.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c index 113703fb72454..6f8816483f1a0 100644 --- a/drivers/iio/adc/ad7768-1.c +++ b/drivers/iio/adc/ad7768-1.c @@ -574,6 +574,21 @@ static int ad7768_probe(struct spi_device *spi) return -ENOMEM; st = iio_priv(indio_dev); + /* + * Datasheet recommends SDI line to be kept high when data is not being + * clocked out of the controller and the spi clock is free running, + * to prevent accidental reset. + * Since many controllers do not support the SPI_MOSI_IDLE_HIGH flag + * yet, only request the MOSI idle state to enable if the controller + * supports it. + */ + if (spi->controller->mode_bits & SPI_MOSI_IDLE_HIGH) { + spi->mode |= SPI_MOSI_IDLE_HIGH; + ret = spi_setup(spi); + if (ret < 0) + return ret; + } + st->spi = spi; st->vref = devm_regulator_get(&spi->dev, "vref"); -- 2.39.5