mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime@cerno.tech>
To: Frank Lee <tiny.windzz@gmail.com>
Cc: Samuel Holland <samuel@sholland.org>,
	Frank Lee <frank@allwinnertech.com>,
	Rob Herring <robh+dt@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 1/3] dt-bindings: gpio: sunxi:create a DT header for Allwinner pin controller
Date: Tue, 10 Nov 2020 12:35:30 +0100	[thread overview]
Message-ID: <20201110113530.rtuo7nbez6r4xtjc@gilmour.lan> (raw)
In-Reply-To: <CAEExFWstKV_uMbh5iQ9ULX7=24aj0_6Ge+4uFe07WmwiyDDRMA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4254 bytes --]

On Wed, Oct 28, 2020 at 08:15:45PM +0800, Frank Lee wrote:
> On Wed, Jul 29, 2020 at 9:06 PM Maxime Ripard <maxime@cerno.tech> wrote:
> >
> > Hi,
> >
> > On Sat, Jul 25, 2020 at 02:18:39PM -0500, Samuel Holland wrote:
> > > On 7/17/20 11:07 AM, Maxime Ripard wrote:
> > > > Hi!
> > > >
> > > > On Wed, Jul 15, 2020 at 07:54:12PM +0800, Frank Lee wrote:
> > > >> From: Yangtao Li <frank@allwinnertech.com>
> > > >>
> > > >> The sunxi gpio binding defines a few custom cells for its gpio specifier.
> > > >> Provide bank name for those.
> > > >>
> > > >> Signed-off-by: Yangtao Li <frank@allwinnertech.com>
> > > >
> > > > Thanks for working on this, I wanted to do it at some point but it kept
> > > > getting pushed further into my todo list.
> > > >
> > > >> ---
> > > >>  include/dt-bindings/gpio/sunxi-gpio.h | 29 +++++++++++++++++++++++++++
> > > >>  1 file changed, 29 insertions(+)
> > > >>  create mode 100644 include/dt-bindings/gpio/sunxi-gpio.h
> > > >>
> > > >> diff --git a/include/dt-bindings/gpio/sunxi-gpio.h b/include/dt-bindings/gpio/sunxi-gpio.h
> > > >> new file mode 100644
> > > >> index 000000000000..c692b4360da6
> > > >> --- /dev/null
> > > >> +++ b/include/dt-bindings/gpio/sunxi-gpio.h
> > > >
> > > > So generally we've been using the compatible name as the file name. You
> > > > should follow that convention too, and since it was added with the A10,
> > > > using the A10 compatible.
> > > >
> > > >> @@ -0,0 +1,29 @@
> > > >> +/* SPDX-License-Identifier: GPL-2.0 */
> > > >> +/*
> > > >> + * GPIO definitions for Allwinner SoCs
> > > >> + *
> > > >> + * Copyright (C) 2020 Yangtao Li <frank@allwinnertech.com>
> > > >> + */
> > > >> +
> > > >> +#ifndef _DT_BINDINGS_SUNXI_GPIO_H
> > > >> +#define _DT_BINDINGS_SUNXI_GPIO_H
> > > >> +
> > > >> +#include <dt-bindings/gpio/gpio.h>
> > > >> +
> > > >> +/* pio */
> > > >> +#define PA        0
> > > >> +#define PB        1
> > > >> +#define PC        2
> > > >> +#define PD        3
> > > >> +#define PE        4
> > > >> +#define PF        5
> > > >> +#define PG        6
> > > >> +#define PH        7
> > > >> +#define PI        8
> > > >> +
> > > >> +/* r-pio */
> > > >> +#define PL        0
> > > >> +#define PM        1
> > > >> +#define PN        2
> > > >> +
> > > >> +#endif /* _DT_BINDINGS_SUNXI_GPIO_H */
> > > >
> > > > Maybe we can go one step further and use a macro to have something like
> > > > PIN(A, 12) ?
> > >
> > > Since we have separate cells for the bank and pin, I don't think it would be
> > > appropriate to have a single macro generating both.
> >
> > Yeah, but it's "just" an encoding issue though, it's not a major concern
> > if it makes our life easier.
> >
> > > And I'm not sure what the benefit of the macro would be, if all it
> > > does is forward its arguments. Are you concerned that P[A-M] could
> > > conflict with something else in the device tree?
> >
> > There's indeed a bunch of names that are fairly generic and could be
> > conflicting with others (PD for power domain is the first one that comes
> > to my mind). Using a prefix would make the GPIO descriptors pretty long,
> > so it wasn't ideal either. A macro makes it readable without increasing
> > too much the risks of conflicts
> 
> I tried to use macros, but failed.
> 
> I have a look at some other GPIO macros, which have a prefix in front of them.
> Maybe we can do the same? It's all numbers. It's not intuitive.

This works

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-olinuxino.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-olinuxino.dts
index f3f8e177ab61..3a66d1102a78 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-olinuxino.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-olinuxino.dts
@@ -8,6 +8,9 @@
 
 #include <dt-bindings/gpio/gpio.h>
 
+#define SUNXI_PE 4
+#define SUNXI_PIN(bank, pin)    SUNXI_##bank pin
+
 / {
 	model = "Olimex A64-Olinuxino";
 	compatible = "olimex,a64-olinuxino", "allwinner,sun50i-a64";
@@ -37,7 +40,7 @@ leds {
 
 		led-0 {
 			label = "a64-olinuxino:red:user";
-			gpios = <&pio 4 17 GPIO_ACTIVE_HIGH>; /* PE17 */
+			gpios = <&pio SUNXI_PIN(PE, 17) GPIO_ACTIVE_HIGH>;
 		};
 	};
 

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      parent reply	other threads:[~2020-11-10 11:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-15 11:54 Frank Lee
2020-07-17 16:07 ` Maxime Ripard
2020-07-25 19:18   ` Samuel Holland
2020-07-29 13:06     ` Maxime Ripard
2020-10-28 12:15       ` Frank Lee
2020-11-09 12:29         ` Frank Lee
2020-11-10 11:35         ` Maxime Ripard [this message]

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=20201110113530.rtuo7nbez6r4xtjc@gilmour.lan \
    --to=maxime@cerno.tech \
    --cc=devicetree@vger.kernel.org \
    --cc=frank@allwinnertech.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=samuel@sholland.org \
    --cc=tiny.windzz@gmail.com \
    --cc=wens@csie.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

all inboxes | Powered by JetHome®