Commit be783cc8 authored by Stephen Boyd's avatar Stephen Boyd

Merge tag 'clk-renesas-for-v4.20-tag2' of...

Merge tag 'clk-renesas-for-v4.20-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers into clk-renesas

Pull Renesas clk driver updates from Geert Uytterhoeven:

 - Add support for CMT timer clocks on R-Car V3H
 - Add support for SHDI and various timer clocks on R-Car V3M
 - Add support for the new RZ/A2 (R7S9210) SoC, including early clock
   support for the Renesas CPG/MSSR driver
 - Add support for the new RZ/G1N (R8A7744) and RZ/G2E (R8A774C0) SoCs
 - Convert DT binding includes to SPDX license identifiers

* tag 'clk-renesas-for-v4.20-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers:
  clk: renesas: r7s9210: Add SPI clocks
  clk: renesas: r7s9210: Move table update to separate function
  clk: renesas: r7s9210: Convert some clocks to early
  clk: renesas: cpg-mssr: Add early clock support
  clk: renesas: r8a77970: Add TPU clock
  clk: renesas: r8a77990: Fix incorrect PLL0 divider in comment
  dt-bindings: clock: renesas: cpg-mssr: Document r8a774c0
  clk: renesas: cpg-mssr: Add r8a774c0 support
  clk: renesas: Add r8a774c0 CPG Core Clock Definitions
  clk: renesas: r8a7743: Add r8a7744 support
  clk: renesas: Add r8a7744 CPG Core Clock Definitions
  dt-bindings: clock: renesas: cpg-mssr: Document r8a7744 binding
  dt-bindings: clock: renesas: Convert to SPDX identifiers
  clk: renesas: cpg-mssr: Add R7S9210 support
  clk: renesas: r8a77970: Add TMU clocks
  clk: renesas: r8a77970: Add CMT clocks
  clk: renesas: r9a06g032: Fix UART34567 clock rate
  clk: renesas: r8a77970: Add SD0H/SD0 clocks for SDHI
  clk: renesas: r8a77980: Add CMT clocks
parents f676d861 a53a28dc
...@@ -13,10 +13,13 @@ They provide the following functionalities: ...@@ -13,10 +13,13 @@ They provide the following functionalities:
Required Properties: Required Properties:
- compatible: Must be one of: - compatible: Must be one of:
- "renesas,r7s9210-cpg-mssr" for the r7s9210 SoC (RZ/A2)
- "renesas,r8a7743-cpg-mssr" for the r8a7743 SoC (RZ/G1M) - "renesas,r8a7743-cpg-mssr" for the r8a7743 SoC (RZ/G1M)
- "renesas,r8a7744-cpg-mssr" for the r8a7744 SoC (RZ/G1N)
- "renesas,r8a7745-cpg-mssr" for the r8a7745 SoC (RZ/G1E) - "renesas,r8a7745-cpg-mssr" for the r8a7745 SoC (RZ/G1E)
- "renesas,r8a77470-cpg-mssr" for the r8a77470 SoC (RZ/G1C) - "renesas,r8a77470-cpg-mssr" for the r8a77470 SoC (RZ/G1C)
- "renesas,r8a774a1-cpg-mssr" for the r8a774a1 SoC (RZ/G2M) - "renesas,r8a774a1-cpg-mssr" for the r8a774a1 SoC (RZ/G2M)
- "renesas,r8a774c0-cpg-mssr" for the r8a774c0 SoC (RZ/G2E)
- "renesas,r8a7790-cpg-mssr" for the r8a7790 SoC (R-Car H2) - "renesas,r8a7790-cpg-mssr" for the r8a7790 SoC (R-Car H2)
- "renesas,r8a7791-cpg-mssr" for the r8a7791 SoC (R-Car M2-W) - "renesas,r8a7791-cpg-mssr" for the r8a7791 SoC (R-Car M2-W)
- "renesas,r8a7792-cpg-mssr" for the r8a7792 SoC (R-Car V2H) - "renesas,r8a7792-cpg-mssr" for the r8a7792 SoC (R-Car V2H)
...@@ -36,12 +39,13 @@ Required Properties: ...@@ -36,12 +39,13 @@ Required Properties:
- clocks: References to external parent clocks, one entry for each entry in - clocks: References to external parent clocks, one entry for each entry in
clock-names clock-names
- clock-names: List of external parent clock names. Valid names are: - clock-names: List of external parent clock names. Valid names are:
- "extal" (r8a7743, r8a7745, r8a77470, r8a774a1, r8a7790, r8a7791, - "extal" (r7s9210, r8a7743, r8a7744, r8a7745, r8a77470, r8a774a1,
r8a7792, r8a7793, r8a7794, r8a7795, r8a7796, r8a77965, r8a774c0, r8a7790, r8a7791, r8a7792, r8a7793, r8a7794,
r8a77970, r8a77980, r8a77990, r8a77995) r8a7795, r8a7796, r8a77965, r8a77970, r8a77980, r8a77990,
r8a77995)
- "extalr" (r8a774a1, r8a7795, r8a7796, r8a77965, r8a77970, r8a77980) - "extalr" (r8a774a1, r8a7795, r8a7796, r8a77965, r8a77970, r8a77980)
- "usb_extal" (r8a7743, r8a7745, r8a77470, r8a7790, r8a7791, r8a7793, - "usb_extal" (r8a7743, r8a7744, r8a7745, r8a77470, r8a7790, r8a7791,
r8a7794) r8a7793, r8a7794)
- #clock-cells: Must be 2 - #clock-cells: Must be 2
- For CPG core clocks, the two clock specifier cells must be "CPG_CORE" - For CPG core clocks, the two clock specifier cells must be "CPG_CORE"
......
...@@ -3,12 +3,14 @@ config CLK_RENESAS ...@@ -3,12 +3,14 @@ config CLK_RENESAS
default y if ARCH_RENESAS default y if ARCH_RENESAS
select CLK_EMEV2 if ARCH_EMEV2 select CLK_EMEV2 if ARCH_EMEV2
select CLK_RZA1 if ARCH_R7S72100 select CLK_RZA1 if ARCH_R7S72100
select CLK_R7S9210 if ARCH_R7S9210
select CLK_R8A73A4 if ARCH_R8A73A4 select CLK_R8A73A4 if ARCH_R8A73A4
select CLK_R8A7740 if ARCH_R8A7740 select CLK_R8A7740 if ARCH_R8A7740
select CLK_R8A7743 if ARCH_R8A7743 select CLK_R8A7743 if ARCH_R8A7743 || ARCH_R8A7744
select CLK_R8A7745 if ARCH_R8A7745 select CLK_R8A7745 if ARCH_R8A7745
select CLK_R8A77470 if ARCH_R8A77470 select CLK_R8A77470 if ARCH_R8A77470
select CLK_R8A774A1 if ARCH_R8A774A1 select CLK_R8A774A1 if ARCH_R8A774A1
select CLK_R8A774C0 if ARCH_R8A774C0
select CLK_R8A7778 if ARCH_R8A7778 select CLK_R8A7778 if ARCH_R8A7778
select CLK_R8A7779 if ARCH_R8A7779 select CLK_R8A7779 if ARCH_R8A7779
select CLK_R8A7790 if ARCH_R8A7790 select CLK_R8A7790 if ARCH_R8A7790
...@@ -46,6 +48,10 @@ config CLK_RZA1 ...@@ -46,6 +48,10 @@ config CLK_RZA1
bool "RZ/A1H clock support" if COMPILE_TEST bool "RZ/A1H clock support" if COMPILE_TEST
select CLK_RENESAS_CPG_MSTP select CLK_RENESAS_CPG_MSTP
config CLK_R7S9210
bool "RZ/A2 clock support" if COMPILE_TEST
select CLK_RENESAS_CPG_MSSR
config CLK_R8A73A4 config CLK_R8A73A4
bool "R-Mobile APE6 clock support" if COMPILE_TEST bool "R-Mobile APE6 clock support" if COMPILE_TEST
select CLK_RENESAS_CPG_MSTP select CLK_RENESAS_CPG_MSTP
...@@ -72,6 +78,10 @@ config CLK_R8A774A1 ...@@ -72,6 +78,10 @@ config CLK_R8A774A1
bool "RZ/G2M clock support" if COMPILE_TEST bool "RZ/G2M clock support" if COMPILE_TEST
select CLK_RCAR_GEN3_CPG select CLK_RCAR_GEN3_CPG
config CLK_R8A774C0
bool "RZ/G2E clock support" if COMPILE_TEST
select CLK_RCAR_GEN3_CPG
config CLK_R8A7778 config CLK_R8A7778
bool "R-Car M1A clock support" if COMPILE_TEST bool "R-Car M1A clock support" if COMPILE_TEST
select CLK_RENESAS_CPG_MSTP select CLK_RENESAS_CPG_MSTP
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
# SoC # SoC
obj-$(CONFIG_CLK_EMEV2) += clk-emev2.o obj-$(CONFIG_CLK_EMEV2) += clk-emev2.o
obj-$(CONFIG_CLK_RZA1) += clk-rz.o obj-$(CONFIG_CLK_RZA1) += clk-rz.o
obj-$(CONFIG_CLK_R7S9210) += r7s9210-cpg-mssr.o
obj-$(CONFIG_CLK_R8A73A4) += clk-r8a73a4.o obj-$(CONFIG_CLK_R8A73A4) += clk-r8a73a4.o
obj-$(CONFIG_CLK_R8A7740) += clk-r8a7740.o obj-$(CONFIG_CLK_R8A7740) += clk-r8a7740.o
obj-$(CONFIG_CLK_R8A7743) += r8a7743-cpg-mssr.o obj-$(CONFIG_CLK_R8A7743) += r8a7743-cpg-mssr.o
obj-$(CONFIG_CLK_R8A7745) += r8a7745-cpg-mssr.o obj-$(CONFIG_CLK_R8A7745) += r8a7745-cpg-mssr.o
obj-$(CONFIG_CLK_R8A77470) += r8a77470-cpg-mssr.o obj-$(CONFIG_CLK_R8A77470) += r8a77470-cpg-mssr.o
obj-$(CONFIG_CLK_R8A774A1) += r8a774a1-cpg-mssr.o obj-$(CONFIG_CLK_R8A774A1) += r8a774a1-cpg-mssr.o
obj-$(CONFIG_CLK_R8A774C0) += r8a774c0-cpg-mssr.o
obj-$(CONFIG_CLK_R8A7778) += clk-r8a7778.o obj-$(CONFIG_CLK_R8A7778) += clk-r8a7778.o
obj-$(CONFIG_CLK_R8A7779) += clk-r8a7779.o obj-$(CONFIG_CLK_R8A7779) += clk-r8a7779.o
obj-$(CONFIG_CLK_R8A7790) += r8a7790-cpg-mssr.o obj-$(CONFIG_CLK_R8A7790) += r8a7790-cpg-mssr.o
......
// SPDX-License-Identifier: GPL-2.0
/*
* R7S9210 Clock Pulse Generator / Module Standby
*
* Based on r8a7795-cpg-mssr.c
*
* Copyright (C) 2018 Chris Brandt
* Copyright (C) 2018 Renesas Electronics Corp.
*
*/
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <dt-bindings/clock/r7s9210-cpg-mssr.h>
#include "renesas-cpg-mssr.h"
#define CPG_FRQCR 0x00
static u8 cpg_mode;
/* Internal Clock ratio table */
static const struct {
unsigned int i;
unsigned int g;
unsigned int b;
unsigned int p1;
/* p0 is always 32 */;
} ratio_tab[5] = { /* I, G, B, P1 */
{ 2, 4, 8, 16}, /* FRQCR = 0x012 */
{ 4, 4, 8, 16}, /* FRQCR = 0x112 */
{ 8, 4, 8, 16}, /* FRQCR = 0x212 */
{ 16, 8, 16, 16}, /* FRQCR = 0x322 */
{ 16, 16, 32, 32}, /* FRQCR = 0x333 */
};
enum rz_clk_types {
CLK_TYPE_RZA_MAIN = CLK_TYPE_CUSTOM,
CLK_TYPE_RZA_PLL,
};
enum clk_ids {
/* Core Clock Outputs exported to DT */
LAST_DT_CORE_CLK = R7S9210_CLK_P0,
/* External Input Clocks */
CLK_EXTAL,
/* Internal Core Clocks */
CLK_MAIN,
CLK_PLL,
/* Module Clocks */
MOD_CLK_BASE
};
static struct cpg_core_clk r7s9210_early_core_clks[] = {
/* External Clock Inputs */
DEF_INPUT("extal", CLK_EXTAL),
/* Internal Core Clocks */
DEF_BASE(".main", CLK_MAIN, CLK_TYPE_RZA_MAIN, CLK_EXTAL),
DEF_BASE(".pll", CLK_PLL, CLK_TYPE_RZA_PLL, CLK_MAIN),
/* Core Clock Outputs */
DEF_FIXED("p1c", R7S9210_CLK_P1C, CLK_PLL, 16, 1),
};
static const struct mssr_mod_clk r7s9210_early_mod_clks[] __initconst = {
DEF_MOD_STB("ostm2", 34, R7S9210_CLK_P1C),
DEF_MOD_STB("ostm1", 35, R7S9210_CLK_P1C),
DEF_MOD_STB("ostm0", 36, R7S9210_CLK_P1C),
};
static struct cpg_core_clk r7s9210_core_clks[] = {
/* Core Clock Outputs */
DEF_FIXED("i", R7S9210_CLK_I, CLK_PLL, 2, 1),
DEF_FIXED("g", R7S9210_CLK_G, CLK_PLL, 4, 1),
DEF_FIXED("b", R7S9210_CLK_B, CLK_PLL, 8, 1),
DEF_FIXED("p1", R7S9210_CLK_P1, CLK_PLL, 16, 1),
DEF_FIXED("p0", R7S9210_CLK_P0, CLK_PLL, 32, 1),
};
static const struct mssr_mod_clk r7s9210_mod_clks[] __initconst = {
DEF_MOD_STB("scif4", 43, R7S9210_CLK_P1C),
DEF_MOD_STB("scif3", 44, R7S9210_CLK_P1C),
DEF_MOD_STB("scif2", 45, R7S9210_CLK_P1C),
DEF_MOD_STB("scif1", 46, R7S9210_CLK_P1C),
DEF_MOD_STB("scif0", 47, R7S9210_CLK_P1C),
DEF_MOD_STB("ether1", 64, R7S9210_CLK_B),
DEF_MOD_STB("ether0", 65, R7S9210_CLK_B),
DEF_MOD_STB("i2c3", 84, R7S9210_CLK_P1),
DEF_MOD_STB("i2c2", 85, R7S9210_CLK_P1),
DEF_MOD_STB("i2c1", 86, R7S9210_CLK_P1),
DEF_MOD_STB("i2c0", 87, R7S9210_CLK_P1),
DEF_MOD_STB("spi2", 95, R7S9210_CLK_P1),
DEF_MOD_STB("spi1", 96, R7S9210_CLK_P1),
DEF_MOD_STB("spi0", 97, R7S9210_CLK_P1),
};
/* The clock dividers in the table vary based on DT and register settings */
static void __init r7s9210_update_clk_table(struct clk *extal_clk,
void __iomem *base)
{
int i;
u16 frqcr;
u8 index;
/* If EXTAL is above 12MHz, then we know it is Mode 1 */
if (clk_get_rate(extal_clk) > 12000000)
cpg_mode = 1;
frqcr = clk_readl(base + CPG_FRQCR) & 0xFFF;
if (frqcr == 0x012)
index = 0;
else if (frqcr == 0x112)
index = 1;
else if (frqcr == 0x212)
index = 2;
else if (frqcr == 0x322)
index = 3;
else if (frqcr == 0x333)
index = 4;
else
BUG_ON(1); /* Illegal FRQCR value */
for (i = 0; i < ARRAY_SIZE(r7s9210_core_clks); i++) {
switch (r7s9210_core_clks[i].id) {
case R7S9210_CLK_I:
r7s9210_core_clks[i].div = ratio_tab[index].i;
break;
case R7S9210_CLK_G:
r7s9210_core_clks[i].div = ratio_tab[index].g;
break;
case R7S9210_CLK_B:
r7s9210_core_clks[i].div = ratio_tab[index].b;
break;
case R7S9210_CLK_P1:
case R7S9210_CLK_P1C:
r7s9210_core_clks[i].div = ratio_tab[index].p1;
break;
case R7S9210_CLK_P0:
r7s9210_core_clks[i].div = 32;
break;
}
}
}
struct clk * __init rza2_cpg_clk_register(struct device *dev,
const struct cpg_core_clk *core, const struct cpg_mssr_info *info,
struct clk **clks, void __iomem *base,
struct raw_notifier_head *notifiers)
{
struct clk *parent;
unsigned int mult = 1;
unsigned int div = 1;
parent = clks[core->parent];
if (IS_ERR(parent))
return ERR_CAST(parent);
switch (core->id) {
case CLK_MAIN:
break;
case CLK_PLL:
if (cpg_mode)
mult = 44; /* Divider 1 is 1/2 */
else
mult = 88; /* Divider 1 is 1 */
break;
default:
return ERR_PTR(-EINVAL);
}
if (core->id == CLK_MAIN)
r7s9210_update_clk_table(parent, base);
return clk_register_fixed_factor(NULL, core->name,
__clk_get_name(parent), 0, mult, div);
}
const struct cpg_mssr_info r7s9210_cpg_mssr_info __initconst = {
/* Early Clocks */
.early_core_clks = r7s9210_early_core_clks,
.num_early_core_clks = ARRAY_SIZE(r7s9210_early_core_clks),
.early_mod_clks = r7s9210_early_mod_clks,
.num_early_mod_clks = ARRAY_SIZE(r7s9210_early_mod_clks),
/* Core Clocks */
.core_clks = r7s9210_core_clks,
.num_core_clks = ARRAY_SIZE(r7s9210_core_clks),
.last_dt_core_clk = LAST_DT_CORE_CLK,
.num_total_core_clks = MOD_CLK_BASE,
/* Module Clocks */
.mod_clks = r7s9210_mod_clks,
.num_mod_clks = ARRAY_SIZE(r7s9210_mod_clks),
.num_hw_mod_clks = 11 * 32, /* includes STBCR0 which doesn't exist */
/* Callbacks */
.cpg_clk_register = rza2_cpg_clk_register,
/* RZ/A2 has Standby Control Registers */
.stbyctrl = true,
};
static void __init r7s9210_cpg_mssr_early_init(struct device_node *np)
{
cpg_mssr_early_init(np, &r7s9210_cpg_mssr_info);
}
CLK_OF_DECLARE_DRIVER(cpg_mstp_clks, "renesas,r7s9210-cpg-mssr",
r7s9210_cpg_mssr_early_init);
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/of.h>
#include <linux/soc/renesas/rcar-rst.h> #include <linux/soc/renesas/rcar-rst.h>
#include <dt-bindings/clock/r8a7743-cpg-mssr.h> #include <dt-bindings/clock/r8a7743-cpg-mssr.h>
...@@ -37,7 +38,7 @@ enum clk_ids { ...@@ -37,7 +38,7 @@ enum clk_ids {
MOD_CLK_BASE MOD_CLK_BASE
}; };
static const struct cpg_core_clk r8a7743_core_clks[] __initconst = { static struct cpg_core_clk r8a7743_core_clks[] __initdata = {
/* External Clock Inputs */ /* External Clock Inputs */
DEF_INPUT("extal", CLK_EXTAL), DEF_INPUT("extal", CLK_EXTAL),
DEF_INPUT("usb_extal", CLK_USB_EXTAL), DEF_INPUT("usb_extal", CLK_USB_EXTAL),
...@@ -238,6 +239,8 @@ static const struct rcar_gen2_cpg_pll_config cpg_pll_configs[8] __initconst = { ...@@ -238,6 +239,8 @@ static const struct rcar_gen2_cpg_pll_config cpg_pll_configs[8] __initconst = {
static int __init r8a7743_cpg_mssr_init(struct device *dev) static int __init r8a7743_cpg_mssr_init(struct device *dev)
{ {
const struct rcar_gen2_cpg_pll_config *cpg_pll_config; const struct rcar_gen2_cpg_pll_config *cpg_pll_config;
struct device_node *np = dev->of_node;
unsigned int i;
u32 cpg_mode; u32 cpg_mode;
int error; int error;
...@@ -247,6 +250,14 @@ static int __init r8a7743_cpg_mssr_init(struct device *dev) ...@@ -247,6 +250,14 @@ static int __init r8a7743_cpg_mssr_init(struct device *dev)
cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)]; cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)];
if (of_device_is_compatible(np, "renesas,r8a7744-cpg-mssr")) {
/* RZ/G1N uses a 1/5 divider for ZG */
for (i = 0; i < ARRAY_SIZE(r8a7743_core_clks); i++)
if (r8a7743_core_clks[i].id == R8A7743_CLK_ZG) {
r8a7743_core_clks[i].div = 5;
break;
}
}
return rcar_gen2_cpg_init(cpg_pll_config, 2, cpg_mode); return rcar_gen2_cpg_init(cpg_pll_config, 2, cpg_mode);
} }
......
This diff is collapsed.
/* /*
* r8a77970 Clock Pulse Generator / Module Standby and Software Reset * r8a77970 Clock Pulse Generator / Module Standby and Software Reset
* *
* Copyright (C) 2017 Cogent Embedded Inc. * Copyright (C) 2017-2018 Cogent Embedded Inc.
* *
* Based on r8a7795-cpg-mssr.c * Based on r8a7795-cpg-mssr.c
* *
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* the Free Software Foundation; version 2 of the License. * the Free Software Foundation; version 2 of the License.
*/ */
#include <linux/clk-provider.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -22,6 +23,13 @@ ...@@ -22,6 +23,13 @@
#include "renesas-cpg-mssr.h" #include "renesas-cpg-mssr.h"
#include "rcar-gen3-cpg.h" #include "rcar-gen3-cpg.h"
#define CPG_SD0CKCR 0x0074
enum r8a77970_clk_types {
CLK_TYPE_R8A77970_SD0H = CLK_TYPE_GEN3_SOC_BASE,
CLK_TYPE_R8A77970_SD0,
};
enum clk_ids { enum clk_ids {
/* Core Clock Outputs exported to DT */ /* Core Clock Outputs exported to DT */
LAST_DT_CORE_CLK = R8A77970_CLK_OSC, LAST_DT_CORE_CLK = R8A77970_CLK_OSC,
...@@ -42,6 +50,20 @@ enum clk_ids { ...@@ -42,6 +50,20 @@ enum clk_ids {
MOD_CLK_BASE MOD_CLK_BASE
}; };
static spinlock_t cpg_lock;
static const struct clk_div_table cpg_sd0h_div_table[] = {
{ 0, 2 }, { 1, 3 }, { 2, 4 }, { 3, 6 },
{ 4, 8 }, { 5, 12 }, { 6, 16 }, { 7, 18 },
{ 8, 24 }, { 10, 36 }, { 11, 48 }, { 0, 0 },
};
static const struct clk_div_table cpg_sd0_div_table[] = {
{ 4, 8 }, { 5, 12 }, { 6, 16 }, { 7, 18 },
{ 8, 24 }, { 10, 36 }, { 11, 48 }, { 12, 10 },
{ 0, 0 },
};
static const struct cpg_core_clk r8a77970_core_clks[] __initconst = { static const struct cpg_core_clk r8a77970_core_clks[] __initconst = {
/* External Clock Inputs */ /* External Clock Inputs */
DEF_INPUT("extal", CLK_EXTAL), DEF_INPUT("extal", CLK_EXTAL),
...@@ -68,6 +90,10 @@ static const struct cpg_core_clk r8a77970_core_clks[] __initconst = { ...@@ -68,6 +90,10 @@ static const struct cpg_core_clk r8a77970_core_clks[] __initconst = {
DEF_FIXED("s2d2", R8A77970_CLK_S2D2, CLK_PLL1_DIV2, 12, 1), DEF_FIXED("s2d2", R8A77970_CLK_S2D2, CLK_PLL1_DIV2, 12, 1),
DEF_FIXED("s2d4", R8A77970_CLK_S2D4, CLK_PLL1_DIV2, 24, 1), DEF_FIXED("s2d4", R8A77970_CLK_S2D4, CLK_PLL1_DIV2, 24, 1),
DEF_BASE("sd0h", R8A77970_CLK_SD0H, CLK_TYPE_R8A77970_SD0H,
CLK_PLL1_DIV2),
DEF_BASE("sd0", R8A77970_CLK_SD0, CLK_TYPE_R8A77970_SD0, CLK_PLL1_DIV2),
DEF_FIXED("cl", R8A77970_CLK_CL, CLK_PLL1_DIV2, 48, 1), DEF_FIXED("cl", R8A77970_CLK_CL, CLK_PLL1_DIV2, 48, 1),
DEF_FIXED("cp", R8A77970_CLK_CP, CLK_EXTAL, 2, 1), DEF_FIXED("cp", R8A77970_CLK_CP, CLK_EXTAL, 2, 1),
...@@ -80,6 +106,11 @@ static const struct cpg_core_clk r8a77970_core_clks[] __initconst = { ...@@ -80,6 +106,11 @@ static const struct cpg_core_clk r8a77970_core_clks[] __initconst = {
}; };
static const struct mssr_mod_clk r8a77970_mod_clks[] __initconst = { static const struct mssr_mod_clk r8a77970_mod_clks[] __initconst = {
DEF_MOD("tmu4", 121, R8A77970_CLK_S2D2),
DEF_MOD("tmu3", 122, R8A77970_CLK_S2D2),
DEF_MOD("tmu2", 123, R8A77970_CLK_S2D2),
DEF_MOD("tmu1", 124, R8A77970_CLK_S2D2),
DEF_MOD("tmu0", 125, R8A77970_CLK_CP),
DEF_MOD("ivcp1e", 127, R8A77970_CLK_S2D1), DEF_MOD("ivcp1e", 127, R8A77970_CLK_S2D1),
DEF_MOD("scif4", 203, R8A77970_CLK_S2D4), DEF_MOD("scif4", 203, R8A77970_CLK_S2D4),
DEF_MOD("scif3", 204, R8A77970_CLK_S2D4), DEF_MOD("scif3", 204, R8A77970_CLK_S2D4),
...@@ -92,6 +123,12 @@ static const struct mssr_mod_clk r8a77970_mod_clks[] __initconst = { ...@@ -92,6 +123,12 @@ static const struct mssr_mod_clk r8a77970_mod_clks[] __initconst = {
DEF_MOD("mfis", 213, R8A77970_CLK_S2D2), DEF_MOD("mfis", 213, R8A77970_CLK_S2D2),
DEF_MOD("sys-dmac2", 217, R8A77970_CLK_S2D1), DEF_MOD("sys-dmac2", 217, R8A77970_CLK_S2D1),
DEF_MOD("sys-dmac1", 218, R8A77970_CLK_S2D1), DEF_MOD("sys-dmac1", 218, R8A77970_CLK_S2D1),
DEF_MOD("cmt3", 300, R8A77970_CLK_R),
DEF_MOD("cmt2", 301, R8A77970_CLK_R),
DEF_MOD("cmt1", 302, R8A77970_CLK_R),
DEF_MOD("cmt0", 303, R8A77970_CLK_R),
DEF_MOD("tpu0", 304, R8A77970_CLK_S2D4),
DEF_MOD("sd-if", 314, R8A77970_CLK_SD0),
DEF_MOD("rwdt", 402, R8A77970_CLK_R), DEF_MOD("rwdt", 402, R8A77970_CLK_R),
DEF_MOD("intc-ex", 407, R8A77970_CLK_CP), DEF_MOD("intc-ex", 407, R8A77970_CLK_CP),
DEF_MOD("intc-ap", 408, R8A77970_CLK_S2D1), DEF_MOD("intc-ap", 408, R8A77970_CLK_S2D1),
...@@ -173,11 +210,46 @@ static int __init r8a77970_cpg_mssr_init(struct device *dev) ...@@ -173,11 +210,46 @@ static int __init r8a77970_cpg_mssr_init(struct device *dev)
if (error) if (error)
return error; return error;
spin_lock_init(&cpg_lock);
cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)]; cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)];
return rcar_gen3_cpg_init(cpg_pll_config, CLK_EXTALR, cpg_mode); return rcar_gen3_cpg_init(cpg_pll_config, CLK_EXTALR, cpg_mode);
} }
static struct clk * __init r8a77970_cpg_clk_register(struct device *dev,
const struct cpg_core_clk *core, const struct cpg_mssr_info *info,
struct clk **clks, void __iomem *base,
struct raw_notifier_head *notifiers)
{
const struct clk_div_table *table;
const struct clk *parent;
unsigned int shift;
switch (core->type) {
case CLK_TYPE_R8A77970_SD0H:
table = cpg_sd0h_div_table;
shift = 8;
break;
case CLK_TYPE_R8A77970_SD0:
table = cpg_sd0_div_table;
shift = 4;
break;
default:
return rcar_gen3_cpg_clk_register(dev, core, info, clks, base,
notifiers);
}
parent = clks[core->parent];
if (IS_ERR(parent))
return ERR_CAST(parent);
return clk_register_divider_table(NULL, core->name,
__clk_get_name(parent), 0,
base + CPG_SD0CKCR,
shift, 4, 0, table, &cpg_lock);
}
const struct cpg_mssr_info r8a77970_cpg_mssr_info __initconst = { const struct cpg_mssr_info r8a77970_cpg_mssr_info __initconst = {
/* Core Clocks */ /* Core Clocks */
.core_clks = r8a77970_core_clks, .core_clks = r8a77970_core_clks,
...@@ -196,5 +268,5 @@ const struct cpg_mssr_info r8a77970_cpg_mssr_info __initconst = { ...@@ -196,5 +268,5 @@ const struct cpg_mssr_info r8a77970_cpg_mssr_info __initconst = {
/* Callbacks */ /* Callbacks */
.init = r8a77970_cpg_mssr_init, .init = r8a77970_cpg_mssr_init,
.cpg_clk_register = rcar_gen3_cpg_clk_register, .cpg_clk_register = r8a77970_cpg_clk_register,
}; };
...@@ -119,6 +119,10 @@ static const struct mssr_mod_clk r8a77980_mod_clks[] __initconst = { ...@@ -119,6 +119,10 @@ static const struct mssr_mod_clk r8a77980_mod_clks[] __initconst = {
DEF_MOD("msiof0", 211, R8A77980_CLK_MSO), DEF_MOD("msiof0", 211, R8A77980_CLK_MSO),
DEF_MOD("sys-dmac2", 217, R8A77980_CLK_S0D3), DEF_MOD("sys-dmac2", 217, R8A77980_CLK_S0D3),
DEF_MOD("sys-dmac1", 218, R8A77980_CLK_S0D3), DEF_MOD("sys-dmac1", 218, R8A77980_CLK_S0D3),
DEF_MOD("cmt3", 300, R8A77980_CLK_R),
DEF_MOD("cmt2", 301, R8A77980_CLK_R),
DEF_MOD("cmt1", 302, R8A77980_CLK_R),
DEF_MOD("cmt0", 303, R8A77980_CLK_R),
DEF_MOD("tpu0", 304, R8A77980_CLK_S3D4), DEF_MOD("tpu0", 304, R8A77980_CLK_S3D4),
DEF_MOD("sdif", 314, R8A77980_CLK_SD0), DEF_MOD("sdif", 314, R8A77980_CLK_SD0),
DEF_MOD("pciec0", 319, R8A77980_CLK_S2D2), DEF_MOD("pciec0", 319, R8A77980_CLK_S2D2),
......
...@@ -250,8 +250,8 @@ static const unsigned int r8a77990_crit_mod_clks[] __initconst = { ...@@ -250,8 +250,8 @@ static const unsigned int r8a77990_crit_mod_clks[] __initconst = {
/* /*
* MD19 EXTAL (MHz) PLL0 PLL1 PLL3 * MD19 EXTAL (MHz) PLL0 PLL1 PLL3
*-------------------------------------------------------------------- *--------------------------------------------------------------------
* 0 48 x 1 x100/4 x100/3 x100/3 * 0 48 x 1 x100/1 x100/3 x100/3
* 1 48 x 1 x100/4 x100/3 x58/3 * 1 48 x 1 x100/1 x100/3 x58/3
*/ */
#define CPG_PLL_CONFIG_INDEX(md) (((md) & BIT(19)) >> 19) #define CPG_PLL_CONFIG_INDEX(md) (((md) & BIT(19)) >> 19)
......
...@@ -539,7 +539,8 @@ r9a06g032_div_round_rate(struct clk_hw *hw, ...@@ -539,7 +539,8 @@ r9a06g032_div_round_rate(struct clk_hw *hw,
* several uarts attached to this divider, and changing this impacts * several uarts attached to this divider, and changing this impacts
* everyone. * everyone.
*/ */
if (clk->index == R9A06G032_DIV_UART) { if (clk->index == R9A06G032_DIV_UART ||
clk->index == R9A06G032_DIV_P2_PG) {
pr_devel("%s div uart hack!\n", __func__); pr_devel("%s div uart hack!\n", __func__);
return clk_get_rate(hw->clk); return clk_get_rate(hw->clk);
} }
......
...@@ -25,6 +25,9 @@ enum rcar_gen3_clk_types { ...@@ -25,6 +25,9 @@ enum rcar_gen3_clk_types {
CLK_TYPE_GEN3_Z2, CLK_TYPE_GEN3_Z2,
CLK_TYPE_GEN3_OSC, /* OSC EXTAL predivider and fixed divider */ CLK_TYPE_GEN3_OSC, /* OSC EXTAL predivider and fixed divider */
CLK_TYPE_GEN3_RCKSEL, /* Select parent/divider using RCKCR.CKSEL */ CLK_TYPE_GEN3_RCKSEL, /* Select parent/divider using RCKCR.CKSEL */
/* SoC specific definitions start here */
CLK_TYPE_GEN3_SOC_BASE,
}; };
#define DEF_GEN3_SD(_name, _id, _parent, _offset) \ #define DEF_GEN3_SD(_name, _id, _parent, _offset) \
......
...@@ -73,6 +73,17 @@ static const u16 smstpcr[] = { ...@@ -73,6 +73,17 @@ static const u16 smstpcr[] = {
#define SMSTPCR(i) smstpcr[i] #define SMSTPCR(i) smstpcr[i]
/*
* Standby Control Register offsets (RZ/A)
* Base address is FRQCR register
*/
static const u16 stbcr[] = {
0xFFFF/*dummy*/, 0x010, 0x014, 0x410, 0x414, 0x418, 0x41C, 0x420,
0x424, 0x428, 0x42C,
};
#define STBCR(i) stbcr[i]
/* /*
* Software Reset Register offsets * Software Reset Register offsets
...@@ -110,6 +121,7 @@ static const u16 srcr[] = { ...@@ -110,6 +121,7 @@ static const u16 srcr[] = {
* @notifiers: Notifier chain to save/restore clock state for system resume * @notifiers: Notifier chain to save/restore clock state for system resume
* @smstpcr_saved[].mask: Mask of SMSTPCR[] bits under our control * @smstpcr_saved[].mask: Mask of SMSTPCR[] bits under our control
* @smstpcr_saved[].val: Saved values of SMSTPCR[] * @smstpcr_saved[].val: Saved values of SMSTPCR[]
* @stbyctrl: This device has Standby Control Registers
*/ */
struct cpg_mssr_priv { struct cpg_mssr_priv {
#ifdef CONFIG_RESET_CONTROLLER #ifdef CONFIG_RESET_CONTROLLER
...@@ -118,11 +130,13 @@ struct cpg_mssr_priv { ...@@ -118,11 +130,13 @@ struct cpg_mssr_priv {
struct device *dev; struct device *dev;
void __iomem *base; void __iomem *base;
spinlock_t rmw_lock; spinlock_t rmw_lock;
struct device_node *np;
struct clk **clks; struct clk **clks;
unsigned int num_core_clks; unsigned int num_core_clks;
unsigned int num_mod_clks; unsigned int num_mod_clks;
unsigned int last_dt_core_clk; unsigned int last_dt_core_clk;
bool stbyctrl;
struct raw_notifier_head notifiers; struct raw_notifier_head notifiers;
struct { struct {
...@@ -131,6 +145,7 @@ struct cpg_mssr_priv { ...@@ -131,6 +145,7 @@ struct cpg_mssr_priv {
} smstpcr_saved[ARRAY_SIZE(smstpcr)]; } smstpcr_saved[ARRAY_SIZE(smstpcr)];
}; };
static struct cpg_mssr_priv *cpg_mssr_priv;
/** /**
* struct mstp_clock - MSTP gating clock * struct mstp_clock - MSTP gating clock
...@@ -162,16 +177,29 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable) ...@@ -162,16 +177,29 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
enable ? "ON" : "OFF"); enable ? "ON" : "OFF");
spin_lock_irqsave(&priv->rmw_lock, flags); spin_lock_irqsave(&priv->rmw_lock, flags);
value = readl(priv->base + SMSTPCR(reg)); if (priv->stbyctrl) {
if (enable) value = readb(priv->base + STBCR(reg));
value &= ~bitmask; if (enable)
else value &= ~bitmask;
value |= bitmask; else
writel(value, priv->base + SMSTPCR(reg)); value |= bitmask;
writeb(value, priv->base + STBCR(reg));
/* dummy read to ensure write has completed */
readb(priv->base + STBCR(reg));
barrier_data(priv->base + STBCR(reg));
} else {
value = readl(priv->base + SMSTPCR(reg));
if (enable)
value &= ~bitmask;
else
value |= bitmask;
writel(value, priv->base + SMSTPCR(reg));
}
spin_unlock_irqrestore(&priv->rmw_lock, flags); spin_unlock_irqrestore(&priv->rmw_lock, flags);
if (!enable) if (!enable || priv->stbyctrl)
return 0; return 0;
for (i = 1000; i > 0; --i) { for (i = 1000; i > 0; --i) {
...@@ -205,7 +233,10 @@ static int cpg_mstp_clock_is_enabled(struct clk_hw *hw) ...@@ -205,7 +233,10 @@ static int cpg_mstp_clock_is_enabled(struct clk_hw *hw)
struct cpg_mssr_priv *priv = clock->priv; struct cpg_mssr_priv *priv = clock->priv;
u32 value; u32 value;
value = readl(priv->base + MSTPSR(clock->index / 32)); if (priv->stbyctrl)
value = readb(priv->base + STBCR(clock->index / 32));
else
value = readl(priv->base + MSTPSR(clock->index / 32));
return !(value & BIT(clock->index % 32)); return !(value & BIT(clock->index % 32));
} }
...@@ -226,6 +257,7 @@ struct clk *cpg_mssr_clk_src_twocell_get(struct of_phandle_args *clkspec, ...@@ -226,6 +257,7 @@ struct clk *cpg_mssr_clk_src_twocell_get(struct of_phandle_args *clkspec,
unsigned int idx; unsigned int idx;
const char *type; const char *type;
struct clk *clk; struct clk *clk;
int range_check;
switch (clkspec->args[0]) { switch (clkspec->args[0]) {
case CPG_CORE: case CPG_CORE:
...@@ -240,8 +272,14 @@ struct clk *cpg_mssr_clk_src_twocell_get(struct of_phandle_args *clkspec, ...@@ -240,8 +272,14 @@ struct clk *cpg_mssr_clk_src_twocell_get(struct of_phandle_args *clkspec,
case CPG_MOD: case CPG_MOD:
type = "module"; type = "module";
idx = MOD_CLK_PACK(clkidx); if (priv->stbyctrl) {
if (clkidx % 100 > 31 || idx >= priv->num_mod_clks) { idx = MOD_CLK_PACK_10(clkidx);
range_check = 7 - (clkidx % 10);
} else {
idx = MOD_CLK_PACK(clkidx);
range_check = 31 - (clkidx % 100);
}
if (range_check < 0 || idx >= priv->num_mod_clks) {
dev_err(dev, "Invalid %s clock index %u\n", type, dev_err(dev, "Invalid %s clock index %u\n", type,
clkidx); clkidx);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -283,7 +321,7 @@ static void __init cpg_mssr_register_core_clk(const struct cpg_core_clk *core, ...@@ -283,7 +321,7 @@ static void __init cpg_mssr_register_core_clk(const struct cpg_core_clk *core,
switch (core->type) { switch (core->type) {
case CLK_TYPE_IN: case CLK_TYPE_IN:
clk = of_clk_get_by_name(priv->dev->of_node, core->name); clk = of_clk_get_by_name(priv->np, core->name);
break; break;
case CLK_TYPE_FF: case CLK_TYPE_FF:
...@@ -646,11 +684,22 @@ static inline int cpg_mssr_reset_controller_register(struct cpg_mssr_priv *priv) ...@@ -646,11 +684,22 @@ static inline int cpg_mssr_reset_controller_register(struct cpg_mssr_priv *priv)
static const struct of_device_id cpg_mssr_match[] = { static const struct of_device_id cpg_mssr_match[] = {
#ifdef CONFIG_CLK_R7S9210
{
.compatible = "renesas,r7s9210-cpg-mssr",
.data = &r7s9210_cpg_mssr_info,
},
#endif
#ifdef CONFIG_CLK_R8A7743 #ifdef CONFIG_CLK_R8A7743
{ {
.compatible = "renesas,r8a7743-cpg-mssr", .compatible = "renesas,r8a7743-cpg-mssr",
.data = &r8a7743_cpg_mssr_info, .data = &r8a7743_cpg_mssr_info,
}, },
/* RZ/G1N is (almost) identical to RZ/G1M w.r.t. clocks. */
{
.compatible = "renesas,r8a7744-cpg-mssr",
.data = &r8a7743_cpg_mssr_info,
},
#endif #endif
#ifdef CONFIG_CLK_R8A7745 #ifdef CONFIG_CLK_R8A7745
{ {
...@@ -670,6 +719,12 @@ static const struct of_device_id cpg_mssr_match[] = { ...@@ -670,6 +719,12 @@ static const struct of_device_id cpg_mssr_match[] = {
.data = &r8a774a1_cpg_mssr_info, .data = &r8a774a1_cpg_mssr_info,
}, },
#endif #endif
#ifdef CONFIG_CLK_R8A774C0
{
.compatible = "renesas,r8a774c0-cpg-mssr",
.data = &r8a774c0_cpg_mssr_info,
},
#endif
#ifdef CONFIG_CLK_R8A7790 #ifdef CONFIG_CLK_R8A7790
{ {
.compatible = "renesas,r8a7790-cpg-mssr", .compatible = "renesas,r8a7790-cpg-mssr",
...@@ -791,13 +846,23 @@ static int cpg_mssr_resume_noirq(struct device *dev) ...@@ -791,13 +846,23 @@ static int cpg_mssr_resume_noirq(struct device *dev)
if (!mask) if (!mask)
continue; continue;
oldval = readl(priv->base + SMSTPCR(reg)); if (priv->stbyctrl)
oldval = readb(priv->base + STBCR(reg));
else
oldval = readl(priv->base + SMSTPCR(reg));
newval = oldval & ~mask; newval = oldval & ~mask;
newval |= priv->smstpcr_saved[reg].val & mask; newval |= priv->smstpcr_saved[reg].val & mask;
if (newval == oldval) if (newval == oldval)
continue; continue;
writel(newval, priv->base + SMSTPCR(reg)); if (priv->stbyctrl) {
writeb(newval, priv->base + STBCR(reg));
/* dummy read to ensure write has completed */
readb(priv->base + STBCR(reg));
barrier_data(priv->base + STBCR(reg));
continue;
} else
writel(newval, priv->base + SMSTPCR(reg));
/* Wait until enabled clocks are really enabled */ /* Wait until enabled clocks are really enabled */
mask &= ~priv->smstpcr_saved[reg].val; mask &= ~priv->smstpcr_saved[reg].val;
...@@ -828,61 +893,115 @@ static const struct dev_pm_ops cpg_mssr_pm = { ...@@ -828,61 +893,115 @@ static const struct dev_pm_ops cpg_mssr_pm = {
#define DEV_PM_OPS NULL #define DEV_PM_OPS NULL
#endif /* CONFIG_PM_SLEEP && CONFIG_ARM_PSCI_FW */ #endif /* CONFIG_PM_SLEEP && CONFIG_ARM_PSCI_FW */
static int __init cpg_mssr_probe(struct platform_device *pdev) static int __init cpg_mssr_common_init(struct device *dev,
struct device_node *np,
const struct cpg_mssr_info *info)
{ {
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
const struct cpg_mssr_info *info;
struct cpg_mssr_priv *priv; struct cpg_mssr_priv *priv;
struct clk **clks = NULL;
unsigned int nclks, i; unsigned int nclks, i;
struct resource *res;
struct clk **clks;
int error; int error;
info = of_device_get_match_data(dev);
if (info->init) { if (info->init) {
error = info->init(dev); error = info->init(dev);
if (error) if (error)
return error; return error;
} }
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
priv->np = np;
priv->dev = dev; priv->dev = dev;
spin_lock_init(&priv->rmw_lock); spin_lock_init(&priv->rmw_lock);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->base = of_iomap(np, 0);
priv->base = devm_ioremap_resource(dev, res); if (!priv->base) {
if (IS_ERR(priv->base)) error = -ENOMEM;
return PTR_ERR(priv->base); goto out_err;
}
nclks = info->num_total_core_clks + info->num_hw_mod_clks; nclks = info->num_total_core_clks + info->num_hw_mod_clks;
clks = devm_kmalloc_array(dev, nclks, sizeof(*clks), GFP_KERNEL); clks = kmalloc_array(nclks, sizeof(*clks), GFP_KERNEL);
if (!clks) if (!clks) {
return -ENOMEM; error = -ENOMEM;
goto out_err;
}
dev_set_drvdata(dev, priv); cpg_mssr_priv = priv;
priv->clks = clks; priv->clks = clks;
priv->num_core_clks = info->num_total_core_clks; priv->num_core_clks = info->num_total_core_clks;
priv->num_mod_clks = info->num_hw_mod_clks; priv->num_mod_clks = info->num_hw_mod_clks;
priv->last_dt_core_clk = info->last_dt_core_clk; priv->last_dt_core_clk = info->last_dt_core_clk;
RAW_INIT_NOTIFIER_HEAD(&priv->notifiers); RAW_INIT_NOTIFIER_HEAD(&priv->notifiers);
priv->stbyctrl = info->stbyctrl;
for (i = 0; i < nclks; i++) for (i = 0; i < nclks; i++)
clks[i] = ERR_PTR(-ENOENT); clks[i] = ERR_PTR(-ENOENT);
error = of_clk_add_provider(np, cpg_mssr_clk_src_twocell_get, priv);
if (error)
goto out_err;
return 0;
out_err:
kfree(clks);
if (priv->base)
iounmap(priv->base);
kfree(priv);
return error;
}
void __init cpg_mssr_early_init(struct device_node *np,
const struct cpg_mssr_info *info)
{
int error;
int i;
error = cpg_mssr_common_init(NULL, np, info);
if (error)
return;
for (i = 0; i < info->num_early_core_clks; i++)
cpg_mssr_register_core_clk(&info->early_core_clks[i], info,
cpg_mssr_priv);
for (i = 0; i < info->num_early_mod_clks; i++)
cpg_mssr_register_mod_clk(&info->early_mod_clks[i], info,
cpg_mssr_priv);
}
static int __init cpg_mssr_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
const struct cpg_mssr_info *info;
struct cpg_mssr_priv *priv;
unsigned int i;
int error;
info = of_device_get_match_data(dev);
if (!cpg_mssr_priv) {
error = cpg_mssr_common_init(dev, dev->of_node, info);
if (error)
return error;
}
priv = cpg_mssr_priv;
priv->dev = dev;
dev_set_drvdata(dev, priv);
for (i = 0; i < info->num_core_clks; i++) for (i = 0; i < info->num_core_clks; i++)
cpg_mssr_register_core_clk(&info->core_clks[i], info, priv); cpg_mssr_register_core_clk(&info->core_clks[i], info, priv);
for (i = 0; i < info->num_mod_clks; i++) for (i = 0; i < info->num_mod_clks; i++)
cpg_mssr_register_mod_clk(&info->mod_clks[i], info, priv); cpg_mssr_register_mod_clk(&info->mod_clks[i], info, priv);
error = of_clk_add_provider(np, cpg_mssr_clk_src_twocell_get, priv);
if (error)
return error;
error = devm_add_action_or_reset(dev, error = devm_add_action_or_reset(dev,
cpg_mssr_del_clk_provider, cpg_mssr_del_clk_provider,
np); np);
...@@ -894,6 +1013,10 @@ static int __init cpg_mssr_probe(struct platform_device *pdev) ...@@ -894,6 +1013,10 @@ static int __init cpg_mssr_probe(struct platform_device *pdev)
if (error) if (error)
return error; return error;
/* Reset Controller not supported for Standby Control SoCs */
if (info->stbyctrl)
return 0;
error = cpg_mssr_reset_controller_register(priv); error = cpg_mssr_reset_controller_register(priv);
if (error) if (error)
return error; return error;
......
...@@ -78,12 +78,24 @@ struct mssr_mod_clk { ...@@ -78,12 +78,24 @@ struct mssr_mod_clk {
#define DEF_MOD(_name, _mod, _parent...) \ #define DEF_MOD(_name, _mod, _parent...) \
{ .name = _name, .id = MOD_CLK_ID(_mod), .parent = _parent } { .name = _name, .id = MOD_CLK_ID(_mod), .parent = _parent }
/* Convert from sparse base-10 to packed index space */
#define MOD_CLK_PACK_10(x) ((x / 10) * 32 + (x % 10))
#define MOD_CLK_ID_10(x) (MOD_CLK_BASE + MOD_CLK_PACK_10(x))
#define DEF_MOD_STB(_name, _mod, _parent...) \
{ .name = _name, .id = MOD_CLK_ID_10(_mod), .parent = _parent }
struct device_node; struct device_node;
/** /**
* SoC-specific CPG/MSSR Description * SoC-specific CPG/MSSR Description
* *
* @early_core_clks: Array of Early Core Clock definitions
* @num_early_core_clks: Number of entries in early_core_clks[]
* @early_mod_clks: Array of Early Module Clock definitions
* @num_early_mod_clks: Number of entries in early_mod_clks[]
*
* @core_clks: Array of Core Clock definitions * @core_clks: Array of Core Clock definitions
* @num_core_clks: Number of entries in core_clks[] * @num_core_clks: Number of entries in core_clks[]
* @last_dt_core_clk: ID of the last Core Clock exported to DT * @last_dt_core_clk: ID of the last Core Clock exported to DT
...@@ -103,14 +115,25 @@ struct device_node; ...@@ -103,14 +115,25 @@ struct device_node;
* *
* @init: Optional callback to perform SoC-specific initialization * @init: Optional callback to perform SoC-specific initialization
* @cpg_clk_register: Optional callback to handle special Core Clock types * @cpg_clk_register: Optional callback to handle special Core Clock types
*
* @stbyctrl: This device has Standby Control Registers which are 8-bits
* wide, no status registers (MSTPSR) and have different address
* offsets.
*/ */
struct cpg_mssr_info { struct cpg_mssr_info {
/* Early Clocks */
const struct cpg_core_clk *early_core_clks;
unsigned int num_early_core_clks;
const struct mssr_mod_clk *early_mod_clks;
unsigned int num_early_mod_clks;
/* Core Clocks */ /* Core Clocks */
const struct cpg_core_clk *core_clks; const struct cpg_core_clk *core_clks;
unsigned int num_core_clks; unsigned int num_core_clks;
unsigned int last_dt_core_clk; unsigned int last_dt_core_clk;
unsigned int num_total_core_clks; unsigned int num_total_core_clks;
bool stbyctrl;
/* Module Clocks */ /* Module Clocks */
const struct mssr_mod_clk *mod_clks; const struct mssr_mod_clk *mod_clks;
...@@ -134,10 +157,12 @@ struct cpg_mssr_info { ...@@ -134,10 +157,12 @@ struct cpg_mssr_info {
struct raw_notifier_head *notifiers); struct raw_notifier_head *notifiers);
}; };
extern const struct cpg_mssr_info r7s9210_cpg_mssr_info;
extern const struct cpg_mssr_info r8a7743_cpg_mssr_info; extern const struct cpg_mssr_info r8a7743_cpg_mssr_info;
extern const struct cpg_mssr_info r8a7745_cpg_mssr_info; extern const struct cpg_mssr_info r8a7745_cpg_mssr_info;
extern const struct cpg_mssr_info r8a77470_cpg_mssr_info; extern const struct cpg_mssr_info r8a77470_cpg_mssr_info;
extern const struct cpg_mssr_info r8a774a1_cpg_mssr_info; extern const struct cpg_mssr_info r8a774a1_cpg_mssr_info;
extern const struct cpg_mssr_info r8a774c0_cpg_mssr_info;
extern const struct cpg_mssr_info r8a7790_cpg_mssr_info; extern const struct cpg_mssr_info r8a7790_cpg_mssr_info;
extern const struct cpg_mssr_info r8a7791_cpg_mssr_info; extern const struct cpg_mssr_info r8a7791_cpg_mssr_info;
extern const struct cpg_mssr_info r8a7792_cpg_mssr_info; extern const struct cpg_mssr_info r8a7792_cpg_mssr_info;
...@@ -150,6 +175,8 @@ extern const struct cpg_mssr_info r8a77980_cpg_mssr_info; ...@@ -150,6 +175,8 @@ extern const struct cpg_mssr_info r8a77980_cpg_mssr_info;
extern const struct cpg_mssr_info r8a77990_cpg_mssr_info; extern const struct cpg_mssr_info r8a77990_cpg_mssr_info;
extern const struct cpg_mssr_info r8a77995_cpg_mssr_info; extern const struct cpg_mssr_info r8a77995_cpg_mssr_info;
void __init cpg_mssr_early_init(struct device_node *np,
const struct cpg_mssr_info *info);
/* /*
* Helpers for fixing up clock tables depending on SoC revision * Helpers for fixing up clock tables depending on SoC revision
......
/* /* SPDX-License-Identifier: GPL-2.0
*
* Copyright (C) 2014 Renesas Solutions Corp. * Copyright (C) 2014 Renesas Solutions Corp.
* Copyright (C) 2014 Wolfram Sang, Sang Engineering <wsa@sang-engineering.com> * Copyright (C) 2014 Wolfram Sang, Sang Engineering <wsa@sang-engineering.com>
*
* 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; version 2 of the License.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R7S72100_H__ #ifndef __DT_BINDINGS_CLOCK_R7S72100_H__
......
/* SPDX-License-Identifier: GPL-2.0
*
* Copyright (C) 2018 Renesas Electronics Corp.
*
*/
#ifndef __DT_BINDINGS_CLOCK_R7S9210_CPG_MSSR_H__
#define __DT_BINDINGS_CLOCK_R7S9210_CPG_MSSR_H__
#include <dt-bindings/clock/renesas-cpg-mssr.h>
/* R7S9210 CPG Core Clocks */
#define R7S9210_CLK_I 0
#define R7S9210_CLK_G 1
#define R7S9210_CLK_B 2
#define R7S9210_CLK_P1 3
#define R7S9210_CLK_P1C 4
#define R7S9210_CLK_P0 5
#endif /* __DT_BINDINGS_CLOCK_R7S9210_CPG_MSSR_H__ */
/* /* SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2016 Cogent Embedded Inc.
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2016 Cogent Embedded Inc.
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A7743_CPG_MSSR_H__ #ifndef __DT_BINDINGS_CLOCK_R8A7743_CPG_MSSR_H__
#define __DT_BINDINGS_CLOCK_R8A7743_CPG_MSSR_H__ #define __DT_BINDINGS_CLOCK_R8A7743_CPG_MSSR_H__
......
/* SPDX-License-Identifier: GPL-2.0
*
* Copyright (C) 2018 Renesas Electronics Corp.
*/
#ifndef __DT_BINDINGS_CLOCK_R8A7744_CPG_MSSR_H__
#define __DT_BINDINGS_CLOCK_R8A7744_CPG_MSSR_H__
#include <dt-bindings/clock/renesas-cpg-mssr.h>
/* r8a7744 CPG Core Clocks */
#define R8A7744_CLK_Z 0
#define R8A7744_CLK_ZG 1
#define R8A7744_CLK_ZTR 2
#define R8A7744_CLK_ZTRD2 3
#define R8A7744_CLK_ZT 4
#define R8A7744_CLK_ZX 5
#define R8A7744_CLK_ZS 6
#define R8A7744_CLK_HP 7
#define R8A7744_CLK_B 9
#define R8A7744_CLK_LB 10
#define R8A7744_CLK_P 11
#define R8A7744_CLK_CL 12
#define R8A7744_CLK_M2 13
#define R8A7744_CLK_ZB3 15
#define R8A7744_CLK_ZB3D2 16
#define R8A7744_CLK_DDR 17
#define R8A7744_CLK_SDH 18
#define R8A7744_CLK_SD0 19
#define R8A7744_CLK_SD2 20
#define R8A7744_CLK_SD3 21
#define R8A7744_CLK_MMC0 22
#define R8A7744_CLK_MP 23
#define R8A7744_CLK_QSPI 26
#define R8A7744_CLK_CP 27
#define R8A7744_CLK_RCAN 28
#define R8A7744_CLK_R 29
#define R8A7744_CLK_OSC 30
#endif /* __DT_BINDINGS_CLOCK_R8A7744_CPG_MSSR_H__ */
/* /* SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2016 Cogent Embedded Inc.
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2016 Cogent Embedded Inc.
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A7745_CPG_MSSR_H__ #ifndef __DT_BINDINGS_CLOCK_R8A7745_CPG_MSSR_H__
#define __DT_BINDINGS_CLOCK_R8A7745_CPG_MSSR_H__ #define __DT_BINDINGS_CLOCK_R8A7745_CPG_MSSR_H__
......
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2018 Renesas Electronics Corp.
*/
#ifndef __DT_BINDINGS_CLOCK_R8A774C0_CPG_MSSR_H__
#define __DT_BINDINGS_CLOCK_R8A774C0_CPG_MSSR_H__
#include <dt-bindings/clock/renesas-cpg-mssr.h>
/* r8a774c0 CPG Core Clocks */
#define R8A774C0_CLK_Z2 0
#define R8A774C0_CLK_ZG 1
#define R8A774C0_CLK_ZTR 2
#define R8A774C0_CLK_ZT 3
#define R8A774C0_CLK_ZX 4
#define R8A774C0_CLK_S0D1 5
#define R8A774C0_CLK_S0D3 6
#define R8A774C0_CLK_S0D6 7
#define R8A774C0_CLK_S0D12 8
#define R8A774C0_CLK_S0D24 9
#define R8A774C0_CLK_S1D1 10
#define R8A774C0_CLK_S1D2 11
#define R8A774C0_CLK_S1D4 12
#define R8A774C0_CLK_S2D1 13
#define R8A774C0_CLK_S2D2 14
#define R8A774C0_CLK_S2D4 15
#define R8A774C0_CLK_S3D1 16
#define R8A774C0_CLK_S3D2 17
#define R8A774C0_CLK_S3D4 18
#define R8A774C0_CLK_S0D6C 19
#define R8A774C0_CLK_S3D1C 20
#define R8A774C0_CLK_S3D2C 21
#define R8A774C0_CLK_S3D4C 22
#define R8A774C0_CLK_LB 23
#define R8A774C0_CLK_CL 24
#define R8A774C0_CLK_ZB3 25
#define R8A774C0_CLK_ZB3D2 26
#define R8A774C0_CLK_CR 27
#define R8A774C0_CLK_CRD2 28
#define R8A774C0_CLK_SD0H 29
#define R8A774C0_CLK_SD0 30
#define R8A774C0_CLK_SD1H 31
#define R8A774C0_CLK_SD1 32
#define R8A774C0_CLK_SD3H 33
#define R8A774C0_CLK_SD3 34
#define R8A774C0_CLK_RPC 35
#define R8A774C0_CLK_RPCD2 36
#define R8A774C0_CLK_ZA2 37
#define R8A774C0_CLK_ZA8 38
#define R8A774C0_CLK_Z2D 39
#define R8A774C0_CLK_MSO 40
#define R8A774C0_CLK_R 41
#define R8A774C0_CLK_OSC 42
#define R8A774C0_CLK_LV0 43
#define R8A774C0_CLK_LV1 44
#define R8A774C0_CLK_CSI0 45
#define R8A774C0_CLK_CP 46
#define R8A774C0_CLK_CPEX 47
#endif /* __DT_BINDINGS_CLOCK_R8A774C0_CPG_MSSR_H__ */
/* /* SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2015 Renesas Electronics Corp.
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2015 Renesas Electronics Corp.
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A7790_CPG_MSSR_H__ #ifndef __DT_BINDINGS_CLOCK_R8A7790_CPG_MSSR_H__
......
/* /* SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2015 Renesas Electronics Corp.
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2015 Renesas Electronics Corp.
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A7791_CPG_MSSR_H__ #ifndef __DT_BINDINGS_CLOCK_R8A7791_CPG_MSSR_H__
......
/* /* SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2015 Renesas Electronics Corp.
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2015 Renesas Electronics Corp.
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A7792_CPG_MSSR_H__ #ifndef __DT_BINDINGS_CLOCK_R8A7792_CPG_MSSR_H__
......
/* /* SPDX-License-Identifier: GPL-2.0
*
* r8a7793 clock definition * r8a7793 clock definition
* *
* Copyright (C) 2014 Renesas Electronics Corporation * Copyright (C) 2014 Renesas Electronics 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
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A7793_H__ #ifndef __DT_BINDINGS_CLOCK_R8A7793_H__
......
/* /* SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2015 Renesas Electronics Corp.
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2015 Renesas Electronics Corp.
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A7793_CPG_MSSR_H__ #ifndef __DT_BINDINGS_CLOCK_R8A7793_CPG_MSSR_H__
......
/* /* SPDX-License-Identifier: GPL-2.0+
*
* Copyright (C) 2014 Renesas Electronics Corporation * Copyright (C) 2014 Renesas Electronics Corporation
* Copyright 2013 Ideas On Board SPRL * Copyright 2013 Ideas On Board SPRL
*
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A7794_H__ #ifndef __DT_BINDINGS_CLOCK_R8A7794_H__
......
/* /* SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2015 Renesas Electronics Corp.
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2015 Renesas Electronics Corp.
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A7794_CPG_MSSR_H__ #ifndef __DT_BINDINGS_CLOCK_R8A7794_CPG_MSSR_H__
......
/* /* SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2015 Renesas Electronics Corp.
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2015 Renesas Electronics Corp.
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A7795_CPG_MSSR_H__ #ifndef __DT_BINDINGS_CLOCK_R8A7795_CPG_MSSR_H__
#define __DT_BINDINGS_CLOCK_R8A7795_CPG_MSSR_H__ #define __DT_BINDINGS_CLOCK_R8A7795_CPG_MSSR_H__
......
/* /* SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2016 Renesas Electronics Corp.
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2016 Renesas Electronics Corp.
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A7796_CPG_MSSR_H__ #ifndef __DT_BINDINGS_CLOCK_R8A7796_CPG_MSSR_H__
#define __DT_BINDINGS_CLOCK_R8A7796_CPG_MSSR_H__ #define __DT_BINDINGS_CLOCK_R8A7796_CPG_MSSR_H__
......
/* /* SPDX-License-Identifier: GPL-2.0+
*
* Copyright (C) 2016 Renesas Electronics Corp. * Copyright (C) 2016 Renesas Electronics Corp.
* Copyright (C) 2017 Cogent Embedded, Inc. * Copyright (C) 2017 Cogent Embedded, Inc.
*
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A77970_CPG_MSSR_H__ #ifndef __DT_BINDINGS_CLOCK_R8A77970_CPG_MSSR_H__
#define __DT_BINDINGS_CLOCK_R8A77970_CPG_MSSR_H__ #define __DT_BINDINGS_CLOCK_R8A77970_CPG_MSSR_H__
......
/* /* SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2017 Glider bvba
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2017 Glider bvba
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_R8A77995_CPG_MSSR_H__ #ifndef __DT_BINDINGS_CLOCK_R8A77995_CPG_MSSR_H__
#define __DT_BINDINGS_CLOCK_R8A77995_CPG_MSSR_H__ #define __DT_BINDINGS_CLOCK_R8A77995_CPG_MSSR_H__
......
/* /* SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2015 Renesas Electronics Corp.
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2015 Renesas Electronics Corp.
* 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.
*/ */
#ifndef __DT_BINDINGS_CLOCK_RENESAS_CPG_MSSR_H__ #ifndef __DT_BINDINGS_CLOCK_RENESAS_CPG_MSSR_H__
#define __DT_BINDINGS_CLOCK_RENESAS_CPG_MSSR_H__ #define __DT_BINDINGS_CLOCK_RENESAS_CPG_MSSR_H__
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment