Re: [PATCHv5 1/2] ARM: socfpga: support suspend to ram

2015-05-29 Thread atull
On Fri, 29 May 2015, Dinh Nguyen wrote:

> 
> 
> On 5/28/15 4:19 PM, Alan Tull wrote:
> > Add code that requests that the sdr controller go into
> > self-refresh mode.  This code is run from ocram.
> > 
> > Suspend-to-RAM and EDAC support are mutually exclusive on
> > SOCFPGA.  If the EDAC is enabled, it will prevent the
> > platform from going into suspend.
> > 
> > Example of how to request to suspend to ram:
> >  $ echo enabled > \
> > /sys/devices/soc/ffc02000.serial0/tty/ttyS0/power/wakeup
> > 
> >  $ echo -n mem > /sys/power/state
> > 
> > Signed-off-by: Alan Tull 
> > Cc: Pavel Machek 
> > Cc: Arnd Bergmann 
> > Cc: Dinh Nguyen 
> > Cc: Steffen Trumtrar 
> > ---
> > v2: use Generic on-chip SRAM driver to allocate ocram
> > rm fncpy_align since generic allocator handles alignment
> > check __arm_ioremap_exec return code
> > check for NULL pointers
> > add a comment regarding sdram controller configuration
> > v3: fix renamed #define
> > propagate socfpga_setup_ocram_self_refresh error code
> > v4: Kconfig: don't need to select GENERIC_ALLOCATER
> > add CONFIG_SOCFPGA_SUSPEND
> > make s2r and EDAC support mutually exclusive
> > socfpga.c: add sdr_ctl_base_addr
> > return error if ocram not available in device tree
> > update copyright years
> > v5: remove compile time dependency
> > edac driver will prevent suspend
> > don't configure scu standby mode; done in enable_scu().
> > fix comments about required sdram controller configuration
> > ---
> >  arch/arm/mach-socfpga/Kconfig|   10 ++-
> >  arch/arm/mach-socfpga/Makefile   |1 +
> >  arch/arm/mach-socfpga/core.h |6 +-
> >  arch/arm/mach-socfpga/pm.c   |  149 
> > ++
> >  arch/arm/mach-socfpga/self-refresh.S |  136 +++
> >  arch/arm/mach-socfpga/socfpga.c  |6 +-
> >  drivers/edac/altera_edac.c   |   20 +
> >  7 files changed, 325 insertions(+), 3 deletions(-)
> >  create mode 100644 arch/arm/mach-socfpga/pm.c
> >  create mode 100644 arch/arm/mach-socfpga/self-refresh.S
> > 
> 
> Which branch are you basing this patch on? I got a trivial patch
> conflict in Kconfig when I applied to arm-soc/for-next and v4.1-rc5.
> 
> Also, I'm getting these sparse warnings:
> 
> arch/arm/mach-socfpga/pm.c:86:25: warning: incorrect type in argument 1
> (different address spaces)
> arch/arm/mach-socfpga/pm.c:86:25:expected void *
> arch/arm/mach-socfpga/pm.c:86:25:got void [noderef]
> *[assigned] suspend_ocram_base
> arch/arm/mach-socfpga/pm.c:108:52: warning: cast removes address space
> of expression
> 
> Dinh
> 

The problem is that fncpy wants parameter 1 to be void* and 
__arm_ioremap_exec wants 'void __ioram *'.

I get other warnings if I declare 'void *suspend_ocram_base' or cast it as
(void *) for fncpy().  It looks like we are stuck with this warning.

However sparse kindly pointed out that I needed to fix a declaration in
altera_edac.c:

-const struct dev_pm_ops altr_sdram_pm_ops = {
+static const struct dev_pm_ops altr_sdram_pm_ops = {

I'll fix that in the next rev.

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv5 1/2] ARM: socfpga: support suspend to ram

2015-05-29 Thread atull
On Fri, 29 May 2015, Dinh Nguyen wrote:

> 
> 
> On 5/28/15 4:19 PM, Alan Tull wrote:
> > Add code that requests that the sdr controller go into
> > self-refresh mode.  This code is run from ocram.
> > 
> > Suspend-to-RAM and EDAC support are mutually exclusive on
> > SOCFPGA.  If the EDAC is enabled, it will prevent the
> > platform from going into suspend.
> > 
> > Example of how to request to suspend to ram:
> >  $ echo enabled > \
> > /sys/devices/soc/ffc02000.serial0/tty/ttyS0/power/wakeup
> > 
> >  $ echo -n mem > /sys/power/state
> > 
> > Signed-off-by: Alan Tull 
> > Cc: Pavel Machek 
> > Cc: Arnd Bergmann 
> > Cc: Dinh Nguyen 
> > Cc: Steffen Trumtrar 
> > ---
> > v2: use Generic on-chip SRAM driver to allocate ocram
> > rm fncpy_align since generic allocator handles alignment
> > check __arm_ioremap_exec return code
> > check for NULL pointers
> > add a comment regarding sdram controller configuration
> > v3: fix renamed #define
> > propagate socfpga_setup_ocram_self_refresh error code
> > v4: Kconfig: don't need to select GENERIC_ALLOCATER
> > add CONFIG_SOCFPGA_SUSPEND
> > make s2r and EDAC support mutually exclusive
> > socfpga.c: add sdr_ctl_base_addr
> > return error if ocram not available in device tree
> > update copyright years
> > v5: remove compile time dependency
> > edac driver will prevent suspend
> > don't configure scu standby mode; done in enable_scu().
> > fix comments about required sdram controller configuration
> > ---
> >  arch/arm/mach-socfpga/Kconfig|   10 ++-
> >  arch/arm/mach-socfpga/Makefile   |1 +
> >  arch/arm/mach-socfpga/core.h |6 +-
> >  arch/arm/mach-socfpga/pm.c   |  149 
> > ++
> >  arch/arm/mach-socfpga/self-refresh.S |  136 +++
> >  arch/arm/mach-socfpga/socfpga.c  |6 +-
> >  drivers/edac/altera_edac.c   |   20 +
> >  7 files changed, 325 insertions(+), 3 deletions(-)
> >  create mode 100644 arch/arm/mach-socfpga/pm.c
> >  create mode 100644 arch/arm/mach-socfpga/self-refresh.S
> > 
> 
> Which branch are you basing this patch on? I got a trivial patch
> conflict in Kconfig when I applied to arm-soc/for-next and v4.1-rc5.

Based on your socfpga_for_next_arria10 branch from 
git://git.kernel.org/pub/scm/linux/kernel/git/dinguyen/linux.git

> 
> Also, I'm getting these sparse warnings:
> 
> arch/arm/mach-socfpga/pm.c:86:25: warning: incorrect type in argument 1
> (different address spaces)
> arch/arm/mach-socfpga/pm.c:86:25:expected void *
> arch/arm/mach-socfpga/pm.c:86:25:got void [noderef]
> *[assigned] suspend_ocram_base
> arch/arm/mach-socfpga/pm.c:108:52: warning: cast removes address space
> of expression
> 
> Dinh
> 

It appears to want suspend_ocram_base to be void * instead of void 
__iomem *.

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv5 1/2] ARM: socfpga: support suspend to ram

2015-05-29 Thread atull
On Fri, 29 May 2015, Dinh Nguyen wrote:

 
 
 On 5/28/15 4:19 PM, Alan Tull wrote:
  Add code that requests that the sdr controller go into
  self-refresh mode.  This code is run from ocram.
  
  Suspend-to-RAM and EDAC support are mutually exclusive on
  SOCFPGA.  If the EDAC is enabled, it will prevent the
  platform from going into suspend.
  
  Example of how to request to suspend to ram:
   $ echo enabled  \
  /sys/devices/soc/ffc02000.serial0/tty/ttyS0/power/wakeup
  
   $ echo -n mem  /sys/power/state
  
  Signed-off-by: Alan Tull at...@opensource.altera.com
  Cc: Pavel Machek pa...@denx.de
  Cc: Arnd Bergmann a...@arndb.de
  Cc: Dinh Nguyen dingu...@opensource.altera.com
  Cc: Steffen Trumtrar s.trumt...@pengutronix.de
  ---
  v2: use Generic on-chip SRAM driver to allocate ocram
  rm fncpy_align since generic allocator handles alignment
  check __arm_ioremap_exec return code
  check for NULL pointers
  add a comment regarding sdram controller configuration
  v3: fix renamed #define
  propagate socfpga_setup_ocram_self_refresh error code
  v4: Kconfig: don't need to select GENERIC_ALLOCATER
  add CONFIG_SOCFPGA_SUSPEND
  make s2r and EDAC support mutually exclusive
  socfpga.c: add sdr_ctl_base_addr
  return error if ocram not available in device tree
  update copyright years
  v5: remove compile time dependency
  edac driver will prevent suspend
  don't configure scu standby mode; done in enable_scu().
  fix comments about required sdram controller configuration
  ---
   arch/arm/mach-socfpga/Kconfig|   10 ++-
   arch/arm/mach-socfpga/Makefile   |1 +
   arch/arm/mach-socfpga/core.h |6 +-
   arch/arm/mach-socfpga/pm.c   |  149 
  ++
   arch/arm/mach-socfpga/self-refresh.S |  136 +++
   arch/arm/mach-socfpga/socfpga.c  |6 +-
   drivers/edac/altera_edac.c   |   20 +
   7 files changed, 325 insertions(+), 3 deletions(-)
   create mode 100644 arch/arm/mach-socfpga/pm.c
   create mode 100644 arch/arm/mach-socfpga/self-refresh.S
  
 
 Which branch are you basing this patch on? I got a trivial patch
 conflict in Kconfig when I applied to arm-soc/for-next and v4.1-rc5.

Based on your socfpga_for_next_arria10 branch from 
git://git.kernel.org/pub/scm/linux/kernel/git/dinguyen/linux.git

 
 Also, I'm getting these sparse warnings:
 
 arch/arm/mach-socfpga/pm.c:86:25: warning: incorrect type in argument 1
 (different address spaces)
 arch/arm/mach-socfpga/pm.c:86:25:expected void *noident
 arch/arm/mach-socfpga/pm.c:86:25:got void [noderef]
 asn:2*[assigned] suspend_ocram_base
 arch/arm/mach-socfpga/pm.c:108:52: warning: cast removes address space
 of expression
 
 Dinh
 

It appears to want suspend_ocram_base to be void * instead of void 
__iomem *.

Alan
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv5 1/2] ARM: socfpga: support suspend to ram

2015-05-29 Thread atull
On Fri, 29 May 2015, Dinh Nguyen wrote:

 
 
 On 5/28/15 4:19 PM, Alan Tull wrote:
  Add code that requests that the sdr controller go into
  self-refresh mode.  This code is run from ocram.
  
  Suspend-to-RAM and EDAC support are mutually exclusive on
  SOCFPGA.  If the EDAC is enabled, it will prevent the
  platform from going into suspend.
  
  Example of how to request to suspend to ram:
   $ echo enabled  \
  /sys/devices/soc/ffc02000.serial0/tty/ttyS0/power/wakeup
  
   $ echo -n mem  /sys/power/state
  
  Signed-off-by: Alan Tull at...@opensource.altera.com
  Cc: Pavel Machek pa...@denx.de
  Cc: Arnd Bergmann a...@arndb.de
  Cc: Dinh Nguyen dingu...@opensource.altera.com
  Cc: Steffen Trumtrar s.trumt...@pengutronix.de
  ---
  v2: use Generic on-chip SRAM driver to allocate ocram
  rm fncpy_align since generic allocator handles alignment
  check __arm_ioremap_exec return code
  check for NULL pointers
  add a comment regarding sdram controller configuration
  v3: fix renamed #define
  propagate socfpga_setup_ocram_self_refresh error code
  v4: Kconfig: don't need to select GENERIC_ALLOCATER
  add CONFIG_SOCFPGA_SUSPEND
  make s2r and EDAC support mutually exclusive
  socfpga.c: add sdr_ctl_base_addr
  return error if ocram not available in device tree
  update copyright years
  v5: remove compile time dependency
  edac driver will prevent suspend
  don't configure scu standby mode; done in enable_scu().
  fix comments about required sdram controller configuration
  ---
   arch/arm/mach-socfpga/Kconfig|   10 ++-
   arch/arm/mach-socfpga/Makefile   |1 +
   arch/arm/mach-socfpga/core.h |6 +-
   arch/arm/mach-socfpga/pm.c   |  149 
  ++
   arch/arm/mach-socfpga/self-refresh.S |  136 +++
   arch/arm/mach-socfpga/socfpga.c  |6 +-
   drivers/edac/altera_edac.c   |   20 +
   7 files changed, 325 insertions(+), 3 deletions(-)
   create mode 100644 arch/arm/mach-socfpga/pm.c
   create mode 100644 arch/arm/mach-socfpga/self-refresh.S
  
 
 Which branch are you basing this patch on? I got a trivial patch
 conflict in Kconfig when I applied to arm-soc/for-next and v4.1-rc5.
 
 Also, I'm getting these sparse warnings:
 
 arch/arm/mach-socfpga/pm.c:86:25: warning: incorrect type in argument 1
 (different address spaces)
 arch/arm/mach-socfpga/pm.c:86:25:expected void *noident
 arch/arm/mach-socfpga/pm.c:86:25:got void [noderef]
 asn:2*[assigned] suspend_ocram_base
 arch/arm/mach-socfpga/pm.c:108:52: warning: cast removes address space
 of expression
 
 Dinh
 

The problem is that fncpy wants parameter 1 to be void* and 
__arm_ioremap_exec wants 'void __ioram *'.

I get other warnings if I declare 'void *suspend_ocram_base' or cast it as
(void *) for fncpy().  It looks like we are stuck with this warning.

However sparse kindly pointed out that I needed to fix a declaration in
altera_edac.c:

-const struct dev_pm_ops altr_sdram_pm_ops = {
+static const struct dev_pm_ops altr_sdram_pm_ops = {

I'll fix that in the next rev.

Alan
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv5 1/2] ARM: socfpga: support suspend to ram

2015-05-28 Thread Dinh Nguyen


On 5/28/15 4:19 PM, Alan Tull wrote:
> Add code that requests that the sdr controller go into
> self-refresh mode.  This code is run from ocram.
> 
> Suspend-to-RAM and EDAC support are mutually exclusive on
> SOCFPGA.  If the EDAC is enabled, it will prevent the
> platform from going into suspend.
> 
> Example of how to request to suspend to ram:
>  $ echo enabled > \
> /sys/devices/soc/ffc02000.serial0/tty/ttyS0/power/wakeup
> 
>  $ echo -n mem > /sys/power/state
> 
> Signed-off-by: Alan Tull 
> Cc: Pavel Machek 
> Cc: Arnd Bergmann 
> Cc: Dinh Nguyen 
> Cc: Steffen Trumtrar 
> ---
> v2: use Generic on-chip SRAM driver to allocate ocram
> rm fncpy_align since generic allocator handles alignment
> check __arm_ioremap_exec return code
> check for NULL pointers
> add a comment regarding sdram controller configuration
> v3: fix renamed #define
> propagate socfpga_setup_ocram_self_refresh error code
> v4: Kconfig: don't need to select GENERIC_ALLOCATER
> add CONFIG_SOCFPGA_SUSPEND
> make s2r and EDAC support mutually exclusive
> socfpga.c: add sdr_ctl_base_addr
> return error if ocram not available in device tree
> update copyright years
> v5: remove compile time dependency
> edac driver will prevent suspend
> don't configure scu standby mode; done in enable_scu().
> fix comments about required sdram controller configuration
> ---
>  arch/arm/mach-socfpga/Kconfig|   10 ++-
>  arch/arm/mach-socfpga/Makefile   |1 +
>  arch/arm/mach-socfpga/core.h |6 +-
>  arch/arm/mach-socfpga/pm.c   |  149 
> ++
>  arch/arm/mach-socfpga/self-refresh.S |  136 +++
>  arch/arm/mach-socfpga/socfpga.c  |6 +-
>  drivers/edac/altera_edac.c   |   20 +
>  7 files changed, 325 insertions(+), 3 deletions(-)
>  create mode 100644 arch/arm/mach-socfpga/pm.c
>  create mode 100644 arch/arm/mach-socfpga/self-refresh.S
> 

Which branch are you basing this patch on? I got a trivial patch
conflict in Kconfig when I applied to arm-soc/for-next and v4.1-rc5.

Also, I'm getting these sparse warnings:

arch/arm/mach-socfpga/pm.c:86:25: warning: incorrect type in argument 1
(different address spaces)
arch/arm/mach-socfpga/pm.c:86:25:expected void *
arch/arm/mach-socfpga/pm.c:86:25:got void [noderef]
*[assigned] suspend_ocram_base
arch/arm/mach-socfpga/pm.c:108:52: warning: cast removes address space
of expression

Dinh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv5 1/2] ARM: socfpga: support suspend to ram

2015-05-28 Thread Alan Tull
Add code that requests that the sdr controller go into
self-refresh mode.  This code is run from ocram.

Suspend-to-RAM and EDAC support are mutually exclusive on
SOCFPGA.  If the EDAC is enabled, it will prevent the
platform from going into suspend.

Example of how to request to suspend to ram:
 $ echo enabled > \
/sys/devices/soc/ffc02000.serial0/tty/ttyS0/power/wakeup

 $ echo -n mem > /sys/power/state

Signed-off-by: Alan Tull 
Cc: Pavel Machek 
Cc: Arnd Bergmann 
Cc: Dinh Nguyen 
Cc: Steffen Trumtrar 
---
v2: use Generic on-chip SRAM driver to allocate ocram
rm fncpy_align since generic allocator handles alignment
check __arm_ioremap_exec return code
check for NULL pointers
add a comment regarding sdram controller configuration
v3: fix renamed #define
propagate socfpga_setup_ocram_self_refresh error code
v4: Kconfig: don't need to select GENERIC_ALLOCATER
add CONFIG_SOCFPGA_SUSPEND
make s2r and EDAC support mutually exclusive
socfpga.c: add sdr_ctl_base_addr
return error if ocram not available in device tree
update copyright years
v5: remove compile time dependency
edac driver will prevent suspend
don't configure scu standby mode; done in enable_scu().
fix comments about required sdram controller configuration
---
 arch/arm/mach-socfpga/Kconfig|   10 ++-
 arch/arm/mach-socfpga/Makefile   |1 +
 arch/arm/mach-socfpga/core.h |6 +-
 arch/arm/mach-socfpga/pm.c   |  149 ++
 arch/arm/mach-socfpga/self-refresh.S |  136 +++
 arch/arm/mach-socfpga/socfpga.c  |6 +-
 drivers/edac/altera_edac.c   |   20 +
 7 files changed, 325 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/pm.c
 create mode 100644 arch/arm/mach-socfpga/self-refresh.S

diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig
index b5f8d75..b26a684 100644
--- a/arch/arm/mach-socfpga/Kconfig
+++ b/arch/arm/mach-socfpga/Kconfig
@@ -1,4 +1,4 @@
-config ARCH_SOCFPGA
+menuconfig ARCH_SOCFPGA
bool "Altera SOCFPGA family" if ARCH_MULTI_V7
select ARM_AMBA
select ARM_GIC
@@ -8,3 +8,11 @@ config ARCH_SOCFPGA
select HAVE_ARM_SCU
select HAVE_ARM_TWD if SMP
select MFD_SYSCON
+
+if ARCH_SOCFPGA
+config SOCFPGA_SUSPEND
+   bool "Suspend to RAM on SOCFPGA"
+   help
+ Select this if you want to enable Suspend-to-RAM on SOCFPGA
+ platforms.
+endif
diff --git a/arch/arm/mach-socfpga/Makefile b/arch/arm/mach-socfpga/Makefile
index 6dd7a93..b8f9e23 100644
--- a/arch/arm/mach-socfpga/Makefile
+++ b/arch/arm/mach-socfpga/Makefile
@@ -4,3 +4,4 @@
 
 obj-y  := socfpga.o
 obj-$(CONFIG_SMP)  += headsmp.o platsmp.o
+obj-$(CONFIG_SOCFPGA_SUSPEND)  += pm.o self-refresh.o
diff --git a/arch/arm/mach-socfpga/core.h b/arch/arm/mach-socfpga/core.h
index 7637b7f..35472f2 100644
--- a/arch/arm/mach-socfpga/core.h
+++ b/arch/arm/mach-socfpga/core.h
@@ -1,6 +1,6 @@
 /*
  * Copyright 2012 Pavel Machek 
- * Copyright (C) 2012 Altera Corporation
+ * Copyright (C) 2012-2015 Altera Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -40,6 +40,10 @@ extern void socfpga_sysmgr_init(void);
 
 extern void __iomem *sys_manager_base_addr;
 extern void __iomem *rst_manager_base_addr;
+extern void __iomem *sdr_ctl_base_addr;
+
+u32 socfpga_sdram_self_refresh(u32 sdr_base);
+extern unsigned int socfpga_sdram_self_refresh_sz;
 
 extern struct smp_operations socfpga_smp_ops;
 extern char secondary_trampoline, secondary_trampoline_end;
diff --git a/arch/arm/mach-socfpga/pm.c b/arch/arm/mach-socfpga/pm.c
new file mode 100644
index 000..1ed89fc
--- /dev/null
+++ b/arch/arm/mach-socfpga/pm.c
@@ -0,0 +1,149 @@
+/*
+ *  arch/arm/mach-socfpga/pm.c
+ *
+ * Copyright (C) 2014-2015 Altera Corporation. All rights reserved.
+ *
+ * with code from pm-imx6.c
+ * Copyright 2011-2014 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "core.h"
+
+/* Pointer to function copied to ocram */
+static u32 (*socfpga_sdram_self_refresh_in_ocram)(u32 sdr_base);
+
+static int 

[PATCHv5 1/2] ARM: socfpga: support suspend to ram

2015-05-28 Thread Alan Tull
Add code that requests that the sdr controller go into
self-refresh mode.  This code is run from ocram.

Suspend-to-RAM and EDAC support are mutually exclusive on
SOCFPGA.  If the EDAC is enabled, it will prevent the
platform from going into suspend.

Example of how to request to suspend to ram:
 $ echo enabled  \
/sys/devices/soc/ffc02000.serial0/tty/ttyS0/power/wakeup

 $ echo -n mem  /sys/power/state

Signed-off-by: Alan Tull at...@opensource.altera.com
Cc: Pavel Machek pa...@denx.de
Cc: Arnd Bergmann a...@arndb.de
Cc: Dinh Nguyen dingu...@opensource.altera.com
Cc: Steffen Trumtrar s.trumt...@pengutronix.de
---
v2: use Generic on-chip SRAM driver to allocate ocram
rm fncpy_align since generic allocator handles alignment
check __arm_ioremap_exec return code
check for NULL pointers
add a comment regarding sdram controller configuration
v3: fix renamed #define
propagate socfpga_setup_ocram_self_refresh error code
v4: Kconfig: don't need to select GENERIC_ALLOCATER
add CONFIG_SOCFPGA_SUSPEND
make s2r and EDAC support mutually exclusive
socfpga.c: add sdr_ctl_base_addr
return error if ocram not available in device tree
update copyright years
v5: remove compile time dependency
edac driver will prevent suspend
don't configure scu standby mode; done in enable_scu().
fix comments about required sdram controller configuration
---
 arch/arm/mach-socfpga/Kconfig|   10 ++-
 arch/arm/mach-socfpga/Makefile   |1 +
 arch/arm/mach-socfpga/core.h |6 +-
 arch/arm/mach-socfpga/pm.c   |  149 ++
 arch/arm/mach-socfpga/self-refresh.S |  136 +++
 arch/arm/mach-socfpga/socfpga.c  |6 +-
 drivers/edac/altera_edac.c   |   20 +
 7 files changed, 325 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/pm.c
 create mode 100644 arch/arm/mach-socfpga/self-refresh.S

diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig
index b5f8d75..b26a684 100644
--- a/arch/arm/mach-socfpga/Kconfig
+++ b/arch/arm/mach-socfpga/Kconfig
@@ -1,4 +1,4 @@
-config ARCH_SOCFPGA
+menuconfig ARCH_SOCFPGA
bool Altera SOCFPGA family if ARCH_MULTI_V7
select ARM_AMBA
select ARM_GIC
@@ -8,3 +8,11 @@ config ARCH_SOCFPGA
select HAVE_ARM_SCU
select HAVE_ARM_TWD if SMP
select MFD_SYSCON
+
+if ARCH_SOCFPGA
+config SOCFPGA_SUSPEND
+   bool Suspend to RAM on SOCFPGA
+   help
+ Select this if you want to enable Suspend-to-RAM on SOCFPGA
+ platforms.
+endif
diff --git a/arch/arm/mach-socfpga/Makefile b/arch/arm/mach-socfpga/Makefile
index 6dd7a93..b8f9e23 100644
--- a/arch/arm/mach-socfpga/Makefile
+++ b/arch/arm/mach-socfpga/Makefile
@@ -4,3 +4,4 @@
 
 obj-y  := socfpga.o
 obj-$(CONFIG_SMP)  += headsmp.o platsmp.o
+obj-$(CONFIG_SOCFPGA_SUSPEND)  += pm.o self-refresh.o
diff --git a/arch/arm/mach-socfpga/core.h b/arch/arm/mach-socfpga/core.h
index 7637b7f..35472f2 100644
--- a/arch/arm/mach-socfpga/core.h
+++ b/arch/arm/mach-socfpga/core.h
@@ -1,6 +1,6 @@
 /*
  * Copyright 2012 Pavel Machek pa...@denx.de
- * Copyright (C) 2012 Altera Corporation
+ * Copyright (C) 2012-2015 Altera Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -40,6 +40,10 @@ extern void socfpga_sysmgr_init(void);
 
 extern void __iomem *sys_manager_base_addr;
 extern void __iomem *rst_manager_base_addr;
+extern void __iomem *sdr_ctl_base_addr;
+
+u32 socfpga_sdram_self_refresh(u32 sdr_base);
+extern unsigned int socfpga_sdram_self_refresh_sz;
 
 extern struct smp_operations socfpga_smp_ops;
 extern char secondary_trampoline, secondary_trampoline_end;
diff --git a/arch/arm/mach-socfpga/pm.c b/arch/arm/mach-socfpga/pm.c
new file mode 100644
index 000..1ed89fc
--- /dev/null
+++ b/arch/arm/mach-socfpga/pm.c
@@ -0,0 +1,149 @@
+/*
+ *  arch/arm/mach-socfpga/pm.c
+ *
+ * Copyright (C) 2014-2015 Altera Corporation. All rights reserved.
+ *
+ * with code from pm-imx6.c
+ * Copyright 2011-2014 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see http://www.gnu.org/licenses/.
+ */
+
+#include linux/bitops.h
+#include linux/genalloc.h
+#include linux/init.h
+#include linux/io.h
+#include linux/of_platform.h
+#include 

Re: [PATCHv5 1/2] ARM: socfpga: support suspend to ram

2015-05-28 Thread Dinh Nguyen


On 5/28/15 4:19 PM, Alan Tull wrote:
 Add code that requests that the sdr controller go into
 self-refresh mode.  This code is run from ocram.
 
 Suspend-to-RAM and EDAC support are mutually exclusive on
 SOCFPGA.  If the EDAC is enabled, it will prevent the
 platform from going into suspend.
 
 Example of how to request to suspend to ram:
  $ echo enabled  \
 /sys/devices/soc/ffc02000.serial0/tty/ttyS0/power/wakeup
 
  $ echo -n mem  /sys/power/state
 
 Signed-off-by: Alan Tull at...@opensource.altera.com
 Cc: Pavel Machek pa...@denx.de
 Cc: Arnd Bergmann a...@arndb.de
 Cc: Dinh Nguyen dingu...@opensource.altera.com
 Cc: Steffen Trumtrar s.trumt...@pengutronix.de
 ---
 v2: use Generic on-chip SRAM driver to allocate ocram
 rm fncpy_align since generic allocator handles alignment
 check __arm_ioremap_exec return code
 check for NULL pointers
 add a comment regarding sdram controller configuration
 v3: fix renamed #define
 propagate socfpga_setup_ocram_self_refresh error code
 v4: Kconfig: don't need to select GENERIC_ALLOCATER
 add CONFIG_SOCFPGA_SUSPEND
 make s2r and EDAC support mutually exclusive
 socfpga.c: add sdr_ctl_base_addr
 return error if ocram not available in device tree
 update copyright years
 v5: remove compile time dependency
 edac driver will prevent suspend
 don't configure scu standby mode; done in enable_scu().
 fix comments about required sdram controller configuration
 ---
  arch/arm/mach-socfpga/Kconfig|   10 ++-
  arch/arm/mach-socfpga/Makefile   |1 +
  arch/arm/mach-socfpga/core.h |6 +-
  arch/arm/mach-socfpga/pm.c   |  149 
 ++
  arch/arm/mach-socfpga/self-refresh.S |  136 +++
  arch/arm/mach-socfpga/socfpga.c  |6 +-
  drivers/edac/altera_edac.c   |   20 +
  7 files changed, 325 insertions(+), 3 deletions(-)
  create mode 100644 arch/arm/mach-socfpga/pm.c
  create mode 100644 arch/arm/mach-socfpga/self-refresh.S
 

Which branch are you basing this patch on? I got a trivial patch
conflict in Kconfig when I applied to arm-soc/for-next and v4.1-rc5.

Also, I'm getting these sparse warnings:

arch/arm/mach-socfpga/pm.c:86:25: warning: incorrect type in argument 1
(different address spaces)
arch/arm/mach-socfpga/pm.c:86:25:expected void *noident
arch/arm/mach-socfpga/pm.c:86:25:got void [noderef]
asn:2*[assigned] suspend_ocram_base
arch/arm/mach-socfpga/pm.c:108:52: warning: cast removes address space
of expression

Dinh
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/