| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Renesas Clock Pulse Generator / Module Standby and Software Reset |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2015 Glider bvba |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; version 2 of the License. |
|---|
| 9 | 6 | */ |
|---|
| 10 | 7 | |
|---|
| 11 | 8 | #ifndef __CLK_RENESAS_CPG_MSSR_H__ |
|---|
| .. | .. |
|---|
| 38 | 35 | CLK_TYPE_FF, /* Fixed Factor Clock */ |
|---|
| 39 | 36 | CLK_TYPE_DIV6P1, /* DIV6 Clock with 1 parent clock */ |
|---|
| 40 | 37 | CLK_TYPE_DIV6_RO, /* DIV6 Clock read only with extra divisor */ |
|---|
| 38 | + CLK_TYPE_FR, /* Fixed Rate Clock */ |
|---|
| 41 | 39 | |
|---|
| 42 | 40 | /* Custom definitions start here */ |
|---|
| 43 | 41 | CLK_TYPE_CUSTOM, |
|---|
| .. | .. |
|---|
| 56 | 54 | DEF_BASE(_name, _id, CLK_TYPE_DIV6P1, _parent, .offset = _offset) |
|---|
| 57 | 55 | #define DEF_DIV6_RO(_name, _id, _parent, _offset, _div) \ |
|---|
| 58 | 56 | DEF_BASE(_name, _id, CLK_TYPE_DIV6_RO, _parent, .offset = _offset, .div = _div, .mult = 1) |
|---|
| 57 | +#define DEF_RATE(_name, _id, _rate) \ |
|---|
| 58 | + DEF_TYPE(_name, _id, CLK_TYPE_FR, .mult = _rate) |
|---|
| 59 | 59 | |
|---|
| 60 | 60 | /* |
|---|
| 61 | 61 | * Definitions of Module Clocks |
|---|
| .. | .. |
|---|
| 75 | 75 | #define DEF_MOD(_name, _mod, _parent...) \ |
|---|
| 76 | 76 | { .name = _name, .id = MOD_CLK_ID(_mod), .parent = _parent } |
|---|
| 77 | 77 | |
|---|
| 78 | +/* Convert from sparse base-10 to packed index space */ |
|---|
| 79 | +#define MOD_CLK_PACK_10(x) ((x / 10) * 32 + (x % 10)) |
|---|
| 80 | + |
|---|
| 81 | +#define MOD_CLK_ID_10(x) (MOD_CLK_BASE + MOD_CLK_PACK_10(x)) |
|---|
| 82 | + |
|---|
| 83 | +#define DEF_MOD_STB(_name, _mod, _parent...) \ |
|---|
| 84 | + { .name = _name, .id = MOD_CLK_ID_10(_mod), .parent = _parent } |
|---|
| 78 | 85 | |
|---|
| 79 | 86 | struct device_node; |
|---|
| 80 | 87 | |
|---|
| 88 | +enum clk_reg_layout { |
|---|
| 89 | + CLK_REG_LAYOUT_RCAR_GEN2_AND_GEN3 = 0, |
|---|
| 90 | + CLK_REG_LAYOUT_RZ_A, |
|---|
| 91 | + CLK_REG_LAYOUT_RCAR_V3U, |
|---|
| 92 | +}; |
|---|
| 93 | + |
|---|
| 81 | 94 | /** |
|---|
| 82 | 95 | * SoC-specific CPG/MSSR Description |
|---|
| 96 | + * |
|---|
| 97 | + * @early_core_clks: Array of Early Core Clock definitions |
|---|
| 98 | + * @num_early_core_clks: Number of entries in early_core_clks[] |
|---|
| 99 | + * @early_mod_clks: Array of Early Module Clock definitions |
|---|
| 100 | + * @num_early_mod_clks: Number of entries in early_mod_clks[] |
|---|
| 83 | 101 | * |
|---|
| 84 | 102 | * @core_clks: Array of Core Clock definitions |
|---|
| 85 | 103 | * @num_core_clks: Number of entries in core_clks[] |
|---|
| .. | .. |
|---|
| 93 | 111 | * @crit_mod_clks: Array with Module Clock IDs of critical clocks that |
|---|
| 94 | 112 | * should not be disabled without a knowledgeable driver |
|---|
| 95 | 113 | * @num_crit_mod_clks: Number of entries in crit_mod_clks[] |
|---|
| 114 | + * @reg_layout: CPG/MSSR register layout from enum clk_reg_layout |
|---|
| 96 | 115 | * |
|---|
| 97 | 116 | * @core_pm_clks: Array with IDs of Core Clocks that are suitable for Power |
|---|
| 98 | 117 | * Management, in addition to Module Clocks |
|---|
| .. | .. |
|---|
| 103 | 122 | */ |
|---|
| 104 | 123 | |
|---|
| 105 | 124 | struct cpg_mssr_info { |
|---|
| 125 | + /* Early Clocks */ |
|---|
| 126 | + const struct cpg_core_clk *early_core_clks; |
|---|
| 127 | + unsigned int num_early_core_clks; |
|---|
| 128 | + const struct mssr_mod_clk *early_mod_clks; |
|---|
| 129 | + unsigned int num_early_mod_clks; |
|---|
| 130 | + |
|---|
| 106 | 131 | /* Core Clocks */ |
|---|
| 107 | 132 | const struct cpg_core_clk *core_clks; |
|---|
| 108 | 133 | unsigned int num_core_clks; |
|---|
| 109 | 134 | unsigned int last_dt_core_clk; |
|---|
| 110 | 135 | unsigned int num_total_core_clks; |
|---|
| 136 | + enum clk_reg_layout reg_layout; |
|---|
| 111 | 137 | |
|---|
| 112 | 138 | /* Module Clocks */ |
|---|
| 113 | 139 | const struct mssr_mod_clk *mod_clks; |
|---|
| .. | .. |
|---|
| 131 | 157 | struct raw_notifier_head *notifiers); |
|---|
| 132 | 158 | }; |
|---|
| 133 | 159 | |
|---|
| 160 | +extern const struct cpg_mssr_info r7s9210_cpg_mssr_info; |
|---|
| 161 | +extern const struct cpg_mssr_info r8a7742_cpg_mssr_info; |
|---|
| 134 | 162 | extern const struct cpg_mssr_info r8a7743_cpg_mssr_info; |
|---|
| 135 | 163 | extern const struct cpg_mssr_info r8a7745_cpg_mssr_info; |
|---|
| 136 | 164 | extern const struct cpg_mssr_info r8a77470_cpg_mssr_info; |
|---|
| 165 | +extern const struct cpg_mssr_info r8a774a1_cpg_mssr_info; |
|---|
| 166 | +extern const struct cpg_mssr_info r8a774b1_cpg_mssr_info; |
|---|
| 167 | +extern const struct cpg_mssr_info r8a774c0_cpg_mssr_info; |
|---|
| 168 | +extern const struct cpg_mssr_info r8a774e1_cpg_mssr_info; |
|---|
| 137 | 169 | extern const struct cpg_mssr_info r8a7790_cpg_mssr_info; |
|---|
| 138 | 170 | extern const struct cpg_mssr_info r8a7791_cpg_mssr_info; |
|---|
| 139 | 171 | extern const struct cpg_mssr_info r8a7792_cpg_mssr_info; |
|---|
| .. | .. |
|---|
| 145 | 177 | extern const struct cpg_mssr_info r8a77980_cpg_mssr_info; |
|---|
| 146 | 178 | extern const struct cpg_mssr_info r8a77990_cpg_mssr_info; |
|---|
| 147 | 179 | extern const struct cpg_mssr_info r8a77995_cpg_mssr_info; |
|---|
| 180 | +extern const struct cpg_mssr_info r8a779a0_cpg_mssr_info; |
|---|
| 148 | 181 | |
|---|
| 182 | +void __init cpg_mssr_early_init(struct device_node *np, |
|---|
| 183 | + const struct cpg_mssr_info *info); |
|---|
| 149 | 184 | |
|---|
| 150 | 185 | /* |
|---|
| 151 | 186 | * Helpers for fixing up clock tables depending on SoC revision |
|---|