Skip to content

Commit

Permalink
Merge tag 'actions-arm-soc+sps-for-4.13' of git://git.kernel.org/pub/…
Browse files Browse the repository at this point in the history
…scm/linux/kernel/git/afaerber/linux-actions into next/soc

Pull "Actions Semi ARM SoC for v4.13 #2" from Andreas Färber:

This adds SMP code to bring up the remaining S500 CPU cores
by reusing a helper factored out of the SPS power domains driver.

* tag 'actions-arm-soc+sps-for-4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/afaerber/linux-actions:
  ARM: owl: smp: Implement SPS power-gating for CPU2 and CPU3
  soc: actions: owl-sps: Factor out owl_sps_set_pg() for power-gating
  soc: actions: Add Owl SPS
  dt-bindings: power: Add Owl SPS power domains
  • Loading branch information
Arnd Bergmann committed Jun 29, 2017
2 parents dc366b1 + b6a0e18 commit c070d6b
Show file tree
Hide file tree
Showing 11 changed files with 377 additions and 2 deletions.
17 changes: 17 additions & 0 deletions Documentation/devicetree/bindings/power/actions,owl-sps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Actions Semi Owl Smart Power System (SPS)

Required properties:
- compatible : "actions,s500-sps" for S500
- reg : Offset and length of the register set for the device.
- #power-domain-cells : Must be 1.
See macros in:
include/dt-bindings/power/owl-s500-powergate.h for S500


Example:

sps: power-controller@b01b0100 {
compatible = "actions,s500-sps";
reg = <0xb01b0100 0x100>;
#power-domain-cells = <1>;
};
1 change: 1 addition & 0 deletions arch/arm/mach-actions/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ menuconfig ARCH_ACTIONS
select GENERIC_IRQ_CHIP
select HAVE_ARM_SCU if SMP
select HAVE_ARM_TWD if SMP
select OWL_PM_DOMAINS_HELPER
select OWL_TIMER
help
This enables support for the Actions Semiconductor S500 SoC family.
36 changes: 34 additions & 2 deletions arch/arm/mach-actions/platsmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/smp.h>
#include <linux/soc/actions/owl-sps.h>
#include <asm/cacheflush.h>
#include <asm/smp_plat.h>
#include <asm/smp_scu.h>
Expand All @@ -28,7 +29,13 @@

#define OWL_CPUx_FLAG_BOOT 0x55aa

#define OWL_SPS_PG_CTL_PWR_CPU2 BIT(5)
#define OWL_SPS_PG_CTL_PWR_CPU3 BIT(6)
#define OWL_SPS_PG_CTL_ACK_CPU2 BIT(21)
#define OWL_SPS_PG_CTL_ACK_CPU3 BIT(22)

static void __iomem *scu_base_addr;
static void __iomem *sps_base_addr;
static void __iomem *timer_base_addr;
static int ncores;

Expand Down Expand Up @@ -58,14 +65,27 @@ void owl_secondary_startup(void);

static int s500_wakeup_secondary(unsigned int cpu)
{
int ret;

if (cpu > 3)
return -EINVAL;

/* The generic PM domain driver is not available this early. */
switch (cpu) {
case 2:
ret = owl_sps_set_pg(sps_base_addr,
OWL_SPS_PG_CTL_PWR_CPU2,
OWL_SPS_PG_CTL_ACK_CPU2, true);
if (ret)
return ret;
break;
case 3:
/* CPU2/3 are power-gated */
return -EINVAL;
ret = owl_sps_set_pg(sps_base_addr,
OWL_SPS_PG_CTL_PWR_CPU3,
OWL_SPS_PG_CTL_ACK_CPU3, true);
if (ret)
return ret;
break;
}

/* wait for CPUx to run to WFE instruction */
Expand Down Expand Up @@ -133,6 +153,18 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus)
return;
}

node = of_find_compatible_node(NULL, NULL, "actions,s500-sps");
if (!node) {
pr_err("%s: missing sps\n", __func__);
return;
}

sps_base_addr = of_iomap(node, 0);
if (!sps_base_addr) {
pr_err("%s: could not map sps registers\n", __func__);
return;
}

if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) {
node = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
if (!node) {
Expand Down
1 change: 1 addition & 0 deletions drivers/soc/Kconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
menu "SOC (System On Chip) specific Drivers"

source "drivers/soc/actions/Kconfig"
source "drivers/soc/atmel/Kconfig"
source "drivers/soc/bcm/Kconfig"
source "drivers/soc/fsl/Kconfig"
Expand Down
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_ARCH_ACTIONS) += actions/
obj-$(CONFIG_ARCH_AT91) += atmel/
obj-y += bcm/
obj-$(CONFIG_ARCH_DOVE) += dove/
Expand Down
16 changes: 16 additions & 0 deletions drivers/soc/actions/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
if ARCH_ACTIONS || COMPILE_TEST

config OWL_PM_DOMAINS_HELPER
bool

config OWL_PM_DOMAINS
bool "Actions Semi SPS power domains"
depends on PM
select OWL_PM_DOMAINS_HELPER
select PM_GENERIC_DOMAINS
help
Say 'y' here to enable support for Smart Power System (SPS)
power-gating on Actions Semiconductor S500 SoC.
If unsure, say 'n'.

endif
2 changes: 2 additions & 0 deletions drivers/soc/actions/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obj-$(CONFIG_OWL_PM_DOMAINS_HELPER) += owl-sps-helper.o
obj-$(CONFIG_OWL_PM_DOMAINS) += owl-sps.o
51 changes: 51 additions & 0 deletions drivers/soc/actions/owl-sps-helper.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Actions Semi Owl Smart Power System (SPS) shared helpers
*
* Copyright 2012 Actions Semi Inc.
* Author: Actions Semi, Inc.
*
* Copyright (c) 2017 Andreas Färber
*
* 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 the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/

#include <linux/delay.h>
#include <linux/io.h>

#define OWL_SPS_PG_CTL 0x0

int owl_sps_set_pg(void __iomem *base, u32 pwr_mask, u32 ack_mask, bool enable)
{
u32 val;
bool ack;
int timeout;

val = readl(base + OWL_SPS_PG_CTL);
ack = val & ack_mask;
if (ack == enable)
return 0;

if (enable)
val |= pwr_mask;
else
val &= ~pwr_mask;

writel(val, base + OWL_SPS_PG_CTL);

for (timeout = 5000; timeout > 0; timeout -= 50) {
val = readl(base + OWL_SPS_PG_CTL);
if ((val & ack_mask) == (enable ? ack_mask : 0))
break;
udelay(50);
}
if (timeout <= 0)
return -ETIMEDOUT;

udelay(10);

return 0;
}
EXPORT_SYMBOL_GPL(owl_sps_set_pg);
Loading

0 comments on commit c070d6b

Please sign in to comment.