• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2017 Fuzhou Rockchip Electronics Co., Ltd
3  *
4  * SPDX-License-Identifier: GPL-2.0+
5  */
6 #ifndef __SOC_ROCKCHIP_OPP_SELECT_H
7 #define __SOC_ROCKCHIP_OPP_SELECT_H
8 
9 #define VOLT_RM_TABLE_END	~1
10 
11 struct rockchip_opp_info;
12 
13 struct volt_rm_table {
14 	int volt;
15 	int rm;
16 };
17 
18 struct rockchip_opp_data {
19 	int (*get_soc_info)(struct device *dev, struct device_node *np,
20 			    int *bin, int *process);
21 	int (*set_read_margin)(struct device *dev,
22 			       struct rockchip_opp_info *opp_info,
23 			       unsigned long volt);
24 };
25 
26 struct rockchip_opp_info {
27 	const struct rockchip_opp_data *data;
28 	struct volt_rm_table *volt_rm_tbl;
29 	struct regmap *grf;
30 	struct regmap *dsu_grf;
31 	struct clk_bulk_data *clks;
32 	int num_clks;
33 	unsigned long volt_rm;
34 	u32 current_rm;
35 };
36 
37 #if IS_ENABLED(CONFIG_ROCKCHIP_OPP)
38 int rockchip_of_get_leakage(struct device *dev, char *lkg_name, int *leakage);
39 void rockchip_of_get_lkg_sel(struct device *dev, struct device_node *np,
40 			     char *lkg_name, int process,
41 			     int *volt_sel, int *scale_sel);
42 void rockchip_of_get_pvtm_sel(struct device *dev, struct device_node *np,
43 			      char *reg_name, int process,
44 			      int *volt_sel, int *scale_sel);
45 void rockchip_of_get_bin_sel(struct device *dev, struct device_node *np,
46 			     int bin, int *scale_sel);
47 void rockchip_of_get_bin_volt_sel(struct device *dev, struct device_node *np,
48 				  int bin, int *bin_volt_sel);
49 int rockchip_nvmem_cell_read_u8(struct device_node *np, const char *cell_id,
50 				u8 *val);
51 int rockchip_nvmem_cell_read_u16(struct device_node *np, const char *cell_id,
52 				 u16 *val);
53 int rockchip_get_volt_rm_table(struct device *dev, struct device_node *np,
54 			       char *porp_name, struct volt_rm_table **table);
55 void rockchip_get_opp_data(const struct of_device_id *matches,
56 			   struct rockchip_opp_info *info);
57 void rockchip_get_scale_volt_sel(struct device *dev, char *lkg_name,
58 				 char *reg_name, int bin, int process,
59 				 int *scale, int *volt_sel);
60 struct opp_table *rockchip_set_opp_prop_name(struct device *dev, int process,
61 					     int volt_sel);
62 int rockchip_adjust_power_scale(struct device *dev, int scale);
63 int rockchip_init_opp_table(struct device *dev,
64 			    struct rockchip_opp_info *info,
65 			    char *lkg_name, char *reg_name);
66 #else
rockchip_of_get_leakage(struct device * dev,char * lkg_name,int * leakage)67 static inline int rockchip_of_get_leakage(struct device *dev, char *lkg_name,
68 					  int *leakage)
69 {
70 	return -ENOTSUPP;
71 }
72 
rockchip_of_get_lkg_sel(struct device * dev,struct device_node * np,char * lkg_name,int process,int * volt_sel,int * scale_sel)73 static inline void rockchip_of_get_lkg_sel(struct device *dev,
74 					   struct device_node *np,
75 					   char *lkg_name, int process,
76 					   int *volt_sel, int *scale_sel)
77 {
78 }
79 
rockchip_of_get_pvtm_sel(struct device * dev,struct device_node * np,char * reg_name,int process,int * volt_sel,int * scale_sel)80 static inline void rockchip_of_get_pvtm_sel(struct device *dev,
81 					    struct device_node *np,
82 					    char *reg_name, int process,
83 					    int *volt_sel, int *scale_sel)
84 {
85 }
86 
rockchip_of_get_bin_sel(struct device * dev,struct device_node * np,int bin,int * scale_sel)87 static inline void rockchip_of_get_bin_sel(struct device *dev,
88 					   struct device_node *np, int bin,
89 					   int *scale_sel)
90 {
91 }
92 
rockchip_of_get_bin_volt_sel(struct device * dev,struct device_node * np,int bin,int * bin_volt_sel)93 static inline void rockchip_of_get_bin_volt_sel(struct device *dev,
94 						struct device_node *np,
95 						int bin, int *bin_volt_sel)
96 {
97 }
98 
rockchip_nvmem_cell_read_u8(struct device_node * np,const char * cell_id,u8 * val)99 static inline int rockchip_nvmem_cell_read_u8(struct device_node *np,
100 					      const char *cell_id, u8 *val)
101 {
102 	return -EOPNOTSUPP;
103 }
104 
rockchip_nvmem_cell_read_u16(struct device_node * np,const char * cell_id,u16 * val)105 static inline int rockchip_nvmem_cell_read_u16(struct device_node *np,
106 					       const char *cell_id, u16 *val)
107 {
108 	return -EOPNOTSUPP;
109 }
110 
rockchip_get_volt_rm_table(struct device * dev,struct device_node * np,char * porp_name,struct volt_rm_table ** table)111 static inline int rockchip_get_volt_rm_table(struct device *dev,
112 					     struct device_node *np,
113 					     char *porp_name,
114 					     struct volt_rm_table **table)
115 {
116 	return -EOPNOTSUPP;
117 
118 }
119 
rockchip_get_opp_data(const struct of_device_id * matches,struct rockchip_opp_info * info)120 static inline void rockchip_get_opp_data(const struct of_device_id *matches,
121 					 struct rockchip_opp_info *info)
122 {
123 }
124 
rockchip_get_scale_volt_sel(struct device * dev,char * lkg_name,char * reg_name,int bin,int process,int * scale,int * volt_sel)125 static inline void rockchip_get_scale_volt_sel(struct device *dev,
126 					       char *lkg_name, char *reg_name,
127 					       int bin, int process, int *scale,
128 					       int *volt_sel)
129 {
130 }
131 
rockchip_set_opp_prop_name(struct device * dev,int process,int volt_sel)132 static inline struct opp_table *rockchip_set_opp_prop_name(struct device *dev,
133 							   int process,
134 							   int volt_sel)
135 {
136 	return ERR_PTR(-ENOTSUPP);
137 }
138 
rockchip_adjust_power_scale(struct device * dev,int scale)139 static inline int rockchip_adjust_power_scale(struct device *dev, int scale)
140 {
141 	return -ENOTSUPP;
142 }
143 
rockchip_init_opp_table(struct device * dev,struct rockchip_opp_info * info,char * lkg_name,char * reg_name)144 static inline int rockchip_init_opp_table(struct device *dev,
145 					  struct rockchip_opp_info *info,
146 					  char *lkg_name, char *reg_name)
147 {
148 	return -ENOTSUPP;
149 }
150 
151 #endif /* CONFIG_ROCKCHIP_OPP */
152 
153 #endif
154