Skip to content

Commit

Permalink
Merge tag 'mvebu-soc-4.3-2' of git://git.infradead.org/linux-mvebu in…
Browse files Browse the repository at this point in the history
…to next/drivers

mvebu soc changes for v4.3 (part #2)

SoC part of the Dove PMU series

* tag 'mvebu-soc-4.3-2' of git://git.infradead.org/linux-mvebu:
  ARM: dove: create a proper PMU driver for power domains, PMU IRQs and resets

Signed-off-by: Olof Johansson <olof@lixom.net>
  • Loading branch information
olofj committed Aug 13, 2015
2 parents 0ff818e + 44e259a commit 3d3cacc
Show file tree
Hide file tree
Showing 10 changed files with 526 additions and 39 deletions.
1 change: 1 addition & 0 deletions arch/arm/mach-mvebu/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ config MACH_DOVE
select MACH_MVEBU_ANY
select ORION_IRQCHIP
select ORION_TIMER
select PM_GENERIC_DOMAINS if PM
select PINCTRL_DOVE
help
Say 'Y' here if you want your kernel to support the
Expand Down
29 changes: 17 additions & 12 deletions arch/arm/mach-mvebu/coherency.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ static const struct of_device_id of_coherency_table[] = {
int ll_enable_coherency(void);
void ll_add_cpu_to_smp_group(void);

int set_cpu_coherent(void)
{
if (!coherency_base) {
pr_warn("Can't make current CPU cache coherent.\n");
pr_warn("Coherency fabric is not initialized\n");
return 1;
}

ll_add_cpu_to_smp_group();
return ll_enable_coherency();
}

static int mvebu_hwcc_notifier(struct notifier_block *nb,
unsigned long event, void *__dev)
{
Expand Down Expand Up @@ -206,6 +194,23 @@ static int coherency_type(void)
return type;
}

int set_cpu_coherent(void)
{
int type = coherency_type();

if (type == COHERENCY_FABRIC_TYPE_ARMADA_370_XP) {
if (!coherency_base) {
pr_warn("Can't make current CPU cache coherent.\n");
pr_warn("Coherency fabric is not initialized\n");
return 1;
}
ll_add_cpu_to_smp_group();
return ll_enable_coherency();
}

return 0;
}

int coherency_available(void)
{
return coherency_type() != COHERENCY_FABRIC_TYPE_NONE;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-mvebu/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +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));

int mvebu_pm_suspend_init(void (*board_pm_enter)(void __iomem *sdram_reg,
u32 srcmd));
#endif
2 changes: 2 additions & 0 deletions arch/arm/mach-mvebu/dove.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/mbus.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/soc/dove/pmu.h>
#include <asm/hardware/cache-tauros2.h>
#include <asm/mach/arch.h>
#include "common.h"
Expand All @@ -24,6 +25,7 @@ static void __init dove_init(void)
tauros2_init(0);
#endif
BUG_ON(mvebu_mbus_dt_init(false));
dove_init_pmu();
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
}

Expand Down
30 changes: 19 additions & 11 deletions arch/arm/mach-mvebu/pm-board.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Board-level suspend/resume support.
*
* Copyright (C) 2014 Marvell
* Copyright (C) 2014-2015 Marvell
*
* Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
*
Expand All @@ -20,27 +20,27 @@
#include <linux/slab.h>
#include "common.h"

#define ARMADA_XP_GP_PIC_NR_GPIOS 3
#define ARMADA_PIC_NR_GPIOS 3

static void __iomem *gpio_ctrl;
static int pic_gpios[ARMADA_XP_GP_PIC_NR_GPIOS];
static int pic_raw_gpios[ARMADA_XP_GP_PIC_NR_GPIOS];
static int pic_gpios[ARMADA_PIC_NR_GPIOS];
static int pic_raw_gpios[ARMADA_PIC_NR_GPIOS];

static void mvebu_armada_xp_gp_pm_enter(void __iomem *sdram_reg, u32 srcmd)
static void mvebu_armada_pm_enter(void __iomem *sdram_reg, u32 srcmd)
{
u32 reg, ackcmd;
int i;

/* Put 001 as value on the GPIOs */
reg = readl(gpio_ctrl);
for (i = 0; i < ARMADA_XP_GP_PIC_NR_GPIOS; i++)
for (i = 0; i < ARMADA_PIC_NR_GPIOS; i++)
reg &= ~BIT(pic_raw_gpios[i]);
reg |= BIT(pic_raw_gpios[0]);
writel(reg, gpio_ctrl);

/* Prepare writing 111 to the GPIOs */
ackcmd = readl(gpio_ctrl);
for (i = 0; i < ARMADA_XP_GP_PIC_NR_GPIOS; i++)
for (i = 0; i < ARMADA_PIC_NR_GPIOS; i++)
ackcmd |= BIT(pic_raw_gpios[i]);

srcmd = cpu_to_le32(srcmd);
Expand Down Expand Up @@ -76,7 +76,7 @@ static void mvebu_armada_xp_gp_pm_enter(void __iomem *sdram_reg, u32 srcmd)
[ackcmd] "r" (ackcmd), [gpio_ctrl] "r" (gpio_ctrl) : "r1");
}

static int mvebu_armada_xp_gp_pm_init(void)
static int __init mvebu_armada_pm_init(void)
{
struct device_node *np;
struct device_node *gpio_ctrl_np;
Expand All @@ -89,7 +89,7 @@ static int mvebu_armada_xp_gp_pm_init(void)
if (!np)
return -ENODEV;

for (i = 0; i < ARMADA_XP_GP_PIC_NR_GPIOS; i++) {
for (i = 0; i < ARMADA_PIC_NR_GPIOS; i++) {
char *name;
struct of_phandle_args args;

Expand Down Expand Up @@ -134,11 +134,19 @@ static int mvebu_armada_xp_gp_pm_init(void)
if (!gpio_ctrl)
return -ENOMEM;

mvebu_pm_init(mvebu_armada_xp_gp_pm_enter);
mvebu_pm_suspend_init(mvebu_armada_pm_enter);

out:
of_node_put(np);
return ret;
}

late_initcall(mvebu_armada_xp_gp_pm_init);
/*
* Registering the mvebu_board_pm_enter callback must be done before
* the platform_suspend_ops will be registered. In the same time we
* also need to have the gpio devices registered. That's why we use a
* device_initcall_sync which is called after all the device_initcall
* (used by the gpio device) but before the late_initcall (used to
* register the platform_suspend_ops)
*/
device_initcall_sync(mvebu_armada_pm_init);
79 changes: 65 additions & 14 deletions arch/arm/mach-mvebu/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,10 @@ static phys_addr_t mvebu_internal_reg_base(void)
return of_translate_address(np, in_addr);
}

static void mvebu_pm_store_bootinfo(void)
static void mvebu_pm_store_armadaxp_bootinfo(u32 *store_addr)
{
u32 *store_addr;
phys_addr_t resume_pc;

store_addr = phys_to_virt(BOOT_INFO_ADDR);
resume_pc = virt_to_phys(armada_370_xp_cpu_resume);

/*
Expand Down Expand Up @@ -151,14 +149,30 @@ static void mvebu_pm_store_bootinfo(void)
writel(BOOT_MAGIC_LIST_END, store_addr);
}

static int mvebu_pm_enter(suspend_state_t state)
static int mvebu_pm_store_bootinfo(void)
{
if (state != PM_SUSPEND_MEM)
return -EINVAL;
u32 *store_addr;

store_addr = phys_to_virt(BOOT_INFO_ADDR);

if (of_machine_is_compatible("marvell,armadaxp"))
mvebu_pm_store_armadaxp_bootinfo(store_addr);
else
return -ENODEV;

return 0;
}

static int mvebu_enter_suspend(void)
{
int ret;

ret = mvebu_pm_store_bootinfo();
if (ret)
return ret;

cpu_pm_enter();

mvebu_pm_store_bootinfo();
cpu_suspend(0, mvebu_pm_powerdown);

outer_resume();
Expand All @@ -168,23 +182,62 @@ static int mvebu_pm_enter(suspend_state_t state)
set_cpu_coherent();

cpu_pm_exit();
return 0;
}

static int mvebu_pm_enter(suspend_state_t state)
{
switch (state) {
case PM_SUSPEND_STANDBY:
cpu_do_idle();
break;
case PM_SUSPEND_MEM:
pr_warn("Entering suspend to RAM. Only special wake-up sources will resume the system\n");
return mvebu_enter_suspend();
default:
return -EINVAL;
}
return 0;
}

static int mvebu_pm_valid(suspend_state_t state)
{
if (state == PM_SUSPEND_STANDBY)
return 1;

if (state == PM_SUSPEND_MEM && mvebu_board_pm_enter != NULL)
return 1;

return 0;
}

static const struct platform_suspend_ops mvebu_pm_ops = {
.enter = mvebu_pm_enter,
.valid = suspend_valid_only_mem,
.valid = mvebu_pm_valid,
};

int mvebu_pm_init(void (*board_pm_enter)(void __iomem *sdram_reg, u32 srcmd))
static int __init mvebu_pm_init(void)
{
if (!of_machine_is_compatible("marvell,armadaxp") &&
!of_machine_is_compatible("marvell,armada370") &&
!of_machine_is_compatible("marvell,armada380") &&
!of_machine_is_compatible("marvell,armada390"))
return -ENODEV;

suspend_set_ops(&mvebu_pm_ops);

return 0;
}


late_initcall(mvebu_pm_init);

int __init mvebu_pm_suspend_init(void (*board_pm_enter)(void __iomem *sdram_reg,
u32 srcmd))
{
struct device_node *np;
struct resource res;

if (!of_machine_is_compatible("marvell,armadaxp"))
return -ENODEV;

np = of_find_compatible_node(NULL, NULL,
"marvell,armada-xp-sdram-controller");
if (!np)
Expand Down Expand Up @@ -212,7 +265,5 @@ int mvebu_pm_init(void (*board_pm_enter)(void __iomem *sdram_reg, u32 srcmd))

mvebu_board_pm_enter = board_pm_enter;

suspend_set_ops(&mvebu_pm_ops);

return 0;
}
1 change: 1 addition & 0 deletions drivers/soc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Makefile for the Linux Kernel SOC specific device drivers.
#

obj-$(CONFIG_MACH_DOVE) += dove/
obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/
obj-$(CONFIG_ARCH_QCOM) += qcom/
obj-$(CONFIG_ARCH_SUNXI) += sunxi/
Expand Down
1 change: 1 addition & 0 deletions drivers/soc/dove/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj-y += pmu.o
Loading

0 comments on commit 3d3cacc

Please sign in to comment.