1 /* 2 * Copyright (C) 2016 Socionext Inc. 3 * Author: Masahiro Yamada <yamada.masahiro@socionext.com> 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> 12 #include <linux/types.h> 13 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 }; 26 27 struct uniphier_clk_gate_data { 28 u8 parent_id; 29 u16 reg; 30 u8 bit; 31 }; 32 33 struct uniphier_clk_mux_data { 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]; 39 }; 40 41 struct uniphier_clk_data { 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; 49 }; 50 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 }, \ 58 } 59 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 }, \ 69 } 70 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[]; 76 extern const struct uniphier_clk_data uniphier_pxs3_sys_clk_data[]; 77 extern const struct uniphier_clk_data uniphier_mio_clk_data[]; 78 79 #endif /* __CLK_UNIPHIER_H__ */ 80