|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
| 2 | +/* |
| 3 | + * Renesas RZ/G3E CPG driver |
| 4 | + * |
| 5 | + * Copyright (C) 2024 Renesas Electronics Corp. |
| 6 | + */ |
| 7 | + |
| 8 | +#include <linux/clk-provider.h> |
| 9 | +#include <linux/device.h> |
| 10 | +#include <linux/init.h> |
| 11 | +#include <linux/kernel.h> |
| 12 | + |
| 13 | +#include <dt-bindings/clock/renesas,r9a09g047-cpg.h> |
| 14 | + |
| 15 | +#include "rzv2h-cpg.h" |
| 16 | + |
| 17 | +enum clk_ids { |
| 18 | + /* Core Clock Outputs exported to DT */ |
| 19 | + LAST_DT_CORE_CLK = R9A09G047_IOTOP_0_SHCLK, |
| 20 | + |
| 21 | + /* External Input Clocks */ |
| 22 | + CLK_AUDIO_EXTAL, |
| 23 | + CLK_RTXIN, |
| 24 | + CLK_QEXTAL, |
| 25 | + |
| 26 | + /* PLL Clocks */ |
| 27 | + CLK_PLLCM33, |
| 28 | + CLK_PLLDTY, |
| 29 | + CLK_PLLCA55, |
| 30 | + |
| 31 | + /* Internal Core Clocks */ |
| 32 | + CLK_PLLCM33_DIV16, |
| 33 | + CLK_PLLDTY_ACPU, |
| 34 | + CLK_PLLDTY_ACPU_DIV4, |
| 35 | + |
| 36 | + /* Module Clocks */ |
| 37 | + MOD_CLK_BASE, |
| 38 | +}; |
| 39 | + |
| 40 | +static const struct clk_div_table dtable_2_64[] = { |
| 41 | + {0, 2}, |
| 42 | + {1, 4}, |
| 43 | + {2, 8}, |
| 44 | + {3, 16}, |
| 45 | + {4, 64}, |
| 46 | + {0, 0}, |
| 47 | +}; |
| 48 | + |
| 49 | +static const struct cpg_core_clk r9a09g047_core_clks[] __initconst = { |
| 50 | + /* External Clock Inputs */ |
| 51 | + DEF_INPUT("audio_extal", CLK_AUDIO_EXTAL), |
| 52 | + DEF_INPUT("rtxin", CLK_RTXIN), |
| 53 | + DEF_INPUT("qextal", CLK_QEXTAL), |
| 54 | + |
| 55 | + /* PLL Clocks */ |
| 56 | + DEF_FIXED(".pllcm33", CLK_PLLCM33, CLK_QEXTAL, 200, 3), |
| 57 | + DEF_FIXED(".plldty", CLK_PLLDTY, CLK_QEXTAL, 200, 3), |
| 58 | + DEF_PLL(".pllca55", CLK_PLLCA55, CLK_QEXTAL, PLL_CONF(0x64)), |
| 59 | + |
| 60 | + /* Internal Core Clocks */ |
| 61 | + DEF_FIXED(".pllcm33_div16", CLK_PLLCM33_DIV16, CLK_PLLCM33, 1, 16), |
| 62 | + |
| 63 | + DEF_DDIV(".plldty_acpu", CLK_PLLDTY_ACPU, CLK_PLLDTY, CDDIV0_DIVCTL2, dtable_2_64), |
| 64 | + DEF_FIXED(".plldty_acpu_div4", CLK_PLLDTY_ACPU_DIV4, CLK_PLLDTY_ACPU, 1, 4), |
| 65 | + |
| 66 | + /* Core Clocks */ |
| 67 | + DEF_FIXED("sys_0_pclk", R9A09G047_SYS_0_PCLK, CLK_QEXTAL, 1, 1), |
| 68 | + DEF_FIXED("iotop_0_shclk", R9A09G047_IOTOP_0_SHCLK, CLK_PLLCM33_DIV16, 1, 1), |
| 69 | +}; |
| 70 | + |
| 71 | +static const struct rzv2h_mod_clk r9a09g047_mod_clks[] __initconst = { |
| 72 | + DEF_MOD_CRITICAL("gic_0_gicclk", CLK_PLLDTY_ACPU_DIV4, 1, 3, 0, 19, |
| 73 | + BUS_MSTOP(3, BIT(5))), |
| 74 | + DEF_MOD("scif_0_clk_pck", CLK_PLLCM33_DIV16, 8, 15, 4, 15, |
| 75 | + BUS_MSTOP(3, BIT(14))), |
| 76 | +}; |
| 77 | + |
| 78 | +static const struct rzv2h_reset r9a09g047_resets[] __initconst = { |
| 79 | + DEF_RST(3, 0, 1, 1), /* SYS_0_PRESETN */ |
| 80 | + DEF_RST(3, 8, 1, 9), /* GIC_0_GICRESET_N */ |
| 81 | + DEF_RST(3, 9, 1, 10), /* GIC_0_DBG_GICRESET_N */ |
| 82 | + DEF_RST(9, 5, 4, 6), /* SCIF_0_RST_SYSTEM_N */ |
| 83 | +}; |
| 84 | + |
| 85 | +const struct rzv2h_cpg_info r9a09g047_cpg_info __initconst = { |
| 86 | + /* Core Clocks */ |
| 87 | + .core_clks = r9a09g047_core_clks, |
| 88 | + .num_core_clks = ARRAY_SIZE(r9a09g047_core_clks), |
| 89 | + .last_dt_core_clk = LAST_DT_CORE_CLK, |
| 90 | + .num_total_core_clks = MOD_CLK_BASE, |
| 91 | + |
| 92 | + /* Module Clocks */ |
| 93 | + .mod_clks = r9a09g047_mod_clks, |
| 94 | + .num_mod_clks = ARRAY_SIZE(r9a09g047_mod_clks), |
| 95 | + .num_hw_mod_clks = 28 * 16, |
| 96 | + |
| 97 | + /* Resets */ |
| 98 | + .resets = r9a09g047_resets, |
| 99 | + .num_resets = ARRAY_SIZE(r9a09g047_resets), |
| 100 | + |
| 101 | + .num_mstop_bits = 208, |
| 102 | +}; |
0 commit comments