linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dharma Balasubiramani <dharma.b@microchip.com>
To: Kamel Bouhara <kamel.bouhara@bootlin.com>,
	William Breathitt Gray <wbg@kernel.org>,
	Nicolas Ferre <nicolas.ferre@microchip.com>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	Claudiu Beznea <claudiu.beznea@tuxon.dev>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Dharma Balasubiramani <dharma.b@microchip.com>
Subject: [PATCH 1/2] counter: microchip-tcb-capture: Retrieve and map parent base address
Date: Wed, 28 May 2025 11:43:04 +0530	[thread overview]
Message-ID: <20250528-mchp-tcb-dma-v1-1-083a41fb7b51@microchip.com> (raw)
In-Reply-To: <20250528-mchp-tcb-dma-v1-0-083a41fb7b51@microchip.com>

Retrieve the parent TCB controller's platform_device and map its MMIO
region using devm_ioremap_resource(). This allows direct register access
through a base address, which is required for features like DMA that need
physical addresses.

Signed-off-by: Dharma Balasubiramani <dharma.b@microchip.com>
---
 drivers/counter/microchip-tcb-capture.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/counter/microchip-tcb-capture.c b/drivers/counter/microchip-tcb-capture.c
index 1a299d1f350b..9634da75bd1a 100644
--- a/drivers/counter/microchip-tcb-capture.c
+++ b/drivers/counter/microchip-tcb-capture.c
@@ -12,6 +12,7 @@
 #include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/of_irq.h>
+#include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <uapi/linux/counter/microchip-tcb-capture.h>
@@ -29,7 +30,9 @@
 
 struct mchp_tc_data {
 	const struct atmel_tcb_config *tc_cfg;
+	struct platform_device *pdev;
 	struct regmap *regmap;
+	void __iomem *base;
 	int qdec_mode;
 	int num_channels;
 	int channel[2];
@@ -479,6 +482,8 @@ static int mchp_tc_probe(struct platform_device *pdev)
 	const struct atmel_tcb_config *tcb_config;
 	const struct of_device_id *match;
 	struct counter_device *counter;
+	struct platform_device *parent_pdev;
+	struct resource *parent_res;
 	struct mchp_tc_data *priv;
 	char clk_name[7];
 	struct regmap *regmap;
@@ -491,6 +496,18 @@ static int mchp_tc_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	priv = counter_priv(counter);
 
+	parent_pdev = of_find_device_by_node(np->parent);
+	if (!parent_pdev)
+		return -EPROBE_DEFER;
+
+	parent_res = platform_get_resource(parent_pdev, IORESOURCE_MEM, 0);
+	if (!parent_res)
+		return -EINVAL;
+
+	priv->base = devm_ioremap_resource(&parent_pdev->dev, parent_res);
+	if (IS_ERR(priv->base))
+		return PTR_ERR(priv->base);
+
 	match = of_match_node(atmel_tc_of_match, np->parent);
 	tcb_config = match->data;
 	if (!tcb_config) {
@@ -563,6 +580,7 @@ static int mchp_tc_probe(struct platform_device *pdev)
 
 	priv->tc_cfg = tcb_config;
 	priv->regmap = regmap;
+	priv->pdev = pdev;
 	counter->name = dev_name(&pdev->dev);
 	counter->parent = &pdev->dev;
 	counter->ops = &mchp_tc_ops;

-- 
2.43.0


  reply	other threads:[~2025-05-28  6:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-28  6:13 [PATCH 0/2] TCB: Add DMA support to read the capture register AB Dharma Balasubiramani
2025-05-28  6:13 ` Dharma Balasubiramani [this message]
2025-05-28  6:13 ` [PATCH 2/2] counter: microchip-tcb-capture: Add DMA support for TC_RAB register reads Dharma Balasubiramani
2025-05-29  9:21   ` kernel test robot
2025-05-29 15:33   ` David Lechner
2025-06-04  6:15     ` Dharma.B
2025-06-04 13:21       ` David Lechner
2025-05-29 15:26 ` [PATCH 0/2] TCB: Add DMA support to read the capture register AB David Lechner
2025-06-04  6:17   ` Dharma.B

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250528-mchp-tcb-dma-v1-1-083a41fb7b51@microchip.com \
    --to=dharma.b@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=kamel.bouhara@bootlin.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=wbg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).