devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Can one  set GPIO direction in pinmux definition?
@ 2012-08-22 15:37 Subodh Nijsure
       [not found] ` <5034FCB2.5040709-4jo+YWezP1RWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Subodh Nijsure @ 2012-08-22 15:37 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: devicetree-discuss


For a MX28 based hardware I am working with I need to use AUART4

I need to configure this AUART4 as uart only when necessary and at all 
other times pins associated with AUART4 need to be configured as inputs.

I am using following DT definitions to setup AUART4 mux  but can't 
figure out how to setup pin direction via DT, can it be done or I need 
to do it in C code?

         apb@80000000 {
                 apbh@80000000 {
                                 auart4_pins_a: auart4@0 {
                                         reg = <0>;
                                         fsl,pinmux-ids = <
                                                 0x3142 /* 
MX28_PAD_SAIF0_MCLK__AUART4_CTS */
                                                 0x3152 /* 
MX28_PAD_SAIF0_LRCLK__AUART4_RTS */
                                                 0x3162 /* 
MX28_PAD_SAIF0_BITCLK__AUART4_RX */
                                                 0x3172 /* 
MX28_PAD_SAIF0_SDATA0__AUART4_TX */
                                         >;
                                         fsl,drive-strength = <0>;
                                         fsl,voltage = <1>;
                                         fsl,pull-up = <0>;
                                 };
                                 auart4_highz_pins: auart4-gpio@0 {
                                         reg = <0>;
                                         fsl,pinmux-ids = <
                                                 0x3143 /* 
MX28_PAD_SAIF0_MCLK__GPIO_3_20 */
                                                 0x3153 /* 
MX28_PAD_SAIF0_LRCLK__GPIO_3_21 */
                                                 0x3163 /* 
MX28_PAD_SAIF0_BITCLK__GPIO_3_22 */
                                                 0x3173 /* 
MX28_PAD_SAIF0_SDATA0__GPIO_3_23 */
                                         >;
                                         fsl,drive-strength = <0>;
                                         fsl,voltage = <1>;
                                         fsl,pull-up = <0>;
                                 };
                  };
           };

                 apbx@80040000 {
                         auart4: serial@80072000 {
                                 pinctrl-names = "default", "auart";
                                 pinctrl-0 = <&auart4_highz_pins>;
                                 pinctrl-1 = <&auart4_pins_a>;
                                 status = "okay";
                         };
                };

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can one  set GPIO direction in pinmux definition?
       [not found] ` <5034FCB2.5040709-4jo+YWezP1RWk0Htik3J/w@public.gmane.org>
@ 2012-08-22 19:52   ` Stephen Warren
       [not found]     ` <5035388D.2060909-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
  2012-08-23  0:17   ` Matt Sealey
  1 sibling, 1 reply; 6+ messages in thread
From: Stephen Warren @ 2012-08-22 19:52 UTC (permalink / raw)
  To: Subodh Nijsure
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Dong Aisheng,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On 08/22/2012 09:37 AM, Subodh Nijsure wrote:
> 
> For a MX28 based hardware I am working with I need to use AUART4
> 
> I need to configure this AUART4 as uart only when necessary and at all
> other times pins associated with AUART4 need to be configured as inputs.

Out of curiosity, why?

BTW, you didn't CC any of the IMX maintainers, so it's likely they won't
see your question. I've CC'd LinusW, Shawn, and Dong.

> I am using following DT definitions to setup AUART4 mux  but can't
> figure out how to setup pin direction via DT, can it be done or I need
> to do it in C code?
> 
>         apb@80000000 {
>                 apbh@80000000 {
>                                 auart4_pins_a: auart4@0 {
>                                         reg = <0>;
>                                         fsl,pinmux-ids = <
>                                                 0x3142 /*
> MX28_PAD_SAIF0_MCLK__AUART4_CTS */
>                                                 0x3152 /*
> MX28_PAD_SAIF0_LRCLK__AUART4_RTS */
>                                                 0x3162 /*
> MX28_PAD_SAIF0_BITCLK__AUART4_RX */
>                                                 0x3172 /*
> MX28_PAD_SAIF0_SDATA0__AUART4_TX */
>                                         >;
>                                         fsl,drive-strength = <0>;
>                                         fsl,voltage = <1>;
>                                         fsl,pull-up = <0>;
>                                 };
>                                 auart4_highz_pins: auart4-gpio@0 {
>                                         reg = <0>;
>                                         fsl,pinmux-ids = <
>                                                 0x3143 /*
> MX28_PAD_SAIF0_MCLK__GPIO_3_20 */
>                                                 0x3153 /*
> MX28_PAD_SAIF0_LRCLK__GPIO_3_21 */
>                                                 0x3163 /*
> MX28_PAD_SAIF0_BITCLK__GPIO_3_22 */
>                                                 0x3173 /*
> MX28_PAD_SAIF0_SDATA0__GPIO_3_23 */
>                                         >;
>                                         fsl,drive-strength = <0>;
>                                         fsl,voltage = <1>;
>                                         fsl,pull-up = <0>;
>                                 };
>                  };
>           };

I don't know IMX HW, but where is highz controlled? On other SoCs I'm
familiar with, when a pad is configured as a GPIO, the highz state is
controlled by the GPIO module, so there's nothing pinmux can do about
it. Even if the pinmux HW does control highz, gpio_direction_*() are
still meant to communicate with the pinctrl driver to implement this, so
overriding it through the pinctrl configuration seems like a bad thing.

So I think your UART driver would have to request the GPIOs, and set
them as inputs. So, I guess your UART node below would need a property
listing the GPIOs to do this to.

>                 apbx@80040000 {
>                         auart4: serial@80072000 {
>                                 pinctrl-names = "default", "auart";
>                                 pinctrl-0 = <&auart4_highz_pins>;
>                                 pinctrl-1 = <&auart4_pins_a>;
>                                 status = "okay";
>                         };
>                };

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can one  set GPIO direction in pinmux definition?
       [not found]     ` <5035388D.2060909-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
@ 2012-08-22 22:10       ` Subodh Nijsure
       [not found]         ` <503558B8.4010603-4jo+YWezP1RWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Subodh Nijsure @ 2012-08-22 22:10 UTC (permalink / raw)
  To: Stephen Warren
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Dong Aisheng,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On 08/22/2012 12:52 PM, Stephen Warren wrote:
> On 08/22/2012 09:37 AM, Subodh Nijsure wrote:
>> For a MX28 based hardware I am working with I need to use AUART4
>>
>> I need to configure this AUART4 as uart only when necessary and at all
>> other times pins associated with AUART4 need to be configured as inputs.
> Out of curiosity, why?
Out hardware is connected to external equipment, electric meter via this 
UART.
This electricity meter can also be read externally by an optical reader.
Since this is a shared bus, we can't be sitting on that bus with our 
interface configured as UART as it prevents optical reader from talking 
to the meter. There are ways we can tell is optical meter is connected, 
if we detect that its connected we configure these pins as input else 
configure them for UART functionality.

> BTW, you didn't CC any of the IMX maintainers, so it's likely they won't
> see your question. I've CC'd LinusW, Shawn, and Dong.
thanks.
>> I am using following DT definitions to setup AUART4 mux  but can't
>> figure out how to setup pin direction via DT, can it be done or I need
>> to do it in C code?
>>
>>          apb@80000000 {
>>                  apbh@80000000 {
>>                                  auart4_pins_a: auart4@0 {
>>                                          reg = <0>;
>>                                          fsl,pinmux-ids = <
>>                                                  0x3142 /*
>> MX28_PAD_SAIF0_MCLK__AUART4_CTS */
>>                                                  0x3152 /*
>> MX28_PAD_SAIF0_LRCLK__AUART4_RTS */
>>                                                  0x3162 /*
>> MX28_PAD_SAIF0_BITCLK__AUART4_RX */
>>                                                  0x3172 /*
>> MX28_PAD_SAIF0_SDATA0__AUART4_TX */
>>                                          >;
>>                                          fsl,drive-strength = <0>;
>>                                          fsl,voltage = <1>;
>>                                          fsl,pull-up = <0>;
>>                                  };
>>                                  auart4_highz_pins: auart4-gpio@0 {
>>                                          reg = <0>;
>>                                          fsl,pinmux-ids = <
>>                                                  0x3143 /*
>> MX28_PAD_SAIF0_MCLK__GPIO_3_20 */
>>                                                  0x3153 /*
>> MX28_PAD_SAIF0_LRCLK__GPIO_3_21 */
>>                                                  0x3163 /*
>> MX28_PAD_SAIF0_BITCLK__GPIO_3_22 */
>>                                                  0x3173 /*
>> MX28_PAD_SAIF0_SDATA0__GPIO_3_23 */
>>                                          >;
>>                                          fsl,drive-strength = <0>;
>>                                          fsl,voltage = <1>;
>>                                          fsl,pull-up = <0>;
>>                                  };
>>                   };
>>            };
> I don't know IMX HW, but where is highz controlled? On other SoCs I'm
> familiar with, when a pad is configured as a GPIO, the highz state is
> controlled by the GPIO module, so there's nothing pinmux can do about
> it. Even if the pinmux HW does control highz, gpio_direction_*() are
> still meant to communicate with the pinctrl driver to implement this, so
> overriding it through the pinctrl configuration seems like a bad thing.
>
> So I think your UART driver would have to request the GPIOs, and set
> them as inputs. So, I guess your UART node below would need a property
> listing the GPIOs to do this to.
Right now that is what I am doing in my code, requesting GPIOs in UART 
drivers and setting up the direction. I just wanted to make sure there 
wasn't way to setup pin direction using pinmux itself.

>>                  apbx@80040000 {
>>                          auart4: serial@80072000 {
>>                                  pinctrl-names = "default", "auart";
>>                                  pinctrl-0 = <&auart4_highz_pins>;
>>                                  pinctrl-1 = <&auart4_pins_a>;
>>                                  status = "okay";
>>                          };
>>                 };
>>

Thanks.
-Subodh

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can one  set GPIO direction in pinmux definition?
       [not found]         ` <503558B8.4010603-4jo+YWezP1RWk0Htik3J/w@public.gmane.org>
@ 2012-08-22 23:18           ` Stephen Warren
  2012-08-23  1:32           ` Shawn Guo
  1 sibling, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2012-08-22 23:18 UTC (permalink / raw)
  To: Subodh Nijsure
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Dong Aisheng

On 08/22/2012 04:10 PM, Subodh Nijsure wrote:
> On 08/22/2012 12:52 PM, Stephen Warren wrote:
>> On 08/22/2012 09:37 AM, Subodh Nijsure wrote:
>>> For a MX28 based hardware I am working with I need to use AUART4
>>>
>>> I need to configure this AUART4 as uart only when necessary and at all
>>> other times pins associated with AUART4 need to be configured as inputs.
>> Out of curiosity, why?
>
> Our hardware is connected to external equipment, electric meter via this
> UART.
> This electricity meter can also be read externally by an optical reader.
> Since this is a shared bus, we can't be sitting on that bus with our
> interface configured as UART as it prevents optical reader from talking
> to the meter. There are ways we can tell is optical meter is connected,
> if we detect that its connected we configure these pins as input else
> configure them for UART functionality.

OK, I guess it was something like that. Can the optical be
plugged/unplugged at run-time, or is it a one-off thing? pinctrl would
be appropriate for runtime. Maybe not so much for one-off detection at
boot-time.

I wonder whether making the UART driver do the switching is the right
thing though. I assume that:

* The UART driver can be used on systems (boards) that never have this
HW configuration, and don't care about this at all.

* The detection of optical meter presence is entirely unrelated to the UART.

So probably, the muxing can be seen as completely external and unrelated
to the UART HW module itself. Would it be better represented as a
completely standalone and custom "RS232 bus mux" node/device instead of
tacking this into the UART driver?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can one set GPIO direction in pinmux definition?
       [not found] ` <5034FCB2.5040709-4jo+YWezP1RWk0Htik3J/w@public.gmane.org>
  2012-08-22 19:52   ` Stephen Warren
@ 2012-08-23  0:17   ` Matt Sealey
  1 sibling, 0 replies; 6+ messages in thread
From: Matt Sealey @ 2012-08-23  0:17 UTC (permalink / raw)
  To: Subodh Nijsure
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Wed, Aug 22, 2012 at 10:37 AM, Subodh Nijsure <snijsure-4jo+YWezP1RWk0Htik3J/w@public.gmane.org> wrote:
>
> For a MX28 based hardware I am working with I need to use AUART4
>
> I need to configure this AUART4 as uart only when necessary and at all other
> times pins associated with AUART4 need to be configured as inputs.
>
> I am using following DT definitions to setup AUART4 mux  but can't figure
> out how to setup pin direction via DT, can it be done or I need to do it in
> C code?
>
>         apb@80000000 {
>                 apbh@80000000 {
>                                 auart4_pins_a: auart4@0 {
>                                         reg = <0>;
>                                         fsl,pinmux-ids = <
>                                                 0x3142 /*
> MX28_PAD_SAIF0_MCLK__AUART4_CTS */
>                                                 0x3152 /*
> MX28_PAD_SAIF0_LRCLK__AUART4_RTS */
>                                                 0x3162 /*
> MX28_PAD_SAIF0_BITCLK__AUART4_RX */
>                                                 0x3172 /*
> MX28_PAD_SAIF0_SDATA0__AUART4_TX */
>                                         >;
>                                         fsl,drive-strength = <0>;
>                                         fsl,voltage = <1>;
>                                         fsl,pull-up = <0>;
>                                 };
>                                 auart4_highz_pins: auart4-gpio@0 {
>                                         reg = <0>;
>                                         fsl,pinmux-ids = <
>                                                 0x3143 /*
> MX28_PAD_SAIF0_MCLK__GPIO_3_20 */
>                                                 0x3153 /*
> MX28_PAD_SAIF0_LRCLK__GPIO_3_21 */
>                                                 0x3163 /*
> MX28_PAD_SAIF0_BITCLK__GPIO_3_22 */
>                                                 0x3173 /*
> MX28_PAD_SAIF0_SDATA0__GPIO_3_23 */
>                                         >;
>                                         fsl,drive-strength = <0>;
>                                         fsl,voltage = <1>;
>                                         fsl,pull-up = <0>;
>                                 };
>                  };
>           };
>
>                 apbx@80040000 {
>                         auart4: serial@80072000 {
>                                 pinctrl-names = "default", "auart";
>                                 pinctrl-0 = <&auart4_highz_pins>;
>                                 pinctrl-1 = <&auart4_pins_a>;
>                                 status = "okay";
>                         };
>                };

Those pin definitions are defined per-device but they're parsed at
module init - so you'd load uart, then your gpio stuff and your uart
would stop working as it's input paths would have moved in the iomux
controller. Until you unloaded the gpio and uart drivers, then loaded
the right one. I am guessing you don't want to be forcibly loading and
unloading drivers just to swap modes.

Someone did some kind of external bus muxing implementation
("extbus"?) a while back which could sort this out; it's since lost in
time and space, or at least I can't figure out the terms I need to
Google to recover it or how I saved my bookmark. You'd have to
(re-)write the drivers to support the switch (i.e. dynamically parse
pinctrl nodes for the swap or pass them by reference to the muxing
implementation) and stop "working" while the other is in use, but I
feel like I remember that only really supported the case where you had
multiple potential plugin boards at boot (not hotpluggable).

In order to set the directions you'd need to define them in a
driver-specific way, but IMO there needs to be a binding that
configures gpio directions anyway since there's not one currently
which is perplexing - for interrupt-capable GPIO sources it is
implicit through the gpio interrupt domain, but for just inputs you
can read, you have to rely on the bootloader setting it up and your
driver knowing exactly what to do..

-- 
Matt Sealey <matt-sEEEE4iEDtaXzmuOJsdVMQ@public.gmane.org>
Product Development Analyst, Genesi USA, Inc.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can one  set GPIO direction in pinmux definition?
       [not found]         ` <503558B8.4010603-4jo+YWezP1RWk0Htik3J/w@public.gmane.org>
  2012-08-22 23:18           ` Stephen Warren
@ 2012-08-23  1:32           ` Shawn Guo
  1 sibling, 0 replies; 6+ messages in thread
From: Shawn Guo @ 2012-08-23  1:32 UTC (permalink / raw)
  To: Subodh Nijsure
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Dong Aisheng,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Wed, Aug 22, 2012 at 03:10:00PM -0700, Subodh Nijsure wrote:
> Right now that is what I am doing in my code, requesting GPIOs in
> UART drivers and setting up the direction. I just wanted to make
> sure there wasn't way to setup pin direction using pinmux itself.
> 
No, there is no way for pinctrl driver to set up gpio direction, which
is completely gpio driver's job.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-23  1:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-22 15:37 Can one set GPIO direction in pinmux definition? Subodh Nijsure
     [not found] ` <5034FCB2.5040709-4jo+YWezP1RWk0Htik3J/w@public.gmane.org>
2012-08-22 19:52   ` Stephen Warren
     [not found]     ` <5035388D.2060909-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-08-22 22:10       ` Subodh Nijsure
     [not found]         ` <503558B8.4010603-4jo+YWezP1RWk0Htik3J/w@public.gmane.org>
2012-08-22 23:18           ` Stephen Warren
2012-08-23  1:32           ` Shawn Guo
2012-08-23  0:17   ` Matt Sealey

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).