Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2018 Amarula Solutions. |
| 4 | * Author: Jagan Teki <jagan@amarulasolutions.com> |
| 5 | */ |
| 6 | |
Samuel Holland | 21d314a | 2021-09-12 11:48:43 -0500 | [diff] [blame] | 7 | #ifndef _CLK_SUNXI_H |
| 8 | #define _CLK_SUNXI_H |
Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 9 | |
Simon Glass | cd93d62 | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 10 | #include <linux/bitops.h> |
Simon Glass | cd93d62 | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 11 | |
Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 12 | /** |
Jagan Teki | 99ba430 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 13 | * enum ccu_flags - ccu clock/reset flags |
Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 14 | * |
| 15 | * @CCU_CLK_F_IS_VALID: is given clock gate is valid? |
Jagan Teki | 99ba430 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 16 | * @CCU_RST_F_IS_VALID: is given reset control is valid? |
Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 17 | */ |
| 18 | enum ccu_flags { |
| 19 | CCU_CLK_F_IS_VALID = BIT(0), |
Jagan Teki | 99ba430 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 20 | CCU_RST_F_IS_VALID = BIT(1), |
Andre Przywara | d6cb09d | 2022-05-05 01:25:43 +0100 | [diff] [blame] | 21 | CCU_CLK_F_DUMMY_GATE = BIT(2), |
Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 22 | }; |
| 23 | |
| 24 | /** |
| 25 | * struct ccu_clk_gate - ccu clock gate |
| 26 | * @off: gate offset |
| 27 | * @bit: gate bit |
| 28 | * @flags: ccu clock gate flags |
| 29 | */ |
| 30 | struct ccu_clk_gate { |
| 31 | u16 off; |
| 32 | u32 bit; |
| 33 | enum ccu_flags flags; |
| 34 | }; |
| 35 | |
| 36 | #define GATE(_off, _bit) { \ |
| 37 | .off = _off, \ |
| 38 | .bit = _bit, \ |
| 39 | .flags = CCU_CLK_F_IS_VALID, \ |
| 40 | } |
| 41 | |
Andre Przywara | d6cb09d | 2022-05-05 01:25:43 +0100 | [diff] [blame] | 42 | #define GATE_DUMMY { \ |
| 43 | .flags = CCU_CLK_F_DUMMY_GATE, \ |
| 44 | } |
| 45 | |
Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 46 | /** |
Jagan Teki | 99ba430 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 47 | * struct ccu_reset - ccu reset |
| 48 | * @off: reset offset |
| 49 | * @bit: reset bit |
| 50 | * @flags: ccu reset control flags |
| 51 | */ |
| 52 | struct ccu_reset { |
| 53 | u16 off; |
| 54 | u32 bit; |
| 55 | enum ccu_flags flags; |
| 56 | }; |
| 57 | |
| 58 | #define RESET(_off, _bit) { \ |
| 59 | .off = _off, \ |
| 60 | .bit = _bit, \ |
| 61 | .flags = CCU_RST_F_IS_VALID, \ |
| 62 | } |
| 63 | |
| 64 | /** |
Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 65 | * struct ccu_desc - clock control unit descriptor |
| 66 | * |
| 67 | * @gates: clock gates |
Jagan Teki | 99ba430 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 68 | * @resets: reset unit |
Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 69 | */ |
| 70 | struct ccu_desc { |
| 71 | const struct ccu_clk_gate *gates; |
Jagan Teki | 99ba430 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 72 | const struct ccu_reset *resets; |
Samuel Holland | 49b2b0a | 2022-05-09 00:29:31 -0500 | [diff] [blame] | 73 | u8 num_gates; |
| 74 | u8 num_resets; |
Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | /** |
Samuel Holland | 5af97b6 | 2022-05-09 00:29:35 -0500 | [diff] [blame] | 78 | * struct ccu_plat - sunxi clock control unit platform data |
Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 79 | * |
| 80 | * @base: base address |
| 81 | * @desc: ccu descriptor |
| 82 | */ |
Samuel Holland | 5af97b6 | 2022-05-09 00:29:35 -0500 | [diff] [blame] | 83 | struct ccu_plat { |
Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 84 | void *base; |
| 85 | const struct ccu_desc *desc; |
| 86 | }; |
| 87 | |
Jagan Teki | 0d47bc7 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 88 | extern struct clk_ops sunxi_clk_ops; |
| 89 | |
Samuel Holland | 21d314a | 2021-09-12 11:48:43 -0500 | [diff] [blame] | 90 | #endif /* _CLK_SUNXI_H */ |