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, |
| 20 | CLK_TYPE_GEN3_SD, |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 21 | CLK_TYPE_GEN3_R, |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 22 | CLK_TYPE_GEN3_MDSEL, /* Select parent/divider using mode pin */ |
| 23 | CLK_TYPE_GEN3_Z, |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 24 | CLK_TYPE_GEN3_OSC, /* OSC EXTAL predivider and fixed divider */ |
| 25 | CLK_TYPE_GEN3_RCKSEL, /* Select parent/divider using RCKCR.CKSEL */ |
| 26 | CLK_TYPE_GEN3_RPCSRC, |
Marek Vasut | 0e8dcb7 | 2021-04-25 21:10:40 +0200 | [diff] [blame] | 27 | CLK_TYPE_GEN3_E3_RPCSRC, |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 28 | CLK_TYPE_GEN3_RPC, |
| 29 | CLK_TYPE_GEN3_RPCD2, |
| 30 | |
| 31 | /* SoC specific definitions start here */ |
| 32 | CLK_TYPE_GEN3_SOC_BASE, |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | #define DEF_GEN3_SD(_name, _id, _parent, _offset) \ |
| 36 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_SD, _parent, .offset = _offset) |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 37 | |
Hai Pham | 215de2b | 2020-08-11 10:25:28 +0700 | [diff] [blame] | 38 | #define DEF_GEN3_RPCD2(_name, _id, _parent, _offset) \ |
| 39 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_RPCD2, _parent, .offset = _offset) |
| 40 | |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 41 | #define DEF_GEN3_MDSEL(_name, _id, _md, _parent0, _div0, _parent1, _div1) \ |
| 42 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_MDSEL, \ |
| 43 | (_parent0) << 16 | (_parent1), \ |
| 44 | .div = (_div0) << 16 | (_div1), .offset = _md) |
| 45 | |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 46 | #define DEF_GEN3_PE(_name, _id, _parent_sscg, _div_sscg, _parent_clean, \ |
| 47 | _div_clean) \ |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 48 | DEF_GEN3_MDSEL(_name, _id, 12, _parent_sscg, _div_sscg, \ |
| 49 | _parent_clean, _div_clean) |
| 50 | |
| 51 | #define DEF_GEN3_OSC(_name, _id, _parent, _div) \ |
| 52 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_OSC, _parent, .div = _div) |
| 53 | |
| 54 | #define DEF_GEN3_RCKSEL(_name, _id, _parent0, _div0, _parent1, _div1) \ |
| 55 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_RCKSEL, \ |
| 56 | (_parent0) << 16 | (_parent1), .div = (_div0) << 16 | (_div1)) |
| 57 | |
Adam Ford | 06c4f9b | 2020-06-30 09:30:08 -0500 | [diff] [blame] | 58 | #define DEF_GEN3_Z(_name, _id, _type, _parent, _div, _offset) \ |
| 59 | DEF_BASE(_name, _id, _type, _parent, .div = _div, .offset = _offset) |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 60 | |
Marek Vasut | 0e8dcb7 | 2021-04-25 21:10:40 +0200 | [diff] [blame] | 61 | #define DEF_FIXED_RPCSRC_E3(_name, _id, _parent0, _parent1) \ |
| 62 | DEF_BASE(_name, _id, CLK_TYPE_GEN3_E3_RPCSRC, \ |
| 63 | (_parent0) << 16 | (_parent1), .div = 8) |
| 64 | |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 65 | struct rcar_gen3_cpg_pll_config { |
| 66 | u8 extal_div; |
| 67 | u8 pll1_mult; |
| 68 | u8 pll1_div; |
| 69 | u8 pll3_mult; |
| 70 | u8 pll3_div; |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 71 | u8 osc_prediv; |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 72 | }; |
| 73 | |
Marek Vasut | 814217e | 2021-04-25 21:53:05 +0200 | [diff] [blame^] | 74 | #define CPG_RST_MODEMR 0x060 |
| 75 | |
Marek Vasut | 7841483 | 2019-03-04 21:38:10 +0100 | [diff] [blame] | 76 | #define CPG_RPCCKCR 0x238 |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 77 | #define CPG_RCKCR 0x240 |
| 78 | |
| 79 | struct gen3_clk_priv { |
| 80 | void __iomem *base; |
| 81 | struct cpg_mssr_info *info; |
| 82 | struct clk clk_extal; |
| 83 | struct clk clk_extalr; |
Marek Vasut | 69459b2 | 2018-05-31 19:47:42 +0200 | [diff] [blame] | 84 | bool sscg; |
Marek Vasut | 7ef12c2 | 2018-01-08 17:09:45 +0100 | [diff] [blame] | 85 | const struct rcar_gen3_cpg_pll_config *cpg_pll_config; |
| 86 | }; |
| 87 | |
| 88 | int gen3_clk_probe(struct udevice *dev); |
| 89 | int gen3_clk_remove(struct udevice *dev); |
| 90 | |
| 91 | extern const struct clk_ops gen3_clk_ops; |
| 92 | |
| 93 | #endif |