blob: aa8d97b2d4171f87b65791d9567abe5f17f81fcb [file] [log] [blame]
Taniya Das8436bd72016-11-21 17:50:13 +05301/*
2 * Copyright (c) 2017, The Linux Foundation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#ifndef __QCOM_CLK_DEBUG_H__
15#define __QCOM_CLK_DEBUG_H__
16
17#include "../clk.h"
18
19/* Debugfs Measure Clocks */
20
21/**
22 * struct measure_clk_data - Structure of clk measure
23 *
24 * @cxo: XO clock.
25 * @xo_div4_cbcr: offset of debug XO/4 div register.
26 * @ctl_reg: offset of debug control register.
27 * @status_reg: offset of debug status register.
28 * @cbcr_offset: branch register to turn on debug mux.
29 */
30struct measure_clk_data {
31 struct clk *cxo;
32 u32 ctl_reg;
33 u32 status_reg;
34 u32 xo_div4_cbcr;
35};
36
37/**
38 * List of Debug clock controllers.
39 */
40enum debug_cc {
41 GCC,
42 CAM_CC,
43 DISP_CC,
44 GPU_CC,
45 VIDEO_CC,
46 CPU,
47};
48
49/**
50 * struct clk_src - Structure of clock source for debug mux
51 *
52 * @parents: clock name to be used as parent for debug mux.
53 * @prim_mux_sel: debug mux index at global clock controller.
54 * @prim_mux_div_val: PLL post-divider setting for the primary mux.
55 * @dbg_cc: indicates the clock controller for recursive debug
56 * clock controllers.
57 * @dbg_cc_mux_sel: indicates the debug mux index at recursive debug mux.
58 * @mux_sel_mask: indicates the mask for the mux selection.
59 * @mux_sel_shift: indicates the shift required for mux selection.
60 * @post_div_mask: indicates the post div mask to be used at recursive
61 * debug mux.
62 * @post_div_shift: indicates the shift required for post divider
63 * configuration.
64 * @post_div_val: indicates the post div value to be used at recursive
65 * debug mux.
66 * @mux_offset: the debug mux offset.
67 * @post_div_offset: register with post-divider settings for the debug mux.
68 * @cbcr_offset: branch register to turn on debug mux.
Deepak Katragadda1a11bd42017-04-24 15:46:39 -070069 * @misc_div_val: includes any pre-set dividers in the measurement logic.
Taniya Das8436bd72016-11-21 17:50:13 +053070 */
71struct clk_src {
72 const char *parents;
73 int prim_mux_sel;
74 u32 prim_mux_div_val;
75 enum debug_cc dbg_cc;
76 int dbg_cc_mux_sel;
77 u32 mux_sel_mask;
78 u32 mux_sel_shift;
79 u32 post_div_mask;
80 u32 post_div_shift;
81 u32 post_div_val;
82 u32 mux_offset;
83 u32 post_div_offset;
84 u32 cbcr_offset;
Deepak Katragadda1a11bd42017-04-24 15:46:39 -070085 u32 misc_div_val;
Taniya Das8436bd72016-11-21 17:50:13 +053086};
87
88#define MUX_SRC_LIST(...) \
89 .parent = (struct clk_src[]){__VA_ARGS__}, \
90 .num_parents = ARRAY_SIZE(((struct clk_src[]){__VA_ARGS__}))
91
92/**
93 * struct clk_debug_mux - Structure of clock debug mux
94 *
95 * @parent: structure of clk_src
96 * @num_parents: number of parents
97 * @regmap: regmaps of debug mux
98 * @priv: private measure_clk_data to be used by debug mux
99 * @debug_offset: debug mux offset.
100 * @post_div_offset: register with post-divider settings for the debug mux.
101 * @cbcr_offset: branch register to turn on debug mux.
102 * @src_sel_mask: indicates the mask to be used for src selection in
103 primary mux.
104 * @src_sel_shift: indicates the shift required for source selection in
105 primary mux.
106 * @post_div_mask: indicates the post div mask to be used for the primary
107 mux.
108 * @post_div_shift: indicates the shift required for post divider
109 selection in primary mux.
110 * @hw: handle between common and hardware-specific interfaces.
111 */
112struct clk_debug_mux {
113 struct clk_src *parent;
114 int num_parents;
115 struct regmap **regmap;
116 void *priv;
117 u32 debug_offset;
118 u32 post_div_offset;
119 u32 cbcr_offset;
120 u32 src_sel_mask;
121 u32 src_sel_shift;
122 u32 post_div_mask;
123 u32 post_div_shift;
124 struct clk_hw hw;
125};
126
127#define to_clk_measure(_hw) container_of((_hw), struct clk_debug_mux, hw)
128
129extern const struct clk_ops clk_debug_mux_ops;
130
131int clk_debug_measure_register(struct clk_hw *hw);
132int clk_debug_measure_add(struct clk_hw *hw, struct dentry *dentry);
133
134#endif