Commit b2ac878a authored by Stephen Boyd's avatar Stephen Boyd

Merge branches 'clk-davinci-psc-da830', 'clk-renesas', 'clk-at91-recalc',...

Merge branches 'clk-davinci-psc-da830', 'clk-renesas', 'clk-at91-recalc', 'clk-davinci' and 'clk-meson' into clk-next

* clk-davinci-psc-da830:
  clk: davinci: psc-da830: fix USB0 48MHz PHY clock registration

* clk-renesas:
  clk: renesas: cpg-mssr: Add support for R-Car E3
  clk: renesas: Add r8a77990 CPG Core Clock Definitions
  clk: renesas: rcar-gen2: Centralize quirks handling
  clk: renesas: r8a77980: Correct parent clock of PCIEC0
  clk: renesas: r8a7794: Fix LB clock divider
  clk: renesas: r8a7792: Fix LB clock divider
  clk: renesas: r8a7791/r8a7793: Fix LB clock divider
  clk: renesas: r8a7745: Fix LB clock divider
  clk: renesas: r8a7743: Fix LB clock divider
  clk: renesas: cpg-mssr: Add r8a77470 support
  clk: renesas: Add r8a77470 CPG Core Clock Definitions
  clk: renesas: r8a77965: Add MSIOF controller clocks

* clk-at91-recalc:
  clk: at91: PLL recalc_rate() now using cached MUL and DIV values

* clk-davinci:
  clk: davinci: Fix link errors when not all SoCs are enabled
  clk: davinci: psc: allow for dev == NULL
  clk: davinci: da850-pll: change PLL0 to CLK_OF_DECLARE
  clk: davinci: pll: allow dev == NULL
  clk: davinci: psc-dm365: fix few clocks
  clk: davinci: pll-dm646x: keep PLL2 SYSCLK1 always enabled
  clk: davinci: psc-dm355: fix ASP0/1 clkdev lookups
  clk: davinci: pll-dm355: fix SYSCLKn parent names
  clk: davinci: pll-dm355: drop pll2_sysclk2

* clk-meson:
  clk: meson: axg: let mpll clocks round closest
  clk: meson: mpll: add round closest support
  clk: meson: meson8b: mark fclk_div2 gate clocks as CLK_IS_CRITICAL
  clk: meson: use SPDX license identifiers consistently
  clk: meson: drop CLK_SET_RATE_PARENT flag
  clk: meson-axg: Add AO Clock and Reset controller driver
  clk: meson: aoclk: refactor common code into dedicated file
  clk: meson: migrate to devm_of_clk_add_hw_provider API
  clk: meson: gxbb: add the video decoder clocks
  clk: meson: meson8b: add support for the NAND clocks
  dt-bindings: clock: reset: Add AXG AO Clock and Reset Bindings
  dt-bindings: clock: axg-aoclkc: New binding for Meson-AXG SoC
  clk: meson: gxbb: expose VDEC_1 and VDEC_HEVC clocks
  dt-bindings: clock: meson8b: export the NAND clock
...@@ -9,6 +9,7 @@ Required Properties: ...@@ -9,6 +9,7 @@ Required Properties:
- GXBB (S905) : "amlogic,meson-gxbb-aoclkc" - GXBB (S905) : "amlogic,meson-gxbb-aoclkc"
- GXL (S905X, S905D) : "amlogic,meson-gxl-aoclkc" - GXL (S905X, S905D) : "amlogic,meson-gxl-aoclkc"
- GXM (S912) : "amlogic,meson-gxm-aoclkc" - GXM (S912) : "amlogic,meson-gxm-aoclkc"
- AXG (A113D, A113X) : "amlogic,meson-axg-aoclkc"
followed by the common "amlogic,meson-gx-aoclkc" followed by the common "amlogic,meson-gx-aoclkc"
- #clock-cells: should be 1. - #clock-cells: should be 1.
......
...@@ -15,6 +15,7 @@ Required Properties: ...@@ -15,6 +15,7 @@ Required Properties:
- compatible: Must be one of: - compatible: Must be one of:
- "renesas,r8a7743-cpg-mssr" for the r8a7743 SoC (RZ/G1M) - "renesas,r8a7743-cpg-mssr" for the r8a7743 SoC (RZ/G1M)
- "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,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)
...@@ -25,6 +26,7 @@ Required Properties: ...@@ -25,6 +26,7 @@ Required Properties:
- "renesas,r8a77965-cpg-mssr" for the r8a77965 SoC (R-Car M3-N) - "renesas,r8a77965-cpg-mssr" for the r8a77965 SoC (R-Car M3-N)
- "renesas,r8a77970-cpg-mssr" for the r8a77970 SoC (R-Car V3M) - "renesas,r8a77970-cpg-mssr" for the r8a77970 SoC (R-Car V3M)
- "renesas,r8a77980-cpg-mssr" for the r8a77980 SoC (R-Car V3H) - "renesas,r8a77980-cpg-mssr" for the r8a77980 SoC (R-Car V3H)
- "renesas,r8a77990-cpg-mssr" for the r8a77990 SoC (R-Car E3)
- "renesas,r8a77995-cpg-mssr" for the r8a77995 SoC (R-Car D3) - "renesas,r8a77995-cpg-mssr" for the r8a77995 SoC (R-Car D3)
- reg: Base address and length of the memory resource used by the CPG/MSSR - reg: Base address and length of the memory resource used by the CPG/MSSR
...@@ -33,10 +35,12 @@ Required Properties: ...@@ -33,10 +35,12 @@ 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, r8a7790, r8a7791, r8a7792, r8a7793, r8a7794, - "extal" (r8a7743, r8a7745, r8a77470, r8a7790, r8a7791, r8a7792,
r8a7795, r8a7796, r8a77965, r8a77970, r8a77980, r8a77995) r8a7793, r8a7794, r8a7795, r8a7796, r8a77965, r8a77970,
r8a77980, r8a77990, r8a77995)
- "extalr" (r8a7795, r8a7796, r8a77965, r8a77970, r8a77980) - "extalr" (r8a7795, r8a7796, r8a77965, r8a77970, r8a77980)
- "usb_extal" (r8a7743, r8a7745, r8a7790, r8a7791, r8a7793, r8a7794) - "usb_extal" (r8a7743, r8a7745, r8a77470, r8a7790, r8a7791, 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"
......
...@@ -132,19 +132,8 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw, ...@@ -132,19 +132,8 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate) unsigned long parent_rate)
{ {
struct clk_pll *pll = to_clk_pll(hw); struct clk_pll *pll = to_clk_pll(hw);
unsigned int pllr;
u16 mul;
u8 div;
regmap_read(pll->regmap, PLL_REG(pll->id), &pllr);
div = PLL_DIV(pllr);
mul = PLL_MUL(pllr, pll->layout);
if (!div || !mul)
return 0;
return (parent_rate / div) * (mul + 1); return (parent_rate / pll->div) * (pll->mul + 1);
} }
static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate, static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate,
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#include <linux/clkdev.h> #include <linux/clkdev.h>
#include <linux/clk/davinci.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -36,11 +37,11 @@ SYSCLK(5, pll0_sysclk5, pll0_pllen, 5, 0); ...@@ -36,11 +37,11 @@ SYSCLK(5, pll0_sysclk5, pll0_pllen, 5, 0);
SYSCLK(6, pll0_sysclk6, pll0_pllen, 5, SYSCLK_FIXED_DIV); SYSCLK(6, pll0_sysclk6, pll0_pllen, 5, SYSCLK_FIXED_DIV);
SYSCLK(7, pll0_sysclk7, pll0_pllen, 5, 0); SYSCLK(7, pll0_sysclk7, pll0_pllen, 5, 0);
int da830_pll_init(struct device *dev, void __iomem *base) int da830_pll_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
{ {
struct clk *clk; struct clk *clk;
davinci_pll_clk_register(dev, &da830_pll_info, "ref_clk", base); davinci_pll_clk_register(dev, &da830_pll_info, "ref_clk", base, cfgchip);
clk = davinci_pll_sysclk_register(dev, &pll0_sysclk2, base); clk = davinci_pll_sysclk_register(dev, &pll0_sysclk2, base);
clk_register_clkdev(clk, "pll0_sysclk2", "da830-psc0"); clk_register_clkdev(clk, "pll0_sysclk2", "da830-psc0");
......
...@@ -7,10 +7,14 @@ ...@@ -7,10 +7,14 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/clk/davinci.h>
#include <linux/clkdev.h> #include <linux/clkdev.h>
#include <linux/device.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/mfd/da8xx-cfgchip.h> #include <linux/mfd/da8xx-cfgchip.h>
#include <linux/mfd/syscon.h>
#include <linux/of_address.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -81,11 +85,11 @@ static const struct davinci_pll_obsclk_info da850_pll0_obsclk_info = { ...@@ -81,11 +85,11 @@ static const struct davinci_pll_obsclk_info da850_pll0_obsclk_info = {
.ocsrc_mask = GENMASK(4, 0), .ocsrc_mask = GENMASK(4, 0),
}; };
int da850_pll0_init(struct device *dev, void __iomem *base) int da850_pll0_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
{ {
struct clk *clk; struct clk *clk;
davinci_pll_clk_register(dev, &da850_pll0_info, "ref_clk", base); davinci_pll_clk_register(dev, &da850_pll0_info, "ref_clk", base, cfgchip);
clk = davinci_pll_sysclk_register(dev, &pll0_sysclk1, base); clk = davinci_pll_sysclk_register(dev, &pll0_sysclk1, base);
clk_register_clkdev(clk, "pll0_sysclk1", "da850-psc0"); clk_register_clkdev(clk, "pll0_sysclk1", "da850-psc0");
...@@ -134,11 +138,22 @@ static const struct davinci_pll_sysclk_info *da850_pll0_sysclk_info[] = { ...@@ -134,11 +138,22 @@ static const struct davinci_pll_sysclk_info *da850_pll0_sysclk_info[] = {
NULL NULL
}; };
int of_da850_pll0_init(struct device *dev, void __iomem *base) void of_da850_pll0_init(struct device_node *node)
{ {
return of_davinci_pll_init(dev, &da850_pll0_info, void __iomem *base;
&da850_pll0_obsclk_info, struct regmap *cfgchip;
da850_pll0_sysclk_info, 7, base);
base = of_iomap(node, 0);
if (!base) {
pr_err("%s: ioremap failed\n", __func__);
return;
}
cfgchip = syscon_regmap_lookup_by_compatible("ti,da830-cfgchip");
of_davinci_pll_init(NULL, node, &da850_pll0_info,
&da850_pll0_obsclk_info,
da850_pll0_sysclk_info, 7, base, cfgchip);
} }
static const struct davinci_pll_clk_info da850_pll1_info = { static const struct davinci_pll_clk_info da850_pll1_info = {
...@@ -179,11 +194,11 @@ static const struct davinci_pll_obsclk_info da850_pll1_obsclk_info = { ...@@ -179,11 +194,11 @@ static const struct davinci_pll_obsclk_info da850_pll1_obsclk_info = {
.ocsrc_mask = GENMASK(4, 0), .ocsrc_mask = GENMASK(4, 0),
}; };
int da850_pll1_init(struct device *dev, void __iomem *base) int da850_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
{ {
struct clk *clk; struct clk *clk;
davinci_pll_clk_register(dev, &da850_pll1_info, "oscin", base); davinci_pll_clk_register(dev, &da850_pll1_info, "oscin", base, cfgchip);
davinci_pll_sysclk_register(dev, &pll1_sysclk1, base); davinci_pll_sysclk_register(dev, &pll1_sysclk1, base);
...@@ -204,9 +219,9 @@ static const struct davinci_pll_sysclk_info *da850_pll1_sysclk_info[] = { ...@@ -204,9 +219,9 @@ static const struct davinci_pll_sysclk_info *da850_pll1_sysclk_info[] = {
NULL NULL
}; };
int of_da850_pll1_init(struct device *dev, void __iomem *base) int of_da850_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
{ {
return of_davinci_pll_init(dev, &da850_pll1_info, return of_davinci_pll_init(dev, dev->of_node, &da850_pll1_info,
&da850_pll1_obsclk_info, &da850_pll1_obsclk_info,
da850_pll1_sysclk_info, 3, base); da850_pll1_sysclk_info, 3, base, cfgchip);
} }
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/clk/davinci.h>
#include <linux/clkdev.h> #include <linux/clkdev.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -22,16 +23,16 @@ static const struct davinci_pll_clk_info dm355_pll1_info = { ...@@ -22,16 +23,16 @@ static const struct davinci_pll_clk_info dm355_pll1_info = {
PLL_POSTDIV_ALWAYS_ENABLED | PLL_POSTDIV_FIXED_DIV, PLL_POSTDIV_ALWAYS_ENABLED | PLL_POSTDIV_FIXED_DIV,
}; };
SYSCLK(1, pll1_sysclk1, pll1, 5, SYSCLK_FIXED_DIV | SYSCLK_ALWAYS_ENABLED); SYSCLK(1, pll1_sysclk1, pll1_pllen, 5, SYSCLK_FIXED_DIV | SYSCLK_ALWAYS_ENABLED);
SYSCLK(2, pll1_sysclk2, pll1, 5, SYSCLK_FIXED_DIV | SYSCLK_ALWAYS_ENABLED); SYSCLK(2, pll1_sysclk2, pll1_pllen, 5, SYSCLK_FIXED_DIV | SYSCLK_ALWAYS_ENABLED);
SYSCLK(3, pll1_sysclk3, pll1, 5, SYSCLK_ALWAYS_ENABLED); SYSCLK(3, pll1_sysclk3, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
SYSCLK(4, pll1_sysclk4, pll1, 5, SYSCLK_ALWAYS_ENABLED); SYSCLK(4, pll1_sysclk4, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
int dm355_pll1_init(struct device *dev, void __iomem *base) int dm355_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
{ {
struct clk *clk; struct clk *clk;
davinci_pll_clk_register(dev, &dm355_pll1_info, "ref_clk", base); davinci_pll_clk_register(dev, &dm355_pll1_info, "ref_clk", base, cfgchip);
clk = davinci_pll_sysclk_register(dev, &pll1_sysclk1, base); clk = davinci_pll_sysclk_register(dev, &pll1_sysclk1, base);
clk_register_clkdev(clk, "pll1_sysclk1", "dm355-psc"); clk_register_clkdev(clk, "pll1_sysclk1", "dm355-psc");
...@@ -62,17 +63,14 @@ static const struct davinci_pll_clk_info dm355_pll2_info = { ...@@ -62,17 +63,14 @@ static const struct davinci_pll_clk_info dm355_pll2_info = {
PLL_POSTDIV_ALWAYS_ENABLED | PLL_POSTDIV_FIXED_DIV, PLL_POSTDIV_ALWAYS_ENABLED | PLL_POSTDIV_FIXED_DIV,
}; };
SYSCLK(1, pll2_sysclk1, pll2, 5, SYSCLK_FIXED_DIV); SYSCLK(1, pll2_sysclk1, pll2_pllen, 5, SYSCLK_FIXED_DIV | SYSCLK_ALWAYS_ENABLED);
SYSCLK(2, pll2_sysclk2, pll2, 5, SYSCLK_FIXED_DIV | SYSCLK_ALWAYS_ENABLED);
int dm355_pll2_init(struct device *dev, void __iomem *base) int dm355_pll2_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
{ {
davinci_pll_clk_register(dev, &dm355_pll2_info, "oscin", base); davinci_pll_clk_register(dev, &dm355_pll2_info, "oscin", base, cfgchip);
davinci_pll_sysclk_register(dev, &pll2_sysclk1, base); davinci_pll_sysclk_register(dev, &pll2_sysclk1, base);
davinci_pll_sysclk_register(dev, &pll2_sysclk2, base);
davinci_pll_sysclkbp_clk_register(dev, "pll2_sysclkbp", base); davinci_pll_sysclkbp_clk_register(dev, "pll2_sysclkbp", base);
return 0; return 0;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/clkdev.h> #include <linux/clkdev.h>
#include <linux/clk/davinci.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -56,11 +57,11 @@ static const struct davinci_pll_obsclk_info dm365_pll1_obsclk_info = { ...@@ -56,11 +57,11 @@ static const struct davinci_pll_obsclk_info dm365_pll1_obsclk_info = {
.ocsrc_mask = BIT(4), .ocsrc_mask = BIT(4),
}; };
int dm365_pll1_init(struct device *dev, void __iomem *base) int dm365_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
{ {
struct clk *clk; struct clk *clk;
davinci_pll_clk_register(dev, &dm365_pll1_info, "ref_clk", base); davinci_pll_clk_register(dev, &dm365_pll1_info, "ref_clk", base, cfgchip);
clk = davinci_pll_sysclk_register(dev, &pll1_sysclk1, base); clk = davinci_pll_sysclk_register(dev, &pll1_sysclk1, base);
clk_register_clkdev(clk, "pll1_sysclk1", "dm365-psc"); clk_register_clkdev(clk, "pll1_sysclk1", "dm365-psc");
...@@ -119,11 +120,11 @@ static const struct davinci_pll_obsclk_info dm365_pll2_obsclk_info = { ...@@ -119,11 +120,11 @@ static const struct davinci_pll_obsclk_info dm365_pll2_obsclk_info = {
.ocsrc_mask = BIT(4), .ocsrc_mask = BIT(4),
}; };
int dm365_pll2_init(struct device *dev, void __iomem *base) int dm365_pll2_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
{ {
struct clk *clk; struct clk *clk;
davinci_pll_clk_register(dev, &dm365_pll2_info, "oscin", base); davinci_pll_clk_register(dev, &dm365_pll2_info, "oscin", base, cfgchip);
davinci_pll_sysclk_register(dev, &pll2_sysclk1, base); davinci_pll_sysclk_register(dev, &pll2_sysclk1, base);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/clk/davinci.h>
#include <linux/clkdev.h> #include <linux/clkdev.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -27,11 +28,11 @@ SYSCLK(2, pll1_sysclk2, pll1_pllen, 4, SYSCLK_FIXED_DIV); ...@@ -27,11 +28,11 @@ SYSCLK(2, pll1_sysclk2, pll1_pllen, 4, SYSCLK_FIXED_DIV);
SYSCLK(3, pll1_sysclk3, pll1_pllen, 4, SYSCLK_FIXED_DIV); SYSCLK(3, pll1_sysclk3, pll1_pllen, 4, SYSCLK_FIXED_DIV);
SYSCLK(5, pll1_sysclk5, pll1_pllen, 4, SYSCLK_FIXED_DIV); SYSCLK(5, pll1_sysclk5, pll1_pllen, 4, SYSCLK_FIXED_DIV);
int dm644x_pll1_init(struct device *dev, void __iomem *base) int dm644x_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
{ {
struct clk *clk; struct clk *clk;
davinci_pll_clk_register(dev, &dm644x_pll1_info, "ref_clk", base); davinci_pll_clk_register(dev, &dm644x_pll1_info, "ref_clk", base, cfgchip);
clk = davinci_pll_sysclk_register(dev, &pll1_sysclk1, base); clk = davinci_pll_sysclk_register(dev, &pll1_sysclk1, base);
clk_register_clkdev(clk, "pll1_sysclk1", "dm644x-psc"); clk_register_clkdev(clk, "pll1_sysclk1", "dm644x-psc");
...@@ -66,9 +67,9 @@ static const struct davinci_pll_clk_info dm644x_pll2_info = { ...@@ -66,9 +67,9 @@ static const struct davinci_pll_clk_info dm644x_pll2_info = {
SYSCLK(1, pll2_sysclk1, pll2_pllen, 4, 0); SYSCLK(1, pll2_sysclk1, pll2_pllen, 4, 0);
SYSCLK(2, pll2_sysclk2, pll2_pllen, 4, 0); SYSCLK(2, pll2_sysclk2, pll2_pllen, 4, 0);
int dm644x_pll2_init(struct device *dev, void __iomem *base) int dm644x_pll2_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
{ {
davinci_pll_clk_register(dev, &dm644x_pll2_info, "oscin", base); davinci_pll_clk_register(dev, &dm644x_pll2_info, "oscin", base, cfgchip);
davinci_pll_sysclk_register(dev, &pll2_sysclk1, base); davinci_pll_sysclk_register(dev, &pll2_sysclk1, base);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/clk/davinci.h>
#include <linux/clkdev.h> #include <linux/clkdev.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -29,11 +30,11 @@ SYSCLK(6, pll1_sysclk6, pll1_pllen, 4, 0); ...@@ -29,11 +30,11 @@ SYSCLK(6, pll1_sysclk6, pll1_pllen, 4, 0);
SYSCLK(8, pll1_sysclk8, pll1_pllen, 4, 0); SYSCLK(8, pll1_sysclk8, pll1_pllen, 4, 0);
SYSCLK(9, pll1_sysclk9, pll1_pllen, 4, 0); SYSCLK(9, pll1_sysclk9, pll1_pllen, 4, 0);
int dm646x_pll1_init(struct device *dev, void __iomem *base) int dm646x_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
{ {
struct clk *clk; struct clk *clk;
davinci_pll_clk_register(dev, &dm646x_pll1_info, "ref_clk", base); davinci_pll_clk_register(dev, &dm646x_pll1_info, "ref_clk", base, cfgchip);
clk = davinci_pll_sysclk_register(dev, &pll1_sysclk1, base); clk = davinci_pll_sysclk_register(dev, &pll1_sysclk1, base);
clk_register_clkdev(clk, "pll1_sysclk1", "dm646x-psc"); clk_register_clkdev(clk, "pll1_sysclk1", "dm646x-psc");
...@@ -72,11 +73,11 @@ static const struct davinci_pll_clk_info dm646x_pll2_info = { ...@@ -72,11 +73,11 @@ static const struct davinci_pll_clk_info dm646x_pll2_info = {
.flags = 0, .flags = 0,
}; };
SYSCLK(1, pll2_sysclk1, pll2_pllen, 4, 0); SYSCLK(1, pll2_sysclk1, pll2_pllen, 4, SYSCLK_ALWAYS_ENABLED);
int dm646x_pll2_init(struct device *dev, void __iomem *base) int dm646x_pll2_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
{ {
davinci_pll_clk_register(dev, &dm646x_pll2_info, "oscin", base); davinci_pll_clk_register(dev, &dm646x_pll2_info, "oscin", base, cfgchip);
davinci_pll_sysclk_register(dev, &pll2_sysclk1, base); davinci_pll_sysclk_register(dev, &pll2_sysclk1, base);
......
This diff is collapsed.
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/regmap.h>
#include <linux/types.h> #include <linux/types.h>
#define PLL_HAS_CLKMODE BIT(0) /* PLL has PLLCTL[CLKMODE] */ #define PLL_HAS_CLKMODE BIT(0) /* PLL has PLLCTL[CLKMODE] */
...@@ -94,7 +95,8 @@ struct davinci_pll_obsclk_info { ...@@ -94,7 +95,8 @@ struct davinci_pll_obsclk_info {
struct clk *davinci_pll_clk_register(struct device *dev, struct clk *davinci_pll_clk_register(struct device *dev,
const struct davinci_pll_clk_info *info, const struct davinci_pll_clk_info *info,
const char *parent_name, const char *parent_name,
void __iomem *base); void __iomem *base,
struct regmap *cfgchip);
struct clk *davinci_pll_auxclk_register(struct device *dev, struct clk *davinci_pll_auxclk_register(struct device *dev,
const char *name, const char *name,
void __iomem *base); void __iomem *base);
...@@ -110,32 +112,29 @@ davinci_pll_sysclk_register(struct device *dev, ...@@ -110,32 +112,29 @@ davinci_pll_sysclk_register(struct device *dev,
const struct davinci_pll_sysclk_info *info, const struct davinci_pll_sysclk_info *info,
void __iomem *base); void __iomem *base);
int of_davinci_pll_init(struct device *dev, int of_davinci_pll_init(struct device *dev, struct device_node *node,
const struct davinci_pll_clk_info *info, const struct davinci_pll_clk_info *info,
const struct davinci_pll_obsclk_info *obsclk_info, const struct davinci_pll_obsclk_info *obsclk_info,
const struct davinci_pll_sysclk_info **div_info, const struct davinci_pll_sysclk_info **div_info,
u8 max_sysclk_id, u8 max_sysclk_id,
void __iomem *base); void __iomem *base,
struct regmap *cfgchip);
/* Platform-specific callbacks */ /* Platform-specific callbacks */
int da830_pll_init(struct device *dev, void __iomem *base); #ifdef CONFIG_ARCH_DAVINCI_DA850
int da850_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip);
int da850_pll0_init(struct device *dev, void __iomem *base); void of_da850_pll0_init(struct device_node *node);
int da850_pll1_init(struct device *dev, void __iomem *base); int of_da850_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip);
int of_da850_pll0_init(struct device *dev, void __iomem *base); #endif
int of_da850_pll1_init(struct device *dev, void __iomem *base); #ifdef CONFIG_ARCH_DAVINCI_DM355
int dm355_pll2_init(struct device *dev, void __iomem *base, struct regmap *cfgchip);
int dm355_pll1_init(struct device *dev, void __iomem *base); #endif
int dm355_pll2_init(struct device *dev, void __iomem *base); #ifdef CONFIG_ARCH_DAVINCI_DM644x
int dm644x_pll2_init(struct device *dev, void __iomem *base, struct regmap *cfgchip);
int dm365_pll1_init(struct device *dev, void __iomem *base); #endif
int dm365_pll2_init(struct device *dev, void __iomem *base); #ifdef CONFIG_ARCH_DAVINCI_DM646x
int dm646x_pll2_init(struct device *dev, void __iomem *base, struct regmap *cfgchip);
int dm644x_pll1_init(struct device *dev, void __iomem *base); #endif
int dm644x_pll2_init(struct device *dev, void __iomem *base);
int dm646x_pll1_init(struct device *dev, void __iomem *base);
int dm646x_pll2_init(struct device *dev, void __iomem *base);
#endif /* __CLK_DAVINCI_PLL_H___ */ #endif /* __CLK_DAVINCI_PLL_H___ */
...@@ -55,7 +55,8 @@ const struct davinci_psc_init_data da830_psc0_init_data = { ...@@ -55,7 +55,8 @@ const struct davinci_psc_init_data da830_psc0_init_data = {
.psc_init = &da830_psc0_init, .psc_init = &da830_psc0_init,
}; };
LPSC_CLKDEV2(usb0_clkdev, NULL, "musb-da8xx", LPSC_CLKDEV3(usb0_clkdev, "fck", "da830-usb-phy-clks",
NULL, "musb-da8xx",
NULL, "cppi41-dmaengine"); NULL, "cppi41-dmaengine");
LPSC_CLKDEV1(usb1_clkdev, NULL, "ohci-da8xx"); LPSC_CLKDEV1(usb1_clkdev, NULL, "ohci-da8xx");
/* REVISIT: gpio-davinci.c should be modified to drop con_id */ /* REVISIT: gpio-davinci.c should be modified to drop con_id */
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/clk/davinci.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/clkdev.h> #include <linux/clkdev.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -41,14 +42,14 @@ static const struct davinci_lpsc_clk_info dm355_psc_info[] = { ...@@ -41,14 +42,14 @@ static const struct davinci_lpsc_clk_info dm355_psc_info[] = {
LPSC(5, 0, timer3, pll1_auxclk, NULL, 0), LPSC(5, 0, timer3, pll1_auxclk, NULL, 0),
LPSC(6, 0, spi1, pll1_sysclk2, spi1_clkdev, 0), LPSC(6, 0, spi1, pll1_sysclk2, spi1_clkdev, 0),
LPSC(7, 0, mmcsd1, pll1_sysclk2, mmcsd1_clkdev, 0), LPSC(7, 0, mmcsd1, pll1_sysclk2, mmcsd1_clkdev, 0),
LPSC(8, 0, asp1, pll1_sysclk2, NULL, 0), LPSC(8, 0, asp1, pll1_sysclk2, mcbsp1_clkdev, 0),
LPSC(9, 0, usb, pll1_sysclk2, usb_clkdev, 0), LPSC(9, 0, usb, pll1_sysclk2, usb_clkdev, 0),
LPSC(10, 0, pwm3, pll1_auxclk, NULL, 0), LPSC(10, 0, pwm3, pll1_auxclk, NULL, 0),
LPSC(11, 0, spi2, pll1_sysclk2, spi2_clkdev, 0), LPSC(11, 0, spi2, pll1_sysclk2, spi2_clkdev, 0),
LPSC(12, 0, rto, pll1_auxclk, NULL, 0), LPSC(12, 0, rto, pll1_auxclk, NULL, 0),
LPSC(14, 0, aemif, pll1_sysclk2, aemif_clkdev, 0), LPSC(14, 0, aemif, pll1_sysclk2, aemif_clkdev, 0),
LPSC(15, 0, mmcsd0, pll1_sysclk2, mmcsd0_clkdev, 0), LPSC(15, 0, mmcsd0, pll1_sysclk2, mmcsd0_clkdev, 0),
LPSC(17, 0, asp0, pll1_sysclk2, NULL, 0), LPSC(17, 0, asp0, pll1_sysclk2, mcbsp0_clkdev, 0),
LPSC(18, 0, i2c, pll1_auxclk, i2c_clkdev, 0), LPSC(18, 0, i2c, pll1_auxclk, i2c_clkdev, 0),
LPSC(19, 0, uart0, pll1_auxclk, uart0_clkdev, 0), LPSC(19, 0, uart0, pll1_auxclk, uart0_clkdev, 0),
LPSC(20, 0, uart1, pll1_auxclk, uart1_clkdev, 0), LPSC(20, 0, uart1, pll1_auxclk, uart1_clkdev, 0),
...@@ -68,7 +69,7 @@ static const struct davinci_lpsc_clk_info dm355_psc_info[] = { ...@@ -68,7 +69,7 @@ static const struct davinci_lpsc_clk_info dm355_psc_info[] = {
{ } { }
}; };
static int dm355_psc_init(struct device *dev, void __iomem *base) int dm355_psc_init(struct device *dev, void __iomem *base)
{ {
return davinci_psc_register_clocks(dev, dm355_psc_info, 42, base); return davinci_psc_register_clocks(dev, dm355_psc_info, 42, base);
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/clk/davinci.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/clkdev.h> #include <linux/clkdev.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -65,15 +66,28 @@ static const struct davinci_lpsc_clk_info dm365_psc_info[] = { ...@@ -65,15 +66,28 @@ static const struct davinci_lpsc_clk_info dm365_psc_info[] = {
LPSC(31, 0, arm, pll2_sysclk2, NULL, LPSC_ALWAYS_ENABLED), LPSC(31, 0, arm, pll2_sysclk2, NULL, LPSC_ALWAYS_ENABLED),
LPSC(38, 0, spi3, pll1_sysclk4, spi3_clkdev, 0), LPSC(38, 0, spi3, pll1_sysclk4, spi3_clkdev, 0),
LPSC(39, 0, spi4, pll1_auxclk, spi4_clkdev, 0), LPSC(39, 0, spi4, pll1_auxclk, spi4_clkdev, 0),
LPSC(40, 0, emac, pll2_sysclk4, emac_clkdev, 0), LPSC(40, 0, emac, pll1_sysclk4, emac_clkdev, 0),
LPSC(44, 1, voice_codec, pll1_sysclk3, voice_codec_clkdev, 0), /*
LPSC(46, 1, vpss_dac, pll1_sysclk3, vpss_dac_clkdev, 0), * The TRM (ARM Subsystem User's Guide) shows two clocks input into
* voice codec module (PLL2 SYSCLK4 with a DIV2 and PLL1 SYSCLK4). Its
* not fully clear from documentation which clock should be considered
* as parent for PSC. The clock chosen here is to maintain
* compatibility with existing code in arch/arm/mach-davinci/dm365.c
*/
LPSC(44, 0, voice_codec, pll2_sysclk4, voice_codec_clkdev, 0),
/*
* Its not fully clear from TRM (ARM Subsystem User's Guide) as to what
* the parent of VPSS DAC LPSC should actually be. PLL1 SYSCLK3 feeds
* into HDVICP and MJCP. The clock chosen here is to remain compatible
* with code existing in arch/arm/mach-davinci/dm365.c
*/
LPSC(46, 0, vpss_dac, pll1_sysclk3, vpss_dac_clkdev, 0),
LPSC(47, 0, vpss_master, pll1_sysclk5, vpss_master_clkdev, 0), LPSC(47, 0, vpss_master, pll1_sysclk5, vpss_master_clkdev, 0),
LPSC(50, 0, mjcp, pll1_sysclk3, NULL, 0), LPSC(50, 0, mjcp, pll1_sysclk3, NULL, 0),
{ } { }
}; };
static int dm365_psc_init(struct device *dev, void __iomem *base) int dm365_psc_init(struct device *dev, void __iomem *base)
{ {
return davinci_psc_register_clocks(dev, dm365_psc_info, 52, base); return davinci_psc_register_clocks(dev, dm365_psc_info, 52, base);
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/clk/davinci.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/clkdev.h> #include <linux/clkdev.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -63,7 +64,7 @@ static const struct davinci_lpsc_clk_info dm644x_psc_info[] = { ...@@ -63,7 +64,7 @@ static const struct davinci_lpsc_clk_info dm644x_psc_info[] = {
{ } { }
}; };
static int dm644x_psc_init(struct device *dev, void __iomem *base) int dm644x_psc_init(struct device *dev, void __iomem *base)
{ {
return davinci_psc_register_clocks(dev, dm644x_psc_info, 41, base); return davinci_psc_register_clocks(dev, dm644x_psc_info, 41, base);
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/clk/davinci.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/clkdev.h> #include <linux/clkdev.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -58,7 +59,7 @@ static const struct davinci_lpsc_clk_info dm646x_psc_info[] = { ...@@ -58,7 +59,7 @@ static const struct davinci_lpsc_clk_info dm646x_psc_info[] = {
{ } { }
}; };
static int dm646x_psc_init(struct device *dev, void __iomem *base) int dm646x_psc_init(struct device *dev, void __iomem *base)
{ {
return davinci_psc_register_clocks(dev, dm646x_psc_info, 46, base); return davinci_psc_register_clocks(dev, dm646x_psc_info, 46, base);
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/clk/davinci.h>
#include <linux/clkdev.h> #include <linux/clkdev.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/of_address.h> #include <linux/of_address.h>
...@@ -63,7 +64,7 @@ struct davinci_psc_data { ...@@ -63,7 +64,7 @@ struct davinci_psc_data {
/** /**
* struct davinci_lpsc_clk - LPSC clock structure * struct davinci_lpsc_clk - LPSC clock structure
* @dev: the device that provides this LPSC * @dev: the device that provides this LPSC or NULL
* @hw: clk_hw for the LPSC * @hw: clk_hw for the LPSC
* @pm_domain: power domain for the LPSC * @pm_domain: power domain for the LPSC
* @genpd_clk: clock reference owned by @pm_domain * @genpd_clk: clock reference owned by @pm_domain
...@@ -221,6 +222,7 @@ static void davinci_psc_genpd_detach_dev(struct generic_pm_domain *pm_domain, ...@@ -221,6 +222,7 @@ static void davinci_psc_genpd_detach_dev(struct generic_pm_domain *pm_domain,
/** /**
* davinci_lpsc_clk_register - register LPSC clock * davinci_lpsc_clk_register - register LPSC clock
* @dev: the clocks's device or NULL
* @name: name of this clock * @name: name of this clock
* @parent_name: name of clock's parent * @parent_name: name of clock's parent
* @regmap: PSC MMIO region * @regmap: PSC MMIO region
...@@ -238,7 +240,7 @@ davinci_lpsc_clk_register(struct device *dev, const char *name, ...@@ -238,7 +240,7 @@ davinci_lpsc_clk_register(struct device *dev, const char *name,
int ret; int ret;
bool is_on; bool is_on;
lpsc = devm_kzalloc(dev, sizeof(*lpsc), GFP_KERNEL); lpsc = kzalloc(sizeof(*lpsc), GFP_KERNEL);
if (!lpsc) if (!lpsc)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -261,9 +263,15 @@ davinci_lpsc_clk_register(struct device *dev, const char *name, ...@@ -261,9 +263,15 @@ davinci_lpsc_clk_register(struct device *dev, const char *name,
lpsc->pd = pd; lpsc->pd = pd;
lpsc->flags = flags; lpsc->flags = flags;
ret = devm_clk_hw_register(dev, &lpsc->hw); ret = clk_hw_register(dev, &lpsc->hw);
if (ret < 0) if (ret < 0) {
kfree(lpsc);
return ERR_PTR(ret); return ERR_PTR(ret);
}
/* for now, genpd is only registered when using device-tree */
if (!dev || !dev->of_node)
return lpsc;
/* genpd attach needs a way to look up this clock */ /* genpd attach needs a way to look up this clock */
ret = clk_hw_register_clkdev(&lpsc->hw, name, best_dev_name(dev)); ret = clk_hw_register_clkdev(&lpsc->hw, name, best_dev_name(dev));
...@@ -378,13 +386,15 @@ __davinci_psc_register_clocks(struct device *dev, ...@@ -378,13 +386,15 @@ __davinci_psc_register_clocks(struct device *dev,
struct regmap *regmap; struct regmap *regmap;
int i, ret; int i, ret;
psc = devm_kzalloc(dev, sizeof(*psc), GFP_KERNEL); psc = kzalloc(sizeof(*psc), GFP_KERNEL);
if (!psc) if (!psc)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
clks = devm_kmalloc_array(dev, num_clks, sizeof(*clks), GFP_KERNEL); clks = kmalloc_array(num_clks, sizeof(*clks), GFP_KERNEL);
if (!clks) if (!clks) {
return ERR_PTR(-ENOMEM); ret = -ENOMEM;
goto err_free_psc;
}
psc->clk_data.clks = clks; psc->clk_data.clks = clks;
psc->clk_data.clk_num = num_clks; psc->clk_data.clk_num = num_clks;
...@@ -396,16 +406,20 @@ __davinci_psc_register_clocks(struct device *dev, ...@@ -396,16 +406,20 @@ __davinci_psc_register_clocks(struct device *dev,
for (i = 0; i < num_clks; i++) for (i = 0; i < num_clks; i++)
clks[i] = ERR_PTR(-ENOENT); clks[i] = ERR_PTR(-ENOENT);
pm_domains = devm_kcalloc(dev, num_clks, sizeof(*pm_domains), GFP_KERNEL); pm_domains = kcalloc(num_clks, sizeof(*pm_domains), GFP_KERNEL);
if (!pm_domains) if (!pm_domains) {
return ERR_PTR(-ENOMEM); ret = -ENOMEM;
goto err_free_clks;
}
psc->pm_data.domains = pm_domains; psc->pm_data.domains = pm_domains;
psc->pm_data.num_domains = num_clks; psc->pm_data.num_domains = num_clks;
regmap = devm_regmap_init_mmio(dev, base, &davinci_psc_regmap_config); regmap = regmap_init_mmio(dev, base, &davinci_psc_regmap_config);
if (IS_ERR(regmap)) if (IS_ERR(regmap)) {
return ERR_CAST(regmap); ret = PTR_ERR(regmap);
goto err_free_pm_domains;
}
for (; info->name; info++) { for (; info->name; info++) {
struct davinci_lpsc_clk *lpsc; struct davinci_lpsc_clk *lpsc;
...@@ -423,6 +437,13 @@ __davinci_psc_register_clocks(struct device *dev, ...@@ -423,6 +437,13 @@ __davinci_psc_register_clocks(struct device *dev,
pm_domains[info->md] = &lpsc->pm_domain; pm_domains[info->md] = &lpsc->pm_domain;
} }
/*
* for now, a reset controller is only registered when there is a device
* to associate it with.
*/
if (!dev)
return psc;
psc->rcdev.ops = &davinci_psc_reset_ops; psc->rcdev.ops = &davinci_psc_reset_ops;
psc->rcdev.owner = THIS_MODULE; psc->rcdev.owner = THIS_MODULE;
psc->rcdev.dev = dev; psc->rcdev.dev = dev;
...@@ -436,6 +457,15 @@ __davinci_psc_register_clocks(struct device *dev, ...@@ -436,6 +457,15 @@ __davinci_psc_register_clocks(struct device *dev,
dev_warn(dev, "Failed to register reset controller (%d)\n", ret); dev_warn(dev, "Failed to register reset controller (%d)\n", ret);
return psc; return psc;
err_free_pm_domains:
kfree(pm_domains);
err_free_clks:
kfree(clks);
err_free_psc:
kfree(psc);
return ERR_PTR(ret);
} }
int davinci_psc_register_clocks(struct device *dev, int davinci_psc_register_clocks(struct device *dev,
...@@ -483,20 +513,34 @@ int of_davinci_psc_clk_init(struct device *dev, ...@@ -483,20 +513,34 @@ int of_davinci_psc_clk_init(struct device *dev,
} }
static const struct of_device_id davinci_psc_of_match[] = { static const struct of_device_id davinci_psc_of_match[] = {
#ifdef CONFIG_ARCH_DAVINCI_DA850
{ .compatible = "ti,da850-psc0", .data = &of_da850_psc0_init_data }, { .compatible = "ti,da850-psc0", .data = &of_da850_psc0_init_data },
{ .compatible = "ti,da850-psc1", .data = &of_da850_psc1_init_data }, { .compatible = "ti,da850-psc1", .data = &of_da850_psc1_init_data },
#endif
{ } { }
}; };
static const struct platform_device_id davinci_psc_id_table[] = { static const struct platform_device_id davinci_psc_id_table[] = {
#ifdef CONFIG_ARCH_DAVINCI_DA830
{ .name = "da830-psc0", .driver_data = (kernel_ulong_t)&da830_psc0_init_data }, { .name = "da830-psc0", .driver_data = (kernel_ulong_t)&da830_psc0_init_data },
{ .name = "da830-psc1", .driver_data = (kernel_ulong_t)&da830_psc1_init_data }, { .name = "da830-psc1", .driver_data = (kernel_ulong_t)&da830_psc1_init_data },
#endif
#ifdef CONFIG_ARCH_DAVINCI_DA850
{ .name = "da850-psc0", .driver_data = (kernel_ulong_t)&da850_psc0_init_data }, { .name = "da850-psc0", .driver_data = (kernel_ulong_t)&da850_psc0_init_data },
{ .name = "da850-psc1", .driver_data = (kernel_ulong_t)&da850_psc1_init_data }, { .name = "da850-psc1", .driver_data = (kernel_ulong_t)&da850_psc1_init_data },
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM355
{ .name = "dm355-psc", .driver_data = (kernel_ulong_t)&dm355_psc_init_data }, { .name = "dm355-psc", .driver_data = (kernel_ulong_t)&dm355_psc_init_data },
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM365
{ .name = "dm365-psc", .driver_data = (kernel_ulong_t)&dm365_psc_init_data }, { .name = "dm365-psc", .driver_data = (kernel_ulong_t)&dm365_psc_init_data },
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM644x
{ .name = "dm644x-psc", .driver_data = (kernel_ulong_t)&dm644x_psc_init_data }, { .name = "dm644x-psc", .driver_data = (kernel_ulong_t)&dm644x_psc_init_data },
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM646x
{ .name = "dm646x-psc", .driver_data = (kernel_ulong_t)&dm646x_psc_init_data }, { .name = "dm646x-psc", .driver_data = (kernel_ulong_t)&dm646x_psc_init_data },
#endif
{ } { }
}; };
......
...@@ -94,15 +94,27 @@ struct davinci_psc_init_data { ...@@ -94,15 +94,27 @@ struct davinci_psc_init_data {
int (*psc_init)(struct device *dev, void __iomem *base); int (*psc_init)(struct device *dev, void __iomem *base);
}; };
#ifdef CONFIG_ARCH_DAVINCI_DA830
extern const struct davinci_psc_init_data da830_psc0_init_data; extern const struct davinci_psc_init_data da830_psc0_init_data;
extern const struct davinci_psc_init_data da830_psc1_init_data; extern const struct davinci_psc_init_data da830_psc1_init_data;
#endif
#ifdef CONFIG_ARCH_DAVINCI_DA850
extern const struct davinci_psc_init_data da850_psc0_init_data; extern const struct davinci_psc_init_data da850_psc0_init_data;
extern const struct davinci_psc_init_data da850_psc1_init_data; extern const struct davinci_psc_init_data da850_psc1_init_data;
extern const struct davinci_psc_init_data of_da850_psc0_init_data; extern const struct davinci_psc_init_data of_da850_psc0_init_data;
extern const struct davinci_psc_init_data of_da850_psc1_init_data; extern const struct davinci_psc_init_data of_da850_psc1_init_data;
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM355
extern const struct davinci_psc_init_data dm355_psc_init_data; extern const struct davinci_psc_init_data dm355_psc_init_data;
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM356
extern const struct davinci_psc_init_data dm365_psc_init_data; extern const struct davinci_psc_init_data dm365_psc_init_data;
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM644x
extern const struct davinci_psc_init_data dm644x_psc_init_data; extern const struct davinci_psc_init_data dm644x_psc_init_data;
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM646x
extern const struct davinci_psc_init_data dm646x_psc_init_data; extern const struct davinci_psc_init_data dm646x_psc_init_data;
#endif
#endif /* __CLK_DAVINCI_PSC_H__ */ #endif /* __CLK_DAVINCI_PSC_H__ */
...@@ -3,6 +3,12 @@ config COMMON_CLK_AMLOGIC ...@@ -3,6 +3,12 @@ config COMMON_CLK_AMLOGIC
depends on OF depends on OF
depends on ARCH_MESON || COMPILE_TEST depends on ARCH_MESON || COMPILE_TEST
config COMMON_CLK_MESON_AO
bool
depends on OF
depends on ARCH_MESON || COMPILE_TEST
select COMMON_CLK_REGMAP_MESON
config COMMON_CLK_REGMAP_MESON config COMMON_CLK_REGMAP_MESON
bool bool
select REGMAP select REGMAP
...@@ -21,6 +27,7 @@ config COMMON_CLK_GXBB ...@@ -21,6 +27,7 @@ config COMMON_CLK_GXBB
bool bool
depends on COMMON_CLK_AMLOGIC depends on COMMON_CLK_AMLOGIC
select RESET_CONTROLLER select RESET_CONTROLLER
select COMMON_CLK_MESON_AO
select COMMON_CLK_REGMAP_MESON select COMMON_CLK_REGMAP_MESON
select MFD_SYSCON select MFD_SYSCON
help help
...@@ -31,6 +38,7 @@ config COMMON_CLK_AXG ...@@ -31,6 +38,7 @@ config COMMON_CLK_AXG
bool bool
depends on COMMON_CLK_AMLOGIC depends on COMMON_CLK_AMLOGIC
select RESET_CONTROLLER select RESET_CONTROLLER
select COMMON_CLK_MESON_AO
select COMMON_CLK_REGMAP_MESON select COMMON_CLK_REGMAP_MESON
select MFD_SYSCON select MFD_SYSCON
help help
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
# #
obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-mpll.o clk-audio-divider.o obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-mpll.o clk-audio-divider.o
obj-$(CONFIG_COMMON_CLK_MESON_AO) += meson-aoclk.o
obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o
obj-$(CONFIG_COMMON_CLK_GXBB) += gxbb.o gxbb-aoclk.o gxbb-aoclk-32k.o obj-$(CONFIG_COMMON_CLK_GXBB) += gxbb.o gxbb-aoclk.o gxbb-aoclk-32k.o
obj-$(CONFIG_COMMON_CLK_AXG) += axg.o obj-$(CONFIG_COMMON_CLK_AXG) += axg.o axg-aoclk.o
obj-$(CONFIG_COMMON_CLK_REGMAP_MESON) += clk-regmap.o obj-$(CONFIG_COMMON_CLK_REGMAP_MESON) += clk-regmap.o
// SPDX-License-Identifier: GPL-2.0+
/*
* Amlogic Meson-AXG Clock Controller Driver
*
* Copyright (c) 2016 Baylibre SAS.
* Author: Michael Turquette <mturquette@baylibre.com>
*
* Copyright (c) 2018 Amlogic, inc.
* Author: Qiufang Dai <qiufang.dai@amlogic.com>
*/
#include <linux/clk-provider.h>
#include <linux/platform_device.h>
#include <linux/reset-controller.h>
#include <linux/mfd/syscon.h>
#include "clk-regmap.h"
#include "meson-aoclk.h"
#include "axg-aoclk.h"
#define AXG_AO_GATE(_name, _bit) \
static struct clk_regmap axg_aoclk_##_name = { \
.data = &(struct clk_regmap_gate_data) { \
.offset = (AO_RTI_GEN_CNTL_REG0), \
.bit_idx = (_bit), \
}, \
.hw.init = &(struct clk_init_data) { \
.name = "axg_ao_" #_name, \
.ops = &clk_regmap_gate_ops, \
.parent_names = (const char *[]){ "clk81" }, \
.num_parents = 1, \
.flags = CLK_IGNORE_UNUSED, \
}, \
}
AXG_AO_GATE(remote, 0);
AXG_AO_GATE(i2c_master, 1);
AXG_AO_GATE(i2c_slave, 2);
AXG_AO_GATE(uart1, 3);
AXG_AO_GATE(uart2, 5);
AXG_AO_GATE(ir_blaster, 6);
AXG_AO_GATE(saradc, 7);
static struct clk_regmap axg_aoclk_clk81 = {
.data = &(struct clk_regmap_mux_data) {
.offset = AO_RTI_PWR_CNTL_REG0,
.mask = 0x1,
.shift = 8,
},
.hw.init = &(struct clk_init_data){
.name = "axg_ao_clk81",
.ops = &clk_regmap_mux_ro_ops,
.parent_names = (const char *[]){ "clk81", "ao_alt_xtal"},
.num_parents = 2,
},
};
static struct clk_regmap axg_aoclk_saradc_mux = {
.data = &(struct clk_regmap_mux_data) {
.offset = AO_SAR_CLK,
.mask = 0x3,
.shift = 9,
},
.hw.init = &(struct clk_init_data){
.name = "axg_ao_saradc_mux",
.ops = &clk_regmap_mux_ops,
.parent_names = (const char *[]){ "xtal", "axg_ao_clk81" },
.num_parents = 2,
},
};
static struct clk_regmap axg_aoclk_saradc_div = {
.data = &(struct clk_regmap_div_data) {
.offset = AO_SAR_CLK,
.shift = 0,
.width = 8,
},
.hw.init = &(struct clk_init_data){
.name = "axg_ao_saradc_div",
.ops = &clk_regmap_divider_ops,
.parent_names = (const char *[]){ "axg_ao_saradc_mux" },
.num_parents = 1,
.flags = CLK_SET_RATE_PARENT,
},
};
static struct clk_regmap axg_aoclk_saradc_gate = {
.data = &(struct clk_regmap_gate_data) {
.offset = AO_SAR_CLK,
.bit_idx = 8,
},
.hw.init = &(struct clk_init_data){
.name = "axg_ao_saradc_gate",
.ops = &clk_regmap_gate_ops,
.parent_names = (const char *[]){ "axg_ao_saradc_div" },
.num_parents = 1,
.flags = CLK_SET_RATE_PARENT,
},
};
static const unsigned int axg_aoclk_reset[] = {
[RESET_AO_REMOTE] = 16,
[RESET_AO_I2C_MASTER] = 18,
[RESET_AO_I2C_SLAVE] = 19,
[RESET_AO_UART1] = 17,
[RESET_AO_UART2] = 22,
[RESET_AO_IR_BLASTER] = 23,
};
static struct clk_regmap *axg_aoclk_regmap[] = {
[CLKID_AO_REMOTE] = &axg_aoclk_remote,
[CLKID_AO_I2C_MASTER] = &axg_aoclk_i2c_master,
[CLKID_AO_I2C_SLAVE] = &axg_aoclk_i2c_slave,
[CLKID_AO_UART1] = &axg_aoclk_uart1,
[CLKID_AO_UART2] = &axg_aoclk_uart2,
[CLKID_AO_IR_BLASTER] = &axg_aoclk_ir_blaster,
[CLKID_AO_SAR_ADC] = &axg_aoclk_saradc,
[CLKID_AO_CLK81] = &axg_aoclk_clk81,
[CLKID_AO_SAR_ADC_SEL] = &axg_aoclk_saradc_mux,
[CLKID_AO_SAR_ADC_DIV] = &axg_aoclk_saradc_div,
[CLKID_AO_SAR_ADC_CLK] = &axg_aoclk_saradc_gate,
};
static const struct clk_hw_onecell_data axg_aoclk_onecell_data = {
.hws = {
[CLKID_AO_REMOTE] = &axg_aoclk_remote.hw,
[CLKID_AO_I2C_MASTER] = &axg_aoclk_i2c_master.hw,
[CLKID_AO_I2C_SLAVE] = &axg_aoclk_i2c_slave.hw,
[CLKID_AO_UART1] = &axg_aoclk_uart1.hw,
[CLKID_AO_UART2] = &axg_aoclk_uart2.hw,
[CLKID_AO_IR_BLASTER] = &axg_aoclk_ir_blaster.hw,
[CLKID_AO_SAR_ADC] = &axg_aoclk_saradc.hw,
[CLKID_AO_CLK81] = &axg_aoclk_clk81.hw,
[CLKID_AO_SAR_ADC_SEL] = &axg_aoclk_saradc_mux.hw,
[CLKID_AO_SAR_ADC_DIV] = &axg_aoclk_saradc_div.hw,
[CLKID_AO_SAR_ADC_CLK] = &axg_aoclk_saradc_gate.hw,
},
.num = NR_CLKS,
};
static const struct meson_aoclk_data axg_aoclkc_data = {
.reset_reg = AO_RTI_GEN_CNTL_REG0,
.num_reset = ARRAY_SIZE(axg_aoclk_reset),
.reset = axg_aoclk_reset,
.num_clks = ARRAY_SIZE(axg_aoclk_regmap),
.clks = axg_aoclk_regmap,
.hw_data = &axg_aoclk_onecell_data,
};
static const struct of_device_id axg_aoclkc_match_table[] = {
{
.compatible = "amlogic,meson-axg-aoclkc",
.data = &axg_aoclkc_data,
},
{ }
};
static struct platform_driver axg_aoclkc_driver = {
.probe = meson_aoclkc_probe,
.driver = {
.name = "axg-aoclkc",
.of_match_table = axg_aoclkc_match_table,
},
};
builtin_platform_driver(axg_aoclkc_driver);
/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
/*
* Copyright (c) 2017 BayLibre, SAS
* Author: Neil Armstrong <narmstrong@baylibre.com>
*
* Copyright (c) 2018 Amlogic, inc.
* Author: Qiufang Dai <qiufang.dai@amlogic.com>
*/
#ifndef __AXG_AOCLKC_H
#define __AXG_AOCLKC_H
#define NR_CLKS 11
/* AO Configuration Clock registers offsets
* Register offsets from the data sheet must be multiplied by 4.
*/
#define AO_RTI_PWR_CNTL_REG1 0x0C
#define AO_RTI_PWR_CNTL_REG0 0x10
#define AO_RTI_GEN_CNTL_REG0 0x40
#define AO_OSCIN_CNTL 0x58
#define AO_CRT_CLK_CNTL1 0x68
#define AO_SAR_CLK 0x90
#define AO_RTC_ALT_CLK_CNTL0 0x94
#define AO_RTC_ALT_CLK_CNTL1 0x98
#include <dt-bindings/clock/axg-aoclkc.h>
#include <dt-bindings/reset/axg-aoclkc.h>
#endif /* __AXG_AOCLKC_H */
...@@ -461,6 +461,7 @@ static struct clk_regmap axg_mpll0_div = { ...@@ -461,6 +461,7 @@ static struct clk_regmap axg_mpll0_div = {
.width = 1, .width = 1,
}, },
.lock = &meson_clk_lock, .lock = &meson_clk_lock,
.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
}, },
.hw.init = &(struct clk_init_data){ .hw.init = &(struct clk_init_data){
.name = "mpll0_div", .name = "mpll0_div",
...@@ -507,6 +508,7 @@ static struct clk_regmap axg_mpll1_div = { ...@@ -507,6 +508,7 @@ static struct clk_regmap axg_mpll1_div = {
.width = 1, .width = 1,
}, },
.lock = &meson_clk_lock, .lock = &meson_clk_lock,
.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
}, },
.hw.init = &(struct clk_init_data){ .hw.init = &(struct clk_init_data){
.name = "mpll1_div", .name = "mpll1_div",
...@@ -553,6 +555,7 @@ static struct clk_regmap axg_mpll2_div = { ...@@ -553,6 +555,7 @@ static struct clk_regmap axg_mpll2_div = {
.width = 1, .width = 1,
}, },
.lock = &meson_clk_lock, .lock = &meson_clk_lock,
.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
}, },
.hw.init = &(struct clk_init_data){ .hw.init = &(struct clk_init_data){
.name = "mpll2_div", .name = "mpll2_div",
...@@ -599,6 +602,7 @@ static struct clk_regmap axg_mpll3_div = { ...@@ -599,6 +602,7 @@ static struct clk_regmap axg_mpll3_div = {
.width = 1, .width = 1,
}, },
.lock = &meson_clk_lock, .lock = &meson_clk_lock,
.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
}, },
.hw.init = &(struct clk_init_data){ .hw.init = &(struct clk_init_data){
.name = "mpll3_div", .name = "mpll3_div",
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (c) 2017 AmLogic, Inc. * Copyright (c) 2017 AmLogic, Inc.
* Author: Jerome Brunet <jbrunet@baylibre.com> * Author: Jerome Brunet <jbrunet@baylibre.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* /*
......
// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
/* /*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright (c) 2016 AmLogic, Inc.
* Author: Michael Turquette <mturquette@baylibre.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
* The full GNU General Public License is included in this distribution
* in the file called COPYING
*
* BSD LICENSE
*
* Copyright (c) 2016 AmLogic, Inc. * Copyright (c) 2016 AmLogic, Inc.
* Author: Michael Turquette <mturquette@baylibre.com> * Author: Michael Turquette <mturquette@baylibre.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
...@@ -89,10 +39,23 @@ static long rate_from_params(unsigned long parent_rate, ...@@ -89,10 +39,23 @@ static long rate_from_params(unsigned long parent_rate,
static void params_from_rate(unsigned long requested_rate, static void params_from_rate(unsigned long requested_rate,
unsigned long parent_rate, unsigned long parent_rate,
unsigned int *sdm, unsigned int *sdm,
unsigned int *n2) unsigned int *n2,
u8 flags)
{ {
uint64_t div = parent_rate; uint64_t div = parent_rate;
unsigned long rem = do_div(div, requested_rate); uint64_t frac = do_div(div, requested_rate);
frac *= SDM_DEN;
if (flags & CLK_MESON_MPLL_ROUND_CLOSEST)
*sdm = DIV_ROUND_CLOSEST_ULL(frac, requested_rate);
else
*sdm = DIV_ROUND_UP_ULL(frac, requested_rate);
if (*sdm == SDM_DEN) {
*sdm = 0;
div += 1;
}
if (div < N2_MIN) { if (div < N2_MIN) {
*n2 = N2_MIN; *n2 = N2_MIN;
...@@ -102,7 +65,6 @@ static void params_from_rate(unsigned long requested_rate, ...@@ -102,7 +65,6 @@ static void params_from_rate(unsigned long requested_rate,
*sdm = SDM_DEN - 1; *sdm = SDM_DEN - 1;
} else { } else {
*n2 = div; *n2 = div;
*sdm = DIV_ROUND_UP_ULL((u64)rem * SDM_DEN, requested_rate);
} }
} }
...@@ -125,9 +87,11 @@ static long mpll_round_rate(struct clk_hw *hw, ...@@ -125,9 +87,11 @@ static long mpll_round_rate(struct clk_hw *hw,
unsigned long rate, unsigned long rate,
unsigned long *parent_rate) unsigned long *parent_rate)
{ {
struct clk_regmap *clk = to_clk_regmap(hw);
struct meson_clk_mpll_data *mpll = meson_clk_mpll_data(clk);
unsigned int sdm, n2; unsigned int sdm, n2;
params_from_rate(rate, *parent_rate, &sdm, &n2); params_from_rate(rate, *parent_rate, &sdm, &n2, mpll->flags);
return rate_from_params(*parent_rate, sdm, n2); return rate_from_params(*parent_rate, sdm, n2);
} }
...@@ -140,7 +104,7 @@ static int mpll_set_rate(struct clk_hw *hw, ...@@ -140,7 +104,7 @@ static int mpll_set_rate(struct clk_hw *hw,
unsigned int sdm, n2; unsigned int sdm, n2;
unsigned long flags = 0; unsigned long flags = 0;
params_from_rate(rate, parent_rate, &sdm, &n2); params_from_rate(rate, parent_rate, &sdm, &n2, mpll->flags);
if (mpll->lock) if (mpll->lock)
spin_lock_irqsave(mpll->lock, flags); spin_lock_irqsave(mpll->lock, flags);
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (c) 2015 Endless Mobile, Inc. * Copyright (c) 2015 Endless Mobile, Inc.
* Author: Carlo Caione <carlo@endlessm.com> * Author: Carlo Caione <carlo@endlessm.com>
* *
* Copyright (c) 2018 Baylibre, SAS. * Copyright (c) 2018 Baylibre, SAS.
* Author: Jerome Brunet <jbrunet@baylibre.com> * Author: Jerome Brunet <jbrunet@baylibre.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* /*
......
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2018 BayLibre, SAS. /*
// Author: Jerome Brunet <jbrunet@baylibre.com> * Copyright (c) 2018 BayLibre, SAS.
* Author: Jerome Brunet <jbrunet@baylibre.com>
*/
#include "clk-regmap.h" #include "clk-regmap.h"
......
// SPDX-License-Identifier: GPL-2.0 /* SPDX-License-Identifier: GPL-2.0 */
// Copyright (c) 2018 BayLibre, SAS. /*
// Author: Jerome Brunet <jbrunet@baylibre.com> * Copyright (c) 2018 BayLibre, SAS.
* Author: Jerome Brunet <jbrunet@baylibre.com>
*/
#ifndef __CLK_REGMAP_H #ifndef __CLK_REGMAP_H
#define __CLK_REGMAP_H #define __CLK_REGMAP_H
......
/* SPDX-License-Identifier: GPL-2.0 */
/* /*
* Copyright (c) 2015 Endless Mobile, Inc. * Copyright (c) 2015 Endless Mobile, Inc.
* Author: Carlo Caione <carlo@endlessm.com> * Author: Carlo Caione <carlo@endlessm.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __CLKC_H #ifndef __CLKC_H
...@@ -97,8 +86,11 @@ struct meson_clk_mpll_data { ...@@ -97,8 +86,11 @@ struct meson_clk_mpll_data {
struct parm ssen; struct parm ssen;
struct parm misc; struct parm misc;
spinlock_t *lock; spinlock_t *lock;
u8 flags;
}; };
#define CLK_MESON_MPLL_ROUND_CLOSEST BIT(0)
struct meson_clk_audio_div_data { struct meson_clk_audio_div_data {
struct parm div; struct parm div;
u8 flags; u8 flags;
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Copyright (c) 2017 BayLibre, SAS. * Copyright (c) 2017 BayLibre, SAS.
* Author: Neil Armstrong <narmstrong@baylibre.com> * Author: Neil Armstrong <narmstrong@baylibre.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/ */
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
......
// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
/* /*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright (c) 2016 BayLibre, SAS. * Copyright (c) 2016 BayLibre, SAS.
* Author: Neil Armstrong <narmstrong@baylibre.com> * Author: Neil Armstrong <narmstrong@baylibre.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
* The full GNU General Public License is included in this distribution
* in the file called COPYING.
*
* BSD LICENSE
*
* Copyright (c) 2016 BayLibre, SAS.
* Author: Neil Armstrong <narmstrong@baylibre.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <linux/clk-provider.h>
#include <linux/of_address.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/reset-controller.h>
#include <linux/mfd/syscon.h> #include <linux/mfd/syscon.h>
#include <linux/regmap.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <dt-bindings/clock/gxbb-aoclkc.h>
#include <dt-bindings/reset/gxbb-aoclkc.h>
#include "clk-regmap.h" #include "clk-regmap.h"
#include "meson-aoclk.h"
#include "gxbb-aoclk.h" #include "gxbb-aoclk.h"
struct gxbb_aoclk_reset_controller {
struct reset_controller_dev reset;
unsigned int *data;
struct regmap *regmap;
};
static int gxbb_aoclk_do_reset(struct reset_controller_dev *rcdev,
unsigned long id)
{
struct gxbb_aoclk_reset_controller *reset =
container_of(rcdev, struct gxbb_aoclk_reset_controller, reset);
return regmap_write(reset->regmap, AO_RTI_GEN_CNTL_REG0,
BIT(reset->data[id]));
}
static const struct reset_control_ops gxbb_aoclk_reset_ops = {
.reset = gxbb_aoclk_do_reset,
};
#define GXBB_AO_GATE(_name, _bit) \ #define GXBB_AO_GATE(_name, _bit) \
static struct clk_regmap _name##_ao = { \ static struct clk_regmap _name##_ao = { \
.data = &(struct clk_regmap_gate_data) { \ .data = &(struct clk_regmap_gate_data) { \
...@@ -96,7 +20,7 @@ static struct clk_regmap _name##_ao = { \ ...@@ -96,7 +20,7 @@ static struct clk_regmap _name##_ao = { \
.ops = &clk_regmap_gate_ops, \ .ops = &clk_regmap_gate_ops, \
.parent_names = (const char *[]){ "clk81" }, \ .parent_names = (const char *[]){ "clk81" }, \
.num_parents = 1, \ .num_parents = 1, \
.flags = (CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED), \ .flags = CLK_IGNORE_UNUSED, \
}, \ }, \
} }
...@@ -117,7 +41,7 @@ static struct aoclk_cec_32k cec_32k_ao = { ...@@ -117,7 +41,7 @@ static struct aoclk_cec_32k cec_32k_ao = {
}, },
}; };
static unsigned int gxbb_aoclk_reset[] = { static const unsigned int gxbb_aoclk_reset[] = {
[RESET_AO_REMOTE] = 16, [RESET_AO_REMOTE] = 16,
[RESET_AO_I2C_MASTER] = 18, [RESET_AO_I2C_MASTER] = 18,
[RESET_AO_I2C_SLAVE] = 19, [RESET_AO_I2C_SLAVE] = 19,
...@@ -135,7 +59,7 @@ static struct clk_regmap *gxbb_aoclk_gate[] = { ...@@ -135,7 +59,7 @@ static struct clk_regmap *gxbb_aoclk_gate[] = {
[CLKID_AO_IR_BLASTER] = &ir_blaster_ao, [CLKID_AO_IR_BLASTER] = &ir_blaster_ao,
}; };
static struct clk_hw_onecell_data gxbb_aoclk_onecell_data = { static const struct clk_hw_onecell_data gxbb_aoclk_onecell_data = {
.hws = { .hws = {
[CLKID_AO_REMOTE] = &remote_ao.hw, [CLKID_AO_REMOTE] = &remote_ao.hw,
[CLKID_AO_I2C_MASTER] = &i2c_master_ao.hw, [CLKID_AO_I2C_MASTER] = &i2c_master_ao.hw,
...@@ -145,58 +69,55 @@ static struct clk_hw_onecell_data gxbb_aoclk_onecell_data = { ...@@ -145,58 +69,55 @@ static struct clk_hw_onecell_data gxbb_aoclk_onecell_data = {
[CLKID_AO_IR_BLASTER] = &ir_blaster_ao.hw, [CLKID_AO_IR_BLASTER] = &ir_blaster_ao.hw,
[CLKID_AO_CEC_32K] = &cec_32k_ao.hw, [CLKID_AO_CEC_32K] = &cec_32k_ao.hw,
}, },
.num = 7, .num = NR_CLKS,
}; };
static int gxbb_aoclkc_probe(struct platform_device *pdev) static int gxbb_register_cec_ao_32k(struct platform_device *pdev)
{ {
struct gxbb_aoclk_reset_controller *rstc;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct regmap *regmap; struct regmap *regmap;
int ret, clkid; int ret;
rstc = devm_kzalloc(dev, sizeof(*rstc), GFP_KERNEL);
if (!rstc)
return -ENOMEM;
regmap = syscon_node_to_regmap(of_get_parent(dev->of_node)); regmap = syscon_node_to_regmap(of_get_parent(dev->of_node));
if (IS_ERR(regmap)) { if (IS_ERR(regmap)) {
dev_err(dev, "failed to get regmap\n"); dev_err(dev, "failed to get regmap\n");
return -ENODEV; return PTR_ERR(regmap);
}
/* Reset Controller */
rstc->regmap = regmap;
rstc->data = gxbb_aoclk_reset;
rstc->reset.ops = &gxbb_aoclk_reset_ops;
rstc->reset.nr_resets = ARRAY_SIZE(gxbb_aoclk_reset);
rstc->reset.of_node = dev->of_node;
ret = devm_reset_controller_register(dev, &rstc->reset);
/*
* Populate regmap and register all clks
*/
for (clkid = 0; clkid < ARRAY_SIZE(gxbb_aoclk_gate); clkid++) {
gxbb_aoclk_gate[clkid]->map = regmap;
ret = devm_clk_hw_register(dev,
gxbb_aoclk_onecell_data.hws[clkid]);
if (ret)
return ret;
} }
/* Specific clocks */ /* Specific clocks */
cec_32k_ao.regmap = regmap; cec_32k_ao.regmap = regmap;
ret = devm_clk_hw_register(dev, &cec_32k_ao.hw); ret = devm_clk_hw_register(dev, &cec_32k_ao.hw);
if (ret) {
dev_err(&pdev->dev, "clk cec_32k_ao register failed.\n");
return ret;
}
return 0;
}
static const struct meson_aoclk_data gxbb_aoclkc_data = {
.reset_reg = AO_RTI_GEN_CNTL_REG0,
.num_reset = ARRAY_SIZE(gxbb_aoclk_reset),
.reset = gxbb_aoclk_reset,
.num_clks = ARRAY_SIZE(gxbb_aoclk_gate),
.clks = gxbb_aoclk_gate,
.hw_data = &gxbb_aoclk_onecell_data,
};
static int gxbb_aoclkc_probe(struct platform_device *pdev)
{
int ret = gxbb_register_cec_ao_32k(pdev);
if (ret) if (ret)
return ret; return ret;
return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get, return meson_aoclkc_probe(pdev);
&gxbb_aoclk_onecell_data);
} }
static const struct of_device_id gxbb_aoclkc_match_table[] = { static const struct of_device_id gxbb_aoclkc_match_table[] = {
{ .compatible = "amlogic,meson-gx-aoclkc" }, {
.compatible = "amlogic,meson-gx-aoclkc",
.data = &gxbb_aoclkc_data,
},
{ } { }
}; };
......
/* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* Copyright (c) 2017 BayLibre, SAS * Copyright (c) 2017 BayLibre, SAS
* Author: Neil Armstrong <narmstrong@baylibre.com> * Author: Neil Armstrong <narmstrong@baylibre.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/ */
#ifndef __GXBB_AOCLKC_H #ifndef __GXBB_AOCLKC_H
#define __GXBB_AOCLKC_H #define __GXBB_AOCLKC_H
#define NR_CLKS 7
/* AO Configuration Clock registers offsets */ /* AO Configuration Clock registers offsets */
#define AO_RTI_PWR_CNTL_REG1 0x0c #define AO_RTI_PWR_CNTL_REG1 0x0c
#define AO_RTI_PWR_CNTL_REG0 0x10 #define AO_RTI_PWR_CNTL_REG0 0x10
...@@ -28,4 +29,7 @@ struct aoclk_cec_32k { ...@@ -28,4 +29,7 @@ struct aoclk_cec_32k {
extern const struct clk_ops meson_aoclk_cec_32k_ops; extern const struct clk_ops meson_aoclk_cec_32k_ops;
#include <dt-bindings/clock/gxbb-aoclkc.h>
#include <dt-bindings/reset/gxbb-aoclkc.h>
#endif /* __GXBB_AOCLKC_H */ #endif /* __GXBB_AOCLKC_H */
// SPDX-License-Identifier: GPL-2.0
/* /*
* AmLogic S905 / GXBB Clock Controller Driver
*
* Copyright (c) 2016 AmLogic, Inc. * Copyright (c) 2016 AmLogic, Inc.
* Michael Turquette <mturquette@baylibre.com> * Michael Turquette <mturquette@baylibre.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/clk.h> #include <linux/clk.h>
...@@ -1543,6 +1530,102 @@ static struct clk_regmap gxbb_vapb = { ...@@ -1543,6 +1530,102 @@ static struct clk_regmap gxbb_vapb = {
}, },
}; };
/* VDEC clocks */
static const char * const gxbb_vdec_parent_names[] = {
"fclk_div4", "fclk_div3", "fclk_div5", "fclk_div7"
};
static struct clk_regmap gxbb_vdec_1_sel = {
.data = &(struct clk_regmap_mux_data){
.offset = HHI_VDEC_CLK_CNTL,
.mask = 0x3,
.shift = 9,
.flags = CLK_MUX_ROUND_CLOSEST,
},
.hw.init = &(struct clk_init_data){
.name = "vdec_1_sel",
.ops = &clk_regmap_mux_ops,
.parent_names = gxbb_vdec_parent_names,
.num_parents = ARRAY_SIZE(gxbb_vdec_parent_names),
.flags = CLK_SET_RATE_PARENT,
},
};
static struct clk_regmap gxbb_vdec_1_div = {
.data = &(struct clk_regmap_div_data){
.offset = HHI_VDEC_CLK_CNTL,
.shift = 0,
.width = 7,
},
.hw.init = &(struct clk_init_data){
.name = "vdec_1_div",
.ops = &clk_regmap_divider_ops,
.parent_names = (const char *[]){ "vdec_1_sel" },
.num_parents = 1,
.flags = CLK_SET_RATE_PARENT,
},
};
static struct clk_regmap gxbb_vdec_1 = {
.data = &(struct clk_regmap_gate_data){
.offset = HHI_VDEC_CLK_CNTL,
.bit_idx = 8,
},
.hw.init = &(struct clk_init_data) {
.name = "vdec_1",
.ops = &clk_regmap_gate_ops,
.parent_names = (const char *[]){ "vdec_1_div" },
.num_parents = 1,
.flags = CLK_SET_RATE_PARENT,
},
};
static struct clk_regmap gxbb_vdec_hevc_sel = {
.data = &(struct clk_regmap_mux_data){
.offset = HHI_VDEC2_CLK_CNTL,
.mask = 0x3,
.shift = 25,
.flags = CLK_MUX_ROUND_CLOSEST,
},
.hw.init = &(struct clk_init_data){
.name = "vdec_hevc_sel",
.ops = &clk_regmap_mux_ops,
.parent_names = gxbb_vdec_parent_names,
.num_parents = ARRAY_SIZE(gxbb_vdec_parent_names),
.flags = CLK_SET_RATE_PARENT,
},
};
static struct clk_regmap gxbb_vdec_hevc_div = {
.data = &(struct clk_regmap_div_data){
.offset = HHI_VDEC2_CLK_CNTL,
.shift = 16,
.width = 7,
},
.hw.init = &(struct clk_init_data){
.name = "vdec_hevc_div",
.ops = &clk_regmap_divider_ops,
.parent_names = (const char *[]){ "vdec_hevc_sel" },
.num_parents = 1,
.flags = CLK_SET_RATE_PARENT,
},
};
static struct clk_regmap gxbb_vdec_hevc = {
.data = &(struct clk_regmap_gate_data){
.offset = HHI_VDEC2_CLK_CNTL,
.bit_idx = 24,
},
.hw.init = &(struct clk_init_data) {
.name = "vdec_hevc",
.ops = &clk_regmap_gate_ops,
.parent_names = (const char *[]){ "vdec_hevc_div" },
.num_parents = 1,
.flags = CLK_SET_RATE_PARENT,
},
};
/* Everything Else (EE) domain gates */ /* Everything Else (EE) domain gates */
static MESON_GATE(gxbb_ddr, HHI_GCLK_MPEG0, 0); static MESON_GATE(gxbb_ddr, HHI_GCLK_MPEG0, 0);
static MESON_GATE(gxbb_dos, HHI_GCLK_MPEG0, 1); static MESON_GATE(gxbb_dos, HHI_GCLK_MPEG0, 1);
...@@ -1786,6 +1869,12 @@ static struct clk_hw_onecell_data gxbb_hw_onecell_data = { ...@@ -1786,6 +1869,12 @@ static struct clk_hw_onecell_data gxbb_hw_onecell_data = {
[CLKID_FCLK_DIV4_DIV] = &gxbb_fclk_div4_div.hw, [CLKID_FCLK_DIV4_DIV] = &gxbb_fclk_div4_div.hw,
[CLKID_FCLK_DIV5_DIV] = &gxbb_fclk_div5_div.hw, [CLKID_FCLK_DIV5_DIV] = &gxbb_fclk_div5_div.hw,
[CLKID_FCLK_DIV7_DIV] = &gxbb_fclk_div7_div.hw, [CLKID_FCLK_DIV7_DIV] = &gxbb_fclk_div7_div.hw,
[CLKID_VDEC_1_SEL] = &gxbb_vdec_1_sel.hw,
[CLKID_VDEC_1_DIV] = &gxbb_vdec_1_div.hw,
[CLKID_VDEC_1] = &gxbb_vdec_1.hw,
[CLKID_VDEC_HEVC_SEL] = &gxbb_vdec_hevc_sel.hw,
[CLKID_VDEC_HEVC_DIV] = &gxbb_vdec_hevc_div.hw,
[CLKID_VDEC_HEVC] = &gxbb_vdec_hevc.hw,
[NR_CLKS] = NULL, [NR_CLKS] = NULL,
}, },
.num = NR_CLKS, .num = NR_CLKS,
...@@ -1942,6 +2031,12 @@ static struct clk_hw_onecell_data gxl_hw_onecell_data = { ...@@ -1942,6 +2031,12 @@ static struct clk_hw_onecell_data gxl_hw_onecell_data = {
[CLKID_FCLK_DIV4_DIV] = &gxbb_fclk_div4_div.hw, [CLKID_FCLK_DIV4_DIV] = &gxbb_fclk_div4_div.hw,
[CLKID_FCLK_DIV5_DIV] = &gxbb_fclk_div5_div.hw, [CLKID_FCLK_DIV5_DIV] = &gxbb_fclk_div5_div.hw,
[CLKID_FCLK_DIV7_DIV] = &gxbb_fclk_div7_div.hw, [CLKID_FCLK_DIV7_DIV] = &gxbb_fclk_div7_div.hw,
[CLKID_VDEC_1_SEL] = &gxbb_vdec_1_sel.hw,
[CLKID_VDEC_1_DIV] = &gxbb_vdec_1_div.hw,
[CLKID_VDEC_1] = &gxbb_vdec_1.hw,
[CLKID_VDEC_HEVC_SEL] = &gxbb_vdec_hevc_sel.hw,
[CLKID_VDEC_HEVC_DIV] = &gxbb_vdec_hevc_div.hw,
[CLKID_VDEC_HEVC] = &gxbb_vdec_hevc.hw,
[NR_CLKS] = NULL, [NR_CLKS] = NULL,
}, },
.num = NR_CLKS, .num = NR_CLKS,
...@@ -2100,6 +2195,12 @@ static struct clk_regmap *const gx_clk_regmaps[] = { ...@@ -2100,6 +2195,12 @@ static struct clk_regmap *const gx_clk_regmaps[] = {
&gxbb_fclk_div4, &gxbb_fclk_div4,
&gxbb_fclk_div5, &gxbb_fclk_div5,
&gxbb_fclk_div7, &gxbb_fclk_div7,
&gxbb_vdec_1_sel,
&gxbb_vdec_1_div,
&gxbb_vdec_1,
&gxbb_vdec_hevc_sel,
&gxbb_vdec_hevc_div,
&gxbb_vdec_hevc,
}; };
struct clkc_data { struct clkc_data {
......
/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
/* /*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright (c) 2016 AmLogic, Inc. * Copyright (c) 2016 AmLogic, Inc.
* Author: Michael Turquette <mturquette@baylibre.com> * Author: Michael Turquette <mturquette@baylibre.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
* The full GNU General Public License is included in this distribution
* in the file called COPYING
*
* BSD LICENSE
*
* Copyright (c) 2016 BayLibre, Inc.
* Author: Michael Turquette <mturquette@baylibre.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __GXBB_H #ifndef __GXBB_H
...@@ -204,8 +154,12 @@ ...@@ -204,8 +154,12 @@
#define CLKID_FCLK_DIV4_DIV 148 #define CLKID_FCLK_DIV4_DIV 148
#define CLKID_FCLK_DIV5_DIV 149 #define CLKID_FCLK_DIV5_DIV 149
#define CLKID_FCLK_DIV7_DIV 150 #define CLKID_FCLK_DIV7_DIV 150
#define CLKID_VDEC_1_SEL 151
#define CLKID_VDEC_1_DIV 152
#define CLKID_VDEC_HEVC_SEL 154
#define CLKID_VDEC_HEVC_DIV 155
#define NR_CLKS 151 #define NR_CLKS 157
/* include the CLKIDs that have been made part of the DT binding */ /* include the CLKIDs that have been made part of the DT binding */
#include <dt-bindings/clock/gxbb-clkc.h> #include <dt-bindings/clock/gxbb-clkc.h>
......
// SPDX-License-Identifier: GPL-2.0+
/*
* Amlogic Meson-AXG Clock Controller Driver
*
* Copyright (c) 2016 BayLibre, SAS.
* Author: Neil Armstrong <narmstrong@baylibre.com>
*
* Copyright (c) 2018 Amlogic, inc.
* Author: Qiufang Dai <qiufang.dai@amlogic.com>
* Author: Yixun Lan <yixun.lan@amlogic.com>
*/
#include <linux/platform_device.h>
#include <linux/reset-controller.h>
#include <linux/mfd/syscon.h>
#include <linux/of_device.h>
#include "clk-regmap.h"
#include "meson-aoclk.h"
static int meson_aoclk_do_reset(struct reset_controller_dev *rcdev,
unsigned long id)
{
struct meson_aoclk_reset_controller *rstc =
container_of(rcdev, struct meson_aoclk_reset_controller, reset);
return regmap_write(rstc->regmap, rstc->data->reset_reg,
BIT(rstc->data->reset[id]));
}
static const struct reset_control_ops meson_aoclk_reset_ops = {
.reset = meson_aoclk_do_reset,
};
int meson_aoclkc_probe(struct platform_device *pdev)
{
struct meson_aoclk_reset_controller *rstc;
struct meson_aoclk_data *data;
struct device *dev = &pdev->dev;
struct regmap *regmap;
int ret, clkid;
data = (struct meson_aoclk_data *) of_device_get_match_data(dev);
if (!data)
return -ENODEV;
rstc = devm_kzalloc(dev, sizeof(*rstc), GFP_KERNEL);
if (!rstc)
return -ENOMEM;
regmap = syscon_node_to_regmap(of_get_parent(dev->of_node));
if (IS_ERR(regmap)) {
dev_err(dev, "failed to get regmap\n");
return PTR_ERR(regmap);
}
/* Reset Controller */
rstc->data = data;
rstc->regmap = regmap;
rstc->reset.ops = &meson_aoclk_reset_ops;
rstc->reset.nr_resets = data->num_reset,
rstc->reset.of_node = dev->of_node;
ret = devm_reset_controller_register(dev, &rstc->reset);
if (ret) {
dev_err(dev, "failed to register reset controller\n");
return ret;
}
/*
* Populate regmap and register all clks
*/
for (clkid = 0; clkid < data->num_clks; clkid++) {
data->clks[clkid]->map = regmap;
ret = devm_clk_hw_register(dev, data->hw_data->hws[clkid]);
if (ret)
return ret;
}
return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
(void *) data->hw_data);
}
/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
/*
* Copyright (c) 2017 BayLibre, SAS
* Author: Neil Armstrong <narmstrong@baylibre.com>
*
* Copyright (c) 2018 Amlogic, inc.
* Author: Qiufang Dai <qiufang.dai@amlogic.com>
* Author: Yixun Lan <yixun.lan@amlogic.com>
*/
#ifndef __MESON_AOCLK_H__
#define __MESON_AOCLK_H__
#include <linux/platform_device.h>
#include <linux/reset-controller.h>
#include "clk-regmap.h"
struct meson_aoclk_data {
const unsigned int reset_reg;
const int num_reset;
const unsigned int *reset;
int num_clks;
struct clk_regmap **clks;
const struct clk_hw_onecell_data *hw_data;
};
struct meson_aoclk_reset_controller {
struct reset_controller_dev reset;
const struct meson_aoclk_data *data;
struct regmap *regmap;
};
int meson_aoclkc_probe(struct platform_device *pdev);
#endif
// SPDX-License-Identifier: GPL-2.0
/* /*
* AmLogic S802 (Meson8) / S805 (Meson8b) / S812 (Meson8m2) Clock Controller
* Driver
*
* Copyright (c) 2015 Endless Mobile, Inc. * Copyright (c) 2015 Endless Mobile, Inc.
* Author: Carlo Caione <carlo@endlessm.com> * Author: Carlo Caione <carlo@endlessm.com>
* *
* Copyright (c) 2016 BayLibre, Inc. * Copyright (c) 2016 BayLibre, Inc.
* Michael Turquette <mturquette@baylibre.com> * Michael Turquette <mturquette@baylibre.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/clk.h> #include <linux/clk.h>
...@@ -246,6 +232,13 @@ static struct clk_regmap meson8b_fclk_div2 = { ...@@ -246,6 +232,13 @@ static struct clk_regmap meson8b_fclk_div2 = {
.ops = &clk_regmap_gate_ops, .ops = &clk_regmap_gate_ops,
.parent_names = (const char *[]){ "fclk_div2_div" }, .parent_names = (const char *[]){ "fclk_div2_div" },
.num_parents = 1, .num_parents = 1,
/*
* FIXME: Ethernet with a RGMII PHYs is not working if
* fclk_div2 is disabled. it is currently unclear why this
* is. keep it enabled until the Ethernet driver knows how
* to manage this clock.
*/
.flags = CLK_IS_CRITICAL,
}, },
}; };
...@@ -639,6 +632,54 @@ static struct clk_regmap meson8b_cpu_clk = { ...@@ -639,6 +632,54 @@ static struct clk_regmap meson8b_cpu_clk = {
}, },
}; };
static struct clk_regmap meson8b_nand_clk_sel = {
.data = &(struct clk_regmap_mux_data){
.offset = HHI_NAND_CLK_CNTL,
.mask = 0x7,
.shift = 9,
.flags = CLK_MUX_ROUND_CLOSEST,
},
.hw.init = &(struct clk_init_data){
.name = "nand_clk_sel",
.ops = &clk_regmap_mux_ops,
/* FIXME all other parents are unknown: */
.parent_names = (const char *[]){ "fclk_div4", "fclk_div3",
"fclk_div5", "fclk_div7", "xtal" },
.num_parents = 5,
.flags = CLK_SET_RATE_PARENT,
},
};
static struct clk_regmap meson8b_nand_clk_div = {
.data = &(struct clk_regmap_div_data){
.offset = HHI_NAND_CLK_CNTL,
.shift = 0,
.width = 7,
.flags = CLK_DIVIDER_ROUND_CLOSEST,
},
.hw.init = &(struct clk_init_data){
.name = "nand_clk_div",
.ops = &clk_regmap_divider_ops,
.parent_names = (const char *[]){ "nand_clk_sel" },
.num_parents = 1,
.flags = CLK_SET_RATE_PARENT,
},
};
static struct clk_regmap meson8b_nand_clk_gate = {
.data = &(struct clk_regmap_gate_data){
.offset = HHI_NAND_CLK_CNTL,
.bit_idx = 8,
},
.hw.init = &(struct clk_init_data){
.name = "nand_clk_gate",
.ops = &clk_regmap_gate_ops,
.parent_names = (const char *[]){ "nand_clk_div" },
.num_parents = 1,
.flags = CLK_SET_RATE_PARENT,
},
};
/* Everything Else (EE) domain gates */ /* Everything Else (EE) domain gates */
static MESON_GATE(meson8b_ddr, HHI_GCLK_MPEG0, 0); static MESON_GATE(meson8b_ddr, HHI_GCLK_MPEG0, 0);
...@@ -834,6 +875,9 @@ static struct clk_hw_onecell_data meson8b_hw_onecell_data = { ...@@ -834,6 +875,9 @@ static struct clk_hw_onecell_data meson8b_hw_onecell_data = {
[CLKID_FCLK_DIV4_DIV] = &meson8b_fclk_div4_div.hw, [CLKID_FCLK_DIV4_DIV] = &meson8b_fclk_div4_div.hw,
[CLKID_FCLK_DIV5_DIV] = &meson8b_fclk_div5_div.hw, [CLKID_FCLK_DIV5_DIV] = &meson8b_fclk_div5_div.hw,
[CLKID_FCLK_DIV7_DIV] = &meson8b_fclk_div7_div.hw, [CLKID_FCLK_DIV7_DIV] = &meson8b_fclk_div7_div.hw,
[CLKID_NAND_SEL] = &meson8b_nand_clk_sel.hw,
[CLKID_NAND_DIV] = &meson8b_nand_clk_div.hw,
[CLKID_NAND_CLK] = &meson8b_nand_clk_gate.hw,
[CLK_NR_CLKS] = NULL, [CLK_NR_CLKS] = NULL,
}, },
.num = CLK_NR_CLKS, .num = CLK_NR_CLKS,
...@@ -939,6 +983,9 @@ static struct clk_regmap *const meson8b_clk_regmaps[] = { ...@@ -939,6 +983,9 @@ static struct clk_regmap *const meson8b_clk_regmaps[] = {
&meson8b_fclk_div4, &meson8b_fclk_div4,
&meson8b_fclk_div5, &meson8b_fclk_div5,
&meson8b_fclk_div7, &meson8b_fclk_div7,
&meson8b_nand_clk_sel,
&meson8b_nand_clk_div,
&meson8b_nand_clk_gate,
}; };
static const struct meson8b_clk_reset_line { static const struct meson8b_clk_reset_line {
......
/* SPDX-License-Identifier: GPL-2.0 */
/* /*
* Copyright (c) 2015 Endless Mobile, Inc. * Copyright (c) 2015 Endless Mobile, Inc.
* Author: Carlo Caione <carlo@endlessm.com> * Author: Carlo Caione <carlo@endlessm.com>
* *
* Copyright (c) 2016 BayLibre, Inc. * Copyright (c) 2016 BayLibre, Inc.
* Michael Turquette <mturquette@baylibre.com> * Michael Turquette <mturquette@baylibre.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __MESON8B_H #ifndef __MESON8B_H
...@@ -40,6 +29,7 @@ ...@@ -40,6 +29,7 @@
#define HHI_VID_CLK_CNTL 0x17c /* 0x5f offset in data sheet */ #define HHI_VID_CLK_CNTL 0x17c /* 0x5f offset in data sheet */
#define HHI_VID_DIVIDER_CNTL 0x198 /* 0x66 offset in data sheet */ #define HHI_VID_DIVIDER_CNTL 0x198 /* 0x66 offset in data sheet */
#define HHI_SYS_CPU_CLK_CNTL0 0x19c /* 0x67 offset in data sheet */ #define HHI_SYS_CPU_CLK_CNTL0 0x19c /* 0x67 offset in data sheet */
#define HHI_NAND_CLK_CNTL 0x25c /* 0x97 offset in data sheet */
#define HHI_MPLL_CNTL 0x280 /* 0xa0 offset in data sheet */ #define HHI_MPLL_CNTL 0x280 /* 0xa0 offset in data sheet */
#define HHI_SYS_PLL_CNTL 0x300 /* 0xc0 offset in data sheet */ #define HHI_SYS_PLL_CNTL 0x300 /* 0xc0 offset in data sheet */
#define HHI_VID_PLL_CNTL 0x320 /* 0xc8 offset in data sheet */ #define HHI_VID_PLL_CNTL 0x320 /* 0xc8 offset in data sheet */
...@@ -83,8 +73,10 @@ ...@@ -83,8 +73,10 @@
#define CLKID_FCLK_DIV4_DIV 107 #define CLKID_FCLK_DIV4_DIV 107
#define CLKID_FCLK_DIV5_DIV 108 #define CLKID_FCLK_DIV5_DIV 108
#define CLKID_FCLK_DIV7_DIV 109 #define CLKID_FCLK_DIV7_DIV 109
#define CLKID_NAND_SEL 110
#define CLKID_NAND_DIV 111
#define CLK_NR_CLKS 110 #define CLK_NR_CLKS 113
/* /*
* include the CLKID and RESETID that have * include the CLKID and RESETID that have
......
...@@ -7,6 +7,7 @@ config CLK_RENESAS ...@@ -7,6 +7,7 @@ config CLK_RENESAS
select CLK_R8A7740 if ARCH_R8A7740 select CLK_R8A7740 if ARCH_R8A7740
select CLK_R8A7743 if ARCH_R8A7743 select CLK_R8A7743 if ARCH_R8A7743
select CLK_R8A7745 if ARCH_R8A7745 select CLK_R8A7745 if ARCH_R8A7745
select CLK_R8A77470 if ARCH_R8A77470
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
...@@ -18,6 +19,7 @@ config CLK_RENESAS ...@@ -18,6 +19,7 @@ config CLK_RENESAS
select CLK_R8A77965 if ARCH_R8A77965 select CLK_R8A77965 if ARCH_R8A77965
select CLK_R8A77970 if ARCH_R8A77970 select CLK_R8A77970 if ARCH_R8A77970
select CLK_R8A77980 if ARCH_R8A77980 select CLK_R8A77980 if ARCH_R8A77980
select CLK_R8A77990 if ARCH_R8A77990
select CLK_R8A77995 if ARCH_R8A77995 select CLK_R8A77995 if ARCH_R8A77995
select CLK_SH73A0 if ARCH_SH73A0 select CLK_SH73A0 if ARCH_SH73A0
...@@ -60,6 +62,10 @@ config CLK_R8A7745 ...@@ -60,6 +62,10 @@ config CLK_R8A7745
bool "RZ/G1E clock support" if COMPILE_TEST bool "RZ/G1E clock support" if COMPILE_TEST
select CLK_RCAR_GEN2_CPG select CLK_RCAR_GEN2_CPG
config CLK_R8A77470
bool "RZ/G1C clock support" if COMPILE_TEST
select CLK_RCAR_GEN2_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
...@@ -111,6 +117,10 @@ config CLK_R8A77980 ...@@ -111,6 +117,10 @@ config CLK_R8A77980
bool "R-Car V3H clock support" if COMPILE_TEST bool "R-Car V3H clock support" if COMPILE_TEST
select CLK_RCAR_GEN3_CPG select CLK_RCAR_GEN3_CPG
config CLK_R8A77990
bool "R-Car E3 clock support" if COMPILE_TEST
select CLK_RCAR_GEN3_CPG
config CLK_R8A77995 config CLK_R8A77995
bool "R-Car D3 clock support" if COMPILE_TEST bool "R-Car D3 clock support" if COMPILE_TEST
select CLK_RCAR_GEN3_CPG select CLK_RCAR_GEN3_CPG
......
...@@ -6,6 +6,7 @@ obj-$(CONFIG_CLK_R8A73A4) += clk-r8a73a4.o ...@@ -6,6 +6,7 @@ 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_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
...@@ -17,6 +18,7 @@ obj-$(CONFIG_CLK_R8A7796) += r8a7796-cpg-mssr.o ...@@ -17,6 +18,7 @@ obj-$(CONFIG_CLK_R8A7796) += r8a7796-cpg-mssr.o
obj-$(CONFIG_CLK_R8A77965) += r8a77965-cpg-mssr.o obj-$(CONFIG_CLK_R8A77965) += r8a77965-cpg-mssr.o
obj-$(CONFIG_CLK_R8A77970) += r8a77970-cpg-mssr.o obj-$(CONFIG_CLK_R8A77970) += r8a77970-cpg-mssr.o
obj-$(CONFIG_CLK_R8A77980) += r8a77980-cpg-mssr.o obj-$(CONFIG_CLK_R8A77980) += r8a77980-cpg-mssr.o
obj-$(CONFIG_CLK_R8A77990) += r8a77990-cpg-mssr.o
obj-$(CONFIG_CLK_R8A77995) += r8a77995-cpg-mssr.o obj-$(CONFIG_CLK_R8A77995) += r8a77995-cpg-mssr.o
obj-$(CONFIG_CLK_SH73A0) += clk-sh73a0.o obj-$(CONFIG_CLK_SH73A0) += clk-sh73a0.o
......
...@@ -52,7 +52,6 @@ static const struct cpg_core_clk r8a7743_core_clks[] __initconst = { ...@@ -52,7 +52,6 @@ static const struct cpg_core_clk r8a7743_core_clks[] __initconst = {
/* Core Clock Outputs */ /* Core Clock Outputs */
DEF_BASE("z", R8A7743_CLK_Z, CLK_TYPE_GEN2_Z, CLK_PLL0), DEF_BASE("z", R8A7743_CLK_Z, CLK_TYPE_GEN2_Z, CLK_PLL0),
DEF_BASE("lb", R8A7743_CLK_LB, CLK_TYPE_GEN2_LB, CLK_PLL1),
DEF_BASE("sdh", R8A7743_CLK_SDH, CLK_TYPE_GEN2_SDH, CLK_PLL1), DEF_BASE("sdh", R8A7743_CLK_SDH, CLK_TYPE_GEN2_SDH, CLK_PLL1),
DEF_BASE("sd0", R8A7743_CLK_SD0, CLK_TYPE_GEN2_SD0, CLK_PLL1), DEF_BASE("sd0", R8A7743_CLK_SD0, CLK_TYPE_GEN2_SD0, CLK_PLL1),
DEF_BASE("qspi", R8A7743_CLK_QSPI, CLK_TYPE_GEN2_QSPI, CLK_PLL1_DIV2), DEF_BASE("qspi", R8A7743_CLK_QSPI, CLK_TYPE_GEN2_QSPI, CLK_PLL1_DIV2),
...@@ -63,6 +62,7 @@ static const struct cpg_core_clk r8a7743_core_clks[] __initconst = { ...@@ -63,6 +62,7 @@ static const struct cpg_core_clk r8a7743_core_clks[] __initconst = {
DEF_FIXED("zs", R8A7743_CLK_ZS, CLK_PLL1, 6, 1), DEF_FIXED("zs", R8A7743_CLK_ZS, CLK_PLL1, 6, 1),
DEF_FIXED("hp", R8A7743_CLK_HP, CLK_PLL1, 12, 1), DEF_FIXED("hp", R8A7743_CLK_HP, CLK_PLL1, 12, 1),
DEF_FIXED("b", R8A7743_CLK_B, CLK_PLL1, 12, 1), DEF_FIXED("b", R8A7743_CLK_B, CLK_PLL1, 12, 1),
DEF_FIXED("lb", R8A7743_CLK_LB, CLK_PLL1, 24, 1),
DEF_FIXED("p", R8A7743_CLK_P, CLK_PLL1, 24, 1), DEF_FIXED("p", R8A7743_CLK_P, CLK_PLL1, 24, 1),
DEF_FIXED("cl", R8A7743_CLK_CL, CLK_PLL1, 48, 1), DEF_FIXED("cl", R8A7743_CLK_CL, CLK_PLL1, 48, 1),
DEF_FIXED("m2", R8A7743_CLK_M2, CLK_PLL1, 8, 1), DEF_FIXED("m2", R8A7743_CLK_M2, CLK_PLL1, 8, 1),
......
...@@ -51,7 +51,6 @@ static const struct cpg_core_clk r8a7745_core_clks[] __initconst = { ...@@ -51,7 +51,6 @@ static const struct cpg_core_clk r8a7745_core_clks[] __initconst = {
DEF_FIXED(".pll1_div2", CLK_PLL1_DIV2, CLK_PLL1, 2, 1), DEF_FIXED(".pll1_div2", CLK_PLL1_DIV2, CLK_PLL1, 2, 1),
/* Core Clock Outputs */ /* Core Clock Outputs */
DEF_BASE("lb", R8A7745_CLK_LB, CLK_TYPE_GEN2_LB, CLK_PLL1),
DEF_BASE("sdh", R8A7745_CLK_SDH, CLK_TYPE_GEN2_SDH, CLK_PLL1), DEF_BASE("sdh", R8A7745_CLK_SDH, CLK_TYPE_GEN2_SDH, CLK_PLL1),
DEF_BASE("sd0", R8A7745_CLK_SD0, CLK_TYPE_GEN2_SD0, CLK_PLL1), DEF_BASE("sd0", R8A7745_CLK_SD0, CLK_TYPE_GEN2_SD0, CLK_PLL1),
DEF_BASE("qspi", R8A7745_CLK_QSPI, CLK_TYPE_GEN2_QSPI, CLK_PLL1_DIV2), DEF_BASE("qspi", R8A7745_CLK_QSPI, CLK_TYPE_GEN2_QSPI, CLK_PLL1_DIV2),
...@@ -63,6 +62,7 @@ static const struct cpg_core_clk r8a7745_core_clks[] __initconst = { ...@@ -63,6 +62,7 @@ static const struct cpg_core_clk r8a7745_core_clks[] __initconst = {
DEF_FIXED("zs", R8A7745_CLK_ZS, CLK_PLL1, 6, 1), DEF_FIXED("zs", R8A7745_CLK_ZS, CLK_PLL1, 6, 1),
DEF_FIXED("hp", R8A7745_CLK_HP, CLK_PLL1, 12, 1), DEF_FIXED("hp", R8A7745_CLK_HP, CLK_PLL1, 12, 1),
DEF_FIXED("b", R8A7745_CLK_B, CLK_PLL1, 12, 1), DEF_FIXED("b", R8A7745_CLK_B, CLK_PLL1, 12, 1),
DEF_FIXED("lb", R8A7745_CLK_LB, CLK_PLL1, 24, 1),
DEF_FIXED("p", R8A7745_CLK_P, CLK_PLL1, 24, 1), DEF_FIXED("p", R8A7745_CLK_P, CLK_PLL1, 24, 1),
DEF_FIXED("cl", R8A7745_CLK_CL, CLK_PLL1, 48, 1), DEF_FIXED("cl", R8A7745_CLK_CL, CLK_PLL1, 48, 1),
DEF_FIXED("cp", R8A7745_CLK_CP, CLK_PLL1, 48, 1), DEF_FIXED("cp", R8A7745_CLK_CP, CLK_PLL1, 48, 1),
......
// SPDX-License-Identifier: GPL-2.0
/*
* r8a77470 Clock Pulse Generator / Module Standby and Software Reset
*
* Copyright (C) 2018 Renesas Electronics Corp.
*/
#include <linux/device.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/soc/renesas/rcar-rst.h>
#include <dt-bindings/clock/r8a77470-cpg-mssr.h>
#include "renesas-cpg-mssr.h"
#include "rcar-gen2-cpg.h"
enum clk_ids {
/* Core Clock Outputs exported to DT */
LAST_DT_CORE_CLK = R8A77470_CLK_OSC,
/* External Input Clocks */
CLK_EXTAL,
CLK_USB_EXTAL,
/* Internal Core Clocks */
CLK_MAIN,
CLK_PLL0,
CLK_PLL1,
CLK_PLL3,
CLK_PLL1_DIV2,
/* Module Clocks */
MOD_CLK_BASE
};
static const struct cpg_core_clk r8a77470_core_clks[] __initconst = {
/* External Clock Inputs */
DEF_INPUT("extal", CLK_EXTAL),
DEF_INPUT("usb_extal", CLK_USB_EXTAL),
/* Internal Core Clocks */
DEF_BASE(".main", CLK_MAIN, CLK_TYPE_GEN2_MAIN, CLK_EXTAL),
DEF_BASE(".pll0", CLK_PLL0, CLK_TYPE_GEN2_PLL0, CLK_MAIN),
DEF_BASE(".pll1", CLK_PLL1, CLK_TYPE_GEN2_PLL1, CLK_MAIN),
DEF_BASE(".pll3", CLK_PLL3, CLK_TYPE_GEN2_PLL3, CLK_MAIN),
DEF_FIXED(".pll1_div2", CLK_PLL1_DIV2, CLK_PLL1, 2, 1),
/* Core Clock Outputs */
DEF_BASE("sdh", R8A77470_CLK_SDH, CLK_TYPE_GEN2_SDH, CLK_PLL1),
DEF_BASE("sd0", R8A77470_CLK_SD0, CLK_TYPE_GEN2_SD0, CLK_PLL1),
DEF_BASE("sd1", R8A77470_CLK_SD1, CLK_TYPE_GEN2_SD1, CLK_PLL1),
DEF_BASE("qspi", R8A77470_CLK_QSPI, CLK_TYPE_GEN2_QSPI, CLK_PLL1_DIV2),
DEF_BASE("rcan", R8A77470_CLK_RCAN, CLK_TYPE_GEN2_RCAN, CLK_USB_EXTAL),
DEF_FIXED("z2", R8A77470_CLK_Z2, CLK_PLL0, 1, 1),
DEF_FIXED("zx", R8A77470_CLK_ZX, CLK_PLL1, 3, 1),
DEF_FIXED("zs", R8A77470_CLK_ZS, CLK_PLL1, 6, 1),
DEF_FIXED("hp", R8A77470_CLK_HP, CLK_PLL1, 12, 1),
DEF_FIXED("b", R8A77470_CLK_B, CLK_PLL1, 12, 1),
DEF_FIXED("lb", R8A77470_CLK_LB, CLK_PLL1, 24, 1),
DEF_FIXED("p", R8A77470_CLK_P, CLK_PLL1, 24, 1),
DEF_FIXED("cl", R8A77470_CLK_CL, CLK_PLL1, 48, 1),
DEF_FIXED("cp", R8A77470_CLK_CP, CLK_PLL1, 48, 1),
DEF_FIXED("m2", R8A77470_CLK_M2, CLK_PLL1, 8, 1),
DEF_FIXED("zb3", R8A77470_CLK_ZB3, CLK_PLL3, 4, 1),
DEF_FIXED("mp", R8A77470_CLK_MP, CLK_PLL1_DIV2, 15, 1),
DEF_FIXED("cpex", R8A77470_CLK_CPEX, CLK_EXTAL, 2, 1),
DEF_FIXED("r", R8A77470_CLK_R, CLK_PLL1, 49152, 1),
DEF_FIXED("osc", R8A77470_CLK_OSC, CLK_PLL1, 12288, 1),
DEF_DIV6P1("sd2", R8A77470_CLK_SD2, CLK_PLL1_DIV2, 0x078),
};
static const struct mssr_mod_clk r8a77470_mod_clks[] __initconst = {
DEF_MOD("msiof0", 0, R8A77470_CLK_MP),
DEF_MOD("vcp0", 101, R8A77470_CLK_ZS),
DEF_MOD("vpc0", 103, R8A77470_CLK_ZS),
DEF_MOD("tmu1", 111, R8A77470_CLK_P),
DEF_MOD("3dg", 112, R8A77470_CLK_ZS),
DEF_MOD("2d-dmac", 115, R8A77470_CLK_ZS),
DEF_MOD("fdp1-0", 119, R8A77470_CLK_ZS),
DEF_MOD("tmu3", 121, R8A77470_CLK_P),
DEF_MOD("tmu2", 122, R8A77470_CLK_P),
DEF_MOD("cmt0", 124, R8A77470_CLK_R),
DEF_MOD("vsp1du0", 128, R8A77470_CLK_ZS),
DEF_MOD("vsp1-sy", 131, R8A77470_CLK_ZS),
DEF_MOD("msiof2", 205, R8A77470_CLK_MP),
DEF_MOD("msiof1", 208, R8A77470_CLK_MP),
DEF_MOD("sys-dmac1", 218, R8A77470_CLK_ZS),
DEF_MOD("sys-dmac0", 219, R8A77470_CLK_ZS),
DEF_MOD("sdhi2", 312, R8A77470_CLK_SD2),
DEF_MOD("sdhi1", 313, R8A77470_CLK_SD1),
DEF_MOD("sdhi0", 314, R8A77470_CLK_SD0),
DEF_MOD("usbhs-dmac0-ch1", 326, R8A77470_CLK_HP),
DEF_MOD("usbhs-dmac1-ch1", 327, R8A77470_CLK_HP),
DEF_MOD("cmt1", 329, R8A77470_CLK_R),
DEF_MOD("usbhs-dmac0-ch0", 330, R8A77470_CLK_HP),
DEF_MOD("usbhs-dmac1-ch0", 331, R8A77470_CLK_HP),
DEF_MOD("rwdt", 402, R8A77470_CLK_R),
DEF_MOD("irqc", 407, R8A77470_CLK_CP),
DEF_MOD("intc-sys", 408, R8A77470_CLK_ZS),
DEF_MOD("audio-dmac0", 502, R8A77470_CLK_HP),
DEF_MOD("pwm", 523, R8A77470_CLK_P),
DEF_MOD("usb-ehci-0", 703, R8A77470_CLK_MP),
DEF_MOD("usbhs-0", 704, R8A77470_CLK_HP),
DEF_MOD("usb-ehci-1", 705, R8A77470_CLK_MP),
DEF_MOD("usbhs-1", 706, R8A77470_CLK_HP),
DEF_MOD("hscif2", 713, R8A77470_CLK_ZS),
DEF_MOD("scif5", 714, R8A77470_CLK_P),
DEF_MOD("scif4", 715, R8A77470_CLK_P),
DEF_MOD("hscif1", 716, R8A77470_CLK_ZS),
DEF_MOD("hscif0", 717, R8A77470_CLK_ZS),
DEF_MOD("scif3", 718, R8A77470_CLK_P),
DEF_MOD("scif2", 719, R8A77470_CLK_P),
DEF_MOD("scif1", 720, R8A77470_CLK_P),
DEF_MOD("scif0", 721, R8A77470_CLK_P),
DEF_MOD("du1", 723, R8A77470_CLK_ZX),
DEF_MOD("du0", 724, R8A77470_CLK_ZX),
DEF_MOD("ipmmu-sgx", 800, R8A77470_CLK_ZX),
DEF_MOD("etheravb", 812, R8A77470_CLK_HP),
DEF_MOD("ether", 813, R8A77470_CLK_P),
DEF_MOD("gpio5", 907, R8A77470_CLK_CP),
DEF_MOD("gpio4", 908, R8A77470_CLK_CP),
DEF_MOD("gpio3", 909, R8A77470_CLK_CP),
DEF_MOD("gpio2", 910, R8A77470_CLK_CP),
DEF_MOD("gpio1", 911, R8A77470_CLK_CP),
DEF_MOD("gpio0", 912, R8A77470_CLK_CP),
DEF_MOD("can1", 915, R8A77470_CLK_P),
DEF_MOD("can0", 916, R8A77470_CLK_P),
DEF_MOD("qspi_mod-1", 917, R8A77470_CLK_QSPI),
DEF_MOD("qspi_mod-0", 918, R8A77470_CLK_QSPI),
DEF_MOD("i2c4", 927, R8A77470_CLK_HP),
DEF_MOD("i2c3", 928, R8A77470_CLK_HP),
DEF_MOD("i2c2", 929, R8A77470_CLK_HP),
DEF_MOD("i2c1", 930, R8A77470_CLK_HP),
DEF_MOD("i2c0", 931, R8A77470_CLK_HP),
DEF_MOD("ssi-all", 1005, R8A77470_CLK_P),
DEF_MOD("ssi9", 1006, MOD_CLK_ID(1005)),
DEF_MOD("ssi8", 1007, MOD_CLK_ID(1005)),
DEF_MOD("ssi7", 1008, MOD_CLK_ID(1005)),
DEF_MOD("ssi6", 1009, MOD_CLK_ID(1005)),
DEF_MOD("ssi5", 1010, MOD_CLK_ID(1005)),
DEF_MOD("ssi4", 1011, MOD_CLK_ID(1005)),
DEF_MOD("ssi3", 1012, MOD_CLK_ID(1005)),
DEF_MOD("ssi2", 1013, MOD_CLK_ID(1005)),
DEF_MOD("ssi1", 1014, MOD_CLK_ID(1005)),
DEF_MOD("ssi0", 1015, MOD_CLK_ID(1005)),
DEF_MOD("scu-all", 1017, R8A77470_CLK_P),
DEF_MOD("scu-dvc1", 1018, MOD_CLK_ID(1017)),
DEF_MOD("scu-dvc0", 1019, MOD_CLK_ID(1017)),
DEF_MOD("scu-ctu1-mix1", 1020, MOD_CLK_ID(1017)),
DEF_MOD("scu-ctu0-mix0", 1021, MOD_CLK_ID(1017)),
DEF_MOD("scu-src6", 1025, MOD_CLK_ID(1017)),
DEF_MOD("scu-src5", 1026, MOD_CLK_ID(1017)),
DEF_MOD("scu-src4", 1027, MOD_CLK_ID(1017)),
DEF_MOD("scu-src3", 1028, MOD_CLK_ID(1017)),
DEF_MOD("scu-src2", 1029, MOD_CLK_ID(1017)),
DEF_MOD("scu-src1", 1030, MOD_CLK_ID(1017)),
};
static const unsigned int r8a77470_crit_mod_clks[] __initconst = {
MOD_CLK_ID(402), /* RWDT */
MOD_CLK_ID(408), /* INTC-SYS (GIC) */
};
/*
* CPG Clock Data
*/
/*
* MD EXTAL PLL0 PLL1 PLL3
* 14 13 (MHz) *1 *2
*---------------------------------------------------
* 0 0 20 x80 x78 x50
* 0 1 26 x60 x60 x56
* 1 0 Prohibitted setting
* 1 1 30 x52 x52 x50
*
* *1 : Table 7.4 indicates VCO output (PLL0 = VCO)
* *2 : Table 7.4 indicates VCO output (PLL1 = VCO)
*/
#define CPG_PLL_CONFIG_INDEX(md) ((((md) & BIT(14)) >> 13) | \
(((md) & BIT(13)) >> 13))
static const struct rcar_gen2_cpg_pll_config cpg_pll_configs[4] __initconst = {
/* EXTAL div PLL1 mult x2 PLL3 mult */
{ 1, 156, 50, },
{ 1, 120, 56, },
{ /* Invalid*/ },
{ 1, 104, 50, },
};
static int __init r8a77470_cpg_mssr_init(struct device *dev)
{
const struct rcar_gen2_cpg_pll_config *cpg_pll_config;
u32 cpg_mode;
int error;
error = rcar_rst_read_mode_pins(&cpg_mode);
if (error)
return error;
cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)];
return rcar_gen2_cpg_init(cpg_pll_config, 2, cpg_mode);
}
const struct cpg_mssr_info r8a77470_cpg_mssr_info __initconst = {
/* Core Clocks */
.core_clks = r8a77470_core_clks,
.num_core_clks = ARRAY_SIZE(r8a77470_core_clks),
.last_dt_core_clk = LAST_DT_CORE_CLK,
.num_total_core_clks = MOD_CLK_BASE,
/* Module Clocks */
.mod_clks = r8a77470_mod_clks,
.num_mod_clks = ARRAY_SIZE(r8a77470_mod_clks),
.num_hw_mod_clks = 12 * 32,
/* Critical Module Clocks */
.crit_mod_clks = r8a77470_crit_mod_clks,
.num_crit_mod_clks = ARRAY_SIZE(r8a77470_crit_mod_clks),
/* Callbacks */
.init = r8a77470_cpg_mssr_init,
.cpg_clk_register = rcar_gen2_cpg_clk_register,
};
...@@ -57,7 +57,6 @@ static struct cpg_core_clk r8a7791_core_clks[] __initdata = { ...@@ -57,7 +57,6 @@ static struct cpg_core_clk r8a7791_core_clks[] __initdata = {
/* Core Clock Outputs */ /* Core Clock Outputs */
DEF_BASE("z", R8A7791_CLK_Z, CLK_TYPE_GEN2_Z, CLK_PLL0), DEF_BASE("z", R8A7791_CLK_Z, CLK_TYPE_GEN2_Z, CLK_PLL0),
DEF_BASE("lb", R8A7791_CLK_LB, CLK_TYPE_GEN2_LB, CLK_PLL1),
DEF_BASE("adsp", R8A7791_CLK_ADSP, CLK_TYPE_GEN2_ADSP, CLK_PLL1), DEF_BASE("adsp", R8A7791_CLK_ADSP, CLK_TYPE_GEN2_ADSP, CLK_PLL1),
DEF_BASE("sdh", R8A7791_CLK_SDH, CLK_TYPE_GEN2_SDH, CLK_PLL1), DEF_BASE("sdh", R8A7791_CLK_SDH, CLK_TYPE_GEN2_SDH, CLK_PLL1),
DEF_BASE("sd0", R8A7791_CLK_SD0, CLK_TYPE_GEN2_SD0, CLK_PLL1), DEF_BASE("sd0", R8A7791_CLK_SD0, CLK_TYPE_GEN2_SD0, CLK_PLL1),
...@@ -70,6 +69,7 @@ static struct cpg_core_clk r8a7791_core_clks[] __initdata = { ...@@ -70,6 +69,7 @@ static struct cpg_core_clk r8a7791_core_clks[] __initdata = {
DEF_FIXED("hp", R8A7791_CLK_HP, CLK_PLL1, 12, 1), DEF_FIXED("hp", R8A7791_CLK_HP, CLK_PLL1, 12, 1),
DEF_FIXED("i", R8A7791_CLK_I, CLK_PLL1, 2, 1), DEF_FIXED("i", R8A7791_CLK_I, CLK_PLL1, 2, 1),
DEF_FIXED("b", R8A7791_CLK_B, CLK_PLL1, 12, 1), DEF_FIXED("b", R8A7791_CLK_B, CLK_PLL1, 12, 1),
DEF_FIXED("lb", R8A7791_CLK_LB, CLK_PLL1, 24, 1),
DEF_FIXED("p", R8A7791_CLK_P, CLK_PLL1, 24, 1), DEF_FIXED("p", R8A7791_CLK_P, CLK_PLL1, 24, 1),
DEF_FIXED("cl", R8A7791_CLK_CL, CLK_PLL1, 48, 1), DEF_FIXED("cl", R8A7791_CLK_CL, CLK_PLL1, 48, 1),
DEF_FIXED("m2", R8A7791_CLK_M2, CLK_PLL1, 8, 1), DEF_FIXED("m2", R8A7791_CLK_M2, CLK_PLL1, 8, 1),
......
...@@ -53,7 +53,6 @@ static const struct cpg_core_clk r8a7792_core_clks[] __initconst = { ...@@ -53,7 +53,6 @@ static const struct cpg_core_clk r8a7792_core_clks[] __initconst = {
DEF_FIXED(".pll1_div2", CLK_PLL1_DIV2, CLK_PLL1, 2, 1), DEF_FIXED(".pll1_div2", CLK_PLL1_DIV2, CLK_PLL1, 2, 1),
/* Core Clock Outputs */ /* Core Clock Outputs */
DEF_BASE("lb", R8A7792_CLK_LB, CLK_TYPE_GEN2_LB, CLK_PLL1),
DEF_BASE("qspi", R8A7792_CLK_QSPI, CLK_TYPE_GEN2_QSPI, CLK_PLL1_DIV2), DEF_BASE("qspi", R8A7792_CLK_QSPI, CLK_TYPE_GEN2_QSPI, CLK_PLL1_DIV2),
DEF_FIXED("z", R8A7792_CLK_Z, CLK_PLL0, 1, 1), DEF_FIXED("z", R8A7792_CLK_Z, CLK_PLL0, 1, 1),
...@@ -63,6 +62,7 @@ static const struct cpg_core_clk r8a7792_core_clks[] __initconst = { ...@@ -63,6 +62,7 @@ static const struct cpg_core_clk r8a7792_core_clks[] __initconst = {
DEF_FIXED("hp", R8A7792_CLK_HP, CLK_PLL1, 12, 1), DEF_FIXED("hp", R8A7792_CLK_HP, CLK_PLL1, 12, 1),
DEF_FIXED("i", R8A7792_CLK_I, CLK_PLL1, 3, 1), DEF_FIXED("i", R8A7792_CLK_I, CLK_PLL1, 3, 1),
DEF_FIXED("b", R8A7792_CLK_B, CLK_PLL1, 12, 1), DEF_FIXED("b", R8A7792_CLK_B, CLK_PLL1, 12, 1),
DEF_FIXED("lb", R8A7792_CLK_LB, CLK_PLL1, 24, 1),
DEF_FIXED("p", R8A7792_CLK_P, CLK_PLL1, 24, 1), DEF_FIXED("p", R8A7792_CLK_P, CLK_PLL1, 24, 1),
DEF_FIXED("cl", R8A7792_CLK_CL, CLK_PLL1, 48, 1), DEF_FIXED("cl", R8A7792_CLK_CL, CLK_PLL1, 48, 1),
DEF_FIXED("m2", R8A7792_CLK_M2, CLK_PLL1, 8, 1), DEF_FIXED("m2", R8A7792_CLK_M2, CLK_PLL1, 8, 1),
......
...@@ -55,7 +55,6 @@ static const struct cpg_core_clk r8a7794_core_clks[] __initconst = { ...@@ -55,7 +55,6 @@ static const struct cpg_core_clk r8a7794_core_clks[] __initconst = {
DEF_FIXED(".pll1_div2", CLK_PLL1_DIV2, CLK_PLL1, 2, 1), DEF_FIXED(".pll1_div2", CLK_PLL1_DIV2, CLK_PLL1, 2, 1),
/* Core Clock Outputs */ /* Core Clock Outputs */
DEF_BASE("lb", R8A7794_CLK_LB, CLK_TYPE_GEN2_LB, CLK_PLL1),
DEF_BASE("adsp", R8A7794_CLK_ADSP, CLK_TYPE_GEN2_ADSP, CLK_PLL1), DEF_BASE("adsp", R8A7794_CLK_ADSP, CLK_TYPE_GEN2_ADSP, CLK_PLL1),
DEF_BASE("sdh", R8A7794_CLK_SDH, CLK_TYPE_GEN2_SDH, CLK_PLL1), DEF_BASE("sdh", R8A7794_CLK_SDH, CLK_TYPE_GEN2_SDH, CLK_PLL1),
DEF_BASE("sd0", R8A7794_CLK_SD0, CLK_TYPE_GEN2_SD0, CLK_PLL1), DEF_BASE("sd0", R8A7794_CLK_SD0, CLK_TYPE_GEN2_SD0, CLK_PLL1),
...@@ -69,6 +68,7 @@ static const struct cpg_core_clk r8a7794_core_clks[] __initconst = { ...@@ -69,6 +68,7 @@ static const struct cpg_core_clk r8a7794_core_clks[] __initconst = {
DEF_FIXED("hp", R8A7794_CLK_HP, CLK_PLL1, 12, 1), DEF_FIXED("hp", R8A7794_CLK_HP, CLK_PLL1, 12, 1),
DEF_FIXED("i", R8A7794_CLK_I, CLK_PLL1, 2, 1), DEF_FIXED("i", R8A7794_CLK_I, CLK_PLL1, 2, 1),
DEF_FIXED("b", R8A7794_CLK_B, CLK_PLL1, 12, 1), DEF_FIXED("b", R8A7794_CLK_B, CLK_PLL1, 12, 1),
DEF_FIXED("lb", R8A7794_CLK_LB, CLK_PLL1, 24, 1),
DEF_FIXED("p", R8A7794_CLK_P, CLK_PLL1, 24, 1), DEF_FIXED("p", R8A7794_CLK_P, CLK_PLL1, 24, 1),
DEF_FIXED("cl", R8A7794_CLK_CL, CLK_PLL1, 48, 1), DEF_FIXED("cl", R8A7794_CLK_CL, CLK_PLL1, 48, 1),
DEF_FIXED("cp", R8A7794_CLK_CP, CLK_PLL1, 48, 1), DEF_FIXED("cp", R8A7794_CLK_CP, CLK_PLL1, 48, 1),
......
...@@ -116,6 +116,10 @@ static const struct mssr_mod_clk r8a77965_mod_clks[] __initconst = { ...@@ -116,6 +116,10 @@ static const struct mssr_mod_clk r8a77965_mod_clks[] __initconst = {
DEF_MOD("scif3", 204, R8A77965_CLK_S3D4), DEF_MOD("scif3", 204, R8A77965_CLK_S3D4),
DEF_MOD("scif1", 206, R8A77965_CLK_S3D4), DEF_MOD("scif1", 206, R8A77965_CLK_S3D4),
DEF_MOD("scif0", 207, R8A77965_CLK_S3D4), DEF_MOD("scif0", 207, R8A77965_CLK_S3D4),
DEF_MOD("msiof3", 208, R8A77965_CLK_MSO),
DEF_MOD("msiof2", 209, R8A77965_CLK_MSO),
DEF_MOD("msiof1", 210, R8A77965_CLK_MSO),
DEF_MOD("msiof0", 211, R8A77965_CLK_MSO),
DEF_MOD("sys-dmac2", 217, R8A77965_CLK_S0D3), DEF_MOD("sys-dmac2", 217, R8A77965_CLK_S0D3),
DEF_MOD("sys-dmac1", 218, R8A77965_CLK_S0D3), DEF_MOD("sys-dmac1", 218, R8A77965_CLK_S0D3),
DEF_MOD("sys-dmac0", 219, R8A77965_CLK_S0D3), DEF_MOD("sys-dmac0", 219, R8A77965_CLK_S0D3),
......
...@@ -116,7 +116,7 @@ static const struct mssr_mod_clk r8a77980_mod_clks[] __initconst = { ...@@ -116,7 +116,7 @@ static const struct mssr_mod_clk r8a77980_mod_clks[] __initconst = {
DEF_MOD("sys-dmac1", 218, R8A77980_CLK_S0D3), DEF_MOD("sys-dmac1", 218, R8A77980_CLK_S0D3),
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_S3D1), DEF_MOD("pciec0", 319, R8A77980_CLK_S2D2),
DEF_MOD("intc-ex", 407, R8A77980_CLK_CP), DEF_MOD("intc-ex", 407, R8A77980_CLK_CP),
DEF_MOD("intc-ap", 408, R8A77980_CLK_S0D3), DEF_MOD("intc-ap", 408, R8A77980_CLK_S0D3),
DEF_MOD("hscif3", 517, R8A77980_CLK_S3D1), DEF_MOD("hscif3", 517, R8A77980_CLK_S3D1),
......
This diff is collapsed.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/sys_soc.h>
#include "renesas-cpg-mssr.h" #include "renesas-cpg-mssr.h"
#include "rcar-gen2-cpg.h" #include "rcar-gen2-cpg.h"
...@@ -260,6 +261,17 @@ static const struct clk_div_table cpg_sd01_div_table[] = { ...@@ -260,6 +261,17 @@ static const struct clk_div_table cpg_sd01_div_table[] = {
static const struct rcar_gen2_cpg_pll_config *cpg_pll_config __initdata; static const struct rcar_gen2_cpg_pll_config *cpg_pll_config __initdata;
static unsigned int cpg_pll0_div __initdata; static unsigned int cpg_pll0_div __initdata;
static u32 cpg_mode __initdata; static u32 cpg_mode __initdata;
static u32 cpg_quirks __initdata;
#define SD_SKIP_FIRST BIT(0) /* Skip first clock in SD table */
static const struct soc_device_attribute cpg_quirks_match[] __initconst = {
{
.soc_id = "r8a77470",
.data = (void *)SD_SKIP_FIRST,
},
{ /* sentinel */ }
};
struct clk * __init rcar_gen2_cpg_clk_register(struct device *dev, struct clk * __init rcar_gen2_cpg_clk_register(struct device *dev,
const struct cpg_core_clk *core, const struct cpg_mssr_info *info, const struct cpg_core_clk *core, const struct cpg_mssr_info *info,
...@@ -327,11 +339,17 @@ struct clk * __init rcar_gen2_cpg_clk_register(struct device *dev, ...@@ -327,11 +339,17 @@ struct clk * __init rcar_gen2_cpg_clk_register(struct device *dev,
case CLK_TYPE_GEN2_SD0: case CLK_TYPE_GEN2_SD0:
table = cpg_sd01_div_table; table = cpg_sd01_div_table;
if (cpg_quirks & SD_SKIP_FIRST)
table++;
shift = 4; shift = 4;
break; break;
case CLK_TYPE_GEN2_SD1: case CLK_TYPE_GEN2_SD1:
table = cpg_sd01_div_table; table = cpg_sd01_div_table;
if (cpg_quirks & SD_SKIP_FIRST)
table++;
shift = 0; shift = 0;
break; break;
...@@ -360,9 +378,15 @@ struct clk * __init rcar_gen2_cpg_clk_register(struct device *dev, ...@@ -360,9 +378,15 @@ struct clk * __init rcar_gen2_cpg_clk_register(struct device *dev,
int __init rcar_gen2_cpg_init(const struct rcar_gen2_cpg_pll_config *config, int __init rcar_gen2_cpg_init(const struct rcar_gen2_cpg_pll_config *config,
unsigned int pll0_div, u32 mode) unsigned int pll0_div, u32 mode)
{ {
const struct soc_device_attribute *attr;
cpg_pll_config = config; cpg_pll_config = config;
cpg_pll0_div = pll0_div; cpg_pll0_div = pll0_div;
cpg_mode = mode; cpg_mode = mode;
attr = soc_device_match(cpg_quirks_match);
if (attr)
cpg_quirks = (uintptr_t)attr->data;
pr_debug("%s: mode = 0x%x quirks = 0x%x\n", __func__, mode, cpg_quirks);
spin_lock_init(&cpg_lock); spin_lock_init(&cpg_lock);
......
...@@ -652,6 +652,12 @@ static const struct of_device_id cpg_mssr_match[] = { ...@@ -652,6 +652,12 @@ static const struct of_device_id cpg_mssr_match[] = {
.data = &r8a7745_cpg_mssr_info, .data = &r8a7745_cpg_mssr_info,
}, },
#endif #endif
#ifdef CONFIG_CLK_R8A77470
{
.compatible = "renesas,r8a77470-cpg-mssr",
.data = &r8a77470_cpg_mssr_info,
},
#endif
#ifdef CONFIG_CLK_R8A7790 #ifdef CONFIG_CLK_R8A7790
{ {
.compatible = "renesas,r8a7790-cpg-mssr", .compatible = "renesas,r8a7790-cpg-mssr",
...@@ -711,6 +717,12 @@ static const struct of_device_id cpg_mssr_match[] = { ...@@ -711,6 +717,12 @@ static const struct of_device_id cpg_mssr_match[] = {
.data = &r8a77980_cpg_mssr_info, .data = &r8a77980_cpg_mssr_info,
}, },
#endif #endif
#ifdef CONFIG_CLK_R8A77990
{
.compatible = "renesas,r8a77990-cpg-mssr",
.data = &r8a77990_cpg_mssr_info,
},
#endif
#ifdef CONFIG_CLK_R8A77995 #ifdef CONFIG_CLK_R8A77995
{ {
.compatible = "renesas,r8a77995-cpg-mssr", .compatible = "renesas,r8a77995-cpg-mssr",
......
...@@ -133,6 +133,7 @@ struct cpg_mssr_info { ...@@ -133,6 +133,7 @@ struct 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 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;
...@@ -142,6 +143,7 @@ extern const struct cpg_mssr_info r8a7796_cpg_mssr_info; ...@@ -142,6 +143,7 @@ extern const struct cpg_mssr_info r8a7796_cpg_mssr_info;
extern const struct cpg_mssr_info r8a77965_cpg_mssr_info; extern const struct cpg_mssr_info r8a77965_cpg_mssr_info;
extern const struct cpg_mssr_info r8a77970_cpg_mssr_info; extern const struct cpg_mssr_info r8a77970_cpg_mssr_info;
extern const struct cpg_mssr_info r8a77980_cpg_mssr_info; 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 r8a77995_cpg_mssr_info; extern const struct cpg_mssr_info r8a77995_cpg_mssr_info;
......
/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
/*
* Copyright (c) 2016 BayLibre, SAS
* Author: Neil Armstrong <narmstrong@baylibre.com>
*
* Copyright (c) 2018 Amlogic, inc.
* Author: Qiufang Dai <qiufang.dai@amlogic.com>
*/
#ifndef DT_BINDINGS_CLOCK_AMLOGIC_MESON_AXG_AOCLK
#define DT_BINDINGS_CLOCK_AMLOGIC_MESON_AXG_AOCLK
#define CLKID_AO_REMOTE 0
#define CLKID_AO_I2C_MASTER 1
#define CLKID_AO_I2C_SLAVE 2
#define CLKID_AO_UART1 3
#define CLKID_AO_UART2 4
#define CLKID_AO_IR_BLASTER 5
#define CLKID_AO_SAR_ADC 6
#define CLKID_AO_CLK81 7
#define CLKID_AO_SAR_ADC_SEL 8
#define CLKID_AO_SAR_ADC_DIV 9
#define CLKID_AO_SAR_ADC_CLK 10
#define CLKID_AO_ALT_XTAL 11
#endif
...@@ -125,5 +125,7 @@ ...@@ -125,5 +125,7 @@
#define CLKID_VAPB_1 138 #define CLKID_VAPB_1 138
#define CLKID_VAPB_SEL 139 #define CLKID_VAPB_SEL 139
#define CLKID_VAPB 140 #define CLKID_VAPB 140
#define CLKID_VDEC_1 153
#define CLKID_VDEC_HEVC 156
#endif /* __GXBB_CLKC_H */ #endif /* __GXBB_CLKC_H */
...@@ -102,5 +102,6 @@ ...@@ -102,5 +102,6 @@
#define CLKID_MPLL0 93 #define CLKID_MPLL0 93
#define CLKID_MPLL1 94 #define CLKID_MPLL1 94
#define CLKID_MPLL2 95 #define CLKID_MPLL2 95
#define CLKID_NAND_CLK 112
#endif /* __MESON8B_CLKC_H */ #endif /* __MESON8B_CLKC_H */
/* SPDX-License-Identifier: GPL-2.0
*
* Copyright (C) 2018 Renesas Electronics Corp.
*/
#ifndef __DT_BINDINGS_CLOCK_R8A77470_CPG_MSSR_H__
#define __DT_BINDINGS_CLOCK_R8A77470_CPG_MSSR_H__
#include <dt-bindings/clock/renesas-cpg-mssr.h>
/* r8a77470 CPG Core Clocks */
#define R8A77470_CLK_Z2 0
#define R8A77470_CLK_ZTR 1
#define R8A77470_CLK_ZTRD2 2
#define R8A77470_CLK_ZT 3
#define R8A77470_CLK_ZX 4
#define R8A77470_CLK_ZS 5
#define R8A77470_CLK_HP 6
#define R8A77470_CLK_B 7
#define R8A77470_CLK_LB 8
#define R8A77470_CLK_P 9
#define R8A77470_CLK_CL 10
#define R8A77470_CLK_CP 11
#define R8A77470_CLK_M2 12
#define R8A77470_CLK_ZB3 13
#define R8A77470_CLK_SDH 14
#define R8A77470_CLK_SD0 15
#define R8A77470_CLK_SD1 16
#define R8A77470_CLK_SD2 17
#define R8A77470_CLK_MP 18
#define R8A77470_CLK_QSPI 19
#define R8A77470_CLK_CPEX 20
#define R8A77470_CLK_RCAN 21
#define R8A77470_CLK_R 22
#define R8A77470_CLK_OSC 23
#endif /* __DT_BINDINGS_CLOCK_R8A77470_CPG_MSSR_H__ */
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2018 Renesas Electronics Corp.
*/
#ifndef __DT_BINDINGS_CLOCK_R8A77990_CPG_MSSR_H__
#define __DT_BINDINGS_CLOCK_R8A77990_CPG_MSSR_H__
#include <dt-bindings/clock/renesas-cpg-mssr.h>
/* r8a77990 CPG Core Clocks */
#define R8A77990_CLK_Z2 0
#define R8A77990_CLK_ZR 1
#define R8A77990_CLK_ZG 2
#define R8A77990_CLK_ZTR 3
#define R8A77990_CLK_ZT 4
#define R8A77990_CLK_ZX 5
#define R8A77990_CLK_S0D1 6
#define R8A77990_CLK_S0D3 7
#define R8A77990_CLK_S0D6 8
#define R8A77990_CLK_S0D12 9
#define R8A77990_CLK_S0D24 10
#define R8A77990_CLK_S1D1 11
#define R8A77990_CLK_S1D2 12
#define R8A77990_CLK_S1D4 13
#define R8A77990_CLK_S2D1 14
#define R8A77990_CLK_S2D2 15
#define R8A77990_CLK_S2D4 16
#define R8A77990_CLK_S3D1 17
#define R8A77990_CLK_S3D2 18
#define R8A77990_CLK_S3D4 19
#define R8A77990_CLK_S0D6C 20
#define R8A77990_CLK_S3D1C 21
#define R8A77990_CLK_S3D2C 22
#define R8A77990_CLK_S3D4C 23
#define R8A77990_CLK_LB 24
#define R8A77990_CLK_CL 25
#define R8A77990_CLK_ZB3 26
#define R8A77990_CLK_ZB3D2 27
#define R8A77990_CLK_CR 28
#define R8A77990_CLK_CRD2 29
#define R8A77990_CLK_SD0H 30
#define R8A77990_CLK_SD0 31
#define R8A77990_CLK_SD1H 32
#define R8A77990_CLK_SD1 33
#define R8A77990_CLK_SD3H 34
#define R8A77990_CLK_SD3 35
#define R8A77990_CLK_RPC 36
#define R8A77990_CLK_RPCD2 37
#define R8A77990_CLK_ZA2 38
#define R8A77990_CLK_ZA8 39
#define R8A77990_CLK_Z2D 40
#define R8A77990_CLK_CANFD 41
#define R8A77990_CLK_MSO 42
#define R8A77990_CLK_R 43
#define R8A77990_CLK_OSC 44
#define R8A77990_CLK_LV0 45
#define R8A77990_CLK_LV1 46
#define R8A77990_CLK_CSI0 47
#define R8A77990_CLK_CP 48
#define R8A77990_CLK_CPEX 49
#endif /* __DT_BINDINGS_CLOCK_R8A77990_CPG_MSSR_H__ */
/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
/*
* Copyright (c) 2016 BayLibre, SAS
* Author: Neil Armstrong <narmstrong@baylibre.com>
*
* Copyright (c) 2018 Amlogic, inc.
* Author: Qiufang Dai <qiufang.dai@amlogic.com>
*/
#ifndef DT_BINDINGS_RESET_AMLOGIC_MESON_AXG_AOCLK
#define DT_BINDINGS_RESET_AMLOGIC_MESON_AXG_AOCLK
#define RESET_AO_REMOTE 0
#define RESET_AO_I2C_MASTER 1
#define RESET_AO_I2C_SLAVE 2
#define RESET_AO_UART1 3
#define RESET_AO_UART2 4
#define RESET_AO_IR_BLASTER 5
#endif
// SPDX-License-Identifier: GPL-2.0
/*
* Clock drivers for TI DaVinci PLL and PSC controllers
*
* Copyright (C) 2018 David Lechner <david@lechnology.com>
*/
#ifndef __LINUX_CLK_DAVINCI_PLL_H___
#define __LINUX_CLK_DAVINCI_PLL_H___
#include <linux/device.h>
#include <linux/regmap.h>
/* function for registering clocks in early boot */
#ifdef CONFIG_ARCH_DAVINCI_DA830
int da830_pll_init(struct device *dev, void __iomem *base, struct regmap *cfgchip);
#endif
#ifdef CONFIG_ARCH_DAVINCI_DA850
int da850_pll0_init(struct device *dev, void __iomem *base, struct regmap *cfgchip);
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM355
int dm355_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip);
int dm355_psc_init(struct device *dev, void __iomem *base);
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM365
int dm365_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip);
int dm365_pll2_init(struct device *dev, void __iomem *base, struct regmap *cfgchip);
int dm365_psc_init(struct device *dev, void __iomem *base);
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM644x
int dm644x_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip);
int dm644x_psc_init(struct device *dev, void __iomem *base);
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM646x
int dm646x_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip);
int dm646x_psc_init(struct device *dev, void __iomem *base);
#endif
#endif /* __LINUX_CLK_DAVINCI_PLL_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