From patchwork Tue Aug 6 13:35:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 13754881 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 AD45C1D27A4 for ; Tue, 6 Aug 2024 13:35:07 +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=1722951307; cv=none; b=lXNtfGEhv/ltnpdq2DqSrRZPAz+DuezYIPrnQpF0oLYbCQXsfKHt91aCxWr2LoCqjFbstIsdQPs3vfd+c/jzOBbEZ5QHd8eKnHRUpAM5fhfD+35wbColMNXwbgpFPMndTzrBFuuGHyAOTX4yiw5USgCFVf0TSW/klL6AxRLtBHg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722951307; c=relaxed/simple; bh=8SypoNiLFSu62aShOWnLsR4i8ZjNvFo3W5/Z+1+KZkI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EJIQnwvydhQet+kM9EEXWPLmUtKymMJzhiuNj+w9431w/hAnO/fPfdT4XtNyIQMDpxajJxqheTDlPxOUIk2QXBODt0FK846Fh+YnTgigGBg/JLOGzI16NAXwCX085itX9BlPcqPlk1uwtiU8nPV9ts86/qmZwUv2UdnUda4nJ8o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jlQtzQrn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jlQtzQrn" Received: by smtp.kernel.org (Postfix) with ESMTPS id 51824C4AF09; Tue, 6 Aug 2024 13:35:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722951307; bh=8SypoNiLFSu62aShOWnLsR4i8ZjNvFo3W5/Z+1+KZkI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jlQtzQrn6oMTyMkNAuOO9P7iWh3iF5gnQcRybuyPVB8AmWzTIPHSAQeH+lpNpqCcf SsIx3dE39vrgR8IBrEnOgsboxMGtZONqGeVNuZ6zjVhyqt1e1cfWATATsSLGORKhs0 CrOFMl4dOmh3N/d0gszmlXc+E5dnAnr/k9uAxdK4oj6oIsq11fLheyrjJoRxlRzCcd nGxIWIQdebcgtb4S8n/uHUlMr43AxopHRs9/cvdPL60LpC+Y96XA3WKVBFJRCetpCm pTpnYbG10DfLx+u191J2wmzuz/wNOQQYMIdAH/OT0z167isYoEhBg5hqhnLweCRUZG QeCDagTmv/VPw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49D06C3DA64; Tue, 6 Aug 2024 13:35:07 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Tue, 06 Aug 2024 15:35:06 +0200 Subject: [PATCH 1/2] iio: dac: adi-axi-dac: support debugfs direct_reg_access Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-dev-backend-dac-direct-reg-access-v1-1-b84a6e8ee8a0@analog.com> References: <20240806-dev-backend-dac-direct-reg-access-v1-0-b84a6e8ee8a0@analog.com> In-Reply-To: <20240806-dev-backend-dac-direct-reg-access-v1-0-b84a6e8ee8a0@analog.com> To: linux-iio@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Dragos Bogdan X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722951306; l=1361; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=70Psr3VQuqq94rjCoV8WjU8cuWr16U1+KQK+zWEHn9Q=; b=ie12noL1qXL6arhMwxrBoobBneNtNwBnKN+DjS9lTltlbrETvPkfDxfdlhTIRMH17epJ+PF5E MhQ57UpZhvaD+z9UYp/a36QAzezqyMBTLZ5EFKOwxWWXKgJv5t+ERi4 X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa Reply-To: nuno.sa@analog.com From: Nuno Sa Make it possible to read/write registers on the backend using the debugfs interface for it. Signed-off-by: Nuno Sa --- drivers/iio/dac/adi-axi-dac.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c index 9655705b158b..0cb00f3bec04 100644 --- a/drivers/iio/dac/adi-axi-dac.c +++ b/drivers/iio/dac/adi-axi-dac.c @@ -507,6 +507,17 @@ static int axi_dac_set_sample_rate(struct iio_backend *back, unsigned int chan, return 0; } +static int axi_dac_reg_access(struct iio_backend *back, unsigned int reg, + unsigned int writeval, unsigned int *readval) +{ + struct axi_dac_state *st = iio_backend_get_priv(back); + + if (readval) + return regmap_read(st->regmap, reg, readval); + + return regmap_write(st->regmap, reg, writeval); +} + static const struct iio_backend_ops axi_dac_generic_ops = { .enable = axi_dac_enable, .disable = axi_dac_disable, @@ -517,6 +528,7 @@ static const struct iio_backend_ops axi_dac_generic_ops = { .ext_info_get = axi_dac_ext_info_get, .data_source_set = axi_dac_data_source_set, .set_sample_rate = axi_dac_set_sample_rate, + .debugfs_reg_access = iio_backend_debugfs_ptr(axi_dac_reg_access), }; static const struct iio_backend_info axi_dac_generic = { From patchwork Tue Aug 6 13:35:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 13754883 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 AD3B01D2780 for ; Tue, 6 Aug 2024 13:35:07 +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=1722951307; cv=none; b=a2j4hZOHgpWJOZKHbtxjGPmfwiI4HE3YXRcQG01X++KODQ80ZzcU79NV2nCE7FWNwR6+12yUSq3aX9SHrMO1vuawEXMInRQlDK7qcH6mM/eHctG3f1fmaahc1SGxxe3aqP8aWFcBUJt4eq0dplQpIxw/d+7g9SOcN/WQtHy4/Hw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722951307; c=relaxed/simple; bh=t4ah0loUiZWAAYLrMq+MTbcEChyKjxhG/C/+7uCku7M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PfjjjHGoub1JMDN8wMTnjXbJ7sXC0NYcJi7LXjmx4KSGJsg7MIiOjFxW37p8wa03SApjRGU8hk64E8gbK+DXIU1xDWH5oLgT1sR0f3+4cmW8EzWiZzz8iq2KG5NgDFo2U2/Xq8qZS+JpVrOYIM5VNZl9ctVuoyho/rq5/bfGNnQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R0YGygFS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="R0YGygFS" Received: by smtp.kernel.org (Postfix) with ESMTPS id 67576C4AF11; Tue, 6 Aug 2024 13:35:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722951307; bh=t4ah0loUiZWAAYLrMq+MTbcEChyKjxhG/C/+7uCku7M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=R0YGygFSrzcGQSDbo0+IiY/1zjovu6WCGVT/61/MWUsgODeMgiNrh3AksDBNKK3j1 92a5oFLNZXg99u3PnpRbH6s1+nV6n7UbMWTsWyyCPKTgiHU8+50FdR7Du9K3hhyyZk YUEjq7rBhWIf5M14pOyLxNeL/AdTqjv6xXKmREs5ZWLeYqoXvVLLwydnxLVbLQX4TT DO2HifhfqraEr/bNBVPMQ6T/aj1v9hZYuepDD13FWek00ILPBnAswMmBxHcjwWR92m eQYKOdx9Pd319emKq3HU8TMRGfJgefEXjrpesqf2mEjqelLmEywrMhKfbi3tPDAtc2 qej/cNhr3j0/A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FDB7C49EA1; Tue, 6 Aug 2024 13:35:07 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Tue, 06 Aug 2024 15:35:07 +0200 Subject: [PATCH 2/2] iio: dac: ad9739a: add backend debugfs interface Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-dev-backend-dac-direct-reg-access-v1-2-b84a6e8ee8a0@analog.com> References: <20240806-dev-backend-dac-direct-reg-access-v1-0-b84a6e8ee8a0@analog.com> In-Reply-To: <20240806-dev-backend-dac-direct-reg-access-v1-0-b84a6e8ee8a0@analog.com> To: linux-iio@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Dragos Bogdan X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722951306; l=880; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=2tJLx9S3feK5aLP/bucGasBHK5sb0LjFdbnPk10uUfM=; b=1Xt2FwsLAKMhNBmQTfuH8OBmjzDVq/oNfTzyD24A55S4nHKWDODYFKG7A/MgG4gka7vBU+FRs aQ4BJbvw+LiC9clKHAlhieSFb3Ng4iZt2z6TXuiSF5+2F+a2obwGnJA X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa Reply-To: nuno.sa@analog.com From: Nuno Sa Call iio_backend_debugfs_add() to add (if available) the backend debug interface. Signed-off-by: Nuno Sa --- drivers/iio/dac/ad9739a.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/iio/dac/ad9739a.c b/drivers/iio/dac/ad9739a.c index 799387f21b9f..615d1a196db3 100644 --- a/drivers/iio/dac/ad9739a.c +++ b/drivers/iio/dac/ad9739a.c @@ -431,7 +431,13 @@ static int ad9739a_probe(struct spi_device *spi) indio_dev->num_channels = ARRAY_SIZE(ad9739a_channels); indio_dev->setup_ops = &ad9739a_buffer_setup_ops; - return devm_iio_device_register(&spi->dev, indio_dev); + ret = devm_iio_device_register(&spi->dev, indio_dev); + if (ret) + return ret; + + iio_backend_debugfs_add(st->back, indio_dev); + + return 0; } static const struct of_device_id ad9739a_of_match[] = {