• 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 clk_bulk_data *clks;
31 	int num_clks;
32 	unsigned long volt_rm;
33 	u32 current_rm;
34 };
35 
36 #if IS_ENABLED(CONFIG_ROCKCHIP_OPP)
37 int rockchip_of_get_leakage(struct device *dev, char *lkg_name, int *leakage);
38 void rockchip_of_get_lkg_sel(struct device *dev, struct device_node *np,
39 			     char *lkg_name, int process,
40 			     int *volt_sel, int *scale_sel);
41 void rockchip_of_get_pvtm_sel(struct device *dev, struct device_node *np,
42 			      char *reg_name, int process,
43 			      int *volt_sel, int *scale_sel);
44 void rockchip_of_get_bin_sel(struct device *dev, struct device_node *np,
45 			     int bin, int *scale_sel);
46 void rockchip_of_get_bin_volt_sel(struct device *dev, struct device_node *np,
47 				  int bin, int *bin_volt_sel);
48 int rockchip_nvmem_cell_read_u8(struct device_node *np, const char *cell_id,
49 				u8 *val);
50 int rockchip_nvmem_cell_read_u16(struct device_node *np, const char *cell_id,
51 				 u16 *val);
52 int rockchip_get_volt_rm_table(struct device *dev, struct device_node *np,
53 			       char *porp_name, struct volt_rm_table **table);
54 void rockchip_get_opp_data(const struct of_device_id *matches,
55 			   struct rockchip_opp_info *info);
56 void rockchip_get_scale_volt_sel(struct device *dev, char *lkg_name,
57 				 char *reg_name, int bin, int process,
58 				 int *scale, int *volt_sel);
59 struct opp_table *rockchip_set_opp_prop_name(struct device *dev, int process,
60 					     int volt_sel);
61 int rockchip_adjust_power_scale(struct device *dev, int scale);
62 int rockchip_init_opp_table(struct device *dev,
63 			    struct rockchip_opp_info *info,
64 			    char *lkg_name, char *reg_name);
65 #else
rockchip_of_get_leakage(struct device * dev,char * lkg_name,int * leakage)66 static inline int rockchip_of_get_leakage(struct device *dev, char *lkg_name,
67 					  int *leakage)
68 {
69 	return -ENOTSUPP;
70 }
71 
rockchip_of_get_lkg_sel(struct device * dev,struct device_node * np,char * lkg_name,int process,int * volt_sel,int * scale_sel)72 static inline void rockchip_of_get_lkg_sel(struct device *dev,
73 					   struct device_node *np,
74 					   char *lkg_name, int process,
75 					   int *volt_sel, int *scale_sel)
76 {
77 }
78 
rockchip_of_get_pvtm_sel(struct device * dev,struct device_node * np,char * reg_name,int process,int * volt_sel,int * scale_sel)79 static inline void rockchip_of_get_pvtm_sel(struct device *dev,
80 					    struct device_node *np,
81 					    char *reg_name, int process,
82 					    int *volt_sel, int *scale_sel)
83 {
84 }
85 
rockchip_of_get_bin_sel(struct device * dev,struct device_node * np,int bin,int * scale_sel)86 static inline void rockchip_of_get_bin_sel(struct device *dev,
87 					   struct device_node *np, int bin,
88 					   int *scale_sel)
89 {
90 }
91 
rockchip_of_get_bin_volt_sel(struct device * dev,struct device_node * np,int bin,int * bin_volt_sel)92 static inline void rockchip_of_get_bin_volt_sel(struct device *dev,
93 						struct device_node *np,
94 						int bin, int *bin_volt_sel)
95 {
96 }
97 
rockchip_nvmem_cell_read_u8(struct device_node * np,const char * cell_id,u8 * val)98 static inline int rockchip_nvmem_cell_read_u8(struct device_node *np,
99 					      const char *cell_id, u8 *val)
100 {
101 	return -EOPNOTSUPP;
102 }
103 
rockchip_nvmem_cell_read_u16(struct device_node * np,const char * cell_id,u16 * val)104 static inline int rockchip_nvmem_cell_read_u16(struct device_node *np,
105 					       const char *cell_id, u16 *val)
106 {
107 	return -EOPNOTSUPP;
108 }
109 
rockchip_get_volt_rm_table(struct device * dev,struct device_node * np,char * porp_name,struct volt_rm_table ** table)110 static inline int rockchip_get_volt_rm_table(struct device *dev,
111 					     struct device_node *np,
112 					     char *porp_name,
113 					     struct volt_rm_table **table)
114 {
115 	return -EOPNOTSUPP;
116 
117 }
118 
rockchip_get_opp_data(const struct of_device_id * matches,struct rockchip_opp_info * info)119 static inline void rockchip_get_opp_data(const struct of_device_id *matches,
120 					 struct rockchip_opp_info *info)
121 {
122 }
123 
rockchip_get_scale_volt_sel(struct device * dev,char * lkg_name,char * reg_name,int bin,int process,int * scale,int * volt_sel)124 static inline void rockchip_get_scale_volt_sel(struct device *dev,
125 					       char *lkg_name, char *reg_name,
126 					       int bin, int process, int *scale,
127 					       int *volt_sel)
128 {
129 }
130 
rockchip_set_opp_prop_name(struct device * dev,int process,int volt_sel)131 static inline struct opp_table *rockchip_set_opp_prop_name(struct device *dev,
132 							   int process,
133 							   int volt_sel)
134 {
135 	return ERR_PTR(-ENOTSUPP);
136 }
137 
rockchip_adjust_power_scale(struct device * dev,int scale)138 static inline int rockchip_adjust_power_scale(struct device *dev, int scale)
139 {
140 	return -ENOTSUPP;
141 }
142 
rockchip_init_opp_table(struct device * dev,struct rockchip_opp_info * info,char * lkg_name,char * reg_name)143 static inline int rockchip_init_opp_table(struct device *dev,
144 					  struct rockchip_opp_info *info,
145 					  char *lkg_name, char *reg_name)
146 {
147 	return -ENOTSUPP;
148 }
149 
150 #endif /* CONFIG_ROCKCHIP_OPP */
151 
152 #endif
153