All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Ruppert <christian.ruppert@abilis.com>
To: Haojian Zhuang <haojian.zhuang@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Shiraz HASHIM <shiraz.hashim@st.com>,
	Patrice CHOTARD <patrice.chotard@st.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Grant Likely <grant.likely@secretlab.ca>,
	Rob Herring <rob.herring@calxeda.com>,
	Rob Landley <rob@landley.net>,
	Sascha Leuenberger <sascha.leuenberger@abilis.com>,
	Pierrick Hascoet <pierrick.hascoet@abilis.com>,
	"devicetree-discuss@lists.ozlabs.org"
	<devicetree-discuss@lists.ozlabs.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>
Subject: Re: [PATCH 1/2] pinmux: Add TB10x pinmux driver
Date: Mon, 3 Jun 2013 14:30:04 +0200	[thread overview]
Message-ID: <20130603123001.GD31808@ab42.lan> (raw)
In-Reply-To: <CAD6h2NSh_4TNAGeFhg+va5QX2hGia+gkw-mPaeMezghsa=Zc6Q@mail.gmail.com>

On Sun, May 26, 2013 at 11:49:20PM +0800, Haojian Zhuang wrote:
> On 24 May 2013 19:50, Christian Ruppert <christian.ruppert@abilis.com> wrote:
> > Hello Haojian,
> >
> > On Thu, May 23, 2013 at 03:43:27PM +0800, Haojian Zhuang wrote:
> >> On 22 May 2013 22:28, Christian Ruppert <christian.ruppert@abilis.com> wrote:
> >> >
> >> > On Mon, May 20, 2013 at 10:10:33AM +0200, Linus Walleij wrote:
> >> > > On Thu, May 16, 2013 at 2:12 AM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> >> > > > On 05/10/2013 02:25 AM, Christian Ruppert wrote:
> [...]
> >> I think that you want to keep the logic simple. If so, I prefer you can
> >> check pinctrl-single driver first. All pins are defined in DTS instead.
> >
> > Thanks for the hint. I haven't understood how to associate GPIOs to
> > other functions, however: Our hardware pin controller makes GPIO pins
> > available depending on the configuration of the non-GPIO interfaces.
> > This means that in many configurations, GPIO banks are only partially
> 
> They're multiple function pins. You can find those pins in most modern SoCs.
> 
> > available because some pins are used for other purposes. We can't expect
> > our customers to manually change the pin assignments in the device tree
> > in order to take this into account for every PCB.
> 
> Yes, you need to define the gpio-range & pinctrl-single,gpio-range.
> If you define them in your DTSI file, customer only need to include it.
> If you define them in your DTS file, customer only need to copy them into
> their DTS file.
> 
> If you don't have the requirements of routing multiple pins to the same GPIO,
> I suggest you to define them in your DTSI file.

OK, here's a simplified example of what we would like to do (this seems
pretty common so I suppose there is a way I haven't understood). Our
situation is slightly more complex but for the purpose of discussion
let's assume a chip with 8 pins which can be configured for the
following functions:

Pin   GPIO-A    I2C    SPI0     SPI1
------------------------------------
 1    GPIOA0    SDA             MISO1
 2    GPIOA1    SCL             MOSI1
 3    GPIOA2                    SS1_B
 4    GPIOA3                    SCLK1
 5    GPIOA4           MISO0
 6    GPIOA5           MOSI0
 7    GPIOA6           SS0_B
 8    GPIOA7           SCLK0

We can now define the following pinctrl-single:

pinmux: pinmux@0xFFEE0000 {
	compatible = "pinctrl-single";
	reg = <0xFFEE0000 0x8>;
	#address-cells = <1>;
	#size-cells = <0>;
	#gpio-range-cells = <3>;
	pinctrl-single,register-width = <32>;
	pinctrl-single,function-mask = <0xffffffff>;
	pinctrl-single,gpio-range = <&range 1 8 0>;
	gpioa_pins: pinmux_gpioa_pins {
		pinctrl-single,pins = <0x0 0 0x4 0>
	};
	i2c_pins: pinmux_i2c_pins {
		pinctrl-single,pins = <0x0 1>
	};
	spi0_pins: pinmux_spi0_pins {
		pinctrl-single,pins = <0x1 1>
	};
	spi1_pins: pinmux_spi1_pins {
		pinctrl-single,pins = <0x0 2>
	};
	range: gpio-range {
		#pinctrl-single,gpio-range-cells = <3>;
	};
};
gpioa: gpio_a {
	/* ... */
	gpio-controller;
	gpio-ranges = <&pinmux 0 0 8>;
};

How do I tell pinctrl-single that:
1. I2C and SPI1 cannot be selected at the same time?
2. In case I2C is selected, GPIOA0 and GPIOA1 cannot be requested but
   GPIOA2 and GPIOA3 are available?
3. In case SPI1 is selected GPIOA0-GPIOA3 are not available?
4. In case SPI0 is selected GPIOA4-GPIOA7 are not available?

> > Is there a way to make different pinmux functions mutually exclusive in
> > pinctrl-single, e.g. a pin is either a GPIO or part of an SPI interface?
> 
> gpio_request() could help you to request GPIO if the pin isn't used yet.
> And even your pin is in I2C mode without usage.
> 
> But if you want to the mutually exclusive, you could do by this way.
> 
> 1) Function is only in GPIO mode.
> In uart node, GPIO is function 1.
> pinctrl-0 = <&uart1_pmx_func>;
> uart1_pmx_func: uart1_pmx_func {
>      pinctrl-single,pins = <0x104 0x1>;
> };
> 
> Then you can't switch to SPI interface, unless you want to switch pin state.
> 
> 2) Function is only in UART mode.
> You can hack gpio function in pinctrl-single,gpio-range property. i.e. you
> always set gpio function as UART mode by hack.
> 
> But I still don't understand why you need this feature.
> 
> > Can the same thing be done for example to mux either SPI or I2C on the
> > same pins?
> 
> Are you using the develop board that one pin may be routed to multiple
> functions? And you can choose SPI or I2C by switch.

We do have development boards to which the customer can connect their
own peripherals (and adapt the device tree accordingly). We are also
looking for a comprehensive way to configure the I/Os even for customers
designing their own boards.

> It means that the sames pin are shared between SPI and I2C driver. Either
> SPI driver gets this pin, or I2C driver gets this pin. Only one driver could
> get the pins even you don't use pinctrl-single driver. It likes GPIO.

Exactly. This is what I'm wondering about in the example above. What
must I do to get a clear error message in case someone by mistake tries
the following in the above example:

spi0: tb10x_spi0 {
	/* ... */
	pinctrl-names = "default";
	pinctrl-0 = <&spi0_pins>;
};
i2c: tb10x_i2c {
	/* ... */
	pinctrl-names = "default";
	pinctrl-0 = <&i2c_pins>;
};

And the following:

i2c: tb10x_i2c {
	/* ... */
	pinctrl-names = "default";
	pinctrl-0 = <&i2c_pins>;
};
some_external_component: ext_comp {
	/* ... */
	gpios = <&gpioa 0>;
};

> SPI & I2C driver are always enabled in your kernel image. So you're enabling
> different devices with different hardware configuration, and you need to
> prepare two DTS files. Your boot loader should find which
> hardware configuration is enabled & loaded the right DTS file.
> So different pinmux settings are written in these two DTS files.

Exactly. In addition, even pinmux modes which are not used in a given
board are still defined in our SOC .dtsi file.

Greetings,
  Christian

-- 
  Christian Ruppert              ,          <christian.ruppert@abilis.com>
                                /|
  Tel: +41/(0)22 816 19-42     //|                 3, Chemin du Pré-Fleuri
                             _// | bilis Systems   CH-1228 Plan-les-Ouates

  reply	other threads:[~2013-06-03 12:30 UTC|newest]

Thread overview: 147+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-10 15:45 [PATCH 1/2] pinmux: Add TB10x pinmux driver Christian Ruppert
2013-04-10 15:45 ` [PATCH 2/2] GPIO: Add TB10x GPIO driver Christian Ruppert
2013-04-17 15:13   ` Linus Walleij
2013-04-17 18:37   ` Stephen Warren
2013-04-17 14:48 ` [PATCH 1/2] pinmux: Add TB10x pinmux driver Linus Walleij
2013-04-17 18:32 ` Stephen Warren
2013-04-18  9:03   ` Christian Ruppert
2013-04-26  7:47     ` Linus Walleij
2013-04-29 16:17       ` Christian Ruppert
     [not found]         ` <20130429161725.GB30136-7oYq3qWSd+k@public.gmane.org>
2013-05-02 18:49           ` Stephen Warren
2013-05-02 18:49             ` Stephen Warren
2013-05-03 18:03             ` Linus Walleij
2013-05-08 16:41               ` Christian Ruppert
2013-05-08 20:01                 ` Stephen Warren
2013-05-10  8:25                   ` Christian Ruppert
2013-05-14 12:29                     ` Linus Walleij
2013-05-15  9:41                       ` Christian Ruppert
2013-05-20  8:03                         ` Linus Walleij
2013-05-22  9:49                           ` Christian Ruppert
2013-06-12 16:44                             ` [RFC] Allow GPIO ranges based on pinctl pin groups Christian Ruppert
     [not found]                               ` <1371055449-15828-1-git-send-email-christian.ruppert-ux6zf3SgZrrQT0dZR+AlfA@public.gmane.org>
2013-06-13  9:00                                 ` Linus Walleij
2013-06-13  9:00                                   ` Linus Walleij
2013-06-13 12:55                                   ` [PATCH 1/2] Add pin list based GPIO ranges Christian Ruppert
     [not found]                                     ` <1371128132-18266-1-git-send-email-christian.ruppert-ux6zf3SgZrrQT0dZR+AlfA@public.gmane.org>
2013-06-13 18:30                                       ` Linus Walleij
2013-06-13 18:30                                         ` Linus Walleij
2013-06-14  7:17                                     ` Patrice CHOTARD
2013-06-14  8:24                                       ` [PATCH] Fix comment on pinctrl_gpio_range.pin_base Christian Ruppert
2013-06-16 10:19                                         ` Linus Walleij
2013-06-13 12:55                                   ` [PATCH 2/2] Make non-linear GPIO ranges accesible from gpiolib Christian Ruppert
2013-06-13 18:36                                     ` Linus Walleij
2013-06-13 21:38                                     ` Stephen Warren
2013-06-14  9:12                                       ` Christian Ruppert
2013-06-19 18:10                                         ` Stephen Warren
2013-06-19 18:27                                           ` Stephen Warren
2013-06-20 11:57                                             ` Christian Ruppert
2013-06-21 21:17                                               ` Stephen Warren
2013-06-25 11:59                                                 ` Christian Ruppert
2013-06-25 15:59                                                   ` Stephen Warren
2013-06-25 14:27                                                 ` Linus Walleij
2013-06-25 15:19                                                   ` Stephen Warren
2013-06-25 14:32                                                 ` Linus Walleij
2013-06-25 15:22                                                   ` Stephen Warren
2013-06-25 14:56                                                 ` Linus Walleij
2013-06-25 15:31                                                   ` Stephen Warren
2013-06-25 15:47                                                     ` Linus Walleij
2013-06-25 15:28                                                 ` Linus Walleij
2013-06-25 15:39                                                   ` Stephen Warren
2013-06-25 15:53                                                     ` Linus Walleij
2013-06-17 16:03                                       ` Christian Ruppert
2013-06-17 16:04                                         ` [PATCH 1/4] " Christian Ruppert
2013-06-18  8:09                                           ` Linus Walleij
2013-06-18  9:25                                             ` Christian Ruppert
2013-06-18  9:29                                               ` Christian Ruppert
2013-06-19 12:03                                                 ` Linus Walleij
2013-06-19 18:15                                                   ` Stephen Warren
2013-06-26 11:42                                                     ` Christian Ruppert
2013-06-26 17:33                                                       ` Stephen Warren
2013-06-19 22:27                                                 ` Stephen Warren
2013-06-26 11:46                                                   ` Christian Ruppert
2013-06-26 17:34                                                     ` Stephen Warren
2013-06-18  9:29                                               ` [PATCH 2/4] pinmux: Add TB10x pinmux driver Christian Ruppert
2013-06-19 22:35                                                 ` Stephen Warren
2013-06-26 11:50                                                   ` Christian Ruppert
2013-06-26 17:40                                                     ` Stephen Warren
2013-07-05  9:49                                                       ` Christian Ruppert
2013-07-05 18:40                                                         ` Stephen Warren
2013-07-08 13:02                                                           ` Christian Ruppert
2013-07-10 19:27                                                             ` Stephen Warren
2013-07-16  8:47                                                               ` Christian Ruppert
2013-07-16 16:04                                                                 ` Stephen Warren
2013-07-18 16:07                                                                   ` Christian Ruppert
2013-07-18 19:54                                                                     ` Stephen Warren
2013-07-26  9:42                                                                       ` Christian Ruppert
2013-07-26 16:05                                                                         ` Stephen Warren
2013-07-29 22:35                                                 ` Linus Walleij
2013-08-05 11:51                                                   ` Christian Ruppert
2013-08-05 11:51                                                     ` Christian Ruppert
2013-08-14 16:53                                                     ` Linus Walleij
2013-08-21 15:57                                                       ` Christian Ruppert
2013-08-22 20:10                                                         ` Stephen Warren
2013-08-28 14:47                                                           ` Christian Ruppert
2013-10-08 12:21                                                             ` Christian Ruppert
2013-10-08 12:25                                                               ` [PATCH 01/03] Make non-linear GPIO ranges accesible from gpiolib Christian Ruppert
2013-10-09 11:58                                                                 ` Linus Walleij
2013-10-09 13:28                                                                   ` Christian Ruppert
2013-10-09 14:01                                                                     ` Linus Walleij
2013-10-10 20:49                                                                       ` Stephen Warren
2013-10-11  7:53                                                                         ` Linus Walleij
2013-10-15 13:36                                                                       ` Christian Ruppert
2013-10-15 13:37                                                                         ` [PATCH V2] " Christian Ruppert
2013-10-16 11:19                                                                           ` Linus Walleij
2013-10-16 12:56                                                                             ` [PATCH] Add a short note on pinctrl_get_group_pins to pinctrl.txt Christian Ruppert
2013-10-16 13:36                                                                               ` Linus Walleij
2013-10-10 20:47                                                                   ` [PATCH 01/03] Make non-linear GPIO ranges accesible from gpiolib Stephen Warren
2013-10-08 12:25                                                               ` [PATCH 02/03] pinmux: Add TB10x pinmux driver Christian Ruppert
2013-10-09 12:30                                                                 ` Linus Walleij
     [not found]                                                                   ` <CACRpkdZdELan7OyMjt4KOi=q-v1xkSaNZNyZ7AnOBY1R=SoW3w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-15 13:39                                                                     ` [PATCH V2] " Christian Ruppert
2013-10-15 13:39                                                                       ` Christian Ruppert
2013-10-16 11:25                                                                       ` Linus Walleij
2013-10-08 12:25                                                               ` [PATCH 03/03] GPIO: Add TB10x GPIO driver Christian Ruppert
2013-10-09 12:19                                                                 ` Linus Walleij
2013-10-15 13:45                                                                   ` Christian Ruppert
2013-10-16 11:29                                                                     ` Linus Walleij
2013-10-16 12:58                                                                       ` Christian Ruppert
2013-10-24 16:23                                                                         ` Christian Ruppert
2013-10-25 21:44                                                                           ` Linus Walleij
2013-10-25  3:27                                                                 ` Kumar Gala
2013-08-28 18:49                                                         ` [PATCH 2/4] pinmux: Add TB10x pinmux driver Linus Walleij
2013-08-29  7:35                                                           ` Christian Ruppert
2013-08-29  8:24                                                             ` Linus Walleij
2013-08-30  8:19                                                               ` Christian Ruppert
2013-06-18  9:29                                               ` [PATCH 3/4] GPIO: Add TB10x GPIO driver Christian Ruppert
2013-06-19 22:37                                                 ` Stephen Warren
2013-06-18  9:29                                               ` [PATCH 4/4] Add Abilis Systems Sarl to device tree vendor prefixes Christian Ruppert
2013-06-17 16:04                                         ` [PATCH 2/4] pinmux: Add TB10x pinmux driver Christian Ruppert
2013-06-17 16:04                                         ` [PATCH 3/4] GPIO: Add TB10x GPIO driver Christian Ruppert
2013-06-17 16:04                                         ` [PATCH 4/4] Add Abilis Systems Sarl to device tree vendor prefixes Christian Ruppert
2013-05-16  0:12                     ` [PATCH 1/2] pinmux: Add TB10x pinmux driver Stephen Warren
2013-05-20  8:10                       ` Linus Walleij
2013-05-22 14:28                         ` Christian Ruppert
2013-05-23  7:43                           ` Haojian Zhuang
2013-05-24 11:50                             ` Christian Ruppert
2013-05-26 15:49                               ` Haojian Zhuang
2013-06-03 12:30                                 ` Christian Ruppert [this message]
     [not found]                                   ` <20130603123001.GD31808-7oYq3qWSd+k@public.gmane.org>
2013-06-05  1:44                                     ` Haojian Zhuang
2013-06-05  1:44                                       ` Haojian Zhuang
2013-06-06 14:11                                       ` Christian Ruppert
2013-06-06 14:32                                         ` Haojian Zhuang
2013-06-06 15:30                                           ` Christian Ruppert
2013-06-07  0:00                                             ` Haojian Zhuang
2013-06-07 11:32                                               ` Christian Ruppert
     [not found]                                                 ` <20130607113207.GE11875-7oYq3qWSd+k@public.gmane.org>
2013-06-07 14:57                                                   ` Haojian Zhuang
2013-06-07 14:57                                                     ` Haojian Zhuang
2013-06-07 19:18                                             ` Stephen Warren
2013-06-08  8:31                                               ` Haojian Zhuang
2013-06-09  2:47                                                 ` Stephen Warren
2013-06-11  7:27                                               ` Christian Ruppert
2013-06-16 11:11                                                 ` Linus Walleij
2013-05-29 12:21                               ` Linus Walleij
2013-06-03  9:42                                 ` Christian Ruppert
     [not found]                                   ` <20130603094204.GC31808-7oYq3qWSd+k@public.gmane.org>
2013-06-07 11:36                                     ` Linus Walleij
2013-06-07 11:36                                       ` Linus Walleij
2013-06-07 13:34                                       ` Christian Ruppert
2013-05-24  9:20                           ` Linus Walleij
2013-05-24 12:03                             ` Christian Ruppert
     [not found]     ` <20130418090310.GA17636-7oYq3qWSd+k@public.gmane.org>
2013-05-02 18:52       ` Stephen Warren
2013-05-02 18:52         ` Stephen Warren

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=20130603123001.GD31808@ab42.lan \
    --to=christian.ruppert@abilis.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=haojian.zhuang@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patrice.chotard@st.com \
    --cc=pierrick.hascoet@abilis.com \
    --cc=rob.herring@calxeda.com \
    --cc=rob@landley.net \
    --cc=sascha.leuenberger@abilis.com \
    --cc=shiraz.hashim@st.com \
    --cc=swarren@wwwdotorg.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.