linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dvorkin Dmitry <dvorkin@tibbo.com>
To: Linus Walleij <linus.walleij@linaro.org>, Wells Lu <wellslutw@gmail.com>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	robh+dt@kernel.org, devicetree@vger.kernel.org,
	qinjian@cqplus1.com
Subject: Re: [PATCH 3/3] devicetree: bindings: pinctrl: Add bindings doc for Sunplus SP7021.
Date: Thu, 18 Nov 2021 15:20:26 +0300	[thread overview]
Message-ID: <b88855af-bdbe-2894-f7ac-c1ea9dba87e4@tibbo.com> (raw)
In-Reply-To: <f315d79da3e742b4a4ec0131d6035046@sphcmbx02.sunplus.com.tw>

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

Dear Linus!

I am the person who wrote this driver. Let me answer to your questions...

-----Original Message-----
>> From: Linus Walleij <linus.walleij@linaro.org>
>> Sent: Tuesday, November 9, 2021 12:00 PM
>> To: Wells Lu <wellslutw@gmail.com>
>> Cc: linux-gpio@vger.kernel.org; linux-kernel@vger.kernel.org;
>> robh+dt@kernel.org; devicetree@vger.kernel.org; qinjian@cqplus1.com;
>> dvorkin@tibbo.com; Wells Lu 呂芳騰 <wells.lu@sunplus.com>
>> Subject: Re: [PATCH 3/3] devicetree: bindings: pinctrl: Add bindings doc for
>> Sunplus SP7021.
>>
>>
>>> +        zero_func:
>>> +          description: |
>>> +            Disabled pins which are not used by pinctrl node's client
>> device.
>>> +          $ref: /schemas/types.yaml#/definitions/uint32-array
>> I have never seen this before. Can't you just use pin control hogs for this so the
>> pin controller just take care of these pins?

zero_func is required.

The bootloader may have different device tree (I am using general sp7021 
DTS in my u-boot setup, for example), while the kernel DTS may be 
changed between boots and specifies it more precisely - it is configured 
by user. So u-boot DTB and kernel DTB may be different -> result is that 
some pins may be muxed wrongly after u-boot starts kernel. Or even in 
pre-u-boot stage (we have the bootloader that starts u-boot, called 
XBoot). This XBoot also do some muxing. So we need this feature to get 
rid of possible unneded muxes done before kernel has been started.

There is the "group of pins" functions and individual pins that may 
intersect.

You may have "group of pins", say, emmc preconfigured before kernel 
started (in general DTS for u-boot) and you may want to have the pin 
from emmc group to be muxed as, say, SD card detect. You mux it in 
kernel DTS as GPIO, it will be in correct GPIO state, configured 
correctly, but while emmc group is enabled (nobody disabled it in kernel 
DTS!) the pin will belong to emmc function (preset group) and will not 
be functional.

I invented zero_func while has been debugging the problem like "why my 
Eth is not working when all pins are configured correctly and muxed to 
Eth". I spend some time to find that the pin I muxed to Eth has been 
muxed to SPI_FLASH GROUP in very early stage (in ROM boot). And I have 
no way to cleanup this mux group easily.

zero_func is the way to easily guarantee that you will successfully and 
correctly mux some pins / functions on kernel load even if somebody 
muxed other pins to this functions before kernel.

If I'd implement "automatic" mux cleanup before muxing some pin, the 
code would be more complex. I would like to keep code as simple as I can 
and give better control to user.


>>
>>> +      allOf:
>>> +        - if:
>>> +            properties:
>>> +              function:
>>> +                enum:
>>> +                  - SPI_FLASH
>>> +          then:
>>> +            properties:
>>> +              groups:
>>> +                enum:
>>> +                  - SPI_FLASH1
>>> +                  - SPI_FLASH2
>>> +        - if:
>>> +            properties:
>>> +              function:
>>> +                enum:
>>> +                  - SPI_FLASH_4BIT
>>> +          then:
>>> +            properties:
>>> +              groups:
>>> +                enum:
>>> +                  - SPI_FLASH_4BIT1
>>> +                  - SPI_FLASH_4BIT2
>>> +        - if:
>>> +            properties:
>>> +              function:
>>> +                enum:
>>> +                  - HDMI_TX
>>> +          then:
>>> +            properties:
>>> +              groups:
>>> +                enum:
>>> +                  - HDMI_TX1
>>> +                  - HDMI_TX2
>>> +                  - HDMI_TX3
>>> +        - if:
>>> +            properties:
>>> +              function:
>>> +                enum:
>>> +                  - LCDIF
>>> +          then:
>>> +            properties:
>>> +              groups:
>>> +                enum:
>>> +                  - LCDIF
>>>
>>> This looks complex to me, I need feedback from bindings people on this.

sp7021 supports two types of muxes:

1) group muxing (1-N sets of predefined pins for some function)

2) individual pin muxing

Some functions may be muxed only in group, like SPI_FLASH or HDMI.

That's why we have

pins = <...>;

and

function = <funcname>;

group = <funcsubname-group>;

second case could be cuted to

function = <funcsubname-group> only;

But I think, the syntax of a pair {function,group} fits SoC logic 
better. Especially if customer is reading possible muxes table for the chip.


>>>
>>> +        pins_uart0: pins_uart0 {
>>> +            function = "UA0";
>>> +            groups = "UA0";
>>> +        };
>>> +
>>> +        pins_uart1: pins_uart1 {
>>> +            pins = <
>>> +
>> SPPCTL_IOPAD(11,SPPCTL_PCTL_G_PMUX,MUXF_UA1_TX,0)
>>> +
>> SPPCTL_IOPAD(10,SPPCTL_PCTL_G_PMUX,MUXF_UA1_RX,0)
>>> +
>> SPPCTL_IOPAD(7,SPPCTL_PCTL_G_GPIO,0,SPPCTL_PCTL_L_OUT)
>>> +            >;
>>> +        };
>> This first looks like two ways to do the same thing?
>> UART0 uses strings for group + function and uart1 control individual pins.
>>
>> Is it possible to just do it one way?
>>
>> I think the pins = <...> scheme includes also multiplexing settings and then it
>> should be named pinmux = <...>:
No. Sorry. It is two different way of supported two different types of 
muxing, described above.
>>
>> Please read
>> Documentation/devicetree/bindings/pinctrl/pinmux-node.yaml
>> closely.
>>
>> Yours,
>> Linus Walleij

[-- Attachment #2: dvorkin.vcf --]
[-- Type: text/x-vcard, Size: 391 bytes --]

BEGIN:VCARD
VERSION:4.0
EMAIL;PREF=1:dvorkin@tibbo.com
EMAIL:dvorkindmitry@gmail.com
FN:Dmitry Dvorkin
NICKNAME:dv
ORG:Tibbo Technology Inc.;
TITLE:Embedded Linux Architect
N:Dvorkin;Dmitry;;;
ADR:;;9F-3\, No.31, Lane 169, Kang-Ning St., Hsi-Chih;New Taipei City;;2218
 0;Taiwan
TEL;VALUE=TEXT:+79190546388
URL;VALUE=URL:https://tibbo.com/
UID:1c58210f-ac8c-4337-b391-0bde146d2d83
END:VCARD

  parent reply	other threads:[~2021-11-18 12:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27  8:55 [PATCH 0/3] Add pin control driver for Sunplus SP7021 SoC Wells Lu
2021-10-27  8:55 ` [PATCH 1/3] pinctrl: Add driver for Sunplus SP7021 Wells Lu
2021-10-27 22:12   ` Randy Dunlap
2021-10-29  3:40     ` Wells Lu 呂芳騰
2021-10-29  4:38       ` Randy Dunlap
2021-10-27  8:55 ` [PATCH 2/3] dt-bindings: pinctrl: Add dt-bindings " Wells Lu
2021-10-27  8:55 ` [PATCH 3/3] devicetree: bindings: pinctrl: Add bindings doc " Wells Lu
2021-11-09  3:59   ` Linus Walleij
     [not found]     ` <f315d79da3e742b4a4ec0131d6035046@sphcmbx02.sunplus.com.tw>
2021-11-18 12:20       ` Dvorkin Dmitry [this message]
2021-11-01  8:11 ` [PATCH v2 0/3] This is a patch series for pinctrl driver for Sunplus SP7021 SoC Wells Lu
2021-11-01  8:11   ` [PATCH v2 1/3] pinctrl: Add driver for Sunplus SP7021 Wells Lu
2021-11-09  4:30     ` Linus Walleij
2021-11-17  8:35       ` Wells Lu 呂芳騰
2021-11-01  8:11   ` [PATCH v2 2/3] dt-bindings: pinctrl: Add dt-bindings " Wells Lu
2021-11-12 15:37     ` Rob Herring
2021-11-18  9:03       ` Wells Lu 呂芳騰
2021-11-01  8:11   ` [PATCH v2 3/3] devicetree: bindings: pinctrl: Add bindings doc " Wells Lu
2021-11-12 15:40     ` Rob Herring
2021-11-18  9:15       ` Wells Lu 呂芳騰

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=b88855af-bdbe-2894-f7ac-c1ea9dba87e4@tibbo.com \
    --to=dvorkin@tibbo.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qinjian@cqplus1.com \
    --cc=robh+dt@kernel.org \
    --cc=wellslutw@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).