Re: [PATCH 0/4] clk: dt: add support for default rate/parent

2014-03-21 Thread Tero Kristo

On 03/20/2014 11:23 PM, Mike Turquette wrote:

Quoting Tero Kristo (2014-03-05 05:10:17)

Ping.

Mike, any feedback on this?


Hi Tero,

Have you seen Sylwester's approach[1]? I prefer it since it is more
device-oriented and less "centralized". The clock consumer enumerates
the default parent or rate of a consumed clock. This can be made to work
like your approach by having the clock driver consume these clocks and
set them up with default rates or parents. What do you think?


Just saw the patches yesterday. I think that approach would work in most 
cases, however I guess there might be cases where you need to setup the 
rate/parent of a clock very early in boot (basically when you are 
registering the clock itself) to avoid any race issues with drivers (or 
the clock framework itself) coming in and using a clock that is not 
properly setup yet. But well, I guess these can be handled by some init 
time tweaks.


I just converted the OMAP4 code to the format provided by Sylwester's 
patches and it seems to work fine. The patch should be changed 
eventually to probe at the time when the CM/PRM instances are probed. 
Inlined here as reference:


From 1b05e03bbd3fb5a4f5192444e7d4365f177c1756 Mon Sep 17 00:00:00 2001
From: Tero Kristo 
Date: Fri, 21 Mar 2014 09:52:47 +0200
Subject: [PATCH] CLK: TI: OMAP4: setup default clocks / rates using the 
clock

 consumer approach

Signed-off-by: Tero Kristo 
---
 arch/arm/boot/dts/omap4.dtsi |8 
 drivers/clk/ti/clk-44xx.c|   44 
--
 drivers/clk/ti/clk.c |   41 
+++

 3 files changed, 49 insertions(+), 44 deletions(-)

diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index d3f8a6e..4826168 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -88,6 +88,14 @@
};
};

+   default-clocks {
+   compatible = "ti,default-clocks";
+   clocks = <&abe_dpll_refclk_mux_ck>, <&dpll_usb_ck>,
+   <&dpll_abe_ck>;
+   clock-parents = <&sys_32k_ck>;
+   clock-rates = <0>, <96000>, <98304000>;
+   };
+
/*
 * XXX: Use a flat representation of the OMAP4 interconnect.
 * The real OMAP interconnect network is quite complex.
diff --git a/drivers/clk/ti/clk-44xx.c b/drivers/clk/ti/clk-44xx.c
index ae00218..dfafb96 100644
--- a/drivers/clk/ti/clk-44xx.c
+++ b/drivers/clk/ti/clk-44xx.c
@@ -16,21 +16,6 @@
 #include 
 #include 

-/*
- * OMAP4 ABE DPLL default frequency. In OMAP4460 TRM version V, section
- * "3.6.3.2.3 CM1_ABE Clock Generator" states that the "DPLL_ABE_X2_CLK
- * must be set to 196.608 MHz" and hence, the DPLL locked frequency is
- * half of this value.
- */
-#define OMAP4_DPLL_ABE_DEFFREQ 98304000
-
-/*
- * OMAP4 USB DPLL default frequency. In OMAP4430 TRM version V, section
- * "3.6.3.9.5 DPLL_USB Preferred Settings" shows that the preferred
- * locked frequency for the USB DPLL is 960MHz.
- */
-#define OMAP4_DPLL_USB_DEFFREQ 96000
-
 static struct ti_dt_clk omap44xx_clks[] = {
DT_CLK(NULL, "extalt_clkin_ck", "extalt_clkin_ck"),
DT_CLK(NULL, "pad_clks_src_ck", "pad_clks_src_ck"),
@@ -281,36 +266,7 @@ static struct ti_dt_clk omap44xx_clks[] = {

 int __init omap4xxx_dt_clk_init(void)
 {
-   int rc;
-   struct clk *abe_dpll_ref, *abe_dpll, *sys_32k_ck, *usb_dpll;
-
ti_dt_clocks_register(omap44xx_clks);
-
omap2_clk_disable_autoidle_all();
-
-   /*
-* Lock USB DPLL on OMAP4 devices so that the L3INIT power
-* domain can transition to retention state when not in use.
-*/
-   usb_dpll = clk_get_sys(NULL, "dpll_usb_ck");
-   rc = clk_set_rate(usb_dpll, OMAP4_DPLL_USB_DEFFREQ);
-   if (rc)
-   pr_err("%s: failed to configure USB DPLL!\n", __func__);
-
-   /*
-* On OMAP4460 the ABE DPLL fails to turn on if in idle low-power
-* state when turning the ABE clock domain. Workaround this by
-* locking the ABE DPLL on boot.
-* Lock the ABE DPLL in any case to avoid issues with audio.
-*/
-   abe_dpll_ref = clk_get_sys(NULL, "abe_dpll_refclk_mux_ck");
-   sys_32k_ck = clk_get_sys(NULL, "sys_32k_ck");
-   rc = clk_set_parent(abe_dpll_ref, sys_32k_ck);
-   abe_dpll = clk_get_sys(NULL, "dpll_abe_ck");
-   if (!rc)
-   rc = clk_set_rate(abe_dpll, OMAP4_DPLL_ABE_DEFFREQ);
-   if (rc)
-   pr_err("%s: failed to configure ABE DPLL!\n", __func__);
-
return 0;
 }
diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
index b1a6f71..469fd4e 100644
--- a/drivers/clk/ti/clk.c
+++ b/drivers/clk/ti/clk.c
@@ -21,6 +21,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 

 #undef pr_fmt
 #define pr_fmt(fmt) "%s: " fmt, __func__
@@ -165,3 +167,41 @@ void ti_dt_clk_init_provider(struct device_

Re: [PATCH 0/4] clk: dt: add support for default rate/parent

2014-03-21 Thread Peter De Schrijver
On Thu, Mar 20, 2014 at 10:23:08PM +0100, Mike Turquette wrote:
> Quoting Tero Kristo (2014-03-05 05:10:17)
> > Ping.
> > 
> > Mike, any feedback on this?
> 
> Hi Tero,
> 
> Have you seen Sylwester's approach[1]? I prefer it since it is more
> device-oriented and less "centralized". The clock consumer enumerates
> the default parent or rate of a consumed clock. This can be made to work

That assumes driver writers are aware of the clock tree topology. IME that's
seldomly the case.

Cheers,

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


Re: [PATCH] net: micrel : ks8851-ml: add vdd-supply support

2014-03-21 Thread Markus Pargmann
Hi,

On Fri, Mar 21, 2014 at 01:52:48AM -0500, Nishanth Menon wrote:
> Few platforms use external regulator to keep the ethernet MAC supplied.
> So, request and enable the regulator for driver functionality.
> 
> Fixes: 66fda75f47dc (regulator: core: Replace direct ops->disable usage)
> Reported-by: Russell King 
> Suggested-by: Markus Pargmann 
> Signed-off-by: Nishanth Menon 
> ---
> 
> This fixes a regression in SDP4430 platform as reported by Russel here:
> http://marc.info/?t=139509918200014&r=1&w=2
> 
> Patch is based on [v3.14-rc7] tag, if it is too late to submit, I can repost
> rebased to git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
> 
>  .../devicetree/bindings/net/micrel-ks8851.txt  |1 +
>  drivers/net/ethernet/micrel/ks8851.c   |   30 
> +++-
>  2 files changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/micrel-ks8851.txt 
> b/Documentation/devicetree/bindings/net/micrel-ks8851.txt
> index 11ace3c..4fc3927 100644
> --- a/Documentation/devicetree/bindings/net/micrel-ks8851.txt
> +++ b/Documentation/devicetree/bindings/net/micrel-ks8851.txt
> @@ -7,3 +7,4 @@ Required properties:
>  
>  Optional properties:
>  - local-mac-address : Ethernet mac address to use
> +- vdd-supply:supply for Ethernet mac
> diff --git a/drivers/net/ethernet/micrel/ks8851.c 
> b/drivers/net/ethernet/micrel/ks8851.c
> index 727b546a..e0c92e0 100644
> --- a/drivers/net/ethernet/micrel/ks8851.c
> +++ b/drivers/net/ethernet/micrel/ks8851.c
> @@ -23,6 +23,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  
> @@ -83,6 +84,7 @@ union ks8851_tx_hdr {
>   * @rc_rxqcr: Cached copy of KS_RXQCR.
>   * @eeprom_size: Companion eeprom size in Bytes, 0 if no eeprom
>   * @eeprom: 93CX6 EEPROM state for accessing on-board EEPROM.
> + * @vdd_reg: Optional regulator supplying the chip
>   *
>   * The @lock ensures that the chip is protected when certain operations are
>   * in progress. When the read or write packet transfer is in progress, most
> @@ -130,6 +132,7 @@ struct ks8851_net {
>   struct spi_transfer spi_xfer2[2];
>  
>   struct eeprom_93cx6 eeprom;
> + struct regulator*vdd_reg;
>  };
>  
>  static int msg_enable;
> @@ -1414,6 +1417,21 @@ static int ks8851_probe(struct spi_device *spi)
>   ks->spidev = spi;
>   ks->tx_space = 6144;
>  
> + ks->vdd_reg = regulator_get_optional(&spi->dev, "vdd");

You could use devm_regulator_get_optional here and remove the
regulator_put.

Regards,

Markus

> + if (IS_ERR(ks->vdd_reg)) {
> + ret = PTR_ERR(ks->vdd_reg);
> + if (ret == -EPROBE_DEFER)
> + goto err_reg;
> + } else {
> + ret = regulator_enable(ks->vdd_reg);
> + if (ret) {
> + dev_err(&spi->dev, "regulator enable fail: %d\n",
> + ret);
> + goto err_reg_en;
> + }
> + }
> +
> +
>   mutex_init(&ks->lock);
>   spin_lock_init(&ks->statelock);
>  
> @@ -1508,8 +1526,14 @@ static int ks8851_probe(struct spi_device *spi)
>  err_netdev:
>   free_irq(ndev->irq, ks);
>  
> -err_id:
>  err_irq:
> +err_id:
> + if (!IS_ERR(ks->vdd_reg))
> + regulator_disable(ks->vdd_reg);
> +err_reg_en:
> + if (!IS_ERR(ks->vdd_reg))
> + regulator_put(ks->vdd_reg);
> +err_reg:
>   free_netdev(ndev);
>   return ret;
>  }
> @@ -1523,6 +1547,10 @@ static int ks8851_remove(struct spi_device *spi)
>  
>   unregister_netdev(priv->netdev);
>   free_irq(spi->irq, priv);
> + if (!IS_ERR(priv->vdd_reg)) {
> + regulator_disable(priv->vdd_reg);
> + regulator_put(priv->vdd_reg);
> + }
>   free_netdev(priv->netdev);
>  
>   return 0;
> -- 
> 1.7.9.5
> 
> 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


signature.asc
Description: Digital signature


[PATCH V2] net: micrel : ks8851-ml: add vdd-supply support

2014-03-21 Thread Nishanth Menon
Few platforms use external regulator to keep the ethernet MAC supplied.
So, request and enable the regulator for driver functionality.

Fixes: 66fda75f47dc (regulator: core: Replace direct ops->disable usage)
Reported-by: Russell King 
Suggested-by: Markus Pargmann 
Signed-off-by: Nishanth Menon 
---
This fixes a regression in SDP4430 platform as reported by Russel here:
http://marc.info/?t=139509918200014&r=1&w=2

Patch is based on [v3.14-rc7] tag, if it is too late to submit, I can repost
rebased to git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

Changes in v2: based on Marcus's comment, switched to managed regulator_get,
however retained the enable/disable as balanced.
v1:  https://patchwork.kernel.org/patch/3871401/

 .../devicetree/bindings/net/micrel-ks8851.txt  |1 +
 drivers/net/ethernet/micrel/ks8851.c   |   24 +++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/micrel-ks8851.txt 
b/Documentation/devicetree/bindings/net/micrel-ks8851.txt
index 11ace3c..4fc3927 100644
--- a/Documentation/devicetree/bindings/net/micrel-ks8851.txt
+++ b/Documentation/devicetree/bindings/net/micrel-ks8851.txt
@@ -7,3 +7,4 @@ Required properties:
 
 Optional properties:
 - local-mac-address : Ethernet mac address to use
+- vdd-supply:  supply for Ethernet mac
diff --git a/drivers/net/ethernet/micrel/ks8851.c 
b/drivers/net/ethernet/micrel/ks8851.c
index 727b546a..44923e0 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -83,6 +84,7 @@ union ks8851_tx_hdr {
  * @rc_rxqcr: Cached copy of KS_RXQCR.
  * @eeprom_size: Companion eeprom size in Bytes, 0 if no eeprom
  * @eeprom: 93CX6 EEPROM state for accessing on-board EEPROM.
+ * @vdd_reg:   Optional regulator supplying the chip
  *
  * The @lock ensures that the chip is protected when certain operations are
  * in progress. When the read or write packet transfer is in progress, most
@@ -130,6 +132,7 @@ struct ks8851_net {
struct spi_transfer spi_xfer2[2];
 
struct eeprom_93cx6 eeprom;
+   struct regulator*vdd_reg;
 };
 
 static int msg_enable;
@@ -1414,6 +1417,20 @@ static int ks8851_probe(struct spi_device *spi)
ks->spidev = spi;
ks->tx_space = 6144;
 
+   ks->vdd_reg = regulator_get_optional(&spi->dev, "vdd");
+   if (IS_ERR(ks->vdd_reg)) {
+   ret = PTR_ERR(ks->vdd_reg);
+   if (ret == -EPROBE_DEFER)
+   goto err_reg;
+   } else {
+   ret = regulator_enable(ks->vdd_reg);
+   if (ret) {
+   dev_err(&spi->dev, "regulator enable fail: %d\n",
+   ret);
+   goto err_reg;
+   }
+   }
+
mutex_init(&ks->lock);
spin_lock_init(&ks->statelock);
 
@@ -1508,8 +1525,11 @@ static int ks8851_probe(struct spi_device *spi)
 err_netdev:
free_irq(ndev->irq, ks);
 
-err_id:
 err_irq:
+err_id:
+   if (!IS_ERR(ks->vdd_reg))
+   regulator_disable(ks->vdd_reg);
+err_reg:
free_netdev(ndev);
return ret;
 }
@@ -1523,6 +1543,8 @@ static int ks8851_remove(struct spi_device *spi)
 
unregister_netdev(priv->netdev);
free_irq(spi->irq, priv);
+   if (!IS_ERR(priv->vdd_reg))
+   regulator_disable(priv->vdd_reg);
free_netdev(priv->netdev);
 
return 0;
-- 
1.7.9.5

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


Re: [PATCH V2] net: micrel : ks8851-ml: add vdd-supply support

2014-03-21 Thread Nishanth Menon
On 03/21/2014 04:28 AM, Nishanth Menon wrote:

> + ks->vdd_reg = regulator_get_optional(&spi->dev, "vdd");
ok, that is unbelievable.. no git commit --amend :(.. Apologies on the
spam.. will resent.


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


[RESEND PATCH V2] net: micrel : ks8851-ml: add vdd-supply support

2014-03-21 Thread Nishanth Menon
Few platforms use external regulator to keep the ethernet MAC supplied.
So, request and enable the regulator for driver functionality.

Fixes: 66fda75f47dc (regulator: core: Replace direct ops->disable usage)
Reported-by: Russell King 
Suggested-by: Markus Pargmann 
Signed-off-by: Nishanth Menon 
---
This fixes a regression in SDP4430 platform as reported by Russell here:
http://marc.info/?t=139509918200014&r=1&w=2

Patch is based on [v3.14-rc7] tag, if it is too late to submit, I can repost
rebased to git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

Changes in v2(resend): based on Marcus's comment, switched to managed regulator
get, however retained the enable/disable as balanced.
v1:  https://patchwork.kernel.org/patch/3871401/

 .../devicetree/bindings/net/micrel-ks8851.txt  |1 +
 drivers/net/ethernet/micrel/ks8851.c   |   24 +++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/micrel-ks8851.txt 
b/Documentation/devicetree/bindings/net/micrel-ks8851.txt
index 11ace3c..4fc3927 100644
--- a/Documentation/devicetree/bindings/net/micrel-ks8851.txt
+++ b/Documentation/devicetree/bindings/net/micrel-ks8851.txt
@@ -7,3 +7,4 @@ Required properties:
 
 Optional properties:
 - local-mac-address : Ethernet mac address to use
+- vdd-supply:  supply for Ethernet mac
diff --git a/drivers/net/ethernet/micrel/ks8851.c 
b/drivers/net/ethernet/micrel/ks8851.c
index 727b546a..674a58a 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -83,6 +84,7 @@ union ks8851_tx_hdr {
  * @rc_rxqcr: Cached copy of KS_RXQCR.
  * @eeprom_size: Companion eeprom size in Bytes, 0 if no eeprom
  * @eeprom: 93CX6 EEPROM state for accessing on-board EEPROM.
+ * @vdd_reg:   Optional regulator supplying the chip
  *
  * The @lock ensures that the chip is protected when certain operations are
  * in progress. When the read or write packet transfer is in progress, most
@@ -130,6 +132,7 @@ struct ks8851_net {
struct spi_transfer spi_xfer2[2];
 
struct eeprom_93cx6 eeprom;
+   struct regulator*vdd_reg;
 };
 
 static int msg_enable;
@@ -1414,6 +1417,20 @@ static int ks8851_probe(struct spi_device *spi)
ks->spidev = spi;
ks->tx_space = 6144;
 
+   ks->vdd_reg = devm_regulator_get_optional(&spi->dev, "vdd");
+   if (IS_ERR(ks->vdd_reg)) {
+   ret = PTR_ERR(ks->vdd_reg);
+   if (ret == -EPROBE_DEFER)
+   goto err_reg;
+   } else {
+   ret = regulator_enable(ks->vdd_reg);
+   if (ret) {
+   dev_err(&spi->dev, "regulator enable fail: %d\n",
+   ret);
+   goto err_reg;
+   }
+   }
+
mutex_init(&ks->lock);
spin_lock_init(&ks->statelock);
 
@@ -1508,8 +1525,11 @@ static int ks8851_probe(struct spi_device *spi)
 err_netdev:
free_irq(ndev->irq, ks);
 
-err_id:
 err_irq:
+err_id:
+   if (!IS_ERR(ks->vdd_reg))
+   regulator_disable(ks->vdd_reg);
+err_reg:
free_netdev(ndev);
return ret;
 }
@@ -1523,6 +1543,8 @@ static int ks8851_remove(struct spi_device *spi)
 
unregister_netdev(priv->netdev);
free_irq(spi->irq, priv);
+   if (!IS_ERR(priv->vdd_reg))
+   regulator_disable(priv->vdd_reg);
free_netdev(priv->netdev);
 
return 0;
-- 
1.7.9.5

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


Re: DSS DT changes

2014-03-21 Thread Tomi Valkeinen
On 19/03/14 17:30, Tony Lindgren wrote:
> * Tomi Valkeinen  [140319 04:29]:
>> Hi Tony,
>>
>> Is it too late to get the DSS dts changes via arm tree?
> 
> Yes too late..
>  
>> I now got everything working fine so that the dts changes and the
>> omapdss driver changes can be merged independently. It would be cleaner
>> if dts changes can go through the proper channel.
>>
>> If you can still take them, I've attached the patches, based on your
>> omap-for-v3.15/dt branch.
>>
>> I also attached the bindings docs. Those I can take via my tree, but I'm
>> not sure if they are supposed to go with the dts changes or with the
>> driver changes, so I have them here also.
>>
>> And I've pushed the changes to my tree:
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux.git
>>
>> The branches are:
>>
>> 3.15/dss-dt-dts - contains the .dts changes
>> 3.15/dss-dt - contains the driver changes + binding docs
> 
> These look OK to me and would be good to get in so we can move
> on with dropping more legacy platform data.
> 
> As you have my acks there, so please feel free to send
> your 3.15/dss-dt-dts along with the DSS patches after the
> arm-soc branches have been merged.

Ok. All this is now in linux-next.

 Tomi




signature.asc
Description: OpenPGP digital signature


[PATCH v9 resend 2/3] mmc: omap_hsmmc: Pin remux workaround to support SDIO interrupt on AM335x

2014-03-21 Thread Andreas Fenkart
The am335x can't detect pending cirq in PM runtime suspend.
This patch reconfigures dat1 as a GPIO before going to suspend.
SDIO interrupts are detected with the GPIO, the GPIO will only wake
the module from suspend, SDIO irq detection will still happen through the
IP block.

Idea of remuxing the pins and some minor changes by Tony Lindgren.

Signed-off-by: Andreas Fenkart 
Signed-off-by: Tony Lindgren 

diff --git a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt 
b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
index 8c8908a..8e1195e 100644
--- a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
+++ b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
@@ -55,3 +55,53 @@ Examples:
&edma 25>;
dma-names = "tx", "rx";
};
+
+[workaround for missing swakeup on am33xx]
+
+This SOC is missing the swakeup line, it will not detect SDIO irq
+while in suspend.
+
+ --
+ | PRCM |
+  --
+   ^ |
+   swakeup | | fclk
+   | v
+   -----   -
+  | card | -- CIRQ -->  | hsmmc | -- IRQ -->  | CPU |
+   -----   -
+
+In suspend the fclk is off and the module is disfunctional. Even
+register reads will fail. A small logic in the host will request
+fclk restore, when an external event is detected. Once the clock
+is restored, the host detects the event normally. Since am33xx
+doesn't have this line it never wakes from suspend.
+
+The workaround is to reconfigure the dat1 line as a GPIO upon
+suspend. To make this work, we need to set 1) the named pinctrl
+states "default", "active" and "idle", 2) the gpio detecting
+sdio irq in suspend and 3) compatibe section, see example below.
+The MMC driver will then toggle between active and idle during
+the runtime. If configuration is incomplete, a warning message is
+emitted "falling back to polling".  Mind not every application
+needs SDIO irq, e.g. MMC cards Affected chips are am335x,
+probably others
+
+
+   mmc1: mmc@48060100 {
+   compatible = "ti,am33xx-hsmmc";
+   ...
+   interrupts-extended = <&intc 64 &gpio2 28 0>;
+   ...
+   pinctrl-names = "default", "active", "idle"
+   pinctrl-0 = <&mmc1_pins>;
+   pinctrl-1 = <&mmc1_pins>;
+   pinctrl-2 = <&mmc1_cirq_pin>;
+   ...
+   };
+
+   mmc1_cirq_pin: pinmux_cirq_pin {
+   pinctrl-single,pins = <
+   0x0f8 0x3f  /* GPIO2_28 */
+   >;
+   };
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 06bf669..2307c78 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -224,6 +224,8 @@ struct omap_hsmmc_host {
 #define HSMMC_SDIO_IRQ_ENABLED (1 << 0)/* SDIO irq enabled */
 #define HSMMC_SWAKEUP_QUIRK(1 << 1)
struct omap_hsmmc_next  next_data;
+   struct pinctrl  *pinctrl;
+   struct pinctrl_state*fixed, *active, *idle;
struct  omap_mmc_platform_data  *pdata;
 };
 
@@ -480,6 +482,70 @@ static void omap_hsmmc_gpio_free(struct 
omap_mmc_platform_data *pdata)
gpio_free(pdata->slots[0].switch_pin);
 }
 
+static int omap_hsmmc_pin_init(struct omap_hsmmc_host *host)
+{
+   struct pinctrl *_pinctrl;
+   int ret;
+
+   _pinctrl = devm_pinctrl_get(host->dev);
+   if (IS_ERR(_pinctrl)) {
+   /* okay, if the bootloader set it up right */
+   dev_warn(host->dev, "no pinctrl handle\n");
+   return 0;
+   }
+
+   host->fixed = pinctrl_lookup_state(_pinctrl,
+  PINCTRL_STATE_DEFAULT);
+   if (IS_ERR(host->fixed)) {
+   dev_info(host->dev,
+"pins are not configured from the driver\n");
+   host->fixed = NULL;
+   devm_pinctrl_put(_pinctrl);
+   return 0;
+   }
+
+   ret = pinctrl_select_state(_pinctrl, host->fixed);
+   if (ret < 0) {
+   dev_warn(host->dev, "fixed pinctrl state failed %d\n", ret);
+   goto err;
+   }
+
+   /* For most cases we don't have wake-ups, and exit after this */
+   host->active = pinctrl_lookup_state(_pinctrl, "active");
+   if (IS_ERR(host->active)) {
+   ret = PTR_ERR(host->active);
+   host->active = NULL;
+   goto done;
+   }
+
+   host->idle = pinctrl_lookup_state(_pinctrl, PINCTRL_STATE_IDLE);
+   if (IS_ERR(host->idle)) {
+   ret = PTR_ERR(host->idle);
+   host->idle = NULL;
+   goto err;
+   }
+
+   /* Let's make sure the active and idle states work */
+   ret = pinctrl_select_state(_pinct

[PATCH v9 resend 0/3] mmc: omap_hsmmc: Enable SDIO IRQ.

2014-03-21 Thread Andreas Fenkart
Resend of v8, with Chris Ball on cc and following changes.

v9
- extended comment about why wake-irq is needed
- drop double '(' ')' around card_detect_irq
- drop final '.' in in subject line of patch

v8
- rebased on top of Tony Lindgren changes
  - improved changelog describing the earlier work
  - improved wakeup irq setup
  - works for am3730 es platform now
- my changes on top:
  - compile tested with #undef CONFIG_OF
  - disable wake_irq in handler to prevent infinite loop  
  - fixed typo and added comment about wake-irq

v7
- rebase on 3.14.0-rc3-49726-g77e15ec
- split omap_hsmmc_pin_init due to regression on omap-3730 platform

v6
- rebase on Linux 3.13-rc3
- reformatting debugfs

v5
- fix compile error introduced by last minute one line fix

v4:
- switch to interrupts-extended format
- drop ti,swakeup-missing flag convert to comaptible section

v3:
- removed gpio_irq from platform_data

v2:
- incorparated changes as suggested by reviewers
- simplified workaround for am335x, gpio will now only wake
  the module from runtime suspend, not handle the sdio irq
  itself 

Andreas Fenkart (3):
  mmc: omap_hsmmc: Enable SDIO interrupt
  mmc: omap_hsmmc: Pin remux workaround to support SDIO interrupt on
AM335x
  mmc: omap_hsmmc: Extend debugfs for SDIO IRQ, GPIO and pinmux

 .../devicetree/bindings/mmc/ti-omap-hsmmc.txt  |   50 +++
 drivers/mmc/host/omap_hsmmc.c  |  339 ++--
 include/linux/platform_data/mmc-omap.h |1 +
 3 files changed, 365 insertions(+), 25 deletions(-)

-- 
1.7.10.4

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


[PATCH v9 resend 3/3] mmc: omap_hsmmc: Extend debugfs for SDIO IRQ, GPIO and pinmux

2014-03-21 Thread Andreas Fenkart
Add SDIO IRQ entries to debugfs entry. Note that PSTATE shows current
state of data lines, incl. SDIO IRQ pending

Signed-off-by: Andreas Fenkart 
Signed-off-by: Tony Lindgren 

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 2307c78..681bf68 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -82,6 +82,7 @@ static void apply_clk_hack(struct device *dev)
 #define OMAP_HSMMC_RSP54   0x0118
 #define OMAP_HSMMC_RSP76   0x011C
 #define OMAP_HSMMC_DATA0x0120
+#define OMAP_HSMMC_PSTATE  0x0124
 #define OMAP_HSMMC_HCTL0x0128
 #define OMAP_HSMMC_SYSCTL  0x012C
 #define OMAP_HSMMC_STAT0x0130
@@ -1854,14 +1855,30 @@ static int omap_hsmmc_regs_show(struct seq_file *s, 
void *data)
 {
struct mmc_host *mmc = s->private;
struct omap_hsmmc_host *host = mmc_priv(mmc);
+   const char *cirq_state;
+   bool suspended;
 
-   seq_printf(s, "mmc%d:\n ctx_loss:\t%d\n\nregs:\n",
-   mmc->index, host->context_loss);
+   seq_printf(s, "mmc%d:\n", mmc->index);
+   if (mmc->caps & MMC_CAP_SDIO_IRQ)
+   cirq_state = (host->flags & HSMMC_SDIO_IRQ_ENABLED) ?
+   "enabled" : "disabled";
+   else
+   cirq_state = "polling";
+   seq_printf(s, "sdio irq\t%s\n", cirq_state);
 
-   pm_runtime_get_sync(host->dev);
+   if (host->flags & HSMMC_SWAKEUP_QUIRK) {
+   suspended = host->dev->power.runtime_status != RPM_ACTIVE;
+   seq_printf(s, "pinmux config\t%s\n", (suspended ?
+ "gpio" : "sdio"));
+   }
+   seq_printf(s, "ctx_loss:\t%d\n", host->context_loss);
 
+   pm_runtime_get_sync(host->dev);
+   seq_puts(s, "\nregs:\n");
seq_printf(s, "CON:\t\t0x%08x\n",
OMAP_HSMMC_READ(host->base, CON));
+   seq_printf(s, "PSTATE:\t\t0x%08x\n",
+  OMAP_HSMMC_READ(host->base, PSTATE));
seq_printf(s, "HCTL:\t\t0x%08x\n",
OMAP_HSMMC_READ(host->base, HCTL));
seq_printf(s, "SYSCTL:\t\t0x%08x\n",
-- 
1.7.10.4

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


[PATCH v9 resend 1/3] mmc: omap_hsmmc: Enable SDIO interrupt

2014-03-21 Thread Andreas Fenkart
There have been various patches floating around for enabling
the SDIO IRQ for hsmmc, but none of them ever got merged.

Probably the reason for not merging the SDIO interrupt patches
has been the lack of wake-up path for SDIO on some omaps that
has also needed remuxing the SDIO DAT1 line to a GPIO making
the patches complex.

This patch adds the minimal SDIO IRQ support to hsmmc for
omaps that do have the wake-up path. For those omaps, the
DAT1 line need to have the wake-up enable bit set, and the
wake-up interrupt is the same as for the MMC controller.

This patch has been tested on am3730 es1.2 with mwifiex
connected to MMC3 with mwifiex waking to Ethernet traffic
from off-idle mode. Note that for omaps that do not have
the SDIO wake-up path, this patch will not work for idle
modes and further patches for remuxing DAT1 to GPIO are
needed.

Based on earlier patches [1][2] by David Vrabel
, Steve Sakoman 
and Andreas Fenkart  with the SDIO IRQ
handing improved following how sdhci.c is doing it.

For now, only support SDIO interrupt if we are booted with
a separate wake-irq configued via device tree. This is
because omaps need the wake-irq for idle states, and some
omaps need special quirks. And we don't want to add new
legacy mux platform init code callbacks any longer as we
are moving to DT based booting anyways.

To use it, you need to specify the wake-irq using the
interrupts-extended property.

[1] 
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux.git;a=commitdiff_plain;h=010810d22f6f49ac03da4ba384969432e0320453
[2] http://comments.gmane.org/gmane.linux.kernel.mmc/20446

Cc: Balaji T K 
Signed-off-by: Andreas Fenkart 
Signed-off-by: Tony Lindgren 

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 317a9d5..06bf669 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -131,6 +133,7 @@ static void apply_clk_hack(struct device *dev)
 #define TC_EN  (1 << 1)
 #define BWR_EN (1 << 4)
 #define BRR_EN (1 << 5)
+#define CIRQ_EN(1 << 8)
 #define ERR_EN (1 << 15)
 #define CTO_EN (1 << 16)
 #define CCRC_EN(1 << 17)
@@ -205,6 +208,8 @@ struct omap_hsmmc_host {
u32 sysctl;
u32 capa;
int irq;
+   int wake_irq;
+   int wake_irq_en;
int use_dma, dma_ch;
struct dma_chan *tx_chan;
struct dma_chan *rx_chan;
@@ -215,6 +220,9 @@ struct omap_hsmmc_host {
int reqs_blocked;
int use_reg;
int req_in_progress;
+   int flags;
+#define HSMMC_SDIO_IRQ_ENABLED (1 << 0)/* SDIO irq enabled */
+#define HSMMC_SWAKEUP_QUIRK(1 << 1)
struct omap_hsmmc_next  next_data;
struct  omap_mmc_platform_data  *pdata;
 };
@@ -495,27 +503,40 @@ static void omap_hsmmc_stop_clock(struct omap_hsmmc_host 
*host)
 static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host,
  struct mmc_command *cmd)
 {
-   unsigned int irq_mask;
+   u32 irq_mask = INT_EN_MASK;
+   unsigned long flags;
 
if (host->use_dma)
-   irq_mask = INT_EN_MASK & ~(BRR_EN | BWR_EN);
-   else
-   irq_mask = INT_EN_MASK;
+   irq_mask &= ~(BRR_EN | BWR_EN);
 
/* Disable timeout for erases */
if (cmd->opcode == MMC_ERASE)
irq_mask &= ~DTO_EN;
 
+   spin_lock_irqsave(&host->irq_lock, flags);
OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
OMAP_HSMMC_WRITE(host->base, ISE, irq_mask);
+
+   /* latch pending CIRQ, but don't signal MMC core */
+   if (host->flags & HSMMC_SDIO_IRQ_ENABLED)
+   irq_mask |= CIRQ_EN;
OMAP_HSMMC_WRITE(host->base, IE, irq_mask);
+   spin_unlock_irqrestore(&host->irq_lock, flags);
 }
 
 static void omap_hsmmc_disable_irq(struct omap_hsmmc_host *host)
 {
-   OMAP_HSMMC_WRITE(host->base, ISE, 0);
-   OMAP_HSMMC_WRITE(host->base, IE, 0);
+   u32 irq_mask = 0;
+   unsigned long flags;
+
+   spin_lock_irqsave(&host->irq_lock, flags);
+   /* no transfer running but need to keep cirq if enabled */
+   if (host->flags & HSMMC_SDIO_IRQ_ENABLED)
+   irq_mask |= CIRQ_EN;
+   OMAP_HSMMC_WRITE(host->base, ISE, irq_mask);
+   OMAP_HSMMC_WRITE(host->base, IE, irq_mask);
OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
+   spin_unlock_irqrestore(&host->irq_lock, flags);
 }
 
 /* Calculate divisor for the given clock frequency */
@@ -1078,8 +1099,12 @@ stati

Re: [PATCH 23/62] ARM: omap1: fix building without 32K_TIMER

2014-03-21 Thread Arnd Bergmann
On Wednesday 19 March 2014, Tony Lindgren wrote:
> * Felipe Balbi  [140319 13:06]:
> > On Wed, Mar 19, 2014 at 02:59:13PM -0500, Felipe Balbi wrote:
> > > I had sent a fix for months and months ago, what happened to it ?
> > 
> > Here
> > 
> > http://marc.info/?l=linux-omap&m=138963632408031&w=2
> > 
> > Tony, did you forget to send a pull request ?
> 
> Hmm yes weird, can't see it in my omap-for-v3.14/fixes branch.
> 
> I must have gotten interrupted while applying and then probably
> ran git reset --hard before committing.
> 
> Arnd, maybe pick up Felipe's earlier patch instead?
> 
> Acked-by: Tony Lindgren 

Ok, using this version now, thanks!

Arnd

>From 64cdcf550319a37d1419aa6a87903e67b9d3d031 Mon Sep 17 00:00:00 2001
From: Felipe Balbi 
Date: Sun, 16 Mar 2014 17:57:55 +0100
Subject: [PATCH] ARM: omap1: fix build when !CONFIG_OMAP_32K_TIMER

If CONFIG_OMAP_32K_TIMER isn't enabled, we will
try to use enable_dyn_sleep which wasn't defined
anywhere.

In order to fix the problem, we always define
enable_dyn_sleep as 0 when !CONFIG_OMAP_32K_TIMER.

Signed-off-by: Felipe Balbi 
Acked-by: Tony Lindgren 
Signed-off-by: Arnd Bergmann 

diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
index 40a1ae3..dbee729 100644
--- a/arch/arm/mach-omap1/pm.c
+++ b/arch/arm/mach-omap1/pm.c
@@ -71,7 +71,11 @@ static unsigned int 
mpui7xx_sleep_save[MPUI7XX_SLEEP_SAVE_SIZE];
 static unsigned int mpui1510_sleep_save[MPUI1510_SLEEP_SAVE_SIZE];
 static unsigned int mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_SIZE];
 
-#ifdef CONFIG_OMAP_32K_TIMER
+#ifndef CONFIG_OMAP_32K_TIMER
+
+static unsigned short enable_dyn_sleep = 0;
+
+#else
 
 static unsigned short enable_dyn_sleep = 1;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 resend 1/3] mmc: omap_hsmmc: Enable SDIO interrupt

2014-03-21 Thread Balaji T K

On Friday 21 March 2014 05:50 PM, Andreas Fenkart wrote:

Thanks Andreas for the patch series

I rebased against latest mmc-next, made few changes to your patch.
I have hosted your series along with devm cleanups on a branch[1] for testing
[1]
git://git.ti.com/~balajitk/ti-linux-kernel/omap-hsmmc.git 
omap_hsmmc_sdio_irq_devm_cleanup

Can you please test on your platform and provide feedback.

Details about the changes below.


diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
@@ -1088,6 +1113,45 @@ static irqreturn_t omap_hsmmc_irq(int irq, void *dev_id)
return IRQ_HANDLED;
  }

+static inline void hsmmc_enable_wake_irq(struct omap_hsmmc_host *host)
+{
+   unsigned long flags;
+
+   if (!host->wake_irq)
+   return;
+
+   spin_lock_irqsave(&host->irq_lock, flags);
+   enable_irq(host->wake_irq);
+   host->wake_irq_en = true;


Using wake_irq_en flag leads to wake_irq enabled always after
suspend/resume due to unbalanced disable/enable_irq
so adding back HSMMC_WAKE_IRQ_ENABLED to host->flags


+   spin_unlock_irqrestore(&host->irq_lock, flags);
+}
+
+static inline void hsmmc_disable_wake_irq(struct omap_hsmmc_host *host)
+{
+   unsigned long flags;
+
+   if (!host->wake_irq)
+   return;
+
+   spin_lock_irqsave(&host->irq_lock, flags);
+   if (host->wake_irq_en)
+   disable_irq_nosync(host->wake_irq);
+   host->wake_irq_en = false;
+   spin_unlock_irqrestore(&host->irq_lock, flags);
+}
+
+static irqreturn_t omap_hsmmc_wake_irq(int irq, void *dev_id)
+{
+   struct omap_hsmmc_host *host = dev_id;
+
+   /* cirq is level triggered, disable to avoid infinite loop */
+   hsmmc_disable_wake_irq(host);
+
+   pm_request_resume(host->dev); /* no use counter */
+
+   return IRQ_HANDLED;
+}
+
  static void set_sd_bus_power(struct omap_hsmmc_host *host)
  {
unsigned long i;
@@ -1591,6 +1655,72 @@ static void omap_hsmmc_init_card(struct mmc_host *mmc, 
struct mmc_card *card)
mmc_slot(host).init_card(card);
  }

+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);
+


Introduced check for runtime suspend to be sure and explicitly
enable clocks using runtime_get_sync for enable sdio irq path.


+   irq_mask = OMAP_HSMMC_READ(host->base, ISE);
+   if (enable) {
+   host->flags |= HSMMC_SDIO_IRQ_ENABLED;
+   irq_mask |= CIRQ_EN;
+   } else {
+   host->flags &= ~HSMMC_SDIO_IRQ_ENABLED;
+   irq_mask &= ~CIRQ_EN;
+   }
+   OMAP_HSMMC_WRITE(host->base, IE, irq_mask);
+
+   /*
+* if enable, piggy back detection on current request
+* but always disable immediately
+*/
+   if (!host->req_in_progress || !enable)
+   OMAP_HSMMC_WRITE(host->base, ISE, irq_mask);
+
+   /* flush posted write */
+   OMAP_HSMMC_READ(host->base, IE);
+
+   spin_unlock_irqrestore(&host->irq_lock, flags);
+}
+
+static int omap_hscmm_configure_wake_irq(struct omap_hsmmc_host *host)
+{
+   struct mmc_host *mmc = host->mmc;
+   int ret;
+
+   /*
+* The wake-irq is needed for omaps with wake-up path and also
+* when doing GPIO remuxing, because omap_hsmmc is doing runtime PM.
+* So there's nothing stopping from shutting it down. And there's
+* really no need to block runtime PM for it as it's working.
+*/
+   if (!host->dev->of_node || !host->wake_irq)
+   return -ENODEV;
+
+   /* Prevent auto-enabling of IRQ */
+   irq_set_status_flags(host->wake_irq, IRQ_NOAUTOEN);
+   ret = request_irq(host->wake_irq, omap_hsmmc_wake_irq,
+ IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+ mmc_hostname(mmc), host);


Replaced request_irq with devm_request_irq


+   if (ret) {
+   dev_err(mmc_dev(host->mmc),
+   "Unable to request wake IRQ\n");
+   return ret;
+   }
+
+   /*
+* Some omaps don't have wake-up path from deeper idle states
+* and need to remux SDIO DAT1 to GPIO for wake-up from idle.
+*/
+   if (host->pdata->controller_flags & OMAP_HSMMC_SWAKEUP_MISSING)
+   host->flags |= HSMMC_SWAKEUP_QUIRK;
+
+   return 0;
+}
+
  static void omap_hsmmc_conf_bus_power(struct omap_hsmmc_host *host)
  {
u32 hctl, capa, value;
@@ -1643,7 +1773,7 @@ static const struct mmc_host_ops omap_hsmmc_ops = {
.get_cd = omap_hsmmc_get_cd,
.get_ro = omap_hsmmc_get_ro,
.init_card = omap_hsmmc_init_card,
-   /* NYET -- enable_sdio_irq */
+   .enable_sdio_irq = omap_hsmmc_enable_sdio_irq,
  };

  #ifdef CONFIG_DEBUG_FS
@@ -1704,8 +1834,19 @@ static void omap_hsmmc_debugfs(struct mmc_host *m

[PATCH 1/9] mmc: omap_hsmmc: use devm_clk_get

2014-03-21 Thread Balaji T K
With devm_clk_get conversion clk_put can be removed in clean up path

Signed-off-by: Balaji T K 
---
 drivers/mmc/host/omap_hsmmc.c |   15 ---
 1 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index e91ee21..578e983 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1922,7 +1922,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
spin_lock_init(&host->irq_lock);
 
-   host->fclk = clk_get(&pdev->dev, "fck");
+   host->fclk = devm_clk_get(&pdev->dev, "fck");
if (IS_ERR(host->fclk)) {
ret = PTR_ERR(host->fclk);
host->fclk = NULL;
@@ -1941,7 +1941,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
omap_hsmmc_context_save(host);
 
-   host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
+   host->dbclk = devm_clk_get(&pdev->dev, "mmchsdb_fck");
/*
 * MMC can still work without debounce clock.
 */
@@ -1949,7 +1949,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
host->dbclk = NULL;
} else if (clk_prepare_enable(host->dbclk) != 0) {
dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n");
-   clk_put(host->dbclk);
host->dbclk = NULL;
}
 
@@ -2105,11 +2104,8 @@ err_irq:
dma_release_channel(host->rx_chan);
pm_runtime_put_sync(host->dev);
pm_runtime_disable(host->dev);
-   clk_put(host->fclk);
-   if (host->dbclk) {
+   if (host->dbclk)
clk_disable_unprepare(host->dbclk);
-   clk_put(host->dbclk);
-   }
 err1:
iounmap(host->base);
mmc_free_host(mmc);
@@ -2144,11 +2140,8 @@ static int omap_hsmmc_remove(struct platform_device 
*pdev)
 
pm_runtime_put_sync(host->dev);
pm_runtime_disable(host->dev);
-   clk_put(host->fclk);
-   if (host->dbclk) {
+   if (host->dbclk)
clk_disable_unprepare(host->dbclk);
-   clk_put(host->dbclk);
-   }
 
omap_hsmmc_gpio_free(host->pdata);
iounmap(host->base);
-- 
1.7.5.4

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


[PATCH 2/9] mmc: omap_hsmmc: use devm_request_irq

2014-03-21 Thread Balaji T K
With devm_request_irq conversion free_irq can be removed in clean up path

Signed-off-by: Balaji T K 
---
 drivers/mmc/host/omap_hsmmc.c |7 ++-
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 578e983..4a3bb4b 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -2017,7 +2017,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
}
 
/* Request IRQ for MMC operations */
-   ret = request_irq(host->irq, omap_hsmmc_irq, 0,
+   ret = devm_request_irq(&pdev->dev, host->irq, omap_hsmmc_irq, 0,
mmc_hostname(mmc), host);
if (ret) {
dev_err(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n");
@@ -2028,7 +2028,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
if (pdata->init(&pdev->dev) != 0) {
dev_err(mmc_dev(host->mmc),
"Unable to configure MMC IRQs\n");
-   goto err_irq_cd_init;
+   goto err_irq;
}
}
 
@@ -2095,8 +2095,6 @@ err_irq_cd:
 err_reg:
if (host->pdata->cleanup)
host->pdata->cleanup(&pdev->dev);
-err_irq_cd_init:
-   free_irq(host->irq, host);
 err_irq:
if (host->tx_chan)
dma_release_channel(host->tx_chan);
@@ -2129,7 +2127,6 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
omap_hsmmc_reg_put(host);
if (host->pdata->cleanup)
host->pdata->cleanup(&pdev->dev);
-   free_irq(host->irq, host);
if (mmc_slot(host).card_detect_irq)
free_irq(mmc_slot(host).card_detect_irq, host);
 
-- 
1.7.5.4

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


[PATCH 0/9] mmc: omap_hsmmc: convert to use devm_* and enable sdio irq

2014-03-21 Thread Balaji T K
Andreas Fenkart (3):
  mmc: omap_hsmmc: Enable SDIO interrupt
  mmc: omap_hsmmc: Pin remux workaround to support SDIO interrupt on
AM335x
  mmc: omap_hsmmc: Extend debugfs for SDIO IRQ, GPIO and pinmux

Balaji T K (6):
  mmc: omap_hsmmc: use devm_clk_get
  mmc: omap_hsmmc: use devm_request_irq
  mmc: omap_hsmmc: use devm_request_threaded_irq
  mmc: omap_hsmmc: use devm_request_mem_region
  mmc: omap_hsmmc: use devm_ioremap
  mmc: omap_hsmmc: enable wakeup event for sdio

 .../devicetree/bindings/mmc/ti-omap-hsmmc.txt  |   50 +++
 drivers/mmc/host/omap_hsmmc.c  |  349 +---
 include/linux/platform_data/mmc-omap.h |1 +
 3 files changed, 346 insertions(+), 54 deletions(-)

-- 
1.7.5.4

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


[PATCH 3/9] mmc: omap_hsmmc: use devm_request_threaded_irq

2014-03-21 Thread Balaji T K
With devm_request_threaded_irq conversion free_irq can be removed
in clean up path

Signed-off-by: Balaji T K 
---
 drivers/mmc/host/omap_hsmmc.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 4a3bb4b..8e35a6e 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -2043,9 +2043,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
/* Request IRQ for card detect */
if ((mmc_slot(host).card_detect_irq)) {
-   ret = request_threaded_irq(mmc_slot(host).card_detect_irq,
-  NULL,
-  omap_hsmmc_detect,
+   ret = devm_request_threaded_irq(&pdev->dev,
+   mmc_slot(host).card_detect_irq,
+   NULL, omap_hsmmc_detect,
   IRQF_TRIGGER_RISING | 
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
   mmc_hostname(mmc), host);
if (ret) {
@@ -2088,7 +2088,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
 err_slot_name:
mmc_remove_host(mmc);
-   free_irq(mmc_slot(host).card_detect_irq, host);
 err_irq_cd:
if (host->use_reg)
omap_hsmmc_reg_put(host);
@@ -2127,8 +2126,6 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
omap_hsmmc_reg_put(host);
if (host->pdata->cleanup)
host->pdata->cleanup(&pdev->dev);
-   if (mmc_slot(host).card_detect_irq)
-   free_irq(mmc_slot(host).card_detect_irq, host);
 
if (host->tx_chan)
dma_release_channel(host->tx_chan);
-- 
1.7.5.4

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


[PATCH 5/9] mmc: omap_hsmmc: use devm_ioremap

2014-03-21 Thread Balaji T K
With devm_ioremap conversion iounmap can be removed in clean up path

Signed-off-by: Balaji T K 
---
 drivers/mmc/host/omap_hsmmc.c |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 9952673..38a75bc 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1905,7 +1905,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
host->irq   = irq;
host->slot_id   = 0;
host->mapbase   = res->start + pdata->reg_offset;
-   host->base  = ioremap(host->mapbase, SZ_4K);
+   host->base  = devm_ioremap(&pdev->dev, host->mapbase, SZ_4K);
host->power_mode = MMC_POWER_OFF;
host->next_data.cookie = 1;
host->pbias_enabled = 0;
@@ -2105,7 +2105,6 @@ err_irq:
if (host->dbclk)
clk_disable_unprepare(host->dbclk);
 err1:
-   iounmap(host->base);
mmc_free_host(mmc);
 err_alloc:
omap_hsmmc_gpio_free(pdata);
@@ -2135,7 +2134,6 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
clk_disable_unprepare(host->dbclk);
 
omap_hsmmc_gpio_free(host->pdata);
-   iounmap(host->base);
mmc_free_host(host->mmc);
 
return 0;
-- 
1.7.5.4

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


[PATCH 6/9] mmc: omap_hsmmc: Enable SDIO interrupt

2014-03-21 Thread Balaji T K
From: Andreas Fenkart 

There have been various patches floating around for enabling
the SDIO IRQ for hsmmc, but none of them ever got merged.

Probably the reason for not merging the SDIO interrupt patches
has been the lack of wake-up path for SDIO on some omaps that
has also needed remuxing the SDIO DAT1 line to a GPIO making
the patches complex.

This patch adds the minimal SDIO IRQ support to hsmmc for
omaps that do have the wake-up path. For those omaps, the
DAT1 line need to have the wake-up enable bit set, and the
wake-up interrupt is the same as for the MMC controller.

This patch has been tested on am3730 es1.2 with mwifiex
connected to MMC3 with mwifiex waking to Ethernet traffic
from off-idle mode. Note that for omaps that do not have
the SDIO wake-up path, this patch will not work for idle
modes and further patches for remuxing DAT1 to GPIO are
needed.

Based on earlier patches [1][2] by David Vrabel
, Steve Sakoman 
and Andreas Fenkart  with the SDIO IRQ
handing improved following how sdhci.c is doing it.

For now, only support SDIO interrupt if we are booted with
a separate wake-irq configued via device tree. This is
because omaps need the wake-irq for idle states, and some
omaps need special quirks. And we don't want to add new
legacy mux platform init code callbacks any longer as we
are moving to DT based booting anyways.

To use it, you need to specify the wake-irq using the
interrupts-extended property.

[1] 
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux.git;a=commitdiff_plain;h=010810d22f6f49ac03da4ba384969432e0320453
[2] http://comments.gmane.org/gmane.linux.kernel.mmc/20446

Signed-off-by: Andreas Fenkart 
Signed-off-by: Tony Lindgren 
Signed-off-by: Balaji T K 
---
 drivers/mmc/host/omap_hsmmc.c  |  207 ++--
 include/linux/platform_data/mmc-omap.h |1 +
 2 files changed, 196 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 38a75bc..0275e0a 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -106,6 +108,7 @@
 #define TC_EN  (1 << 1)
 #define BWR_EN (1 << 4)
 #define BRR_EN (1 << 5)
+#define CIRQ_EN(1 << 8)
 #define ERR_EN (1 << 15)
 #define CTO_EN (1 << 16)
 #define CCRC_EN(1 << 17)
@@ -140,7 +143,6 @@
 #define VDD_3V0300 /* 30 uV */
 #define VDD_165_195(ffs(MMC_VDD_165_195) - 1)
 
-#define AUTO_CMD23 (1 << 1)/* Auto CMD23 support */
 /*
  * One controller can have multiple slots, like on some omap boards using
  * omap.c controller driver. Luckily this is not currently done on any known
@@ -194,6 +196,7 @@ struct omap_hsmmc_host {
u32 sysctl;
u32 capa;
int irq;
+   int wake_irq;
int use_dma, dma_ch;
struct dma_chan *tx_chan;
struct dma_chan *rx_chan;
@@ -206,6 +209,11 @@ struct omap_hsmmc_host {
int req_in_progress;
unsigned long   clk_rate;
unsigned intflags;
+#define HSMMC_RUNTIME_SUSPENDED (1 << 0)
+#define AUTO_CMD23 (1 << 1)/* Auto CMD23 support */
+#define HSMMC_SWAKEUP_QUIRK(1 << 2)
+#define HSMMC_SDIO_IRQ_ENABLED (1 << 3)/* SDIO irq enabled */
+#define HSMMC_WAKE_IRQ_ENABLED (1 << 4)
struct omap_hsmmc_next  next_data;
struct  omap_mmc_platform_data  *pdata;
 };
@@ -510,27 +518,40 @@ static void omap_hsmmc_stop_clock(struct omap_hsmmc_host 
*host)
 static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host,
  struct mmc_command *cmd)
 {
-   unsigned int irq_mask;
+   u32 irq_mask = INT_EN_MASK;
+   unsigned long flags;
 
if (host->use_dma)
-   irq_mask = INT_EN_MASK & ~(BRR_EN | BWR_EN);
-   else
-   irq_mask = INT_EN_MASK;
+   irq_mask &= ~(BRR_EN | BWR_EN);
 
/* Disable timeout for erases */
if (cmd->opcode == MMC_ERASE)
irq_mask &= ~DTO_EN;
 
+   spin_lock_irqsave(&host->irq_lock, flags);
OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
OMAP_HSMMC_WRITE(host->base, ISE, irq_mask);
+
+   /* latch pending CIRQ, but don't signal MMC core */
+   if (host->flags & HSMMC_SDIO_IRQ_ENABLED)
+   irq_mask |= CIRQ_EN;
OMAP_HSMMC_WRITE(host->base, IE, irq_mask);
+   spin_unlock_irqrestore(&host->irq_lock, flags);
 }
 
 static void omap_hsmmc_disable_irq(struct omap_hsmmc_host *host)
 {
-   OMAP_HSMMC_WRITE(host->bas

[PATCH 4/9] mmc: omap_hsmmc: use devm_request_mem_region

2014-03-21 Thread Balaji T K
With devm_request_mem_region conversion release_mem_region can be
removed in clean up path

Signed-off-by: Balaji T K 
---
 drivers/mmc/host/omap_hsmmc.c |   11 ++-
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 8e35a6e..9952673 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1881,7 +1881,8 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
if (res == NULL || irq < 0)
return -ENXIO;
 
-   res = request_mem_region(res->start, resource_size(res), pdev->name);
+   res = devm_request_mem_region(&pdev->dev, res->start,
+   resource_size(res), pdev->name);
if (res == NULL)
return -EBUSY;
 
@@ -2109,16 +2110,12 @@ err1:
 err_alloc:
omap_hsmmc_gpio_free(pdata);
 err:
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (res)
-   release_mem_region(res->start, resource_size(res));
return ret;
 }
 
 static int omap_hsmmc_remove(struct platform_device *pdev)
 {
struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
-   struct resource *res;
 
pm_runtime_get_sync(host->dev);
mmc_remove_host(host->mmc);
@@ -2141,10 +2138,6 @@ static int omap_hsmmc_remove(struct platform_device 
*pdev)
iounmap(host->base);
mmc_free_host(host->mmc);
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (res)
-   release_mem_region(res->start, resource_size(res));
-
return 0;
 }
 
-- 
1.7.5.4

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


[PATCH 7/9] mmc: omap_hsmmc: Pin remux workaround to support SDIO interrupt on AM335x

2014-03-21 Thread Balaji T K
From: Andreas Fenkart 

The am335x can't detect pending cirq in PM runtime suspend.
This patch reconfigures dat1 as a GPIO before going to suspend.
SDIO interrupts are detected with the GPIO, the GPIO will only wake
the module from suspend, SDIO irq detection will still happen through the
IP block.

Idea of remuxing the pins and some minor changes by Tony Lindgren.

Signed-off-by: Andreas Fenkart 
Signed-off-by: Tony Lindgren 
Signed-off-by: Balaji T K 
---
 .../devicetree/bindings/mmc/ti-omap-hsmmc.txt  |   50 +
 drivers/mmc/host/omap_hsmmc.c  |   74 +---
 2 files changed, 113 insertions(+), 11 deletions(-)

diff --git a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt 
b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
index ce80561..0f9b426 100644
--- a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
+++ b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
@@ -56,3 +56,53 @@ Examples:
&edma 25>;
dma-names = "tx", "rx";
};
+
+[workaround for missing swakeup on am33xx]
+
+This SOC is missing the swakeup line, it will not detect SDIO irq
+while in suspend.
+
+ --
+ | PRCM |
+  --
+   ^ |
+   swakeup | | fclk
+   | v
+   -----   -
+  | card | -- CIRQ -->  | hsmmc | -- IRQ -->  | CPU |
+   -----   -
+
+In suspend the fclk is off and the module is disfunctional. Even
+register reads will fail. A small logic in the host will request
+fclk restore, when an external event is detected. Once the clock
+is restored, the host detects the event normally. Since am33xx
+doesn't have this line it never wakes from suspend.
+
+The workaround is to reconfigure the dat1 line as a GPIO upon
+suspend. To make this work, we need to set 1) the named pinctrl
+states "default", "active" and "idle", 2) the gpio detecting
+sdio irq in suspend and 3) compatibe section, see example below.
+The MMC driver will then toggle between active and idle during
+the runtime. If configuration is incomplete, a warning message is
+emitted "falling back to polling".  Mind not every application
+needs SDIO irq, e.g. MMC cards Affected chips are am335x,
+probably others
+
+
+   mmc1: mmc@48060100 {
+   compatible = "ti,am33xx-hsmmc";
+   ...
+   interrupts-extended = <&intc 64 &gpio2 28 0>;
+   ...
+   pinctrl-names = "default", "active", "idle"
+   pinctrl-0 = <&mmc1_pins>;
+   pinctrl-1 = <&mmc1_pins>;
+   pinctrl-2 = <&mmc1_cirq_pin>;
+   ...
+   };
+
+   mmc1_cirq_pin: pinmux_cirq_pin {
+   pinctrl-single,pins = <
+   0x0f8 0x3f  /* GPIO2_28 */
+   >;
+   };
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 0275e0a..dc23ac7 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -215,6 +215,8 @@ struct omap_hsmmc_host {
 #define HSMMC_SDIO_IRQ_ENABLED (1 << 3)/* SDIO irq enabled */
 #define HSMMC_WAKE_IRQ_ENABLED (1 << 4)
struct omap_hsmmc_next  next_data;
+   struct pinctrl  *pinctrl;
+   struct pinctrl_state*active;
struct  omap_mmc_platform_data  *pdata;
 };
 
@@ -495,6 +497,47 @@ static void omap_hsmmc_gpio_free(struct 
omap_mmc_platform_data *pdata)
gpio_free(pdata->slots[0].switch_pin);
 }
 
+static int omap_hsmmc_pin_init(struct omap_hsmmc_host *host)
+{
+   struct pinctrl *_pinctrl;
+   int ret;
+
+   _pinctrl = devm_pinctrl_get(host->dev);
+   if (IS_ERR(_pinctrl)) {
+   /* okay, if the bootloader set it up right */
+   dev_warn(host->dev, "no pinctrl handle\n");
+   return 0;
+   }
+
+   /* For most cases we don't have wake-ups, and exit after this */
+   host->active = pinctrl_lookup_state(_pinctrl, "active");
+   if (IS_ERR(host->active)) {
+   ret = PTR_ERR(host->active);
+   host->active = NULL;
+   goto done;
+   }
+
+   /* Let's make sure the active and idle states work */
+   ret = pinctrl_pm_select_idle_state(host->dev);
+   if (ret < 0)
+   goto err;
+
+   ret = pinctrl_select_state(_pinctrl, host->active);
+   if (ret < 0)
+   goto err;
+
+   dev_info(mmc_dev(host->mmc), "pins configured for wake-up events\n");
+
+done:
+   host->pinctrl = _pinctrl;
+   return 0;
+
+err:
+   dev_err(mmc_dev(host->mmc), "pins configuration error: %i\n", ret);
+   devm_pinctrl_put(_pinctrl);
+   return ret;
+}
+
 /*
  * Start clock to the card
  */
@@ -1737,7 +1780,7 @@ static int omap_hsmmc_configure_wake_ir

[PATCH 8/9] mmc: omap_hsmmc: Extend debugfs for SDIO IRQ, GPIO and pinmux

2014-03-21 Thread Balaji T K
From: Andreas Fenkart 

Add SDIO IRQ entries to debugfs entry. Note that PSTATE shows current
state of data lines, incl. SDIO IRQ pending

Signed-off-by: Andreas Fenkart 
Signed-off-by: Tony Lindgren 
Signed-off-by: Balaji T K 
---
 drivers/mmc/host/omap_hsmmc.c |   23 ---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index dc23ac7..2482783 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -56,6 +56,7 @@
 #define OMAP_HSMMC_RSP54   0x0118
 #define OMAP_HSMMC_RSP76   0x011C
 #define OMAP_HSMMC_DATA0x0120
+#define OMAP_HSMMC_PSTATE  0x0124
 #define OMAP_HSMMC_HCTL0x0128
 #define OMAP_HSMMC_SYSCTL  0x012C
 #define OMAP_HSMMC_STAT0x0130
@@ -1865,14 +1866,30 @@ static int omap_hsmmc_regs_show(struct seq_file *s, 
void *data)
 {
struct mmc_host *mmc = s->private;
struct omap_hsmmc_host *host = mmc_priv(mmc);
+   const char *cirq_state;
+   bool suspended;
 
-   seq_printf(s, "mmc%d:\n ctx_loss:\t%d\n\nregs:\n",
-   mmc->index, host->context_loss);
+   seq_printf(s, "mmc%d:\n", mmc->index);
+   if (mmc->caps & MMC_CAP_SDIO_IRQ)
+   cirq_state = (host->flags & HSMMC_SDIO_IRQ_ENABLED) ?
+   "enabled" : "disabled";
+   else
+   cirq_state = "polling";
+   seq_printf(s, "sdio irq\t%s\n", cirq_state);
 
-   pm_runtime_get_sync(host->dev);
+   if (host->flags & HSMMC_SWAKEUP_QUIRK) {
+   suspended = host->dev->power.runtime_status != RPM_ACTIVE;
+   seq_printf(s, "pinmux config\t%s\n", (suspended ?
+ "gpio" : "sdio"));
+   }
+   seq_printf(s, "ctx_loss:\t%d\n", host->context_loss);
 
+   pm_runtime_get_sync(host->dev);
+   seq_puts(s, "\nregs:\n");
seq_printf(s, "CON:\t\t0x%08x\n",
OMAP_HSMMC_READ(host->base, CON));
+   seq_printf(s, "PSTATE:\t\t0x%08x\n",
+  OMAP_HSMMC_READ(host->base, PSTATE));
seq_printf(s, "HCTL:\t\t0x%08x\n",
OMAP_HSMMC_READ(host->base, HCTL));
seq_printf(s, "SYSCTL:\t\t0x%08x\n",
-- 
1.7.5.4

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


[PATCH 9/9] mmc: omap_hsmmc: enable wakeup event for sdio

2014-03-21 Thread Balaji T K
To detect sdio irqs properly without spurious events,
OMAP4 needs IWE in CON and CTPL, CLKEXTFREE in HCTL to be set

Signed-off-by: Balaji T K 
---
 drivers/mmc/host/omap_hsmmc.c |   13 -
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 2482783..120f7cf 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -94,7 +94,10 @@
 #define BCE(1 << 1)
 #define FOUR_BIT   (1 << 1)
 #define HSPE   (1 << 2)
+#define IWE(1 << 24)
 #define DDR(1 << 19)
+#define CLKEXTFREE (1 << 16)
+#define CTPL   (1 << 11)
 #define DW8(1 << 5)
 #define OD 0x1
 #define STAT_CLEAR 0x
@@ -732,6 +735,8 @@ static int omap_hsmmc_context_restore(struct 
omap_hsmmc_host *host)
capa = VS18;
}
 
+   if (host->mmc->caps & MMC_CAP_SDIO_IRQ)
+   hctl |= IWE;
OMAP_HSMMC_WRITE(host->base, HCTL,
OMAP_HSMMC_READ(host->base, HCTL) | hctl);
 
@@ -1728,7 +1733,7 @@ static void omap_hsmmc_init_card(struct mmc_host *mmc, 
struct mmc_card *card)
 static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 {
struct omap_hsmmc_host *host = mmc_priv(mmc);
-   u32 irq_mask;
+   u32 irq_mask, con;
unsigned long flags;
 
if (enable)
@@ -1737,14 +1742,18 @@ static void omap_hsmmc_enable_sdio_irq(struct mmc_host 
*mmc, int enable)
if (host->flags & HSMMC_RUNTIME_SUSPENDED)
goto out;
 
+   con = OMAP_HSMMC_READ(host->base, CON);
irq_mask = OMAP_HSMMC_READ(host->base, ISE);
if (enable) {
host->flags |= HSMMC_SDIO_IRQ_ENABLED;
irq_mask |= CIRQ_EN;
+   con |= CTPL | CLKEXTFREE;
} else {
host->flags &= ~HSMMC_SDIO_IRQ_ENABLED;
irq_mask &= ~CIRQ_EN;
+   con &= ~(CTPL | CLKEXTFREE);
}
+   OMAP_HSMMC_WRITE(host->base, CON, con);
OMAP_HSMMC_WRITE(host->base, IE, irq_mask);
 
/*
@@ -1801,6 +1810,8 @@ static int omap_hsmmc_configure_wake_irq(struct 
omap_hsmmc_host *host)
}
host->flags |= HSMMC_SWAKEUP_QUIRK;
}
+   OMAP_HSMMC_WRITE(host->base, HCTL,
+OMAP_HSMMC_READ(host->base, HCTL) | IWE);
 
return 0;
 }
-- 
1.7.5.4

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


Re: [PATCH 4/9] mmc: omap_hsmmc: use devm_request_mem_region

2014-03-21 Thread Felipe Balbi
On Fri, Mar 21, 2014 at 09:47:33PM +0530, Balaji T K wrote:
> With devm_request_mem_region conversion release_mem_region can be
> removed in clean up path
> 
> Signed-off-by: Balaji T K 
> ---
>  drivers/mmc/host/omap_hsmmc.c |   11 ++-
>  1 files changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 8e35a6e..9952673 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -1881,7 +1881,8 @@ static int omap_hsmmc_probe(struct platform_device 
> *pdev)
>   if (res == NULL || irq < 0)
>   return -ENXIO;
>  
> - res = request_mem_region(res->start, resource_size(res), pdev->name);
> + res = devm_request_mem_region(&pdev->dev, res->start,
> + resource_size(res), pdev->name);

while at that, why don't you switch over to devm_ioremap_resource()
already ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 4/9] mmc: omap_hsmmc: use devm_request_mem_region

2014-03-21 Thread Balaji T K

On Friday 21 March 2014 09:48 PM, Felipe Balbi wrote:

On Fri, Mar 21, 2014 at 09:47:33PM +0530, Balaji T K wrote:

With devm_request_mem_region conversion release_mem_region can be
removed in clean up path

Signed-off-by: Balaji T K 
---
  drivers/mmc/host/omap_hsmmc.c |   11 ++-
  1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 8e35a6e..9952673 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1881,7 +1881,8 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
if (res == NULL || irq < 0)
return -ENXIO;

-   res = request_mem_region(res->start, resource_size(res), pdev->name);
+   res = devm_request_mem_region(&pdev->dev, res->start,
+   resource_size(res), pdev->name);


while at that, why don't you switch over to devm_ioremap_resource()
already ?


I can't do that because of 0x100 reg_offset on OMAP4+ and am335x+

Thanks and Regards,
Balaji T K
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/9] mmc: omap_hsmmc: use devm_request_mem_region

2014-03-21 Thread Felipe Balbi
On Fri, Mar 21, 2014 at 09:57:52PM +0530, Balaji T K wrote:
> On Friday 21 March 2014 09:48 PM, Felipe Balbi wrote:
> >On Fri, Mar 21, 2014 at 09:47:33PM +0530, Balaji T K wrote:
> >>With devm_request_mem_region conversion release_mem_region can be
> >>removed in clean up path
> >>
> >>Signed-off-by: Balaji T K 
> >>---
> >>  drivers/mmc/host/omap_hsmmc.c |   11 ++-
> >>  1 files changed, 2 insertions(+), 9 deletions(-)
> >>
> >>diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> >>index 8e35a6e..9952673 100644
> >>--- a/drivers/mmc/host/omap_hsmmc.c
> >>+++ b/drivers/mmc/host/omap_hsmmc.c
> >>@@ -1881,7 +1881,8 @@ static int omap_hsmmc_probe(struct platform_device 
> >>*pdev)
> >>if (res == NULL || irq < 0)
> >>return -ENXIO;
> >>
> >>-   res = request_mem_region(res->start, resource_size(res), pdev->name);
> >>+   res = devm_request_mem_region(&pdev->dev, res->start,
> >>+   resource_size(res), pdev->name);
> >
> >while at that, why don't you switch over to devm_ioremap_resource()
> >already ?
> 
> I can't do that because of 0x100 reg_offset on OMAP4+ and am335x+

split the resource into two parts, one is OMAP-specific and the other is
the generic SDHCI start.

-- 
balbi


signature.asc
Description: Digital signature


[PATCH RFC 0/2] Move dai-link level properties away from dai subnodes

2014-03-21 Thread Jyri Sarha
This patch is implemented on top of late patches from Jean-Francois
Moine [1]. 

The patches implement the main part of the simple-card changes
discussed in alsa-devel mailing list.

[1] http://mailman.alsa-project.org/pipermail/alsa-devel/2014-March/074592.html

Best regards,
Jyri

Jyri Sarha (2):
  ASoC: core: Update snd_soc_of_parse_daifmt() interface
  ASoC: simple-card: Move dai-link level properties away from dai
subnodes

 .../devicetree/bindings/sound/simple-card.txt  |   91 
 include/sound/soc.h|4 +-
 sound/soc/generic/simple-card.c|  237 
 sound/soc/soc-core.c   |8 +-
 4 files changed, 201 insertions(+), 139 deletions(-)

-- 
1.7.9.5

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


[PATCH RFC 2/2] ASoC: simple-card: Move dai-link level properties away from dai subnodes

2014-03-21 Thread Jyri Sarha
The properties like format, bitclock-master, frame-master,
bitclock-inversion, and frame-inversion should be common to the dais
connected with a dai-link. For bitclock-master and frame-master
properties to be unambiguous they need to indicate the mastering dai
node with a phandle.

Signed-off-by: Jyri Sarha 
---
 .../devicetree/bindings/sound/simple-card.txt  |   91 
 sound/soc/generic/simple-card.c|  237 
 2 files changed, 191 insertions(+), 137 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt 
b/Documentation/devicetree/bindings/sound/simple-card.txt
index 131aa2a..3cafa9e 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -1,6 +1,6 @@
 Simple-Card:
 
-Simple-Card specifies audio DAI connection of SoC <-> codec.
+Simple-Card specifies audio DAI connections of SoC <-> codec.
 
 Required properties:
 
@@ -8,28 +8,54 @@ Required properties:
 
 Optional properties:
 
-- simple-audio-card,name   : User specified audio sound card name, 
one string
+- simple-audio-card,name   : User specified audio sound card name,
+one string
  property.
-- simple-audio-card,format : CPU/CODEC common audio format.
- "i2s", "right_j", "left_j" , "dsp_a"
- "dsp_b", "ac97", "pdm", "msb", "lsb"
 - simple-audio-card,widgets: Please refer to widgets.txt.
 - simple-audio-card,routing: A list of the connections between 
audio components.
  Each entry is a pair of strings, the 
first being the
  connection's sink, the second being 
the connection's
  source.
-- dai-tdm-slot-num : Please refer to tdm-slot.txt.
-- dai-tdm-slot-width   : Please refer to tdm-slot.txt.
+Optional subnodes:
+
+- simple-audio-card,dai-link   : Container for dai-link level
+ properties and the CPU and CODEC
+ sub-nodes. This container may be
+ omitted when the card has only one
+ DAI link. See the examples and the
+ section bellow.
+
+Dai-link subnode properties and subnodes:
+
+If dai-link subnode is omitted and the subnode properties are directly
+under "sound"-node the subnode property and subnode names have to be
+prefixed with "simple-audio-card,"-prefix.
 
-Required subnodes:
+Requred dai-link subnodes:
 
-- simple-audio-card,dai-link   : container for the CPU and CODEC 
sub-nodes
- This container may be omitted when the
- card has only one DAI link.
- See the examples.
+- cpu  : CPU   sub-node
+- codec: CODEC sub-node
 
-- simple-audio-card,cpu: CPU   sub-node
-- simple-audio-card,codec  : CODEC sub-node
+Optional dai-link subnode properties:
+
+- format   : CPU/CODEC common audio format.
+ "i2s", "right_j", "left_j" , "dsp_a"
+ "dsp_b", "ac97", "pdm", "msb", "lsb"
+- frame-master : Indicates dai-link frame master.
+ phandle to a cpu or codec subnode.
+- bitclock-master  : Indicates dai-link bit clock master.
+ phandle to a cpu or codec subnode.
+- bitclock-inversion   : bool property. Add this if the
+ dai-link uses bit clock inversion.
+- frame-inversion  : bool property. Add this if the
+ dai-link uses frame clock inversion.
+
+For backward compatibility the frame-master and bitclock-master
+properties can be used as booleans in codec subnode to indicate if the
+codec is the dai-link frame or bit clock master. In this case the same
+properties should not be present at dai-link level and the
+bitclock-inversion and frame-inversion properties should also be placed
+in the codec node if needed.
 
 Required CPU/CODEC subnodes properties:
 
@@ -37,29 +63,21 @@ Required CPU/CODEC subnodes properties:
 
 Optional CPU/CODEC subnodes properties:
 
-- format   : CPU/CODEC specific audio format if 
needed.
- see simple-audio-card,format
-- frame-master : bool property. add this if subnode is 
frame m

[PATCH RFC 1/2] ASoC: core: Update snd_soc_of_parse_daifmt() interface

2014-03-21 Thread Jyri Sarha
Adds struct device_node **bitclkmaster and struct device_node **framemaster
function parameters. With the new syntax bitclock-master and frame-master
properties can explicitly indicate the dai-link bit-clock and frame masters
with a phandle.

Signed-off-by: Jyri Sarha 
---
 include/sound/soc.h  |4 +++-
 sound/soc/soc-core.c |8 +++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index f7de629..e40713a 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1228,7 +1228,9 @@ int snd_soc_of_parse_tdm_slot(struct device_node *np,
 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
   const char *propname);
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
-const char *prefix);
+const char *prefix,
+struct device_node **bitclkmaster,
+struct device_node **framemaster);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
const char **dai_name);
 
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index b322cf2..7979dcc 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4560,7 +4560,9 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card 
*card,
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_routing);
 
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
-const char *prefix)
+const char *prefix,
+struct device_node **bitclkmaster,
+struct device_node **framemaster)
 {
int ret, i;
char prop[128];
@@ -4643,9 +4645,13 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node 
*np,
 */
snprintf(prop, sizeof(prop), "%sbitclock-master", prefix);
bit = !!of_get_property(np, prop, NULL);
+   if (bit && bitclkmaster)
+   *bitclkmaster = of_parse_phandle(np, prop, 0);
 
snprintf(prop, sizeof(prop), "%sframe-master", prefix);
frame = !!of_get_property(np, prop, NULL);
+   if (frame && framemaster)
+   *framemaster = of_parse_phandle(np, prop, 0);
 
switch ((bit << 4) + frame) {
case 0x11:
-- 
1.7.9.5

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


Re: [RFC] possible removal of omap-serial

2014-03-21 Thread Tony Lindgren
* Felipe Balbi  [140320 19:57]:
> On Thu, Mar 20, 2014 at 09:45:42PM -0500, Robert Nelson wrote:
> > On Thu, Mar 20, 2014 at 9:36 PM, Greg KH  wrote:
> > > On Thu, Mar 20, 2014 at 08:37:29PM -0500, Felipe Balbi wrote:
> > >> On Thu, Mar 20, 2014 at 08:35:57PM -0500, Felipe Balbi wrote:
> > >> > Hi,
> > >> >
> > >> > On Thu, Mar 20, 2014 at 05:12:28PM -0700, Greg KH wrote:
> > >> > > On Thu, Mar 20, 2014 at 06:52:10PM -0500, Felipe Balbi wrote:
> > >> > > > Hi folks,
> > >> > > >
> > >> > > > I've been toying with the idea of removing
> > >> > > > drivers/tty/serial/omap-serial.c since that's, to put it bluntly, 
> > >> > > > an
> > >> > > > ungly copy of 8250 driver.
> > >> > > >
> > >> > > > The original concern was wrt suspend/resume but I think it'd be a 
> > >> > > > far
> > >> > > > better approach to implement runtime PM in 8250 and write a rather 
> > >> > > > small
> > >> > > > 8250-omap.c glue (much like 8250-acorn.c or 8250-dw.c) just to get 
> > >> > > > the
> > >> > > > OMAP-specific details out of the way.
> > >> > > >
> > >> > > > The question I have is: omap-serial.c calls the serial devnodes 
> > >> > > > ttyO\d,
> > >> > > > instead of ttyS\d so removing omap-serial.c would have a direct 
> > >> > > > impact
> > >> > > > in userland. I wonder if it's an acceptable "regression" 
> > >> > > > considering
> > >> > > > we'd be able to reuse 8250 gaining proper Flow Control support, 
> > >> > > > proper
> > >> > > > DMA support, years and years of bug-fixes, etc.
> > >> > >
> > >> > > Breaking device node names is a contentious issue for serial ports, I
> > >> > > don't think you can do that :(
> > >> >
> > >> > would an upstream udev rule creating a symbolic link from ttyO to ttyS
> > >> > be enough ?
> > >> >
> > >> > I didn't test this yet but I guess this is enough (?)
> > >> >
> > >> > KERNEL=="ttyO[0-9]", GROUP="dialout", SYMLINK+="ttyS"
> > >>
> > >> or actually it should be to other way around, ttyS would be the real
> > >> device:
> > >>
> > >> KERNEL=="ttyS[0-9]", GROUP="dialout", SYMLINK+="ttyO"
> > >
> > > As udev rules don't ship with the kernel, this might be tough to do :(
> > >
> > > Might be easier to make the 8250 driver handle different "names" like
> > > Alan said.
> 
> I'll see if I find a way to avoid that or at least see if we find any
> other way of creating a symlink... In any case, just switching back to
> 8250, even if just maintaining ttyO name, is already a big benefit.
> 
> > On the support side, I'm not looking forward to this for beagle/panda
> > users.  We've already converted them once from ttySx -> ttyOx back in
> > 2.6.33/2.6.34? days.  That was an irc/email/u-boot/kernel nightmare...
> 
> that's exactly why we're talking about ways to maintain backwards
> compatibility here. But I'm more interested in finding a way to switch
> over to ttyS and have a symlink to ttyO, that way a simple debootstrap
> (or any other ARM distro minimal rootfs) would work out of the box,
> without any changes, just like in "normal" systems.

Yeah let's not break things. The symlink solution won't work for kernel
console output so it needs to be dealt with some other way.

It seems that the biggest amount of work is making existing 8250
support the missing features in a clean way and without breaking
other platforms. Looks like 8250_dw.c has some pm_runtime_calls so
obviously it's doable.

Regards,

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


Re: [RFC] possible removal of omap-serial

2014-03-21 Thread Felipe Balbi
Hi,

On Fri, Mar 21, 2014 at 10:10:30AM -0700, Tony Lindgren wrote:
> > > On the support side, I'm not looking forward to this for beagle/panda
> > > users.  We've already converted them once from ttySx -> ttyOx back in
> > > 2.6.33/2.6.34? days.  That was an irc/email/u-boot/kernel nightmare...
> > 
> > that's exactly why we're talking about ways to maintain backwards
> > compatibility here. But I'm more interested in finding a way to switch
> > over to ttyS and have a symlink to ttyO, that way a simple debootstrap
> > (or any other ARM distro minimal rootfs) would work out of the box,
> > without any changes, just like in "normal" systems.
> 
> Yeah let's not break things. The symlink solution won't work for kernel

again. Let's not break things again.

> console output so it needs to be dealt with some other way.

it would if kernel itself would create the symlink, but that might not
be doable in a clean way.

> It seems that the biggest amount of work is making existing 8250
> support the missing features in a clean way and without breaking
> other platforms. Looks like 8250_dw.c has some pm_runtime_calls so
> obviously it's doable.

right

-- 
balbi


signature.asc
Description: Digital signature


Re: [RFC] possible removal of omap-serial

2014-03-21 Thread Greg KH
On Fri, Mar 21, 2014 at 12:36:53PM -0500, Felipe Balbi wrote:
> Hi,
> 
> On Fri, Mar 21, 2014 at 10:10:30AM -0700, Tony Lindgren wrote:
> > > > On the support side, I'm not looking forward to this for beagle/panda
> > > > users.  We've already converted them once from ttySx -> ttyOx back in
> > > > 2.6.33/2.6.34? days.  That was an irc/email/u-boot/kernel nightmare...
> > > 
> > > that's exactly why we're talking about ways to maintain backwards
> > > compatibility here. But I'm more interested in finding a way to switch
> > > over to ttyS and have a symlink to ttyO, that way a simple debootstrap
> > > (or any other ARM distro minimal rootfs) would work out of the box,
> > > without any changes, just like in "normal" systems.
> > 
> > Yeah let's not break things. The symlink solution won't work for kernel
> 
> again. Let's not break things again.
> 
> > console output so it needs to be dealt with some other way.
> 
> it would if kernel itself would create the symlink, but that might not
> be doable in a clean way.

The kernel isn't going to create the symlink, sorry, no.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 2/6] iio: pulse: add TI ECAP driver

2014-03-21 Thread Matt Ranostay
On Wed, Feb 5, 2014 at 11:01 AM, Matt Porter  wrote:
> Adds support for capturing PWM signals using the TI ECAP peripheral.
> This driver supports triggered buffer capture of pulses on multiple
> ECAP instances. In addition, the driver supports configurable polarity
> of the signal to be captured.
>
> Signed-off-by: Matt Porter 

Tested-by: Matt Ranostay 

> ---
>  drivers/iio/pulse/Kconfig  |  20 ++
>  drivers/iio/pulse/Makefile |   6 +
>  drivers/iio/pulse/tiecap.c | 491 
> +
>  3 files changed, 517 insertions(+)
>  create mode 100644 drivers/iio/pulse/Kconfig
>  create mode 100644 drivers/iio/pulse/Makefile
>  create mode 100644 drivers/iio/pulse/tiecap.c
>
> diff --git a/drivers/iio/pulse/Kconfig b/drivers/iio/pulse/Kconfig
> new file mode 100644
> index 000..9864d4b
> --- /dev/null
> +++ b/drivers/iio/pulse/Kconfig
> @@ -0,0 +1,20 @@
> +#
> +# Pulse Capture Devices
> +#
> +# When adding new entries keep the list in alphabetical order
> +
> +menu "Pulse Capture Devices"
> +
> +config IIO_TIECAP
> +   tristate "TI ECAP Pulse Capture"
> +   depends on SOC_AM33XX
> +   select IIO_BUFFER
> +   select IIO_TRIGGERED_BUFFER
> +   help
> +If you say yes here you get support for the TI ECAP peripheral
> +in pulse capture mode.
> +
> +This driver can also be built as a module.  If so, the module
> +will be called tiecap
> +
> +endmenu
> diff --git a/drivers/iio/pulse/Makefile b/drivers/iio/pulse/Makefile
> new file mode 100644
> index 000..94d4b00
> --- /dev/null
> +++ b/drivers/iio/pulse/Makefile
> @@ -0,0 +1,6 @@
> +#
> +# Makefile for IIO PWM Capture Devices
> +#
> +
> +# When adding new entries keep the list in alphabetical order
> +obj-$(CONFIG_IIO_TIECAP)   += tiecap.o
> diff --git a/drivers/iio/pulse/tiecap.c b/drivers/iio/pulse/tiecap.c
> new file mode 100644
> index 000..fd96745
> --- /dev/null
> +++ b/drivers/iio/pulse/tiecap.c
> @@ -0,0 +1,491 @@
> +/*
> + * ECAP IIO pulse capture driver
> + *
> + * Copyright (C) 2014 Linaro Limited
> + * Author: Matt Porter 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "../../pwm/pwm-tipwmss.h"
> +
> +/* ECAP regs and bits */
> +#define CAP1   0x08
> +#define CAP2   0x0c
> +#define ECCTL1 0x28
> +#define ECCTL1_RUN_FREEBIT(15)
> +#define ECCTL1_CAPLDEN BIT(8)
> +#define ECCTL1_CAP2POL BIT(2)
> +#define ECCTL1_CTRRST1 BIT(1)
> +#define ECCTL1_CAP1POL BIT(0)
> +#define ECCTL2 0x2a
> +#define ECCTL2_SYNCO_SEL_DIS   BIT(7)
> +#define ECCTL2_TSCTR_FREERUN   BIT(4)
> +#define ECCTL2_REARM   BIT(3)
> +#define ECCTL2_STOP_WRAP_2 BIT(1)
> +#define ECEINT 0x2c
> +#define ECFLG  0x2e
> +#define ECCLR  0x30
> +#define ECINT_CTRCMP   BIT(7)
> +#define ECINT_CTRPRD   BIT(6)
> +#define ECINT_CTROVF   BIT(5)
> +#define ECINT_CEVT4BIT(4)
> +#define ECINT_CEVT3BIT(3)
> +#define ECINT_CEVT2BIT(2)
> +#define ECINT_CEVT1BIT(1)
> +#define ECINT_ALL  (ECINT_CTRCMP | \
> +   ECINT_CTRPRD |  \
> +   ECINT_CTROVF |  \
> +   ECINT_CEVT4 |   \
> +   ECINT_CEVT3 |   \
> +   ECINT_CEVT2 |   \
> +   ECINT_CEVT1)
> +
> +/* ECAP driver flags */
> +#define ECAP_POLARITY_HIGH BIT(1)
> +#define ECAP_ENABLED   BIT(0)
> +
> +struct ecap_context {
> +   u32 cap1;
> +   u32 cap2;
> +   u16 ecctl1;
> +   u16 ecctl2;
> +   u16 eceint;
> +};
> +
> +struct ecap_state {
> +   unsigned long   flags;
> +   unsigned intclk_rate;
> +   void __iomem*regs;
> +   u32 *buf;
> +   struct ecap_context ctx;
> +};
> +
> +#define dev_to_ecap_state(d)   iio_priv(dev_to_iio_dev(d))
> +
> +static const struct iio_chan_spec ecap_channels[] = {
> +   {
> +   .type   = IIO_PULSE,
> +   .info_mask_separate =
> +   BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +   .scan_index = 0,
> +   .scan_type = {
> +   .sign   = 'u',
> +   .realbits   = 32,
> +   .storagebits= 32,
> +