Re: [PATCH] mmc: omap_hsmmc: Enable SDIO IRQ using a GPIO in idle mode.

2013-02-18 Thread Daniel Mack
On 10.01.2013 21:22, Tony Lindgren wrote:
 * Andreas Fenkart andreas.fenk...@streamunlimited.com [121220 14:15]:
 Without functional clock the omap_hsmmc module can't forward
 SDIO IRQs to the system. This patch reconfigures dat1 line
 as a gpio while the fclk is off. And uses SDIO IRQ detection of
 the module, while fclk is present.
 
 Looks pretty good to me, however I could not figure out what
 to apply this on for testing. It fails to apply at least against
 current linux next, can you please update against that?
  
 +static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 +{
 +struct omap_hsmmc_host *host = mmc_priv(mmc);
 +u32 irq_mask;
 +unsigned long flags;
 +
 +spin_lock_irqsave(host-irq_lock, flags);
 +
 +host-sdio_irq_en = (enable != 0) ? true : false;
 +
 +if (host-active_pinmux) {
 +irq_mask = OMAP_HSMMC_READ(host-base, ISE);
 +if (enable)
 +irq_mask |= CIRQ_ENABLE;
 +else
 +irq_mask = ~CIRQ_ENABLE;
 +OMAP_HSMMC_WRITE(host-base, IE, irq_mask);
 +
 +if (!host-req_in_progress)
 +OMAP_HSMMC_WRITE(host-base, ISE, irq_mask);
 +
 +#if 0
 +OMAP_HSMMC_READ(host-base, IE); /* flush posted write */
 +#endif
 
 Maybe just replace #if 0 with just a comment in case it turns out to be
 needed for some cases?

Is there any update on this series? Andreas, did you do more tests?


Thanks and best regards,
Daniel

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


Re: [PATCH] mmc: omap_hsmmc: Enable SDIO IRQ using a GPIO in idle mode.

2013-02-18 Thread Andreas Fenkart
Hi,

On Mon, Feb 18, 2013 at 11:26:38AM +0100, Daniel Mack wrote:
 On 10.01.2013 21:22, Tony Lindgren wrote:
  * Andreas Fenkart andreas.fenk...@streamunlimited.com [121220 14:15]:
  Without functional clock the omap_hsmmc module can't forward
  SDIO IRQs to the system. This patch reconfigures dat1 line
  as a gpio while the fclk is off. And uses SDIO IRQ detection of
  the module, while fclk is present.
  
  Looks pretty good to me, however I could not figure out what
  to apply this on for testing. It fails to apply at least against
  current linux next, can you please update against that?
   
  +static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
  +{
  +  struct omap_hsmmc_host *host = mmc_priv(mmc);
  +  u32 irq_mask;
  +  unsigned long flags;
  +
  +  spin_lock_irqsave(host-irq_lock, flags);
  +
  +  host-sdio_irq_en = (enable != 0) ? true : false;
  +
  +  if (host-active_pinmux) {
  +  irq_mask = OMAP_HSMMC_READ(host-base, ISE);
  +  if (enable)
  +  irq_mask |= CIRQ_ENABLE;
  +  else
  +  irq_mask = ~CIRQ_ENABLE;
  +  OMAP_HSMMC_WRITE(host-base, IE, irq_mask);
  +
  +  if (!host-req_in_progress)
  +  OMAP_HSMMC_WRITE(host-base, ISE, irq_mask);
  +
  +#if 0
  +  OMAP_HSMMC_READ(host-base, IE); /* flush posted write */
  +#endif
  
  Maybe just replace #if 0 with just a comment in case it turns out to be
  needed for some cases?
 
 Is there any update on this series? Andreas, did you do more tests?

Thanks for all the feedback so far. Yes I did more testing. After
reducing the autosuspend delay, I found two more bugs.

--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -138,7 +138,7 @@ static void apply_clk_hack(void)
 #define SOFTRESET  (1  1)
 #define RESETDONE  (1  0)

-#define MMC_AUTOSUSPEND_DELAY  100
+#define MMC_AUTOSUSPEND_DELAY  1
 #define MMC_TIMEOUT_MS 20

One is already fixed[1], the other I'm still working on.
Hope to progress this week, then need to redo the testing.
Plan is to resubmit latest next week.

Andi

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


Re: [PATCH] mmc: omap_hsmmc: Enable SDIO IRQ using a GPIO in idle mode.

2013-02-08 Thread Grant Likely
On Thu, 20 Dec 2012 23:12:12 +0100, Andreas Fenkart 
andreas.fenk...@streamunlimited.com wrote:
 Without functional clock the omap_hsmmc module can't forward
 SDIO IRQs to the system. This patch reconfigures dat1 line
 as a gpio while the fclk is off. And uses SDIO IRQ detection of
 the module, while fclk is present.
 
 Signed-off-by: Andreas Fenkart andreas.fenk...@streamunlimited.com
 ---
  .../devicetree/bindings/mmc/ti-omap-hsmmc.txt  |   42 
  arch/arm/plat-omap/include/plat/mmc.h  |4 +
  drivers/mmc/host/omap_hsmmc.c  |  219 
 ++--
  3 files changed, 247 insertions(+), 18 deletions(-)
 
 diff --git a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt 
 b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
 index d1b8932..4d57637 100644
 --- a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
 +++ b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
 @@ -24,6 +24,29 @@ One tx and one rx pair is required.
  dma-names: DMA request names. These strings correspond 1:1 with
  the ordered pairs in dmas. The RX request must be rx and the
  TX request must be tx.
 +ti,cirq-gpio: When omap_hsmmc module is suspended, its functional
 +clock is turned off. Without fclk it can't forward SDIO IRQs to the
 +system. For that to happen, it needs to tell the PRCM to restore
 +its fclk, which is done through the swakeup line.
 +
 +   --
 +  | PRCM |
 +   --
 +| ^
 +   fclk | | swakeup
 +v |
 +  ---   --
 +  -- IRQ -- | hsmmc | -- CIRQ -- | card |
 +  ---   --
 +
 +The problem is, that on the AM335x family the swakeup line is
 +missing, it has not been routed from the module to the PRCM.
 +The way to work around this, is to reconfigure the dat1 line as a
 +GPIO upon suspend. Beyond this option you also need to set named
 +states default and idle in the .dts file for the pins, using
 +pinctrl-single.c. The MMC driver will then then toggle between
 +default and idle during the runtime.
 +
  
  Examples:
  
 @@ -53,3 +76,22 @@ Examples:
   edma 25;
   dma-names = tx, rx;
   };
 +
 +[am335x with with gpio for sdio irq]
 +
 + mmc1_cirq_pin: pinmux_cirq_pin {
 + pinctrl-single,pins = 
 + 0x0f8 0x3f  /* MMC0_DAT1 as GPIO2_28 */
 + ;
 + };
 +
 + mmc1: mmc@4806 {
 + pinctrl-names = default, idle;
 + pinctrl-0 = mmc1_pins;
 + pinctrl-1 = mmc1_cirq_pin;
 + ti,cirq-gpio = gpio3 28 0;
 + ti,non-removable;
 + bus-width = 4;
 + vmmc-supply = ldo2_reg;
 + vmmc_aux-supply = vmmc;
 + };

Binding looks reasonable.

Reviewed-by: Grant Likely grant.lik...@secretlab.ca

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


Re: [PATCH] mmc: omap_hsmmc: Enable SDIO IRQ using a GPIO in idle mode.

2013-01-10 Thread Tony Lindgren
* Andreas Fenkart andreas.fenk...@streamunlimited.com [121220 14:15]:
 Without functional clock the omap_hsmmc module can't forward
 SDIO IRQs to the system. This patch reconfigures dat1 line
 as a gpio while the fclk is off. And uses SDIO IRQ detection of
 the module, while fclk is present.

Looks pretty good to me, however I could not figure out what
to apply this on for testing. It fails to apply at least against
current linux next, can you please update against that?
 
 +static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 +{
 + struct omap_hsmmc_host *host = mmc_priv(mmc);
 + u32 irq_mask;
 + unsigned long flags;
 +
 + spin_lock_irqsave(host-irq_lock, flags);
 +
 + host-sdio_irq_en = (enable != 0) ? true : false;
 +
 + if (host-active_pinmux) {
 + irq_mask = OMAP_HSMMC_READ(host-base, ISE);
 + if (enable)
 + irq_mask |= CIRQ_ENABLE;
 + else
 + irq_mask = ~CIRQ_ENABLE;
 + OMAP_HSMMC_WRITE(host-base, IE, irq_mask);
 +
 + if (!host-req_in_progress)
 + OMAP_HSMMC_WRITE(host-base, ISE, irq_mask);
 +
 +#if 0
 + OMAP_HSMMC_READ(host-base, IE); /* flush posted write */
 +#endif

Maybe just replace #if 0 with just a comment in case it turns out to be
needed for some cases?

Regards,

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


[PATCH] mmc: omap_hsmmc: Enable SDIO IRQ using a GPIO in idle mode.

2012-12-20 Thread Andreas Fenkart
Without functional clock the omap_hsmmc module can't forward
SDIO IRQs to the system. This patch reconfigures dat1 line
as a gpio while the fclk is off. And uses SDIO IRQ detection of
the module, while fclk is present.

Signed-off-by: Andreas Fenkart andreas.fenk...@streamunlimited.com
---
 .../devicetree/bindings/mmc/ti-omap-hsmmc.txt  |   42 
 arch/arm/plat-omap/include/plat/mmc.h  |4 +
 drivers/mmc/host/omap_hsmmc.c  |  219 ++--
 3 files changed, 247 insertions(+), 18 deletions(-)

diff --git a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt 
b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
index d1b8932..4d57637 100644
--- a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
+++ b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
@@ -24,6 +24,29 @@ One tx and one rx pair is required.
 dma-names: DMA request names. These strings correspond 1:1 with
 the ordered pairs in dmas. The RX request must be rx and the
 TX request must be tx.
+ti,cirq-gpio: When omap_hsmmc module is suspended, its functional
+clock is turned off. Without fclk it can't forward SDIO IRQs to the
+system. For that to happen, it needs to tell the PRCM to restore
+its fclk, which is done through the swakeup line.
+
+   --
+  | PRCM |
+   --
+| ^
+   fclk | | swakeup
+v |
+  ---   --
+  -- IRQ -- | hsmmc | -- CIRQ -- | card |
+  ---   --
+
+The problem is, that on the AM335x family the swakeup line is
+missing, it has not been routed from the module to the PRCM.
+The way to work around this, is to reconfigure the dat1 line as a
+GPIO upon suspend. Beyond this option you also need to set named
+states default and idle in the .dts file for the pins, using
+pinctrl-single.c. The MMC driver will then then toggle between
+default and idle during the runtime.
+
 
 Examples:
 
@@ -53,3 +76,22 @@ Examples:
edma 25;
dma-names = tx, rx;
};
+
+[am335x with with gpio for sdio irq]
+
+   mmc1_cirq_pin: pinmux_cirq_pin {
+   pinctrl-single,pins = 
+   0x0f8 0x3f  /* MMC0_DAT1 as GPIO2_28 */
+   ;
+   };
+
+   mmc1: mmc@4806 {
+   pinctrl-names = default, idle;
+   pinctrl-0 = mmc1_pins;
+   pinctrl-1 = mmc1_cirq_pin;
+   ti,cirq-gpio = gpio3 28 0;
+   ti,non-removable;
+   bus-width = 4;
+   vmmc-supply = ldo2_reg;
+   vmmc_aux-supply = vmmc;
+   };
diff --git a/arch/arm/plat-omap/include/plat/mmc.h 
b/arch/arm/plat-omap/include/plat/mmc.h
index 8b4e4f2..807676a 100644
--- a/arch/arm/plat-omap/include/plat/mmc.h
+++ b/arch/arm/plat-omap/include/plat/mmc.h
@@ -130,6 +130,7 @@ struct omap_mmc_platform_data {
 
int switch_pin; /* gpio (card detect) */
int gpio_wp;/* gpio (write protect) */
+   int gpio_cirq;  /* gpio (card irq) */
 
int (*set_bus_mode)(struct device *dev, int slot, int bus_mode);
int (*set_power)(struct device *dev, int slot,
@@ -160,6 +161,9 @@ struct omap_mmc_platform_data {
int card_detect_irq;
int (*card_detect)(struct device *dev, int slot);
 
+   /* SDIO IRQs */
+   int sdio_irq;
+
unsigned int ban_openended:1;
 
} slots[OMAP_MMC_MAX_SLOTS];
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 53703c6..1a48cb1 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -108,6 +108,7 @@ static void apply_clk_hack(void)
 #define INT_EN_MASK0x307F0033
 #define BWR_ENABLE (1  4)
 #define BRR_ENABLE (1  5)
+#define CIRQ_ENABLE(1  8)
 #define DTO_ENABLE (1  20)
 #define INIT_STREAM(1  1)
 #define DP_SELECT  (1  21)
@@ -121,6 +122,7 @@ static void apply_clk_hack(void)
 #define CC 0x1
 #define TC 0x02
 #define OD 0x1
+#define CIRQ   (1  8)
 #define ERR(1  15)
 #define CMD_TIMEOUT(1  16)
 #define DATA_TIMEOUT   (1  20)
@@ -198,11 +200,25 @@ struct omap_hsmmc_host {
int reqs_blocked;
int use_reg;
int req_in_progress;
+   boolactive_pinmux;
+   boolsdio_irq_en;
struct omap_hsmmc_next  next_data;
 
struct  omap_mmc_platform_data  *pdata;
+
+   struct pinctrl *pinctrl;
+   struct pinctrl_state *active, *idle;
+
 };
 
+static irqreturn_t omap_hsmmc_cirq(int irq, void