diff mbox

mmc: dt: Add 'broken-cd' DT binding

Message ID 1345547371-6784-1-git-send-email-thomas.abraham@linaro.org
State New
Headers show

Commit Message

thomas.abraham@linaro.org Aug. 21, 2012, 11:09 a.m. UTC
'broken-cd' binding lets mmc controller device node to indicate that
the card detect line is broken.

Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
---
The 'broken-cd' DT binding for MMC controllers is picked up from the OLPC
project git repo and was originally conceived by Chris Ball <cjb@laptop.org>.

 Documentation/devicetree/bindings/mmc/mmc.txt |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Arnd Bergmann Aug. 21, 2012, 11:01 a.m. UTC | #1
On Tuesday 21 August 2012, Thomas Abraham wrote:
> diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt b/Documentation/devicetree/bindings/mmc/mmc.txt
> index 8a6811f..1aa527a 100644
> --- a/Documentation/devicetree/bindings/mmc/mmc.txt
> +++ b/Documentation/devicetree/bindings/mmc/mmc.txt
> @@ -16,6 +16,8 @@ Optional properties:
>  - wp-inverted: when present, polarity on the wp gpio line is inverted
>  - non-removable: non-removable slot (like eMMC)
>  - max-frequency: maximum operating clock frequency
> +- broken-cd: when present, indicates that the cd-gpios line is not
> +       connected to the card-detect pad of the MMC host controller.

What is the difference between listing the cd line as broken and
listing no cd line at all?

	Arnd
thomas.abraham@linaro.org Aug. 21, 2012, 11:14 a.m. UTC | #2
On 21 August 2012 16:31, Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Tuesday 21 August 2012, Thomas Abraham wrote:
> > diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt
> > b/Documentation/devicetree/bindings/mmc/mmc.txt
> > index 8a6811f..1aa527a 100644
> > --- a/Documentation/devicetree/bindings/mmc/mmc.txt
> > +++ b/Documentation/devicetree/bindings/mmc/mmc.txt
> > @@ -16,6 +16,8 @@ Optional properties:
> >  - wp-inverted: when present, polarity on the wp gpio line is inverted
> >  - non-removable: non-removable slot (like eMMC)
> >  - max-frequency: maximum operating clock frequency
> > +- broken-cd: when present, indicates that the cd-gpios line is not
> > +       connected to the card-detect pad of the MMC host controller.
>
> What is the difference between listing the cd line as broken and
> listing no cd line at all?

I am trying to have a way to represent a gpio line as card detect line
that is not connected to the card-detect pad of the mmc controller but
instead used as a gpio interrupt line or polled gpio line.

'broken-cd' would imply that the card-detect pad of the mmc controller
is not connected to the card-detect pin at the slot. The 'cd-gpios'
property in that case would let the driver code to use the 'cd-gpios'
line as the external gpio interrupt or poll it.

Thanks,
Thomas.

>
>         Arnd
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-samsung-soc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chris Ball Aug. 21, 2012, 11:56 a.m. UTC | #3
Hi,

On Tue, Aug 21 2012, Thomas Abraham wrote:
> I am trying to have a way to represent a gpio line as card detect line
> that is not connected to the card-detect pad of the mmc controller but
> instead used as a gpio interrupt line or polled gpio line.
>
> 'broken-cd' would imply that the card-detect pad of the mmc controller
> is not connected to the card-detect pin at the slot. The 'cd-gpios'
> property in that case would let the driver code to use the 'cd-gpios'
> line as the external gpio interrupt or poll it.

How about this?

broken-cd: No CD available, use polling.

cd-gpios: The CD pin on the host is working and brought out to a GPIO.

external-cd-gpios: The CD pin on the host is broken, but there's an
                   independent external GPIO available.


(Each host should only have one of these properties.)
                   
Thanks,

- Chris.
Arnd Bergmann Aug. 21, 2012, 12:08 p.m. UTC | #4
On Tuesday 21 August 2012, Chris Ball wrote:
> How about this?
> 
> broken-cd: No CD available, use polling.
> 
> cd-gpios: The CD pin on the host is working and brought out to a GPIO.
> 
> external-cd-gpios: The CD pin on the host is broken, but there's an
>                    independent external GPIO available.
> 
> 
> (Each host should only have one of these properties.)

The fsl-imx-esdhc.txt binding already has all three cases, but
describes them differently:

fsl,cd-internal: when present, the CD pin on the host is working
cd-gpios: when present, contains the gpio line that CD is connected to
If both are absent, it has to use polling.

	Arnd
thomas.abraham@linaro.org Aug. 21, 2012, 12:30 p.m. UTC | #5
On 21 August 2012 17:26, Chris Ball <cjb@laptop.org> wrote:
> Hi,
>
> On Tue, Aug 21 2012, Thomas Abraham wrote:
>> I am trying to have a way to represent a gpio line as card detect line
>> that is not connected to the card-detect pad of the mmc controller but
>> instead used as a gpio interrupt line or polled gpio line.
>>
>> 'broken-cd' would imply that the card-detect pad of the mmc controller
>> is not connected to the card-detect pin at the slot. The 'cd-gpios'
>> property in that case would let the driver code to use the 'cd-gpios'
>> line as the external gpio interrupt or poll it.
>
> How about this?
>
> broken-cd: No CD available, use polling.
>
> cd-gpios: The CD pin on the host is working and brought out to a GPIO.
>
> external-cd-gpios: The CD pin on the host is broken, but there's an
>                    independent external GPIO available.
>
>
> (Each host should only have one of these properties.)

How about a property using 'cd-external' property in place of
'external-cd-gpios'.  'cd-external' would mean that the gpio listed by
'cd-gpios' is a gpio line which is not connected the card-detect pad
of the mmc controller.

This can simplfy the dt parsing code since it is required to look for
only one gpio property, which is 'cd-gpios' which implies lesser error
handling code. 'cd-external' can qualify it further as an external cd
pin.

Either way, I am fine with the binding you have proposed. If you post
a patch for these new bindings, I will base the sdhci-s3c dt patch on
top of that patch.

Thanks,
Thomas.
Rob Herring Aug. 21, 2012, 2:21 p.m. UTC | #6
On 08/21/2012 07:08 AM, Arnd Bergmann wrote:
> On Tuesday 21 August 2012, Chris Ball wrote:
>> How about this?
>>
>> broken-cd: No CD available, use polling.
>>
>> cd-gpios: The CD pin on the host is working and brought out to a GPIO.
>>
>> external-cd-gpios: The CD pin on the host is broken, but there's an
>>                    independent external GPIO available.
>>
>>
>> (Each host should only have one of these properties.)
> 
> The fsl-imx-esdhc.txt binding already has all three cases, but
> describes them differently:
> 
> fsl,cd-internal: when present, the CD pin on the host is working
> cd-gpios: when present, contains the gpio line that CD is connected to
> If both are absent, it has to use polling.

This makes the most sense to me. However, I prefer broken-cd over
cd-internal. The binding should add properties for exceptions, not SDHCI
spec compliant implementations.

Rob
Chris Ball Aug. 21, 2012, 2:48 p.m. UTC | #7
Hi, adding Shawn and Wolfram,

On Tue, Aug 21 2012, Arnd Bergmann wrote:
> On Tuesday 21 August 2012, Chris Ball wrote:
>> How about this?
>> 
>> broken-cd: No CD available, use polling.
>> 
>> cd-gpios: The CD pin on the host is working and brought out to a GPIO.
>> 
>> external-cd-gpios: The CD pin on the host is broken, but there's an
>>                    independent external GPIO available.
>> 
>> 
>> (Each host should only have one of these properties.)
>
> The fsl-imx-esdhc.txt binding already has all three cases, but
> describes them differently:
>
> fsl,cd-internal: when present, the CD pin on the host is working
> cd-gpios: when present, contains the gpio line that CD is connected to
> If both are absent, it has to use polling.

Aside: the bindings do not match the code.  The bindings document says
to use "fsl,cd-internal", and imx51-babbage.dts does so -- but the code
doesn't check for "fsl,cd-internal", it checks for "fsl,cd-controller":

        if (of_get_property(np, "fsl,cd-controller", NULL))
                boarddata->cd_type = ESDHC_CD_CONTROLLER;

The same confusion is present for fsl,wp-{controller,internal}.

Ignoring that, these bindings are similar, but not the same -- imx-esdhc
only allows one of the cd_type cases to be true, so you either have
cd-internal or you have cd-gpios:

        if (of_get_property(np, "fsl,cd-controller", NULL))
                boarddata->cd_type = ESDHC_CD_CONTROLLER;

        boarddata->cd_gpio = of_get_named_gpio(np, "cd-gpios", 0);
        if (gpio_is_valid(boarddata->cd_gpio))
                boarddata->cd_type = ESDHC_CD_GPIO;

This differs from Thomas's binding -- he wants a way to say "the cd-gpio
mentioned in cd-gpios is [internal/external] to the card's CD pin".

Rob Herring said:
> This makes the most sense to me. However, I prefer broken-cd over
> cd-internal. The binding should add properties for exceptions, not SDHCI
> spec compliant implementations.

Agreed, I was going to say the same thing.  Putting it all together, it
sounds like we want:

no extra properties:  the CD pin on the host just works.
broken-cd:            the CD pin on the host is broken; use polling.
cd-gpios:             the GPIO listed is the CD pin on the host being
                      brought out directly to a GPIO.
cd-external:          when used with cd-gpios, specifies that the GPIO
                      in cd-gpios is external to the CD pin on the host.

cd-gpios and cd-external can be present on the same node.  if broken-cd
is present, it must be the only one of these nodes used.

Shawn, I guess I'll leave it up to you on whether/when you'd like to
move away from the "fsl," properties to the new common ones?

If this looks okay to everyone, I'll send a patch soon.

Thanks!

- Chris.
Rob Herring Aug. 21, 2012, 3:03 p.m. UTC | #8
On 08/21/2012 09:48 AM, Chris Ball wrote:
> Hi, adding Shawn and Wolfram,

snip...

> Rob Herring said:
>> This makes the most sense to me. However, I prefer broken-cd over
>> cd-internal. The binding should add properties for exceptions, not SDHCI
>> spec compliant implementations.
> 
> Agreed, I was going to say the same thing.  Putting it all together, it
> sounds like we want:
> 
> no extra properties:  the CD pin on the host just works.
> broken-cd:            the CD pin on the host is broken; use polling.
> cd-gpios:             the GPIO listed is the CD pin on the host being
>                       brought out directly to a GPIO.
> cd-external:          when used with cd-gpios, specifies that the GPIO
>                       in cd-gpios is external to the CD pin on the host.
> 
> cd-gpios and cd-external can be present on the same node.  if broken-cd
> is present, it must be the only one of these nodes used.

I don't see the point of cd-external. Either you just use the CD
interrupt defined within the SDHCI or you have a gpio line independent
of the SDHCI and use cd-gpios.

Rob
Chris Ball Aug. 21, 2012, 3:18 p.m. UTC | #9
Hi,

On Tue, Aug 21 2012, Rob Herring wrote:
>> cd-gpios and cd-external can be present on the same node.  if broken-cd
>> is present, it must be the only one of these nodes used.
>
> I don't see the point of cd-external. Either you just use the CD
> interrupt defined within the SDHCI or you have a gpio line independent
> of the SDHCI and use cd-gpios.

You've described two of the possible cases, but not the third.  In the
third case, you have a gpio line that is not independent of the SDHCI,
because it is the SDHCI's CD pin brought out to be directly accessible
via a GPIO.

The difference is in the handling of the interrupt -- if you don't have
"cd-external" then you're just using the SDHCI's interrupt, but if you
have an independent line then you're going to need to register your own
IRQ handler on it, and "cd-external" signifies that.

Thomas wrote this explanation earlier in the thread:
> "samsung,sdhci-cd-gpio" means that the cd-gpio line is not connected
> to the card-detect pad of the sdhci controller. Instead, it identifies
> cd-gpio as a gpio pin, connected to the card-detect pin of the "card
> slot" and it can used as a source of external interrupt. The driver
> can register card insert/remove handler for this interrupt and get
> notified about the changes in card state.
> 
> "sdhci-cd-internal" means that the "cd-gpio" line is used to connect
> the card-detect pin of the card slot and the card-detect pad of the
> sdhci controller. The controller is then aware of any changes in card
> state and the controller generates appropriate interrupts to notify
> changes in card-state.

Thanks,

- Chris.
thomas.abraham@linaro.org Aug. 21, 2012, 3:21 p.m. UTC | #10
On 21 August 2012 20:33, Rob Herring <robherring2@gmail.com> wrote:
> On 08/21/2012 09:48 AM, Chris Ball wrote:
>> Hi, adding Shawn and Wolfram,
>
> snip...
>
>> Rob Herring said:
>>> This makes the most sense to me. However, I prefer broken-cd over
>>> cd-internal. The binding should add properties for exceptions, not SDHCI
>>> spec compliant implementations.
>>
>> Agreed, I was going to say the same thing.  Putting it all together, it
>> sounds like we want:
>>
>> no extra properties:  the CD pin on the host just works.
>> broken-cd:            the CD pin on the host is broken; use polling.
>> cd-gpios:             the GPIO listed is the CD pin on the host being
>>                       brought out directly to a GPIO.
>> cd-external:          when used with cd-gpios, specifies that the GPIO
>>                       in cd-gpios is external to the CD pin on the host.
>>
>> cd-gpios and cd-external can be present on the same node.  if broken-cd
>> is present, it must be the only one of these nodes used.
>
> I don't see the point of cd-external. Either you just use the CD
> interrupt defined within the SDHCI or you have a gpio line independent
> of the SDHCI and use cd-gpios.

There should be way to distinguish between the two types of 'cd-gpios' value.

(A) a 'cd-gpios' line that connects the card-detect pin of the mmc
physical slot to the card-detect pad to the mmc host controller.

(B) a 'cd-gpios' line that is connected to the card-detect pin of the
slot but not to the card-detect pad of the mmc host controller (used
either as gpio interrupt or polled gpio line).

So the binding 'cd-external' can act as an additional qualifier to
value of 'cd-gpios' to represent the second type. Hence, the bindings
proposed by Chris does support all the possible combinations of
card-detection used by the Samsung sdhci controller driver.

Thanks,
Thomas.





>
> Rob
>
Rob Herring Aug. 21, 2012, 4:01 p.m. UTC | #11
On 08/21/2012 10:18 AM, Chris Ball wrote:
> Hi,
> 
> On Tue, Aug 21 2012, Rob Herring wrote:
>>> cd-gpios and cd-external can be present on the same node.  if broken-cd
>>> is present, it must be the only one of these nodes used.
>>
>> I don't see the point of cd-external. Either you just use the CD
>> interrupt defined within the SDHCI or you have a gpio line independent
>> of the SDHCI and use cd-gpios.
> 
> You've described two of the possible cases, but not the third.  In the
> third case, you have a gpio line that is not independent of the SDHCI,
> because it is the SDHCI's CD pin brought out to be directly accessible
> via a GPIO.

That is covered by absence of cd-gpios and broken-cd. Any *-gpios
property means the signal is a GPIO line controlled by a GPIO controller.

I suppose you could have the CD state readable via the SDHCI, but the
interrupt comes from a GPIO controller. Or vice-versa, but that's a
pretty broken use case if you can't pick which way you are going to use
things.

> 
> The difference is in the handling of the interrupt -- if you don't have
> "cd-external" then you're just using the SDHCI's interrupt, but if you
> have an independent line then you're going to need to register your own
> IRQ handler on it, and "cd-external" signifies that.
> 
> Thomas wrote this explanation earlier in the thread:
>> "samsung,sdhci-cd-gpio" means that the cd-gpio line is not connected
>> to the card-detect pad of the sdhci controller. Instead, it identifies
>> cd-gpio as a gpio pin, connected to the card-detect pin of the "card
>> slot" and it can used as a source of external interrupt. The driver
>> can register card insert/remove handler for this interrupt and get
>> notified about the changes in card state.
>>
>> "sdhci-cd-internal" means that the "cd-gpio" line is used to connect
>> the card-detect pin of the card slot and the card-detect pad of the
>> sdhci controller. The controller is then aware of any changes in card
>> state and the controller generates appropriate interrupts to notify
>> changes in card-state.
> 

It seems you are mixing pin muxing and who controls/handles the CD
detect signal. Pin muxing is a separate issue and should be addressed by
pin mux bindings. Either the signal functions as a GPIO or it functions
as a CD as part of the SDHCI. You may have muxing on the CD pin that
allows it to function either way, but the DT binding should describe how
you want it to be configured and used.

Rob

> Thanks,
> 
> - Chris.
>
thomas.abraham@linaro.org Aug. 21, 2012, 5:33 p.m. UTC | #12
On 21 August 2012 21:31, Rob Herring <robherring2@gmail.com> wrote:
> On 08/21/2012 10:18 AM, Chris Ball wrote:
>> Hi,
>>
>> On Tue, Aug 21 2012, Rob Herring wrote:
>>>> cd-gpios and cd-external can be present on the same node.  if broken-cd
>>>> is present, it must be the only one of these nodes used.
>>>
>>> I don't see the point of cd-external. Either you just use the CD
>>> interrupt defined within the SDHCI or you have a gpio line independent
>>> of the SDHCI and use cd-gpios.
>>
>> You've described two of the possible cases, but not the third.  In the
>> third case, you have a gpio line that is not independent of the SDHCI,
>> because it is the SDHCI's CD pin brought out to be directly accessible
>> via a GPIO.
>
> That is covered by absence of cd-gpios and broken-cd. Any *-gpios
> property means the signal is a GPIO line controlled by a GPIO controller.
>
> I suppose you could have the CD state readable via the SDHCI, but the
> interrupt comes from a GPIO controller. Or vice-versa, but that's a
> pretty broken use case if you can't pick which way you are going to use
> things.
>
>>
>> The difference is in the handling of the interrupt -- if you don't have
>> "cd-external" then you're just using the SDHCI's interrupt, but if you
>> have an independent line then you're going to need to register your own
>> IRQ handler on it, and "cd-external" signifies that.
>>
>> Thomas wrote this explanation earlier in the thread:
>>> "samsung,sdhci-cd-gpio" means that the cd-gpio line is not connected
>>> to the card-detect pad of the sdhci controller. Instead, it identifies
>>> cd-gpio as a gpio pin, connected to the card-detect pin of the "card
>>> slot" and it can used as a source of external interrupt. The driver
>>> can register card insert/remove handler for this interrupt and get
>>> notified about the changes in card state.
>>>
>>> "sdhci-cd-internal" means that the "cd-gpio" line is used to connect
>>> the card-detect pin of the card slot and the card-detect pad of the
>>> sdhci controller. The controller is then aware of any changes in card
>>> state and the controller generates appropriate interrupts to notify
>>> changes in card-state.
>>
>
> It seems you are mixing pin muxing and who controls/handles the CD
> detect signal. Pin muxing is a separate issue and should be addressed by
> pin mux bindings. Either the signal functions as a GPIO or it functions
> as a CD as part of the SDHCI. You may have muxing on the CD pin that
> allows it to function either way, but the DT binding should describe how
> you want it to be configured and used.

Ok, I agree with Rob. I was mixing pin muxing here. So if we have
'cd-gpios' and 'broken-cd' as generic bindings, would the following be
valid?

[A] cd-gpios not present ,  broken-cd not present : This means that
there is no card detect pin available. Controller drivers are free to
infer this as "card detection is broken" and use implementation
specific behavior.

[B] cd-gpio not present , broken-cd present :  This means that there
is nothing connected to the card-detect pad of the mmc host
controller. Controller drivers are free to use implementation specific
behavior to deal with card detection.

[C] cd-gpio present, broken-cd not present : This means that 'cd-gpio'
line connects card-detect pad of the controller to the card-detect pin
of the mmc slot.

[D] cd-gpio present, broken-cd present : This means that there is
nothing connected to the card-detect pad of the mmc host controller.
Controller drivers are free to use the 'cd-gpio' line in any
implementation specific way.

Thanks,
Thomas.
Shawn Guo Aug. 22, 2012, 5:51 a.m. UTC | #13
On Tue, Aug 21, 2012 at 11:03:59PM +0530, Thomas Abraham wrote:
> Ok, I agree with Rob. I was mixing pin muxing here. So if we have
> 'cd-gpios' and 'broken-cd' as generic bindings, would the following be
> valid?
> 
> [A] cd-gpios not present ,  broken-cd not present : This means that
> there is no card detect pin available. Controller drivers are free to
> infer this as "card detection is broken" and use implementation
> specific behavior.
> 
> [B] cd-gpio not present , broken-cd present :  This means that there
> is nothing connected to the card-detect pad of the mmc host
> controller. Controller drivers are free to use implementation specific
> behavior to deal with card detection.
> 
> [C] cd-gpio present, broken-cd not present : This means that 'cd-gpio'
> line connects card-detect pad of the controller to the card-detect pin
> of the mmc slot.
> 
> [D] cd-gpio present, broken-cd present : This means that there is
> nothing connected to the card-detect pad of the mmc host controller.
> Controller drivers are free to use the 'cd-gpio' line in any
> implementation specific way.
> 
The following is what I have on my mind.

broken-cd	cd-gpios	implication
-------------------------------------------
no		no		SDHCI CD
no		yes		GPIO CD
yes		no		NO CD / Broken CD
yes		yes		Invalid

yes: property presents
no: property does not present
Shawn Guo Aug. 22, 2012, 6 a.m. UTC | #14
On Tue, Aug 21, 2012 at 10:48:43AM -0400, Chris Ball wrote:
> Aside: the bindings do not match the code.  The bindings document says
> to use "fsl,cd-internal", and imx51-babbage.dts does so -- but the code
> doesn't check for "fsl,cd-internal", it checks for "fsl,cd-controller":
> 
>         if (of_get_property(np, "fsl,cd-controller", NULL))
>                 boarddata->cd_type = ESDHC_CD_CONTROLLER;
> 
> The same confusion is present for fsl,wp-{controller,internal}.
> 
Thanks for spotting it.  I will submit a patch to fix binding doc and
dts.

> Ignoring that, these bindings are similar, but not the same -- imx-esdhc
> only allows one of the cd_type cases to be true, so you either have
> cd-internal or you have cd-gpios:
> 
>         if (of_get_property(np, "fsl,cd-controller", NULL))
>                 boarddata->cd_type = ESDHC_CD_CONTROLLER;
> 
>         boarddata->cd_gpio = of_get_named_gpio(np, "cd-gpios", 0);
>         if (gpio_is_valid(boarddata->cd_gpio))
>                 boarddata->cd_type = ESDHC_CD_GPIO;
> 
> This differs from Thomas's binding -- he wants a way to say "the cd-gpio
> mentioned in cd-gpios is [internal/external] to the card's CD pin".
> 
> Rob Herring said:
> > This makes the most sense to me. However, I prefer broken-cd over
> > cd-internal. The binding should add properties for exceptions, not SDHCI
> > spec compliant implementations.
> 
> Agreed, I was going to say the same thing.  Putting it all together, it
> sounds like we want:
> 
> no extra properties:  the CD pin on the host just works.
> broken-cd:            the CD pin on the host is broken; use polling.
> cd-gpios:             the GPIO listed is the CD pin on the host being
>                       brought out directly to a GPIO.
> cd-external:          when used with cd-gpios, specifies that the GPIO
>                       in cd-gpios is external to the CD pin on the host.
> 
> cd-gpios and cd-external can be present on the same node.  if broken-cd
> is present, it must be the only one of these nodes used.
> 
> Shawn, I guess I'll leave it up to you on whether/when you'd like to
> move away from the "fsl," properties to the new common ones?
> 
Ok, I will move to the common one once it appears on your tree.
Chris Ball Aug. 22, 2012, 10:17 a.m. UTC | #15
Hi,

On Wed, Aug 22 2012, Shawn Guo wrote:
> The following is what I have on my mind.
>
> broken-cd	cd-gpios	implication
> -------------------------------------------
> no		no		SDHCI CD
> no		yes		GPIO CD
> yes		no		NO CD / Broken CD
> yes		yes		Invalid
>
> yes: property presents
> no: property does not present

This matches Mitch's last suggestion exactly -- I think we're all agreed
on these properties now.  The only remaining question is how to handle
the pinctrl for CD in Thomas's case.

Thanks!

- Chris.
thomas.abraham@linaro.org Aug. 22, 2012, 10:51 a.m. UTC | #16
On 22 August 2012 15:47, Chris Ball <cjb@laptop.org> wrote:
> Hi,
>
> On Wed, Aug 22 2012, Shawn Guo wrote:
>> The following is what I have on my mind.
>>
>> broken-cd     cd-gpios        implication
>> -------------------------------------------
>> no            no              SDHCI CD
>> no            yes             GPIO CD
>> yes           no              NO CD / Broken CD
>> yes           yes             Invalid
>>
>> yes: property presents
>> no: property does not present
>
> This matches Mitch's last suggestion exactly -- I think we're all agreed
> on these properties now.  The only remaining question is how to handle
> the pinctrl for CD in Thomas's case.

Hi Chris,

For sdhci-s3c driver, the 'broken-cd' and 'cd-gpios' bindings are
sufficient. But, are drivers free to use implementation specific
behavior when using these bindings. Or do we strictly adhere to the
table which Shawn has listed. For sdhci-s3c driver, I would like to
deviate from the "implication" column listed above.

On second thoughts, I now understand that gpio's terminate at the gpio
controller, not at the card-detect pad of the mmc host controller.
Those that terminate at the mmc controller pads are actually mux
functions. I do agree that the long term solution for sdhci-s3c driver
is to use the pinctrl driver.

If sdhci-s3c has to strictly adhere to the Shawn's table above, then I
prefer to postpone the device tree support in sdhci-s3c driver after
having proper support for Samsung pinctrl driver. But then, sdhci-s3c
driver is used on multiple Samsung SoC's, all of which might not get
pinctrl driver support anytime soon.

Hence, for sdhci-s3c driver, 'broken-cd' and 'cd-gpios' bindings are
sufficient, but sdhci-s3c driver should be free to use these bindings
in a implementation specific way.

Thanks,
Thomas.
Chris Ball Aug. 22, 2012, 11:08 a.m. UTC | #17
Hi Thomas,

On Wed, Aug 22 2012, Thomas Abraham wrote:
>> This matches Mitch's last suggestion exactly -- I think we're all agreed
>> on these properties now.  The only remaining question is how to handle
>> the pinctrl for CD in Thomas's case.
>
> Hi Chris,
>
> For sdhci-s3c driver, the 'broken-cd' and 'cd-gpios' bindings are
> sufficient. But, are drivers free to use implementation specific
> behavior when using these bindings. Or do we strictly adhere to the
> table which Shawn has listed. For sdhci-s3c driver, I would like to
> deviate from the "implication" column listed above.

I'd rather you use the implications described above for the names
described above; there's not much point in defining named behaviors
across the subsystem if they're actually different in each driver.

But I think you can still use driver-internal properties that change the
interpretation of those names in a documented way.  If the meaning of
cd-gpios is modified when coupled with your "samsung,sdhci-cd-external",
that's okay with me.  That should cover all the cases you need until you
migrate to using pinctrl, right?  So, you could immediately support:

none          -> currently "samsung,sdhci-cd-internal"
broken-cd     -> currently "samsung,sdhci-cd-none"
cd-gpios      -> currently "samsung,sdhci-cd-gpios"
non-removable -> currently "samsung,sdhci-cd-permanent"
cd-gpios + samsung,sdhci-cd-external -> currently "samsung,sdhci-cd-external"

How does that sound?

Thanks,

- Chris.
thomas.abraham@linaro.org Aug. 22, 2012, 12:04 p.m. UTC | #18
On 22 August 2012 16:38, Chris Ball <cjb@laptop.org> wrote:
> Hi Thomas,
>
> On Wed, Aug 22 2012, Thomas Abraham wrote:
>>> This matches Mitch's last suggestion exactly -- I think we're all agreed
>>> on these properties now.  The only remaining question is how to handle
>>> the pinctrl for CD in Thomas's case.
>>
>> Hi Chris,
>>
>> For sdhci-s3c driver, the 'broken-cd' and 'cd-gpios' bindings are
>> sufficient. But, are drivers free to use implementation specific
>> behavior when using these bindings. Or do we strictly adhere to the
>> table which Shawn has listed. For sdhci-s3c driver, I would like to
>> deviate from the "implication" column listed above.
>
> I'd rather you use the implications described above for the names
> described above; there's not much point in defining named behaviors
> across the subsystem if they're actually different in each driver.

Ok.

>
> But I think you can still use driver-internal properties that change the
> interpretation of those names in a documented way.  If the meaning of
> cd-gpios is modified when coupled with your "samsung,sdhci-cd-external",
> that's okay with me.  That should cover all the cases you need until you
> migrate to using pinctrl, right?  So, you could immediately support:
>
> none          -> currently "samsung,sdhci-cd-internal"
> broken-cd     -> currently "samsung,sdhci-cd-none"
> cd-gpios      -> currently "samsung,sdhci-cd-gpios"
> non-removable -> currently "samsung,sdhci-cd-permanent"
> cd-gpios + samsung,sdhci-cd-external -> currently "samsung,sdhci-cd-external"
>
> How does that sound?

Not quite there yet. It is not possible to leave out cd-gpios for
"samsung,sdhci-cd-internal" since the current Samsung pinmux
configuration piggybacks on gpio dt binding. Can we use the following
instead.

none               -> currently "samsung,sdhci-cd-none"
broken-cd        -> currently "samsung,sdhci-cd-none"
cd-gpios          -> currently "samsung,sdhci-cd-gpios"
non-removable -> currently "samsung,sdhci-cd-permanent"
cd-gpios + samsung,sdhci-cd-internal -> currently "samsung,sdhci-cd-internal"

Thanks Chris.

Regards,
Thomas.
Shawn Guo Aug. 22, 2012, 12:26 p.m. UTC | #19
Hi Chris,

On Tue, Aug 21, 2012 at 10:48:43AM -0400, Chris Ball wrote:
> Aside: the bindings do not match the code.  The bindings document says
> to use "fsl,cd-internal", and imx51-babbage.dts does so -- but the code
> doesn't check for "fsl,cd-internal", it checks for "fsl,cd-controller":
> 
>         if (of_get_property(np, "fsl,cd-controller", NULL))
>                 boarddata->cd_type = ESDHC_CD_CONTROLLER;
> 
> The same confusion is present for fsl,wp-{controller,internal}.
> 
I'm trying to fix the mismatch between dts and code, but seeing that
the "controller" mode has been broken for quite a while.  I just ran
a bisect and was told as below.

30832ab56c80d96cfaf5a786524f0d8c57fadfa1 is the first bad commit
commit 30832ab56c80d96cfaf5a786524f0d8c57fadfa1
Author: Todd Poynor <toddpoynor@google.com>
Date:   Tue Dec 27 15:48:46 2011 +0200

    mmc: sdhci: Always pass clock request value zero to set_clock host op

    To allow the set_clock host op to disable the SDCLK source when not
    needed, always call the host op when the requested clock speed is
    zero.  Do this even if host->clock already equals zero, because
    the SDHCI driver may set that value (without calling the host op)
    to force an update at the next (non-zero-speed) call.

    Signed-off-by: Todd Poynor <toddpoynor@google.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Signed-off-by: Chris Ball <cjb@laptop.org>

Reverting the commit will get "controller" mode back to work.
Chris Ball Aug. 22, 2012, 1:54 p.m. UTC | #20
Hi Shawn,

On Wed, Aug 22 2012, Shawn Guo wrote:
>     mmc: sdhci: Always pass clock request value zero to set_clock host op
>
>     To allow the set_clock host op to disable the SDCLK source when not
>     needed, always call the host op when the requested clock speed is
>     zero.  Do this even if host->clock already equals zero, because
>     the SDHCI driver may set that value (without calling the host op)
>     to force an update at the next (non-zero-speed) call.
>
>     Signed-off-by: Todd Poynor <toddpoynor@google.com>
>     Acked-by: Adrian Hunter <adrian.hunter@intel.com>
>     Signed-off-by: Chris Ball <cjb@laptop.org>
>
> Reverting the commit will get "controller" mode back to work.

Weird; I wonder how that's related to card detection.

I'm afraid it's ultimately a driver bug -- esdhc should be able to
handle having set_clock called with a value of 0.  It seems to have
a case in esdhc_set_clock() for 0, so I'm surprised it's not working.

What's the symptom of the failure?  Can you debug some more?

Thanks,

- Chris.
Chris Ball Aug. 22, 2012, 2:54 p.m. UTC | #21
Hi Thomas,

On Wed, Aug 22 2012, Thomas Abraham wrote:
>> none          -> currently "samsung,sdhci-cd-internal"
>> broken-cd     -> currently "samsung,sdhci-cd-none"
>> cd-gpios      -> currently "samsung,sdhci-cd-gpios"
>> non-removable -> currently "samsung,sdhci-cd-permanent"
>> cd-gpios + samsung,sdhci-cd-external -> currently "samsung,sdhci-cd-external"
>>
>> How does that sound?
>
> Not quite there yet. It is not possible to leave out cd-gpios for
> "samsung,sdhci-cd-internal" since the current Samsung pinmux
> configuration piggybacks on gpio dt binding. Can we use the following
> instead.
>
> none               -> currently "samsung,sdhci-cd-none"
> broken-cd        -> currently "samsung,sdhci-cd-none"
> cd-gpios          -> currently "samsung,sdhci-cd-gpios"
> non-removable -> currently "samsung,sdhci-cd-permanent"
> cd-gpios + samsung,sdhci-cd-internal -> currently "samsung,sdhci-cd-internal"

I see.  Okay; unless anyone has better ideas, it sounds like you should
go ahead and do that -- with something like this in your binding docs:

"This binding differs from the core MMC binding by requiring a cd-gpios
property to be present to use internal card-detection.  If no cd-gpios
are present (and "non-removable" is missing) the driver will poll for
card-detection as if a "broken-cd" property was provided."

I'll send out the new core bindings doc shortly.  Finishing off another
thread -- the "samsung-sdhci.txt" name is okay.

Thanks,

- Chris.
thomas.abraham@linaro.org Aug. 22, 2012, 2:59 p.m. UTC | #22
On 22 August 2012 20:24, Chris Ball <cjb@laptop.org> wrote:
> Hi Thomas,
>
> On Wed, Aug 22 2012, Thomas Abraham wrote:
>>> none          -> currently "samsung,sdhci-cd-internal"
>>> broken-cd     -> currently "samsung,sdhci-cd-none"
>>> cd-gpios      -> currently "samsung,sdhci-cd-gpios"
>>> non-removable -> currently "samsung,sdhci-cd-permanent"
>>> cd-gpios + samsung,sdhci-cd-external -> currently "samsung,sdhci-cd-external"
>>>
>>> How does that sound?
>>
>> Not quite there yet. It is not possible to leave out cd-gpios for
>> "samsung,sdhci-cd-internal" since the current Samsung pinmux
>> configuration piggybacks on gpio dt binding. Can we use the following
>> instead.
>>
>> none               -> currently "samsung,sdhci-cd-none"
>> broken-cd        -> currently "samsung,sdhci-cd-none"
>> cd-gpios          -> currently "samsung,sdhci-cd-gpios"
>> non-removable -> currently "samsung,sdhci-cd-permanent"
>> cd-gpios + samsung,sdhci-cd-internal -> currently "samsung,sdhci-cd-internal"
>
> I see.  Okay; unless anyone has better ideas, it sounds like you should
> go ahead and do that -- with something like this in your binding docs:

Ok.

>
> "This binding differs from the core MMC binding by requiring a cd-gpios
> property to be present to use internal card-detection.  If no cd-gpios
> are present (and "non-removable" is missing) the driver will poll for
> card-detection as if a "broken-cd" property was provided."
>
> I'll send out the new core bindings doc shortly.  Finishing off another
> thread -- the "samsung-sdhci.txt" name is okay.

Thanks Chris for your time on this subject. I will prepare the
sdhci-s3c dt support patch on top of your new core bindings patch.

Thanks,
Thomas.
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt b/Documentation/devicetree/bindings/mmc/mmc.txt
index 8a6811f..1aa527a 100644
--- a/Documentation/devicetree/bindings/mmc/mmc.txt
+++ b/Documentation/devicetree/bindings/mmc/mmc.txt
@@ -16,6 +16,8 @@  Optional properties:
 - wp-inverted: when present, polarity on the wp gpio line is inverted
 - non-removable: non-removable slot (like eMMC)
 - max-frequency: maximum operating clock frequency
+- broken-cd: when present, indicates that the cd-gpios line is not
+	connected to the card-detect pad of the MMC host controller.
 
 Example: