mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xu Yilun <yilun.xu@intel.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	trix@redhat.com, hao.wu@intel.com,
	matthew.gerlach@linux.intel.com, russell.h.weight@intel.com,
	yilun.xu@intel.com
Subject: Re: [PATCH 4/6] spi: altera: use regmap instead of direct mmio register access
Date: Fri, 12 Jun 2020 12:43:46 +0800	[thread overview]
Message-ID: <20200612044346.GC21214@yilunxu-OptiPlex-7050> (raw)
In-Reply-To: <20200611110211.GD4671@sirena.org.uk>

On Thu, Jun 11, 2020 at 12:02:11PM +0100, Mark Brown wrote:
> On Thu, Jun 11, 2020 at 11:25:09AM +0800, Xu Yilun wrote:
> 
> > +	if (pdata && pdata->use_parent_regmap) {
> > +		hw->regmap = dev_get_regmap(pdev->dev.parent, NULL);
> > +		if (!hw->regmap) {
> > +			dev_err(&pdev->dev, "get regmap failed\n");
> > +			goto exit;
> > +		}
> > +		hw->base = pdata->regoff;
> 
> This seems very confused - there's some abstraction problem here.  This
> looks like the driver should know about whatever is causing it to use
> the parent regmap, it shouldn't just be "use the parent regmap" directly
> since that is too much of an implementation detail.  This new feature

Our usecase is that, we have the PCIE card which integrates this
spi-altera soft IP. So It seems reasonable we reuse this driver. But the
IP registers are not directly accessed by MMIO. It is accessed via an
indirect access interfaces, SW need to operate on the indirect access
interfaces to RW the spi-altera registers. like the following:

+------+   +------------+   +------------+
| PCIE |---| indirect   |---| spi-altera |
+------+   | access     |   +------------+
           | interfaces |
           +------------+
           | SPI params |
           +------------+

So we think of creating regmap to abstract the actually register accessing
detail. The parent device driver creates the regmap of indirect access,
and it creates the spi-altera platform device as child. Spi-altera
driver could just get the regmap from parent, don't have to care about
the indirect access detail.

It seems your concern is how to gracefully let spi-altera driver get the
regmap. or not using it. Since our platform doesn't enable device tree
support, seems the only way to talk to platform device is the
platform_data.

Do you have any suggestion on that?


I think the driver may need to figure out the role of the device in
system, whether it is a subdev of other device (like MFD? Many mfd subdev
driver will get parent regmap by default), or it is an independent mmio
device. But I'm not sure how to do it in right way.

> also seems like a separate change which should be in a separate patch,
> the changelog only talked about converting to use regmap which I'd have
> expected to be a straight 1:1 replacement of non-regmap stuff with
> regmap stuff.

Understood. I should make a patch to do 1:1 replacement of regmap first,
then a second patch to handle the parent regmap.



  reply	other threads:[~2020-06-12  4:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11  3:25 [PATCH 0/6] Add more configuration and regmap support for spi-altera Xu Yilun
2020-06-11  3:25 ` [PATCH 1/6] spi: altera: add 32bit data width transfer support Xu Yilun
2020-06-11  3:25 ` [PATCH 2/6] spi: altera: add SPI core parameters support via platform data Xu Yilun
2020-06-11  3:25 ` [PATCH 3/6] spi: altera: add platform data for slave information Xu Yilun
2020-06-11  3:25 ` [PATCH 4/6] spi: altera: use regmap instead of direct mmio register access Xu Yilun
2020-06-11 11:02   ` Mark Brown
2020-06-12  4:43     ` Xu Yilun [this message]
2020-06-12 11:52       ` Mark Brown
2020-06-12 12:31         ` Xu Yilun
2020-06-11  3:25 ` [PATCH 5/6] spi: altera: move driver name string to header file Xu Yilun
2020-06-11 14:03   ` Mark Brown
2020-06-12  3:14     ` Xu Yilun
2020-06-11  3:25 ` [PATCH 6/6] spi: altera: fix size mismatch on 64 bit processors Xu Yilun
2020-06-11 11:04   ` Mark Brown
2020-06-12  3:39     ` Xu Yilun
2020-06-11 12:56 ` [PATCH 0/6] Add more configuration and regmap support for spi-altera Tom Rix
2020-06-15 23:41 ` Mark Brown

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=20200612044346.GC21214@yilunxu-OptiPlex-7050 \
    --to=yilun.xu@intel.com \
    --cc=broonie@kernel.org \
    --cc=hao.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=matthew.gerlach@linux.intel.com \
    --cc=russell.h.weight@intel.com \
    --cc=trix@redhat.com \
    /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

all inboxes | Powered by JetHome®