Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Masahiro Yamada | e4dfb05 | 2016-02-02 21:11:32 +0900 | [diff] [blame] | 2 | /* |
Masahiro Yamada | fa1f73f | 2016-07-19 21:56:13 +0900 | [diff] [blame] | 3 | * Copyright (C) 2016 Socionext Inc. |
| 4 | * Author: Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | e4dfb05 | 2016-02-02 21:11:32 +0900 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __CLK_UNIPHIER_H__ |
| 8 | #define __CLK_UNIPHIER_H__ |
| 9 | |
| 10 | #include <linux/kernel.h> |
Masahiro Yamada | 4980668 | 2017-10-13 19:21:59 +0900 | [diff] [blame] | 11 | #include <linux/types.h> |
Masahiro Yamada | e4dfb05 | 2016-02-02 21:11:32 +0900 | [diff] [blame] | 12 | |
Masahiro Yamada | 4980668 | 2017-10-13 19:21:59 +0900 | [diff] [blame] | 13 | #define UNIPHIER_CLK_MUX_MAX_PARENTS 8 |
| 14 | |
| 15 | #define UNIPHIER_CLK_TYPE_END 0 |
| 16 | #define UNIPHIER_CLK_TYPE_FIXED_RATE 2 |
| 17 | #define UNIPHIER_CLK_TYPE_GATE 3 |
| 18 | #define UNIPHIER_CLK_TYPE_MUX 4 |
| 19 | |
| 20 | #define UNIPHIER_CLK_ID_INVALID (U8_MAX) |
| 21 | |
| 22 | struct uniphier_clk_fixed_rate_data { |
| 23 | unsigned long fixed_rate; |
| 24 | }; |
Masahiro Yamada | 8bdfe0a | 2016-10-17 22:18:01 +0900 | [diff] [blame] | 25 | |
Masahiro Yamada | e4dfb05 | 2016-02-02 21:11:32 +0900 | [diff] [blame] | 26 | struct uniphier_clk_gate_data { |
Masahiro Yamada | 4980668 | 2017-10-13 19:21:59 +0900 | [diff] [blame] | 27 | u8 parent_id; |
| 28 | u16 reg; |
| 29 | u8 bit; |
Masahiro Yamada | e4dfb05 | 2016-02-02 21:11:32 +0900 | [diff] [blame] | 30 | }; |
| 31 | |
Masahiro Yamada | 8bdfe0a | 2016-10-17 22:18:01 +0900 | [diff] [blame] | 32 | struct uniphier_clk_mux_data { |
Masahiro Yamada | 4980668 | 2017-10-13 19:21:59 +0900 | [diff] [blame] | 33 | u8 parent_ids[UNIPHIER_CLK_MUX_MAX_PARENTS]; |
| 34 | u8 num_parents; |
| 35 | u16 reg; |
| 36 | u32 masks[UNIPHIER_CLK_MUX_MAX_PARENTS]; |
| 37 | u32 vals[UNIPHIER_CLK_MUX_MAX_PARENTS]; |
Masahiro Yamada | e4dfb05 | 2016-02-02 21:11:32 +0900 | [diff] [blame] | 38 | }; |
| 39 | |
Masahiro Yamada | 8bdfe0a | 2016-10-17 22:18:01 +0900 | [diff] [blame] | 40 | struct uniphier_clk_data { |
Masahiro Yamada | 4980668 | 2017-10-13 19:21:59 +0900 | [diff] [blame] | 41 | u8 type; |
| 42 | u8 id; |
| 43 | union { |
| 44 | struct uniphier_clk_fixed_rate_data rate; |
| 45 | struct uniphier_clk_gate_data gate; |
| 46 | struct uniphier_clk_mux_data mux; |
| 47 | } data; |
Masahiro Yamada | e4dfb05 | 2016-02-02 21:11:32 +0900 | [diff] [blame] | 48 | }; |
| 49 | |
Masahiro Yamada | 4980668 | 2017-10-13 19:21:59 +0900 | [diff] [blame] | 50 | #define UNIPHIER_CLK_RATE(_id, _rate) \ |
| 51 | { \ |
| 52 | .type = UNIPHIER_CLK_TYPE_FIXED_RATE, \ |
| 53 | .id = (_id), \ |
| 54 | .data.rate = { \ |
| 55 | .fixed_rate = (_rate), \ |
| 56 | }, \ |
Masahiro Yamada | e4dfb05 | 2016-02-02 21:11:32 +0900 | [diff] [blame] | 57 | } |
| 58 | |
Masahiro Yamada | 4980668 | 2017-10-13 19:21:59 +0900 | [diff] [blame] | 59 | #define UNIPHIER_CLK_GATE(_id, _parent, _reg, _bit) \ |
| 60 | { \ |
| 61 | .type = UNIPHIER_CLK_TYPE_GATE, \ |
| 62 | .id = (_id), \ |
| 63 | .data.gate = { \ |
| 64 | .parent_id = (_parent), \ |
| 65 | .reg = (_reg), \ |
| 66 | .bit = (_bit), \ |
| 67 | }, \ |
Masahiro Yamada | 8bdfe0a | 2016-10-17 22:18:01 +0900 | [diff] [blame] | 68 | } |
| 69 | |
Masahiro Yamada | 4980668 | 2017-10-13 19:21:59 +0900 | [diff] [blame] | 70 | #define UNIPHIER_CLK_GATE_SIMPLE(_id, _reg, _bit) \ |
| 71 | UNIPHIER_CLK_GATE(_id, UNIPHIER_CLK_ID_INVALID, _reg, _bit) |
| 72 | |
| 73 | extern const struct uniphier_clk_data uniphier_pxs2_sys_clk_data[]; |
| 74 | extern const struct uniphier_clk_data uniphier_ld20_sys_clk_data[]; |
Masahiro Yamada | 52cdec0 | 2017-10-13 19:22:00 +0900 | [diff] [blame] | 75 | extern const struct uniphier_clk_data uniphier_pxs3_sys_clk_data[]; |
Masahiro Yamada | 4980668 | 2017-10-13 19:21:59 +0900 | [diff] [blame] | 76 | extern const struct uniphier_clk_data uniphier_mio_clk_data[]; |
Masahiro Yamada | e4dfb05 | 2016-02-02 21:11:32 +0900 | [diff] [blame] | 77 | |
| 78 | #endif /* __CLK_UNIPHIER_H__ */ |