Skip to content

Commit

Permalink
Merge tag 'mvebu-soc-suspend-3.19' of git://git.infradead.org/linux-m…
Browse files Browse the repository at this point in the history
…vebu into next/soc

Pull "mvebu SoC suspend changes for v3.19" from Jason Cooper:

 - Armada 370/XP suspend/resume support

 - mvebu SoC driver suspend/resume support
    - irqchip
    - clocksource
    - mbus
    - clk

* tag 'mvebu-soc-suspend-3.19' of git://git.infradead.org/linux-mvebu:
  ARM: mvebu: add SDRAM controller description for Armada XP
  ARM: mvebu: adjust mbus controller description on Armada 370/XP
  ARM: mvebu: add suspend/resume DT information for Armada XP GP
  ARM: mvebu: synchronize secondary CPU clocks on resume
  ARM: mvebu: make sure MMU is disabled in armada_370_xp_cpu_resume
  ARM: mvebu: Armada XP GP specific suspend/resume code
  ARM: mvebu: reserve the first 10 KB of each memory bank for suspend/resume
  ARM: mvebu: implement suspend/resume support for Armada XP
  clk: mvebu: add suspend/resume for gatable clocks
  bus: mvebu-mbus: provide a mechanism to save SDRAM window configuration
  bus: mvebu-mbus: suspend/resume support
  clocksource: time-armada-370-xp: add suspend/resume support
  irqchip: armada-370-xp: Add suspend/resume support
  Documentation: dt-bindings: minimal documentation for MVEBU SDRAM controller

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
  • Loading branch information
Arnd Bergmann committed Dec 4, 2014
2 parents 756f80c + 6e6db2b commit ab64920
Show file tree
Hide file tree
Showing 18 changed files with 777 additions and 32 deletions.
17 changes: 10 additions & 7 deletions Documentation/devicetree/bindings/bus/mvebu-mbus.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ Required properties:
- compatible: Should be set to "marvell,mbus-controller".

- reg: Device's register space.
Two entries are expected (see the examples below):
the first one controls the devices decoding window and
the second one controls the SDRAM decoding window.
Two or three entries are expected (see the examples below):
the first one controls the devices decoding window,
the second one controls the SDRAM decoding window and
the third controls the MBus bridge (only with the
marvell,armada370-mbus and marvell,armadaxp-mbus
compatible strings)

Example:

Expand All @@ -67,7 +70,7 @@ Example:

mbusc: mbus-controller@20000 {
compatible = "marvell,mbus-controller";
reg = <0x20000 0x100>, <0x20180 0x20>;
reg = <0x20000 0x100>, <0x20180 0x20>, <0x20250 0x8>;
};

/* more children ...*/
Expand Down Expand Up @@ -126,7 +129,7 @@ are skipped.

mbusc: mbus-controller@20000 {
compatible = "marvell,mbus-controller";
reg = <0x20000 0x100>, <0x20180 0x20>;
reg = <0x20000 0x100>, <0x20180 0x20>, <0x20250 0x8>;
};

/* more children ...*/
Expand Down Expand Up @@ -170,7 +173,7 @@ Using this macro, the above example would be:

mbusc: mbus-controller@20000 {
compatible = "marvell,mbus-controller";
reg = <0x20000 0x100>, <0x20180 0x20>;
reg = <0x20000 0x100>, <0x20180 0x20>, <0x20250 0x8>;
};

/* other children */
Expand Down Expand Up @@ -266,7 +269,7 @@ See the example below, where a more complete device tree is shown:
ranges = <0 MBUS_ID(0xf0, 0x01) 0 0x100000>;

mbusc: mbus-controller@20000 {
reg = <0x20000 0x100>, <0x20180 0x20>;
reg = <0x20000 0x100>, <0x20180 0x20>, <0x20250 0x8>;
};

interrupt-controller@20000 {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Device Tree bindings for MVEBU SDRAM controllers

The Marvell EBU SoCs all have a SDRAM controller. The SDRAM controller
differs from one SoC variant to another, but they also share a number
of commonalities.

For now, this Device Tree binding documentation only documents the
Armada XP SDRAM controller.

Required properties:

- compatible: for Armada XP, "marvell,armada-xp-sdram-controller"
- reg: a resource specifier for the register space, which should
include all SDRAM controller registers as per the datasheet.

Example:

sdramc@1400 {
compatible = "marvell,armada-xp-sdram-controller";
reg = <0x1400 0x500>;
};
3 changes: 2 additions & 1 deletion arch/arm/boot/dts/armada-370-xp.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@

mbusc: mbus-controller@20000 {
compatible = "marvell,mbus-controller";
reg = <0x20000 0x100>, <0x20180 0x20>;
reg = <0x20000 0x100>, <0x20180 0x20>,
<0x20250 0x8>;
};

mpic: interrupt-controller@20000 {
Expand Down
19 changes: 18 additions & 1 deletion arch/arm/boot/dts/armada-xp-gp.dts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

/dts-v1/;
#include <dt-bindings/gpio/gpio.h>
#include "armada-xp-mv78460.dtsi"

/ {
Expand All @@ -48,6 +49,14 @@
<0x00000001 0x00000000 0x00000001 0x00000000>;
};

cpus {
pm_pic {
ctrl-gpios = <&gpio0 16 GPIO_ACTIVE_LOW>,
<&gpio0 17 GPIO_ACTIVE_LOW>,
<&gpio0 18 GPIO_ACTIVE_LOW>;
};
};

soc {
ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xf1000000 0x100000
MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000
Expand Down Expand Up @@ -115,7 +124,15 @@
serial@12300 {
status = "okay";
};

pinctrl {
pinctrl-0 = <&pic_pins>;
pinctrl-names = "default";
pic_pins: pic-pins-0 {
marvell,pins = "mpp16", "mpp17",
"mpp18";
marvell,function = "gpio";
};
};
sata@a0000 {
nr-ports = <2>;
status = "okay";
Expand Down
5 changes: 5 additions & 0 deletions arch/arm/boot/dts/armada-xp.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
};

internal-regs {
sdramc@1400 {
compatible = "marvell,armada-xp-sdram-controller";
reg = <0x1400 0x500>;
};

L2: l2-cache {
compatible = "marvell,aurora-system-cache";
reg = <0x08000 0x1000>;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-mvebu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CFLAGS_pmsu.o := -march=armv7-a
obj-$(CONFIG_MACH_MVEBU_ANY) += system-controller.o mvebu-soc-id.o

ifeq ($(CONFIG_MACH_MVEBU_V7),y)
obj-y += cpu-reset.o board-v7.o coherency.o coherency_ll.o pmsu.o pmsu_ll.o
obj-y += cpu-reset.o board-v7.o coherency.o coherency_ll.o pmsu.o pmsu_ll.o pm.o pm-board.o
obj-$(CONFIG_SMP) += platsmp.o headsmp.o platsmp-a9.o headsmp-a9.o
endif

Expand Down
51 changes: 51 additions & 0 deletions arch/arm/mach-mvebu/board-v7.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
#include <linux/init.h>
#include <linux/clk-provider.h>
#include <linux/of_address.h>
#include <linux/of_fdt.h>
#include <linux/of_platform.h>
#include <linux/io.h>
#include <linux/clocksource.h>
#include <linux/dma-mapping.h>
#include <linux/memblock.h>
#include <linux/mbus.h>
#include <linux/signal.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -56,6 +58,54 @@ void __iomem *mvebu_get_scu_base(void)
return scu_base;
}

/*
* When returning from suspend, the platform goes through the
* bootloader, which executes its DDR3 training code. This code has
* the unfortunate idea of using the first 10 KB of each DRAM bank to
* exercise the RAM and calculate the optimal timings. Therefore, this
* area of RAM is overwritten, and shouldn't be used by the kernel if
* suspend/resume is supported.
*/

#ifdef CONFIG_SUSPEND
#define MVEBU_DDR_TRAINING_AREA_SZ (10 * SZ_1K)
static int __init mvebu_scan_mem(unsigned long node, const char *uname,
int depth, void *data)
{
const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
const __be32 *reg, *endp;
int l;

if (type == NULL || strcmp(type, "memory"))
return 0;

reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l);
if (reg == NULL)
reg = of_get_flat_dt_prop(node, "reg", &l);
if (reg == NULL)
return 0;

endp = reg + (l / sizeof(__be32));
while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
u64 base, size;

base = dt_mem_next_cell(dt_root_addr_cells, &reg);
size = dt_mem_next_cell(dt_root_size_cells, &reg);

memblock_reserve(base, MVEBU_DDR_TRAINING_AREA_SZ);
}

return 0;
}

static void __init mvebu_memblock_reserve(void)
{
of_scan_flat_dt(mvebu_scan_mem, NULL);
}
#else
static void __init mvebu_memblock_reserve(void) {}
#endif

/*
* Early versions of Armada 375 SoC have a bug where the BootROM
* leaves an external data abort pending. The kernel is hit by this
Expand Down Expand Up @@ -151,6 +201,7 @@ DT_MACHINE_START(ARMADA_370_XP_DT, "Marvell Armada 370/XP (Device Tree)")
.init_machine = mvebu_dt_init,
.init_irq = mvebu_init_irq,
.restart = mvebu_restart,
.reserve = mvebu_memblock_reserve,
.dt_compat = armada_370_xp_dt_compat,
MACHINE_END

Expand Down
2 changes: 2 additions & 0 deletions arch/arm/mach-mvebu/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ int mvebu_system_controller_get_soc_id(u32 *dev, u32 *rev);

void __iomem *mvebu_get_scu_base(void);

int mvebu_pm_init(void (*board_pm_enter)(void __iomem *sdram_reg, u32 srcmd));

#endif
31 changes: 15 additions & 16 deletions arch/arm/mach-mvebu/platsmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define AXP_BOOTROM_BASE 0xfff00000
#define AXP_BOOTROM_SIZE 0x100000

static struct clk *__init get_cpu_clk(int cpu)
static struct clk *get_cpu_clk(int cpu)
{
struct clk *cpu_clk;
struct device_node *np = of_get_cpu_node(cpu, NULL);
Expand All @@ -48,29 +48,28 @@ static struct clk *__init get_cpu_clk(int cpu)
return cpu_clk;
}

static void __init set_secondary_cpus_clock(void)
static void set_secondary_cpu_clock(unsigned int cpu)
{
int thiscpu, cpu;
int thiscpu;
unsigned long rate;
struct clk *cpu_clk;

thiscpu = smp_processor_id();
thiscpu = get_cpu();

cpu_clk = get_cpu_clk(thiscpu);
if (!cpu_clk)
return;
goto out;
clk_prepare_enable(cpu_clk);
rate = clk_get_rate(cpu_clk);

/* set all the other CPU clk to the same rate than the boot CPU */
for_each_possible_cpu(cpu) {
if (cpu == thiscpu)
continue;
cpu_clk = get_cpu_clk(cpu);
if (!cpu_clk)
return;
clk_set_rate(cpu_clk, rate);
clk_prepare_enable(cpu_clk);
}
cpu_clk = get_cpu_clk(cpu);
if (!cpu_clk)
goto out;
clk_set_rate(cpu_clk, rate);
clk_prepare_enable(cpu_clk);

out:
put_cpu();
}

static int armada_xp_boot_secondary(unsigned int cpu, struct task_struct *idle)
Expand All @@ -80,6 +79,7 @@ static int armada_xp_boot_secondary(unsigned int cpu, struct task_struct *idle)
pr_info("Booting CPU %d\n", cpu);

hw_cpu = cpu_logical_map(cpu);
set_secondary_cpu_clock(hw_cpu);
mvebu_pmsu_set_cpu_boot_addr(hw_cpu, armada_xp_secondary_startup);

/*
Expand Down Expand Up @@ -128,7 +128,6 @@ static void __init armada_xp_smp_prepare_cpus(unsigned int max_cpus)
struct resource res;
int err;

set_secondary_cpus_clock();
flush_cache_all();
set_cpu_coherent();

Expand Down
Loading

0 comments on commit ab64920

Please sign in to comment.