| .. | .. |
|---|
| 6 | 6 | #ifndef __SOC_ROCKCHIP_OPP_SELECT_H |
|---|
| 7 | 7 | #define __SOC_ROCKCHIP_OPP_SELECT_H |
|---|
| 8 | 8 | |
|---|
| 9 | +#define VOLT_RM_TABLE_END ~1 |
|---|
| 10 | + |
|---|
| 11 | +/* |
|---|
| 12 | + * [0]: set intermediate rate |
|---|
| 13 | + * [1]: scaling up rate or scaling down rate |
|---|
| 14 | + * [1]: add length for pvtpll |
|---|
| 15 | + * [2:5]: length |
|---|
| 16 | + * [2]: use low length for pvtpll |
|---|
| 17 | + * [3:5]: reserved |
|---|
| 18 | + */ |
|---|
| 19 | +#define OPP_RATE_MASK 0x3f |
|---|
| 20 | + |
|---|
| 21 | +/* Set intermediate rate */ |
|---|
| 22 | +#define OPP_INTERMEDIATE_RATE BIT(0) |
|---|
| 23 | +#define OPP_SCALING_UP_RATE BIT(1) |
|---|
| 24 | +#define OPP_SCALING_UP_INTER (OPP_INTERMEDIATE_RATE | OPP_SCALING_UP_RATE) |
|---|
| 25 | +#define OPP_SCALING_DOWN_INTER OPP_INTERMEDIATE_RATE |
|---|
| 26 | + |
|---|
| 27 | +/* Add length for pvtpll */ |
|---|
| 28 | +#define OPP_ADD_LENGTH BIT(1) |
|---|
| 29 | +#define OPP_LENGTH_MASK 0xf |
|---|
| 30 | +#define OPP_LENGTH_SHIFT 2 |
|---|
| 31 | + |
|---|
| 32 | +/* Use low length for pvtpll */ |
|---|
| 33 | +#define OPP_LENGTH_LOW BIT(2) |
|---|
| 34 | + |
|---|
| 35 | +struct rockchip_opp_info; |
|---|
| 36 | + |
|---|
| 37 | +struct volt_rm_table { |
|---|
| 38 | + int volt; |
|---|
| 39 | + int rm; |
|---|
| 40 | +}; |
|---|
| 41 | + |
|---|
| 42 | +struct rockchip_opp_data { |
|---|
| 43 | + int (*get_soc_info)(struct device *dev, struct device_node *np, |
|---|
| 44 | + int *bin, int *process); |
|---|
| 45 | + int (*set_soc_info)(struct device *dev, struct device_node *np, |
|---|
| 46 | + int bin, int process, int volt_sel); |
|---|
| 47 | + int (*set_read_margin)(struct device *dev, |
|---|
| 48 | + struct rockchip_opp_info *opp_info, |
|---|
| 49 | + u32 rm); |
|---|
| 50 | +}; |
|---|
| 51 | + |
|---|
| 52 | +struct pvtpll_opp_table { |
|---|
| 53 | + unsigned long rate; |
|---|
| 54 | + unsigned long u_volt; |
|---|
| 55 | + unsigned long u_volt_min; |
|---|
| 56 | + unsigned long u_volt_max; |
|---|
| 57 | + unsigned long u_volt_mem; |
|---|
| 58 | + unsigned long u_volt_mem_min; |
|---|
| 59 | + unsigned long u_volt_mem_max; |
|---|
| 60 | +}; |
|---|
| 61 | + |
|---|
| 62 | +struct rockchip_opp_info { |
|---|
| 63 | + struct device *dev; |
|---|
| 64 | + struct pvtpll_opp_table *opp_table; |
|---|
| 65 | + const struct rockchip_opp_data *data; |
|---|
| 66 | + struct volt_rm_table *volt_rm_tbl; |
|---|
| 67 | + struct regmap *grf; |
|---|
| 68 | + struct regmap *dsu_grf; |
|---|
| 69 | + struct clk_bulk_data *clks; |
|---|
| 70 | + struct clk *scmi_clk; |
|---|
| 71 | + /* The threshold frequency for set intermediate rate */ |
|---|
| 72 | + unsigned long intermediate_threshold_freq; |
|---|
| 73 | + unsigned int pvtpll_avg_offset; |
|---|
| 74 | + unsigned int pvtpll_min_rate; |
|---|
| 75 | + unsigned int pvtpll_volt_step; |
|---|
| 76 | + int num_clks; |
|---|
| 77 | + /* The read margin for low voltage */ |
|---|
| 78 | + u32 low_rm; |
|---|
| 79 | + u32 current_rm; |
|---|
| 80 | + u32 target_rm; |
|---|
| 81 | +}; |
|---|
| 82 | + |
|---|
| 9 | 83 | #if IS_ENABLED(CONFIG_ROCKCHIP_OPP) |
|---|
| 10 | 84 | int rockchip_of_get_leakage(struct device *dev, char *lkg_name, int *leakage); |
|---|
| 11 | 85 | void rockchip_of_get_lkg_sel(struct device *dev, struct device_node *np, |
|---|
| 12 | 86 | char *lkg_name, int process, |
|---|
| 13 | 87 | int *volt_sel, int *scale_sel); |
|---|
| 88 | +void rockchip_pvtpll_calibrate_opp(struct rockchip_opp_info *info); |
|---|
| 89 | +void rockchip_pvtpll_add_length(struct rockchip_opp_info *info); |
|---|
| 14 | 90 | void rockchip_of_get_pvtm_sel(struct device *dev, struct device_node *np, |
|---|
| 15 | 91 | char *reg_name, int process, |
|---|
| 16 | 92 | int *volt_sel, int *scale_sel); |
|---|
| .. | .. |
|---|
| 22 | 98 | u8 *val); |
|---|
| 23 | 99 | int rockchip_nvmem_cell_read_u16(struct device_node *np, const char *cell_id, |
|---|
| 24 | 100 | u16 *val); |
|---|
| 25 | | -void rockchip_get_soc_info(struct device *dev, |
|---|
| 26 | | - const struct of_device_id *matches, |
|---|
| 27 | | - int *bin, int *process); |
|---|
| 101 | +int rockchip_get_volt_rm_table(struct device *dev, struct device_node *np, |
|---|
| 102 | + char *porp_name, struct volt_rm_table **table); |
|---|
| 103 | +void rockchip_get_opp_data(const struct of_device_id *matches, |
|---|
| 104 | + struct rockchip_opp_info *info); |
|---|
| 28 | 105 | void rockchip_get_scale_volt_sel(struct device *dev, char *lkg_name, |
|---|
| 29 | 106 | char *reg_name, int bin, int process, |
|---|
| 30 | 107 | int *scale, int *volt_sel); |
|---|
| 31 | 108 | struct opp_table *rockchip_set_opp_prop_name(struct device *dev, int process, |
|---|
| 32 | 109 | int volt_sel); |
|---|
| 33 | 110 | int rockchip_adjust_power_scale(struct device *dev, int scale); |
|---|
| 111 | +int rockchip_get_read_margin(struct device *dev, |
|---|
| 112 | + struct rockchip_opp_info *opp_info, |
|---|
| 113 | + unsigned long volt, u32 *target_rm); |
|---|
| 114 | +int rockchip_set_read_margin(struct device *dev, |
|---|
| 115 | + struct rockchip_opp_info *opp_info, u32 rm, |
|---|
| 116 | + bool is_set_rm); |
|---|
| 117 | +int rockchip_init_read_margin(struct device *dev, |
|---|
| 118 | + struct rockchip_opp_info *opp_info, |
|---|
| 119 | + char *reg_name); |
|---|
| 120 | +int rockchip_set_intermediate_rate(struct device *dev, |
|---|
| 121 | + struct rockchip_opp_info *opp_info, |
|---|
| 122 | + struct clk *clk, unsigned long old_freq, |
|---|
| 123 | + unsigned long new_freq, bool is_scaling_up, |
|---|
| 124 | + bool is_set_clk); |
|---|
| 34 | 125 | int rockchip_init_opp_table(struct device *dev, |
|---|
| 35 | | - const struct of_device_id *matches, |
|---|
| 126 | + struct rockchip_opp_info *info, |
|---|
| 36 | 127 | char *lkg_name, char *reg_name); |
|---|
| 37 | 128 | #else |
|---|
| 38 | 129 | static inline int rockchip_of_get_leakage(struct device *dev, char *lkg_name, |
|---|
| 39 | 130 | int *leakage) |
|---|
| 40 | 131 | { |
|---|
| 41 | | - return -ENOTSUPP; |
|---|
| 132 | + return -EOPNOTSUPP; |
|---|
| 42 | 133 | } |
|---|
| 43 | 134 | |
|---|
| 44 | 135 | static inline void rockchip_of_get_lkg_sel(struct device *dev, |
|---|
| 45 | 136 | struct device_node *np, |
|---|
| 46 | 137 | char *lkg_name, int process, |
|---|
| 47 | 138 | int *volt_sel, int *scale_sel) |
|---|
| 139 | +{ |
|---|
| 140 | +} |
|---|
| 141 | + |
|---|
| 142 | +static inline void rockchip_pvtpll_calibrate_opp(struct rockchip_opp_info *info) |
|---|
| 143 | +{ |
|---|
| 144 | +} |
|---|
| 145 | + |
|---|
| 146 | +static inline void rockchip_pvtpll_add_length(struct rockchip_opp_info *info) |
|---|
| 48 | 147 | { |
|---|
| 49 | 148 | } |
|---|
| 50 | 149 | |
|---|
| .. | .. |
|---|
| 79 | 178 | return -EOPNOTSUPP; |
|---|
| 80 | 179 | } |
|---|
| 81 | 180 | |
|---|
| 82 | | -static inline void rockchip_get_soc_info(struct device *dev, |
|---|
| 83 | | - const struct of_device_id *matches, |
|---|
| 84 | | - int *bin, int *process) |
|---|
| 181 | +static inline int rockchip_get_volt_rm_table(struct device *dev, |
|---|
| 182 | + struct device_node *np, |
|---|
| 183 | + char *porp_name, |
|---|
| 184 | + struct volt_rm_table **table) |
|---|
| 185 | +{ |
|---|
| 186 | + return -EOPNOTSUPP; |
|---|
| 187 | + |
|---|
| 188 | +} |
|---|
| 189 | + |
|---|
| 190 | +static inline void rockchip_get_opp_data(const struct of_device_id *matches, |
|---|
| 191 | + struct rockchip_opp_info *info) |
|---|
| 85 | 192 | { |
|---|
| 86 | 193 | } |
|---|
| 87 | 194 | |
|---|
| .. | .. |
|---|
| 96 | 203 | int process, |
|---|
| 97 | 204 | int volt_sel) |
|---|
| 98 | 205 | { |
|---|
| 99 | | - return ERR_PTR(-ENOTSUPP); |
|---|
| 206 | + return ERR_PTR(-EOPNOTSUPP); |
|---|
| 100 | 207 | } |
|---|
| 101 | 208 | |
|---|
| 102 | 209 | static inline int rockchip_adjust_power_scale(struct device *dev, int scale) |
|---|
| 103 | 210 | { |
|---|
| 104 | | - return -ENOTSUPP; |
|---|
| 211 | + return -EOPNOTSUPP; |
|---|
| 212 | +} |
|---|
| 213 | + |
|---|
| 214 | +static inline int rockchip_get_read_margin(struct device *dev, |
|---|
| 215 | + struct rockchip_opp_info *opp_info, |
|---|
| 216 | + unsigned long volt, u32 *target_rm) |
|---|
| 217 | +{ |
|---|
| 218 | + return -EOPNOTSUPP; |
|---|
| 219 | +} |
|---|
| 220 | +static inline int rockchip_set_read_margin(struct device *dev, |
|---|
| 221 | + struct rockchip_opp_info *opp_info, |
|---|
| 222 | + u32 rm, bool is_set_rm) |
|---|
| 223 | +{ |
|---|
| 224 | + return -EOPNOTSUPP; |
|---|
| 225 | +} |
|---|
| 226 | + |
|---|
| 227 | +static inline int rockchip_init_read_margin(struct device *dev, |
|---|
| 228 | + struct rockchip_opp_info *opp_info, |
|---|
| 229 | + char *reg_name) |
|---|
| 230 | +{ |
|---|
| 231 | + return -EOPNOTSUPP; |
|---|
| 232 | +} |
|---|
| 233 | + |
|---|
| 234 | +static inline int |
|---|
| 235 | +rockchip_set_intermediate_rate(struct device *dev, |
|---|
| 236 | + struct rockchip_opp_info *opp_info, |
|---|
| 237 | + struct clk *clk, unsigned long old_freq, |
|---|
| 238 | + unsigned long new_freq, bool is_scaling_up, |
|---|
| 239 | + bool is_set_clk) |
|---|
| 240 | +{ |
|---|
| 241 | + return -EOPNOTSUPP; |
|---|
| 105 | 242 | } |
|---|
| 106 | 243 | |
|---|
| 107 | 244 | static inline int rockchip_init_opp_table(struct device *dev, |
|---|
| 108 | | - const struct of_device_id *matches, |
|---|
| 245 | + struct rockchip_opp_info *info, |
|---|
| 109 | 246 | char *lkg_name, char *reg_name) |
|---|
| 110 | 247 | { |
|---|
| 111 | | - return -ENOTSUPP; |
|---|
| 248 | + return -EOPNOTSUPP; |
|---|
| 112 | 249 | } |
|---|
| 113 | 250 | |
|---|
| 114 | 251 | #endif /* CONFIG_ROCKCHIP_OPP */ |
|---|