From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Joe Perches <joe@perches.com>, Rob Herring <robh+dt@kernel.org>
Cc: Wolfram Sang <wsa@the-dreams.de>,
linux-i2c@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
linux-doc@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Arnd Bergmann <arnd@arndb.de>,
Przemyslaw Sroka <psroka@cadence.com>,
Arkadiusz Golec <agolec@cadence.com>,
Alan Douglas <adouglas@cadence.com>,
Bartosz Folta <bfolta@cadence.com>, Damian Kos <dkos@cadence.com>,
Alicja Jurasik-Urbaniak <alicja@cadence.com>,
Cyprian Wronka <cwronka@cadence.com>,
Suresh Punnoose <sureshp@cadence.com>,
Rafal Ciepiela <rafalc@cadence.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Nishanth Menon <nm@ti.com>, Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Kumar Gala <galak@codeaurora.org>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Vitor Soares <Vitor.Soares@synopsys.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Linus Walleij <linus.walleij@linaro.org>,
Xiang Lin <Xiang.Lin@synaptics.com>,
linux-gpio@vger.kernel.org, Sekhar Nori <nsekhar@ti.com>,
Przemyslaw Gaj <pgaj@cadence.com>, Peter Rosin <peda@axentia.se>,
Mike Shettel <mshettel@codeaurora.org>,
Stephen Boyd <swboyd@chromium.org>
Subject: Re: [PATCH v8 05/10] dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg property
Date: Wed, 3 Oct 2018 21:06:13 +0200 [thread overview]
Message-ID: <20181003210613.27d180c7@bbrezillon> (raw)
In-Reply-To: <20181003205953.426021bb@bbrezillon>
On Wed, 3 Oct 2018 20:59:53 +0200
Boris Brezillon <boris.brezillon@bootlin.com> wrote:
> On Wed, 03 Oct 2018 11:37:17 -0700
> Joe Perches <joe@perches.com> wrote:
>
> > On Wed, 2018-10-03 at 15:22 +0200, Boris Brezillon wrote:
> > > The reg property of devices connected to an I3C bus have 3 cells, and
> > > filling them manually is not trivial. Provides macros to help doing
> > > that.
> >
> > This patch logic seems excessively fragile.
>
> Keep in mind that this header is meant to be include by .dts(i) files,
> not regular .c files.
>
> >
> > > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> > > Reviewed-by: Rob Herring <robh@kernel.org>
> > > ---
> > > Changes in v8:
> > > - None
> > >
> > > Changes in v5:
> > > - none
> > > ---
> > > include/dt-bindings/i3c/i3c.h | 28 ++++++++++++++++++++++++++++
> > > 1 file changed, 28 insertions(+)
> > > create mode 100644 include/dt-bindings/i3c/i3c.h
> > >
> > > diff --git a/include/dt-bindings/i3c/i3c.h b/include/dt-bindings/i3c/i3c.h
> > > new file mode 100644
> > > index 000000000000..97448c546649
> > > --- /dev/null
> > > +++ b/include/dt-bindings/i3c/i3c.h
> > > @@ -0,0 +1,28 @@
> > > +/* SPDX-License-Identifier: GPL-2.0 */
> > > +/*
> > > + * Copyright (C) 2017 Cadence Design Systems Inc.
> > > + *
> > > + * Author: Boris Brezillon <boris.brezillon@bootlin.com>
> > > + */
> > > +
> > > +#ifndef _DT_BINDINGS_I3C_I3C_H
> > > +#define _DT_BINDINGS_I3C_I3C_H
> > > +
> > > +#define IS_I2C_DEV 0x80000000
> > > +
> > > +#define I2C_DEV(addr, lvr) \
> > > + (addr) (IS_I2C_DEV | (lvr)) 0x0
> >
> > This looks to be missing surrounding parentheses.
>
> Actually it's not. The macro is supposed to declare 3 u32 integers each
> of them separated by a space:
>
> reg = <I2C_DEV(0x34, 0x1)>;
>
> is translated into
>
> reg = <0x34 0x80000001 0x0>;
>
> >
> > > +
> > > +#define I3C_PID(manufid, partid, instid, extrainfo) \
> > > + ((manufid) << 1) \
> > > + (((partid) << 16) | ((instid) << 12) | (extrainfo))
> >
> > This macro doesn't make any sense. Missing a shift and an or?
>
> Same here, the PID is taking 2 32-bit entries.
>
> Now, I agree that this is far from obvious, and if Rob is okay, I'd
> like to propose a different binding to avoid having to define these
> macros:
>
> reg = <i2c_addr_or_i3c_static_addr pid_msb pid_lsb>;
>
> If pid_msb and pid_lsb are 0, then the node is defining an I2C device
Actually, I meant pid_msb == 0. This part of the PID is encoding the
manufacturer, and I don't think 0 is a valid manufacturer (I hope it's
not). So, we'd have something like:
reg = <i2c_addr_or_i3c_static_addr pid_msb pid_lsb_or_i2c_lvr>;
> (AFAICT, 0 is not a valid PID), otherwise it's an I3C device. This way
> we get rid of the IS_I2C_DEV flag, and we can get rid of those macros
> without making I3C dev node definition too painful (the only part
> developers will have to get right is the PID)
>
> >
> > > +
> > > +#define I3C_DEV_WITH_STATIC_ADDR(addr, manufid, partid, \
> > > + instid, extrainfo) \
> > > + (addr) I3C_PID(manufid, partid, instid, extrainfo)
> > > +
> > > +#define I3C_DEV(manufid, partid, instid, extrainfo) \
> > > + I3C_DEV_WITH_STATIC_ADDR(0x0, manufid, partid, \
> > > + instid, extrainfo)
> > > +
> > > +#endif
> >
>
WARNING: multiple messages have this Message-ID (diff)
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Joe Perches <joe@perches.com>, Rob Herring <robh+dt@kernel.org>
Cc: Wolfram Sang <wsa@the-dreams.de>,
linux-i2c@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
linux-doc@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Arnd Bergmann <arnd@arndb.de>,
Przemyslaw Sroka <psroka@cadence.com>,
Arkadiusz Golec <agolec@cadence.com>,
Alan Douglas <adouglas@cadence.com>,
Bartosz Folta <bfolta@cadence.com>, Damian Kos <dkos@cadence.com>,
Alicja Jurasik-Urbaniak <alicja@cadence.com>,
Cyprian Wronka <cwronka@cadence.com>,
Suresh Punnoose <sureshp@cadence.com>,
Rafal Ciepiela <rafalc@cadence.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Nishanth Menon <nm@ti.com>, Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Kumar Gala <galak@codeau>
Subject: Re: [PATCH v8 05/10] dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg property
Date: Wed, 3 Oct 2018 21:06:13 +0200 [thread overview]
Message-ID: <20181003210613.27d180c7@bbrezillon> (raw)
In-Reply-To: <20181003205953.426021bb@bbrezillon>
On Wed, 3 Oct 2018 20:59:53 +0200
Boris Brezillon <boris.brezillon@bootlin.com> wrote:
> On Wed, 03 Oct 2018 11:37:17 -0700
> Joe Perches <joe@perches.com> wrote:
>
> > On Wed, 2018-10-03 at 15:22 +0200, Boris Brezillon wrote:
> > > The reg property of devices connected to an I3C bus have 3 cells, and
> > > filling them manually is not trivial. Provides macros to help doing
> > > that.
> >
> > This patch logic seems excessively fragile.
>
> Keep in mind that this header is meant to be include by .dts(i) files,
> not regular .c files.
>
> >
> > > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> > > Reviewed-by: Rob Herring <robh@kernel.org>
> > > ---
> > > Changes in v8:
> > > - None
> > >
> > > Changes in v5:
> > > - none
> > > ---
> > > include/dt-bindings/i3c/i3c.h | 28 ++++++++++++++++++++++++++++
> > > 1 file changed, 28 insertions(+)
> > > create mode 100644 include/dt-bindings/i3c/i3c.h
> > >
> > > diff --git a/include/dt-bindings/i3c/i3c.h b/include/dt-bindings/i3c/i3c.h
> > > new file mode 100644
> > > index 000000000000..97448c546649
> > > --- /dev/null
> > > +++ b/include/dt-bindings/i3c/i3c.h
> > > @@ -0,0 +1,28 @@
> > > +/* SPDX-License-Identifier: GPL-2.0 */
> > > +/*
> > > + * Copyright (C) 2017 Cadence Design Systems Inc.
> > > + *
> > > + * Author: Boris Brezillon <boris.brezillon@bootlin.com>
> > > + */
> > > +
> > > +#ifndef _DT_BINDINGS_I3C_I3C_H
> > > +#define _DT_BINDINGS_I3C_I3C_H
> > > +
> > > +#define IS_I2C_DEV 0x80000000
> > > +
> > > +#define I2C_DEV(addr, lvr) \
> > > + (addr) (IS_I2C_DEV | (lvr)) 0x0
> >
> > This looks to be missing surrounding parentheses.
>
> Actually it's not. The macro is supposed to declare 3 u32 integers each
> of them separated by a space:
>
> reg = <I2C_DEV(0x34, 0x1)>;
>
> is translated into
>
> reg = <0x34 0x80000001 0x0>;
>
> >
> > > +
> > > +#define I3C_PID(manufid, partid, instid, extrainfo) \
> > > + ((manufid) << 1) \
> > > + (((partid) << 16) | ((instid) << 12) | (extrainfo))
> >
> > This macro doesn't make any sense. Missing a shift and an or?
>
> Same here, the PID is taking 2 32-bit entries.
>
> Now, I agree that this is far from obvious, and if Rob is okay, I'd
> like to propose a different binding to avoid having to define these
> macros:
>
> reg = <i2c_addr_or_i3c_static_addr pid_msb pid_lsb>;
>
> If pid_msb and pid_lsb are 0, then the node is defining an I2C device
Actually, I meant pid_msb == 0. This part of the PID is encoding the
manufacturer, and I don't think 0 is a valid manufacturer (I hope it's
not). So, we'd have something like:
reg = <i2c_addr_or_i3c_static_addr pid_msb pid_lsb_or_i2c_lvr>;
> (AFAICT, 0 is not a valid PID), otherwise it's an I3C device. This way
> we get rid of the IS_I2C_DEV flag, and we can get rid of those macros
> without making I3C dev node definition too painful (the only part
> developers will have to get right is the PID)
>
> >
> > > +
> > > +#define I3C_DEV_WITH_STATIC_ADDR(addr, manufid, partid, \
> > > + instid, extrainfo) \
> > > + (addr) I3C_PID(manufid, partid, instid, extrainfo)
> > > +
> > > +#define I3C_DEV(manufid, partid, instid, extrainfo) \
> > > + I3C_DEV_WITH_STATIC_ADDR(0x0, manufid, partid, \
> > > + instid, extrainfo)
> > > +
> > > +#endif
> >
>
next prev parent reply other threads:[~2018-10-03 19:06 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-03 13:22 [PATCH v8 00/10] Add the I3C subsystem Boris Brezillon
2018-10-03 13:22 ` Boris Brezillon
2018-10-03 13:22 ` [PATCH v8 01/10] i3c: Add core I3C infrastructure Boris Brezillon
2018-10-03 13:22 ` Boris Brezillon
2018-10-03 13:22 ` [PATCH v8 02/10] docs: driver-api: Add I3C documentation Boris Brezillon
2018-10-03 13:22 ` Boris Brezillon
2018-10-03 13:22 ` [PATCH v8 03/10] i3c: Add sysfs ABI spec Boris Brezillon
2018-10-03 13:22 ` Boris Brezillon
2018-10-03 13:22 ` [PATCH v8 04/10] dt-bindings: i3c: Document core bindings Boris Brezillon
2018-10-03 13:22 ` Boris Brezillon
2018-10-03 13:22 ` [PATCH v8 05/10] dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg property Boris Brezillon
2018-10-03 13:22 ` Boris Brezillon
2018-10-03 18:37 ` Joe Perches
2018-10-03 18:37 ` Joe Perches
2018-10-03 18:45 ` Geert Uytterhoeven
2018-10-03 18:45 ` Geert Uytterhoeven
2018-10-03 19:02 ` Joe Perches
2018-10-03 19:02 ` Joe Perches
2018-10-03 18:59 ` Boris Brezillon
2018-10-03 18:59 ` Boris Brezillon
2018-10-03 19:06 ` Boris Brezillon [this message]
2018-10-03 19:06 ` Boris Brezillon
2018-10-03 13:22 ` [PATCH v8 06/10] MAINTAINERS: Add myself as the I3C subsystem maintainer Boris Brezillon
2018-10-03 13:22 ` Boris Brezillon
2018-10-03 13:22 ` [PATCH v8 07/10] i3c: master: Add driver for Cadence IP Boris Brezillon
2018-10-03 13:22 ` Boris Brezillon
2018-10-08 10:06 ` Arnd Bergmann
2018-10-08 10:06 ` Arnd Bergmann
2018-10-08 10:21 ` Boris Brezillon
2018-10-08 10:21 ` Boris Brezillon
2018-10-08 10:36 ` Arnd Bergmann
2018-10-08 10:36 ` Arnd Bergmann
2018-10-08 12:05 ` Boris Brezillon
2018-10-08 12:05 ` Boris Brezillon
2018-10-03 13:22 ` [PATCH v8 08/10] dt-bindings: i3c: Document Cadence I3C master bindings Boris Brezillon
2018-10-03 13:22 ` Boris Brezillon
2018-10-03 13:22 ` [PATCH v8 09/10] gpio: Add a driver for Cadence I3C GPIO expander Boris Brezillon
2018-10-03 13:22 ` Boris Brezillon
2018-10-03 13:22 ` [PATCH v8 10/10] dt-bindings: gpio: Add bindings for Cadence I3C gpio expander Boris Brezillon
2018-10-03 13:22 ` Boris Brezillon
2018-10-04 8:35 ` Linus Walleij
2018-10-04 8:35 ` Linus Walleij
2018-10-08 10:47 ` [PATCH v8 00/10] Add the I3C subsystem Arnd Bergmann
2018-10-08 10:47 ` Arnd Bergmann
2018-10-17 13:18 ` Boris Brezillon
2018-10-17 13:18 ` Boris Brezillon
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=20181003210613.27d180c7@bbrezillon \
--to=boris.brezillon@bootlin.com \
--cc=Vitor.Soares@synopsys.com \
--cc=Xiang.Lin@synaptics.com \
--cc=adouglas@cadence.com \
--cc=agolec@cadence.com \
--cc=alicja@cadence.com \
--cc=arnd@arndb.de \
--cc=bfolta@cadence.com \
--cc=corbet@lwn.net \
--cc=cwronka@cadence.com \
--cc=devicetree@vger.kernel.org \
--cc=dkos@cadence.com \
--cc=galak@codeaurora.org \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=joe@perches.com \
--cc=linus.walleij@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mshettel@codeaurora.org \
--cc=nm@ti.com \
--cc=nsekhar@ti.com \
--cc=pawel.moll@arm.com \
--cc=peda@axentia.se \
--cc=pgaj@cadence.com \
--cc=psroka@cadence.com \
--cc=rafalc@cadence.com \
--cc=robh+dt@kernel.org \
--cc=sureshp@cadence.com \
--cc=swboyd@chromium.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=wsa@the-dreams.de \
/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.