1 /* 2 * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms and conditions of the GNU General Public License, 6 * version 2, as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 * more details. 12 */ 13 #ifndef __SOC_ROCKCHIP_DMC_H 14 #define __SOC_ROCKCHIP_DMC_H 15 16 #include <linux/devfreq.h> 17 18 /* for lcdc_type */ 19 #define SCREEN_NULL 0 20 #define SCREEN_RGB 1 21 #define SCREEN_LVDS 2 22 #define SCREEN_DUAL_LVDS 3 23 #define SCREEN_MCU 4 24 #define SCREEN_TVOUT 5 25 #define SCREEN_HDMI 6 26 #define SCREEN_MIPI 7 27 #define SCREEN_DUAL_MIPI 8 28 #define SCREEN_EDP 9 29 #define SCREEN_TVOUT_TEST 10 30 #define SCREEN_LVDS_10BIT 11 31 #define SCREEN_DUAL_LVDS_10BIT 12 32 #define SCREEN_DP 13 33 34 #define DMCFREQ_TABLE_END ~1u 35 36 struct freq_map_table { 37 unsigned int min; 38 unsigned int max; 39 unsigned long freq; 40 }; 41 42 struct rl_map_table { 43 unsigned int pn; /* panel number */ 44 unsigned int rl; /* readlatency */ 45 }; 46 47 struct dmcfreq_common_info { 48 struct device *dev; 49 struct devfreq *devfreq; 50 struct freq_map_table *vop_bw_tbl; 51 struct freq_map_table *vop_frame_bw_tbl; 52 struct rl_map_table *vop_pn_rl_tbl; 53 struct delayed_work msch_rl_work; 54 unsigned long vop_req_rate; 55 unsigned int read_latency; 56 unsigned int auto_freq_en; 57 bool is_msch_rl_work_started; 58 int (*set_msch_readlatency)(unsigned int rl); 59 }; 60 61 struct dmcfreq_vop_info { 62 unsigned int line_bw_mbyte; 63 unsigned int frame_bw_mbyte; 64 unsigned int plane_num; 65 }; 66 67 #if IS_ENABLED(CONFIG_ARM_ROCKCHIP_DMC_DEVFREQ) 68 void rockchip_dmcfreq_lock(void); 69 void rockchip_dmcfreq_lock_nested(void); 70 void rockchip_dmcfreq_unlock(void); 71 int rockchip_dmcfreq_write_trylock(void); 72 void rockchip_dmcfreq_write_unlock(void); 73 int rockchip_dmcfreq_wait_complete(void); 74 int rockchip_dmcfreq_vop_bandwidth_init(struct dmcfreq_common_info *info); 75 int rockchip_dmcfreq_vop_bandwidth_request(struct dmcfreq_vop_info *vop_info); 76 void rockchip_dmcfreq_vop_bandwidth_update(struct dmcfreq_vop_info *vop_info); 77 #else rockchip_dmcfreq_lock(void)78static inline void rockchip_dmcfreq_lock(void) 79 { 80 } 81 rockchip_dmcfreq_lock_nested(void)82static inline void rockchip_dmcfreq_lock_nested(void) 83 { 84 } 85 rockchip_dmcfreq_unlock(void)86static inline void rockchip_dmcfreq_unlock(void) 87 { 88 } 89 rockchip_dmcfreq_write_trylock(void)90static inline int rockchip_dmcfreq_write_trylock(void) 91 { 92 return 0; 93 } 94 rockchip_dmcfreq_write_unlock(void)95static inline void rockchip_dmcfreq_write_unlock(void) 96 { 97 } 98 rockchip_dmcfreq_wait_complete(void)99static inline int rockchip_dmcfreq_wait_complete(void) 100 { 101 return 0; 102 } 103 104 static inline int rockchip_dmcfreq_vop_bandwidth_request(struct dmcfreq_vop_info * vop_info)105rockchip_dmcfreq_vop_bandwidth_request(struct dmcfreq_vop_info *vop_info) 106 { 107 return 0; 108 } 109 110 static inline void rockchip_dmcfreq_vop_bandwidth_update(struct dmcfreq_vop_info * vop_info)111rockchip_dmcfreq_vop_bandwidth_update(struct dmcfreq_vop_info *vop_info) 112 { 113 } 114 115 static inline void rockchip_dmcfreq_vop_bandwidth_init(struct dmcfreq_common_info * info)116rockchip_dmcfreq_vop_bandwidth_init(struct dmcfreq_common_info *info) 117 { 118 } 119 #endif 120 121 #endif 122