Re: [PATCH] omap3: make coresight register save across OFF modes a sysfs option

2010-07-26 Thread Alexander Shishkin
On Mon, Jul 26, 2010 at 02:01:14 +0530, Shilimkar, Santosh wrote:
> 
> 
> > -Original Message-
> > From: Alexander Shishkin [mailto:virtu...@slind.org]
> > Sent: Monday, July 26, 2010 1:02 PM
> > To: Shilimkar, Santosh
> > Cc: Hari Kanigeri; linux-arm-ker...@lists.infradead.org; Tony Lindgren;
> > Russell King; Paul Walmsley; Kevin Hilman; linux-omap@vger.kernel.org;
> > linux-ker...@vger.kernel.org
> > Subject: Re: [PATCH] omap3: make coresight register save across OFF modes
> > a sysfs option
> > 
> > On Mon, Jul 26, 2010 at 12:28:38 +0530, Shilimkar, Santosh wrote:
> > > > -Original Message-
> > > > From: linux-omap-ow...@vger.kernel.org [mailto:linux-omap-
> > > > ow...@vger.kernel.org] On Behalf Of Alexander Shishkin
> > > > Sent: Monday, July 26, 2010 2:34 AM
> > > > To: Hari Kanigeri
> > > > Cc: Alexander Shishkin; linux-arm-ker...@lists.infradead.org; Tony
> > > > Lindgren; Russell King; Paul Walmsley; Kevin Hilman; linux-
> > > > o...@vger.kernel.org; linux-ker...@vger.kernel.org
> > > > Subject: [PATCH] omap3: make coresight register save across OFF modes
> > a
> > > > sysfs option
> > > >
> > > > This adds a sysfs file at /sys/power/coresight_save which is used to
> > > > control if the ETM and debug components' states should be saved and
> > > > restored across OFF modes.
> > > >
> > > > Signed-off-by: Alexander Shishkin 
> > > > Cc: Tony Lindgren 
> > > > Cc: Russell King 
> > > > Cc: Paul Walmsley 
> > > > Cc: Kevin Hilman 
> > > > Cc: linux-omap@vger.kernel.org
> > > > Cc: linux-arm-ker...@lists.infradead.org
> > > > Cc: linux-ker...@vger.kernel.org
> > > > ---
> > > >  arch/arm/mach-omap2/Makefile|1 +
> > > >  arch/arm/mach-omap2/debug34xx.c |   66
> > > > +++
> > > >  arch/arm/mach-omap2/pm.h|6 +++
> > > >  arch/arm/mach-omap2/pm34xx.c|3 ++
> > > >  4 files changed, 76 insertions(+), 0 deletions(-)
> > > >  create mode 100644 arch/arm/mach-omap2/debug34xx.c
> > > >
> > > > diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-
> > omap2/Makefile
> > > > index f5b4ff4..3a64ce4 100644
> > > > --- a/arch/arm/mach-omap2/Makefile
> > > > +++ b/arch/arm/mach-omap2/Makefile
> > > > @@ -49,6 +49,7 @@ ifeq ($(CONFIG_PM),y)
> > > >  obj-$(CONFIG_ARCH_OMAP2)   += pm24xx.o
> > > >  obj-$(CONFIG_ARCH_OMAP2)   += sleep24xx.o
> > > >  obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o 
> > > > cpuidle34xx.o
> > > > +obj-$(CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG) += debug34xx.o
> > > >  obj-$(CONFIG_PM_DEBUG) += pm-debug.o
> > > >
> > > >  AFLAGS_sleep24xx.o :=-Wa,-march=armv6
> > > > diff --git a/arch/arm/mach-omap2/debug34xx.c b/arch/arm/mach-
> > > > omap2/debug34xx.c
> > > > new file mode 100644
> > > > index 000..698e83a
> > > > --- /dev/null
> > > > +++ b/arch/arm/mach-omap2/debug34xx.c
> > >
> > > > @@ -0,0 +1,66 @@
> > > > +/*
> > > > + * Control saving and restoring of coresight components' state during
> > > > + * OFF mode.
> > > > + *
> > > > + * Copyright (C) 2010 Nokia Corporation
> > > > + * Alexander Shishkin
> > > > + *
> > > > + * This program is free software; you can redistribute it and/or
> > modify
> > > > + * it under the terms of the GNU General Public License version 2 as
> > > > + * published by the Free Software Foundation.
> > > > + */
> > > > +
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +
> > > > +#include "pm.h"
> > > > +
> > > > +/*
> > > > + * Pointer to a place in sram where the ETM/debug state save
> > > > + * flag is. It can be calculated after the omap_sram_idle is
> > > > + * pushed to sram.
> > > > + */
> > > > +static unsigned int *_etm_save;
> > > > +
> > > > +/*
> > > > + * sysfs file /sys/power/coresight_save controls whether the
> > > > + * state of coresight components should be saved and restored
> > > > +

RE: [PATCH] omap3: make coresight register save across OFF modes a sysfs option

2010-07-26 Thread Shilimkar, Santosh


> -Original Message-
> From: Alexander Shishkin [mailto:virtu...@slind.org]
> Sent: Monday, July 26, 2010 1:02 PM
> To: Shilimkar, Santosh
> Cc: Hari Kanigeri; linux-arm-ker...@lists.infradead.org; Tony Lindgren;
> Russell King; Paul Walmsley; Kevin Hilman; linux-omap@vger.kernel.org;
> linux-ker...@vger.kernel.org
> Subject: Re: [PATCH] omap3: make coresight register save across OFF modes
> a sysfs option
> 
> On Mon, Jul 26, 2010 at 12:28:38 +0530, Shilimkar, Santosh wrote:
> > > -Original Message-
> > > From: linux-omap-ow...@vger.kernel.org [mailto:linux-omap-
> > > ow...@vger.kernel.org] On Behalf Of Alexander Shishkin
> > > Sent: Monday, July 26, 2010 2:34 AM
> > > To: Hari Kanigeri
> > > Cc: Alexander Shishkin; linux-arm-ker...@lists.infradead.org; Tony
> > > Lindgren; Russell King; Paul Walmsley; Kevin Hilman; linux-
> > > o...@vger.kernel.org; linux-ker...@vger.kernel.org
> > > Subject: [PATCH] omap3: make coresight register save across OFF modes
> a
> > > sysfs option
> > >
> > > This adds a sysfs file at /sys/power/coresight_save which is used to
> > > control if the ETM and debug components' states should be saved and
> > > restored across OFF modes.
> > >
> > > Signed-off-by: Alexander Shishkin 
> > > Cc: Tony Lindgren 
> > > Cc: Russell King 
> > > Cc: Paul Walmsley 
> > > Cc: Kevin Hilman 
> > > Cc: linux-omap@vger.kernel.org
> > > Cc: linux-arm-ker...@lists.infradead.org
> > > Cc: linux-ker...@vger.kernel.org
> > > ---
> > >  arch/arm/mach-omap2/Makefile|1 +
> > >  arch/arm/mach-omap2/debug34xx.c |   66
> > > +++
> > >  arch/arm/mach-omap2/pm.h|6 +++
> > >  arch/arm/mach-omap2/pm34xx.c|3 ++
> > >  4 files changed, 76 insertions(+), 0 deletions(-)
> > >  create mode 100644 arch/arm/mach-omap2/debug34xx.c
> > >
> > > diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-
> omap2/Makefile
> > > index f5b4ff4..3a64ce4 100644
> > > --- a/arch/arm/mach-omap2/Makefile
> > > +++ b/arch/arm/mach-omap2/Makefile
> > > @@ -49,6 +49,7 @@ ifeq ($(CONFIG_PM),y)
> > >  obj-$(CONFIG_ARCH_OMAP2) += pm24xx.o
> > >  obj-$(CONFIG_ARCH_OMAP2) += sleep24xx.o
> > >  obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o cpuidle34xx.o
> > > +obj-$(CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG) += debug34xx.o
> > >  obj-$(CONFIG_PM_DEBUG)   += pm-debug.o
> > >
> > >  AFLAGS_sleep24xx.o   :=-Wa,-march=armv6
> > > diff --git a/arch/arm/mach-omap2/debug34xx.c b/arch/arm/mach-
> > > omap2/debug34xx.c
> > > new file mode 100644
> > > index 000..698e83a
> > > --- /dev/null
> > > +++ b/arch/arm/mach-omap2/debug34xx.c
> >
> > > @@ -0,0 +1,66 @@
> > > +/*
> > > + * Control saving and restoring of coresight components' state during
> > > + * OFF mode.
> > > + *
> > > + * Copyright (C) 2010 Nokia Corporation
> > > + * Alexander Shishkin
> > > + *
> > > + * This program is free software; you can redistribute it and/or
> modify
> > > + * it under the terms of the GNU General Public License version 2 as
> > > + * published by the Free Software Foundation.
> > > + */
> > > +
> > > +#include 
> > > +#include 
> > > +#include 
> > > +
> > > +#include "pm.h"
> > > +
> > > +/*
> > > + * Pointer to a place in sram where the ETM/debug state save
> > > + * flag is. It can be calculated after the omap_sram_idle is
> > > + * pushed to sram.
> > > + */
> > > +static unsigned int *_etm_save;
> > > +
> > > +/*
> > > + * sysfs file /sys/power/coresight_save controls whether the
> > > + * state of coresight components should be saved and restored
> > > + * across OFF modes.
> > > + */
> > > +static ssize_t coresight_save_show(struct kobject *kobj,
> > > +   struct kobj_attribute *attr,
> > > +   char *buf)
> > > +{
> > > + return sprintf(buf, "%u\n", *_etm_save);
> > > +}
> > > +
> > > +static ssize_t coresight_save_store(struct kobject *kobj,
> > > +struct kobj_attribute *attr,
> > > +const char *buf, size_t n)
> > >

Re: [PATCH] omap3: make coresight register save across OFF modes a sysfs option

2010-07-26 Thread Alexander Shishkin
On Mon, Jul 26, 2010 at 12:28:38 +0530, Shilimkar, Santosh wrote:
> > -Original Message-
> > From: linux-omap-ow...@vger.kernel.org [mailto:linux-omap-
> > ow...@vger.kernel.org] On Behalf Of Alexander Shishkin
> > Sent: Monday, July 26, 2010 2:34 AM
> > To: Hari Kanigeri
> > Cc: Alexander Shishkin; linux-arm-ker...@lists.infradead.org; Tony
> > Lindgren; Russell King; Paul Walmsley; Kevin Hilman; linux-
> > o...@vger.kernel.org; linux-ker...@vger.kernel.org
> > Subject: [PATCH] omap3: make coresight register save across OFF modes a
> > sysfs option
> > 
> > This adds a sysfs file at /sys/power/coresight_save which is used to
> > control if the ETM and debug components' states should be saved and
> > restored across OFF modes.
> > 
> > Signed-off-by: Alexander Shishkin 
> > Cc: Tony Lindgren 
> > Cc: Russell King 
> > Cc: Paul Walmsley 
> > Cc: Kevin Hilman 
> > Cc: linux-omap@vger.kernel.org
> > Cc: linux-arm-ker...@lists.infradead.org
> > Cc: linux-ker...@vger.kernel.org
> > ---
> >  arch/arm/mach-omap2/Makefile|1 +
> >  arch/arm/mach-omap2/debug34xx.c |   66
> > +++
> >  arch/arm/mach-omap2/pm.h|6 +++
> >  arch/arm/mach-omap2/pm34xx.c|3 ++
> >  4 files changed, 76 insertions(+), 0 deletions(-)
> >  create mode 100644 arch/arm/mach-omap2/debug34xx.c
> > 
> > diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> > index f5b4ff4..3a64ce4 100644
> > --- a/arch/arm/mach-omap2/Makefile
> > +++ b/arch/arm/mach-omap2/Makefile
> > @@ -49,6 +49,7 @@ ifeq ($(CONFIG_PM),y)
> >  obj-$(CONFIG_ARCH_OMAP2)   += pm24xx.o
> >  obj-$(CONFIG_ARCH_OMAP2)   += sleep24xx.o
> >  obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o cpuidle34xx.o
> > +obj-$(CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG) += debug34xx.o
> >  obj-$(CONFIG_PM_DEBUG) += pm-debug.o
> > 
> >  AFLAGS_sleep24xx.o :=-Wa,-march=armv6
> > diff --git a/arch/arm/mach-omap2/debug34xx.c b/arch/arm/mach-
> > omap2/debug34xx.c
> > new file mode 100644
> > index 000..698e83a
> > --- /dev/null
> > +++ b/arch/arm/mach-omap2/debug34xx.c
> 
> > @@ -0,0 +1,66 @@
> > +/*
> > + * Control saving and restoring of coresight components' state during
> > + * OFF mode.
> > + *
> > + * Copyright (C) 2010 Nokia Corporation
> > + * Alexander Shishkin
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include "pm.h"
> > +
> > +/*
> > + * Pointer to a place in sram where the ETM/debug state save
> > + * flag is. It can be calculated after the omap_sram_idle is
> > + * pushed to sram.
> > + */
> > +static unsigned int *_etm_save;
> > +
> > +/*
> > + * sysfs file /sys/power/coresight_save controls whether the
> > + * state of coresight components should be saved and restored
> > + * across OFF modes.
> > + */
> > +static ssize_t coresight_save_show(struct kobject *kobj,
> > + struct kobj_attribute *attr,
> > + char *buf)
> > +{
> > +   return sprintf(buf, "%u\n", *_etm_save);
> > +}
> > +
> > +static ssize_t coresight_save_store(struct kobject *kobj,
> > +  struct kobj_attribute *attr,
> > +  const char *buf, size_t n)
> > +{
> > +   unsigned int value;
> > +
> > +   if (sscanf(buf, "%u", &value) != 1)
> > +   return -EINVAL;
> > +
> > +   *_etm_save = !!value;
> > +
> > +   return n;
> > +}
> > +
> > +static struct kobj_attribute coresight_save_attr =
> > +   __ATTR(coresight_save, 0644, coresight_save_show,
> > coresight_save_store);
> > +
> > +int omap3_coresight_pm_init(void *sram_addr)
> > +{
> > +   int ret;
> > +
> > +   /* the last word from the top of omap_sram_idle */
> > +   _etm_save = (unsigned *)((u8 *)sram_addr + omap34xx_cpu_suspend_sz -
> > 4);
> > +
> > +   ret = sysfs_create_file(power_kobj, &coresight_save_attr.attr);
> > +
> > +   return ret;
> > +}
> 
> Looking at content of this file, I think you can keep this under common 
> pm-debug.c file. 
> Any problems with that ?

I was trying to avoid #ifdeffing too much and I didn't want this code to
compile at all when CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG is not set.
Otherwise, no problems.

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


RE: [PATCH] omap3: make coresight register save across OFF modes a sysfs option

2010-07-25 Thread Shilimkar, Santosh
> -Original Message-
> From: linux-omap-ow...@vger.kernel.org [mailto:linux-omap-
> ow...@vger.kernel.org] On Behalf Of Alexander Shishkin
> Sent: Monday, July 26, 2010 2:34 AM
> To: Hari Kanigeri
> Cc: Alexander Shishkin; linux-arm-ker...@lists.infradead.org; Tony
> Lindgren; Russell King; Paul Walmsley; Kevin Hilman; linux-
> o...@vger.kernel.org; linux-ker...@vger.kernel.org
> Subject: [PATCH] omap3: make coresight register save across OFF modes a
> sysfs option
> 
> This adds a sysfs file at /sys/power/coresight_save which is used to
> control if the ETM and debug components' states should be saved and
> restored across OFF modes.
> 
> Signed-off-by: Alexander Shishkin 
> Cc: Tony Lindgren 
> Cc: Russell King 
> Cc: Paul Walmsley 
> Cc: Kevin Hilman 
> Cc: linux-omap@vger.kernel.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-ker...@vger.kernel.org
> ---
>  arch/arm/mach-omap2/Makefile|1 +
>  arch/arm/mach-omap2/debug34xx.c |   66
> +++
>  arch/arm/mach-omap2/pm.h|6 +++
>  arch/arm/mach-omap2/pm34xx.c|3 ++
>  4 files changed, 76 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/mach-omap2/debug34xx.c
> 
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index f5b4ff4..3a64ce4 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -49,6 +49,7 @@ ifeq ($(CONFIG_PM),y)
>  obj-$(CONFIG_ARCH_OMAP2) += pm24xx.o
>  obj-$(CONFIG_ARCH_OMAP2) += sleep24xx.o
>  obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o cpuidle34xx.o
> +obj-$(CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG) += debug34xx.o
>  obj-$(CONFIG_PM_DEBUG)   += pm-debug.o
> 
>  AFLAGS_sleep24xx.o   :=-Wa,-march=armv6
> diff --git a/arch/arm/mach-omap2/debug34xx.c b/arch/arm/mach-
> omap2/debug34xx.c
> new file mode 100644
> index 000..698e83a
> --- /dev/null
> +++ b/arch/arm/mach-omap2/debug34xx.c

> @@ -0,0 +1,66 @@
> +/*
> + * Control saving and restoring of coresight components' state during
> + * OFF mode.
> + *
> + * Copyright (C) 2010 Nokia Corporation
> + * Alexander Shishkin
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +#include "pm.h"
> +
> +/*
> + * Pointer to a place in sram where the ETM/debug state save
> + * flag is. It can be calculated after the omap_sram_idle is
> + * pushed to sram.
> + */
> +static unsigned int *_etm_save;
> +
> +/*
> + * sysfs file /sys/power/coresight_save controls whether the
> + * state of coresight components should be saved and restored
> + * across OFF modes.
> + */
> +static ssize_t coresight_save_show(struct kobject *kobj,
> +   struct kobj_attribute *attr,
> +   char *buf)
> +{
> + return sprintf(buf, "%u\n", *_etm_save);
> +}
> +
> +static ssize_t coresight_save_store(struct kobject *kobj,
> +struct kobj_attribute *attr,
> +const char *buf, size_t n)
> +{
> + unsigned int value;
> +
> + if (sscanf(buf, "%u", &value) != 1)
> + return -EINVAL;
> +
> + *_etm_save = !!value;
> +
> + return n;
> +}
> +
> +static struct kobj_attribute coresight_save_attr =
> + __ATTR(coresight_save, 0644, coresight_save_show,
> coresight_save_store);
> +
> +int omap3_coresight_pm_init(void *sram_addr)
> +{
> + int ret;
> +
> + /* the last word from the top of omap_sram_idle */
> + _etm_save = (unsigned *)((u8 *)sram_addr + omap34xx_cpu_suspend_sz -
> 4);
> +
> + ret = sysfs_create_file(power_kobj, &coresight_save_attr.attr);
> +
> + return ret;
> +}

Looking at content of this file, I think you can keep this under common 
pm-debug.c file. 
Any problems with that ?
> +
> diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
> index 3de6ece..0321834 100644
> --- a/arch/arm/mach-omap2/pm.h
> +++ b/arch/arm/mach-omap2/pm.h
> @@ -76,6 +76,12 @@ extern void omap34xx_cpu_suspend(u32 *addr, int
> save_state);
>  extern void save_secure_ram_context(u32 *addr);
>  extern void omap3_save_scratchpad_contents(void);
> 
> +#ifdef CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG
> +int omap3_coresight_pm_init(void *sram_addr);
> +#else
> +#define omap3_coresight_pm_init(x) do {} while (0)
> +#

Re: [PATCH] omap3: make coresight register save across OFF modes a sysfs option

2010-07-25 Thread Alexander Shishkin
On Mon, Jul 26, 2010 at 12:04:23 +0300, Alexander Shishkin wrote:
> This adds a sysfs file at /sys/power/coresight_save which is used to
> control if the ETM and debug components' states should be saved and
> restored across OFF modes.

Oops, I wanted to resend the previous patch, but it's getting late here.
Sorry for the spam.

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


[PATCH] omap3: make coresight register save across OFF modes a sysfs option

2010-07-25 Thread Alexander Shishkin
This adds a sysfs file at /sys/power/coresight_save which is used to
control if the ETM and debug components' states should be saved and
restored across OFF modes.

Signed-off-by: Alexander Shishkin 
Cc: Tony Lindgren 
Cc: Russell King 
Cc: Paul Walmsley 
Cc: Kevin Hilman 
Cc: linux-omap@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-ker...@vger.kernel.org
---
 arch/arm/mach-omap2/Makefile|1 +
 arch/arm/mach-omap2/debug34xx.c |   66 +++
 arch/arm/mach-omap2/pm.h|6 +++
 arch/arm/mach-omap2/pm34xx.c|3 ++
 4 files changed, 76 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/debug34xx.c

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index f5b4ff4..3a64ce4 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -49,6 +49,7 @@ ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)   += pm24xx.o
 obj-$(CONFIG_ARCH_OMAP2)   += sleep24xx.o
 obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o cpuidle34xx.o
+obj-$(CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG) += debug34xx.o
 obj-$(CONFIG_PM_DEBUG) += pm-debug.o
 
 AFLAGS_sleep24xx.o :=-Wa,-march=armv6
diff --git a/arch/arm/mach-omap2/debug34xx.c b/arch/arm/mach-omap2/debug34xx.c
new file mode 100644
index 000..698e83a
--- /dev/null
+++ b/arch/arm/mach-omap2/debug34xx.c
@@ -0,0 +1,66 @@
+/*
+ * Control saving and restoring of coresight components' state during
+ * OFF mode.
+ *
+ * Copyright (C) 2010 Nokia Corporation
+ * Alexander Shishkin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+
+#include "pm.h"
+
+/*
+ * Pointer to a place in sram where the ETM/debug state save
+ * flag is. It can be calculated after the omap_sram_idle is
+ * pushed to sram.
+ */
+static unsigned int *_etm_save;
+
+/*
+ * sysfs file /sys/power/coresight_save controls whether the
+ * state of coresight components should be saved and restored
+ * across OFF modes.
+ */
+static ssize_t coresight_save_show(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ char *buf)
+{
+   return sprintf(buf, "%u\n", *_etm_save);
+}
+
+static ssize_t coresight_save_store(struct kobject *kobj,
+  struct kobj_attribute *attr,
+  const char *buf, size_t n)
+{
+   unsigned int value;
+
+   if (sscanf(buf, "%u", &value) != 1)
+   return -EINVAL;
+
+   *_etm_save = !!value;
+
+   return n;
+}
+
+static struct kobj_attribute coresight_save_attr =
+   __ATTR(coresight_save, 0644, coresight_save_show, coresight_save_store);
+
+int omap3_coresight_pm_init(void *sram_addr)
+{
+   int ret;
+
+   /* the last word from the top of omap_sram_idle */
+   _etm_save = (unsigned *)((u8 *)sram_addr + omap34xx_cpu_suspend_sz - 4);
+
+   ret = sysfs_create_file(power_kobj, &coresight_save_attr.attr);
+
+   return ret;
+}
+
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 3de6ece..0321834 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -76,6 +76,12 @@ extern void omap34xx_cpu_suspend(u32 *addr, int save_state);
 extern void save_secure_ram_context(u32 *addr);
 extern void omap3_save_scratchpad_contents(void);
 
+#ifdef CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG
+int omap3_coresight_pm_init(void *sram_addr);
+#else
+#define omap3_coresight_pm_init(x) do {} while (0)
+#endif
+
 extern unsigned int omap24xx_idle_loop_suspend_sz;
 extern unsigned int omap34xx_suspend_sz;
 extern unsigned int save_secure_ram_context_sz;
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index fb4994a..c389e65 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -1096,6 +1096,9 @@ static int __init omap3_pm_init(void)
core_clkdm = clkdm_lookup("core_clkdm");
 
omap_push_sram_idle();
+
+   omap3_coresight_pm_init(_omap_sram_idle);
+
 #ifdef CONFIG_SUSPEND
suspend_set_ops(&omap_pm_ops);
 #endif /* CONFIG_SUSPEND */
-- 
1.7.1

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