Marek Vasut | 0e8dcb7 | 2021-04-25 21:10:40 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 2 | /* |
| 3 | * R-Car Gen3 Clock Pulse Generator |
| 4 | * |
Marek Vasut | 0e8dcb7 | 2021-04-25 21:10:40 +0200 | [diff] [blame] | 5 | * Copyright (C) 2015-2018 Glider bvba |
| 6 | * Copyright (C) 2018 Renesas Electronics Corp. |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 7 | * |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef __CLK_RENESAS_RCAR_GEN3_CPG_H__ |
| 11 | #define __CLK_RENESAS_RCAR_GEN3_CPG_H__ |
| 12 | |
| 13 | enum rcar_gen3_clk_types { |
| 14 | CLK_TYPE_GEN3_MAIN = CLK_TYPE_CUSTOM, |
| 15 | CLK_TYPE_GEN3_PLL0, |
| 16 | CLK_TYPE_GEN3_PLL1, |
| 17 | CLK_TYPE_GEN3_PLL2, |
| 18 | CLK_TYPE_GEN3_PLL3, |
| 19 | CLK_TYPE_GEN3_PLL4, |
Hai Pham | 0985e0e | 2023-01-26 21:01:49 +0100 | [diff] [blame] | 20 | CLK_TYPE_GEN3_SDH, |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 21 | CLK_TYPE_GEN3_SD, |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 22 | CLK_TYPE_GEN3_R, |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 23 | CLK_TYPE_GEN3_MDSEL, /* Select parent/divider using mode pin */ |
| 24 | CLK_TYPE_GEN3_Z, |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 25 | CLK_TYPE_GEN3_OSC, /* OSC EXTAL predivider and fixed divider */ |
| 26 | CLK_TYPE_GEN3_RCKSEL, /* Select parent/divider using RCKCR.CKSEL */ |
| 27 | CLK_TYPE_GEN3_RPCSRC, |
Marek Vasut | d1ff7e0 | 2023-01-26 21:01:55 +0100 | [diff] [blame] | 28 | CLK_TYPE_GEN3_D3_RPCSRC, |
Marek Vasut | 0e8dcb7 | 2021-04-25 21:10:40 +0200 | [diff] [blame] | 29 | CLK_TYPE_GEN3_E3_RPCSRC, |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 30 | CLK_TYPE_GEN3_RPC, |
| 31 | CLK_TYPE_GEN3_RPCD2, |
Hai Pham | 86d59f3 | 2020-08-11 10:46:34 +0700 | [diff] [blame] | 32 | |
Marek Vasut | 569acef | 2023-01-26 21:01:56 +0100 | [diff] [blame] | 33 | CLK_TYPE_GEN4_MAIN, |
| 34 | CLK_TYPE_GEN4_PLL1, |
| 35 | CLK_TYPE_GEN4_PLL2X_3X, /* PLL[23][01] */ |
| 36 | CLK_TYPE_GEN4_PLL5, |
| 37 | CLK_TYPE_GEN4_SDH, |
| 38 | CLK_TYPE_GEN4_SD, |
| 39 | CLK_TYPE_GEN4_MDSEL, /* Select parent/divider using mode pin */ |
| 40 | CLK_TYPE_GEN4_Z, |
| 41 | CLK_TYPE_GEN4_OSC, /* OSC EXTAL predivider and fixed divider */ |
| 42 | CLK_TYPE_GEN4_RPCSRC, |
| 43 | CLK_TYPE_GEN4_RPC, |
| 44 | CLK_TYPE_GEN4_RPCD2, |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 45 | |
| 46 | /* SoC specific definitions start here */ |
| 47 | CLK_TYPE_GEN3_SOC_BASE, |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 48 | }; |
| 49 | |
Hai Pham | 0985e0e | 2023-01-26 21:01:49 +0100 | [diff] [blame] | 50 | #define DEF_GEN3_SDH(_name, _id, _parent, _offset) \ |
| 51 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_SDH, _parent, .offset = _offset) |
| 52 | |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 53 | #define DEF_GEN3_SD(_name, _id, _parent, _offset) \ |
| 54 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_SD, _parent, .offset = _offset) |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 55 | |
Hai Pham | 215de2b | 2020-08-11 10:25:28 +0700 | [diff] [blame] | 56 | #define DEF_GEN3_RPCD2(_name, _id, _parent, _offset) \ |
| 57 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_RPCD2, _parent, .offset = _offset) |
| 58 | |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 59 | #define DEF_GEN3_MDSEL(_name, _id, _md, _parent0, _div0, _parent1, _div1) \ |
| 60 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_MDSEL, \ |
| 61 | (_parent0) << 16 | (_parent1), \ |
| 62 | .div = (_div0) << 16 | (_div1), .offset = _md) |
| 63 | |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 64 | #define DEF_GEN3_PE(_name, _id, _parent_sscg, _div_sscg, _parent_clean, \ |
| 65 | _div_clean) \ |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 66 | DEF_GEN3_MDSEL(_name, _id, 12, _parent_sscg, _div_sscg, \ |
| 67 | _parent_clean, _div_clean) |
| 68 | |
| 69 | #define DEF_GEN3_OSC(_name, _id, _parent, _div) \ |
| 70 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_OSC, _parent, .div = _div) |
| 71 | |
| 72 | #define DEF_GEN3_RCKSEL(_name, _id, _parent0, _div0, _parent1, _div1) \ |
| 73 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_RCKSEL, \ |
| 74 | (_parent0) << 16 | (_parent1), .div = (_div0) << 16 | (_div1)) |
| 75 | |
Adam Ford | 06c4f9b | 2020-06-30 09:30:08 -0500 | [diff] [blame] | 76 | #define DEF_GEN3_Z(_name, _id, _type, _parent, _div, _offset) \ |
| 77 | DEF_BASE(_name, _id, _type, _parent, .div = _div, .offset = _offset) |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 78 | |
Marek Vasut | d1ff7e0 | 2023-01-26 21:01:55 +0100 | [diff] [blame] | 79 | #define DEF_FIXED_RPCSRC_D3(_name, _id, _parent0, _parent1) \ |
| 80 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_D3_RPCSRC, \ |
| 81 | (_parent0) << 16 | (_parent1), .div = 5) |
| 82 | |
Marek Vasut | 0e8dcb7 | 2021-04-25 21:10:40 +0200 | [diff] [blame] | 83 | #define DEF_FIXED_RPCSRC_E3(_name, _id, _parent0, _parent1) \ |
| 84 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_E3_RPCSRC, \ |
| 85 | (_parent0) << 16 | (_parent1), .div = 8) |
| 86 | |
Marek Vasut | 569acef | 2023-01-26 21:01:56 +0100 | [diff] [blame] | 87 | #define DEF_GEN4_SDH(_name, _id, _parent, _offset) \ |
| 88 | DEF_BASE(_name, _id, CLK_TYPE_GEN4_SDH, _parent, .offset = _offset) |
| 89 | |
| 90 | #define DEF_GEN4_SD(_name, _id, _parent, _offset) \ |
| 91 | DEF_BASE(_name, _id, CLK_TYPE_GEN4_SD, _parent, .offset = _offset) |
| 92 | |
| 93 | #define DEF_GEN4_MDSEL(_name, _id, _md, _parent0, _div0, _parent1, _div1) \ |
| 94 | DEF_BASE(_name, _id, CLK_TYPE_GEN4_MDSEL, \ |
| 95 | (_parent0) << 16 | (_parent1), \ |
| 96 | .div = (_div0) << 16 | (_div1), .offset = _md) |
| 97 | |
| 98 | #define DEF_GEN4_OSC(_name, _id, _parent, _div) \ |
| 99 | DEF_BASE(_name, _id, CLK_TYPE_GEN4_OSC, _parent, .div = _div) |
| 100 | |
| 101 | #define DEF_GEN4_Z(_name, _id, _type, _parent, _div, _offset) \ |
| 102 | DEF_BASE(_name, _id, _type, _parent, .div = _div, .offset = _offset) |
| 103 | |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 104 | struct rcar_gen3_cpg_pll_config { |
| 105 | u8 extal_div; |
| 106 | u8 pll1_mult; |
| 107 | u8 pll1_div; |
| 108 | u8 pll3_mult; |
| 109 | u8 pll3_div; |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 110 | u8 osc_prediv; |
Marek Vasut | 0fbb8a7 | 2021-04-27 19:52:53 +0200 | [diff] [blame] | 111 | u8 pll5_mult; |
| 112 | u8 pll5_div; |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 113 | }; |
| 114 | |
Marek Vasut | 814217e | 2021-04-25 21:53:05 +0200 | [diff] [blame] | 115 | #define CPG_RST_MODEMR 0x060 |
| 116 | |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 117 | #define CPG_RPCCKCR 0x238 |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 118 | #define CPG_RCKCR 0x240 |
| 119 | |
| 120 | struct gen3_clk_priv { |
| 121 | void __iomem *base; |
| 122 | struct cpg_mssr_info *info; |
| 123 | struct clk clk_extal; |
| 124 | struct clk clk_extalr; |
Marek Vasut | 69459b2 | 2018-05-31 19:47:42 +0200 | [diff] [blame] | 125 | bool sscg; |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 126 | const struct rcar_gen3_cpg_pll_config *cpg_pll_config; |
| 127 | }; |
| 128 | |
Marek Vasut | f6b3202 | 2023-01-26 21:02:03 +0100 | [diff] [blame^] | 129 | int gen3_cpg_bind(struct udevice *parent); |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 130 | |
| 131 | extern const struct clk_ops gen3_clk_ops; |
| 132 | |
| 133 | #endif |