From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1AE91DF27C for ; Tue, 7 Jan 2025 23:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736293835; cv=none; b=q8G3POtW4ZfW0eVnfGb1enoEwvjYZX4Dj81BcrX0MbEc0aD0jGyqJxHsRH/khiz+h9n4G7vF3jsSdmPPGGwl2BTio2SWOjk7V/2rEC3ug+LI+ypwBw0IA+x0I6FKbhL5v773Zmu0/DvQ8UeYJCw03FIoIPPARXNZqCnFApazcjQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736293835; c=relaxed/simple; bh=XfPvlCPGM6v+rwnBGl4dOBG7B5R6Eye3/uGl5/TBzoo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ay+BYKMOqaeVzffatIlf9VSulN24L5EWn7pEAfve+gkU67VYLiQC3wdM2hndEvpTmb/79LhA+Q74247APXUDKCO/xihA/yOnnhOOH0PVdk7NWSVCXQNZrn+6HCL6eN9NJ9GgHIxh3XeKunG9q62eJpt33k1aZlhabtg/KwCrUoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=qYRv5iz5; arc=none smtp.client-ip=209.85.161.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="qYRv5iz5" Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-5f2d5b3c094so3233099eaf.1 for ; Tue, 07 Jan 2025 15:50:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736293832; x=1736898632; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=sOh6SgpD0fnoQUo4jBTRWWnnORTvD4Gd2yKfcHr0wjI=; b=qYRv5iz5uMYu87LBXB6oD37vMQoDpkJTq0+/2tKEaTvPs8LBJy7n08rXSXOhy2E31e rNFvBqBB1RXYrIrezLaPEYdt3mdFY7konUkXvEl1Bg7GUtTWnj0l3/doKhU3I5YLoIxf ZGDgxk4RMBE1t+7tpio7IXb5B82thM/+bTEXz2VoOlDKleldrHrI9h9FYIPeHzIWQ+bn iZpMWO3JuasnB2YNkZWYvCvUIvoDzZYRRnkWD3H+zQmCCoedadgLywGgQVZNdempLxRV D2RLZQKwW/fjaK5ghkNLtuGfag5pHVuk3mV8PTFM313bj00cxo816cJ46dSMv+XvaRod hEDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736293832; x=1736898632; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sOh6SgpD0fnoQUo4jBTRWWnnORTvD4Gd2yKfcHr0wjI=; b=RoLHg8t1U5/8YffXg5IygR3t54xn83dQuP7ljjJ/5aAQlXGJ8LPUkzTRMHJFiLvOr6 fXkb6qy8PJrYZhRIphTpDUNjNYndsBNKrkngSH8DL2jqFqiaofwOfJlaxykOlwXwp9+d PxE6mR6ihDtV7yDpA2Dm8X0vrACluA4QUUzkzGfP+9fIU6wX9EMpxN/R5MX5cCQRr7Br cpGIPU1+mNLBugTiET+VeZZvjOyxEHU/GrNkBq3g4v+jYouwyMsdwqzngr3HtHba1K61 RAhZSFffETpLPDb9y8RLh5z3eIem3+4bLXwMBsgENIPxM68rbLDMadH8lGqg9dvJWs5q kJQg== X-Forwarded-Encrypted: i=1; AJvYcCVPwwj4vVGd0AEbIL+SShzYithaVAVrK82rJB/DgT85J1GQaFZ4SDON5QmwBLiGVNrs9I7wo2oU5l5B1l4=@vger.kernel.org X-Gm-Message-State: AOJu0YzcrNenwgnd5K3uYrAct2L3lyouobYf75XWhU77Wfv9tCLsFeRR b8xy/xiN2YJ+d2fJ6HdmsIVLfQ0wgFDPj+kren7izaL3Q9Jtf6cG+L+vfM1j+gs= X-Gm-Gg: ASbGncsAMDhMIznUZaNm8avg2Z1MKC+cf1Ub0VWVMc71bib48fpp64h14/DXblmiOyj Q9ER7iEX49+1Kyd1oTtQzTpzi3k4tpFe9gpgGr6nlRjI7ItbowQmeZeLBIPlkBgnkSkqgl87gZ5 63BU9IEZqMM6CaaoKSxrJv9Xn40GPBu7107gJmbE2f1/RxUbu11rDUfyN7t9Ek59jOCKOKZRpgd JpYQeXBb4DoL8ryA3+xMTZvhv+JZmOgpdy7D5ZFs0vPX1P3u+xxxODxyGx/hjubTzETthmLuIaE xaoKuT+KBqUWQxsCAA== X-Google-Smtp-Source: AGHT+IEV5Fz0MfSNQ/uGaWWpS3qlhYqNZZWNPwgurnfrwPJX5zzf/vl5vBDqy23+j/EAHi9NAHKtgg== X-Received: by 2002:a05:6820:543:b0:5f6:c2a3:a146 with SMTP id 006d021491bc7-5f7308c08bemr286228eaf.1.1736293831925; Tue, 07 Jan 2025 15:50:31 -0800 (PST) Received: from [192.168.0.142] (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc976635dsm10819604a34.9.2025.01.07.15.50.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Jan 2025 15:50:30 -0800 (PST) Message-ID: Date: Tue, 7 Jan 2025 17:50:29 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 14/15] iio: adc: ad7768-1: add support for Synchronization over SPI To: Jonathan Santos , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, marcelo.schmitt1@gmail.com References: <0f9a15e6e2e6b7b2c82ef79d8cb883d9eb6c55dd.1736201898.git.Jonathan.Santos@analog.com> From: David Lechner Content-Language: en-US In-Reply-To: <0f9a15e6e2e6b7b2c82ef79d8cb883d9eb6c55dd.1736201898.git.Jonathan.Santos@analog.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/7/25 9:27 AM, Jonathan Santos wrote: > The synchronization method using GPIO requires the generated pulse to be > truly synchronous with the base MCLK signal. When it is not possible to > do that in hardware, the datasheet recommends using synchronization over > SPI, where the generated pulse is already synchronous with MCLK. This > requires the SYNC_OUT pin to be connected to SYNC_IN pin. > > Add the option to handle device synchronization over SPI. > > Signed-off-by: Jonathan Santos > --- ... > static int ad7768_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) > @@ -697,11 +708,21 @@ static int ad7768_setup(struct ad7768_state *st) > if (ret) > return ret; > > - st->gpio_sync_in = devm_gpiod_get(&st->spi->dev, "adi,sync-in", > - GPIOD_OUT_LOW); > + st->gpio_sync_in = devm_gpiod_get_optional(&st->spi->dev, "adi,sync-in", > + GPIOD_OUT_LOW); > if (IS_ERR(st->gpio_sync_in)) > return PTR_ERR(st->gpio_sync_in); > > + if (device_property_present(&st->spi->dev, "adi,sync-in-spi")) > + st->en_spi_sync = true; > + > + /* > + * GPIO and SPI Synchronization are mutually exclusive. > + * Return error if both are enabled Should it also be an error if we have neither? Otherwise it sounds like decimation won't work correctly since there is a comment that says we have to toggle this after updating the decimation rate register. > + */ > + if (st->gpio_sync_in && st->en_spi_sync) > + return -EINVAL; A dev_err_probe() message would be helpful here when creating a new DT and bringing up a new system since it is easy to forget a property or make a typo that could lead to this error. > + > ret = ad7768_gpio_init(st); > if (ret < 0) > return ret;