blob: f76611664437d0c9237f94da613f406a604d70e2 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (C) 2016 MediaTek Inc.
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 as
6 * 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.
11 * See http://www.gnu.org/licenses/gpl-2.0.html for more details.
12 */
13
14struct seq_file;
15
16#define clk_readl(addr) readl(addr)
17#define clk_writel(addr, val) \
18 do { writel(val, addr); wmb(); } while (0) /* sync write */
19#define clk_setl(addr, val) clk_writel(addr, clk_readl(addr) | (val))
20#define clk_clrl(addr, val) clk_writel(addr, clk_readl(addr) & ~(val))
21
22enum FMETER_TYPE {
23 FT_NULL,
24 ABIST,
25 CKGEN
26};
27
28struct fmeter_clk {
29 enum FMETER_TYPE type;
30 u32 id;
31 const char *name;
32};
33
34struct regbase {
35 u32 phys;
36 void __iomem *virt;
37 const char *name;
38};
39
40struct regname {
41 struct regbase *base;
42 u32 ofs;
43 const char *name;
44};
45
46#define ADDR(rn) (rn->base->virt + rn->ofs)
47#define PHYSADDR(rn) (rn->base->phys + rn->ofs)
48
49struct cmd_fn {
50 const char *cmd;
51 int (*fn)(struct seq_file *, void *);
52};
53
54#define CMDFN(_cmd, _fn) { \
55 .cmd = _cmd, \
56 .fn = _fn, \
57}
58
59struct provider_clk {
60 const char *provider_name;
61 u32 idx;
62 struct clk *ck;
63 u32 pwr_mask;
64};
65
66struct clkdbg_ops {
67 const struct fmeter_clk *(*get_all_fmeter_clks)(void);
68 void *(*prepare_fmeter)(void);
69 void (*unprepare_fmeter)(void *data);
70 u32 (*fmeter_freq)(const struct fmeter_clk *fclk);
71 const struct regname *(*get_all_regnames)(void);
72 const char * const *(*get_all_clk_names)(void);
73 const char * const *(*get_pwr_names)(void);
74 void (*setup_provider_clk)(struct provider_clk *pvdck);
75 u32 (*get_spm_pwr_status)(void);
76};
77
78void set_clkdbg_ops(const struct clkdbg_ops *ops);
79void set_custom_cmds(const struct cmd_fn *cmds);
80
81struct provider_clk *get_all_provider_clks(void);
82const char *get_last_cmd(void);
83
84void reg_pdrv(const char *pdname);
85void unreg_pdrv(const char *pdname);
86void prepare_enable_provider(const char *pvd);
87void disable_unprepare_provider(const char *pvd);
88
89void print_regs(void);
90void print_fmeter_all(void);