[Patch V2 4/4] ARM: dts: AM33XX: update rtc node compatibility

2013-07-03 Thread Hebbar Gururaja
Since AM33xx  RTC IP has RTC_IRQWAKEEN to support Alarm Wake-up.

Update the rtc compatible property to ti,am3352-rtc to enable handling
of this feature inside rtc-omap driver.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
---
:100644 100644 77aa1b0... dde180a... M  arch/arm/boot/dts/am33xx.dtsi
 arch/arm/boot/dts/am33xx.dtsi |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index 77aa1b0..dde180a 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -297,7 +297,7 @@
};
 
rtc@44e3e000 {
-   compatible = ti,da830-rtc;
+   compatible = ti,am3352-rtc;
reg = 0x44e3e000 0x1000;
interrupts = 75
  76;
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[Patch V2 2/4] ARM: Davinci: da8xx/omap-l1: Remove hard coding of rtc device wakeup

2013-07-03 Thread Hebbar Gururaja
Since now rtc-omap driver itself calls deice_init_wakeup(dev, true),
duplicate call from the rtc device registration can be removed.

This is basically a partial revert of the prev commit

commit 75c99bb0006ee065b4e2995078d779418b0fab54
Author: Sekhar Nori nsek...@ti.com

davinci: da8xx/omap-l1: mark RTC as a wakeup source

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Acked-by: Kevin Hilman khil...@linaro.org
Acked-by: Sekhar Nori nsek...@ti.com
Cc: Russell King li...@arm.linux.org.uk
---
Changes in V2:
- Coding style corrections (remove extra space)
- use prefix ARM: for commit subject keeping with arch/arm convention

:100644 100644 bf57252... 9140b1c... M  arch/arm/mach-davinci/devices-da8xx.c
 arch/arm/mach-davinci/devices-da8xx.c |9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/arch/arm/mach-davinci/devices-da8xx.c 
b/arch/arm/mach-davinci/devices-da8xx.c
index bf57252..9140b1c 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -827,14 +827,7 @@ static struct platform_device da8xx_rtc_device = {
 
 int da8xx_register_rtc(void)
 {
-   int ret;
-
-   ret = platform_device_register(da8xx_rtc_device);
-   if (!ret)
-   /* Atleast on DA850, RTC is a wakeup source */
-   device_init_wakeup(da8xx_rtc_device.dev, true);
-
-   return ret;
+   return platform_device_register(da8xx_rtc_device);
 }
 
 static void __iomem *da8xx_ddr2_ctlr_base;
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[Patch V2 3/4] rtc: omap: add rtc wakeup support to alarm events

2013-07-03 Thread Hebbar Gururaja
On some platforms (like AM33xx), a special register (RTC_IRQWAKEEN)
is available to enable Alarm Wakeup feature. This register needs to be
properly handled for the rtcwake to work properly.

Platforms using such IP should set ti,am3352-rtc in rtc device dt
compatibility node.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Acked-by: Kevin Hilman khil...@linaro.org
Acked-by: Sekhar Nori nsek...@ti.com
Cc: Grant Likely grant.lik...@linaro.org
Cc: Rob Herring rob.herr...@calxeda.com
Cc: Rob Landley r...@landley.net
Cc: Alessandro Zummo a.zu...@towertech.it
Cc: rtc-li...@googlegroups.com
Cc: devicetree-discuss@lists.ozlabs.org
Cc: linux-...@vger.kernel.org
---
Changes in V2:
- Coding style corrections (use lower case for hex numbers)
- use [AM/am]3352 instead of [AM/am]335x to keep the all
  usages in sync.
- Use index defined for struct members so they remain in sync

:100644 100644 b47aa41... 5a0f02d... M  
Documentation/devicetree/bindings/rtc/rtc-omap.txt
:100644 100644 761919d... c2e18fe... M  drivers/rtc/rtc-omap.c
 Documentation/devicetree/bindings/rtc/rtc-omap.txt |6 +-
 drivers/rtc/rtc-omap.c |   60 +---
 2 files changed, 57 insertions(+), 9 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt 
b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
index b47aa41..5a0f02d 100644
--- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt
+++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
@@ -1,7 +1,11 @@
 TI Real Time Clock
 
 Required properties:
-- compatible: ti,da830-rtc
+- compatible:
+   - ti,da830-rtc  - for RTC IP used similar to that on DA8xx SoC family.
+   - ti,am3352-rtc - for RTC IP used similar to that on AM335x SoC 
family.
+   This RTC IP has special WAKE-EN Register to enable
+   Wakeup generation for event Alarm.
 - reg: Address range of rtc register set
 - interrupts: rtc timer, alarm interrupts in order
 - interrupt-parent: phandle for the interrupt controller
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 761919d..c2e18fe 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -72,6 +72,8 @@
 #define OMAP_RTC_KICK0_REG 0x6c
 #define OMAP_RTC_KICK1_REG 0x70
 
+#define OMAP_RTC_IRQWAKEEN 0x7c
+
 /* OMAP_RTC_CTRL_REG bit fields: */
 #define OMAP_RTC_CTRL_SPLIT(17)
 #define OMAP_RTC_CTRL_DISABLE  (16)
@@ -96,12 +98,21 @@
 #define OMAP_RTC_INTERRUPTS_IT_ALARM(13)
 #define OMAP_RTC_INTERRUPTS_IT_TIMER(12)
 
+/* OMAP_RTC_IRQWAKEEN bit fields: */
+#define OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN(11)
+
 /* OMAP_RTC_KICKER values */
 #defineKICK0_VALUE 0x83e70b13
 #defineKICK1_VALUE 0x95a4f1e0
 
 #defineOMAP_RTC_HAS_KICKER 0x1
 
+/*
+ * Few RTC IP revisions has special WAKE-EN Register to enable Wakeup
+ * generation for event Alarm.
+ */
+#defineOMAP_RTC_HAS_IRQWAKEEN  0x2
+
 static void __iomem*rtc_base;
 
 #define rtc_read(addr) readb(rtc_base + (addr))
@@ -301,12 +312,18 @@ static struct rtc_class_ops omap_rtc_ops = {
 static int omap_rtc_alarm;
 static int omap_rtc_timer;
 
-#defineOMAP_RTC_DATA_DA830_IDX 1
+#defineOMAP_RTC_DATA_AM3352_IDX1
+#defineOMAP_RTC_DATA_DA830_IDX 2
 
 static struct platform_device_id omap_rtc_devtype[] = {
{
.name   = DRIVER_NAME,
-   }, {
+   },
+   [OMAP_RTC_DATA_AM3352_IDX] = {
+   .name   = am3352-rtc,
+   .driver_data = OMAP_RTC_HAS_KICKER | OMAP_RTC_HAS_IRQWAKEEN,
+   },
+   [OMAP_RTC_DATA_DA830_IDX] = {
.name   = da830-rtc,
.driver_data = OMAP_RTC_HAS_KICKER,
},
@@ -318,6 +335,9 @@ static const struct of_device_id omap_rtc_of_match[] = {
{   .compatible = ti,da830-rtc,
.data   = omap_rtc_devtype[OMAP_RTC_DATA_DA830_IDX],
},
+   {   .compatible = ti,am3352-rtc,
+   .data   = omap_rtc_devtype[OMAP_RTC_DATA_AM3352_IDX],
+   },
{},
 };
 MODULE_DEVICE_TABLE(of, omap_rtc_of_match);
@@ -466,16 +486,28 @@ static u8 irqstat;
 
 static int omap_rtc_suspend(struct device *dev)
 {
+   u8 irqwake_stat;
+   struct platform_device *pdev = to_platform_device(dev);
+   const struct platform_device_id *id_entry =
+   platform_get_device_id(pdev);
+
irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG);
 
/* FIXME the RTC alarm is not currently acting as a wakeup event
-* source, and in fact this enable() call is just saving a flag
-* that's never used...
+* source on some platforms, and in fact this enable() call is just
+* saving a flag that's never used

[Patch V2 1/4] rtc: omap: restore back (hard-code) wakeup support

2013-07-03 Thread Hebbar Gururaja
rtc-omap driver modules is used both by OMAP1/2, Davinci SoC platforms.

However, rtc wake support on OMAP1 is broken. Hence the
device_init_wakeup() was removed from rtc-omap driver and moved to
platform board files that supported it (DA850/OMAP-L138). [1]

However, recently [2] it was suggested that driver should always do a
device_init_wakeup(dev, true). Platforms that don't want/need
wakeup support can disable it from userspace via:

echo disabled  /sys/devices/.../power/wakeup

Also, with the new DT boot-up, board file doesn't exist and hence there
is no way to have device wakeup support rtc.

The fix for above issues, is to hard code device_init_wakeup() inside
driver and let platforms that don't need this, handle it through the
sysfs power entry.

[1]
https://patchwork.kernel.org/patch/136731/

[2]
http://www.mail-archive.com/davinci-linux-open-source@linux.
davincidsp.com/msg26077.html

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Acked-by: Kevin Hilman khil...@linaro.org
Cc: Alessandro Zummo a.zu...@towertech.it
Cc: rtc-li...@googlegroups.com
---
:100644 100644 b0ba3fc... 761919d... M  drivers/rtc/rtc-omap.c
 drivers/rtc/rtc-omap.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index b0ba3fc..761919d 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -423,6 +423,8 @@ static int __init omap_rtc_probe(struct platform_device 
*pdev)
 *is write-only, and always reads as zero...)
 */
 
+   device_init_wakeup(pdev-dev, true);
+
if (new_ctrl  (u8) OMAP_RTC_CTRL_SPLIT)
pr_info(%s: split power mode\n, pdev-name);
 
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 3/4] rtc: omap: add rtc wakeup support to alarm events

2013-07-02 Thread Hebbar, Gururaja
On Tue, Jul 02, 2013 at 11:32:34, Nori, Sekhar wrote:
 On 6/28/2013 3:05 PM, Hebbar Gururaja wrote:
  On some platforms (like AM33xx), a special register (RTC_IRQWAKEEN)
  is available to enable Alarm Wakeup feature. This register needs to be
  properly handled for the rtcwake to work properly.
  
  Platforms using such IP should set ti,am3352-rtc in rtc device dt
  compatibility node.
  
  Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
  Cc: Grant Likely grant.lik...@linaro.org
  Cc: Rob Herring rob.herr...@calxeda.com
  Cc: Rob Landley r...@landley.net
  Cc: Sekhar Nori nsek...@ti.com
  Cc: Kevin Hilman khil...@linaro.org
  Cc: Alessandro Zummo a.zu...@towertech.it
  Cc: rtc-li...@googlegroups.com
  Cc: devicetree-discuss@lists.ozlabs.org
  Cc: linux-...@vger.kernel.org
  ---
 
 [...]
 
  -#defineOMAP_RTC_DATA_DA830_IDX 1
  +#defineOMAP_RTC_DATA_DA830_IDX 1
  +#defineOMAP_RTC_DATA_AM335X_IDX2
   
   static struct platform_device_id omap_rtc_devtype[] = {
  {
  @@ -309,6 +321,9 @@ static struct platform_device_id omap_rtc_devtype[] = {
  }, {
  .name   = da830-rtc,
  .driver_data = OMAP_RTC_HAS_KICKER,
  +   }, {
  +   .name   = am335x-rtc,
 
 may be use am3352-rtc here just to keep the platform device name and of
 compatible in sync.

Correct. I will update the same in v2.

 
  +   .driver_data = OMAP_RTC_HAS_KICKER | OMAP_RTC_HAS_IRQWAKEEN,
  },
  {},
 
 It is better to use the index defined above in the static initialization
 so they remain in sync.

Sorry. I didn’t get this.

 
   ...
   [OMAP_RTC_DATA_DA830_IDX] = {
   .name   = da830-rtc,
   .driver_data = OMAP_RTC_HAS_KICKER,
   },
   ...
 
   };
  @@ -318,6 +333,9 @@ static const struct of_device_id omap_rtc_of_match[] = {
  {   .compatible = ti,da830-rtc,
  .data   = omap_rtc_devtype[OMAP_RTC_DATA_DA830_IDX],
  },
  +   {   .compatible = ti,am3352-rtc,
  +   .data   = omap_rtc_devtype[OMAP_RTC_DATA_AM335X_IDX],
  +   },
  {},
   };
   MODULE_DEVICE_TABLE(of, omap_rtc_of_match);
 
 Apart from these minor issues, the patch looks good to me.
 
 Acked-by: Sekhar Nori nsek...@ti.com
 
 Thanks,
 Sekhar
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 3/4] rtc: omap: add rtc wakeup support to alarm events

2013-07-02 Thread Hebbar, Gururaja
On Tue, Jul 02, 2013 at 11:39:28, Nori, Sekhar wrote:
 On 7/2/2013 11:34 AM, Hebbar, Gururaja wrote:
  On Tue, Jul 02, 2013 at 11:32:34, Nori, Sekhar wrote:
  On 6/28/2013 3:05 PM, Hebbar Gururaja wrote:
  On some platforms (like AM33xx), a special register (RTC_IRQWAKEEN)
  is available to enable Alarm Wakeup feature. This register needs to be
  properly handled for the rtcwake to work properly.
 
  Platforms using such IP should set ti,am3352-rtc in rtc device dt
  compatibility node.
 
  Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
  Cc: Grant Likely grant.lik...@linaro.org
  Cc: Rob Herring rob.herr...@calxeda.com
  Cc: Rob Landley r...@landley.net
  Cc: Sekhar Nori nsek...@ti.com
  Cc: Kevin Hilman khil...@linaro.org
  Cc: Alessandro Zummo a.zu...@towertech.it
  Cc: rtc-li...@googlegroups.com
  Cc: devicetree-discuss@lists.ozlabs.org
  Cc: linux-...@vger.kernel.org
  ---
 
  [...]
 
  -#define  OMAP_RTC_DATA_DA830_IDX 1
  +#define  OMAP_RTC_DATA_DA830_IDX 1
  +#define  OMAP_RTC_DATA_AM335X_IDX2
   
   static struct platform_device_id omap_rtc_devtype[] = {
{
  @@ -309,6 +321,9 @@ static struct platform_device_id omap_rtc_devtype[] = 
  {
}, {
.name   = da830-rtc,
.driver_data = OMAP_RTC_HAS_KICKER,
  + }, {
  + .name   = am335x-rtc,
 
  may be use am3352-rtc here just to keep the platform device name and of
  compatible in sync.
  
  Correct. I will update the same in v2.
  
 
  + .driver_data = OMAP_RTC_HAS_KICKER | OMAP_RTC_HAS_IRQWAKEEN,
},
{},
 
  It is better to use the index defined above in the static initialization
  so they remain in sync.
  
  Sorry. I didn’t get this.
  
 
 See example below I provided. If its still not clear, let me know what
 is not clear.
 
 ...
 [OMAP_RTC_DATA_DA830_IDX] = {
 .name   = da830-rtc,
 .driver_data = OMAP_RTC_HAS_KICKER,
 },

Thanks for the clarification. In this case will it ok if I update the previous
member also.

 
 Thanks,
 Sekhar
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 4/4] ARM: dts: AM33XX: update rtc node compatibility

2013-07-02 Thread Hebbar, Gururaja
On Tue, Jul 02, 2013 at 11:42:49, Nori, Sekhar wrote:
 Changing to Benoit's gmail id since he apparently wont access TI mail
 anymore.
 
 On 6/28/2013 3:05 PM, Hebbar Gururaja wrote:
  Since AM33xx  RTC IP has RTC_IRQWAKEEN to support Alarm Wake-up.
  
  Update the rtc compatible property to ti,am3352-rtc to enable handling
  of this feature inside rtc-omap driver.
  
  Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
  Cc: Tony Lindgren t...@atomide.com
  Cc: Sekhar Nori nsek...@ti.com
  Cc: Kevin Hilman khil...@linaro.org
  Cc: b-cous...@ti.com
  ---
  :100644 100644 77aa1b0... dde180a... M  arch/arm/boot/dts/am33xx.dtsi
   arch/arm/boot/dts/am33xx.dtsi |2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
  
  diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
  index 77aa1b0..dde180a 100644
  --- a/arch/arm/boot/dts/am33xx.dtsi
  +++ b/arch/arm/boot/dts/am33xx.dtsi
  @@ -297,7 +297,7 @@
  };
   
  rtc@44e3e000 {
  -   compatible = ti,da830-rtc;
  +   compatible = ti,am3352-rtc;
 
 compatible is a list so you can instead do:
   
   compatible = ti,am3352-rtc, ti,da830-rtc;
 
 That way the dts works irrespective of driver updates. When driver
 supports enhanced features of hardware, they are available to the user
 else the basic functionality still works.

Ok. I will update the same now in v2.

 
 Thanks,
 Sekhar
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 4/4] ARM: dts: AM33XX: update rtc node compatibility

2013-07-02 Thread Hebbar, Gururaja
On Tue, Jul 02, 2013 at 11:42:49, Nori, Sekhar wrote:
 Changing to Benoit's gmail id since he apparently wont access TI mail
 anymore.
 
 On 6/28/2013 3:05 PM, Hebbar Gururaja wrote:
  Since AM33xx  RTC IP has RTC_IRQWAKEEN to support Alarm Wake-up.
  
  Update the rtc compatible property to ti,am3352-rtc to enable handling
  of this feature inside rtc-omap driver.
  
  Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
  Cc: Tony Lindgren t...@atomide.com
  Cc: Sekhar Nori nsek...@ti.com
  Cc: Kevin Hilman khil...@linaro.org
  Cc: b-cous...@ti.com
  ---
  :100644 100644 77aa1b0... dde180a... M  arch/arm/boot/dts/am33xx.dtsi
   arch/arm/boot/dts/am33xx.dtsi |2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
  
  diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
  index 77aa1b0..dde180a 100644
  --- a/arch/arm/boot/dts/am33xx.dtsi
  +++ b/arch/arm/boot/dts/am33xx.dtsi
  @@ -297,7 +297,7 @@
  };
   
  rtc@44e3e000 {
  -   compatible = ti,da830-rtc;
  +   compatible = ti,am3352-rtc;
 
 compatible is a list so you can instead do:
   
   compatible = ti,am3352-rtc, ti,da830-rtc;

I believe the order is not important here. I mean, below is also fine. Right?

compatible = ti,da830-rtc, ti,am3352-rtc;


 
 That way the dts works irrespective of driver updates. When driver
 supports enhanced features of hardware, they are available to the user
 else the basic functionality still works.
 
 Thanks,
 Sekhar
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 3/4] rtc: omap: add rtc wakeup support to alarm events

2013-07-02 Thread Hebbar, Gururaja
Hi all,

Kindly ignore this message. It was sent in wrong format.

Sorry for the noise

Regards, 
Gururaja

On Wed, Jul 03, 2013 at 10:26:57, Hebbar, Gururaja wrote:
 Below is the code snippet I was referring to
  
  
 From drivers/rtc/rtc-omap.c
  
 static struct platform_device_id omap_rtc_devtype[] = {
   {
 .name = DRIVER_NAME,
   },
   [OMAP_RTC_DATA_AM3352_IDX] = {
 .name = am3352-rtc,
 .driver_data = OMAP_RTC_HAS_KICKER | OMAP_RTC_HAS_IRQWAKEEN,
   },
   [OMAP_RTC_DATA_DA830_IDX] = {
 .name = da830-rtc,
 .driver_data = OMAP_RTC_HAS_KICKER,
  },
   {},
 };
 MODULE_DEVICE_TABLE(platform, omap_rtc_devtype);
  
 static const struct of_device_id omap_rtc_of_match[] = {
   { .compatible = ti,da830-rtc,
 .data   = omap_rtc_devtype[OMAP_RTC_DATA_DA830_IDX],
   },
   { .compatible = ti,am3352-rtc,
 .data   = omap_rtc_devtype[OMAP_RTC_DATA_AM3352_IDX],
   },
   {},
 };
 MODULE_DEVICE_TABLE(of, omap_rtc_of_match);
  
  
 From arch/arm/boot/dts/am33xx.dtsi
  
 rtc@44e3e000 {
   compatible = ti,da830-rtc, ti,am3352-rtc;
   reg = 0x44e3e000 0x1000;
   interrupts = 75
   76;
   ti,hwmods = rtc;
 };
  
  
 As seen from above snippet, 2 compatible items are specified for
 compatible dt property (ti,da830-rtc  ti,am3352-rtc”)
 These are the same compatibles that are mentioned in the of_device_id
 structure inside rtc-omap driver.
  
 What I observed is, if we mention both compatible in the .dtsi file that
 are under one single of_device_id structure, the first match from the
 of_device_id structure is considered (ti,da830-rtc in above case)
  
 To confirm, I switched the 2 compatible inside of_device_id structure as
 below
  
  
 static const struct of_device_id omap_rtc_of_match[] = {
   { .compatible = ti,am3352-rtc,
 .data   = omap_rtc_devtype[OMAP_RTC_DATA_AM3352_IDX],
   },
   { .compatible = ti,da830-rtc,
 .data   = omap_rtc_devtype[OMAP_RTC_DATA_DA830_IDX],
   },
   {},
 };
  
 In this case, the first match from compatible field was chosen
 (ti,am3352-rtc now).
  
  
 Hope this is clear.
  
 Kindly let me know when you are free to discuss.
  
  
 Regards
 Gururaja
  
  -Original Message-
  From: Nori, Sekhar
  Sent: Tuesday, July 02, 2013 11:47 AM
  To: Hebbar, Gururaja
  Cc: khil...@linaro.org; t...@atomide.com; Cousson, Benoit; linux-
  o...@vger.kernel.org; devicetree-discuss@lists.ozlabs.org; linux-
  ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org;
  davinci-linux-open-sou...@linux.davincidsp.com; Bedia, Vaibhav;
  Rajashekhara, Sudhakar; Grant Likely; Rob Herring; Rob Landley;
  Alessandro Zummo; rtc-li...@googlegroups.com; linux-
  d...@vger.kernel.org
  Subject: Re: [PATCH 3/4] rtc: omap: add rtc wakeup support to
  alarm events
  
  
  
  On 7/2/2013 11:41 AM, Hebbar, Gururaja wrote:
   On Tue, Jul 02, 2013 at 11:39:28, Nori, Sekhar wrote:
   On 7/2/2013 11:34 AM, Hebbar, Gururaja wrote:
   On Tue, Jul 02, 2013 at 11:32:34, Nori, Sekhar wrote:
   On 6/28/2013 3:05 PM, Hebbar Gururaja wrote:
   On some platforms (like AM33xx), a special register
  (RTC_IRQWAKEEN)
   is available to enable Alarm Wakeup feature. This register
  needs to be
   properly handled for the rtcwake to work properly.
  
   Platforms using such IP should set ti,am3352-rtc in rtc
  device dt
   compatibility node.
  
   Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
 mailto:gururaja.heb...@ti.com 
   Cc: Grant Likely grant.lik...@linaro.org
 mailto:grant.lik...@linaro.org 
   Cc: Rob Herring rob.herr...@calxeda.com
 mailto:rob.herr...@calxeda.com 
   Cc: Rob Landley r...@landley.net mailto:r...@landley.net 
   Cc: Sekhar Nori nsek...@ti.com mailto:nsek...@ti.com 
   Cc: Kevin Hilman khil...@linaro.org mailto:khil...@linaro.org
 
   Cc: Alessandro Zummo a.zu...@towertech.it
 mailto:a.zu...@towertech.it 
   Cc: rtc-li...@googlegroups.com
 mailto:rtc-li...@googlegroups.com 
   Cc: devicetree-discuss@lists.ozlabs.org
 mailto:devicetree-discuss@lists.ozlabs.org 
   Cc: linux-...@vger.kernel.org mailto:linux-...@vger.kernel.org
   ---
  
   [...]
  
   -#define  OMAP_RTC_DATA_DA830_IDX 1
   +#define  OMAP_RTC_DATA_DA830_IDX   1
   +#define  OMAP_RTC_DATA_AM335X_IDX  2
  
static struct platform_device_id omap_rtc_devtype[] = {
   {
   @@ -309,6 +321,9 @@ static struct platform_device_id
  omap_rtc_devtype[] = {
   }, {
 .name = da830-rtc,
 .driver_data = OMAP_RTC_HAS_KICKER,
   +   }, {
   + .name = am335x-rtc,
  
   may be use am3352-rtc here just to keep the platform device
  name and of
   compatible in sync.
  
   Correct. I will update the same in v2.
  
  
   + .driver_data = OMAP_RTC_HAS_KICKER |
  OMAP_RTC_HAS_IRQWAKEEN

RE: [PATCH 3/4] rtc: omap: add rtc wakeup support to alarm events

2013-07-01 Thread Hebbar, Gururaja
On Tue, Jul 02, 2013 at 05:45:01, Kevin Hilman wrote:
 Hebbar Gururaja gururaja.heb...@ti.com writes:
 
  On some platforms (like AM33xx), a special register (RTC_IRQWAKEEN)
  is available to enable Alarm Wakeup feature. This register needs to be
  properly handled for the rtcwake to work properly.
 
  Platforms using such IP should set ti,am3352-rtc in rtc device dt
  compatibility node.
 
  Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
  Cc: Grant Likely grant.lik...@linaro.org
  Cc: Rob Herring rob.herr...@calxeda.com
  Cc: Rob Landley r...@landley.net
  Cc: Sekhar Nori nsek...@ti.com
  Cc: Kevin Hilman khil...@linaro.org
  Cc: Alessandro Zummo a.zu...@towertech.it
  Cc: rtc-li...@googlegroups.com
  Cc: devicetree-discuss@lists.ozlabs.org
  Cc: linux-...@vger.kernel.org
 
 Acked-by: Kevin Hilman khil...@linaro.org
 
 ...with a minor nit below...
 
  ---
  :100644 100644 b47aa41... 5a0f02d... M  
  Documentation/devicetree/bindings/rtc/rtc-omap.txt
  :100644 100644 761919d... 666b0c2... M  drivers/rtc/rtc-omap.c
   Documentation/devicetree/bindings/rtc/rtc-omap.txt |6 ++-
   drivers/rtc/rtc-omap.c |   56 
  +---
   2 files changed, 54 insertions(+), 8 deletions(-)
 
  diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt 
  b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
  index b47aa41..5a0f02d 100644
  --- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt
  +++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
  @@ -1,7 +1,11 @@
   TI Real Time Clock
   
   Required properties:
  -- compatible: ti,da830-rtc
  +- compatible:
  +   - ti,da830-rtc  - for RTC IP used similar to that on DA8xx SoC family.
  +   - ti,am3352-rtc - for RTC IP used similar to that on AM335x SoC 
  family.
  +   This RTC IP has special WAKE-EN Register to enable
  +   Wakeup generation for event Alarm.
   - reg: Address range of rtc register set
   - interrupts: rtc timer, alarm interrupts in order
   - interrupt-parent: phandle for the interrupt controller
  diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
  index 761919d..666b0c2 100644
  --- a/drivers/rtc/rtc-omap.c
  +++ b/drivers/rtc/rtc-omap.c
  @@ -72,6 +72,8 @@
   #define OMAP_RTC_KICK0_REG 0x6c
   #define OMAP_RTC_KICK1_REG 0x70
   
  +#define OMAP_RTC_IRQWAKEEN 0x7C
  +
 
 nit: letters in hex numbers are usually lower-case.

Thanks for the review. V2 will soon follow.

 
 
 Kevin
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 2/4] davinci: da8xx/omap-l1: Remove hard coding of rtc device wakeup

2013-07-01 Thread Hebbar, Gururaja
On Tue, Jul 02, 2013 at 05:37:43, Kevin Hilman wrote:
 Hebbar Gururaja gururaja.heb...@ti.com writes:
 
  Since now rtc-omap driver itself calls deice_init_wakeup(dev, true),
  duplicate call from the rtc device registration can be removed.
 
  This is basically a partial revert of the prev commit
 
  commit 75c99bb0006ee065b4e2995078d779418b0fab54
  Author: Sekhar Nori nsek...@ti.com
 
  davinci: da8xx/omap-l1: mark RTC as a wakeup source
 
  Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
  Cc: Sekhar Nori nsek...@ti.com
  Cc: Kevin Hilman khil...@linaro.org
  Cc: Russell King li...@arm.linux.org.uk
 
  ---
  :100644 100644 bf57252... 85a900c... M  
  arch/arm/mach-davinci/devices-da8xx.c
   arch/arm/mach-davinci/devices-da8xx.c |9 +
   1 file changed, 1 insertion(+), 8 deletions(-)
 
  diff --git a/arch/arm/mach-davinci/devices-da8xx.c 
  b/arch/arm/mach-davinci/devices-da8xx.c
  index bf57252..85a900c 100644
  --- a/arch/arm/mach-davinci/devices-da8xx.c
  +++ b/arch/arm/mach-davinci/devices-da8xx.c
  @@ -827,14 +827,7 @@ static struct platform_device da8xx_rtc_device = {
   
   int da8xx_register_rtc(void)
   {
  -   int ret;
  -
  -   ret = platform_device_register(da8xx_rtc_device);
  -   if (!ret)
  -   /* Atleast on DA850, RTC is a wakeup source */
  -   device_init_wakeup(da8xx_rtc_device.dev, true);
  -
  -   return ret;
  +   return  platform_device_register(da8xx_rtc_device);
 
 nit: extra space between 'return' and 'platform_'

Thanks for the review. V2 will soon follow.

 
   }
   
   static void __iomem *da8xx_ddr2_ctlr_base;
 
 Otherwise,
 
 Acked-by: Kevin Hilman khil...@linaro.org
 
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 2/4] davinci: da8xx/omap-l1: Remove hard coding of rtc device wakeup

2013-07-01 Thread Hebbar, Gururaja
On Tue, Jul 02, 2013 at 11:10:14, Nori, Sekhar wrote:
 
 On 6/28/2013 3:05 PM, Hebbar Gururaja wrote:
  Since now rtc-omap driver itself calls deice_init_wakeup(dev, true),
  duplicate call from the rtc device registration can be removed.
  
  This is basically a partial revert of the prev commit
  
  commit 75c99bb0006ee065b4e2995078d779418b0fab54
  Author: Sekhar Nori nsek...@ti.com
  
  davinci: da8xx/omap-l1: mark RTC as a wakeup source
  
  Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
  Cc: Sekhar Nori nsek...@ti.com
  Cc: Kevin Hilman khil...@linaro.org
  Cc: Russell King li...@arm.linux.org.uk
 
 Subject line should be prefixed with ARM: keeping with arch/arm
 convention. Otherwise looks good.

Will fix it in v2.

 
 Acked-by: Sekhar Nori nsek...@ti.com

Thanks for the review.

 
 Thanks,
 Sekhar
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 0/4] rtc: omap: handle rtc wakeup support in driver

2013-06-28 Thread Hebbar Gururaja
rtc-omap driver modules is used both by OMAP1/2, Davinci SoC platforms.

However, rtc wake support on OMAP1 is broken. Hence the
device_init_wakeup() was removed from rtc-omap driver and moved to
platform board files that supported it (DA850/OMAP-L138). [1]

However, recently [2] it was suggested that driver should always do a
device_init_wakeup(dev, true). Platforms that don't want/need
wakeup support can disable it from userspace via:

echo disabled  /sys/devices/.../power/wakeup

Also, with the new DT boot-up, board file doesn't exist and hence there
is no way to have device wakeup support rtc.

The fix for above issues, is to hard code device_init_wakeup() inside
driver and let platforms that don't need this, handle it through the
sysfs power entry.


Also, update Davinci  AM335x files to above changes.

[1]
https://patchwork.kernel.org/patch/136731/

[2]
http://www.mail-archive.com/davinci-linux-open-source@linux.
davincidsp.com/msg26077.html

Hebbar Gururaja (4):
  rtc: omap: restore back (hard-code) wakeup support
  davinci: da8xx/omap-l1: Remove hard coding of rtc device wakeup
  rtc: omap: add rtc wakeup support to alarm events
  ARM: dts: AM33XX: update rtc node compatibility

 Documentation/devicetree/bindings/rtc/rtc-omap.txt |6 +-
 arch/arm/boot/dts/am33xx.dtsi  |2 +-
 arch/arm/mach-davinci/devices-da8xx.c  |9 +--
 drivers/rtc/rtc-omap.c |   58 +---
 4 files changed, 58 insertions(+), 17 deletions(-)

-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 1/4] rtc: omap: restore back (hard-code) wakeup support

2013-06-28 Thread Hebbar Gururaja
rtc-omap driver modules is used both by OMAP1/2, Davinci SoC platforms.

However, rtc wake support on OMAP1 is broken. Hence the
device_init_wakeup() was removed from rtc-omap driver and moved to
platform board files that supported it (DA850/OMAP-L138). [1]

However, recently [2] it was suggested that driver should always do a
device_init_wakeup(dev, true). Platforms that don't want/need
wakeup support can disable it from userspace via:

echo disabled  /sys/devices/.../power/wakeup

Also, with the new DT boot-up, board file doesn't exist and hence there
is no way to have device wakeup support rtc.

The fix for above issues, is to hard code device_init_wakeup() inside
driver and let platforms that don't need this, handle it through the
sysfs power entry.

[1]
https://patchwork.kernel.org/patch/136731/

[2]
http://www.mail-archive.com/davinci-linux-open-source@linux.
davincidsp.com/msg26077.html

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Alessandro Zummo a.zu...@towertech.it
Cc: rtc-li...@googlegroups.com
---
:100644 100644 b0ba3fc... 761919d... M  drivers/rtc/rtc-omap.c
 drivers/rtc/rtc-omap.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index b0ba3fc..761919d 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -423,6 +423,8 @@ static int __init omap_rtc_probe(struct platform_device 
*pdev)
 *is write-only, and always reads as zero...)
 */
 
+   device_init_wakeup(pdev-dev, true);
+
if (new_ctrl  (u8) OMAP_RTC_CTRL_SPLIT)
pr_info(%s: split power mode\n, pdev-name);
 
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 3/4] rtc: omap: add rtc wakeup support to alarm events

2013-06-28 Thread Hebbar Gururaja
On some platforms (like AM33xx), a special register (RTC_IRQWAKEEN)
is available to enable Alarm Wakeup feature. This register needs to be
properly handled for the rtcwake to work properly.

Platforms using such IP should set ti,am3352-rtc in rtc device dt
compatibility node.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Grant Likely grant.lik...@linaro.org
Cc: Rob Herring rob.herr...@calxeda.com
Cc: Rob Landley r...@landley.net
Cc: Sekhar Nori nsek...@ti.com
Cc: Kevin Hilman khil...@linaro.org
Cc: Alessandro Zummo a.zu...@towertech.it
Cc: rtc-li...@googlegroups.com
Cc: devicetree-discuss@lists.ozlabs.org
Cc: linux-...@vger.kernel.org
---
:100644 100644 b47aa41... 5a0f02d... M  
Documentation/devicetree/bindings/rtc/rtc-omap.txt
:100644 100644 761919d... 666b0c2... M  drivers/rtc/rtc-omap.c
 Documentation/devicetree/bindings/rtc/rtc-omap.txt |6 ++-
 drivers/rtc/rtc-omap.c |   56 +---
 2 files changed, 54 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt 
b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
index b47aa41..5a0f02d 100644
--- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt
+++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
@@ -1,7 +1,11 @@
 TI Real Time Clock
 
 Required properties:
-- compatible: ti,da830-rtc
+- compatible:
+   - ti,da830-rtc  - for RTC IP used similar to that on DA8xx SoC family.
+   - ti,am3352-rtc - for RTC IP used similar to that on AM335x SoC 
family.
+   This RTC IP has special WAKE-EN Register to enable
+   Wakeup generation for event Alarm.
 - reg: Address range of rtc register set
 - interrupts: rtc timer, alarm interrupts in order
 - interrupt-parent: phandle for the interrupt controller
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 761919d..666b0c2 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -72,6 +72,8 @@
 #define OMAP_RTC_KICK0_REG 0x6c
 #define OMAP_RTC_KICK1_REG 0x70
 
+#define OMAP_RTC_IRQWAKEEN 0x7C
+
 /* OMAP_RTC_CTRL_REG bit fields: */
 #define OMAP_RTC_CTRL_SPLIT(17)
 #define OMAP_RTC_CTRL_DISABLE  (16)
@@ -96,12 +98,21 @@
 #define OMAP_RTC_INTERRUPTS_IT_ALARM(13)
 #define OMAP_RTC_INTERRUPTS_IT_TIMER(12)
 
+/* OMAP_RTC_IRQWAKEEN bit fields: */
+#define OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN(11)
+
 /* OMAP_RTC_KICKER values */
 #defineKICK0_VALUE 0x83e70b13
 #defineKICK1_VALUE 0x95a4f1e0
 
 #defineOMAP_RTC_HAS_KICKER 0x1
 
+/*
+ * Few RTC IP revisions has special WAKE-EN Register to enable Wakeup
+ * generation for event Alarm.
+ */
+#defineOMAP_RTC_HAS_IRQWAKEEN  0x2
+
 static void __iomem*rtc_base;
 
 #define rtc_read(addr) readb(rtc_base + (addr))
@@ -301,7 +312,8 @@ static struct rtc_class_ops omap_rtc_ops = {
 static int omap_rtc_alarm;
 static int omap_rtc_timer;
 
-#defineOMAP_RTC_DATA_DA830_IDX 1
+#defineOMAP_RTC_DATA_DA830_IDX 1
+#defineOMAP_RTC_DATA_AM335X_IDX2
 
 static struct platform_device_id omap_rtc_devtype[] = {
{
@@ -309,6 +321,9 @@ static struct platform_device_id omap_rtc_devtype[] = {
}, {
.name   = da830-rtc,
.driver_data = OMAP_RTC_HAS_KICKER,
+   }, {
+   .name   = am335x-rtc,
+   .driver_data = OMAP_RTC_HAS_KICKER | OMAP_RTC_HAS_IRQWAKEEN,
},
{},
 };
@@ -318,6 +333,9 @@ static const struct of_device_id omap_rtc_of_match[] = {
{   .compatible = ti,da830-rtc,
.data   = omap_rtc_devtype[OMAP_RTC_DATA_DA830_IDX],
},
+   {   .compatible = ti,am3352-rtc,
+   .data   = omap_rtc_devtype[OMAP_RTC_DATA_AM335X_IDX],
+   },
{},
 };
 MODULE_DEVICE_TABLE(of, omap_rtc_of_match);
@@ -466,16 +484,28 @@ static u8 irqstat;
 
 static int omap_rtc_suspend(struct device *dev)
 {
+   u8 irqwake_stat;
+   struct platform_device *pdev = to_platform_device(dev);
+   const struct platform_device_id *id_entry =
+   platform_get_device_id(pdev);
+
irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG);
 
/* FIXME the RTC alarm is not currently acting as a wakeup event
-* source, and in fact this enable() call is just saving a flag
-* that's never used...
+* source on some platforms, and in fact this enable() call is just
+* saving a flag that's never used...
 */
-   if (device_may_wakeup(dev))
+   if (device_may_wakeup(dev)) {
enable_irq_wake(omap_rtc_alarm);
-   else
+
+   if (id_entry-driver_data  OMAP_RTC_HAS_IRQWAKEEN) {
+   irqwake_stat = rtc_read(OMAP_RTC_IRQWAKEEN);
+   irqwake_stat

[PATCH 4/4] ARM: dts: AM33XX: update rtc node compatibility

2013-06-28 Thread Hebbar Gururaja
Since AM33xx  RTC IP has RTC_IRQWAKEEN to support Alarm Wake-up.

Update the rtc compatible property to ti,am3352-rtc to enable handling
of this feature inside rtc-omap driver.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Sekhar Nori nsek...@ti.com
Cc: Kevin Hilman khil...@linaro.org
Cc: b-cous...@ti.com
---
:100644 100644 77aa1b0... dde180a... M  arch/arm/boot/dts/am33xx.dtsi
 arch/arm/boot/dts/am33xx.dtsi |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index 77aa1b0..dde180a 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -297,7 +297,7 @@
};
 
rtc@44e3e000 {
-   compatible = ti,da830-rtc;
+   compatible = ti,am3352-rtc;
reg = 0x44e3e000 0x1000;
interrupts = 75
  76;
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 2/4] davinci: da8xx/omap-l1: Remove hard coding of rtc device wakeup

2013-06-28 Thread Hebbar Gururaja
Since now rtc-omap driver itself calls deice_init_wakeup(dev, true),
duplicate call from the rtc device registration can be removed.

This is basically a partial revert of the prev commit

commit 75c99bb0006ee065b4e2995078d779418b0fab54
Author: Sekhar Nori nsek...@ti.com

davinci: da8xx/omap-l1: mark RTC as a wakeup source

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Sekhar Nori nsek...@ti.com
Cc: Kevin Hilman khil...@linaro.org
Cc: Russell King li...@arm.linux.org.uk

---
:100644 100644 bf57252... 85a900c... M  arch/arm/mach-davinci/devices-da8xx.c
 arch/arm/mach-davinci/devices-da8xx.c |9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/arch/arm/mach-davinci/devices-da8xx.c 
b/arch/arm/mach-davinci/devices-da8xx.c
index bf57252..85a900c 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -827,14 +827,7 @@ static struct platform_device da8xx_rtc_device = {
 
 int da8xx_register_rtc(void)
 {
-   int ret;
-
-   ret = platform_device_register(da8xx_rtc_device);
-   if (!ret)
-   /* Atleast on DA850, RTC is a wakeup source */
-   device_init_wakeup(da8xx_rtc_device.dev, true);
-
-   return ret;
+   return  platform_device_register(da8xx_rtc_device);
 }
 
 static void __iomem *da8xx_ddr2_ctlr_base;
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 5/5] mmc: omap_hsmmc: Add reg-offset to bindings documentation

2013-06-25 Thread Hebbar, Gururaja
On Wed, Jun 26, 2013 at 06:55:01, Fernandes, Joel wrote:
 From: Joel A Fernandes agnel.j...@gmail.com
 
 A new reg-offset property was added to account for register offsets
 in some omap-hsmmc's. Document the new property.
 

Small nitpick

I usually get feedback that any driver DT changes and the associated
Binding doc update should come in one single patch for better readability.

In this case, I believe it would be patch 1/5  5/5


Regards, 
Gururaja


 Signed-off-by: Joel A Fernandes agnel.j...@gmail.com
 ---
  .../devicetree/bindings/mmc/ti-omap-hsmmc.txt  |3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt 
 b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
 index 8c8908a..33f4b1e 100644
 --- a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
 +++ b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
 @@ -20,6 +20,9 @@ ti,dual-volt: boolean, supports dual voltage cards
  ti,non-removable: non-removable slot (like eMMC)
  ti,needs-special-reset: Requires a special softreset sequence
  ti,needs-special-hs-handling: HSMMC IP needs special setting for handling 
 High Speed
 +reg-offset: Supplementing the common reg property (described in 
 bindings/mmc/mmc.txt),
 +some omap-hsmmc's can start an offset from reg but are otherwise identical 
 to others.
 +The registers between start to offset are considered reserved.
  dmas: List of DMA specifiers with the controller specific format
  as described in the generic DMA client binding. A tx and rx
  specifier is required.
 -- 
 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
 
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 2/2] rtc: omap: add rtc wakeup support to alarm events

2013-06-14 Thread Hebbar, Gururaja
On Fri, Jun 14, 2013 at 03:51:43, Kevin Hilman wrote:
 Hebbar, Gururaja gururaja.heb...@ti.com writes:
 
  Hi Kevin,
 
  On Mon, Jun 10, 2013 at 16:55:17, Hebbar, Gururaja wrote:
  On Fri, May 31, 2013 at 23:11:22, Kevin Hilman wrote:
   Hebbar Gururaja gururaja.heb...@ti.com writes:
   
On some platforms (like AM33xx), a special register (RTC_IRQWAKEEN)
is available to enable Wakeup feature for Alarm Events.
   
Since new platforms/Boards are now added through DT only, this feature
is supported via DT property only.
   
Platforms using such IP should add the property ti,has_irq_wake_enb
in rtc DT node.
   
   This is a property of the IP, not the board.  Can't you detect this
   based on the revision of the IP?
  
  Here is what I found out till now.
  
  1. rtc-omap driver is used by Davinci, OMAP-1/2  AM33xx SoC.
  
  2. Only AM33xx soc rtc ip has revision register ( populated). Older OMAP
 Or davinci doesn't have this register.
  
  3. AFAIK, this was the reason why Afzal used platform_device_id  
 of_device_id-data method to detect new versions (commit
 9e0344dcc225fe1a0e8b8af9ff7df44ec4613580)
  
  
  So now either 
  a. I can follow the same method and add new member to omap_rtc_devtype  
  add a new compatible in 
   omap_rtc_of_match in rtc-omap.c
  
  or
  
  b. use dt property to indicate existence of above property.
  
  
  Kindly let me know your opinion about the same.
 
  Any update on this. I have patch ready for both the choices. Waiting for 
  your ok to send
 
 I think (a) is better.

Ok. I will add the property using a new DT compatibility.


 
 The driver should always do a device_init_wakeup(dev, true), *except*
 for devtypes that don't have this feature.

wakeup capable and irq-wake-enable-for-alarm-event are different

For irq-wake-enable-for-alarm-event, I will add a new DT compability.

However, wakeup capable notification is done in another patch using the a 
DT property ti,wakeup_capable.

The reason for using a dt property is specified below


commit fa5b07820fe3a0fc06ac368516e71f10a59b9539
Author: Sekhar Nori nsek...@ti.com
Date:   Wed Oct 27 15:33:05 2010 -0700

rtc: omap: let device wakeup capability be configured from chip
init logic

The rtc-omap driver currently hardcodes the RTC wakeup
capability to be not capable.  While this seems to be true for
existing OMAP1 boards which are not wired for this, the
DA850/OMAP-L138 SoC, the RTC can always be wake up source from
its deep sleep mode.


So I cannot directly add device_init_wakeup(dev, true), inside driver code.
So, I added a DT property




 
 Kevin
 
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 2/2] rtc: omap: add rtc wakeup support to alarm events

2013-06-13 Thread Hebbar, Gururaja
Hi Kevin,

On Mon, Jun 10, 2013 at 16:55:17, Hebbar, Gururaja wrote:
 On Fri, May 31, 2013 at 23:11:22, Kevin Hilman wrote:
  Hebbar Gururaja gururaja.heb...@ti.com writes:
  
   On some platforms (like AM33xx), a special register (RTC_IRQWAKEEN)
   is available to enable Wakeup feature for Alarm Events.
  
   Since new platforms/Boards are now added through DT only, this feature
   is supported via DT property only.
  
   Platforms using such IP should add the property ti,has_irq_wake_enb
   in rtc DT node.
  
  This is a property of the IP, not the board.  Can't you detect this
  based on the revision of the IP?
 
 Here is what I found out till now.
 
 1. rtc-omap driver is used by Davinci, OMAP-1/2  AM33xx SoC.
 
 2. Only AM33xx soc rtc ip has revision register ( populated). Older OMAP
Or davinci doesn't have this register.
 
 3. AFAIK, this was the reason why Afzal used platform_device_id  
of_device_id-data method to detect new versions (commit
9e0344dcc225fe1a0e8b8af9ff7df44ec4613580)
 
 
 So now either 
 a. I can follow the same method and add new member to omap_rtc_devtype  add 
 a new compatible in 
  omap_rtc_of_match in rtc-omap.c
 
 or
 
 b. use dt property to indicate existence of above property.
 
 
 Kindly let me know your opinion about the same.

Any update on this. I have patch ready for both the choices. Waiting for your 
ok to send


 
  
  Kevin
  
 
 
 Regards, 
 Gururaja
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 11/11] i2c: omap: enhance pinctrl support

2013-06-05 Thread Hebbar, Gururaja
On Fri, May 31, 2013 at 20:25:38, Strashko, Grygorii wrote:
 On 05/31/2013 01:13 PM, Hebbar Gururaja wrote:
  Amend the I2C omap pin controller to optionally take a pin control
  handle and set the state of the pins to:
 
  - default on boot, resume and before performing an i2c transfer
  - idle after initial default, after resume default, and after each
  i2c xfer
  - sleep on suspend()
 
  By optionally putting the pins into sleep state in the suspend callback
  we can accomplish two things.
  - One is to minimize current leakage from pins and thus save power,
  - second, we can prevent the IP from driving pins output in an
  uncontrolled manner, which may happen if the power domain drops the
  domain regulator.
 
  Note:
  A .suspend  .resume callback is added which simply puts the pins to sleep
  state upon suspend  are moved to default  idle state upon resume.
 
  If any of the above pin states are missing in dt, a warning message
  about the missing state is displayed.
  If certain pin-states are not available, to remove this warning message
  pass respective state name with null phandler.
 
  (Changes based on i2c-nomadik.c)
 
  Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
  Cc: Tony Lindgren t...@atomide.com
  Cc: Wolfram Sang w...@the-dreams.de
  Cc: linux-o...@vger.kernel.org
  Cc: linux-...@vger.kernel.org
  ---
  :100644 100644 e02f9e3... 588ba28... M  drivers/i2c/busses/i2c-omap.c
drivers/i2c/busses/i2c-omap.c |  112 
  ++---
1 file changed, 105 insertions(+), 7 deletions(-)
 
  diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
  index e02f9e3..588ba28 100644
  --- a/drivers/i2c/busses/i2c-omap.c
  +++ b/drivers/i2c/busses/i2c-omap.c
  @@ -214,7 +214,11 @@ struct omap_i2c_dev {
  u16 westate;
  u16 errata;

  -   struct pinctrl  *pins;
  +   /* Three pin states - default, idle  sleep */
  +   struct pinctrl  *pinctrl;
  +   struct pinctrl_state*pins_default;
  +   struct pinctrl_state*pins_idle;
  +   struct pinctrl_state*pins_sleep;
};

static const u8 reg_map_ip_v1[] = {
  @@ -641,6 +645,11 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
  msgs[], int num)
  if (IS_ERR_VALUE(r))
  goto out;

 The current HWMOD framework configures PINs to enable state before 
 enabling the device and
 switch PINs to idle state after disabling the device. Why here its done 
 in different order?

AFAIK, in case of DT boot, oh-mux will be NULL. So hwmod will not change
Any pins.


  +   /* Optionaly enable pins to be muxed in and configured */
  +   if (!IS_ERR(dev-pins_default))
  +   if (pinctrl_select_state(dev-pinctrl, dev-pins_default))
  +   dev_err(dev-dev, could not set default pins\n);
  +
  r = omap_i2c_wait_for_bb(dev);
  if (r  0)
  goto out;
  @@ -664,7 +673,13 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
  msgs[], int num)

out:
  pm_runtime_mark_last_busy(dev-dev);
  +
  pm_runtime_put_autosuspend(dev-dev);
  +   /* Optionally let pins go into idle state */
  +   if (!IS_ERR(dev-pins_idle))
  +   if (pinctrl_select_state(dev-pinctrl, dev-pins_idle))
  +   dev_err(dev-dev, could not set pins to idle state\n);
  +
  return r;
}

  @@ -1123,14 +1138,47 @@ omap_i2c_probe(struct platform_device *pdev)
  dev-set_mpu_wkup_lat = pdata-set_mpu_wkup_lat;
  }

  -   dev-pins = devm_pinctrl_get_select_default(pdev-dev);
  -   if (IS_ERR(dev-pins)) {
  -   if (PTR_ERR(dev-pins) == -EPROBE_DEFER)
  +   dev-pinctrl = devm_pinctrl_get(pdev-dev);
 May be struct device -pins-p can be used instead of dev-pinctrl?
  +   if (!IS_ERR(dev-pinctrl)) {
  +   dev-pins_default = pinctrl_lookup_state(dev-pinctrl,
  +PINCTRL_STATE_DEFAULT);
  +   if (IS_ERR(dev-pins_default))
  +   dev_dbg(pdev-dev, could not get default pinstate\n);
  +   else
  +   if (pinctrl_select_state(dev-pinctrl,
  +dev-pins_default))
  +   dev_err(pdev-dev,
  +   could not set default pinstate\n);
 Don't need to set Default pin state
 Default pins state is applied by DD framework automatically before 
 device probing
 and stored in struct device -pins-default_state

Correct.

  +
  +   dev-pins_idle = pinctrl_lookup_state(dev-pinctrl,
  + PINCTRL_STATE_IDLE);
  +   if (IS_ERR(dev-pins_idle))
  +   dev_dbg(pdev-dev, could not get idle pinstate\n);
  +   else
  +   /* If possible, let's idle until the first transfer */
  +   if (pinctrl_select_state(dev-pinctrl

RE: [PATCH 2/2] rtc: omap: add rtc wakeup support to alarm events

2013-06-04 Thread Hebbar, Gururaja
On Fri, May 31, 2013 at 23:11:22, Kevin Hilman wrote:
 Hebbar Gururaja gururaja.heb...@ti.com writes:
 
  On some platforms (like AM33xx), a special register (RTC_IRQWAKEEN)
  is available to enable Wakeup feature for Alarm Events.
 
  Since new platforms/Boards are now added through DT only, this feature
  is supported via DT property only.
 
  Platforms using such IP should add the property ti,has_irq_wake_enb
  in rtc DT node.
 
 This is a property of the IP, not the board.  

Correct.

 Can't you detect this
 based on the revision of the IP?

Will check this and return.

 
 Kevin
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 1/2] rtc: omap: add option to indicate wakeup support through DT

2013-06-04 Thread Hebbar, Gururaja
On Fri, May 31, 2013 at 23:18:03, Kevin Hilman wrote:
 Hebbar Gururaja gururaja.heb...@ti.com writes:
 
  Even though RTC-IP is wakeup capable, Not all Boards support it.
 
  For example
  The rtc alarm wakeup is available in rtc-ip since omap1 days but alarm
  was not wired properly in previous ompa1 boards.
 
  commit fa5b07820fe3a0fc06ac368516e71f10a59b9539
  Author: Sekhar Nori nsek...@ti.com
  Date:   Wed Oct 27 15:33:05 2010 -0700
 
  rtc: omap: let device wakeup capability be configured from chip
  init logic
 
  The rtc-omap driver currently hardcodes the RTC wakeup
  capability to be not capable.  While this seems to be true for
  existing OMAP1 boards which are not wired for this, the
  DA850/OMAP-L138 SoC, the RTC can always be wake up source from
  its deep sleep mode.
 
  Current rtc-omap driver expects the rtc module wake-up capabilities to
  be set up by board specific code. However, in case of DT, this is not
  possible.
 
  So, add a DT property ti,wakeup_capable to indicate that the module is
  wake-up capable.
 
 Why is this a TI-specific property?  

May be I am wrong but isn't this driver used only be TI SoC (Davinci, OMAP ...)

 
 Also, I think we can do this without a new DT property.Did you see this
 patch from Tony which is already queued for v3.11:
 
 http://marc.info/?l=linux-omapm=136917244530612w=2

AFAIK, all boards that use twl rtc IP by default support rtc wakeup.

However, as mentioned in the commit message not all boards that uses
OMAP rtc IP supports rtc wake up (due to somoe wiring issue).
Hence I am adding a new DT property for this.

 
 I think this is the right way to go.  Platforms that don't want/need
 wakeup support can disable it from userspace via:
 
 echo disabled  /sys/devices/.../power/wakeup

Hmmm. Debatable. Let me get some more info about this and come back

 
 Kevin
 
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 11/11] i2c: omap: enhance pinctrl support

2013-06-04 Thread Hebbar, Gururaja
On Fri, May 31, 2013 at 23:37:02, Kevin Hilman wrote:
 +Linus Walleij (pinctrl maintainer)
 
 Hebbar Gururaja gururaja.heb...@ti.com writes:
 
  Amend the I2C omap pin controller to optionally take a pin control
  handle and set the state of the pins to:
 
  - default on boot, resume and before performing an i2c transfer
  - idle after initial default, after resume default, and after each
  i2c xfer
  - sleep on suspend()
 
  By optionally putting the pins into sleep state in the suspend callback
  we can accomplish two things.
  - One is to minimize current leakage from pins and thus save power,
  - second, we can prevent the IP from driving pins output in an
  uncontrolled manner, which may happen if the power domain drops the
  domain regulator.
 
  Note:
  A .suspend  .resume callback is added which simply puts the pins to sleep
  state upon suspend  are moved to default  idle state upon resume.
 
  If any of the above pin states are missing in dt, a warning message
  about the missing state is displayed.
  If certain pin-states are not available, to remove this warning message
  pass respective state name with null phandler.
 
  (Changes based on i2c-nomadik.c)
 
  Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
  Cc: Tony Lindgren t...@atomide.com
  Cc: Wolfram Sang w...@the-dreams.de
  Cc: linux-o...@vger.kernel.org
  Cc: linux-...@vger.kernel.org
 
 [...]
 
  @@ -1123,14 +1138,47 @@ omap_i2c_probe(struct platform_device *pdev)
  dev-set_mpu_wkup_lat = pdata-set_mpu_wkup_lat;
  }
   
  -   dev-pins = devm_pinctrl_get_select_default(pdev-dev);
  -   if (IS_ERR(dev-pins)) {
  -   if (PTR_ERR(dev-pins) == -EPROBE_DEFER)
  +   dev-pinctrl = devm_pinctrl_get(pdev-dev);
  +   if (!IS_ERR(dev-pinctrl)) {
  +   dev-pins_default = pinctrl_lookup_state(dev-pinctrl,
  +PINCTRL_STATE_DEFAULT);
 
 This part is already done by probe in driver core, why does it need to
 be done again.  dev-pins-default_state should already have this.
 (c.f. pinctrl_bind_pins() in drivers/base/pinctrl.c)
 
 But that brings up a bigger question about whether or not we should be
 doing the rest of this (idle/sleep) pin management in the drivers or in
 the driver core as well.  I would much prefer it be handled by the
 driver core.
 
 In fact, since these are all PM related events, it should probably be
 handled by the PM core and seems pretty straight forward to do so.

Let me pull out some info about these and come back

 
 Kevin
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 09/11] mmc: omap_hsmmc: enhance pinctrl support

2013-06-04 Thread Hebbar, Gururaja
On Tue, Jun 04, 2013 at 12:49:57, Linus Walleij wrote:
 On Tue, Jun 4, 2013 at 9:11 AM, Linus Walleij linus.wall...@linaro.org 
 wrote:
  On Fri, May 31, 2013 at 12:13 PM, Hebbar Gururaja
  gururaja.heb...@ti.com wrote:
 
  Amend the hsmmc controller to optionally take a pin control handle and
  set the state of the pins to:
 
  - default on boot, resume and before performing a mmc transfer
  - idle after initial default, after resume default, and after each
  mmc/sd card access
  - sleep on suspend()
 
  By optionally putting the pins into sleep state in the suspend callback
  we can accomplish two things.
  - One is to minimize current leakage from pins and thus save power,
  - second, we can prevent the IP from driving pins output in an
  uncontrolled manner, which may happen if the power domain drops the
  domain regulator.
 
  If any of the above pin states are missing in dt, a warning message
  about the missing state is displayed.
  If certain pin-states are not available, to remove this warning message
  pass respective state name with null phandler.
 
  Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
  Cc: Balaji T K balaj...@ti.com
  Cc: Chris Ball c...@laptop.org
  Cc: linux-...@vger.kernel.org
  Cc: linux-o...@vger.kernel.org
 
  This is perfectly correct.
  Acked-by: Linus Walleij linus.wall...@linaro.org
 
 So please consider my other option given in patch 2 instead.

I will check how I can be a part of this implementation

 
 Yours,
 Linus Walleij
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 05/11] spi: omap2-mcspi: enhance pinctrl support

2013-06-04 Thread Hebbar, Gururaja
On Sun, Jun 02, 2013 at 00:57:26, Mark Brown wrote:
 On Fri, May 31, 2013 at 03:43:05PM +0530, Hebbar Gururaja wrote:
  Amend the spi omap controller to optionally take a pin control
  handle and set the state of the pins to:
  
  - default on boot, resume and before performing an spi transfer
  - idle after initial default, after resume default, and after each
  spi xfer
  - sleep on suspend()
 
 Looking at this code I can't really see what's OMAP-specific about it -
 exactly the same flow should apply to pretty much any SPI controller,
 especially given that the code will happily ignore missing states.
 We're just setting the idle state when not actively transferring data
 which seems sensible and generic.
 
 This suggests to me that we should be adding this code into the core,
 probably joined up with the transfer_one_message stuff, so that any
 hardware which has an idle state will be able to get the benefit.  Can
 anyone think of a reason why we shouldn't do that?

Let me pull out some info about these and come back

 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 1/2] rtc: omap: add option to indicate wakeup support through DT

2013-05-31 Thread Hebbar Gururaja
Even though RTC-IP is wakeup capable, Not all Boards support it.

For example
The rtc alarm wakeup is available in rtc-ip since omap1 days but alarm
was not wired properly in previous ompa1 boards.

commit fa5b07820fe3a0fc06ac368516e71f10a59b9539
Author: Sekhar Nori nsek...@ti.com
Date:   Wed Oct 27 15:33:05 2010 -0700

rtc: omap: let device wakeup capability be configured from chip
init logic

The rtc-omap driver currently hardcodes the RTC wakeup
capability to be not capable.  While this seems to be true for
existing OMAP1 boards which are not wired for this, the
DA850/OMAP-L138 SoC, the RTC can always be wake up source from
its deep sleep mode.

Current rtc-omap driver expects the rtc module wake-up capabilities to
be set up by board specific code. However, in case of DT, this is not
possible.

So, add a DT property ti,wakeup_capable to indicate that the module is
wake-up capable.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
---
:100644 100644 b47aa41... 108a629... M  
Documentation/devicetree/bindings/rtc/rtc-omap.txt
:100644 100644 b0ba3fc... 000a02f... M  drivers/rtc/rtc-omap.c
 Documentation/devicetree/bindings/rtc/rtc-omap.txt |4 
 drivers/rtc/rtc-omap.c |5 +
 2 files changed, 9 insertions(+)

diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt 
b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
index b47aa41..108a629 100644
--- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt
+++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
@@ -6,6 +6,10 @@ Required properties:
 - interrupts: rtc timer, alarm interrupts in order
 - interrupt-parent: phandle for the interrupt controller
 
+Optional properties:
+- ti,wakeup_capable: Inform the rtc driver that this module is wake-up
+  capable so that rtcwake and suspend tests can work.
+
 Example:
 
 rtc@1c23000 {
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index b0ba3fc..000a02f 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -423,6 +423,11 @@ static int __init omap_rtc_probe(struct platform_device 
*pdev)
 *is write-only, and always reads as zero...)
 */
 
+   /* Fixup wakeup-enable feature based on the device tree */
+   if (of_id  of_find_property(pdev-dev.of_node,
+ ti,wakeup_capable, NULL))
+   device_init_wakeup(pdev-dev, 1);
+
if (new_ctrl  (u8) OMAP_RTC_CTRL_SPLIT)
pr_info(%s: split power mode\n, pdev-name);
 
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 0/2] rtc: rtc-omap: add support for DT wakeup alarm events

2013-05-31 Thread Hebbar Gururaja
Current rtc-omap driver expects the rtc module wake-up capabilities to
be set up by board specific code. However, in case of DT, this is not
possible.

So, add a DT property ti,wakeup_capable to indicate that the module
is wake-up capable.

Also, on some platforms (like AM33xx), a special register
(RTC_IRQWAKEEN) is available to enable Wakeup feature for Alarm Events.

Since new platforms/Boards are now added through DT only, this feature
is supported via DT property only. Platforms using such IP should add
the property ti,has_irq_wake_enb in rtc DT node.

Kernel Base for the series is
 git://git.kernel.org/pub/scm/linux/kernel/git/bcousson/
linux-omap-dt.git
 linux-omap-git/for_3.11/dts

Hebbar Gururaja (2):
  rtc: omap: add option to indicate wakeup support through DT
  rtc: omap: add rtc wakeup support to alarm events

 Documentation/devicetree/bindings/rtc/rtc-omap.txt |6 +++
 drivers/rtc/rtc-omap.c |   50 +---
 2 files changed, 49 insertions(+), 7 deletions(-)

-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 2/2] rtc: omap: add rtc wakeup support to alarm events

2013-05-31 Thread Hebbar Gururaja
On some platforms (like AM33xx), a special register (RTC_IRQWAKEEN)
is available to enable Wakeup feature for Alarm Events.

Since new platforms/Boards are now added through DT only, this feature
is supported via DT property only.

Platforms using such IP should add the property ti,has_irq_wake_enb
in rtc DT node.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
---
:100644 100644 108a629... b870d87... M  
Documentation/devicetree/bindings/rtc/rtc-omap.txt
:100644 100644 000a02f... 5e9c0dd... M  drivers/rtc/rtc-omap.c
 Documentation/devicetree/bindings/rtc/rtc-omap.txt |2 +
 drivers/rtc/rtc-omap.c |   47 
 2 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt 
b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
index 108a629..b870d87 100644
--- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt
+++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
@@ -9,6 +9,8 @@ Required properties:
 Optional properties:
 - ti,wakeup_capable: Inform the rtc driver that this module is wake-up
   capable so that rtcwake and suspend tests can work.
+- ti,has_irq_wake_enb: Inform rtc driver that this module has a a
+  special register to enable Wakeup feature for Alarm events.
 
 Example:
 
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 000a02f..5e9c0dd 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -72,6 +72,8 @@
 #define OMAP_RTC_KICK0_REG 0x6c
 #define OMAP_RTC_KICK1_REG 0x70
 
+#define OMAP_RTC_IRQWAKEEN 0x7C
+
 /* OMAP_RTC_CTRL_REG bit fields: */
 #define OMAP_RTC_CTRL_SPLIT(17)
 #define OMAP_RTC_CTRL_DISABLE  (16)
@@ -96,6 +98,9 @@
 #define OMAP_RTC_INTERRUPTS_IT_ALARM(13)
 #define OMAP_RTC_INTERRUPTS_IT_TIMER(12)
 
+/* OMAP_RTC_IRQWAKEEN bit fields: */
+#define OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN(11)
+
 /* OMAP_RTC_KICKER values */
 #defineKICK0_VALUE 0x83e70b13
 #defineKICK1_VALUE 0x95a4f1e0
@@ -103,6 +108,7 @@
 #defineOMAP_RTC_HAS_KICKER 0x1
 
 static void __iomem*rtc_base;
+static unsigned inthas_irq_wake_enb_bit;
 
 #define rtc_read(addr) readb(rtc_base + (addr))
 #define rtc_write(val, addr)   writeb(val, rtc_base + (addr))
@@ -425,9 +431,14 @@ static int __init omap_rtc_probe(struct platform_device 
*pdev)
 
/* Fixup wakeup-enable feature based on the device tree */
if (of_id  of_find_property(pdev-dev.of_node,
- ti,wakeup_capable, NULL))
+ ti,wakeup_capable, NULL)) {
device_init_wakeup(pdev-dev, 1);
 
+   if (of_find_property(pdev-dev.of_node,
+ti,has_irq_wake_enb, NULL))
+   has_irq_wake_enb_bit = true;
+   }
+
if (new_ctrl  (u8) OMAP_RTC_CTRL_SPLIT)
pr_info(%s: split power mode\n, pdev-name);
 
@@ -469,16 +480,26 @@ static u8 irqstat;
 
 static int omap_rtc_suspend(struct device *dev)
 {
+   u8 irqwake_stat;
+
irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG);
 
-   /* FIXME the RTC alarm is not currently acting as a wakeup event
-* source, and in fact this enable() call is just saving a flag
-* that's never used...
+   /*
+* FIXME. On some platforms the RTC alarm is not currently acting as a
+* wakeup event source, and in fact this enable() call is just saving a
+* flag that's never used...
 */
-   if (device_may_wakeup(dev))
+   if (device_may_wakeup(dev)) {
enable_irq_wake(omap_rtc_alarm);
-   else
+
+   if (has_irq_wake_enb_bit == true) {
+   irqwake_stat = rtc_read(OMAP_RTC_IRQWAKEEN);
+   irqwake_stat |= OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN;
+   rtc_write(irqwake_stat, OMAP_RTC_IRQWAKEEN);
+   }
+   } else {
rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
+   }
 
/* Disable the clock/module */
pm_runtime_put_sync(dev);
@@ -488,13 +509,23 @@ static int omap_rtc_suspend(struct device *dev)
 
 static int omap_rtc_resume(struct device *dev)
 {
+   u8 irqwake_stat;
+
/* Enable the clock/module so that we can access the registers */
pm_runtime_get_sync(dev);
 
-   if (device_may_wakeup(dev))
+   if (device_may_wakeup(dev)) {
disable_irq_wake(omap_rtc_alarm);
-   else
+
+   if (has_irq_wake_enb_bit == true) {
+   irqwake_stat = rtc_read(OMAP_RTC_IRQWAKEEN);
+   irqwake_stat = ~OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN;
+   rtc_write(irqwake_stat, OMAP_RTC_IRQWAKEEN);
+   }
+   } else {
rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG);
+   }
+
return 0

RE: [PATCH 1/2] rtc: omap: add option to indicate wakeup support through DT

2013-05-31 Thread Hebbar, Gururaja
On Fri, May 31, 2013 at 12:14:44, Prabhakar Lad wrote:
 Hi Gururaja,
 
 Thanks for the patch.
 
 On Fri, May 31, 2013 at 12:03 PM, Hebbar Gururaja
 gururaja.heb...@ti.com wrote:
  Even though RTC-IP is wakeup capable, Not all Boards support it.
 
  For example
  The rtc alarm wakeup is available in rtc-ip since omap1 days but alarm
  was not wired properly in previous ompa1 boards.
 
 [snip]
 
  +Optional properties:
  +- ti,wakeup_capable: Inform the rtc driver that this module is wake-up
 For devicetree properties '-' is preferred over '_'.

Thanks for the review. I will make the correction. But will wait for some 
more time (so others can review) and then send V2

 
 Regards,
 --Prabhakar Lad
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 01/11] pinctrl: single: adopt pinctrl sleep mode management

2013-05-31 Thread Hebbar Gururaja
Make pinctrl-single able to handle suspend/resume events and change
hogged pins states accordingly.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Linus Walleij linus.wall...@linaro.org
---
:100644 100644 b9fa046... bfd4f6a... M  drivers/pinctrl/pinctrl-single.c
 drivers/pinctrl/pinctrl-single.c |   27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index b9fa046..bfd4f6a 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1346,6 +1346,29 @@ static int pcs_add_gpio_func(struct device_node *node, 
struct pcs_device *pcs)
return ret;
 }
 
+static int pinctrl_single_suspend(struct platform_device *pdev,
+   pm_message_t state)
+{
+   struct pcs_device *pcs;
+
+   pcs = platform_get_drvdata(pdev);
+   if (!pcs)
+   return -EINVAL;
+
+   return pinctrl_force_sleep(pcs-pctl);
+}
+
+static int pinctrl_single_resume(struct platform_device *pdev)
+{
+   struct pcs_device *pcs;
+
+   pcs = platform_get_drvdata(pdev);
+   if (!pcs)
+   return -EINVAL;
+
+   return pinctrl_force_default(pcs-pctl);
+}
+
 static int pcs_probe(struct platform_device *pdev)
 {
struct device_node *np = pdev-dev.of_node;
@@ -1494,6 +1517,10 @@ static struct platform_driver pcs_driver = {
.name   = DRIVER_NAME,
.of_match_table = pcs_of_match,
},
+#ifdef CONFIG_PM
+   .suspend = pinctrl_single_suspend,
+   .resume = pinctrl_single_resume,
+#endif
 };
 
 module_platform_driver(pcs_driver);
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 02/11] leds: leds-gpio: Enhance pinctrl support

2013-05-31 Thread Hebbar Gururaja
Amend leds-gpio driver to optionally take a pin control handle and set
the state of the pins to:

- default on boot, resume
- sleep on suspend()

By optionally putting the pins into sleep state in the suspend callback
we can accomplish two things.
- One is to minimize current leakage from pins and thus save power,
- second, we can prevent the IP from driving pins output in an
uncontrolled manner, which may happen if the power domain drops the
domain regulator.

If any of the above pin states are missing in dt, a warning message
about the missing state is displayed.
If certain pin-states are not available, to remove this warning message
pass respective state name with null phandler.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Bryan Wu coolo...@gmail.com
Cc: Richard Purdie rpur...@rpsys.net
Cc: linux-l...@vger.kernel.org
---
:100644 100644 b02b679... b094e52... M  drivers/leds/leds-gpio.c
 drivers/leds/leds-gpio.c |   81 ++
 1 file changed, 75 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index b02b679..b094e52 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -153,6 +153,10 @@ static void delete_gpio_led(struct gpio_led_data *led)
 
 struct gpio_leds_priv {
int num_leds;
+   /* Two optional pin states - default  sleep */
+   struct pinctrl  *pinctrl;
+   struct pinctrl_state*pins_default;
+   struct pinctrl_state*pins_sleep;
struct gpio_led_data leds[];
 };
 
@@ -162,6 +166,43 @@ static inline int sizeof_gpio_leds_priv(int num_leds)
(sizeof(struct gpio_led_data) * num_leds);
 }
 
+/* Use pinctrl API for gpio configuration */
+static void gpio_led_get_pinctrl(struct gpio_leds_priv *priv,
+   struct platform_device *pdev)
+{
+   priv-pinctrl = devm_pinctrl_get(pdev-dev);
+   if (!IS_ERR(priv-pinctrl)) {
+   priv-pins_default = pinctrl_lookup_state(priv-pinctrl,
+   PINCTRL_STATE_DEFAULT);
+   /* enable pins to be muxed in and configured */
+   if (IS_ERR(priv-pins_default))
+   dev_dbg(pdev-dev,
+   could not get default pinstate\n);
+   else
+   if (pinctrl_select_state(priv-pinctrl,
+priv-pins_default))
+   dev_err(pdev-dev,
+   could not set default pins\n);
+
+   priv-pins_sleep = pinctrl_lookup_state(priv-pinctrl,
+   PINCTRL_STATE_SLEEP);
+   if (IS_ERR(priv-pins_sleep))
+   dev_dbg(pdev-dev,
+   could not get sleep pinstate\n);
+   } else {
+   /*
+   * Since we continue even when pinctrl node is not found,
+   * Invalidate pins as not available. This is to make sure that
+   * IS_ERR(pins_xxx) results in failure when used.
+   */
+   priv-pins_default = ERR_PTR(-ENODATA);
+   priv-pins_sleep = ERR_PTR(-ENODATA);
+
+   dev_dbg(pdev-dev,
+   pins are not configured from the driver\n);
+   }
+}
+
 /* Code to create from OpenFirmware platform devices */
 #ifdef CONFIG_OF_GPIO
 static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
@@ -184,6 +225,8 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct 
platform_device *pdev)
if (!priv)
return ERR_PTR(-ENOMEM);
 
+   gpio_led_get_pinctrl(priv, pdev);
+
for_each_child_of_node(np, child) {
struct gpio_led led = {};
enum of_gpio_flags flags;
@@ -236,14 +279,8 @@ static int gpio_led_probe(struct platform_device *pdev)
 {
struct gpio_led_platform_data *pdata = pdev-dev.platform_data;
struct gpio_leds_priv *priv;
-   struct pinctrl *pinctrl;
int i, ret = 0;
 
-   pinctrl = devm_pinctrl_get_select_default(pdev-dev);
-   if (IS_ERR(pinctrl))
-   dev_warn(pdev-dev,
-   pins are not configured from the driver\n);
-
if (pdata  pdata-num_leds) {
priv = devm_kzalloc(pdev-dev,
sizeof_gpio_leds_priv(pdata-num_leds),
@@ -251,6 +288,8 @@ static int gpio_led_probe(struct platform_device *pdev)
if (!priv)
return -ENOMEM;
 
+   gpio_led_get_pinctrl(priv, pdev);
+
priv-num_leds = pdata-num_leds;
for (i = 0; i  priv-num_leds; i++) {
ret = create_gpio_led(pdata-leds[i],
@@ -287,6 +326,32 @@ static int gpio_led_remove(struct platform_device *pdev)
return 0;
 }
 
+static int gpio_led_suspend(struct platform_device *pdev

[PATCH 00/11] drivers: Add Pinctrl PM support

2013-05-31 Thread Hebbar Gururaja
By optionally putting the pins into sleep state in the suspend [or in
runtime_suspend] callback we can accomplish two things.
- One is to minimize current leakage from pins and thus save power,
- second, we can prevent the IP from driving pins output in an
uncontrolled manner, which may happen if the power domain drops the
domain regulator.

These states can be specified in the DT blob and corresponding driver
can pick these states during probe  set the related values during
idle/suspend.

Not all drivers support/has idle state. Drivers like i2c, spi, mmc has
idle states and hence these drivers are updated to support all the
three states
- default  : during regular operation
- idle : when the module is in idle state
- sleep : when the module is in suspend state

For those drivers which doesn't support/have idle state (at least at
the moment), only default  sleep state is added.

The modification expects DT blob to provide the phandler  the pinctrl
states otherwise it gives a warning message. To remove this warning
message pass default state with null phandler to pinctrl in device node

Kernel Base for the series is
 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/
linux-2.6.git
 tag: v3.10-rc3

Hebbar Gururaja (11):
  pinctrl: single: adopt pinctrl sleep mode management
  leds: leds-gpio: Enhance pinctrl support
  Input: gpio_keys: Adopt pinctrl support
  Input: matrix-keypad: Adopt pinctrl support
  spi: omap2-mcspi: enhance pinctrl support
  usb: musb: dsps: Adopt pinctrl support
  pwm: pwm-tiehrpwm: enhance pinctrl support
  pwm: pwm-tiecap: enhance pinctrl support
  mmc: omap_hsmmc: enhance pinctrl support
  video: da8xx-fb: adopt pinctrl support
  i2c: omap: enhance pinctrl support

 drivers/i2c/busses/i2c-omap.c  |  112 ++--
 drivers/input/keyboard/gpio_keys.c |   47 ++
 drivers/input/keyboard/matrix_keypad.c |   48 ++
 drivers/leds/leds-gpio.c   |   81 +--
 drivers/mmc/host/omap_hsmmc.c  |   79 --
 drivers/pinctrl/pinctrl-single.c   |   27 
 drivers/pwm/pwm-tiecap.c   |   48 --
 drivers/pwm/pwm-tiehrpwm.c |   49 --
 drivers/spi/spi-omap2-mcspi.c  |   89 +++--
 drivers/usb/musb/musb_dsps.c   |   46 +
 drivers/video/da8xx-fb.c   |   48 ++
 11 files changed, 641 insertions(+), 33 deletions(-)

-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 03/11] Input: gpio_keys: Adopt pinctrl support

2013-05-31 Thread Hebbar Gururaja
Amend gpio-keys driver to optionally take a pin control handle and set
the state of the pins to:

- default on boot, resume
- sleep on suspend()

By Optionally putting the pins into sleep state in the suspend callback
we can accomplish two things.
- One is to minimize current leakage from pins and thus save power,
- second, we can prevent the IP from driving pins output in an
uncontrolled manner, which may happen if the power domain drops the
domain regulator.

If any of the above pin states are missing in dt, a warning message
about the missing state is displayed.
If certain pin-states are not available, to remove this warning message
pass respective state name with null phandler.

Todo:
- if an idle state is available for pins, add support for it.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Dmitry Torokhov dmitry.torok...@gmail.com
Cc: linux-in...@vger.kernel.org
---
:100644 100644 b29ca65... ca615a4... M  drivers/input/keyboard/gpio_keys.c
 drivers/input/keyboard/gpio_keys.c |   47 
 1 file changed, 47 insertions(+)

diff --git a/drivers/input/keyboard/gpio_keys.c 
b/drivers/input/keyboard/gpio_keys.c
index b29ca65..ca615a4 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -28,6 +28,7 @@
 #include linux/gpio.h
 #include linux/of_platform.h
 #include linux/of_gpio.h
+#include linux/pinctrl/consumer.h
 #include linux/spinlock.h
 
 struct gpio_button_data {
@@ -47,6 +48,10 @@ struct gpio_keys_drvdata {
struct input_dev *input;
struct mutex disable_lock;
struct gpio_button_data data[0];
+   /* Two optional pin states - default  sleep */
+   struct pinctrl  *pinctrl;
+   struct pinctrl_state*pins_default;
+   struct pinctrl_state*pins_sleep;
 };
 
 /*
@@ -709,6 +714,35 @@ static int gpio_keys_probe(struct platform_device *pdev)
goto fail1;
}
 
+   ddata-pinctrl = devm_pinctrl_get(dev);
+   if (!IS_ERR(ddata-pinctrl)) {
+   ddata-pins_default = pinctrl_lookup_state(ddata-pinctrl,
+   PINCTRL_STATE_DEFAULT);
+   /* enable pins to be muxed in and configured */
+   if (IS_ERR(ddata-pins_default))
+   dev_dbg(dev, could not get default pinstate\n);
+   else
+   if (pinctrl_select_state(ddata-pinctrl,
+ddata-pins_default))
+   dev_err(dev,
+   could not set default pinstate\n);
+
+   ddata-pins_sleep = pinctrl_lookup_state(ddata-pinctrl,
+   PINCTRL_STATE_SLEEP);
+   if (IS_ERR(ddata-pins_sleep))
+   dev_dbg(dev, could not get sleep pinstate\n);
+   } else {
+   /*
+   * Since we continue even when pinctrl node is not found,
+   * Invalidate pins as not available. This is to make sure that
+   * IS_ERR(pins_xxx) results in failure when used.
+   */
+   ddata-pins_default = ERR_PTR(-ENODATA);
+   ddata-pins_sleep = ERR_PTR(-ENODATA);
+
+   dev_dbg(dev, pins are not configured from the driver\n);
+   }
+
ddata-pdata = pdata;
ddata-input = input;
mutex_init(ddata-disable_lock);
@@ -816,6 +850,13 @@ static int gpio_keys_suspend(struct device *dev)
enable_irq_wake(bdata-irq);
}
} else {
+   /* Optionally let pins go into sleep states */
+   if (!IS_ERR(ddata-pins_sleep))
+   if (pinctrl_select_state(ddata-pinctrl,
+ddata-pins_sleep))
+   dev_err(dev,
+   could not set pins to sleep state\n);
+
mutex_lock(input-mutex);
if (input-users)
gpio_keys_close(input);
@@ -839,6 +880,12 @@ static int gpio_keys_resume(struct device *dev)
disable_irq_wake(bdata-irq);
}
} else {
+   /* Optionaly enable pins to be muxed in and configured */
+   if (!IS_ERR(ddata-pins_default))
+   if (pinctrl_select_state(ddata-pinctrl,
+ddata-pins_default))
+   dev_err(dev, could not set default pins\n);
+
mutex_lock(input-mutex);
if (input-users)
error = gpio_keys_open(input);
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 05/11] spi: omap2-mcspi: enhance pinctrl support

2013-05-31 Thread Hebbar Gururaja
Amend the spi omap controller to optionally take a pin control
handle and set the state of the pins to:

- default on boot, resume and before performing an spi transfer
- idle after initial default, after resume default, and after each
spi xfer
- sleep on suspend()

By optionally putting the pins into sleep state in the suspend callback
we can accomplish two things.
- One is to minimize current leakage from pins and thus save power,
- second, we can prevent the IP from driving pins output in an
uncontrolled manner, which may happen if the power domain drops the
domain regulator.

If any of the above pin states are missing in dt, a warning message
about the missing state is displayed.
If certain pin-states are not available, to remove this warning message
pass respective state name with null phandler.

(Changes based on i2c-nomadik.c  spi-pl022.c)

Note:
A .suspend callback is added which simply puts the pins to sleep state.
They are moved to default  idle state by the .resume callback.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Mark Brown broo...@kernel.org
Cc: Grant Likely grant.lik...@linaro.org
Cc: spi-devel-gene...@lists.sourceforge.net
---
:100644 100644 86d2158... 146dd16... M  drivers/spi/spi-omap2-mcspi.c
 drivers/spi/spi-omap2-mcspi.c |   89 ++---
 1 file changed, 84 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 86d2158..146dd16 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -130,6 +130,12 @@ struct omap2_mcspi {
struct device   *dev;
struct omap2_mcspi_regs ctx;
unsigned intpin_dir:1;
+
+   /* Three pin states - default, idle  sleep */
+   struct pinctrl  *pinctrl;
+   struct pinctrl_state*pins_default;
+   struct pinctrl_state*pins_idle;
+   struct pinctrl_state*pins_sleep;
 };
 
 struct omap2_mcspi_cs {
@@ -267,6 +273,12 @@ static int omap2_prepare_transfer(struct spi_master 
*master)
struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
 
pm_runtime_get_sync(mcspi-dev);
+
+   /* Optionaly enable pins to be muxed in and configured */
+   if (!IS_ERR(mcspi-pins_default))
+   if (pinctrl_select_state(mcspi-pinctrl, mcspi-pins_default))
+   dev_err(mcspi-dev, could not set default pins\n);
+
return 0;
 }
 
@@ -274,6 +286,12 @@ static int omap2_unprepare_transfer(struct spi_master 
*master)
 {
struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
 
+   /* Optionally let pins go into idle state */
+   if (!IS_ERR(mcspi-pins_idle))
+   if (pinctrl_select_state(mcspi-pinctrl, mcspi-pins_idle))
+   dev_err(mcspi-dev,
+   could not set pins to idle state\n);
+
pm_runtime_mark_last_busy(mcspi-dev);
pm_runtime_put_autosuspend(mcspi-dev);
return 0;
@@ -1186,7 +1204,6 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
static int  bus_num = 1;
struct device_node  *node = pdev-dev.of_node;
const struct of_device_id *match;
-   struct pinctrl *pinctrl;
 
master = spi_alloc_master(pdev-dev, sizeof *mcspi);
if (master == NULL) {
@@ -1284,10 +1301,46 @@ static int omap2_mcspi_probe(struct platform_device 
*pdev)
if (status  0)
goto dma_chnl_free;
 
-   pinctrl = devm_pinctrl_get_select_default(pdev-dev);
-   if (IS_ERR(pinctrl))
-   dev_warn(pdev-dev,
-   pins are not configured from the driver\n);
+   mcspi-pinctrl = devm_pinctrl_get(pdev-dev);
+   if (!IS_ERR(mcspi-pinctrl)) {
+   mcspi-pins_default = pinctrl_lookup_state(mcspi-pinctrl,
+PINCTRL_STATE_DEFAULT);
+   if (IS_ERR(mcspi-pins_default))
+   dev_dbg(pdev-dev, could not get default pinstate\n);
+   else
+   if (pinctrl_select_state(mcspi-pinctrl,
+mcspi-pins_default))
+   dev_err(pdev-dev,
+   could not set default pinstate\n);
+
+   mcspi-pins_idle = pinctrl_lookup_state(mcspi-pinctrl,
+ PINCTRL_STATE_IDLE);
+   if (IS_ERR(mcspi-pins_idle))
+   dev_dbg(pdev-dev, could not get idle pinstate\n);
+   else
+   /* If possible, let's idle until the first transfer */
+   if (pinctrl_select_state(mcspi-pinctrl,
+mcspi-pins_idle))
+   dev_err(pdev-dev,
+   could not set idle

[PATCH 04/11] Input: matrix-keypad: Adopt pinctrl support

2013-05-31 Thread Hebbar Gururaja
Amend matrix-keypad driver to optionally take a pin control handle and
set the state of the pins to:

- default on boot, resume
- sleep on suspend()

By optionally putting the pins into sleep state in the suspend callback
we can accomplish two things.
- One is to minimize current leakage from pins and thus save power,
- second, we can prevent the IP from driving pins output in an
uncontrolled manner, which may happen if the power domain drops the
domain regulator.

If any of the above pin states are missing in dt, a warning message
about the missing state is displayed.
If certain pin-states are not available, to remove this warning message
pass respective state name with null phandler.

Todo:
- if an idle state is available for pins, add support for it.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Dmitry Torokhov dmitry.torok...@gmail.com
Cc: linux-in...@vger.kernel.org
---
:100644 100644 71d7719... aed43fb... M  drivers/input/keyboard/matrix_keypad.c
 drivers/input/keyboard/matrix_keypad.c |   48 
 1 file changed, 48 insertions(+)

diff --git a/drivers/input/keyboard/matrix_keypad.c 
b/drivers/input/keyboard/matrix_keypad.c
index 71d7719..aed43fb 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -26,6 +26,7 @@
 #include linux/of.h
 #include linux/of_gpio.h
 #include linux/of_platform.h
+#include linux/pinctrl/consumer.h
 
 struct matrix_keypad {
const struct matrix_keypad_platform_data *pdata;
@@ -40,6 +41,10 @@ struct matrix_keypad {
bool scan_pending;
bool stopped;
bool gpio_all_disabled;
+   /* Two optional pin states - default  sleep */
+   struct pinctrl  *pinctrl;
+   struct pinctrl_state*pins_default;
+   struct pinctrl_state*pins_sleep;
 };
 
 /*
@@ -280,6 +285,13 @@ static int matrix_keypad_suspend(struct device *dev)
 
if (device_may_wakeup(pdev-dev))
matrix_keypad_enable_wakeup(keypad);
+   else
+   /* Optionally let pins go into sleep states */
+   if (!IS_ERR(keypad-pins_sleep))
+   if (pinctrl_select_state(keypad-pinctrl,
+keypad-pins_sleep))
+   dev_err(dev,
+   could not set pins to sleep state\n);
 
return 0;
 }
@@ -291,6 +303,12 @@ static int matrix_keypad_resume(struct device *dev)
 
if (device_may_wakeup(pdev-dev))
matrix_keypad_disable_wakeup(keypad);
+   else
+   /* Optionaly enable pins to be muxed in and configured */
+   if (!IS_ERR(keypad-pins_default))
+   if (pinctrl_select_state(keypad-pinctrl,
+keypad-pins_default))
+   dev_err(dev, could not set default pins\n);
 
matrix_keypad_start(keypad-input_dev);
 
@@ -491,6 +509,36 @@ static int matrix_keypad_probe(struct platform_device 
*pdev)
goto err_free_mem;
}
 
+   keypad-pinctrl = devm_pinctrl_get(pdev-dev);
+   if (!IS_ERR(keypad-pinctrl)) {
+   keypad-pins_default = pinctrl_lookup_state(keypad-pinctrl,
+   PINCTRL_STATE_DEFAULT);
+   /* enable pins to be muxed in and configured */
+   if (IS_ERR(keypad-pins_default))
+   dev_dbg(pdev-dev, could not get default pinstate\n);
+   else
+   if (pinctrl_select_state(keypad-pinctrl,
+keypad-pins_default))
+   dev_err(pdev-dev,
+   could not set default pins\n);
+
+   keypad-pins_sleep = pinctrl_lookup_state(keypad-pinctrl,
+   PINCTRL_STATE_SLEEP);
+   if (IS_ERR(keypad-pins_sleep))
+   dev_dbg(pdev-dev, could not get sleep pinstate\n);
+   } else {
+   /*
+   * Since we continue even when pinctrl node is not found,
+   * Invalidate pins as not available. This is to make sure that
+   * IS_ERR(pins_xxx) results in failure when used.
+   */
+   keypad-pins_default = ERR_PTR(-ENODATA);
+   keypad-pins_sleep = ERR_PTR(-ENODATA);
+
+   dev_dbg(pdev-dev,
+   pins are not configured from the driver\n);
+   }
+
keypad-input_dev = input_dev;
keypad-pdata = pdata;
keypad-row_shift = get_count_order(pdata-num_col_gpios);
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 10/11] video: da8xx-fb: adopt pinctrl support

2013-05-31 Thread Hebbar Gururaja
Amend the da8xx-fb controller to optionally take a pin control handle
and set the state of the pins to:

- default on boot, resume
- sleep on suspend()

By optionally putting the pins into sleep state in the suspend callback
we can accomplish two things.
- One is to minimize current leakage from pins and thus save power,
- second, we can prevent the IP from driving pins output in an
uncontrolled manner, which may happen if the power domain drops the
domain regulator.

If any of the above pin states are missing in dt, a warning message
about the missing state is displayed.
If certain pin-states are not available, to remove this warning message
pass respective state name with null phandler.

Todo:
- if an idle state is available for pins, add support for it.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Florian Tobias Schandinat florianschandi...@gmx.de
Cc: linux-fb...@vger.kernel.org
---
:100644 100644 0810939... 10c8036... M  drivers/video/da8xx-fb.c
 drivers/video/da8xx-fb.c |   48 ++
 1 file changed, 48 insertions(+)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index 0810939..10c8036 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -36,6 +36,7 @@
 #include linux/slab.h
 #include linux/delay.h
 #include linux/lcm.h
+#include linux/pinctrl/consumer.h
 #include video/da8xx-fb.h
 #include asm/div64.h
 
@@ -182,6 +183,11 @@ struct da8xx_fb_par {
 #endif
void (*panel_power_ctrl)(int);
u32 pseudo_palette[16];
+
+   /* two pin states - default, sleep */
+   struct pinctrl  *pinctrl;
+   struct pinctrl_state*pins_default;
+   struct pinctrl_state*pins_sleep;
 };
 
 /* Variable Screen Information */
@@ -1306,6 +1312,36 @@ static int fb_probe(struct platform_device *device)
par-lcd_fck_rate = clk_get_rate(fb_clk);
 #endif
par-pxl_clk = lcdc_info-pixclock;
+
+   par-pinctrl = devm_pinctrl_get(device-dev);
+   if (!IS_ERR(par-pinctrl)) {
+   par-pins_default = pinctrl_lookup_state(par-pinctrl,
+PINCTRL_STATE_DEFAULT);
+   if (IS_ERR(par-pins_default))
+   dev_dbg(device-dev, could not get default 
pinstate\n);
+   else
+   if (pinctrl_select_state(par-pinctrl,
+par-pins_default))
+   dev_err(device-dev,
+   could not set default pinstate\n);
+
+   par-pins_sleep = pinctrl_lookup_state(par-pinctrl,
+  PINCTRL_STATE_SLEEP);
+   if (IS_ERR(par-pins_sleep))
+   dev_dbg(device-dev, could not get sleep pinstate\n);
+   } else {
+   /*
+   * Since we continue even when pinctrl node is not found,
+   * Invalidate pins as not available. This is to make sure that
+   * IS_ERR(pins_xxx) results in failure when used.
+   */
+   par-pins_default = ERR_PTR(-ENODATA);
+   par-pins_sleep = ERR_PTR(-ENODATA);
+
+   dev_dbg(device-dev, did not get pins for lcd error: %li\n,
+   PTR_ERR(par-pinctrl));
+   }
+
if (fb_pdata-panel_power_ctrl) {
par-panel_power_ctrl = fb_pdata-panel_power_ctrl;
par-panel_power_ctrl(1);
@@ -1551,6 +1587,12 @@ static int fb_suspend(struct platform_device *dev, 
pm_message_t state)
pm_runtime_put_sync(dev-dev);
console_unlock();
 
+   /* Optionally let pins go into sleep states */
+   if (!IS_ERR(par-pins_sleep))
+   if (pinctrl_select_state(par-pinctrl, par-pins_sleep))
+   dev_err(dev-dev,
+   could not set pins to sleep state\n);
+
return 0;
 }
 static int fb_resume(struct platform_device *dev)
@@ -1560,6 +1602,12 @@ static int fb_resume(struct platform_device *dev)
 
console_lock();
pm_runtime_get_sync(dev-dev);
+
+   /* Optionaly enable pins to be muxed in and configured */
+   if (!IS_ERR(par-pins_default))
+   if (pinctrl_select_state(par-pinctrl, par-pins_default))
+   dev_err(dev-dev, could not set default pins\n);
+
lcd_context_restore();
if (par-blank == FB_BLANK_UNBLANK) {
lcd_enable_raster();
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 06/11] usb: musb: dsps: Adopt pinctrl support

2013-05-31 Thread Hebbar Gururaja
Amend the musb controller to optionally take a pin control handle and
set the state of the pins to:

- default on boot, resume
- sleep on suspend()

By optionally putting the pins into sleep state in the suspend callback
we can accomplish two things.
- One is to minimize current leakage from pins and thus save power,
- second, we can prevent the IP from driving pins output in an
uncontrolled manner, which may happen if the power domain drops the
domain regulator.

If any of the above pin states are missing in dt, a warning message
about the missing state is displayed.
If certain pin-states are not available, to remove this warning message
pass respective state name with null phandler.

Todo:
- if an idle state is available for pins, add support for it.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Felipe Balbi ba...@ti.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: linux-...@vger.kernel.org
---
:100644 100644 e1b661d... a9580fe... M  drivers/usb/musb/musb_dsps.c
 drivers/usb/musb/musb_dsps.c |   46 ++
 1 file changed, 46 insertions(+)

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index e1b661d..a9580fe 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -39,6 +39,7 @@
 #include linux/usb/nop-usb-xceiv.h
 #include linux/platform_data/usb-omap.h
 #include linux/sizes.h
+#include linux/pinctrl/consumer.h
 
 #include linux/of.h
 #include linux/of_device.h
@@ -124,6 +125,11 @@ struct dsps_glue {
struct timer_list timer[2]; /* otg_workaround timer */
unsigned long last_timer[2];/* last timer data for each instance */
u32 __iomem *usb_ctrl[2];
+
+   /* two pin states - default, sleep */
+   struct pinctrl  *pinctrl;
+   struct pinctrl_state*pins_default;
+   struct pinctrl_state*pins_sleep;
 };
 
 #defineDSPS_AM33XX_CONTROL_MODULE_PHYS_0   0x44e10620
@@ -636,6 +642,36 @@ static int dsps_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto err1;
}
+
+   glue-pinctrl = devm_pinctrl_get(pdev-dev);
+   if (!IS_ERR(glue-pinctrl)) {
+   glue-pins_default = pinctrl_lookup_state(glue-pinctrl,
+PINCTRL_STATE_DEFAULT);
+   if (IS_ERR(glue-pins_default))
+   dev_dbg(pdev-dev, could not get default pinstate\n);
+   else
+   if (pinctrl_select_state(glue-pinctrl,
+glue-pins_default))
+   dev_err(pdev-dev,
+   could not set default pinstate\n);
+
+   glue-pins_sleep = pinctrl_lookup_state(glue-pinctrl,
+  PINCTRL_STATE_SLEEP);
+   if (IS_ERR(glue-pins_sleep))
+   dev_dbg(pdev-dev, could not get sleep pinstate\n);
+   } else {
+   /*
+   * Since we continue even when pinctrl node is not found,
+   * Invalidate pins as not available. This is to make sure that
+   * IS_ERR(pins_xxx) results in failure when used.
+   */
+   glue-pins_default = ERR_PTR(-ENODATA);
+   glue-pins_sleep = ERR_PTR(-ENODATA);
+
+   dev_dbg(pdev-dev, did not get pins for i2c error: %li\n,
+   PTR_ERR(glue-pinctrl));
+   }
+
platform_set_drvdata(pdev, glue);
 
/* enable the usbss clocks */
@@ -700,6 +736,11 @@ static int dsps_suspend(struct device *dev)
for (i = 0; i  wrp-instances; i++)
musb_dsps_phy_control(glue, i, 0);
 
+   /* Optionally let pins go into sleep states */
+   if (!IS_ERR(glue-pins_sleep))
+   if (pinctrl_select_state(glue-pinctrl, glue-pins_sleep))
+   dev_err(dev, could not set pins to sleep state\n);
+
return 0;
 }
 
@@ -710,6 +751,11 @@ static int dsps_resume(struct device *dev)
const struct dsps_musb_wrapper *wrp = glue-wrp;
int i;
 
+   /* Optionaly enable pins to be muxed in and configured */
+   if (!IS_ERR(glue-pins_default))
+   if (pinctrl_select_state(glue-pinctrl, glue-pins_default))
+   dev_err(dev, could not set default pins\n);
+
for (i = 0; i  wrp-instances; i++)
musb_dsps_phy_control(glue, i, 1);
 
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 08/11] pwm: pwm-tiecap: enhance pinctrl support

2013-05-31 Thread Hebbar Gururaja
Amend TI ecap controller to optionally take a pin control handle and
set the state of the pins to:

- default on boot, resume
- sleep on suspend()

By optionally putting the pins into sleep state in the suspend callback
we can accomplish two things.
- One is to minimize current leakage from pins and thus save power,
- second, we can prevent the IP from driving pins output in an
uncontrolled manner, which may happen if the power domain drops the
domain regulator.

If any of the above pin states are missing in dt, a warning message
about the missing state is displayed.
If certain pin-states are not available, to remove this warning message
pass respective state name with null phandler.

Todo:
- if an idle state is available for pins, add support for it.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Thierry Reding thierry.red...@avionic-design.de
Cc: Philip, Avinash avinashphi...@ti.com
---
:100644 100644 72ca42d... d02769d... M  drivers/pwm/pwm-tiecap.c
 drivers/pwm/pwm-tiecap.c |   48 +-
 1 file changed, 43 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-tiecap.c b/drivers/pwm/pwm-tiecap.c
index 72ca42d..d02769d 100644
--- a/drivers/pwm/pwm-tiecap.c
+++ b/drivers/pwm/pwm-tiecap.c
@@ -52,6 +52,11 @@ struct ecap_pwm_chip {
unsigned intclk_rate;
void __iomem*mmio_base;
struct ecap_context ctx;
+
+   /* two pin states - default, sleep */
+   struct pinctrl  *pinctrl;
+   struct pinctrl_state*pins_default;
+   struct pinctrl_state*pins_sleep;
 };
 
 static inline struct ecap_pwm_chip *to_ecap_pwm_chip(struct pwm_chip *chip)
@@ -208,11 +213,6 @@ static int ecap_pwm_probe(struct platform_device *pdev)
struct clk *clk;
struct ecap_pwm_chip *pc;
u16 status;
-   struct pinctrl *pinctrl;
-
-   pinctrl = devm_pinctrl_get_select_default(pdev-dev);
-   if (IS_ERR(pinctrl))
-   dev_warn(pdev-dev, unable to select pin group\n);
 
pc = devm_kzalloc(pdev-dev, sizeof(*pc), GFP_KERNEL);
if (!pc) {
@@ -220,6 +220,34 @@ static int ecap_pwm_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
+   pc-pinctrl = devm_pinctrl_get(pdev-dev);
+   if (!IS_ERR(pc-pinctrl)) {
+   pc-pins_default = pinctrl_lookup_state(pc-pinctrl,
+PINCTRL_STATE_DEFAULT);
+   if (IS_ERR(pc-pins_default))
+   dev_dbg(pdev-dev, could not get default pinstate\n);
+   else
+   if (pinctrl_select_state(pc-pinctrl, pc-pins_default))
+   dev_err(pdev-dev,
+   could not set default pinstate\n);
+
+   pc-pins_sleep = pinctrl_lookup_state(pc-pinctrl,
+  PINCTRL_STATE_SLEEP);
+   if (IS_ERR(pc-pins_sleep))
+   dev_dbg(pdev-dev, could not get sleep pinstate\n);
+   } else {
+   /*
+   * Since we continue even when pinctrl node is not found,
+   * Invalidate pins as not available. This is to make sure that
+   * IS_ERR(pins_xxx) results in failure when used.
+   */
+   pc-pins_default = ERR_PTR(-ENODATA);
+   pc-pins_sleep = ERR_PTR(-ENODATA);
+
+   dev_dbg(pdev-dev, did not get pins for i2c error: %li\n,
+   PTR_ERR(pc-pinctrl));
+   }
+
clk = devm_clk_get(pdev-dev, fck);
if (IS_ERR(clk)) {
dev_err(pdev-dev, failed to get clock\n);
@@ -318,6 +346,11 @@ static int ecap_pwm_suspend(struct device *dev)
if (test_bit(PWMF_ENABLED, pwm-flags))
pm_runtime_put_sync(dev);
 
+   /* Optionally let pins go into sleep states */
+   if (!IS_ERR(pc-pins_sleep))
+   if (pinctrl_select_state(pc-pinctrl, pc-pins_sleep))
+   dev_err(dev, could not set pins to sleep state\n);
+
return 0;
 }
 
@@ -326,6 +359,11 @@ static int ecap_pwm_resume(struct device *dev)
struct ecap_pwm_chip *pc = dev_get_drvdata(dev);
struct pwm_device *pwm = pc-chip.pwms;
 
+   /* Optionaly enable pins to be muxed in and configured */
+   if (!IS_ERR(pc-pins_default))
+   if (pinctrl_select_state(pc-pinctrl, pc-pins_default))
+   dev_err(dev, could not set default pins\n);
+
/* Enable explicitly if PWM was running */
if (test_bit(PWMF_ENABLED, pwm-flags))
pm_runtime_get_sync(dev);
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 09/11] mmc: omap_hsmmc: enhance pinctrl support

2013-05-31 Thread Hebbar Gururaja
Amend the hsmmc controller to optionally take a pin control handle and
set the state of the pins to:

- default on boot, resume and before performing a mmc transfer
- idle after initial default, after resume default, and after each
mmc/sd card access
- sleep on suspend()

By optionally putting the pins into sleep state in the suspend callback
we can accomplish two things.
- One is to minimize current leakage from pins and thus save power,
- second, we can prevent the IP from driving pins output in an
uncontrolled manner, which may happen if the power domain drops the
domain regulator.

If any of the above pin states are missing in dt, a warning message
about the missing state is displayed.
If certain pin-states are not available, to remove this warning message
pass respective state name with null phandler.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Balaji T K balaj...@ti.com
Cc: Chris Ball c...@laptop.org
Cc: linux-...@vger.kernel.org
Cc: linux-o...@vger.kernel.org
---
:100644 100644 6e44025... a2d69aa... M  drivers/mmc/host/omap_hsmmc.c
 drivers/mmc/host/omap_hsmmc.c |   79 ++---
 1 file changed, 74 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 6e44025..a2d69aa 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -183,6 +183,12 @@ struct omap_hsmmc_host {
struct omap_hsmmc_next  next_data;
 
struct  omap_mmc_platform_data  *pdata;
+
+   /* Three pin states - default, idle  sleep */
+   struct pinctrl  *pinctrl;
+   struct pinctrl_state*pins_default;
+   struct pinctrl_state*pins_idle;
+   struct pinctrl_state*pins_sleep;
 };
 
 static int omap_hsmmc_card_detect(struct device *dev, int slot)
@@ -1775,7 +1781,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
const struct of_device_id *match;
dma_cap_mask_t mask;
unsigned tx_req, rx_req;
-   struct pinctrl *pinctrl;
 
match = of_match_device(of_match_ptr(omap_mmc_of_match), pdev-dev);
if (match) {
@@ -1982,10 +1987,46 @@ static int omap_hsmmc_probe(struct platform_device 
*pdev)
 
omap_hsmmc_disable_irq(host);
 
-   pinctrl = devm_pinctrl_get_select_default(pdev-dev);
-   if (IS_ERR(pinctrl))
-   dev_warn(pdev-dev,
-   pins are not configured from the driver\n);
+   host-pinctrl = devm_pinctrl_get(pdev-dev);
+   if (!IS_ERR(host-pinctrl)) {
+   host-pins_default = pinctrl_lookup_state(host-pinctrl,
+   PINCTRL_STATE_DEFAULT);
+   if (IS_ERR(host-pins_default))
+   dev_dbg(pdev-dev, could not get default pinstate\n);
+   else
+   if (pinctrl_select_state(host-pinctrl,
+host-pins_default))
+   dev_err(pdev-dev,
+   could not set default pinstate\n);
+
+   host-pins_idle = pinctrl_lookup_state(host-pinctrl,
+   PINCTRL_STATE_IDLE);
+   if (IS_ERR(host-pins_idle))
+   dev_dbg(pdev-dev, could not get idle pinstate\n);
+   else
+   /* If possible, let's idle until the first transfer */
+   if (pinctrl_select_state(host-pinctrl,
+host-pins_idle))
+   dev_err(pdev-dev,
+   could not set idle pinstate\n);
+
+   host-pins_sleep = pinctrl_lookup_state(host-pinctrl,
+   PINCTRL_STATE_SLEEP);
+   if (IS_ERR(host-pins_sleep))
+   dev_dbg(pdev-dev, could not get sleep pinstate\n);
+   } else {
+   /*
+   * Since we continue even when pinctrl node is not found,
+   * Invalidate pins as not available. This is to make sure that
+   * IS_ERR(pins_xxx) results in failure when used.
+   */
+   host-pins_default = ERR_PTR(-ENODATA);
+   host-pins_idle = ERR_PTR(-ENODATA);
+   host-pins_sleep = ERR_PTR(-ENODATA);
+
+   dev_dbg(pdev-dev, did not get pins for mmc error: %li\n,
+   PTR_ERR(host-pinctrl));
+   }
 
omap_hsmmc_protect_card(host);
 
@@ -2135,6 +2176,12 @@ static int omap_hsmmc_suspend(struct device *dev)
clk_disable_unprepare(host-dbclk);
 err:
pm_runtime_put_sync(host-dev);
+
+   /* Optionally let pins go into sleep states */
+   if (!IS_ERR(host-pins_sleep))
+   if (pinctrl_select_state(host-pinctrl, host-pins_sleep))
+   dev_err(dev

[PATCH 07/11] pwm: pwm-tiehrpwm: enhance pinctrl support

2013-05-31 Thread Hebbar Gururaja
Amend the ti ehrpwm controller to optionally take a pin control handle
and set the state of the pins to:

- default on boot, resume
- sleep on suspend()

By optionally putting the pins into sleep state in the suspend callback
we can accomplish two things.
- One is to minimize current leakage from pins and thus save power,
- second, we can prevent the IP from driving pins output in an
uncontrolled manner, which may happen if the power domain drops the
domain regulator.

If any of the above pin states are missing in dt, a warning message
about the missing state is displayed.
If certain pin-states are not available, to remove this warning message
pass respective state name with null phandler.

Todo:
- if an idle state is available for pins, add support for it.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Thierry Reding thierry.red...@avionic-design.de
Cc: Philip, Avinash avinashphi...@ti.com
---
:100644 100644 48a485c... ed55460ae. M  drivers/pwm/pwm-tiehrpwm.c
 drivers/pwm/pwm-tiehrpwm.c |   49 +++-
 1 file changed, 44 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 48a485c..ed55460ae 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -132,6 +132,11 @@ struct ehrpwm_pwm_chip {
enum pwm_polarity polarity[NUM_PWM_CHANNEL];
struct  clk *tbclk;
struct ehrpwm_context ctx;
+
+   /* two pin states - default, sleep */
+   struct pinctrl  *pinctrl;
+   struct pinctrl_state*pins_default;
+   struct pinctrl_state*pins_sleep;
 };
 
 static inline struct ehrpwm_pwm_chip *to_ehrpwm_pwm_chip(struct pwm_chip *chip)
@@ -439,11 +444,6 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
struct clk *clk;
struct ehrpwm_pwm_chip *pc;
u16 status;
-   struct pinctrl *pinctrl;
-
-   pinctrl = devm_pinctrl_get_select_default(pdev-dev);
-   if (IS_ERR(pinctrl))
-   dev_warn(pdev-dev, unable to select pin group\n);
 
pc = devm_kzalloc(pdev-dev, sizeof(*pc), GFP_KERNEL);
if (!pc) {
@@ -451,6 +451,34 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
+   pc-pinctrl = devm_pinctrl_get(pdev-dev);
+   if (!IS_ERR(pc-pinctrl)) {
+   pc-pins_default = pinctrl_lookup_state(pc-pinctrl,
+PINCTRL_STATE_DEFAULT);
+   if (IS_ERR(pc-pins_default))
+   dev_dbg(pdev-dev, could not get default pinstate\n);
+   else
+   if (pinctrl_select_state(pc-pinctrl, pc-pins_default))
+   dev_err(pdev-dev,
+   could not set default pinstate\n);
+
+   pc-pins_sleep = pinctrl_lookup_state(pc-pinctrl,
+  PINCTRL_STATE_SLEEP);
+   if (IS_ERR(pc-pins_sleep))
+   dev_dbg(pdev-dev, could not get sleep pinstate\n);
+   } else {
+   /*
+   * Since we continue even when pinctrl node is not found,
+   * Invalidate pins as not available. This is to make sure that
+   * IS_ERR(pins_xxx) results in failure when used.
+   */
+   pc-pins_default = ERR_PTR(-ENODATA);
+   pc-pins_sleep = ERR_PTR(-ENODATA);
+
+   dev_dbg(pdev-dev, did not get pins for i2c error: %li\n,
+   PTR_ERR(pc-pinctrl));
+   }
+
clk = devm_clk_get(pdev-dev, fck);
if (IS_ERR(clk)) {
dev_err(pdev-dev, failed to get clock\n);
@@ -570,6 +598,12 @@ static int ehrpwm_pwm_suspend(struct device *dev)
/* Disable explicitly if PWM is running */
pm_runtime_put_sync(dev);
}
+
+   /* Optionally let pins go into sleep states */
+   if (!IS_ERR(pc-pins_sleep))
+   if (pinctrl_select_state(pc-pinctrl, pc-pins_sleep))
+   dev_err(dev, could not set pins to sleep state\n);
+
return 0;
 }
 
@@ -578,6 +612,11 @@ static int ehrpwm_pwm_resume(struct device *dev)
struct ehrpwm_pwm_chip *pc = dev_get_drvdata(dev);
int i;
 
+   /* Optionaly enable pins to be muxed in and configured */
+   if (!IS_ERR(pc-pins_default))
+   if (pinctrl_select_state(pc-pinctrl, pc-pins_default))
+   dev_err(dev, could not set default pins\n);
+
for (i = 0; i  pc-chip.npwm; i++) {
struct pwm_device *pwm = pc-chip.pwms[i];
 
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 11/11] i2c: omap: enhance pinctrl support

2013-05-31 Thread Hebbar Gururaja
Amend the I2C omap pin controller to optionally take a pin control
handle and set the state of the pins to:

- default on boot, resume and before performing an i2c transfer
- idle after initial default, after resume default, and after each
i2c xfer
- sleep on suspend()

By optionally putting the pins into sleep state in the suspend callback
we can accomplish two things.
- One is to minimize current leakage from pins and thus save power,
- second, we can prevent the IP from driving pins output in an
uncontrolled manner, which may happen if the power domain drops the
domain regulator.

Note:
A .suspend  .resume callback is added which simply puts the pins to sleep
state upon suspend  are moved to default  idle state upon resume.

If any of the above pin states are missing in dt, a warning message
about the missing state is displayed.
If certain pin-states are not available, to remove this warning message
pass respective state name with null phandler.

(Changes based on i2c-nomadik.c)

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Wolfram Sang w...@the-dreams.de
Cc: linux-o...@vger.kernel.org
Cc: linux-...@vger.kernel.org
---
:100644 100644 e02f9e3... 588ba28... M  drivers/i2c/busses/i2c-omap.c
 drivers/i2c/busses/i2c-omap.c |  112 ++---
 1 file changed, 105 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index e02f9e3..588ba28 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -214,7 +214,11 @@ struct omap_i2c_dev {
u16 westate;
u16 errata;
 
-   struct pinctrl  *pins;
+   /* Three pin states - default, idle  sleep */
+   struct pinctrl  *pinctrl;
+   struct pinctrl_state*pins_default;
+   struct pinctrl_state*pins_idle;
+   struct pinctrl_state*pins_sleep;
 };
 
 static const u8 reg_map_ip_v1[] = {
@@ -641,6 +645,11 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
if (IS_ERR_VALUE(r))
goto out;
 
+   /* Optionaly enable pins to be muxed in and configured */
+   if (!IS_ERR(dev-pins_default))
+   if (pinctrl_select_state(dev-pinctrl, dev-pins_default))
+   dev_err(dev-dev, could not set default pins\n);
+
r = omap_i2c_wait_for_bb(dev);
if (r  0)
goto out;
@@ -664,7 +673,13 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
 
 out:
pm_runtime_mark_last_busy(dev-dev);
+
pm_runtime_put_autosuspend(dev-dev);
+   /* Optionally let pins go into idle state */
+   if (!IS_ERR(dev-pins_idle))
+   if (pinctrl_select_state(dev-pinctrl, dev-pins_idle))
+   dev_err(dev-dev, could not set pins to idle state\n);
+
return r;
 }
 
@@ -1123,14 +1138,47 @@ omap_i2c_probe(struct platform_device *pdev)
dev-set_mpu_wkup_lat = pdata-set_mpu_wkup_lat;
}
 
-   dev-pins = devm_pinctrl_get_select_default(pdev-dev);
-   if (IS_ERR(dev-pins)) {
-   if (PTR_ERR(dev-pins) == -EPROBE_DEFER)
+   dev-pinctrl = devm_pinctrl_get(pdev-dev);
+   if (!IS_ERR(dev-pinctrl)) {
+   dev-pins_default = pinctrl_lookup_state(dev-pinctrl,
+PINCTRL_STATE_DEFAULT);
+   if (IS_ERR(dev-pins_default))
+   dev_dbg(pdev-dev, could not get default pinstate\n);
+   else
+   if (pinctrl_select_state(dev-pinctrl,
+dev-pins_default))
+   dev_err(pdev-dev,
+   could not set default pinstate\n);
+
+   dev-pins_idle = pinctrl_lookup_state(dev-pinctrl,
+ PINCTRL_STATE_IDLE);
+   if (IS_ERR(dev-pins_idle))
+   dev_dbg(pdev-dev, could not get idle pinstate\n);
+   else
+   /* If possible, let's idle until the first transfer */
+   if (pinctrl_select_state(dev-pinctrl, dev-pins_idle))
+   dev_err(pdev-dev,
+   could not set idle pinstate\n);
+
+   dev-pins_sleep = pinctrl_lookup_state(dev-pinctrl,
+  PINCTRL_STATE_SLEEP);
+   if (IS_ERR(dev-pins_sleep))
+   dev_dbg(pdev-dev, could not get sleep pinstate\n);
+   } else {
+   if (PTR_ERR(dev-pinctrl) == -EPROBE_DEFER)
return -EPROBE_DEFER;
 
-   dev_warn(pdev-dev, did not get pins for i2c error: %li\n,
-PTR_ERR(dev-pins));
-   dev

RE: [net-next resend PATCH 1/6] net: cpsw: enhance pinctrl support

2013-05-23 Thread Hebbar, Gururaja
On Thu, May 23, 2013 at 12:27:41, David Miller wrote:
 From: Mugunthan V N mugunthan...@ti.com
 Date: Tue, 21 May 2013 15:24:58 +0530
 
  +   priv-pins_default = pinctrl_lookup_state(priv-pinctrl,
  +   PINCTRL_STATE_DEFAULT);
 
 This is not indented correctly.
 
 Argument on the second, and subsequent, lines of a function call
 must start at the first column after the openning parenthesis of
 the function call itself.

Well, if I am correct, doing so will make the line cross 80 character limit.
If you could (please I ask), can you let me know how it can be handled in 
above situation. I will make the changes/corrections and re-send it.

Thanks a lot in advance.

 
 Please audit for this problem in your entire patch series, fix
 it up, and resubmit the full set of patches.
 
 Thanks.
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH v4 0/3] ASoC davinci/tlv320aic3x updates, fixes DT support

2013-02-26 Thread Hebbar, Gururaja
Mark,

On Thu, Jan 31, 2013 at 18:23:03, Hebbar, Gururaja wrote:
 1. Convert tlv320aic3x mic bias to a supply widget and related machine driver
 2. Add DT support for Davinci machine platform
 3. Remove __dev* attributes
 
 This patch-set is tested on Davinci platform (DA850 EVM). This series applies 
 on
 top of tag next-20130128 git tree
 https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
 
 These patches cannot be tested directly on mainline kernel (DT based).
 This is because dma is not yet completely ported to Davinci ASoC. I had to add
 few hacks to get Audio working on Davinci DA850 platform.
 
 For reference, I have placed the entire working tree @
 Tree :  https://github.com/ghebbar/linux.git
 Branch : dev_next-20130128_davinci_asoc_dt_v3

Only one patch out of the 3 is accepted.  I haven't received any review comments
from anyone for the other 2.

Kindly let me know if any further changes are required in the remaining changes 
or if I have missed any of comments.

If not, Could you please accept the remaining patch?

Remaining patches
ASoC: davinci: remove __dev* attributes [1]
ASoC: davinci: machine: Add device tree binding [2]


[1]
http://lkml.org/lkml/2013/1/31/243


[2]
http://lkml.org/lkml/2013/1/31/244


Regards, 
Gururaja

 
 Changes in v4
- updated pending machine driver to change in micbias - supply widget
- merge codec  machine driver change into a single commit
 
 Changes in v3
   - drop mcasp pinctrl handler patch from series as it is now handled
 centrally.
   - Convert tlv320aic3x mic bias to a supply widget and related machine
 driver
   - remove __dev* attributes
 
 Changes in v2
- Remove reference to Linux  software details from DT binding
 
 Hebbar Gururaja (2):
   ASoC: tlv320aic3x: Convert mic bias to a supply widget
   ASoC: davinci: remove __dev* attributes
 
 Hebbar, Gururaja (1):
   ASoC: davinci: machine: Add device tree binding
 
  .../bindings/sound/davinci-evm-audio.txt   |   53 ++
  .../devicetree/bindings/sound/tlv320aic3x.txt  |6 +
  include/sound/tlv320aic3x.h|   10 ++
  sound/soc/codecs/tlv320aic3x.c |   83 -
  sound/soc/codecs/tlv320aic3x.h |4 +
  sound/soc/davinci/davinci-evm.c|  185 
 +---
  sound/soc/omap/n810.c  |4 +-
  sound/soc/omap/rx51.c  |8 +-
  8 files changed, 318 insertions(+), 35 deletions(-)
  create mode 100644 
 Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
 
 -- 
 1.7.9.5
 
 
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH v3 2/4] ASoC: davinci: update machine driver dapm routes

2013-01-31 Thread Hebbar Gururaja
Now since micbias is converted to supply widget, updated machine driver
as well.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
---
Changes in v3
 - New patch

:100644 100644 d55e647... 484b22c... M  sound/soc/davinci/davinci-evm.c
 sound/soc/davinci/davinci-evm.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index d55e647..484b22c 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -116,9 +116,9 @@ static const struct snd_soc_dapm_route audio_map[] = {
{Line Out, NULL, RLOUT},
 
/* Mic connected to (MIC3L | MIC3R) */
-   {MIC3L, NULL, Mic Bias 2V},
-   {MIC3R, NULL, Mic Bias 2V},
-   {Mic Bias 2V, NULL, Mic Jack},
+   {MIC3L, NULL, Mic Bias},
+   {MIC3R, NULL, Mic Bias},
+   {Mic Bias, NULL, Mic Jack},
 
/* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
{LINE1L, NULL, Line In},
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH v3 0/4] ASoC davinci/tlv320aic3x updates, fixes DT support

2013-01-31 Thread Hebbar Gururaja
1. Convert tlv320aic3x mic bias to a supply widget and related machine driver
2. Add DT support for Davinci machine platform
3. remove __dev* attributes

This patch-set is tested on Davinci platform (DA850 EVM). This series applies on
top of tag next-20130128 git tree
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

These patches cannot be tested directly on mainline kernel (DT based).
This is because dma is not yet completely ported to Davinci ASoC. I had to add
few hacks to get Audio working on Davinci DA850 platform.

For reference, I have placed the entire working tree @ 
Tree :  https://github.com/ghebbar/linux.git
Branch : dev_next-20130128_davinci_asoc_dt_v3

changes in v3
- drop mcasp pinctrl handler patch from seried as it is now handled
  centrally.
- Convert tlv320aic3x mic bias to a supply widget and related machine
  driver
- remove __dev* attributes

Changes in V2
 - Remove reference to Linux  software details from DT binding

Hebbar Gururaja (3):
  ASoC: tlv320aic3x: Convert mic bias to a supply widget
  ASoC: davinci: update machine driver dapm routes
  ASoC: davinci: remove __dev* attributes

Hebbar, Gururaja (1):
  ASoC: davinci: machine: Add device tree binding

 .../bindings/sound/davinci-evm-audio.txt   |   53 ++
 .../devicetree/bindings/sound/tlv320aic3x.txt  |6 +
 include/sound/tlv320aic3x.h|   10 ++
 sound/soc/codecs/tlv320aic3x.c |   83 -
 sound/soc/codecs/tlv320aic3x.h |4 +
 sound/soc/davinci/davinci-evm.c|  185 +---
 6 files changed, 312 insertions(+), 29 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/sound/davinci-evm-audio.txt

-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH v3 4/4] ASoC: davinci: remove __dev* attributes

2013-01-31 Thread Hebbar Gururaja
CONFIG_HOTPLUG is going away as an option.  As result the __dev*
markings will be going away.

Remove use of __devexit_p and __devexit.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
---
Changes in v3
 - New patch

:100644 100644 e6009a4... 37b8e78... M  sound/soc/davinci/davinci-evm.c
 sound/soc/davinci/davinci-evm.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index e6009a4..37b8e78 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -390,7 +390,7 @@ static int davinci_evm_probe(struct platform_device *pdev)
return ret;
 }
 
-static int __devexit davinci_evm_remove(struct platform_device *pdev)
+static int davinci_evm_remove(struct platform_device *pdev)
 {
struct snd_soc_card *card = platform_get_drvdata(pdev);
 
@@ -401,7 +401,7 @@ static int __devexit davinci_evm_remove(struct 
platform_device *pdev)
 
 static struct platform_driver davinci_evm_driver = {
.probe  = davinci_evm_probe,
-   .remove = __devexit_p(davinci_evm_remove),
+   .remove = davinci_evm_remove,
.driver = {
.name   = davinci_evm,
.owner  = THIS_MODULE,
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH v3 1/4] ASoC: tlv320aic3x: Convert mic bias to a supply widget

2013-01-31 Thread Hebbar Gururaja
Convert MicBias widgets to supply widget.

On tlv320aic3x, Mic bias power on/off shares the same register bits
with output mic bias voltage.  So, when power on mic bias, we need
reclaim it to voltage value.

Provide a new platform data so that the micbias voltage can be sent
according to board requirement. Now since tlc320aic3x codec driver
is DT aware, update dt files and functions to handle this new
micbias-vg  platform data.

Because of sharing of bits, when enabling the micbias, voltage also
needs to be updated. So use SND_SOC_DAPM_POST_PMU  SND_SOC_DAPM_PRE_PMD
macro to create an event to handle this.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
---
Changes in v3
 - New patch

:100644 100644 e7b98f4... f47c3f5... M  
Documentation/devicetree/bindings/sound/tlv320aic3x.txt
:100644 100644 ffd9bc7... 9407fd0... M  include/sound/tlv320aic3x.h
:100644 100644 4989143... 65d09d6... M  sound/soc/codecs/tlv320aic3x.c
:100644 100644 6db3c41... e521ac3... M  sound/soc/codecs/tlv320aic3x.h
 .../devicetree/bindings/sound/tlv320aic3x.txt  |6 ++
 include/sound/tlv320aic3x.h|   10 +++
 sound/soc/codecs/tlv320aic3x.c |   83 ++--
 sound/soc/codecs/tlv320aic3x.h |4 +
 4 files changed, 97 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/tlv320aic3x.txt 
b/Documentation/devicetree/bindings/sound/tlv320aic3x.txt
index e7b98f4..f47c3f5 100644
--- a/Documentation/devicetree/bindings/sound/tlv320aic3x.txt
+++ b/Documentation/devicetree/bindings/sound/tlv320aic3x.txt
@@ -11,6 +11,12 @@ Optional properties:
 
 - gpio-reset - gpio pin number used for codec reset
 - ai3x-gpio-func - array of 2 int - AIC3X_GPIO1  AIC3X_GPIO2 Functionality
+- ai3x-micbias-vg - MicBias Voltage required.
+   1 - MICBIAS output is powered to 2.0V,
+   2 - MICBIAS output is powered to 2.5V,
+   3 - MICBIAS output is connected to AVDD,
+   If this node is not mentioned or if the value is incorrect, then MicBias
+   is powered down.
 
 Example:
 
diff --git a/include/sound/tlv320aic3x.h b/include/sound/tlv320aic3x.h
index ffd9bc7..9407fd0 100644
--- a/include/sound/tlv320aic3x.h
+++ b/include/sound/tlv320aic3x.h
@@ -46,6 +46,13 @@ enum {
AIC3X_GPIO2_FUNC_BUTTON_PRESS_IRQ   = 15
 };
 
+enum aic3x_micbias_voltage {
+   AIC3X_MICBIAS_OFF = 0,
+   AIC3X_MICBIAS_2_0V = 1,
+   AIC3X_MICBIAS_2_5V = 2,
+   AIC3X_MICBIAS_AVDDV = 3,
+};
+
 struct aic3x_setup_data {
unsigned int gpio_func[2];
 };
@@ -53,6 +60,9 @@ struct aic3x_setup_data {
 struct aic3x_pdata {
int gpio_reset; /*  0 if not used */
struct aic3x_setup_data *setup;
+
+   /* Selects the micbias voltage */
+   enum aic3x_micbias_voltage micbias_vg;
 };
 
 #endif
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 4989143..65d09d6 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -85,6 +85,9 @@ struct aic3x_priv {
 #define AIC3X_MODEL_33 1
 #define AIC3X_MODEL_3007 2
u16 model;
+
+   /* Selects the micbias voltage */
+   enum aic3x_micbias_voltage micbias_vg;
 };
 
 /*
@@ -195,6 +198,37 @@ static int snd_soc_dapm_put_volsw_aic3x(struct 
snd_kcontrol *kcontrol,
return ret;
 }
 
+/*
+ * mic bias power on/off share the same register bits with
+ * output voltage of mic bias. when power on mic bias, we
+ * need reclaim it to voltage value.
+ * 0x0 = Powered off
+ * 0x1 = MICBIAS output is powered to 2.0V,
+ * 0x2 = MICBIAS output is powered to 2.5V
+ * 0x3 = MICBIAS output is connected to AVDD
+ */
+static int mic_bias_event(struct snd_soc_dapm_widget *w,
+   struct snd_kcontrol *kcontrol, int event)
+{
+   struct snd_soc_codec *codec = w-codec;
+   struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
+
+   switch (event) {
+   case SND_SOC_DAPM_POST_PMU:
+   /* change mic bias voltage to user defined */
+   snd_soc_update_bits(codec, MICBIAS_CTRL,
+   MICBIAS_LEVEL_MASK,
+   aic3x-micbias_vg  MICBIAS_LEVEL_SHIFT);
+   break;
+
+   case SND_SOC_DAPM_PRE_PMD:
+   snd_soc_update_bits(codec, MICBIAS_CTRL,
+   MICBIAS_LEVEL_MASK, 0);
+   break;
+   }
+   return 0;
+}
+
 static const char *aic3x_left_dac_mux[] = { DAC_L1, DAC_L3, DAC_L2 };
 static const char *aic3x_right_dac_mux[] = { DAC_R1, DAC_R3, DAC_R2 };
 static const char *aic3x_left_hpcom_mux[] =
@@ -596,12 +630,9 @@ static const struct snd_soc_dapm_widget 
aic3x_dapm_widgets[] = {
 AIC3X_ASD_INTF_CTRLA, 0, 3, 3, 0),
 
/* Mic Bias */
-   SND_SOC_DAPM_REG(snd_soc_dapm_micbias, Mic Bias 2V,
-MICBIAS_CTRL, 6, 3, 1, 0),
-   SND_SOC_DAPM_REG(snd_soc_dapm_micbias, Mic Bias 2.5V

[PATCH v3 3/4] ASoC: davinci: machine: Add device tree binding

2013-01-31 Thread Hebbar Gururaja
From: Hebbar, Gururaja gururaja.heb...@ti.com

Device tree support for Davinci Machine driver

When the board boots with device tree, the driver will receive card,
codec, dai interface details (like the card name, DAPM routing map,
phandle for the audio components described in the dts file, codec mclk
speed).
The card will be set up based on this information.
Since the routing is provided via DT we can mark the card fully routed
so core can take care of disconnecting the unused pins.

Signed-off-by: Hebbar, Gururaja gururaja.heb...@ti.com
---
Changes in v3
 - New patch

Changes in v2
 - Remove reference to Linux  software details from DT binding

:00 100644 000... 92ad4c7... A  
Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
:100644 100644 484b22c... e6009a4... M  sound/soc/davinci/davinci-evm.c
 .../bindings/sound/davinci-evm-audio.txt   |   53 ++
 sound/soc/davinci/davinci-evm.c|  179 +---
 2 files changed, 212 insertions(+), 20 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt 
b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
new file mode 100644
index 000..92ad4c7
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
@@ -0,0 +1,53 @@
+* Texas Instruments SoC audio setups with TLV320AIC3X Codec
+
+Required properties:
+- compatible :
+   ti,dm365-voice-codec-audio: for DM365 platforms with Voice Codec
+   ti,da830-evm-audio: for DM365/DA8xx/OMAPL1x/AM33xx
+
+- ti,model : The user-visible name of this sound complex.
+- ti,audio-codec : The phandle of the TLV320AIC3x audio codec
+- ti,mcasp-controller : The phandle of the McASP controller
+- ti,codec-clock-rate : The Codec Clock rate (in Hz) applied to the Codec
+- ti,audio-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. Valid names for sources and
+  sinks are the codec's pins, and the jacks on the board:
+
+  Codec pins:
+
+  * MIC3L
+  * MIC3R
+  * LINE1L
+  * LINE2L
+  * LINE1R
+  * LINE2R
+
+  Board connectors:
+
+  * Headphone Jack
+  * Line Out
+  * Mic Jack
+
+
+Example:
+
+sound {
+   compatible = ti,da830-evm-audio;
+   ti,model = DA830 EVM;
+   ti,audio-codec = tlv320aic3x;
+   ti,mcasp-controller = mcasp1;
+   ti,codec-clock-rate = 1200;
+   ti,audio-routing =
+   Headphone Jack,   HPLOUT,
+   Headphone Jack,   HPROUT,
+   Line Out, LLOUT,
+   Line Out, RLOUT,
+   MIC3L,Mic Bias,
+   MIC3R,Mic Bias,
+   Mic Bias, Mic Jack,
+   LINE1L,   Line In,
+   LINE2L,   Line In,
+   LINE1R,   Line In,
+   LINE2R,   Line In;
+};
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 484b22c..e6009a4 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -15,6 +15,7 @@
 #include linux/interrupt.h
 #include linux/platform_device.h
 #include linux/i2c.h
+#include linux/of_platform.h
 #include sound/core.h
 #include sound/pcm.h
 #include sound/soc.h
@@ -34,27 +35,38 @@ static int evm_hw_params(struct snd_pcm_substream 
*substream,
struct snd_soc_pcm_runtime *rtd = substream-private_data;
struct snd_soc_dai *codec_dai = rtd-codec_dai;
struct snd_soc_dai *cpu_dai = rtd-cpu_dai;
+   struct snd_soc_codec *codec = rtd-codec;
+   struct snd_soc_card *soc_card = codec-card;
+   struct device_node *np = soc_card-dev-of_node;
int ret = 0;
unsigned sysclk;
 
-   /* ASP1 on DM355 EVM is clocked by an external oscillator */
-   if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm() ||
-   machine_is_davinci_dm365_evm())
-   sysclk = 2700;
-
-   /* ASP0 in DM6446 EVM is clocked by U55, as configured by
-* board-dm644x-evm.c using GPIOs from U18.  There are six
-* options; here we know we use a 48 KHz sample rate.
-*/
-   else if (machine_is_davinci_evm())
-   sysclk = 12288000;
-
-   else if (machine_is_davinci_da830_evm() ||
-   machine_is_davinci_da850_evm())
-   sysclk = 24576000;
-
-   else
-   return -EINVAL;
+   if (np) {
+   ret = of_property_read_u32(np, ti,codec-clock-rate, sysclk);
+   if (ret  0)
+   return ret;
+   } else {
+   /* ASP1 on DM355 EVM is clocked by an external oscillator */
+   if (machine_is_davinci_dm355_evm() ||
+   machine_is_davinci_dm6467_evm

RE: [PATCH v3 1/4] ASoC: tlv320aic3x: Convert mic bias to a supply widget

2013-01-31 Thread Hebbar, Gururaja
On Thu, Jan 31, 2013 at 16:54:16, Mark Brown wrote:
 On Thu, Jan 31, 2013 at 04:53:10PM +0530, Hebbar Gururaja wrote:
 
  :100644 100644 e7b98f4... f47c3f5... M  
  Documentation/devicetree/bindings/sound/tlv320aic3x.txt
  :100644 100644 ffd9bc7... 9407fd0... M  include/sound/tlv320aic3x.h
  :100644 100644 4989143... 65d09d6... M  sound/soc/codecs/tlv320aic3x.c
  :100644 100644 6db3c41... e521ac3... M  sound/soc/codecs/tlv320aic3x.h
 
 As mentioned when you posted this before this patch needs to update the
 machine drivers using the device too.

The patch-set 2/4 does the same thing. Since I have da850-evm at my end, I 
have modified that machine driver and sent-it as 2/4.

 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH v3 1/4] ASoC: tlv320aic3x: Convert mic bias to a supply widget

2013-01-31 Thread Hebbar, Gururaja
On Thu, Jan 31, 2013 at 17:00:38, Mark Brown wrote:
 On Thu, Jan 31, 2013 at 11:27:07AM +, Hebbar, Gururaja wrote:
  On Thu, Jan 31, 2013 at 16:54:16, Mark Brown wrote:
 
   As mentioned when you posted this before this patch needs to update the
   machine drivers using the device too.
 
  The patch-set 2/4 does the same thing. Since I have da850-evm at my end, I 
  have modified that machine driver and sent-it as 2/4.
 
 Two problems here.  One is that the update should be done in the same
 patch and the other is that you need to update *all* the machine drivers
 using the device, not just one of them.

Ok, I will send the updated version now.

 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH v4 0/3] ASoC davinci/tlv320aic3x updates, fixes DT support

2013-01-31 Thread Hebbar Gururaja
1. Convert tlv320aic3x mic bias to a supply widget and related machine driver
2. Add DT support for Davinci machine platform
3. Remove __dev* attributes

This patch-set is tested on Davinci platform (DA850 EVM). This series applies on
top of tag next-20130128 git tree
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

These patches cannot be tested directly on mainline kernel (DT based).
This is because dma is not yet completely ported to Davinci ASoC. I had to add
few hacks to get Audio working on Davinci DA850 platform.

For reference, I have placed the entire working tree @
Tree :  https://github.com/ghebbar/linux.git
Branch : dev_next-20130128_davinci_asoc_dt_v3

Changes in v4
 - updated pending machine driver to change in micbias - supply widget
 - merge codec  machine driver change into a single commit

Changes in v3
- drop mcasp pinctrl handler patch from series as it is now handled
  centrally.
- Convert tlv320aic3x mic bias to a supply widget and related machine
  driver
- remove __dev* attributes

Changes in v2
 - Remove reference to Linux  software details from DT binding

Hebbar Gururaja (2):
  ASoC: tlv320aic3x: Convert mic bias to a supply widget
  ASoC: davinci: remove __dev* attributes

Hebbar, Gururaja (1):
  ASoC: davinci: machine: Add device tree binding

 .../bindings/sound/davinci-evm-audio.txt   |   53 ++
 .../devicetree/bindings/sound/tlv320aic3x.txt  |6 +
 include/sound/tlv320aic3x.h|   10 ++
 sound/soc/codecs/tlv320aic3x.c |   83 -
 sound/soc/codecs/tlv320aic3x.h |4 +
 sound/soc/davinci/davinci-evm.c|  185 +---
 sound/soc/omap/n810.c  |4 +-
 sound/soc/omap/rx51.c  |8 +-
 8 files changed, 318 insertions(+), 35 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/sound/davinci-evm-audio.txt

-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH v4 1/3] ASoC: tlv320aic3x: Convert mic bias to a supply widget

2013-01-31 Thread Hebbar Gururaja
Convert MicBias widgets to supply widget.

On tlv320aic3x, Mic bias power on/off shares the same register bits
with output mic bias voltage.  So, when power on mic bias, we need
reclaim it to voltage value.

Provide a new platform data so that the micbias voltage can be sent
according to board requirement. Now since tlv320aic3x codec driver
is DT aware, update dt files and functions to handle this new
micbias-vg  platform data.

Because of sharing of bits, when enabling the micbias, voltage also
needs to be updated. So use SND_SOC_DAPM_POST_PMU  SND_SOC_DAPM_PRE_PMD
macro to create an event to handle this.

Since micbias is converted to supply widget, updated machine drivers as
well.

This change is runtime tested on da850-evm with audio loopback
(arecord|aplay) for confirmation.

Signed-off-by: Hebbar Gururaja gururaja.heb...@ti.com
---
Changes in v4
 - updated pending machine driver to change in micbias - supply widget
 - merge codec  machine driver change into a single commit

Changes in v3
 - New patch

:100644 100644 e7b98f4... f47c3f5... M  
Documentation/devicetree/bindings/sound/tlv320aic3x.txt
:100644 100644 ffd9bc7... 9407fd0... M  include/sound/tlv320aic3x.h
:100644 100644 4989143... 65d09d6... M  sound/soc/codecs/tlv320aic3x.c
:100644 100644 6db3c41... e521ac3... M  sound/soc/codecs/tlv320aic3x.h
:100644 100644 d55e647... 484b22c... M  sound/soc/davinci/davinci-evm.c
:100644 100644 230b8c1... ee7cd53... M  sound/soc/omap/n810.c
:100644 100644 d921ddb... 3cd5257... M  sound/soc/omap/rx51.c
 .../devicetree/bindings/sound/tlv320aic3x.txt  |6 ++
 include/sound/tlv320aic3x.h|   10 +++
 sound/soc/codecs/tlv320aic3x.c |   83 ++--
 sound/soc/codecs/tlv320aic3x.h |4 +
 sound/soc/davinci/davinci-evm.c|6 +-
 sound/soc/omap/n810.c  |4 +-
 sound/soc/omap/rx51.c  |8 +-
 7 files changed, 106 insertions(+), 15 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/tlv320aic3x.txt 
b/Documentation/devicetree/bindings/sound/tlv320aic3x.txt
index e7b98f4..f47c3f5 100644
--- a/Documentation/devicetree/bindings/sound/tlv320aic3x.txt
+++ b/Documentation/devicetree/bindings/sound/tlv320aic3x.txt
@@ -11,6 +11,12 @@ Optional properties:
 
 - gpio-reset - gpio pin number used for codec reset
 - ai3x-gpio-func - array of 2 int - AIC3X_GPIO1  AIC3X_GPIO2 Functionality
+- ai3x-micbias-vg - MicBias Voltage required.
+   1 - MICBIAS output is powered to 2.0V,
+   2 - MICBIAS output is powered to 2.5V,
+   3 - MICBIAS output is connected to AVDD,
+   If this node is not mentioned or if the value is incorrect, then MicBias
+   is powered down.
 
 Example:
 
diff --git a/include/sound/tlv320aic3x.h b/include/sound/tlv320aic3x.h
index ffd9bc7..9407fd0 100644
--- a/include/sound/tlv320aic3x.h
+++ b/include/sound/tlv320aic3x.h
@@ -46,6 +46,13 @@ enum {
AIC3X_GPIO2_FUNC_BUTTON_PRESS_IRQ   = 15
 };
 
+enum aic3x_micbias_voltage {
+   AIC3X_MICBIAS_OFF = 0,
+   AIC3X_MICBIAS_2_0V = 1,
+   AIC3X_MICBIAS_2_5V = 2,
+   AIC3X_MICBIAS_AVDDV = 3,
+};
+
 struct aic3x_setup_data {
unsigned int gpio_func[2];
 };
@@ -53,6 +60,9 @@ struct aic3x_setup_data {
 struct aic3x_pdata {
int gpio_reset; /*  0 if not used */
struct aic3x_setup_data *setup;
+
+   /* Selects the micbias voltage */
+   enum aic3x_micbias_voltage micbias_vg;
 };
 
 #endif
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 4989143..65d09d6 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -85,6 +85,9 @@ struct aic3x_priv {
 #define AIC3X_MODEL_33 1
 #define AIC3X_MODEL_3007 2
u16 model;
+
+   /* Selects the micbias voltage */
+   enum aic3x_micbias_voltage micbias_vg;
 };
 
 /*
@@ -195,6 +198,37 @@ static int snd_soc_dapm_put_volsw_aic3x(struct 
snd_kcontrol *kcontrol,
return ret;
 }
 
+/*
+ * mic bias power on/off share the same register bits with
+ * output voltage of mic bias. when power on mic bias, we
+ * need reclaim it to voltage value.
+ * 0x0 = Powered off
+ * 0x1 = MICBIAS output is powered to 2.0V,
+ * 0x2 = MICBIAS output is powered to 2.5V
+ * 0x3 = MICBIAS output is connected to AVDD
+ */
+static int mic_bias_event(struct snd_soc_dapm_widget *w,
+   struct snd_kcontrol *kcontrol, int event)
+{
+   struct snd_soc_codec *codec = w-codec;
+   struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
+
+   switch (event) {
+   case SND_SOC_DAPM_POST_PMU:
+   /* change mic bias voltage to user defined */
+   snd_soc_update_bits(codec, MICBIAS_CTRL,
+   MICBIAS_LEVEL_MASK,
+   aic3x-micbias_vg  MICBIAS_LEVEL_SHIFT);
+   break;
+
+   case SND_SOC_DAPM_PRE_PMD

[PATCH v4 2/3] ASoC: davinci: machine: Add device tree binding

2013-01-31 Thread Hebbar Gururaja
From: Hebbar, Gururaja gururaja.heb...@ti.com

Device tree support for Davinci Machine driver

When the board boots with device tree, the driver will receive card,
codec, dai interface details (like the card name, DAPM routing map,
phandle for the audio components described in the dts file, codec mclk
speed).
The card will be set up based on this information.
Since the routing is provided via DT we can mark the card fully routed
so core can take care of disconnecting the unused pins.

Signed-off-by: Hebbar, Gururaja gururaja.heb...@ti.com
---
Changes in v4
 - No change

Changes in v3
 - No change

Changes in v2
 - Remove reference to Linux  software details from DT binding

:00 100644 000... 92ad4c7... A  
Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
:100644 100644 484b22c... e6009a4... M  sound/soc/davinci/davinci-evm.c
 .../bindings/sound/davinci-evm-audio.txt   |   53 ++
 sound/soc/davinci/davinci-evm.c|  179 +---
 2 files changed, 212 insertions(+), 20 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt 
b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
new file mode 100644
index 000..92ad4c7
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
@@ -0,0 +1,53 @@
+* Texas Instruments SoC audio setups with TLV320AIC3X Codec
+
+Required properties:
+- compatible :
+   ti,dm365-voice-codec-audio: for DM365 platforms with Voice Codec
+   ti,da830-evm-audio: for DM365/DA8xx/OMAPL1x/AM33xx
+
+- ti,model : The user-visible name of this sound complex.
+- ti,audio-codec : The phandle of the TLV320AIC3x audio codec
+- ti,mcasp-controller : The phandle of the McASP controller
+- ti,codec-clock-rate : The Codec Clock rate (in Hz) applied to the Codec
+- ti,audio-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. Valid names for sources and
+  sinks are the codec's pins, and the jacks on the board:
+
+  Codec pins:
+
+  * MIC3L
+  * MIC3R
+  * LINE1L
+  * LINE2L
+  * LINE1R
+  * LINE2R
+
+  Board connectors:
+
+  * Headphone Jack
+  * Line Out
+  * Mic Jack
+
+
+Example:
+
+sound {
+   compatible = ti,da830-evm-audio;
+   ti,model = DA830 EVM;
+   ti,audio-codec = tlv320aic3x;
+   ti,mcasp-controller = mcasp1;
+   ti,codec-clock-rate = 1200;
+   ti,audio-routing =
+   Headphone Jack,   HPLOUT,
+   Headphone Jack,   HPROUT,
+   Line Out, LLOUT,
+   Line Out, RLOUT,
+   MIC3L,Mic Bias,
+   MIC3R,Mic Bias,
+   Mic Bias, Mic Jack,
+   LINE1L,   Line In,
+   LINE2L,   Line In,
+   LINE1R,   Line In,
+   LINE2R,   Line In;
+};
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 484b22c..e6009a4 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -15,6 +15,7 @@
 #include linux/interrupt.h
 #include linux/platform_device.h
 #include linux/i2c.h
+#include linux/of_platform.h
 #include sound/core.h
 #include sound/pcm.h
 #include sound/soc.h
@@ -34,27 +35,38 @@ static int evm_hw_params(struct snd_pcm_substream 
*substream,
struct snd_soc_pcm_runtime *rtd = substream-private_data;
struct snd_soc_dai *codec_dai = rtd-codec_dai;
struct snd_soc_dai *cpu_dai = rtd-cpu_dai;
+   struct snd_soc_codec *codec = rtd-codec;
+   struct snd_soc_card *soc_card = codec-card;
+   struct device_node *np = soc_card-dev-of_node;
int ret = 0;
unsigned sysclk;
 
-   /* ASP1 on DM355 EVM is clocked by an external oscillator */
-   if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm() ||
-   machine_is_davinci_dm365_evm())
-   sysclk = 2700;
-
-   /* ASP0 in DM6446 EVM is clocked by U55, as configured by
-* board-dm644x-evm.c using GPIOs from U18.  There are six
-* options; here we know we use a 48 KHz sample rate.
-*/
-   else if (machine_is_davinci_evm())
-   sysclk = 12288000;
-
-   else if (machine_is_davinci_da830_evm() ||
-   machine_is_davinci_da850_evm())
-   sysclk = 24576000;
-
-   else
-   return -EINVAL;
+   if (np) {
+   ret = of_property_read_u32(np, ti,codec-clock-rate, sysclk);
+   if (ret  0)
+   return ret;
+   } else {
+   /* ASP1 on DM355 EVM is clocked by an external oscillator */
+   if (machine_is_davinci_dm355_evm() ||
+   machine_is_davinci_dm6467_evm

RE: [alsa-devel] [PATCH V2 2/2] ASoC: Davinci: machine: Add device tree binding

2013-01-24 Thread Hebbar, Gururaja
On Wed, Jan 23, 2013 at 21:18:12, Mark Brown wrote:
 On Wed, Jan 23, 2013 at 12:39:35PM +, Hebbar, Gururaja wrote:
  On Fri, Jan 04, 2013 at 17:56:12, Mark Brown wrote:
 
   The CODEC driver biases should be changed over to be supplies, this
   makes the above much more natural - the routing there is a hack for
   older versions of ASoc.  Otherwise this looks fine.
 
  ON TLV320AIC3x Codec, MIC Bias power on/off share the same register bits
  with Bias voltage output.
 
 So you need to use an event to write the actual enable bit.

Yes. Bias Enable/Disable is possible using SND_SOC_DAPM_SUPPLY. However the 
actual Bias voltage should be user selectable.

 
  SGTL5000 -- Single register for MIC BIAS enable  output impedance of MIC
  Bias. The driver uses SND_SOC_DAPM_POST_PMU  SND_SOC_DAPM_PRE_PMD macro to
  handle the MIC Bias enable  disable event.
 
 This is the way these things should be handled.

However, as mentioned before, TLV320AIC3x Codec there is no separate 
enable/disable bit. It is mixed with Bias Voltage settings.

So it is either 
a. Bias is disabled 
b. Bias is enabled with some voltage. This voltage should be user 
 configurable.

So, by just using the SND_SOC_DAPM_POST_PMU  SND_SOC_DAPM_PRE_PMD I can mask 
 handle one particular voltage. 

Now I am not able understand how to make this user configurable using
SND_SOC_DAPM_xx macro.


I believe the below code change [1] should work in this situation. What is your 
opinion?



Thanks  Regards
Gururaja

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 5708a97..2c17e46 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -268,6 +268,11 @@ static DECLARE_TLV_DB_SCALE(adc_tlv, 0, 50, 0);
  */
 static DECLARE_TLV_DB_SCALE(output_stage_tlv, -5900, 50, 1);
 
+static const char *mic_bias_level_txt[] = { off, 2V, 2.5V, AVDD };
+
+static const struct soc_enum mic_bias_level =
+SOC_ENUM_SINGLE(MICBIAS_CTRL, 6, 4, mic_bias_level_txt);
+
 static const struct snd_kcontrol_new aic3x_snd_controls[] = {
/* Output */
SOC_DOUBLE_R_TLV(PCM Playback Volume,
@@ -391,6 +396,9 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = 
{
SOC_DOUBLE_R(PGA Capture Switch, LADC_VOL, RADC_VOL, 7, 0x01, 1),
 
SOC_ENUM(ADC HPF Cut-off, aic3x_enum[ADC_HPF_ENUM]),
+
+   /* Mic Bias Level */
+   SOC_ENUM(Mic Bias Level, mic_bias_level),
 };
 
 /*
@@ -596,12 +604,7 @@ static const struct snd_soc_dapm_widget 
aic3x_dapm_widgets[] = {
 AIC3X_ASD_INTF_CTRLA, 0, 3, 3, 0),
 
/* Mic Bias */
-   SND_SOC_DAPM_REG(snd_soc_dapm_micbias, Mic Bias 2V,
-MICBIAS_CTRL, 6, 3, 1, 0),
-   SND_SOC_DAPM_REG(snd_soc_dapm_micbias, Mic Bias 2.5V,
-MICBIAS_CTRL, 6, 3, 2, 0),
-   SND_SOC_DAPM_REG(snd_soc_dapm_micbias, Mic Bias AVDD,
-MICBIAS_CTRL, 6, 3, 3, 0),
+   SND_SOC_DAPM_SUPPLY(Mic Bias, MICBIAS_CTRL, 6, 0, NULL, 0),
 
/* Output mixers */
SND_SOC_DAPM_MIXER(Left Line Mixer, SND_SOC_NOPM, 0, 0,
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 82d29a5..37b8e78 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -128,9 +128,9 @@ static const struct snd_soc_dapm_route audio_map[] = {
{Line Out, NULL, RLOUT},
 
/* Mic connected to (MIC3L | MIC3R) */
-   {MIC3L, NULL, Mic Bias 2V},
-   {MIC3R, NULL, Mic Bias 2V},
-   {Mic Bias 2V, NULL, Mic Jack},
+   {MIC3L, NULL, Mic Bias},
+   {MIC3R, NULL, Mic Bias},
+   {Mic Bias, NULL, Mic Jack},
 
/* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
{LINE1L, NULL, Line In},




___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [alsa-devel] [PATCH V2 2/2] ASoC: Davinci: machine: Add device tree binding

2013-01-24 Thread Hebbar, Gururaja
On Thu, Jan 24, 2013 at 15:32:55, Mark Brown wrote:
 On Thu, Jan 24, 2013 at 09:33:34AM +, Hebbar, Gururaja wrote:
 
  So, by just using the SND_SOC_DAPM_POST_PMU  SND_SOC_DAPM_PRE_PMD I can 
  mask 
   handle one particular voltage. 
 
 What makes you say that?  That is just not true.

What I meant was that by using this macro (SND_SOC_DAPM_POST_PMU 
SND_SOC_DAPM_PRE_PMD) I can just save and restore existing voltage values inside
the event. They will not be user configurable (available to user through some 
widget).


 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [alsa-devel] [PATCH V2 2/2] ASoC: Davinci: machine: Add device tree binding

2013-01-24 Thread Hebbar, Gururaja
On Thu, Jan 24, 2013 at 15:43:03, Mark Brown wrote:
 On Thu, Jan 24, 2013 at 10:06:42AM +, Hebbar, Gururaja wrote:
 
  What I meant was that by using this macro (SND_SOC_DAPM_POST_PMU 
  SND_SOC_DAPM_PRE_PMD) I can just save and restore existing voltage values 
  inside
  the event. They will not be user configurable (available to user through 
  some widget).
 
 Well, you *could* add separate register control for that 

That’s what I am doing using a different register control


+static const char *mic_bias_level_txt[] = { off, 2V, 2.5V, 
AVDD };
+
+static const struct soc_enum mic_bias_level =
+SOC_ENUM_SINGLE(MICBIAS_CTRL, 6, 4, mic_bias_level_txt);
+
 static const struct snd_kcontrol_new aic3x_snd_controls[] = {
/* Output */
SOC_DOUBLE_R_TLV(PCM Playback Volume,
@@ -391,6 +396,9 @@ static const struct snd_kcontrol_new 
aic3x_snd_controls[] = {
SOC_DOUBLE_R(PGA Capture Switch, LADC_VOL, RADC_VOL, 7, 0x01, 
1),
 
SOC_ENUM(ADC HPF Cut-off, aic3x_enum[ADC_HPF_ENUM]),
+
+   /* Mic Bias Level */
+   SOC_ENUM(Mic Bias Level, mic_bias_level),



 but it's not
 really something that should obviously be exposed to users; usually
 that'd be something that is fixed by the platform via platform data.

Will look into this angle.

 

Going by the way of using extra register control, will my method (code change
attached in prev mail) be sufficient?


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [alsa-devel] [PATCH V2 2/2] ASoC: Davinci: machine: Add device tree binding

2013-01-23 Thread Hebbar, Gururaja
On Fri, Jan 04, 2013 at 17:56:12, Mark Brown wrote:
 On Fri, Jan 04, 2013 at 03:24:37PM +0530, Hebbar Gururaja wrote:
 
  +   MIC3L,Mic Bias 2V,
  +   MIC3R,Mic Bias 2V,
  +   Mic Bias 2V,  Mic Jack,
 
 The CODEC driver biases should be changed over to be supplies, this
 makes the above much more natural - the routing there is a hack for
 older versions of ASoc.  Otherwise this looks fine.


ON TLV320AIC3x Codec, MIC Bias power on/off share the same register bits
with Bias voltage output.

Page 0 / Register 25: MICBIAS Control Register

BIT READ/WRITE  RESET VALUE DESCRIPTION
D7–D6   R/W 00  MICBIAS Level Control
00: MICBIAS output is powered down
01: MICBIAS output is powered to 2.0V
10: MICBIAS output is powered to 2.5V
11: MICBIAS output is connected to AVDD


Because of this, I find it difficult to use SND_SOC_DAPM_SUPPLY macro.

I found a similar implementation (MIC BIAS enable + Bias voltage selection)
in 2 other platform (WM8900  SGTL5000).

WM8900 -- Different registers for MIC BIAS enable  Bias voltage selection.
However both are implemented using different macros

static const char *mic_bias_level_txt[] = { 0.9*AVDD, 0.65*AVDD };

static const struct soc_enum mic_bias_level =
SOC_ENUM_SINGLE(WM8900_REG_INCTL, 8, 2, mic_bias_level_txt);

...
static const struct snd_kcontrol_new wm8900_snd_controls[] = {
SOC_ENUM(Mic Bias Level, mic_bias_level),
...

SND_SOC_DAPM_SUPPLY(Mic Bias, WM8900_REG_POWER1, 4, 0, NULL, 0),



SGTL5000 -- Single register for MIC BIAS enable  output impedance of MIC
Bias. The driver uses SND_SOC_DAPM_POST_PMU  SND_SOC_DAPM_PRE_PMD macro to
handle the MIC Bias enable  disable event.


static int mic_bias_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
switch (event) {
case SND_SOC_DAPM_POST_PMU:
...

static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = {
...
SND_SOC_DAPM_SUPPLY(Mic Bias, SGTL5000_CHIP_MIC_CTRL, 8, 0,
mic_bias_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),


Since TLV320AIC3x Codec uses single register bit-set to indicate BIA state
 Voltage level, I am not able to able to change existing code to
SND_SOC_DAPM_SUPPLY macro.


Could you please show some pointers on how to handle/implement
SND_SOC_DAPM_SUPPLY in above scenario?


Thanks  Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH v4 01/14] ARM: davinci: move private EDMA API to arm/common

2013-01-10 Thread Hebbar, Gururaja
On Fri, Jan 11, 2013 at 11:18:37, Porter, Matt wrote:
 Move mach-davinci/dma.c to common/edma.c so it can be used
 by OMAP (specifically AM33xx) as well. This just moves the
 private EDMA API and enables it to build on OMAP.
 
 Signed-off-by: Matt Porter mpor...@ti.com
 ---
  arch/arm/Kconfig   |1 +
  arch/arm/common/Kconfig|3 +
  arch/arm/common/Makefile   |1 +
  arch/arm/{mach-davinci/dma.c = common/edma.c} |2 +-
  arch/arm/mach-davinci/Makefile |2 +-
  arch/arm/mach-davinci/board-tnetv107x-evm.c|2 +-
  arch/arm/mach-davinci/davinci.h|2 +-
  arch/arm/mach-davinci/devices-tnetv107x.c  |2 +-
  arch/arm/mach-davinci/devices.c|7 +-
  arch/arm/mach-davinci/dm355.c  |2 +-
  arch/arm/mach-davinci/dm365.c  |2 +-
  arch/arm/mach-davinci/dm644x.c |2 +-
  arch/arm/mach-davinci/dm646x.c |2 +-
  arch/arm/mach-davinci/include/mach/da8xx.h |2 +-
  arch/arm/mach-davinci/include/mach/edma.h  |  267 
 
  arch/arm/plat-omap/Kconfig |1 +
  drivers/dma/edma.c |2 +-
  drivers/mmc/host/davinci_mmc.c |1 +
  include/linux/mfd/davinci_voicecodec.h |3 +-
  include/linux/platform_data/edma.h |  182 

Headers file are just moved here. So git mv file1 flie2; and the git 
format-patch -C on commit should just generate few lines of patch.

  include/linux/platform_data/spi-davinci.h  |2 +-
  sound/soc/davinci/davinci-evm.c|1 +
  sound/soc/davinci/davinci-pcm.c|1 +
  sound/soc/davinci/davinci-pcm.h|2 +-
  sound/soc/davinci/davinci-sffsdr.c |6 +-
  25 files changed, 212 insertions(+), 288 deletions(-)
  rename arch/arm/{mach-davinci/dma.c = common/edma.c} (99%)
  delete mode 100644 arch/arm/mach-davinci/include/mach/edma.h
  create mode 100644 include/linux/platform_data/edma.h
 
 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
 index 67874b8..7637d31 100644
 --- a/arch/arm/Kconfig
 +++ b/arch/arm/Kconfig
 @@ -932,6 +932,7 @@ config ARCH_DAVINCI
   select GENERIC_IRQ_CHIP
   select HAVE_IDE
   select NEED_MACH_GPIO_H
 + select TI_PRIV_EDMA
   select USE_OF
   select ZONE_DMA
   help
 diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
 index 45ceeb0..9e32d0d 100644
 --- a/arch/arm/common/Kconfig
 +++ b/arch/arm/common/Kconfig
 @@ -40,3 +40,6 @@ config SHARP_PARAM
  
  config SHARP_SCOOP
   bool
 +
 +config TI_PRIV_EDMA
 + bool
 diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
 index e8a4e58..d09a39b 100644
 --- a/arch/arm/common/Makefile
 +++ b/arch/arm/common/Makefile
 @@ -13,3 +13,4 @@ obj-$(CONFIG_SHARP_PARAM)   += sharpsl_param.o
  obj-$(CONFIG_SHARP_SCOOP)+= scoop.o
  obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
  obj-$(CONFIG_ARM_TIMER_SP804)+= timer-sp.o
 +obj-$(CONFIG_TI_PRIV_EDMA)   += edma.o
 diff --git a/arch/arm/mach-davinci/dma.c b/arch/arm/common/edma.c
 similarity index 99%
 rename from arch/arm/mach-davinci/dma.c
 rename to arch/arm/common/edma.c
 index a685e97..4411087 100644
 --- a/arch/arm/mach-davinci/dma.c
 +++ b/arch/arm/common/edma.c
 @@ -25,7 +25,7 @@
  #include linux/io.h
  #include linux/slab.h
  
 -#include mach/edma.h
 +#include linux/platform_data/edma.h
  
  /* Offsets matching struct edmacc_param */
  #define PARM_OPT 0x00
 diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
 index fb5c1aa..493a36b 100644
 --- a/arch/arm/mach-davinci/Makefile
 +++ b/arch/arm/mach-davinci/Makefile
 @@ -5,7 +5,7 @@
  
  # Common objects
  obj-y:= time.o clock.o serial.o psc.o \
 -dma.o usb.o common.o sram.o aemif.o
 +usb.o common.o sram.o aemif.o
  
  obj-$(CONFIG_DAVINCI_MUX)+= mux.o
  
 diff --git a/arch/arm/mach-davinci/board-tnetv107x-evm.c 
 b/arch/arm/mach-davinci/board-tnetv107x-evm.c
 index be30997..86f55ba 100644
 --- a/arch/arm/mach-davinci/board-tnetv107x-evm.c
 +++ b/arch/arm/mach-davinci/board-tnetv107x-evm.c
 @@ -26,12 +26,12 @@
  #include linux/input.h
  #include linux/input/matrix_keypad.h
  #include linux/spi/spi.h
 +#include linux/platform_data/edma.h
  
  #include asm/mach/arch.h
  #include asm/mach-types.h
  
  #include mach/irqs.h
 -#include mach/edma.h
  #include mach/mux.h
  #include mach/cp_intc.h
  #include mach/tnetv107x.h
 diff --git a/arch/arm/mach-davinci/davinci.h b/arch/arm/mach-davinci/davinci.h
 index 12d544b..d26a6bc 100644
 --- a/arch/arm/mach-davinci/davinci.h
 +++ b/arch/arm/mach-davinci/davinci.h
 @@ -23,9 +23,9 @@
  #include linux/platform_device.h
  #include linux/spi/spi.h
  #include linux/platform_data/davinci_asp.h
 

RE: [PATCH v4 05/14] dmaengine: edma: Add TI EDMA device tree binding

2013-01-10 Thread Hebbar, Gururaja
On Fri, Jan 11, 2013 at 11:18:41, Porter, Matt wrote:
 The binding definition is based on the generic DMA controller
 binding.
 
 Signed-off-by: Matt Porter mpor...@ti.com
 ---
  Documentation/devicetree/bindings/dma/ti-edma.txt |   51 
 +
  1 file changed, 51 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/dma/ti-edma.txt
 
 diff --git a/Documentation/devicetree/bindings/dma/ti-edma.txt 
 b/Documentation/devicetree/bindings/dma/ti-edma.txt
 new file mode 100644
 index 000..3344345
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/dma/ti-edma.txt
 @@ -0,0 +1,51 @@
 +TI EDMA
 +
 +Required properties:
 +- compatible : ti,edma3
 +- ti,hwmods: Name of the hwmods associated to the EDMA
 +- ti,edma-regions: Number of regions
 +- ti,edma-slots: Number of slots
 +- ti,edma-queue-tc-map: List of transfer control to queue mappings
 +- ti,edma-queue-priority-map: List of queue priority mappings
 +- ti,edma-default-queue: Default queue value
 +
 +Optional properties:
 +- ti,edma-reserved-channels: List of reserved channel regions
 +- ti,edma-reserved-slots: List of reserved slot regions
 +- ti,edma-xbar-event-map: Crossbar event to channel map
 +
 +Example:
 +
 +edma: edma@4900 {
 + #address-cells = 1;
 + #size-cells = 0;

address-cells  size-cells are only required when current node is a parent 
node  it has sibling/child nodes (that too if the child node uses reg 
property).

 + reg = 0x4900 0x1;
 + interrupt-parent = intc;
 + interrupts = 12 13 14;
 + compatible = ti,edma3;
 + ti,hwmods = tpcc, tptc0, tptc1, tptc2;
 + #dma-cells = 1;
 + dma-channels = 64;
 + ti,edma-regions = 4;
 + ti,edma-slots = 256;
 + ti,edma-reserved-channels = 0  2
 +  14 2
 +  26 6
 +  48 4
 +  56 8;
 + ti,edma-reserved-slots = 0  2
 +   14 2
 +   26 6
 +   48 4
 +   56 8
 +   64 127;
 + ti,edma-queue-tc-map = 0 0
 + 1 1
 + 2 2;
 + ti,edma-queue-priority-map = 0 0
 +   1 1
 +   2 2;
 + ti,edma-default-queue = 0;
 + ti,edma-xbar-event-map = 1 12
 +   2 13;
 +};
 -- 
 1.7.9.5
 
 ___
 Davinci-linux-open-source mailing list
 davinci-linux-open-sou...@linux.davincidsp.com
 http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [alsa-devel] [PATCH V2 2/2] ASoC: Davinci: machine: Add device tree binding

2013-01-07 Thread Hebbar, Gururaja
On Fri, Jan 04, 2013 at 17:56:12, Mark Brown wrote:
 On Fri, Jan 04, 2013 at 03:24:37PM +0530, Hebbar Gururaja wrote:
 
  +   MIC3L,Mic Bias 2V,
  +   MIC3R,Mic Bias 2V,
  +   Mic Bias 2V,  Mic Jack,
 
 The CODEC driver biases should be changed over to be supplies, this
 makes the above much more natural - the routing there is a hack for
 older versions of ASoc.  

I will be looking into this now. To speed up the things, do you have any
reference link/implementation which  I can refer to?

I looked at the OMAP implementation but they are following the same (meaning 
both
DT  non-DT use similar audio map for routing).


 Otherwise this looks fine.

Thanks for the review.

 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH V2 1/2] ASoC: davinci-mcasp: Add pinctrl support

2013-01-04 Thread Hebbar Gururaja
From: Hebbar, Gururaja gururaja.heb...@ti.com

Signed-off-by: Hebbar, Gururaja gururaja.heb...@ti.com
---
Changes in V2
- no change

:100644 100644 55e2bf6... 83d96eb... M  sound/soc/davinci/davinci-mcasp.c
 sound/soc/davinci/davinci-mcasp.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/sound/soc/davinci/davinci-mcasp.c 
b/sound/soc/davinci/davinci-mcasp.c
index 55e2bf6..83d96eb 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -25,6 +25,7 @@
 #include linux/of.h
 #include linux/of_platform.h
 #include linux/of_device.h
+#include linux/pinctrl/consumer.h
 
 #include sound/core.h
 #include sound/pcm.h
@@ -1080,6 +1081,7 @@ static int davinci_mcasp_probe(struct platform_device 
*pdev)
struct resource *mem, *ioarea, *res;
struct snd_platform_data *pdata;
struct davinci_audio_dev *dev;
+   struct pinctrl *pinctrl;
int ret;
 
if (!pdev-dev.platform_data  !pdev-dev.of_node) {
@@ -,6 +1113,11 @@ static int davinci_mcasp_probe(struct platform_device 
*pdev)
return -EBUSY;
}
 
+   pinctrl = devm_pinctrl_get_select_default(pdev-dev);
+   if (IS_ERR(pinctrl))
+   dev_warn(pdev-dev,
+   pins are not configured from the driver\n);
+
pm_runtime_enable(pdev-dev);
 
ret = pm_runtime_get_sync(pdev-dev);
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH V2 0/2] ARM/ASoC: Davinci: Device Tree Update

2013-01-04 Thread Hebbar Gururaja
1. Add pinctrl for McASP Module
2. Add DT support for Davinci machine platform

This patch-set is tested on Davinci platform (DA850 EVM). This series applies on
top of tag next-20130103 git tree
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

These patches cannot be tested directly on mainline kernel (DT based).
This is because dma is not yet completely ported to Davinci ASoC. I had to add
few hacks to get Audio working on Davinci DA850 platform.

For reference, I have placed the entire working tree @ 
Tree : https://gitorious.org/davinci-asoc-dt/davinci-asoc-dt
Branch : dev_next-20130103_davinci_asoc_dt

Changes in V2
 - Remove reference to Linux  software details from DT binding

Hebbar, Gururaja (2):
  ASoC: davinci-mcasp: Add pinctrl support
  ASoC: Davinci: machine: Add device tree binding

 .../bindings/sound/davinci-evm-audio.txt   |   53 ++
 sound/soc/davinci/davinci-evm.c|  179 +---
 sound/soc/davinci/davinci-mcasp.c  |7 +
 3 files changed, 219 insertions(+), 20 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/sound/davinci-evm-audio.txt

-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH V2 2/2] ASoC: Davinci: machine: Add device tree binding

2013-01-04 Thread Hebbar Gururaja
From: Hebbar, Gururaja gururaja.heb...@ti.com

Device tree support for Davinci Machine driver

When the board boots with device tree, the driver will receive card,
codec, dai interface details (like the card name, DAPM routing map,
phandle for the audio components described in the dts file, codec mclk
speed).
The card will be set up based on this information.
Since the routing is provided via DT we can mark the card fully routed
so core can take care of disconnecting the unused pins.

Signed-off-by: Hebbar, Gururaja gururaja.heb...@ti.com
---
Changes in V2
 - Remove reference to Linux  software details from DT binding

:00 100644 000... 25f7180... A  
Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
:100644 100644 d55e647... 91a32e5... M  sound/soc/davinci/davinci-evm.c
 .../bindings/sound/davinci-evm-audio.txt   |   53 ++
 sound/soc/davinci/davinci-evm.c|  179 +---
 2 files changed, 212 insertions(+), 20 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt 
b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
new file mode 100644
index 000..25f7180
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
@@ -0,0 +1,53 @@
+* Texas Instruments SoC audio setups with TLV320AIC3X Codec
+
+Required properties:
+- compatible :
+   ti,dm365-voice-codec-audio: for DM365 platforms with Voice Codec
+   ti,da830-evm-audio: for DM365/DA8xx/OMAPL1x/AM33xx
+
+- ti,model : The user-visible name of this sound complex.
+- ti,audio-codec : The phandle of the TLV320AIC3x audio codec
+- ti,mcasp-controller : The phandle of the McASP controller
+- ti,codec-clock-rate : The Codec Clock rate (in Hz) applied to the Codec
+- ti,audio-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. Valid names for sources and
+  sinks are the codec's pins, and the jacks on the board:
+
+  Codec pins:
+
+  * MIC3L
+  * MIC3R
+  * LINE1L
+  * LINE2L
+  * LINE1R
+  * LINE2R
+
+  Board connectors:
+
+  * Headphone Jack
+  * Line Out
+  * Mic Jack
+
+
+Example:
+
+sound {
+   compatible = ti,da830-evm-audio;
+   ti,model = DA830 EVM;
+   ti,audio-codec = tlv320aic3x;
+   ti,mcasp-controller = mcasp1;
+   ti,codec-clock-rate = 1200;
+   ti,audio-routing =
+   Headphone Jack,   HPLOUT,
+   Headphone Jack,   HPROUT,
+   Line Out, LLOUT,
+   Line Out, RLOUT,
+   MIC3L,Mic Bias 2V,
+   MIC3R,Mic Bias 2V,
+   Mic Bias 2V,  Mic Jack,
+   LINE1L,   Line In,
+   LINE2L,   Line In,
+   LINE1R,   Line In,
+   LINE2R,   Line In;
+};
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index d55e647..91a32e5 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -15,6 +15,7 @@
 #include linux/interrupt.h
 #include linux/platform_device.h
 #include linux/i2c.h
+#include linux/of_platform.h
 #include sound/core.h
 #include sound/pcm.h
 #include sound/soc.h
@@ -34,27 +35,38 @@ static int evm_hw_params(struct snd_pcm_substream 
*substream,
struct snd_soc_pcm_runtime *rtd = substream-private_data;
struct snd_soc_dai *codec_dai = rtd-codec_dai;
struct snd_soc_dai *cpu_dai = rtd-cpu_dai;
+   struct snd_soc_codec *codec = rtd-codec;
+   struct snd_soc_card *soc_card = codec-card;
+   struct device_node *np = soc_card-dev-of_node;
int ret = 0;
unsigned sysclk;
 
-   /* ASP1 on DM355 EVM is clocked by an external oscillator */
-   if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm() ||
-   machine_is_davinci_dm365_evm())
-   sysclk = 2700;
-
-   /* ASP0 in DM6446 EVM is clocked by U55, as configured by
-* board-dm644x-evm.c using GPIOs from U18.  There are six
-* options; here we know we use a 48 KHz sample rate.
-*/
-   else if (machine_is_davinci_evm())
-   sysclk = 12288000;
-
-   else if (machine_is_davinci_da830_evm() ||
-   machine_is_davinci_da850_evm())
-   sysclk = 24576000;
-
-   else
-   return -EINVAL;
+   if (np) {
+   ret = of_property_read_u32(np, ti,codec-clock-rate, sysclk);
+   if (ret  0)
+   return ret;
+   } else {
+   /* ASP1 on DM355 EVM is clocked by an external oscillator */
+   if (machine_is_davinci_dm355_evm() ||
+   machine_is_davinci_dm6467_evm() ||
+   machine_is_davinci_dm365_evm

RE: [PATCH 2/2] ASoC: Davinci: machine: Add device tree binding

2012-11-27 Thread Hebbar, Gururaja
On Mon, Nov 26, 2012 at 17:26:19, Mark Brown wrote:
 On Thu, Nov 22, 2012 at 09:34:59AM +0530, Hebbar, Gururaja wrote:
 
  +- dai-data : A list of DAI data used by SOC code to register
  + DAI, Codecs platform.
  + The string index should be as shown below.
  +dai-data =
  +DAI Name,  DAI Stream Name,
  +CODEC DAI Name,true if evm_aic3x_init is required, else 
  false,
  +evm ops required (evm_ops or evm_spdif_ops);
 
 This continues to have the same issue as with previous versions, this is
 all Linux internals (especially the evm_aic3x_init thing) not a
 description of the hardware, there's not enough information to allow
 someone to work out what the bindings for their system should be.

Last time when you gave the review comments for this, I misunderstood it for
missing/incomplete documentation, which is why I added more details to the
binding document in V3. 

Now that I have understood correctly, I will be removing references to 
linux/software parts in the DT and will handle it internally in the driver
code. 

Kindly accept my apologies in this regard.

 
 Do not post *ANY* further versions that have this evm_aic3x_init stuff
 in them, it's very annoying that you keep on ignoring this feedback.

Sure will remove the reference and repost it soon.

Thanks for all the review and guidance.

 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [PATCH 0/2] ARM/ASoC: Davinci: Device Tree Update

2012-11-26 Thread Hebbar, Gururaja
Mark,

On Thu, Nov 22, 2012 at 09:34:57, Hebbar, Gururaja wrote:
 From: Hebbar, Gururaja gururaja.heb...@ti.com
 
 1. Add pinctrl for McASP Module
 2. Add DT support for Davinci machine platform (resend)
 
 Second commit is a resend after re-basing on latest broonie-asoc/for-next
 (v3.7-rc6)
 
 Hebbar, Gururaja (2):
   ASoC: davinci-mcasp: Add pinctrl support
   ASoC: Davinci: machine: Add device tree binding

With these 2 patches, DT support for Davinci ASoC will be complete 
(well almost because edma dt binding is yet to be added). 
However it will at least be complete on Davinci platform.

Can you please review them and if it's OK, Could you please accept this series?

 
  .../bindings/sound/davinci-evm-audio.txt   |   66 +++
  sound/soc/davinci/davinci-evm.c|  185 
 +---
  sound/soc/davinci/davinci-mcasp.c  |7 +
  3 files changed, 238 insertions(+), 20 deletions(-)
  create mode 100644 
 Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
 
 -- 
 1.7.9.5
 
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 1/2] ASoC: davinci-mcasp: Add pinctrl support

2012-11-21 Thread Hebbar, Gururaja
From: Hebbar, Gururaja gururaja.heb...@ti.com

Signed-off-by: Hebbar, Gururaja gururaja.heb...@ti.com
---
:100644 100644 5715595... 76c05d9... M  sound/soc/davinci/davinci-mcasp.c
 sound/soc/davinci/davinci-mcasp.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/sound/soc/davinci/davinci-mcasp.c 
b/sound/soc/davinci/davinci-mcasp.c
index 5715595..76c05d9 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -25,6 +25,7 @@
 #include linux/of.h
 #include linux/of_platform.h
 #include linux/of_device.h
+#include linux/pinctrl/consumer.h
 
 #include sound/core.h
 #include sound/pcm.h
@@ -1108,6 +1109,7 @@ static int davinci_mcasp_probe(struct platform_device 
*pdev)
struct resource *mem, *ioarea, *res;
struct snd_platform_data *pdata;
struct davinci_audio_dev *dev;
+   struct pinctrl *pinctrl;
int ret;
 
if (!pdev-dev.platform_data  !pdev-dev.of_node) {
@@ -1139,6 +1141,11 @@ static int davinci_mcasp_probe(struct platform_device 
*pdev)
return -EBUSY;
}
 
+   pinctrl = devm_pinctrl_get_select_default(pdev-dev);
+   if (IS_ERR(pinctrl))
+   dev_warn(pdev-dev,
+   pins are not configured from the driver\n);
+
pm_runtime_enable(pdev-dev);
 
ret = pm_runtime_get_sync(pdev-dev);
-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 0/2] ARM/ASoC: Davinci: Device Tree Update

2012-11-21 Thread Hebbar, Gururaja
From: Hebbar, Gururaja gururaja.heb...@ti.com

1. Add pinctrl for McASP Module
2. Add DT support for Davinci machine platform (resend)

Second commit is a resend after re-basing on latest broonie-asoc/for-next
(v3.7-rc6)

Hebbar, Gururaja (2):
  ASoC: davinci-mcasp: Add pinctrl support
  ASoC: Davinci: machine: Add device tree binding

 .../bindings/sound/davinci-evm-audio.txt   |   66 +++
 sound/soc/davinci/davinci-evm.c|  185 +---
 sound/soc/davinci/davinci-mcasp.c  |7 +
 3 files changed, 238 insertions(+), 20 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/sound/davinci-evm-audio.txt

-- 
1.7.9.5

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 2/2] ASoC: Davinci: machine: Add device tree binding

2012-11-21 Thread Hebbar, Gururaja
From: Hebbar, Gururaja gururaja.heb...@ti.com

Device tree support for Davinci Machine driver

When the board boots with device tree, the driver will receive card,
codec, dai interface details (like the card name, DAPM routing map,
phandle for the audio components described in the dts file, codec mclk
speed).
The card will be set up based on this information.
Since the routing is provided via DT we can mark the card fully routed
so core can take care of disconnecting the unused pins.

When here, code indentation and comment style is also fixed

Signed-off-by: Hebbar, Gururaja gururaja.heb...@ti.com
---
:00 100644 000... b248014... A  
Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
:100644 100644 d55e647... 2af8110... M  sound/soc/davinci/davinci-evm.c
 .../bindings/sound/davinci-evm-audio.txt   |   66 +++
 sound/soc/davinci/davinci-evm.c|  185 +---
 2 files changed, 231 insertions(+), 20 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt 
b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
new file mode 100644
index 000..b248014
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
@@ -0,0 +1,66 @@
+* Texas Instruments SoC audio setups with TLV320AIC3X Codec
+
+Required properties:
+- compatible : ti,davinci-evm-audio
+- ti,model : The user-visible name of this sound complex.
+- ti,audio-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. Valid names for sources and
+  sinks are the codec's pins, and the jacks on the board:
+
+  Codec pins:
+
+  * MIC3L
+  * MIC3R
+  * LINE1L
+  * LINE2L
+  * LINE1R
+  * LINE2R
+
+  Board connectors:
+
+  * Headphone Jack
+  * Line Out
+  * Mic Jack
+
+- ti,mcasp-controller : The phandle of the McASP controller
+- ti,audio-codec : The phandle of the TLV320AIC3x audio codec
+- ti,codec-clock-rate : The Codec Clock rate (in Hz) applied to the Codec
+
+- dai-data : A list of DAI data used by SOC code to register
+ DAI, Codecs platform.
+ The string index should be as shown below.
+dai-data =
+DAI Name,  DAI Stream Name,
+CODEC DAI Name,true if evm_aic3x_init is required, else false,
+evm ops required (evm_ops or evm_spdif_ops);
+
+Here fields
+DAI Name   : used to indicate the DAI Name
+DAI Stream Name: used to indicate the Stream Name
+CODEC DAI Name : used to bind the link between Codec DAI and ASOC DAI
+
+Machine related options
+true/false : Whether the machine specific initialization
+   : evm_aic3x_init() is required
+
+evm ops required   : Which hardware ops function is to be used.
+   : (evm_ops or evm_spdif_ops)
+   : use evm-spdif-ops if DAI is working in DIT mode
+   : else use evm-ops. These ops setup hw param callbacks
+   : which are used to setup CODEC/cpu DAI configuration
+   : and codec system clock.
+
+Example:
+
+sound {
+   compatible = ti,davinci-evm-audio;
+   ti,model = DA830 EVM;
+   ti,audio-codec = tlv320aic3x;
+   ti,mcasp-controller = mcasp1;
+   ti,codec-clock-rate = 1200;
+   dai-data =
+   TLV320AIC3X,  AIC3X,
+   tlv320aic3x-hifi, true,
+   evm-ops;
+};
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index d55e647..2af8110 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -34,27 +34,38 @@ static int evm_hw_params(struct snd_pcm_substream 
*substream,
struct snd_soc_pcm_runtime *rtd = substream-private_data;
struct snd_soc_dai *codec_dai = rtd-codec_dai;
struct snd_soc_dai *cpu_dai = rtd-cpu_dai;
+   struct snd_soc_codec *codec = rtd-codec;
+   struct snd_soc_card *soc_card = codec-card;
+   struct device_node *np = soc_card-dev-of_node;
int ret = 0;
unsigned sysclk;
 
-   /* ASP1 on DM355 EVM is clocked by an external oscillator */
-   if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm() ||
-   machine_is_davinci_dm365_evm())
-   sysclk = 2700;
-
-   /* ASP0 in DM6446 EVM is clocked by U55, as configured by
-* board-dm644x-evm.c using GPIOs from U18.  There are six
-* options; here we know we use a 48 KHz sample rate.
-*/
-   else if (machine_is_davinci_evm())
-   sysclk = 12288000;
-
-   else if (machine_is_davinci_da830_evm() ||
-   machine_is_davinci_da850_evm())
-   sysclk = 24576000;
-
-   else
-   return -EINVAL;
+   if (np) {
+   ret = of_property_read_u32(np, ti,codec-clock-rate, sysclk

RE: [PATCH V3] mmc: omap_hsmmc: Enable HSPE bit for high speed cards

2012-11-04 Thread Hebbar, Gururaja
On Thu, Nov 01, 2012 at 01:46:26, Balbi, Felipe wrote:
 Hi,
 
 On Thu, Nov 01, 2012 at 01:21:36AM +0530, Venkatraman S wrote:
  On Wed, Oct 31, 2012 at 5:56 PM, Felipe Balbi ba...@ti.com wrote:
   Hi,
  
   On Wed, Oct 31, 2012 at 05:27:36PM +0530, Hebbar, Gururaja wrote:
   HSMMC IP on AM33xx need a special setting to handle High-speed cards.
   Other platforms like TI81xx, OMAP4 may need this as-well. This depends
   on the HSMMC IP timing closure done for the high speed cards.
  
   From AM335x TRM (SPRUH73F - 18.3.12 Output Signals Generation)
  
   The MMC/SD/SDIO output signals can be driven on either falling edge or
   rising edge depending on the SD_HCTL[2] HSPE bit. This feature allows
   to reach better timing performance, and thus to increase data transfer
   frequency.
  
   There are few pre-requisites for enabling the HSPE bit
   - Controller should support High-Speed-Enable Bit and
   - Controller should not be using DDR Mode and
   - Controller should advertise that it supports High Speed in
 capabilities register and
   - MMC/SD clock coming out of controller  25MHz
  
   Note:
   The implementation reuses the output of calc_divisor() so as to reduce
   code addition.
  
   Signed-off-by: Hebbar, Gururaja gururaja.heb...@ti.com
  
   this looks good to my eyes, hopefully I haven't missed anything:
  
   Reviewed-by: Felipe Balbi ba...@ti.com
  
  
  Except for the excessively verbose comments which are just duplicating the 
  code,
  Quote
   +  * Enable High-Speed Support
   +  * Pre-Requisites
   +  *  - Controller should support High-Speed-Enable Bit
   +  *  - Controller should not be using DDR Mode
   +  *  - Controller should advertise that it supports High Speed
   +  *in capabilities register
   +  *  - MMC/SD clock coming out of controller  25MHz
   +  */
  /Quote
  
  I'm ok with this patch as well. I'm putting a few patches under test
  including this one,
  and will send it to Chris as part of that series.
  I'll strip out the above mentioned comments, unless there are any
  objections.
 
 please don't. Detailing the pre-requisites for getting HSP mode working
 isn't bad at all. Should someone decide to change the behavior and ends
 up breaking it, the comment will help putting things back together.
 
 my 2 cents, you've got the final decision though.

Same here. Description is required in commit message since it will help
in during git bisect.

 
 -- 
 balbi
 


Regards, 
Gururaja
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


RE: [RFC PATCH v3 00/16] DMA Engine support for AM33XX

2012-11-04 Thread Hebbar, Gururaja
On Thu, Oct 18, 2012 at 18:56:39, Porter, Matt wrote:

...snip...
...snip...
...snip...

 
 This series adds DMA Engine support for AM33xx, which uses
 an EDMA DMAC. The EDMA DMAC has been previously supported by only
 a private API implementation (much like the situation with OMAP
 DMA) found on the DaVinci family of SoCs.
 
 The series applies on top of 3.7-rc1 and the following patches:
 
   - GPMC fails to reserve memory fix:
 http://www.spinics.net/lists/linux-omap/msg79675.html
   - TPS65910 regulator fix:
 https://patchwork.kernel.org/patch/1593651/
   - dmaengine DT support from Vinod's dmaengine_dt branch in
 git://git.infradead.org/users/vkoul/slave-dma.git since
 027478851791df751176398be02a3b1c5f6aa824
 
 The approach taken is similar to how OMAP DMA is being converted to
 DMA Engine support. With the functional EDMA private API already
 existing in mach-davinci/dma.c, we first move that to an ARM common
 area so it can be shared. Adding DT and runtime PM support to the
 private EDMA API implementation allows it to run on AM33xx. AM33xx
 *only* boots using DT so we leverage Jon's generic DT DMA helpers to
 register EDMA DMAC with the of_dma framework and then add support
 for calling the dma_request_slave_channel() API to both the mmc
 and spi drivers.
 
 With this series both BeagleBone and the AM335x EVM have working
 MMC and SPI support.
 
 This is tested on BeagleBone with a SPI framebuffer driver and MMC
 rootfs. A trivial gpio DMA event misc driver was used to test the
 crossbar DMA event support. It is also tested on the AM335x EVM
 with the onboard SPI flash and MMC rootfs. The branch at
 https://github.com/ohporter/linux/tree/edma-dmaengine-v3 has the
 complete series, dependencies, and some test drivers/defconfigs.
 
 Regression testing was done on AM180x-EVM (which also makes use
 of the EDMA dmaengine driver and the EDMA private API) using SD,
 SPI flash, and the onboard audio supported by the ASoC Davinci
 driver.

Since you have tested MMC, and probably will be adding Audio support
for AM335x as well, I believe you will also be adding Pin-mux support
for both the modules.

Can you share your plan to release the next version? 
I have few patches pending for AM335x Audio (DT related). 

Thanks in advance

Regards
Gururaja

 
 After this series, the plan is to convert the last in-tree user
 of the private EDMA API (davinci-pcm/mcasp) and then eliminate
 the private EDMA API by folding its functionality into
 drivers/dma/edma.c.
 
 Matt Porter (16):
   dmaengine: edma: fix slave config dependency on direction
   ARM: davinci: move private EDMA API to arm/common
   ARM: edma: remove unused transfer controller handlers
   ARM: edma: add DT and runtime PM support for AM33XX
   ARM: edma: add AM33XX crossbar event support
   dmaengine: edma: enable build for AM33XX
   dmaengine: edma: Add TI EDMA device tree binding
   ARM: dts: add AM33XX EDMA support
   dmaengine: add dma_request_slave_channel_compat()
   mmc: omap_hsmmc: convert to dma_request_slave_channel_compat()
   mmc: omap_hsmmc: limit max_segs with the EDMA DMAC
   mmc: omap_hsmmc: add generic DMA request support to the DT binding
   ARM: dts: add AM33XX MMC support
   spi: omap2-mcspi: convert to dma_request_slave_channel_compat()
   spi: omap2-mcspi: add generic DMA request support to the DT binding
   ARM: dts: add AM33XX SPI support
 
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss