diff mbox

mmc:sdhci:add support to request/free pins for controllers sharing hardware bus

Message ID BANLkTinj4pnDG=cCJY3JGYGXOYoVPHtA9A@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Barry Song April 26, 2011, 3:34 a.m. UTC
From: Bin Shi <bin.shi@csr.com>

some controllers share data bus or other pins between
multi-controllers and need to switch the functions of shared pins
runtime.
this patch requested those shared pins before actual hardware access
and release them after access

Signed-off-by: Bin Shi <bin.shi@csr.com>
Cc: Binghua Duan <binghua.duan@csr.com>
Cc: Andrei Warkentin <andreiw@motorola.com>
Cc: Philip Rakity <prakity@marvell.com>
Signed-off-by: Barry Song <21cnbao@gmail.com>
---
 drivers/mmc/host/sdhci.c |   13 +++++++++++++
 drivers/mmc/host/sdhci.h |    2 ++
 2 files changed, 15 insertions(+), 0 deletions(-)

--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Chris Ball April 26, 2011, 3:48 a.m. UTC | #1
Hi Barry,

On Mon, Apr 25 2011, Barry Song wrote:
> From: Bin Shi <bin.shi@csr.com>
>
> some controllers share data bus or other pins between
> multi-controllers and need to switch the functions of shared pins
> runtime.
> this patch requested those shared pins before actual hardware access
> and release them after access
>
> Signed-off-by: Bin Shi <bin.shi@csr.com>
> Cc: Binghua Duan <binghua.duan@csr.com>
> Cc: Andrei Warkentin <andreiw@motorola.com>
> Cc: Philip Rakity <prakity@marvell.com>
> Signed-off-by: Barry Song <21cnbao@gmail.com>

* The patch is corrupt:
    fatal: corrupt patch at line 11
  You can check whether the patch is okay by first e-mailing it to
  yourself and checking that git can apply it.

* Where is the patch that implements the get_shared_pins() hook in
  your driver?

Thanks,

- Chris.
Philip Rakity April 26, 2011, 3:48 a.m. UTC | #2
Hi Barry,

How are SDIO interrupts handled ?

Philip

On Apr 25, 2011, at 8:34 PM, Barry Song wrote:

> From: Bin Shi <bin.shi@csr.com>
> 
> some controllers share data bus or other pins between
> multi-controllers and need to switch the functions of shared pins
> runtime.
> this patch requested those shared pins before actual hardware access
> and release them after access
> 
> Signed-off-by: Bin Shi <bin.shi@csr.com>
> Cc: Binghua Duan <binghua.duan@csr.com>
> Cc: Andrei Warkentin <andreiw@motorola.com>
> Cc: Philip Rakity <prakity@marvell.com>
> Signed-off-by: Barry Song <21cnbao@gmail.com>
> ---
>  drivers/mmc/host/sdhci.c |   13 +++++++++++++
>  drivers/mmc/host/sdhci.h |    2 ++
>  2 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index f70e21e..92ae9f7 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1143,6 +1143,13 @@ static void sdhci_request(struct mmc_host *mmc,
> struct mmc_request *mrq)
> 
>        host = mmc_priv(mmc);
> 
> +       /*
> +        * some controllers share data bus or other pins between
> multi-controller
> +        * and need to switch the function of pins runtime
> +        */
> +       if (host->ops->get_shared_pins)
> +               host->ops->get_shared_pins(host);
> +
>        spin_lock_irqsave(&host->lock, flags);
> 
>        WARN_ON(host->mrq != NULL);
> @@ -1417,6 +1424,12 @@ static void sdhci_tasklet_finish(unsigned long param)
>        spin_unlock_irqrestore(&host->lock, flags);
> 
>        mmc_request_done(host->mmc, mrq);
> +
> +       /*
> +        * release shared pins so that other controllers can use them
> +        */
> +       if (host->ops->put_shared_pins)
> +               host->ops->put_shared_pins(host);
>  }
> 
>  static void sdhci_timeout_timer(unsigned long data)
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index c6e25a7..5a26cfe 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -231,6 +231,8 @@ struct sdhci_ops {
>        unsigned int    (*get_ro)(struct sdhci_host *host);
>        void    (*platform_reset_enter)(struct sdhci_host *host, u8 mask);
>        void    (*platform_reset_exit)(struct sdhci_host *host, u8 mask);
> +       unsigned int    (*get_shared_pins)(struct sdhci_host *host);
> +       unsigned int    (*put_shared_pins)(struct sdhci_host *host);
>  };
> 
>  #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
> --
> 1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Barry Song April 26, 2011, 3:50 a.m. UTC | #3
2011/4/26 Chris Ball <cjb@laptop.org>:
> Hi Barry,
>
> On Mon, Apr 25 2011, Barry Song wrote:
>> From: Bin Shi <bin.shi@csr.com>
>>
>> some controllers share data bus or other pins between
>> multi-controllers and need to switch the functions of shared pins
>> runtime.
>> this patch requested those shared pins before actual hardware access
>> and release them after access
>>
>> Signed-off-by: Bin Shi <bin.shi@csr.com>
>> Cc: Binghua Duan <binghua.duan@csr.com>
>> Cc: Andrei Warkentin <andreiw@motorola.com>
>> Cc: Philip Rakity <prakity@marvell.com>
>> Signed-off-by: Barry Song <21cnbao@gmail.com>
>
> * The patch is corrupt:
>    fatal: corrupt patch at line 11
>  You can check whether the patch is okay by first e-mailing it to
>  yourself and checking that git can apply it.

Hi Chris,
I am deeply sorry for our firewall still stops me to send email by
git. I post it in web and this patch should be not able to be applied.
Then i attatched the origianl patch as an attachment.
Our IT will open related ports. Then we can send formated patches later.
>
> * Where is the patch that implements the get_shared_pins() hook in
>  your driver?
We send the common level patch ahead to get the upstream agreement so
that we can maintain our bottom level sdhci codes better. We will send
the special driver patch after some time.
Basically, the driver get a mutex and set hardware registers to make
the related pin switch roles.

>
> Thanks,
>
> - Chris.
> --
> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
> One Laptop Per Child
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Wolfram Sang April 26, 2011, 6:58 a.m. UTC | #4
> > * Where is the patch that implements the get_shared_pins() hook in
> >  your driver?
> We send the common level patch ahead to get the upstream agreement so
> that we can maintain our bottom level sdhci codes better. We will send
> the special driver patch after some time.

Hmm, why should be there a functionality if there is no user for it? A
reference user helps people understand how it is intended to be used.

Regards,

   Wolfram
Barry Song April 26, 2011, 7:27 a.m. UTC | #5
Hi Wolfram,

2011/4/26 Wolfram Sang <w.sang@pengutronix.de>:
>> > * Where is the patch that implements the get_shared_pins() hook in
>> >  your driver?
>> We send the common level patch ahead to get the upstream agreement so
>> that we can maintain our bottom level sdhci codes better. We will send
>> the special driver patch after some time.
>
> Hmm, why should be there a functionality if there is no user for it? A
> reference user helps people understand how it is intended to be used.

completely right. Of course this patch is based on real applications
and SoCs. We are using ARASAN sd controller IP, it can be configurated
to use shared pins mode in SoC design. And it looks like it is a
common requirement to save chip footprint by sharing data bus between
multi-controllers.

Just because Our SoCs are still on the way to opensource and mainline.
Even our arch/arm/mach-xxx hasn't been merged yet. Our target is
syncing our codes with mainline. So as a modification to sdhci common
level, we just get upstream's opinion for local maintaining earlier.

Anyway, this patch may be applied later after our others are ready. Or
it can be now so that other SoC companies can use this feature.

>
> Regards,
>
>   Wolfram
>
> --
> Pengutronix e.K.                           | Wolfram Sang                |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chris Ball April 26, 2011, 1 p.m. UTC | #6
Hi Barry,

On Tue, Apr 26 2011, Barry Song wrote:
> Just because Our SoCs are still on the way to opensource and mainline.
> Even our arch/arm/mach-xxx hasn't been merged yet. Our target is
> syncing our codes with mainline. So as a modification to sdhci common
> level, we just get upstream's opinion for local maintaining earlier.
>
> Anyway, this patch may be applied later after our others are ready. Or
> it can be now so that other SoC companies can use this feature.

Thanks for the explanation.  In that case, I'll give you my Reviewed-by:
on the patch now, but will wait to merge it until you have your driver
support code posted too.  (Or until, as you say, someone else would like
the same hook.)

- Chris.
Philip Rakity April 26, 2011, 3:28 p.m. UTC | #7
Barry,

How are interrupts from SDIO devices handled ?   SDIO devices use one of the pins to signal a interrupt to the host when data is availabe.

Philip

On Apr 26, 2011, at 12:27 AM, Barry Song wrote:

> Hi Wolfram,
> 
> 2011/4/26 Wolfram Sang <w.sang@pengutronix.de>:
>>>> * Where is the patch that implements the get_shared_pins() hook in
>>>>  your driver?
>>> We send the common level patch ahead to get the upstream agreement so
>>> that we can maintain our bottom level sdhci codes better. We will send
>>> the special driver patch after some time.
>> 
>> Hmm, why should be there a functionality if there is no user for it? A
>> reference user helps people understand how it is intended to be used.
> 
> completely right. Of course this patch is based on real applications
> and SoCs. We are using ARASAN sd controller IP, it can be configurated
> to use shared pins mode in SoC design. And it looks like it is a
> common requirement to save chip footprint by sharing data bus between
> multi-controllers.
> 
> Just because Our SoCs are still on the way to opensource and mainline.
> Even our arch/arm/mach-xxx hasn't been merged yet. Our target is
> syncing our codes with mainline. So as a modification to sdhci common
> level, we just get upstream's opinion for local maintaining earlier.
> 
> Anyway, this patch may be applied later after our others are ready. Or
> it can be now so that other SoC companies can use this feature.
> 
>> 
>> Regards,
>> 
>>   Wolfram
>> 
>> --
>> Pengutronix e.K.                           | Wolfram Sang                |
>> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Barry Song April 28, 2011, 1:14 a.m. UTC | #8
Hi Philip,

2011/4/26 Philip Rakity <prakity@marvell.com>:
>
> Barry,
>
> How are interrupts from SDIO devices handled ?   SDIO devices use one of the pins to signal a interrupt to the host when data is availabe.

Good question. in fact, it is impossible to support both sharing all
data bus and sdio interrupt in hardware except that hardware gives a
special design with data1. Otherwise, controllers with shared pins
requested at runtime will not support sdio devices with interrupts.

>
> Philip
>
> On Apr 26, 2011, at 12:27 AM, Barry Song wrote:
>
>> Hi Wolfram,
>>
>> 2011/4/26 Wolfram Sang <w.sang@pengutronix.de>:
>>>>> * Where is the patch that implements the get_shared_pins() hook in
>>>>>  your driver?
>>>> We send the common level patch ahead to get the upstream agreement so
>>>> that we can maintain our bottom level sdhci codes better. We will send
>>>> the special driver patch after some time.
>>>
>>> Hmm, why should be there a functionality if there is no user for it? A
>>> reference user helps people understand how it is intended to be used.
>>
>> completely right. Of course this patch is based on real applications
>> and SoCs. We are using ARASAN sd controller IP, it can be configurated
>> to use shared pins mode in SoC design. And it looks like it is a
>> common requirement to save chip footprint by sharing data bus between
>> multi-controllers.
>>
>> Just because Our SoCs are still on the way to opensource and mainline.
>> Even our arch/arm/mach-xxx hasn't been merged yet. Our target is
>> syncing our codes with mainline. So as a modification to sdhci common
>> level, we just get upstream's opinion for local maintaining earlier.
>>
>> Anyway, this patch may be applied later after our others are ready. Or
>> it can be now so that other SoC companies can use this feature.
>>
>>>
>>> Regards,
>>>
>>>   Wolfram
>>>
>>> --
>>> Pengutronix e.K.                           | Wolfram Sang                |
>>> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>>>
>
>
-barry
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Barry Song April 28, 2011, 1:16 a.m. UTC | #9
2011/4/28 Barry Song <21cnbao@gmail.com>:
> Hi Philip,
>
> 2011/4/26 Philip Rakity <prakity@marvell.com>:
>>
>> Barry,
>>
>> How are interrupts from SDIO devices handled ?   SDIO devices use one of the pins to signal a interrupt to the host when data is availabe.
>
> Good question. in fact, it is impossible to support both sharing all
> data bus and sdio interrupt in hardware except that hardware gives a
> special design with data1. Otherwise, controllers with shared pins
> requested at runtime will not support sdio devices with interrupts.

So the point is that leaving get/put_shared_pins implementation to
bottom level drivers. Let the bottom level handle possible details.

>
>>
>> Philip
>>
>> On Apr 26, 2011, at 12:27 AM, Barry Song wrote:
>>
>>> Hi Wolfram,
>>>
>>> 2011/4/26 Wolfram Sang <w.sang@pengutronix.de>:
>>>>>> * Where is the patch that implements the get_shared_pins() hook in
>>>>>>  your driver?
>>>>> We send the common level patch ahead to get the upstream agreement so
>>>>> that we can maintain our bottom level sdhci codes better. We will send
>>>>> the special driver patch after some time.
>>>>
>>>> Hmm, why should be there a functionality if there is no user for it? A
>>>> reference user helps people understand how it is intended to be used.
>>>
>>> completely right. Of course this patch is based on real applications
>>> and SoCs. We are using ARASAN sd controller IP, it can be configurated
>>> to use shared pins mode in SoC design. And it looks like it is a
>>> common requirement to save chip footprint by sharing data bus between
>>> multi-controllers.
>>>
>>> Just because Our SoCs are still on the way to opensource and mainline.
>>> Even our arch/arm/mach-xxx hasn't been merged yet. Our target is
>>> syncing our codes with mainline. So as a modification to sdhci common
>>> level, we just get upstream's opinion for local maintaining earlier.
>>>
>>> Anyway, this patch may be applied later after our others are ready. Or
>>> it can be now so that other SoC companies can use this feature.
>>>
>>>>
>>>> Regards,
>>>>
>>>>   Wolfram
>>>>
>>>> --
>>>> Pengutronix e.K.                           | Wolfram Sang                |
>>>> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>>>>
>>
>>
> -barry
>
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index f70e21e..92ae9f7 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1143,6 +1143,13 @@  static void sdhci_request(struct mmc_host *mmc,
struct mmc_request *mrq)

       host = mmc_priv(mmc);

+       /*
+        * some controllers share data bus or other pins between
multi-controller
+        * and need to switch the function of pins runtime
+        */
+       if (host->ops->get_shared_pins)
+               host->ops->get_shared_pins(host);
+
       spin_lock_irqsave(&host->lock, flags);

       WARN_ON(host->mrq != NULL);
@@ -1417,6 +1424,12 @@  static void sdhci_tasklet_finish(unsigned long param)
       spin_unlock_irqrestore(&host->lock, flags);

       mmc_request_done(host->mmc, mrq);
+
+       /*
+        * release shared pins so that other controllers can use them
+        */
+       if (host->ops->put_shared_pins)
+               host->ops->put_shared_pins(host);
 }

 static void sdhci_timeout_timer(unsigned long data)
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index c6e25a7..5a26cfe 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -231,6 +231,8 @@  struct sdhci_ops {
       unsigned int    (*get_ro)(struct sdhci_host *host);
       void    (*platform_reset_enter)(struct sdhci_host *host, u8 mask);
       void    (*platform_reset_exit)(struct sdhci_host *host, u8 mask);
+       unsigned int    (*get_shared_pins)(struct sdhci_host *host);
+       unsigned int    (*put_shared_pins)(struct sdhci_host *host);
 };

 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS