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