| rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame] | 1 | /* | 
|  | 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 |  | 
|  | 14 | struct 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 |  | 
|  | 22 | enum FMETER_TYPE { | 
|  | 23 | FT_NULL, | 
|  | 24 | ABIST, | 
|  | 25 | CKGEN | 
|  | 26 | }; | 
|  | 27 |  | 
|  | 28 | struct fmeter_clk { | 
|  | 29 | enum FMETER_TYPE type; | 
|  | 30 | u32 id; | 
|  | 31 | const char *name; | 
|  | 32 | }; | 
|  | 33 |  | 
|  | 34 | struct regbase { | 
|  | 35 | u32 phys; | 
|  | 36 | void __iomem *virt; | 
|  | 37 | const char *name; | 
|  | 38 | }; | 
|  | 39 |  | 
|  | 40 | struct 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 |  | 
|  | 49 | struct 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 |  | 
|  | 59 | struct provider_clk { | 
|  | 60 | const char *provider_name; | 
|  | 61 | u32 idx; | 
|  | 62 | struct clk *ck; | 
|  | 63 | u32 pwr_mask; | 
|  | 64 | }; | 
|  | 65 |  | 
|  | 66 | struct 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 |  | 
|  | 78 | void set_clkdbg_ops(const struct clkdbg_ops *ops); | 
|  | 79 | void set_custom_cmds(const struct cmd_fn *cmds); | 
|  | 80 |  | 
|  | 81 | struct provider_clk *get_all_provider_clks(void); | 
|  | 82 | const char *get_last_cmd(void); | 
|  | 83 |  | 
|  | 84 | void reg_pdrv(const char *pdname); | 
|  | 85 | void unreg_pdrv(const char *pdname); | 
|  | 86 | void prepare_enable_provider(const char *pvd); | 
|  | 87 | void disable_unprepare_provider(const char *pvd); | 
|  | 88 |  | 
|  | 89 | void print_regs(void); | 
|  | 90 | void print_fmeter_all(void); |