linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Michael Walle <michael@walle.cc>
To: Lee Jones <lee.jones@linaro.org>
Cc: devicetree@vger.kernel.org, arnd@arndb.de,
	gregkh@linuxfoundation.org, linus.walleij@linaro.org,
	linux-kernel@vger.kernel.org, robh+dt@kernel.org,
	Wolfram Sang <wsa@kernel.org>,
	bgolaszewski@baylibre.com, broonie@kernel.org,
	andriy.shevchenko@linux.intel.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 1/1] mfd: Add I2C based System Configuaration (SYSCON) access
Date: Thu, 02 Jul 2020 11:12:56 +0200	[thread overview]
Message-ID: <58ae64ebf22707ad1725987615b355c2@walle.cc> (raw)
In-Reply-To: <20200702081825.GR1179328@dell>

Am 2020-07-02 10:18, schrieb Lee Jones:
> On Thu, 02 Jul 2020, Michael Walle wrote:
> 
>> Am 2020-07-02 08:54, schrieb Lee Jones:
>> > On Wed, 01 Jul 2020, Michael Walle wrote:
>> >
>> > > Am 2020-07-01 09:04, schrieb Lee Jones:
>> > > > On Wed, 01 Jul 2020, Michael Walle wrote:
>> > > >
>> > > > > Hi Lee,
>> > > > >
>> > > > > Am 2020-06-30 11:16, schrieb Michael Walle:
>> > > > > > I'm just trying to use this for my sl28 driver. Some remarks, see below.
>> > > > > >
>> > > > > > Am 2020-06-22 09:51, schrieb Lee Jones:
>> > > > > > > The existing SYSCON implementation only supports MMIO (memory mapped)
>> > > > > > > accesses, facilitated by Regmap.  This extends support for registers
>> > > > > > > held behind I2C busses.
>> > > > > > >
>> > > > > > > Signed-off-by: Lee Jones <lee.jones@linaro.org>
>> > > > > > > ---
>> > > > > > > Changelog:
>> > > > > > >
>> > > > > > > v3 => v4
>> > > > > > >   - Add ability to provide a non-default Regmap configuration
>> > > > > > >
>> > > > > > > v2 => v3
>> > > > > > >   - Change 'is CONFIG' present check to include loadable modules
>> > > > > > >     - s/#ifdef CONFIG_MFD_SYSCON_I2C/#if
>> > > > > > > IS_ENABLED(CONFIG_MFD_SYSCON_I2C)/
>> > > > > > >
>> > > > > > > v1 => v2
>> > > > > > >   - Remove legacy references to OF
>> > > > > > >   - Allow building as a module (fixes h8300 0-day issue)
>> > > > > > >
>> > > > > > > drivers/mfd/Kconfig            |   7 +++
>> > > > > > >  drivers/mfd/Makefile           |   1 +
>> > > > > > >  drivers/mfd/syscon-i2c.c       | 104
>> > > > > > > +++++++++++++++++++++++++++++++++
>> > > > > > >  include/linux/mfd/syscon-i2c.h |  36 ++++++++++++
>> > > > > > >  4 files changed, 148 insertions(+)
>> > > > > > >  create mode 100644 drivers/mfd/syscon-i2c.c
>> > > > > > >  create mode 100644 include/linux/mfd/syscon-i2c.h
>> >
>> > [...]
>> >
>> > > > > > This way, (a) a driver doesn't have to use "#include <linux/i2c.h>" just
>> > > > > > to call to_i2c_client() (or i2c_verify_client()) and (b) you won't do it
>> > > > > > all over again in all sub drivers.
>> > > > > >
>> > > > > > So you could just do a
>> > > > > >   regmap = syscon_i2c_to_regmap(pdev->dev.parent);
>> > > > > >
>> > > > > > I've also noticed that the mmio syscon uses device_node as parameter.
>> > > > > > What
>> > > > > > was the reason to divert from that? Just curious.
>> > > > >
>> > > > > How is this supposed to be used?
>> > > > >
>> > > > > I had something like the following in mind:
>> > > > >
>> > > > > &i2c {
>> > > > >   cpld@4a {
>> > > > >     compatible = "simple-mfd";
>> > > > >     reg = <0x4a>;
>> > > > >
>> > > > >     gpio@4 {
>> > > > >       compatible = "vendor,gpio";
>> > > > >       reg = <0x4>;
>> > > > >     };
>> > > > >   };
>> > > > > };
>> > > >
>> > > > Yes, that was the idea.
>> > > >
>> > > > > But I think the childen are not enumerated if its an I2C device. And
>> > > > > the actual i2c driver is also missing.
>> > > >
>> > > > What do you mean?  Can you elaborate?
>> > >
>> > > There is no i2c_driver instance who would create the regmap.
>> >
>> > The regmap is created by the first caller of:
>> >
>> >  syscon_i2c_to_regmap{_config}()
>> 
>> But which one is an i2c_driver? All the sub devices are platform 
>> drivers
>> and there should be no need for them to know that they are behind an
>> i2c driver (or spi driver or just mmio). All they have to know is how
>> to access the registers.
>> 
>> > > If I'm
>> > > reading the I2C code correctly, it won't probe any i2c device of a
>> > > bus if there is no i2c_driver with an associated .probe() or
>> > > .probe_new().
>> >
>> > Why wouldn't the children be registered using i2c_driver?
>> 
>> Where is the code which enumerates the children?
> 
> Yes, I see the problem now.  So I2C devices depend on a device
> registering with the i2c_driver framework, which then probes the
> device accordingly.  Thus a physical driver is required to convert I2C
> devices to platform devices.  So this stops being an MFD problem and
> starts being a 'simple-i2c' issue. :)

Yes, but this is still MFD specifc, because no other normal (in lack of
a better word, think of one-function-devices) I2C device has sub-nodes.
Thus my proposal for that simple-mfd-i2c driver. And keep in mind that
this likely isn't specific to I2C but also to SPI (without having
looked at it). So in theory that simple-mfd-i2c, could also register
a spi_driver which then registers an SPI regmap and enumerates the
children. So this is not only an I2C topic, but IMHO still MFD.

-michael

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-07-02  9:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200622075145.1464020-1-lee.jones@linaro.org>
2020-06-30  9:16 ` [PATCH v4 1/1] mfd: Add I2C based System Configuaration (SYSCON) access Michael Walle
2020-06-30 22:32   ` Michael Walle
2020-07-01  7:04     ` Lee Jones
2020-07-01 21:01       ` Michael Walle
2020-07-02  6:54         ` Lee Jones
2020-07-02  7:02           ` Michael Walle
2020-07-02  8:18             ` Lee Jones
2020-07-02  9:12               ` Michael Walle [this message]
2020-07-02  7:14   ` Lee Jones
2020-07-02  7:21     ` Michael Walle
2020-07-05 13:10 ` kernel test robot

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=58ae64ebf22707ad1725987615b355c2@walle.cc \
    --to=michael@walle.cc \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=bgolaszewski@baylibre.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=wsa@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).