Jagan Teki | 1d150b4 | 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 | |
| 7 | #ifndef _ASM_ARCH_CCU_H |
| 8 | #define _ASM_ARCH_CCU_H |
| 9 | |
| 10 | /** |
Jagan Teki | 7f6c2a8 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 11 | * enum ccu_flags - ccu clock/reset flags |
Jagan Teki | 1d150b4 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 12 | * |
| 13 | * @CCU_CLK_F_IS_VALID: is given clock gate is valid? |
Jagan Teki | 7f6c2a8 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 14 | * @CCU_RST_F_IS_VALID: is given reset control is valid? |
Jagan Teki | 1d150b4 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 15 | */ |
| 16 | enum ccu_flags { |
| 17 | CCU_CLK_F_IS_VALID = BIT(0), |
Jagan Teki | 7f6c2a8 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 18 | CCU_RST_F_IS_VALID = BIT(1), |
Jagan Teki | 1d150b4 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 19 | }; |
| 20 | |
| 21 | /** |
| 22 | * struct ccu_clk_gate - ccu clock gate |
| 23 | * @off: gate offset |
| 24 | * @bit: gate bit |
| 25 | * @flags: ccu clock gate flags |
| 26 | */ |
| 27 | struct ccu_clk_gate { |
| 28 | u16 off; |
| 29 | u32 bit; |
| 30 | enum ccu_flags flags; |
| 31 | }; |
| 32 | |
| 33 | #define GATE(_off, _bit) { \ |
| 34 | .off = _off, \ |
| 35 | .bit = _bit, \ |
| 36 | .flags = CCU_CLK_F_IS_VALID, \ |
| 37 | } |
| 38 | |
| 39 | /** |
Jagan Teki | 7f6c2a8 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 40 | * struct ccu_reset - ccu reset |
| 41 | * @off: reset offset |
| 42 | * @bit: reset bit |
| 43 | * @flags: ccu reset control flags |
| 44 | */ |
| 45 | struct ccu_reset { |
| 46 | u16 off; |
| 47 | u32 bit; |
| 48 | enum ccu_flags flags; |
| 49 | }; |
| 50 | |
| 51 | #define RESET(_off, _bit) { \ |
| 52 | .off = _off, \ |
| 53 | .bit = _bit, \ |
| 54 | .flags = CCU_RST_F_IS_VALID, \ |
| 55 | } |
| 56 | |
| 57 | /** |
Jagan Teki | 1d150b4 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 58 | * struct ccu_desc - clock control unit descriptor |
| 59 | * |
| 60 | * @gates: clock gates |
Jagan Teki | 7f6c2a8 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 61 | * @resets: reset unit |
Jagan Teki | 1d150b4 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 62 | */ |
| 63 | struct ccu_desc { |
| 64 | const struct ccu_clk_gate *gates; |
Jagan Teki | 7f6c2a8 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 65 | const struct ccu_reset *resets; |
Jagan Teki | 1d150b4 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | /** |
| 69 | * struct ccu_priv - sunxi clock control unit |
| 70 | * |
| 71 | * @base: base address |
| 72 | * @desc: ccu descriptor |
| 73 | */ |
| 74 | struct ccu_priv { |
| 75 | void *base; |
| 76 | const struct ccu_desc *desc; |
| 77 | }; |
| 78 | |
| 79 | /** |
| 80 | * sunxi_clk_probe - common sunxi clock probe |
| 81 | * @dev: clock device |
| 82 | */ |
| 83 | int sunxi_clk_probe(struct udevice *dev); |
| 84 | |
| 85 | extern struct clk_ops sunxi_clk_ops; |
| 86 | |
Jagan Teki | 7f6c2a8 | 2019-01-18 22:18:13 +0530 | [diff] [blame] | 87 | /** |
| 88 | * sunxi_reset_bind() - reset binding |
| 89 | * |
| 90 | * @dev: reset device |
| 91 | * @count: reset count |
| 92 | * @return 0 success, or error value |
| 93 | */ |
| 94 | int sunxi_reset_bind(struct udevice *dev, ulong count); |
| 95 | |
Jagan Teki | 1d150b4 | 2018-12-22 21:32:49 +0530 | [diff] [blame] | 96 | #endif /* _ASM_ARCH_CCU_H */ |