From nobody Fri Dec 19 15:55:09 2025 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 33FD2267F74 for ; Tue, 8 Apr 2025 10:20:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744107620; cv=none; b=kLjtJnA0kZTbzsteQhi4pJwoGyTjP30chp/IXTeP1OmTQVX8Ln/gXaMoGIFqX9ugmKoa41d8TVOj5qeR4xsBSzZJt7LX6IwQknC3bLgjuIbMPmqLf6o38q1hQhVhFSvY5SZO8QrqSERfESM/ljhllmyLfT9U/So5lmhQCrMboZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744107620; c=relaxed/simple; bh=uaSn6MwlcUjmKtZsVLaWOQsSsxy2zH+ZMA/NJ+Ecw1I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GI3o3muq5V77mN6aDg3h79bGyEuCJb2fWQ5StMPn+gCc2WhZ2WYMQKRs/F4q5XQCcE3BcdykBP9rT/L3dWLkbdm5O6I05YbBOws//Qgc9wnlA+jHDlqdTLj5+VLAHPaT9jM4isfX6aJ+mBLKpCGxu5EYyTd8VS4B9zJQRsmh0i8= 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=1D6dpUnv; arc=none smtp.client-ip=209.85.128.47 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="1D6dpUnv" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-43cf06eabdaso49812155e9.2 for ; Tue, 08 Apr 2025 03:20:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1744107614; x=1744712414; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=5TWjREkBL8GjTju5ZPe7ZnjIycMK9O4uTTIH3dx3mcg=; b=1D6dpUnvnAsWmZeluKx2NMBI3WA+071Xtany+l+7sPq8R0i3BF1ovS1fePxDfzcIBm 8IAxxs4zbJs5JFDt+7Uu+UIaNhbyuCtyOdBuaBwht03KyjJObB5asHuU0ybiqC1+Btb3 tdqFq6somI7PWDZLGzEGttu3SKMb1p/PtXWsO5qh9wfXyPhImApkrXHqvQ79sVm9XbVp iQO3VwuvdVp/UF18QYB9kPZazxR+5aq6MYhWlYLJvkHtEYqvfjlImvXd8AE1lmr4LvyJ gbgDBLiJ2i8IkIzyp/4jjVrv7YDdT02eeWH26EH7ntI7fXZWnAYzOww2Q+n9JOJIB9x4 b89w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744107614; x=1744712414; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5TWjREkBL8GjTju5ZPe7ZnjIycMK9O4uTTIH3dx3mcg=; b=rdwyHd2jf8xBEj2QM26lqHdGRhKzvhyGcLtnwFyERzemwwDRcxJ0/46fmO7g2i1Nob iyTcD3SQL7v4SdZ5BOE+oU4PsgaJtTins3qZ+ppiuH42s+0R87dOdot1PWztSoLCrtth aVxbhXZ8cxEfleN6HN1K15sNksdzyXmN8J5ACPGBn2O0CtBRMHVjjIzDhW+Akn+J1/Nt J12QDk10I1RMEPHOQRc7afEYnaeSw17s5BRBxmp/A/IXUcxHQ2Ced7KxJfTjdtw79g2X qRLfXjXn6gN2P3HyMVwsJtPJlGtmmXl+vwS90DZnpCd+hMHLXDd1rZpeWXbdsOzlsJ8w iNmQ== X-Forwarded-Encrypted: i=1; AJvYcCWgRZWIverrLb3VqRdtu2aksp5CGu8+ag6CmRBsnjIaFGQxIkYgbkNTpfxeXkATGOdErV0i/dWvA2otfTA=@vger.kernel.org X-Gm-Message-State: AOJu0Yzo51LVxiKVRj/CwdNxhVuYRTfWmEmSS43ua5bko/FyR+r5QoSo KdJnI9q7qUJm/UUaHz1jgbmFnglgvxq/p7PJxZGenSFQ1F9GezQiW8pv8ZyrEZsBO/XmWWImSdN u X-Gm-Gg: ASbGncvyRiHhVtEPB0lgAyRiB4zW1uqYNL18RD32W0jUV8uJm4WjGfEejZnndi7VaRV a2foN4RQTX610zmyssvBLTX+JpPj37D00D2G544evIRisyKFe7UNOCwn9+QUGMKFFSFmwuagWmX ZWc5TlSF8JLbyYalQMPGfRonFfwv2pXpB2hvJ8A+D5a+8Ut8RELqCOuvi9q6GryeLWclcJUJEZD 1HkR7RlTXJEpyepP2AwUFXXOlwetZGKEGGDTt3DM+aJ9dTZ/ltL1OPAFUkk0IDZWdd2/SW1R53H owXVKlsjQTFqfGdjIaWI9wLZAYdqvj02M87D7jnB7MdAdu4ziF/LaOpZs+ggCdzkmuFPrO1ahXB qRFN7Ze3I7aYElq+0i6bW6A== X-Google-Smtp-Source: AGHT+IGRho06kAFvyYZIybkWVdW8uTOAmiAGyOTWEhu5um6FvJaKPHVpVzSbgjTLVAUzrMNLKKYedQ== X-Received: by 2002:a5d:59a5:0:b0:39b:fa24:950a with SMTP id ffacd0b85a97d-39cba9825e1mr12129520f8f.36.1744107614314; Tue, 08 Apr 2025 03:20:14 -0700 (PDT) Received: from [192.168.0.2] (host-87-15-70-119.retail.telecomitalia.it. [87.15.70.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39d7c6d838bsm4396138f8f.69.2025.04.08.03.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Apr 2025 03:20:13 -0700 (PDT) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 08 Apr 2025 12:18:51 +0200 Subject: [PATCH v4 1/5] iio: dac: adi-axi-dac: add cntrl chan check Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250408-wip-bl-ad3552r-fixes-v4-1-b33c0264bd78@baylibre.com> References: <20250408-wip-bl-ad3552r-fixes-v4-0-b33c0264bd78@baylibre.com> In-Reply-To: <20250408-wip-bl-ad3552r-fixes-v4-0-b33c0264bd78@baylibre.com> To: =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron , Lars-Peter Clausen , Jonathan Corbet , Olivier Moysan , Michael Hennerich Cc: linux-iio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3092; i=adureghello@baylibre.com; h=from:subject:message-id; bh=UoS9PVUrR5VQ2Mqe4V6ZiAxOY0YtQJ30vm21lXMXNAw=; b=owGbwMvMwCXGf3bn1e/btlsznlZLYkj/8kMo6slvwRyLdb8OvPbLZFtiXxaQ1GDRePZNfeXy7 IO7LI0LO0pZGMS4GGTFFFnqEiNMQm+HSikvYJwNM4eVCWQIAxenAEykdSrDP3u3idteO8kLyOS2 qb9iW54os/CIwo/pEWJOzjMWfX3leonhf/EHhglXDx+sVJlebBrPKxPGUyYSVZFiUCTyemGdZfo EPgA= X-Developer-Key: i=adureghello@baylibre.com; a=openpgp; fpr=703CDFAD8B573EB00850E38366D1CB9419AF3953 From: Angelo Dureghello Add validity check on CNTRL_X channels (valid as 0 to 15). Reviewed-by: Nuno S=C3=A1 Signed-off-by: Angelo Dureghello --- drivers/iio/dac/adi-axi-dac.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c index 892d770aec69c4259de777058801c9ab33c79923..f86acb98b0cffb09bf4d4626f93= 2bf1edc911e2b 100644 --- a/drivers/iio/dac/adi-axi-dac.c +++ b/drivers/iio/dac/adi-axi-dac.c @@ -84,6 +84,7 @@ #define AXI_DAC_CHAN_CNTRL_7_REG(c) (0x0418 + (c) * 0x40) #define AXI_DAC_CHAN_CNTRL_7_DATA_SEL GENMASK(3, 0) =20 +#define AXI_DAC_CHAN_CNTRL_MAX 15 #define AXI_DAC_RD_ADDR(x) (BIT(7) | (x)) =20 /* 360 degrees in rad */ @@ -186,6 +187,9 @@ static int __axi_dac_frequency_get(struct axi_dac_state= *st, unsigned int chan, u32 reg, raw; int ret; =20 + if (chan > AXI_DAC_CHAN_CNTRL_MAX) + return -EINVAL; + if (!st->dac_clk) { dev_err(st->dev, "Sampling rate is 0...\n"); return -EINVAL; @@ -230,6 +234,9 @@ static int axi_dac_scale_get(struct axi_dac_state *st, int ret, vals[2]; u32 reg, raw; =20 + if (chan->channel > AXI_DAC_CHAN_CNTRL_MAX) + return -EINVAL; + if (tone_2) reg =3D AXI_DAC_CHAN_CNTRL_3_REG(chan->channel); else @@ -264,6 +271,9 @@ static int axi_dac_phase_get(struct axi_dac_state *st, u32 reg, raw, phase; int ret, vals[2]; =20 + if (chan->channel > AXI_DAC_CHAN_CNTRL_MAX) + return -EINVAL; + if (tone_2) reg =3D AXI_DAC_CHAN_CNTRL_4_REG(chan->channel); else @@ -291,6 +301,9 @@ static int __axi_dac_frequency_set(struct axi_dac_state= *st, unsigned int chan, u16 raw; int ret; =20 + if (chan > AXI_DAC_CHAN_CNTRL_MAX) + return -EINVAL; + if (!sample_rate || freq > sample_rate / 2) { dev_err(st->dev, "Invalid frequency(%u) dac_clk(%llu)\n", freq, sample_rate); @@ -342,6 +355,9 @@ static int axi_dac_scale_set(struct axi_dac_state *st, u32 raw =3D 0, reg; int ret; =20 + if (chan->channel > AXI_DAC_CHAN_CNTRL_MAX) + return -EINVAL; + ret =3D iio_str_to_fixpoint(buf, 100000, &integer, &frac); if (ret) return ret; @@ -385,6 +401,9 @@ static int axi_dac_phase_set(struct axi_dac_state *st, u32 raw, reg; int ret; =20 + if (chan->channel > AXI_DAC_CHAN_CNTRL_MAX) + return -EINVAL; + ret =3D iio_str_to_fixpoint(buf, 100000, &integer, &frac); if (ret) return ret; @@ -493,6 +512,9 @@ static int axi_dac_data_source_set(struct iio_backend *= back, unsigned int chan, { struct axi_dac_state *st =3D iio_backend_get_priv(back); =20 + if (chan > AXI_DAC_CHAN_CNTRL_MAX) + return -EINVAL; + switch (data) { case IIO_BACKEND_INTERNAL_CONTINUOUS_WAVE: return regmap_update_bits(st->regmap, @@ -521,6 +543,8 @@ static int axi_dac_set_sample_rate(struct iio_backend *= back, unsigned int chan, unsigned int freq; int ret, tone; =20 + if (chan > AXI_DAC_CHAN_CNTRL_MAX) + return -EINVAL; if (!sample_rate) return -EINVAL; if (st->reg_config & AXI_DAC_CONFIG_DDS_DISABLE) --=20 2.49.0 From nobody Fri Dec 19 15:55:09 2025 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 8A7B026869B for ; Tue, 8 Apr 2025 10:20:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744107621; cv=none; b=B9xjOnLLfBAOpVlNd2zalqL1jaqZ6UcyZiMIswwXVXHTnljd70cR6i2GFooRg5DZkLp7aCLzr2VfUHXxDbrtpDX6Wd8tNBLMqUZU7uf+M33ac7075qkN3l6XWM2pnmw7swyXb2z9M5g/RbAIQSzfo8HVpd7nBpGPoqkss1CyJjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744107621; c=relaxed/simple; bh=fJ2QDU0edCT1i91gDbLTwkRKAOLcggRrfUQ3QN1wvvo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=na3XEMxPBHbmibHYwWv1DmJW2UAP0uZ/WixiA+cUEx7FSaQ8Ph4MeX5VELxgFA4vKiwyZFV74Pb9VapPiKAldbAKwWlPMi+uO8qec55x6KGbPok3jdhoGnEwYLsYSeHW1zvdalB1UCV+ZLJ7KOKJ137pjeWyArwdX6bmqNRpIUc= 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=rC9Py0Z+; arc=none smtp.client-ip=209.85.221.47 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="rC9Py0Z+" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-39d83782ef6so309925f8f.0 for ; Tue, 08 Apr 2025 03:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1744107616; x=1744712416; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=N25ObTi9+VYre0Pwf0ivFwi1iTe0QqqN5sDF++TPjWQ=; b=rC9Py0Z+m0uUfuDFIwlBk31G1XYK80sM6+QkJNSSB1Ua6KhsObB1xv0IfDeuTOb9pf LeveQ7G3F8yg4dTG1Ki2mZIlgycYh7BktEJ5eZT6V8AhFllbAsEjQHQoqnl+GX3rsuuC KhhUSYVSr9nz0WXeHZqy+jndWn+ZemqOadWLxhPWG01laIdm6h+SvOpHwI8gJhVlBfZu RD8Kge7LP+UY0MjAe1M15YU39NC9IguMG0JxLBTW9WLopeuQ0bcPwFDG7FnE4ljwr0+U +aukPRQydKecn4ReISSKvFy8EDhgykWM0tA3hvwpVzC6+Hzz2+iVt17YBr41qFVTKO5M LcNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744107616; x=1744712416; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N25ObTi9+VYre0Pwf0ivFwi1iTe0QqqN5sDF++TPjWQ=; b=ROluM4WLCRi6J5Q2L4gli/DfpWKTxp9z9FWIxW6CJoqXcLB5HYBeYBMIs7SqEHh3hB Po/QOdbxGEpwagzf6DNGejZboPhvGUwbMfn8mFitH0g5EP6/YqORqIL/asFQH+S+Wg4O WemLpvE8IK4+7D1z6j4LqEJtEcYGeowxFtRq4Em7OWdZnGqRFWfYrPjjkvuioeXx/9Dx V0ZWwnJ08sVK94qHJm8Bp/Y0I8xecc4kcvCdlSINhUCnMdLc75NmX19507cQZeDVdcnx 2QzV2ZtNQde6jHQX69up/3p4CIomVwvE3UcBtHGH3zAZ+sqwYp/QzZ1zvud/MVFdy8rE LEOw== X-Forwarded-Encrypted: i=1; AJvYcCU4y6CKTsG4DOX4r7nieBR6JFpoLgWeOr4vy0KCrjP35XvELqUWCJiU+PTl/85TRbzvsqqlmdHg7mNCrFA=@vger.kernel.org X-Gm-Message-State: AOJu0YzYgh9JdHcs9tRwr/e5u9rkjdVUG1gBaEUy+2/e2+mYgQyWDJo6 OMWJZOAaYzZGB2xBYPf0i+ZwgyGm87Ze0kdVfvheAPM8kQB1+9N02aGijZcJsTg= X-Gm-Gg: ASbGncsOQIBmNK772YgHtxlvFJsq1VmWTglzLkP7ED+Q5sMtBk1Cn5cVXC8jjLzT+0L u6raQTCWMOe7vodxfFIPCnsMzOOJxZoup3XUiaQ24sYk0p/Qyq9kOemJzC1pijkw9n6V9VchzEJ L4dXKoOwrB8eiVc5Sg9CdUqyuremVp0jQQ/oS3aGNrOVVhB8A7+vFTZSQLMsofDuEniRy7U9oTm LFeA09JvwRcdcocOtsASlSlFUN8Hd4LnsF0xFCzm4u8mRRh5e6oeDti4xXBr5X5vwlr09BOdFeS yHx8YgkBTFQxrVL4KXix9OAVw0piyE9NVUD7+RJAoZrTliNRB3T0WwaMZgHQGmmL8TFbQj9KTIc vtAm9rfMXbrLtDsplAmYDKw== X-Google-Smtp-Source: AGHT+IGnPzc6uTuByt/3GyKTMHMQg/lwzqCoRyC3eh5DaNDXFcSV/h/SNkUkfCihJuOscV6vPXXflA== X-Received: by 2002:a05:6000:401f:b0:39b:3c96:80df with SMTP id ffacd0b85a97d-39d820ac9bemr2407988f8f.11.1744107615738; Tue, 08 Apr 2025 03:20:15 -0700 (PDT) Received: from [192.168.0.2] (host-87-15-70-119.retail.telecomitalia.it. [87.15.70.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39d7c6d838bsm4396138f8f.69.2025.04.08.03.20.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Apr 2025 03:20:15 -0700 (PDT) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 08 Apr 2025 12:18:52 +0200 Subject: [PATCH v4 2/5] docs: iio: add documentation for ad3552r driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250408-wip-bl-ad3552r-fixes-v4-2-b33c0264bd78@baylibre.com> References: <20250408-wip-bl-ad3552r-fixes-v4-0-b33c0264bd78@baylibre.com> In-Reply-To: <20250408-wip-bl-ad3552r-fixes-v4-0-b33c0264bd78@baylibre.com> To: =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron , Lars-Peter Clausen , Jonathan Corbet , Olivier Moysan , Michael Hennerich Cc: linux-iio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4342; i=adureghello@baylibre.com; h=from:subject:message-id; bh=6w/Ug2UM5FIVCK/04ZJVGDVSrtb3C+at0h3MVUDEs+E=; b=owGbwMvMwCXGf3bn1e/btlsznlZLYkj/8kNoK99sE8GjVXm3k6tdFvhEnvZKO7Vji2nRaXXmt pSyVy6nO0pZGMS4GGTFFFnqEiNMQm+HSikvYJwNM4eVCWQIAxenAEwkpo7hr1Be3/Sk7/fzijYd Zvq2M96C7Yv15cxK3f8F3okbj77NtmNk+N5UuWJjqflJkaup6e7OX/p0JiswvGBtut18ebnCkif HWQA= X-Developer-Key: i=adureghello@baylibre.com; a=openpgp; fpr=703CDFAD8B573EB00850E38366D1CB9419AF3953 From: Angelo Dureghello Add documentation for ad3552r driver, needed to describe the high-speed driver debugfs attributes and shows how the user may use them. Signed-off-by: Angelo Dureghello --- Documentation/iio/ad3552r.rst | 73 +++++++++++++++++++++++++++++++++++++++= ++++ Documentation/iio/index.rst | 1 + MAINTAINERS | 1 + 3 files changed, 75 insertions(+) diff --git a/Documentation/iio/ad3552r.rst b/Documentation/iio/ad3552r.rst new file mode 100644 index 0000000000000000000000000000000000000000..bd63b333ca10d993230027f933c= ebf7054684974 --- /dev/null +++ b/Documentation/iio/ad3552r.rst @@ -0,0 +1,73 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +AD3552R driver +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Device driver for Analog Devices Inc. AD35XXR series of DACs. The module n= ame +is ``ad3552r``. +With the same module name, two different driver variants are available, the +``generic spi`` variant, to be used with any classic SPI controllers, and = the +``hs`` (high speed) variant, for an ADI ``axi-dac`` (IP core) based contro= ller +that allows to reach the maximum sample rate supported from the DACs, usin= g the +DMA transfer and all the SPI lines available (D/QDSPI).. +The high speed driver variant is intended to be used with the ``adi-axi-da= c`` +backend support enabled, that is enabled by default when the driver is sel= ected. + +Supported devices +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +* `AD3541R `_ +* `AD3542R `_ +* `AD3551R `_ +* `AD3552R `_ + +Wiring connections +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Generic SPI +----------- +Use the classic SPI S_CLK/CS/SDO/SDI connection. + +High speed (using axi-dac backend) +---------------------------------- + +:: + + .-----------------. .-------. + | |--- D/QSPI -----| | + | DAC IP CORE |--- SPI S_CLK --| DAC | + | |--- SPI CS -----| | + | |--- LDAC -------| | + | |--- RESET ------| | + |_________________| |_______| + + +High speed features +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Device attributes +----------------- + +The following table shows the ad35xxr related device debug files, found in= the +specific debugfs path ``/sys/kernel/debug/iio/iio:deviceX``. + ++-----------------------+-------------------------------------------------= -----+ +| Debugfs device files | Description = | ++-----------------------+-------------------------------------------------= -----+ +| data_source | The used data source, as i.e. = | +| | ``iio-buffer``, ``backend-ramp-generator``, etc.= | ++-----------------------+-------------------------------------------------= -----+ +| data_source_available | The available data sources. = | ++-----------------------+-------------------------------------------------= -----+ +Usage examples +-------------- + +. code-block:: bash + root:/sys/bus/iio/devices/iio:device0# cat data_source + iio-buffer + root:/sys/bus/iio/devices/iio:device0# echo -n backend-ramp-generator > d= ata_source + root:/sys/bus/iio/devices/iio:device0# cat data_source + backend-ramp-generator + + diff --git a/Documentation/iio/index.rst b/Documentation/iio/index.rst index bbb2edce8272e7483acca500d1a757bbcc11c1e0..2d6afc5a8ed54a90cd8d5723f0d= c5212b8593d16 100644 --- a/Documentation/iio/index.rst +++ b/Documentation/iio/index.rst @@ -19,6 +19,7 @@ Industrial I/O Kernel Drivers .. toctree:: :maxdepth: 1 =20 + ad3552r ad4000 ad4030 ad4695 diff --git a/MAINTAINERS b/MAINTAINERS index 57eaab00f6cb53df52a4799eb2c1afbbd1e77a1e..52bc56a9ee22c66b90555681c47= 57ea4399adae1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1295,6 +1295,7 @@ L: linux-iio@vger.kernel.org S: Supported W: https://ez.analog.com/linux-software-drivers F: Documentation/devicetree/bindings/iio/dac/adi,ad3552r.yaml +F: Documentation/iio/ad3552r.rst F: drivers/iio/dac/ad3552r.c =20 ANALOG DEVICES INC AD4000 DRIVER --=20 2.49.0 From nobody Fri Dec 19 15:55:09 2025 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 18979265612 for ; Tue, 8 Apr 2025 10:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744107623; cv=none; b=aJBw8TLygO4119LJwDz2aWKakCf7JhpR/VckZpfk1Bal6H/K8OwSe0PvWwIwL/jcUn0JmfgFvvAqduLoQKjab2IF+FOzmiinPchfzYACdg8Mad4cE11zT/uAOmrtgURiRQq5kkvM9F7ZBaxf7qYFwtCBcH0UfjhlDBWIDnCcrKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744107623; c=relaxed/simple; bh=lgsAI1C4GJ9f/lxYOr2FZ5rkqth02XBYIH8GiAkKCgM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qJ6GzucDF0GC9K1o4ymvW9tSzqiBgtp1f2E6HdAG78QnYxFDX3PK02LTfT4/Rc2arG4ehUNRsS2rjdCWMnGf1U+sGsyx7TiJ1SCarDj9pImFbrTwmskbjGH1//qhI2X41rnGucFHJKHvm7aA5ZfPSiOThGk8c1G/oZnmH7cjHSc= 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=X3WEjOF5; arc=none smtp.client-ip=209.85.221.54 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="X3WEjOF5" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-39c1efbefc6so3109278f8f.1 for ; Tue, 08 Apr 2025 03:20:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1744107617; x=1744712417; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QYLrYCRZJaz3Q9z9V56+5pPJKQA4s8QRrtBGVRh2868=; b=X3WEjOF5Q1YCT3wxvcOsbRSmVJzWjIrRGi/Q1sqnAEicm1G3sigx0vKU9Abz+54YOp 1U4wj5BWcmB7PNm0fRt2BwyDGcJYAu0Wkof2tIV303kZKbbt4jh46yVVA5VXTcP0b6/S qsdSHr1boNDKWUpsBTZQCDFrs3STf8j8Sfop0Y8m/hT8wooRO4E+p/FNxo5YXpgkcrLV jcoZCaW10pxYE9Rw00VSgxqGnEwULDV++SzFXmOLEF3radfrE27SH51Z3YwaDq2MQwpE pmKYiMA8yECMGMRum5PDyWNWCysw0I7UPFP7i5j6M7fmQCUG9gVcGskkwccAL7I5ZxWu l2ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744107617; x=1744712417; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QYLrYCRZJaz3Q9z9V56+5pPJKQA4s8QRrtBGVRh2868=; b=fzv/CuteJpHWZxB5bdx+V9R87fVSYS8G6eKX4xoawgBFekfNDm6IR0G/IsfbMDcI2Z jIPJksQRmLG6s1TroOy0ihOS22My4k+/MHJrSnzzF/UogcsXZFYZlZQpem2S/DUKImEf tASBr2XOa34OjqMcOHbbOYoG/Cfk6wxIpJdCK98/IVSK8qVcJtzusHvYjHqut0Gj5A+r N+ns+I8htfIg2j4YDye+4qh1U/2wwUA1XlXhhqHScL3QAIOe+/x/EuUd2FQFnhFG9RIS /lAxXcvp1jUN4T2SkYzY7T4jV/8iYjRmtw3pNqm9ypzrjeqLa+QhTmbBNSTZ1TjCgvCG HT3A== X-Forwarded-Encrypted: i=1; AJvYcCVwX/ol08YXGhz9nPy9O7D2oSTlMes/6fREWYVNsV5ey0N+lUBwIBszWsLVHkml/dhmf6G/V7Ippjev8cY=@vger.kernel.org X-Gm-Message-State: AOJu0YyuLSPDIhr5l2NCRveEuh9cXb0UEl71J/6t/lh31lwLFJXShEVS Att7IZegFYsfq4eN54H6oyFNzFdC49T8xk+KW/pMZRIgPgIzr8XbbDSDxsNItx0= X-Gm-Gg: ASbGncv9PdZDfcFp2AyCBWjBMNQ53DRAdjCExwnkD7eosZnjotjrOjTtDakcAUS+AN4 9r/GdkzKA7G1+DnZaDSK3mYtiazMzNCgC3T8SfnFv2pVnaPT/YhMyd0J6YbuNU+xXuOgDK17QOG wRp2mAMJbAPjt1fMrqoEujkfUJDEHKqEgnZovnxJrR6WRjc2IfKBA+if/4pcs8BNGv+cSRcmiZl mh/A7mqj0jQmaRg3AmzUIdoQ/gU3UhCJrHWi2DPM1F9UihKyzUIn/9N79JX9giEX9KMnTSTYR+l sZ4Q8hAPMopG/mAXlJ+oVGkRIRIPFk4nbl5DXAjMRct2xiywyfjEi77TtSPKNyj3d9rmz0N7ugg LlQXcs9pUIJHNld5o1XAKTA== X-Google-Smtp-Source: AGHT+IGxgp39FjNPJEbArAS3WynvmgHVgFnW8e0TESe1VHTjuSvvOXJpuMeA42affgvOD3UXCRT7NQ== X-Received: by 2002:a05:6000:290b:b0:391:300f:7474 with SMTP id ffacd0b85a97d-39d6fc291bemr8609128f8f.18.1744107617207; Tue, 08 Apr 2025 03:20:17 -0700 (PDT) Received: from [192.168.0.2] (host-87-15-70-119.retail.telecomitalia.it. [87.15.70.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39d7c6d838bsm4396138f8f.69.2025.04.08.03.20.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Apr 2025 03:20:16 -0700 (PDT) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 08 Apr 2025 12:18:53 +0200 Subject: [PATCH v4 3/5] iio: backend: add support for data source get Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250408-wip-bl-ad3552r-fixes-v4-3-b33c0264bd78@baylibre.com> References: <20250408-wip-bl-ad3552r-fixes-v4-0-b33c0264bd78@baylibre.com> In-Reply-To: <20250408-wip-bl-ad3552r-fixes-v4-0-b33c0264bd78@baylibre.com> To: =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron , Lars-Peter Clausen , Jonathan Corbet , Olivier Moysan , Michael Hennerich Cc: linux-iio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3533; i=adureghello@baylibre.com; h=from:subject:message-id; bh=2lP6oKpb0hmzBUffbG/vd1ZR0rWtSFsiZRG8+MHxxuM=; b=owGbwMvMwCXGf3bn1e/btlsznlZLYkj/8kPI5UatbjprZUaeTtvfZUYiSee7OzwtRD3D9gQus ej3+Hymo5SFQYyLQVZMkaUuMcIk9HaolPICxtkwc1iZQIYwcHEKwET4zzAyHHn5SVrd8Q2bmc3z G+8+/LmxckLQp6fO/OITo7KYjc9fe8vw3831U5NsifpytkD93u07+Vd/yvqrrvOKe+n+mbHLipS WsQIA X-Developer-Key: i=adureghello@baylibre.com; a=openpgp; fpr=703CDFAD8B573EB00850E38366D1CB9419AF3953 From: Angelo Dureghello Add backend support for getting the data source used. The ad3552r HDL implements an internal ramp generator, so adding the getter to allow data source get/set by debugfs. Reviewed-by: Nuno S=C3=A1 Signed-off-by: Angelo Dureghello --- drivers/iio/industrialio-backend.c | 28 ++++++++++++++++++++++++++++ include/linux/iio/backend.h | 5 +++++ 2 files changed, 33 insertions(+) diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-= backend.c index a43c8d1bb3d0f4dda4277cac94b0ea9232c071e4..c1eb9ef9db08aec8437d0d00cf7= 7914ad6611b72 100644 --- a/drivers/iio/industrialio-backend.c +++ b/drivers/iio/industrialio-backend.c @@ -380,6 +380,34 @@ int iio_backend_data_source_set(struct iio_backend *ba= ck, unsigned int chan, } EXPORT_SYMBOL_NS_GPL(iio_backend_data_source_set, "IIO_BACKEND"); =20 +/** + * iio_backend_data_source_get - Get current data source + * @back: Backend device + * @chan: Channel number + * @data: Pointer to receive the current source value + * + * A given backend may have different sources to stream/sync data. This al= lows + * to know what source is in use. + * + * RETURNS: + * 0 on success, negative error number on failure. + */ +int iio_backend_data_source_get(struct iio_backend *back, unsigned int cha= n, + enum iio_backend_data_source *data) +{ + int ret; + + ret =3D iio_backend_op_call(back, data_source_get, chan, data); + if (ret) + return ret; + + if (*data >=3D IIO_BACKEND_DATA_SOURCE_MAX) + return -EINVAL; + + return 0; +} +EXPORT_SYMBOL_NS_GPL(iio_backend_data_source_get, "IIO_BACKEND"); + /** * iio_backend_set_sampling_freq - Set channel sampling rate * @back: Backend device diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h index e45b7dfbec35c094942a3034fc6057a7960b9772..e59d909cb65924b4872cadd4b7e= 5e894c13c189f 100644 --- a/include/linux/iio/backend.h +++ b/include/linux/iio/backend.h @@ -84,6 +84,7 @@ enum iio_backend_interface_type { * @chan_disable: Disable one channel. * @data_format_set: Configure the data format for a specific channel. * @data_source_set: Configure the data source for a specific channel. + * @data_source_get: Data source getter for a specific channel. * @set_sample_rate: Configure the sampling rate for a specific channel. * @test_pattern_set: Configure a test pattern. * @chan_status: Get the channel status. @@ -115,6 +116,8 @@ struct iio_backend_ops { const struct iio_backend_data_fmt *data); int (*data_source_set)(struct iio_backend *back, unsigned int chan, enum iio_backend_data_source data); + int (*data_source_get)(struct iio_backend *back, unsigned int chan, + enum iio_backend_data_source *data); int (*set_sample_rate)(struct iio_backend *back, unsigned int chan, u64 sample_rate_hz); int (*test_pattern_set)(struct iio_backend *back, @@ -176,6 +179,8 @@ int iio_backend_data_format_set(struct iio_backend *bac= k, unsigned int chan, const struct iio_backend_data_fmt *data); int iio_backend_data_source_set(struct iio_backend *back, unsigned int cha= n, enum iio_backend_data_source data); +int iio_backend_data_source_get(struct iio_backend *back, unsigned int cha= n, + enum iio_backend_data_source *data); int iio_backend_set_sampling_freq(struct iio_backend *back, unsigned int c= han, u64 sample_rate_hz); int iio_backend_test_pattern_set(struct iio_backend *back, --=20 2.49.0 From nobody Fri Dec 19 15:55:09 2025 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 87B902686AB for ; Tue, 8 Apr 2025 10:20:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744107622; cv=none; b=Vu0QnrX/4w8LNP66xWDDLEnamDkPbsMaGjcPJ7c9cQEdvTmEABVFcVueWImn8W5+t0K9JhN1QsHS1MnRx2Z3qZipe5cVZVakExX7Y/dvonab3+vCKV5mLk2GImUQR2oeb1DPGBs1x2YFInzsStCo/SJ8WSx6tKpqpuKdcwXrE5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744107622; c=relaxed/simple; bh=4KSeXmCw6z9Bh/u/zmCWqVRpCXcjpLPI9k+ZizbF7YE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qRBJQ24qtnjfCINlih5FYhIy5lsJa5B/6XZQvyBIG8aLmnD+wb/w8JL7GG6S+B6dtu6FOlP15aUMv387qsm0mBJLwoQcZgmhqG5V/9/UdJt0aFVKObwpLbEY8RJC29cLBrF7xi31e9C8KqYCa9PgQ2qYOxyHF2fnxlrNh9OqCoA= 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=l6lTGonG; arc=none smtp.client-ip=209.85.221.50 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="l6lTGonG" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-39c1efbefc6so3109293f8f.1 for ; Tue, 08 Apr 2025 03:20:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1744107618; x=1744712418; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wgEWndJtLeto4lW/nFUn4b5LOfScisxB+yrfREee8i4=; b=l6lTGonGg0nC9X6Xxx3f/4LV1cqXKJxTJpwd8S7JCgCPT/Skyf75UNHI3kDkjk8oMR znpD/CTuzPQOkiJXlljomK4kTmC4UktuJSVDAXAqMwm4S2pKipOwlrhJ67yp7sJ4HlWI lm/K6hqzjRjcxLgeCLH+ue8bmUWq3AIfNaaCME2MCGYkfj/BbrXzd6kzztWTqfVG4Pu1 GT/I6sTXFKHLlGzbPRVHfVCVWrcGoFq3nCF8sK2F2PrJE6KjfY7Zo0g/JCkKuSrNMm0s 31pFMqEIGolT+IuEccXYuwe4WFhdddq9aW53OSCVzOODqocQ//EfTVKQPRagCXCFeEVT Nowg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744107618; x=1744712418; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wgEWndJtLeto4lW/nFUn4b5LOfScisxB+yrfREee8i4=; b=ZsFzqaJ1lUSK9cn4hU9BzJUYViSe4Pm2CflTw7a0ZTJgFfeuQamQxb4c56kZ4ouVdM 612rO37K3JI/GfWT/Kl1dSFxvyh8+7z9fGtBNUNblIXdUFLcwInmscXk/Oqsxm03OXin NHH77PHxCwljKzSkzMi327KD42hCKPYupYWLe0+fUvsiqf5Mkdd9dYymPjFzDuwofz9r T/s0E4DMqd/vY9s5kAqlL8ZaABZmGCYqIP+Zbi8RihgiQPB3n+yaRoGiLwS5rA/mRaTv 3xoZIGFUvB7+gdJ1g0UXHKgGqHwY/ImBX95dGF6IsTuukasp1g8JvB+t5vMsrNoyNTmg JN9Q== X-Forwarded-Encrypted: i=1; AJvYcCXHDdB/kQWs6XKVYvy6sF+rI9ECpihM1pvUs4WaoeYqpvtmH9wjHpxyAWiOTcqh0QxofTc708Pugu82y7E=@vger.kernel.org X-Gm-Message-State: AOJu0YyymPpCFd117C90A2KhyZmGBIhtAoPkz4P25YNdjudWeZh/x8m5 7UZmnPVE+Y1G98pMCZf9xYEhMoESZ/c16Xy6Ap0bp/e9upADMjKmQ/SRhvho2+0= X-Gm-Gg: ASbGncsOS9NsRrLmZUSW/m/A6XqgQWjWR7Rjmdfs8Q9jcAianeiLXVY2z2qDBFiD3U2 vHkW1o0/kn6P4ZZKty/Vx2jCU9oMjHIFg0QNyt/shJ0vQoJ1vxQQh0+noEJZyfpeO9zeu9LM/Pg /+N33l0ZC2YQZpPr1OoRGN9u2ccaJmvJ1OgHFErISOosQa/XRTOM/ggKaztZQiH/kgW257Nek0y JJXW2V/GEbvxXjQdc5IckbGeEvOi7KBmqKcVwKXXnMEJ9Q634QK9zUL46xwbFdY/1Dpt0tpDpz/ 2cbBSeYJsMqaAmLOkl095AdygqR7G5gehXZHcT80iUApq4/YlPjv/X7JKwdR07shrIhQexWnlG3 /Iu2edjey99fNbYu0UjG4IQ== X-Google-Smtp-Source: AGHT+IE16kQdWoaOdUZSc0jBccGORe0Is3ES1Dz4BnnxEo5oDNDU3iW4GWjTfYWewqM5Ap/v54mENQ== X-Received: by 2002:a05:6000:2506:b0:38f:3073:708 with SMTP id ffacd0b85a97d-39d6fc00b6dmr11042622f8f.3.1744107618605; Tue, 08 Apr 2025 03:20:18 -0700 (PDT) Received: from [192.168.0.2] (host-87-15-70-119.retail.telecomitalia.it. [87.15.70.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39d7c6d838bsm4396138f8f.69.2025.04.08.03.20.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Apr 2025 03:20:18 -0700 (PDT) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 08 Apr 2025 12:18:54 +0200 Subject: [PATCH v4 4/5] iio: dac: adi-axi-dac: add data source get Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250408-wip-bl-ad3552r-fixes-v4-4-b33c0264bd78@baylibre.com> References: <20250408-wip-bl-ad3552r-fixes-v4-0-b33c0264bd78@baylibre.com> In-Reply-To: <20250408-wip-bl-ad3552r-fixes-v4-0-b33c0264bd78@baylibre.com> To: =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron , Lars-Peter Clausen , Jonathan Corbet , Olivier Moysan , Michael Hennerich Cc: linux-iio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1828; i=adureghello@baylibre.com; h=from:subject:message-id; bh=FaVSbpu5wfHy4/JtVk4ww5/ACGVgPb27AkggQGWKjsw=; b=owGbwMvMwCXGf3bn1e/btlsznlZLYkj/8kPoXUeeXGnOJ/bX/wLaZ3wKazikPO9QrOur+xoFe rFW94rtOkpZGMS4GGTFFFnqEiNMQm+HSikvYJwNM4eVCWQIAxenAEzEewHD/xQWS2GeqF9fWFNv 9k9rUXicWCSiKCdbVOrUUqhiF3OageGfbYPH46sFOabyF7PvHVG61P1W312xafaLfW9mt9487l7 BAwA= X-Developer-Key: i=adureghello@baylibre.com; a=openpgp; fpr=703CDFAD8B573EB00850E38366D1CB9419AF3953 From: Angelo Dureghello Add data source getter. Reviewed-by: Nuno S=C3=A1 Signed-off-by: Angelo Dureghello --- drivers/iio/dac/adi-axi-dac.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c index f86acb98b0cffb09bf4d4626f932bf1edc911e2b..8ed5ad1fa24cef649056bc5f4ca= 80abbf28b9323 100644 --- a/drivers/iio/dac/adi-axi-dac.c +++ b/drivers/iio/dac/adi-axi-dac.c @@ -536,6 +536,35 @@ static int axi_dac_data_source_set(struct iio_backend = *back, unsigned int chan, } } =20 +static int axi_dac_data_source_get(struct iio_backend *back, unsigned int = chan, + enum iio_backend_data_source *data) +{ + struct axi_dac_state *st =3D iio_backend_get_priv(back); + int ret; + u32 val; + + if (chan > AXI_DAC_CHAN_CNTRL_MAX) + return -EINVAL; + + ret =3D regmap_read(st->regmap, AXI_DAC_CHAN_CNTRL_7_REG(chan), &val); + if (ret) + return ret; + + switch (val) { + case AXI_DAC_DATA_INTERNAL_TONE: + *data =3D IIO_BACKEND_INTERNAL_CONTINUOUS_WAVE; + return 0; + case AXI_DAC_DATA_DMA: + *data =3D IIO_BACKEND_EXTERNAL; + return 0; + case AXI_DAC_DATA_INTERNAL_RAMP_16BIT: + *data =3D IIO_BACKEND_INTERNAL_RAMP_16BIT; + return 0; + default: + return -EIO; + } +} + static int axi_dac_set_sample_rate(struct iio_backend *back, unsigned int = chan, u64 sample_rate) { @@ -818,6 +847,7 @@ static const struct iio_backend_ops axi_ad3552r_ops =3D= { .request_buffer =3D axi_dac_request_buffer, .free_buffer =3D axi_dac_free_buffer, .data_source_set =3D axi_dac_data_source_set, + .data_source_get =3D axi_dac_data_source_get, .ddr_enable =3D axi_dac_ddr_enable, .ddr_disable =3D axi_dac_ddr_disable, .data_stream_enable =3D axi_dac_data_stream_enable, --=20 2.49.0 From nobody Fri Dec 19 15:55:09 2025 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 C93FC268C50 for ; Tue, 8 Apr 2025 10:20:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744107624; cv=none; b=dyQZUMnSagNBmJgdn6SUry7tcDXww9Fo6F5d0Tk2upPe63+UNANuzlokQm8sL2qqs+sHxYaJU8XX4on2bSOT0hdZ+wKKNpceJCpwNq0UveixsRXm6q01iel/MK1BbTxxHmmcWQyrke85ip6PdomDKK5mMiJbGyeB37Z0V5hegKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744107624; c=relaxed/simple; bh=vvWq4Dz82xJD2sorErUACcDZI4fJMciMqS6/2CqU+gA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OPVZJrhEsjKl4KaAyuUYmSqjYuJyW6nMpSOEY2RBEA5pT2SwNF0MsY6l+B2kDK7+VbiUtCq7u2MCr0DGCEyqBWFLDaxuqHgQe9O2lhNGkgg1yKaTgRxI1cla6M3wdvt1xEeSbW9Qpr7FRvK2WD0bJytmk+77r5mb/KZfs3jAEw8= 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=xF44p1Kp; arc=none smtp.client-ip=209.85.221.54 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="xF44p1Kp" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3912fdddf8fso4099655f8f.1 for ; Tue, 08 Apr 2025 03:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1744107620; x=1744712420; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=j9eheXrMshD0J5XzJ2mOaNomxGQPlMHtmpHgpZQ0nvc=; b=xF44p1Kp1zpqOd6AsWoksh6+pvdU6KnFL3dcg1nMea7EVTy56JXgyJv7uFYkuEiJ2U ybiauoUEMpsF0mlIWPanxiM8gyVpQwTQpnQZIkgUuMr3DJlT5qg7zWOvGjVCFfTrZ9Oy gWASP7qX6g6z7BzUdQIXf6K4BnHkHeB4ue4Mnm9pJAGtL03BI3Rnl2lh6YNbp7kMoseG acCqE+Xhsu0wSUjnajqi+Fe6ivrBCaFnbQMJc874/ZEkvp6VxLpZUTwrKPrXFiKeYyqK FJr1CI294yb4sUbC7CDr8WkXw+smGow+IFe9wOC5yqD4XGwzaCJIEHzhdPj2VsQlBrZn u2Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744107620; x=1744712420; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j9eheXrMshD0J5XzJ2mOaNomxGQPlMHtmpHgpZQ0nvc=; b=dvkBMQTmcIBdBgaX9QK9rUr9zvjPfjZeh1DFlpA1GFrXy8pfHEeKl1Kr+25i4W/Bl0 zPKpq6lBWqXcntaB41kiKLNdY9LyQBfAPvdEROLxWsD/O5Ep0GSw759PvQuZeuYIl3Gx GUH2+/M1tAxf0ThNMqN0Oj3yeyWe3SSkJTfh0W6VbQcfFGaYY5E1TEkF9DnbYSwcs3Pm FJmUvyTmKAKCh6VwXGK3U0cUeWX0eijZV5gj9Oa14F5kpxY9PHT8lJBRneRJMe2tGuda 7widyfBIHolctrVHi0YZcMNpLR9XqvyjGQcM26WzYvQqsB6bejLW07IItzkoajMX+eBc rdsg== X-Forwarded-Encrypted: i=1; AJvYcCXC6I/+vKzkpc3S45gtDwKDnZ9EXs14UjSiKh27lLLiGyHJ483E7p+ce462SySKJ/l9fj1W8xPfTaM9w6U=@vger.kernel.org X-Gm-Message-State: AOJu0YyVUBidJJw0ki1uoC4qH0pDW+/3V0pQlSegXf8ox3GLmGst5Bfo To3yq+ilw/iNgxAUn8b3OFXoBlfX9ioE8TWuyRjLmQ2F3fxVKtXIW38355eDxpw= X-Gm-Gg: ASbGncuhbl4nThJO1LHvs6qgj3ziKqtmQoEjykJ5OZsgyR7G4W5IkNc8ajovbvbpeQ9 87jeCtP73bFRToeZ7Pfhug5/9OcalbMN8DAQqzCWF7AHYvRBfphNbBLAIP6aDC24K4l7JMM7w5D n3mz/1lx3Hah06LZ2nnm6wTY7T9P++4alcpX2CNi0Ix9fAIs0T7nXIUBFuai+lcLn1Vqfrjtcgg FtYNM4lUoR3MkZBh+cIhwATyiZ3PkvxFkIO93biX1tvZzqIrnPBi6MmJG+uFwEVK/7IGvbA2ra0 +xOAk9M9nS6fl+vBoWxURG7iD1q+HkuxG7Lm9xsZuL51vqCZezthWK1HigORcveIHuwkocUO/Yu YzTFK1d8M0ePrBKTxiv/QKw== X-Google-Smtp-Source: AGHT+IH1dn/lIQfI3/RR+xyibwTynK6fakDPZSh/3lkCbbOZVJhtIhqx23aIAqsLFWaMCdqOV7Lz+A== X-Received: by 2002:a5d:6d87:0:b0:391:865:5a93 with SMTP id ffacd0b85a97d-39d820d2859mr2254662f8f.22.1744107620018; Tue, 08 Apr 2025 03:20:20 -0700 (PDT) Received: from [192.168.0.2] (host-87-15-70-119.retail.telecomitalia.it. [87.15.70.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39d7c6d838bsm4396138f8f.69.2025.04.08.03.20.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Apr 2025 03:20:19 -0700 (PDT) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 08 Apr 2025 12:18:55 +0200 Subject: [PATCH v4 5/5] iio: dac: ad3552r-hs: add support for internal ramp Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250408-wip-bl-ad3552r-fixes-v4-5-b33c0264bd78@baylibre.com> References: <20250408-wip-bl-ad3552r-fixes-v4-0-b33c0264bd78@baylibre.com> In-Reply-To: <20250408-wip-bl-ad3552r-fixes-v4-0-b33c0264bd78@baylibre.com> To: =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron , Lars-Peter Clausen , Jonathan Corbet , Olivier Moysan , Michael Hennerich Cc: linux-iio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6386; i=adureghello@baylibre.com; h=from:subject:message-id; bh=E2cwLHSNnDDaFAnFhmELZVQmtS+a6XU+agiX8UTiSa4=; b=owGbwMvMwCXGf3bn1e/btlsznlZLYkj/8kPo9f0ska+2gR+7Dc7br3vUdEOnovhiyNEa5amHn kkXpCUld5SyMIhxMciKKbLUJUaYhN4OlVJewDgbZg4rE8gQBi5OAZjIxVMM/90uSS8K+1Cd++CM tgn/86si3iW/MtLe1y4rCn6+7DDbTieG/0WeDvf/+XAWOl9+K/5ncTrrr2Onj8j28kr/lQsr+rL SkxUA X-Developer-Key: i=adureghello@baylibre.com; a=openpgp; fpr=703CDFAD8B573EB00850E38366D1CB9419AF3953 From: Angelo Dureghello The ad3552r can be feeded from the HDL controller by an internally generated 16bit ramp, useful for debug pourposes. Add debugfs a file to enable or disable it. Signed-off-by: Angelo Dureghello Reviewed-by: Nuno S=C3=A1 --- drivers/iio/dac/ad3552r-hs.c | 166 +++++++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 160 insertions(+), 6 deletions(-) diff --git a/drivers/iio/dac/ad3552r-hs.c b/drivers/iio/dac/ad3552r-hs.c index 37397e188f225a8099745ec03f7c604da76960b1..9a8eed7a06e4f2e7b23d59764b8= f2fc21e2c4537 100644 --- a/drivers/iio/dac/ad3552r-hs.c +++ b/drivers/iio/dac/ad3552r-hs.c @@ -7,6 +7,7 @@ */ =20 #include +#include #include #include #include @@ -54,6 +55,18 @@ struct ad3552r_hs_state { struct ad3552r_hs_platform_data *data; /* INTERFACE_CONFIG_D register cache, in DDR we cannot read values. */ u32 config_d; + /* Protects backend I/O operations from concurrent accesses. */ + struct mutex lock; +}; + +enum ad3552r_sources { + AD3552R_SRC_IIO_BUFFER, + AD3552R_SRC_BACKEND_RAMP_GEN, +}; + +static const char * const dbgfs_attr_source[] =3D { + [AD3552R_SRC_IIO_BUFFER] =3D "iio-buffer", + [AD3552R_SRC_BACKEND_RAMP_GEN] =3D "backend-ramp-generator", }; =20 static int ad3552r_hs_reg_read(struct ad3552r_hs_state *st, u32 reg, u32 *= val, @@ -65,6 +78,20 @@ static int ad3552r_hs_reg_read(struct ad3552r_hs_state *= st, u32 reg, u32 *val, return st->data->bus_reg_read(st->back, reg, val, xfer_size); } =20 +static int ad3552r_hs_set_data_source(struct ad3552r_hs_state *st, + enum iio_backend_data_source type) +{ + int i, ret; + + for (i =3D 0; i < st->model_data->num_hw_channels; ++i) { + ret =3D iio_backend_data_source_set(st->back, i, type); + if (ret) + return ret; + } + + return 0; +} + static int ad3552r_hs_update_reg_bits(struct ad3552r_hs_state *st, u32 reg, u32 mask, u32 val, size_t xfer_size) { @@ -483,6 +510,107 @@ static int ad3552r_hs_reg_access(struct iio_dev *indi= o_dev, unsigned int reg, return st->data->bus_reg_write(st->back, reg, writeval, 1); } =20 +static ssize_t ad3552r_hs_show_data_source(struct file *f, char __user *us= erbuf, + size_t count, loff_t *ppos) +{ + struct ad3552r_hs_state *st =3D file_inode(f)->i_private; + enum iio_backend_data_source type; + int idx, ret; + + guard(mutex)(&st->lock); + + ret =3D iio_backend_data_source_get(st->back, 0, &type); + if (ret) + return ret; + + switch (type) { + case IIO_BACKEND_INTERNAL_RAMP_16BIT: + idx =3D AD3552R_SRC_BACKEND_RAMP_GEN; + break; + case IIO_BACKEND_EXTERNAL: + idx =3D AD3552R_SRC_IIO_BUFFER; + break; + default: + return -EINVAL; + } + + return simple_read_from_buffer(userbuf, count, ppos, + dbgfs_attr_source[idx], + strlen(dbgfs_attr_source[idx])); +} + +static ssize_t ad3552r_hs_write_data_source(struct file *f, + const char __user *userbuf, + size_t count, loff_t *ppos) +{ + struct ad3552r_hs_state *st =3D file_inode(f)->i_private; + char buf[64]; + int ret, source; + + guard(mutex)(&st->lock); + + ret =3D simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, userbuf, + count); + if (ret < 0) + return ret; + + buf[count] =3D '\0'; + + ret =3D match_string(dbgfs_attr_source, ARRAY_SIZE(dbgfs_attr_source), + buf); + if (ret < 0) + return ret; + + switch (ret) { + case AD3552R_SRC_BACKEND_RAMP_GEN: + source =3D IIO_BACKEND_INTERNAL_RAMP_16BIT; + break; + case AD3552R_SRC_IIO_BUFFER: + source =3D IIO_BACKEND_EXTERNAL; + break; + default: + return -EINVAL; + } + + ret =3D ad3552r_hs_set_data_source(st, source); + if (ret) + return ret; + + return count; +} + +static ssize_t ad3552r_hs_show_data_source_avail(struct file *f, + char __user *userbuf, + size_t count, loff_t *ppos) +{ + ssize_t len =3D 0; + char *buf; + int i; + + buf =3D kmalloc(PAGE_SIZE, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + for (i =3D 0; i < ARRAY_SIZE(dbgfs_attr_source); i++) { + len +=3D scnprintf(buf + len, PAGE_SIZE - len, "%s ", + dbgfs_attr_source[i]); + } + buf[len - 1] =3D '\n'; + + return simple_read_from_buffer(userbuf, count, ppos, buf, len); +} + +static const struct file_operations ad3552r_hs_data_source_fops =3D { + .owner =3D THIS_MODULE, + .write =3D ad3552r_hs_write_data_source, + .read =3D ad3552r_hs_show_data_source, +}; + +static const struct file_operations ad3552r_hs_data_source_avail_fops =3D { + .owner =3D THIS_MODULE, + .read =3D ad3552r_hs_show_data_source_avail, +}; + static int ad3552r_hs_setup(struct ad3552r_hs_state *st) { u16 id; @@ -550,11 +678,7 @@ static int ad3552r_hs_setup(struct ad3552r_hs_state *s= t) if (ret) return ret; =20 - ret =3D iio_backend_data_source_set(st->back, 0, IIO_BACKEND_EXTERNAL); - if (ret) - return ret; - - ret =3D iio_backend_data_source_set(st->back, 1, IIO_BACKEND_EXTERNAL); + ret =3D ad3552r_hs_set_data_source(st, IIO_BACKEND_EXTERNAL); if (ret) return ret; =20 @@ -661,6 +785,26 @@ static const struct iio_info ad3552r_hs_info =3D { .debugfs_reg_access =3D &ad3552r_hs_reg_access, }; =20 +static void ad3552r_hs_debugfs_init(struct iio_dev *indio_dev) +{ + struct ad3552r_hs_state *st =3D iio_priv(indio_dev); + struct dentry *d =3D iio_get_debugfs_dentry(indio_dev); + + if (!IS_ENABLED(CONFIG_DEBUG_FS)) + return; + + d =3D iio_get_debugfs_dentry(indio_dev); + if (!d) { + dev_warn(st->dev, "can't set debugfs in driver dir\n"); + return; + } + + debugfs_create_file("data_source", 0600, d, st, + &ad3552r_hs_data_source_fops); + debugfs_create_file("data_source_available", 0600, d, st, + &ad3552r_hs_data_source_avail_fops); +} + static int ad3552r_hs_probe(struct platform_device *pdev) { struct ad3552r_hs_state *st; @@ -705,7 +849,17 @@ static int ad3552r_hs_probe(struct platform_device *pd= ev) if (ret) return ret; =20 - return devm_iio_device_register(&pdev->dev, indio_dev); + ret =3D devm_iio_device_register(&pdev->dev, indio_dev); + if (ret) + return ret; + + ret =3D devm_mutex_init(&pdev->dev, &st->lock); + if (ret) + return ret; + + ad3552r_hs_debugfs_init(indio_dev); + + return ret; } =20 static const struct of_device_id ad3552r_hs_of_id[] =3D { --=20 2.49.0