From: Lee Jones <lee.jones@linaro.org>
To: Michael Walle <michael@walle.cc>
Cc: devicetree@vger.kernel.org, arnd@arndb.de,
gregkh@linuxfoundation.org, linus.walleij@linaro.org,
linux-kernel@vger.kernel.org, robh+dt@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, 2 Jul 2020 08:14:02 +0100 [thread overview]
Message-ID: <20200702071402.GP1179328@dell> (raw)
In-Reply-To: <e436fd60bf0ebb6d72a76034d0fc35de@walle.cc>
On Tue, 30 Jun 2020, Michael Walle wrote:
> Hi Lee,
>
> 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
> >
>
> [..]
>
> > +static struct regmap *syscon_i2c_get_regmap(struct i2c_client *client,
> > + struct regmap_config *regmap_config)
> > +{
> > + struct device *dev = &client->dev;
> > + struct syscon *entry, *syscon = NULL;
> > +
> > + spin_lock(&syscon_i2c_list_slock);
> > +
> > + list_for_each_entry(entry, &syscon_i2c_list, list)
> > + if (entry->dev == dev) {
> > + syscon = entry;
> > + break;
> > + }
> > +
> > + spin_unlock(&syscon_i2c_list_slock);
> > +
> > + if (!syscon)
> > + syscon = syscon_i2c_register(client, regmap_config);
> > +
> > + if (IS_ERR(syscon))
> > + return ERR_CAST(syscon);
> > +
> > + return syscon->regmap;
> > +}
> > +
> > +struct regmap *syscon_i2c_to_regmap_config(struct i2c_client *client,
> > + struct regmap_config *regmap_config)
> > +{
> > + return syscon_i2c_get_regmap(client, regmap_config);
> > +}
> > +EXPORT_SYMBOL_GPL(syscon_i2c_to_regmap_config);
> > +
> > +struct regmap *syscon_i2c_to_regmap(struct i2c_client *client)
> > +{
> > + return syscon_i2c_get_regmap(client, &syscon_i2c_regmap_config);
> > +}
> > +EXPORT_SYMBOL_GPL(syscon_i2c_to_regmap);
>
> What do you think about
>
> struct regmap *syscon_i2c_to_regmap(struct device *dev)
> {
> struct i2c_client *client = i2c_verify_client(dev);
>
> if (!client)
> return ERR_PTR(-EINVAL);
>
> return syscon_i2c_get_regmap(client, &syscon_i2c_regmap_config);
> }
>
> Or even move it to syscon_i2c_get_regmap().
>
> 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.
What is your use-case? This is set-up for based I2C drivers to call
into. 'client' is given to them as their .probe() arg.
> 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.
This is a helper for I2C clients. There aren't any OF helpers in here
(yet). If you think they would be helpful we can add them. How do
you see them being used?
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee.jones@linaro.org>
To: Michael Walle <michael@walle.cc>
Cc: robh+dt@kernel.org, broonie@kernel.org,
gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com,
devicetree@vger.kernel.org, linus.walleij@linaro.org,
bgolaszewski@baylibre.com, arnd@arndb.de,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/1] mfd: Add I2C based System Configuaration (SYSCON) access
Date: Thu, 2 Jul 2020 08:14:02 +0100 [thread overview]
Message-ID: <20200702071402.GP1179328@dell> (raw)
In-Reply-To: <e436fd60bf0ebb6d72a76034d0fc35de@walle.cc>
On Tue, 30 Jun 2020, Michael Walle wrote:
> Hi Lee,
>
> 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
> >
>
> [..]
>
> > +static struct regmap *syscon_i2c_get_regmap(struct i2c_client *client,
> > + struct regmap_config *regmap_config)
> > +{
> > + struct device *dev = &client->dev;
> > + struct syscon *entry, *syscon = NULL;
> > +
> > + spin_lock(&syscon_i2c_list_slock);
> > +
> > + list_for_each_entry(entry, &syscon_i2c_list, list)
> > + if (entry->dev == dev) {
> > + syscon = entry;
> > + break;
> > + }
> > +
> > + spin_unlock(&syscon_i2c_list_slock);
> > +
> > + if (!syscon)
> > + syscon = syscon_i2c_register(client, regmap_config);
> > +
> > + if (IS_ERR(syscon))
> > + return ERR_CAST(syscon);
> > +
> > + return syscon->regmap;
> > +}
> > +
> > +struct regmap *syscon_i2c_to_regmap_config(struct i2c_client *client,
> > + struct regmap_config *regmap_config)
> > +{
> > + return syscon_i2c_get_regmap(client, regmap_config);
> > +}
> > +EXPORT_SYMBOL_GPL(syscon_i2c_to_regmap_config);
> > +
> > +struct regmap *syscon_i2c_to_regmap(struct i2c_client *client)
> > +{
> > + return syscon_i2c_get_regmap(client, &syscon_i2c_regmap_config);
> > +}
> > +EXPORT_SYMBOL_GPL(syscon_i2c_to_regmap);
>
> What do you think about
>
> struct regmap *syscon_i2c_to_regmap(struct device *dev)
> {
> struct i2c_client *client = i2c_verify_client(dev);
>
> if (!client)
> return ERR_PTR(-EINVAL);
>
> return syscon_i2c_get_regmap(client, &syscon_i2c_regmap_config);
> }
>
> Or even move it to syscon_i2c_get_regmap().
>
> 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.
What is your use-case? This is set-up for based I2C drivers to call
into. 'client' is given to them as their .probe() arg.
> 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.
This is a helper for I2C clients. There aren't any OF helpers in here
(yet). If you think they would be helpful we can add them. How do
you see them being used?
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
next prev parent reply other threads:[~2020-07-02 7:15 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-22 7:51 [PATCH v4 1/1] mfd: Add I2C based System Configuaration (SYSCON) access Lee Jones
2020-06-30 9:16 ` Michael Walle
2020-06-30 9:16 ` Michael Walle
2020-06-30 22:32 ` Michael Walle
2020-06-30 22:32 ` Michael Walle
2020-07-01 7:04 ` Lee Jones
2020-07-01 7:04 ` Lee Jones
2020-07-01 21:01 ` Michael Walle
2020-07-01 21:01 ` Michael Walle
2020-07-02 6:54 ` Lee Jones
2020-07-02 6:54 ` Lee Jones
2020-07-02 7:02 ` Michael Walle
2020-07-02 7:02 ` Michael Walle
2020-07-02 8:18 ` Lee Jones
2020-07-02 8:18 ` Lee Jones
2020-07-02 9:12 ` Michael Walle
2020-07-02 9:12 ` Michael Walle
2020-07-02 7:14 ` Lee Jones [this message]
2020-07-02 7:14 ` Lee Jones
2020-07-02 7:21 ` Michael Walle
2020-07-02 7:21 ` Michael Walle
2020-07-05 13:10 ` kernel test robot
2020-07-05 13:10 ` kernel test robot
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=20200702071402.GP1179328@dell \
--to=lee.jones@linaro.org \
--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=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@walle.cc \
--cc=robh+dt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.