]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
soc: renesas: Move pm-rcar to drivers/soc/renesas/rcar-sysc
authorGeert Uytterhoeven <geert+renesas@glider.be>
Wed, 20 Apr 2016 12:02:36 +0000 (14:02 +0200)
committerSimon Horman <horms+renesas@verge.net.au>
Fri, 22 Apr 2016 07:23:13 +0000 (17:23 +1000)
Move the pm-rcar driver from arch/arm/mach-shmobile/ to
drivers/soc/renesas/, and its header file to include/linux/soc/renesas/,
so it can be shared between arm32 (R-Car H1 and Gen2) and arm64 (R-Car
Gen3). Rename it to rcar-sysc as it's really a driver for the R-Car
System Controller (SYSC).

Kill the intermediate PM_RCAR config symbol, as it's not user
configurable anymore, and to prepare for SoC-specific make rules.

Add the missing #include <linux/types.h> to rcar-sysc.h, which was
exposed by different include order.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
13 files changed:
MAINTAINERS
arch/arm/mach-shmobile/Kconfig
arch/arm/mach-shmobile/Makefile
arch/arm/mach-shmobile/pm-r8a7779.c
arch/arm/mach-shmobile/pm-rcar-gen2.c
arch/arm/mach-shmobile/pm-rcar.c [deleted file]
arch/arm/mach-shmobile/pm-rcar.h [deleted file]
arch/arm/mach-shmobile/smp-r8a7779.c
arch/arm/mach-shmobile/smp-r8a7790.c
drivers/soc/Makefile
drivers/soc/renesas/Makefile [new file with mode: 0644]
drivers/soc/renesas/rcar-sysc.c [new file with mode: 0644]
include/linux/soc/renesas/rcar-sysc.h [new file with mode: 0644]

index 03e00c7c88ebca4161bff9d4be82d59f3698f177..a0e23922a90b17a90d4d227d7a8e818116306043 100644 (file)
@@ -1491,6 +1491,8 @@ Q:        http://patchwork.kernel.org/project/linux-renesas-soc/list/
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git next
 S:     Supported
 F:     arch/arm64/boot/dts/renesas/
+F:     drivers/soc/renesas/
+F:     include/linux/soc/renesas/
 
 ARM/RISCPC ARCHITECTURE
 M:     Russell King <linux@arm.linux.org.uk>
@@ -1604,6 +1606,8 @@ F:        arch/arm/configs/shmobile_defconfig
 F:     arch/arm/include/debug/renesas-scif.S
 F:     arch/arm/mach-shmobile/
 F:     drivers/sh/
+F:     drivers/soc/renesas/
+F:     include/linux/soc/renesas/
 
 ARM/SOCFPGA ARCHITECTURE
 M:     Dinh Nguyen <dinguyen@opensource.altera.com>
index f2bc5c353119e96de7fad68ff4daf43686e3f851..fe4ccb52f9213d8b586a1440ba606ad2afa1bc6e 100644 (file)
@@ -4,11 +4,6 @@ config ARCH_SHMOBILE
 config ARCH_SHMOBILE_MULTI
        bool
 
-config PM_RCAR
-       bool
-       select PM
-       select PM_GENERIC_DOMAINS
-
 config PM_RMOBILE
        bool
        select PM
@@ -16,13 +11,15 @@ config PM_RMOBILE
 
 config ARCH_RCAR_GEN1
        bool
-       select PM_RCAR
+       select PM
+       select PM_GENERIC_DOMAINS
        select RENESAS_INTC_IRQPIN
        select SYS_SUPPORTS_SH_TMU
 
 config ARCH_RCAR_GEN2
        bool
-       select PM_RCAR
+       select PM
+       select PM_GENERIC_DOMAINS
        select RENESAS_IRQC
        select SYS_SUPPORTS_SH_CMT
        select PCI_DOMAINS if PCI
index a65c80ac9009d51f1e54fd0b07e58336d8241e02..ebb909c55b856a58d201d3d93892aff882339d6b 100644 (file)
@@ -39,7 +39,6 @@ smp-$(CONFIG_ARCH_EMEV2)      += smp-emev2.o headsmp-scu.o platsmp-scu.o
 # PM objects
 obj-$(CONFIG_SUSPEND)          += suspend.o
 obj-$(CONFIG_CPU_FREQ)         += cpufreq.o
-obj-$(CONFIG_PM_RCAR)          += pm-rcar.o
 obj-$(CONFIG_PM_RMOBILE)       += pm-rmobile.o
 obj-$(CONFIG_ARCH_RCAR_GEN2)   += pm-rcar-gen2.o
 
index 14c42a1bdf1ef20d506f47d8fe013be7e71254b9..4174cbcbc467d047d1bba4208a365f3e927d4054 100644 (file)
@@ -9,9 +9,10 @@
  * for more details.
  */
 
+#include <linux/soc/renesas/rcar-sysc.h>
+
 #include <asm/io.h>
 
-#include "pm-rcar.h"
 #include "r8a7779.h"
 
 /* SYSC */
index 6815781ad1165ef34df418929dd643e218c24ff3..691ac166a277c03fe1a562d5521affa6c75e5fc3 100644 (file)
@@ -13,9 +13,9 @@
 #include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/smp.h>
+#include <linux/soc/renesas/rcar-sysc.h>
 #include <asm/io.h>
 #include "common.h"
-#include "pm-rcar.h"
 #include "rcar-gen2.h"
 
 /* RST */
diff --git a/arch/arm/mach-shmobile/pm-rcar.c b/arch/arm/mach-shmobile/pm-rcar.c
deleted file mode 100644 (file)
index 0af05d2..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * R-Car SYSC Power management support
- *
- * Copyright (C) 2014  Magnus Damm
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/delay.h>
-#include <linux/err.h>
-#include <linux/mm.h>
-#include <linux/spinlock.h>
-#include <linux/io.h>
-#include "pm-rcar.h"
-
-/* SYSC Common */
-#define SYSCSR                 0x00    /* SYSC Status Register */
-#define SYSCISR                        0x04    /* Interrupt Status Register */
-#define SYSCISCR               0x08    /* Interrupt Status Clear Register */
-#define SYSCIER                        0x0c    /* Interrupt Enable Register */
-#define SYSCIMR                        0x10    /* Interrupt Mask Register */
-
-/* SYSC Status Register */
-#define SYSCSR_PONENB          1       /* Ready for power resume requests */
-#define SYSCSR_POFFENB         0       /* Ready for power shutoff requests */
-
-/*
- * Power Control Register Offsets inside the register block for each domain
- * Note: The "CR" registers for ARM cores exist on H1 only
- *       Use WFI to power off, CPG/APMU to resume ARM cores on R-Car Gen2
- */
-#define PWRSR_OFFS             0x00    /* Power Status Register */
-#define PWROFFCR_OFFS          0x04    /* Power Shutoff Control Register */
-#define PWROFFSR_OFFS          0x08    /* Power Shutoff Status Register */
-#define PWRONCR_OFFS           0x0c    /* Power Resume Control Register */
-#define PWRONSR_OFFS           0x10    /* Power Resume Status Register */
-#define PWRER_OFFS             0x14    /* Power Shutoff/Resume Error */
-
-
-#define SYSCSR_RETRIES         100
-#define SYSCSR_DELAY_US                1
-
-#define PWRER_RETRIES          100
-#define PWRER_DELAY_US         1
-
-#define SYSCISR_RETRIES                1000
-#define SYSCISR_DELAY_US       1
-
-static void __iomem *rcar_sysc_base;
-static DEFINE_SPINLOCK(rcar_sysc_lock); /* SMP CPUs + I/O devices */
-
-static int rcar_sysc_pwr_on_off(const struct rcar_sysc_ch *sysc_ch, bool on)
-{
-       unsigned int sr_bit, reg_offs;
-       int k;
-
-       if (on) {
-               sr_bit = SYSCSR_PONENB;
-               reg_offs = PWRONCR_OFFS;
-       } else {
-               sr_bit = SYSCSR_POFFENB;
-               reg_offs = PWROFFCR_OFFS;
-       }
-
-       /* Wait until SYSC is ready to accept a power request */
-       for (k = 0; k < SYSCSR_RETRIES; k++) {
-               if (ioread32(rcar_sysc_base + SYSCSR) & BIT(sr_bit))
-                       break;
-               udelay(SYSCSR_DELAY_US);
-       }
-
-       if (k == SYSCSR_RETRIES)
-               return -EAGAIN;
-
-       /* Submit power shutoff or power resume request */
-       iowrite32(BIT(sysc_ch->chan_bit),
-                 rcar_sysc_base + sysc_ch->chan_offs + reg_offs);
-
-       return 0;
-}
-
-static int rcar_sysc_power(const struct rcar_sysc_ch *sysc_ch, bool on)
-{
-       unsigned int isr_mask = BIT(sysc_ch->isr_bit);
-       unsigned int chan_mask = BIT(sysc_ch->chan_bit);
-       unsigned int status;
-       unsigned long flags;
-       int ret = 0;
-       int k;
-
-       spin_lock_irqsave(&rcar_sysc_lock, flags);
-
-       iowrite32(isr_mask, rcar_sysc_base + SYSCISCR);
-
-       /* Submit power shutoff or resume request until it was accepted */
-       for (k = 0; k < PWRER_RETRIES; k++) {
-               ret = rcar_sysc_pwr_on_off(sysc_ch, on);
-               if (ret)
-                       goto out;
-
-               status = ioread32(rcar_sysc_base +
-                                 sysc_ch->chan_offs + PWRER_OFFS);
-               if (!(status & chan_mask))
-                       break;
-
-               udelay(PWRER_DELAY_US);
-       }
-
-       if (k == PWRER_RETRIES) {
-               ret = -EIO;
-               goto out;
-       }
-
-       /* Wait until the power shutoff or resume request has completed * */
-       for (k = 0; k < SYSCISR_RETRIES; k++) {
-               if (ioread32(rcar_sysc_base + SYSCISR) & isr_mask)
-                       break;
-               udelay(SYSCISR_DELAY_US);
-       }
-
-       if (k == SYSCISR_RETRIES)
-               ret = -EIO;
-
-       iowrite32(isr_mask, rcar_sysc_base + SYSCISCR);
-
- out:
-       spin_unlock_irqrestore(&rcar_sysc_lock, flags);
-
-       pr_debug("sysc power domain %d: %08x -> %d\n",
-                sysc_ch->isr_bit, ioread32(rcar_sysc_base + SYSCISR), ret);
-       return ret;
-}
-
-int rcar_sysc_power_down(const struct rcar_sysc_ch *sysc_ch)
-{
-       return rcar_sysc_power(sysc_ch, false);
-}
-
-int rcar_sysc_power_up(const struct rcar_sysc_ch *sysc_ch)
-{
-       return rcar_sysc_power(sysc_ch, true);
-}
-
-bool rcar_sysc_power_is_off(const struct rcar_sysc_ch *sysc_ch)
-{
-       unsigned int st;
-
-       st = ioread32(rcar_sysc_base + sysc_ch->chan_offs + PWRSR_OFFS);
-       if (st & BIT(sysc_ch->chan_bit))
-               return true;
-
-       return false;
-}
-
-void __iomem *rcar_sysc_init(phys_addr_t base)
-{
-       rcar_sysc_base = ioremap_nocache(base, PAGE_SIZE);
-       if (!rcar_sysc_base)
-               panic("unable to ioremap R-Car SYSC hardware block\n");
-
-       return rcar_sysc_base;
-}
diff --git a/arch/arm/mach-shmobile/pm-rcar.h b/arch/arm/mach-shmobile/pm-rcar.h
deleted file mode 100644 (file)
index 1b901db..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef PM_RCAR_H
-#define PM_RCAR_H
-
-struct rcar_sysc_ch {
-       u16 chan_offs;
-       u8 chan_bit;
-       u8 isr_bit;
-};
-
-int rcar_sysc_power_down(const struct rcar_sysc_ch *sysc_ch);
-int rcar_sysc_power_up(const struct rcar_sysc_ch *sysc_ch);
-bool rcar_sysc_power_is_off(const struct rcar_sysc_ch *sysc_ch);
-void __iomem *rcar_sysc_init(phys_addr_t base);
-
-#endif /* PM_RCAR_H */
index f5c31fbc10b2efbf3c341f9efbaa66f261c0f4d4..c6951ee245889b8f79a83018740c0eea910d60dd 100644 (file)
 #include <linux/spinlock.h>
 #include <linux/io.h>
 #include <linux/delay.h>
+#include <linux/soc/renesas/rcar-sysc.h>
 
 #include <asm/cacheflush.h>
 #include <asm/smp_plat.h>
 #include <asm/smp_scu.h>
 
 #include "common.h"
-#include "pm-rcar.h"
 #include "r8a7779.h"
 
 #define AVECR IOMEM(0xfe700040)
index f6426c6fdefcb489e08dd2c69e47c16d5fc22d59..28f26d5362d8d4d2959cb1737c2ab31b36c925d8 100644 (file)
 #include <linux/init.h>
 #include <linux/smp.h>
 #include <linux/io.h>
+#include <linux/soc/renesas/rcar-sysc.h>
 
 #include <asm/smp_plat.h>
 
 #include "common.h"
 #include "platsmp-apmu.h"
-#include "pm-rcar.h"
 #include "rcar-gen2.h"
 #include "r8a7790.h"
 
index 5ade71306ee10d080414aaf2168fc93fbcd6fe4b..380230f03874d4adb216b90a7433eb592123aa40 100644 (file)
@@ -9,7 +9,8 @@ obj-$(CONFIG_MACH_DOVE)         += dove/
 obj-y                          += fsl/
 obj-$(CONFIG_ARCH_MEDIATEK)    += mediatek/
 obj-$(CONFIG_ARCH_QCOM)                += qcom/
-obj-$(CONFIG_ARCH_ROCKCHIP)            += rockchip/
+obj-$(CONFIG_ARCH_RENESAS)     += renesas/
+obj-$(CONFIG_ARCH_ROCKCHIP)    += rockchip/
 obj-$(CONFIG_SOC_SAMSUNG)      += samsung/
 obj-$(CONFIG_ARCH_SUNXI)       += sunxi/
 obj-$(CONFIG_ARCH_TEGRA)       += tegra/
diff --git a/drivers/soc/renesas/Makefile b/drivers/soc/renesas/Makefile
new file mode 100644 (file)
index 0000000..2b64f6c
--- /dev/null
@@ -0,0 +1,5 @@
+obj-$(CONFIG_ARCH_R8A7779)     += rcar-sysc.o
+obj-$(CONFIG_ARCH_R8A7790)     += rcar-sysc.o
+obj-$(CONFIG_ARCH_R8A7791)     += rcar-sysc.o
+obj-$(CONFIG_ARCH_R8A7793)     += rcar-sysc.o
+obj-$(CONFIG_ARCH_R8A7794)     += rcar-sysc.o
diff --git a/drivers/soc/renesas/rcar-sysc.c b/drivers/soc/renesas/rcar-sysc.c
new file mode 100644 (file)
index 0000000..d59bcdf
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * R-Car SYSC Power management support
+ *
+ * Copyright (C) 2014  Magnus Damm
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/mm.h>
+#include <linux/spinlock.h>
+#include <linux/io.h>
+#include <linux/soc/renesas/rcar-sysc.h>
+
+/* SYSC Common */
+#define SYSCSR                 0x00    /* SYSC Status Register */
+#define SYSCISR                        0x04    /* Interrupt Status Register */
+#define SYSCISCR               0x08    /* Interrupt Status Clear Register */
+#define SYSCIER                        0x0c    /* Interrupt Enable Register */
+#define SYSCIMR                        0x10    /* Interrupt Mask Register */
+
+/* SYSC Status Register */
+#define SYSCSR_PONENB          1       /* Ready for power resume requests */
+#define SYSCSR_POFFENB         0       /* Ready for power shutoff requests */
+
+/*
+ * Power Control Register Offsets inside the register block for each domain
+ * Note: The "CR" registers for ARM cores exist on H1 only
+ *       Use WFI to power off, CPG/APMU to resume ARM cores on R-Car Gen2
+ */
+#define PWRSR_OFFS             0x00    /* Power Status Register */
+#define PWROFFCR_OFFS          0x04    /* Power Shutoff Control Register */
+#define PWROFFSR_OFFS          0x08    /* Power Shutoff Status Register */
+#define PWRONCR_OFFS           0x0c    /* Power Resume Control Register */
+#define PWRONSR_OFFS           0x10    /* Power Resume Status Register */
+#define PWRER_OFFS             0x14    /* Power Shutoff/Resume Error */
+
+
+#define SYSCSR_RETRIES         100
+#define SYSCSR_DELAY_US                1
+
+#define PWRER_RETRIES          100
+#define PWRER_DELAY_US         1
+
+#define SYSCISR_RETRIES                1000
+#define SYSCISR_DELAY_US       1
+
+static void __iomem *rcar_sysc_base;
+static DEFINE_SPINLOCK(rcar_sysc_lock); /* SMP CPUs + I/O devices */
+
+static int rcar_sysc_pwr_on_off(const struct rcar_sysc_ch *sysc_ch, bool on)
+{
+       unsigned int sr_bit, reg_offs;
+       int k;
+
+       if (on) {
+               sr_bit = SYSCSR_PONENB;
+               reg_offs = PWRONCR_OFFS;
+       } else {
+               sr_bit = SYSCSR_POFFENB;
+               reg_offs = PWROFFCR_OFFS;
+       }
+
+       /* Wait until SYSC is ready to accept a power request */
+       for (k = 0; k < SYSCSR_RETRIES; k++) {
+               if (ioread32(rcar_sysc_base + SYSCSR) & BIT(sr_bit))
+                       break;
+               udelay(SYSCSR_DELAY_US);
+       }
+
+       if (k == SYSCSR_RETRIES)
+               return -EAGAIN;
+
+       /* Submit power shutoff or power resume request */
+       iowrite32(BIT(sysc_ch->chan_bit),
+                 rcar_sysc_base + sysc_ch->chan_offs + reg_offs);
+
+       return 0;
+}
+
+static int rcar_sysc_power(const struct rcar_sysc_ch *sysc_ch, bool on)
+{
+       unsigned int isr_mask = BIT(sysc_ch->isr_bit);
+       unsigned int chan_mask = BIT(sysc_ch->chan_bit);
+       unsigned int status;
+       unsigned long flags;
+       int ret = 0;
+       int k;
+
+       spin_lock_irqsave(&rcar_sysc_lock, flags);
+
+       iowrite32(isr_mask, rcar_sysc_base + SYSCISCR);
+
+       /* Submit power shutoff or resume request until it was accepted */
+       for (k = 0; k < PWRER_RETRIES; k++) {
+               ret = rcar_sysc_pwr_on_off(sysc_ch, on);
+               if (ret)
+                       goto out;
+
+               status = ioread32(rcar_sysc_base +
+                                 sysc_ch->chan_offs + PWRER_OFFS);
+               if (!(status & chan_mask))
+                       break;
+
+               udelay(PWRER_DELAY_US);
+       }
+
+       if (k == PWRER_RETRIES) {
+               ret = -EIO;
+               goto out;
+       }
+
+       /* Wait until the power shutoff or resume request has completed * */
+       for (k = 0; k < SYSCISR_RETRIES; k++) {
+               if (ioread32(rcar_sysc_base + SYSCISR) & isr_mask)
+                       break;
+               udelay(SYSCISR_DELAY_US);
+       }
+
+       if (k == SYSCISR_RETRIES)
+               ret = -EIO;
+
+       iowrite32(isr_mask, rcar_sysc_base + SYSCISCR);
+
+ out:
+       spin_unlock_irqrestore(&rcar_sysc_lock, flags);
+
+       pr_debug("sysc power domain %d: %08x -> %d\n",
+                sysc_ch->isr_bit, ioread32(rcar_sysc_base + SYSCISR), ret);
+       return ret;
+}
+
+int rcar_sysc_power_down(const struct rcar_sysc_ch *sysc_ch)
+{
+       return rcar_sysc_power(sysc_ch, false);
+}
+
+int rcar_sysc_power_up(const struct rcar_sysc_ch *sysc_ch)
+{
+       return rcar_sysc_power(sysc_ch, true);
+}
+
+bool rcar_sysc_power_is_off(const struct rcar_sysc_ch *sysc_ch)
+{
+       unsigned int st;
+
+       st = ioread32(rcar_sysc_base + sysc_ch->chan_offs + PWRSR_OFFS);
+       if (st & BIT(sysc_ch->chan_bit))
+               return true;
+
+       return false;
+}
+
+void __iomem *rcar_sysc_init(phys_addr_t base)
+{
+       rcar_sysc_base = ioremap_nocache(base, PAGE_SIZE);
+       if (!rcar_sysc_base)
+               panic("unable to ioremap R-Car SYSC hardware block\n");
+
+       return rcar_sysc_base;
+}
diff --git a/include/linux/soc/renesas/rcar-sysc.h b/include/linux/soc/renesas/rcar-sysc.h
new file mode 100644 (file)
index 0000000..96f30c2
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef __LINUX_SOC_RENESAS_RCAR_SYSC_H__
+#define __LINUX_SOC_RENESAS_RCAR_SYSC_H__
+
+#include <linux/types.h>
+
+struct rcar_sysc_ch {
+       u16 chan_offs;
+       u8 chan_bit;
+       u8 isr_bit;
+};
+
+int rcar_sysc_power_down(const struct rcar_sysc_ch *sysc_ch);
+int rcar_sysc_power_up(const struct rcar_sysc_ch *sysc_ch);
+bool rcar_sysc_power_is_off(const struct rcar_sysc_ch *sysc_ch);
+void __iomem *rcar_sysc_init(phys_addr_t base);
+
+#endif /* __LINUX_SOC_RENESAS_RCAR_SYSC_H__ */