Initial commit: Linux kernel 4.19 for Unplugged OS

This commit is contained in:
ziv committed 2025-10-06 13:52:42 +00:00
commit d30235b04c
80519 files changed
+35800681

No files matched your search

@@ -0,0 +1,448 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2021 MediaTek Inc.
*/
#ifndef ___MT_GPUFREQ_INTERNAL_PLAT_H___
#define ___MT_GPUFREQ_INTERNAL_PLAT_H___
/**************************************************
* 0: all on when mtk probe init (freq/ Vgpu/ Vsram_gpu)
* disable DDK power on/off callback
**************************************************/
#define MT_GPUFREQ_POWER_CTL_ENABLE 1
/**************************************************
* (DVFS_ENABLE, CUST_CONFIG)
* (1, 1) -> DVFS enable and init to CUST_INIT_OPP
* (1, 0) -> DVFS enable
* (0, 1) -> DVFS disable but init to CUST_INIT_OPP (do DVFS only onces)
* (0, 0) -> DVFS disable
**************************************************/
#define MT_GPUFREQ_DVFS_ENABLE 1
#define MT_GPUFREQ_CUST_CONFIG 0
#define MT_GPUFREQ_CUST_INIT_OPP (g_opp_table_segment_1[8].gpufreq_khz)
/**************************************************
* DVFS Setting
**************************************************/
#define NUM_OF_OPP_IDX (sizeof(g_opp_table_segment_1) / \
sizeof(g_opp_table_segment_1[0]))
/* On opp table, low vgpu will use the same vsram.
* And hgih vgpu will have the same diff with vsram.
*
* if (vgpu <= FIXED_VSRAM_VOLT_THSRESHOLD) {
* vsram = FIXED_VSRAM_VOLT;
* } else {
* vsram = vgpu + FIXED_VSRAM_VOLT_DIFF;
* }
*/
#define FIXED_VSRAM_VOLT (75000)
#define FIXED_VSRAM_VOLT_THSRESHOLD (75000)
#define FIXED_VSRAM_VOLT_DIFF (0)
/**************************************************
* PMIC Setting
**************************************************/
/* PMIC hardware range:
* vgpu 0.3 ~ 1.19375 V
* vsram_gpu 0.5 ~ 1.29375 V
*/
#define VGPU_MAX_VOLT (119375) /* mV x 100 */
#define VGPU_MIN_VOLT (30000) /* mV x 100 */
#define VSRAM_GPU_MAX_VOLT (129375) /* mV x 100 */
#define VSRAM_GPU_MIN_VOLT (50000) /* mV x 100 */
#define PMIC_STEP (625) /* mV x 100 */
/*
* (-100)mv <= (VSRAM - VGPU) <= (300)mV
*/
#define BUCK_DIFF_MAX (30000) /* mV x 100 */
#define BUCK_DIFF_MIN (-10000) /* mV x 100 */
/**************************************************
* Clock Setting
**************************************************/
#define POSDIV_4_MAX_FREQ (950000) /* KHz */
#define POSDIV_4_MIN_FREQ (375000) /* KHz */
#define POSDIV_8_MAX_FREQ (475000) /* KHz */
#define POSDIV_8_MIN_FREQ (187500) /* KHz */
#define POSDIV_SHIFT (24) /* bit */
#define DDS_SHIFT (14) /* bit */
#define TO_MHZ_HEAD (100)
#define TO_MHZ_TAIL (10)
#define ROUNDING_VALUE (5)
#define MFGPLL_FIN (26) /* MHz */
#define MFGPLL_FH_PLL FH_PLL6
#define MFGPLL_CON1 (g_apmixed_base + 0x026C)
/**************************************************
* Reference Power Setting
**************************************************/
#define GPU_ACT_REF_POWER (1133) /* mW */
#define GPU_ACT_REF_FREQ (950000) /* KHz */
#define GPU_ACT_REF_VOLT (80000) /* mV x 100 */
#define PTPOD_DISABLE_VOLT (75000)
/**************************************************
* Battery Over Current Protect
**************************************************/
#define MT_GPUFREQ_BATT_OC_PROTECT 1
#define MT_GPUFREQ_BATT_OC_LIMIT_FREQ (485000) /* KHz */
/**************************************************
* Battery Percentage Protect
**************************************************/
#define MT_GPUFREQ_BATT_PERCENT_PROTECT 0
#define MT_GPUFREQ_BATT_PERCENT_LIMIT_FREQ (485000) /* KHz */
/**************************************************
* Low Battery Volume Protect
**************************************************/
#define MT_GPUFREQ_LOW_BATT_VOLT_PROTECT 1
#define MT_GPUFREQ_LOW_BATT_VOLT_LIMIT_FREQ (485000) /* KHz */
/**************************************************
* DFD Dump
**************************************************/
#define MT_GPUFREQ_DFD_ENABLE 1
#define MT_GPUFREQ_DFD_DEBUG 0
/**************************************************
* Register Manipulations
**************************************************/
#define READ_REGISTER_UINT32(reg) \
(*(unsigned int * const)(reg))
#define WRITE_REGISTER_UINT32(reg, val) \
((*(unsigned int * const)(reg)) = (val))
#define INREG32(x) \
READ_REGISTER_UINT32((unsigned int *)((void *)(x)))
#define OUTREG32(x, y) \
WRITE_REGISTER_UINT32((unsigned int *)((void *)(x)), (unsigned int)(y))
#define SETREG32(x, y) \
OUTREG32(x, INREG32(x)|(y))
#define CLRREG32(x, y) \
OUTREG32(x, INREG32(x)&~(y))
#define MASKREG32(x, y, z) \
OUTREG32(x, (INREG32(x)&~(y))|(z))
#define DRV_Reg32(addr) INREG32(addr)
#define DRV_WriteReg32(addr, data) OUTREG32(addr, data)
#define DRV_SetReg32(addr, data) SETREG32(addr, data)
#define DRV_ClrReg32(addr, data) CLRREG32(addr, data)
/**************************************************
* Proc Node Definition
**************************************************/
#ifdef CONFIG_PROC_FS
#define PROC_FOPS_RW(name) \
static int mt_ ## name ## _proc_open( \
struct inode *inode, \
struct file *file) \
{ \
return single_open( \
file, \
mt_ ## name ## _proc_show, \
PDE_DATA(inode)); \
} \
static const struct file_operations mt_ ## name ## _proc_fops = \
{ \
.owner = THIS_MODULE, \
.open = mt_ ## name ## _proc_open, \
.read = seq_read, \
.llseek = seq_lseek, \
.release = single_release, \
.write = mt_ ## name ## _proc_write, \
}
#define PROC_FOPS_RO(name) \
static int mt_ ## name ## _proc_open( \
struct inode *inode, \
struct file *file) \
{ \
return single_open( \
file, \
mt_ ## name ## _proc_show, \
PDE_DATA(inode)); \
} \
static const struct file_operations mt_ ## name ## _proc_fops = \
{ \
.owner = THIS_MODULE, \
.open = mt_ ## name ## _proc_open, \
.read = seq_read, \
.llseek = seq_lseek, \
.release = single_release, \
}
#define PROC_ENTRY(name) \
{__stringify(name), &mt_ ## name ## _proc_fops}
#endif
/**************************************************
* Operation Definition
**************************************************/
#define VOLT_NORMALIZATION(volt) \
((volt % 625) ? (volt - (volt % 625) + 625) : volt)
#ifndef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
#define GPUOP(khz, vgpu, vsram, post_divider, aging_margin) \
{ \
.gpufreq_khz = khz, \
.gpufreq_vgpu = vgpu, \
.gpufreq_vsram = vsram, \
.gpufreq_post_divider = post_divider, \
.gpufreq_aging_margin = aging_margin, \
}
/**************************************************
* Enumerations
**************************************************/
enum g_segment_id_enum {
MT6853_SEGMENT = 1,
MT6853T_SEGMENT, //Reserve Segment
};
enum g_posdiv_power_enum {
POSDIV_POWER_1 = 0,
POSDIV_POWER_2,
POSDIV_POWER_4,
POSDIV_POWER_8,
POSDIV_POWER_16,
};
enum g_clock_source_enum {
CLOCK_MAIN = 0,
CLOCK_SUB,
};
enum g_limit_enable_enum {
LIMIT_DISABLE = 0,
LIMIT_ENABLE,
};
enum {
GPUFREQ_LIMIT_PRIO_NONE, /* the lowest priority */
GPUFREQ_LIMIT_PRIO_1,
GPUFREQ_LIMIT_PRIO_2,
GPUFREQ_LIMIT_PRIO_3,
GPUFREQ_LIMIT_PRIO_4,
GPUFREQ_LIMIT_PRIO_5,
GPUFREQ_LIMIT_PRIO_6,
GPUFREQ_LIMIT_PRIO_7,
GPUFREQ_LIMIT_PRIO_8 /* the highest priority */
};
struct gpudvfs_limit {
unsigned int kicker;
char *name;
unsigned int prio;
unsigned int upper_idx;
unsigned int upper_enable;
unsigned int lower_idx;
unsigned int lower_enable;
};
#define LIMIT_IDX_DEFAULT -1
struct gpudvfs_limit limit_table[] = {
{KIR_STRESS, "STRESS", GPUFREQ_LIMIT_PRIO_8,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE},
{KIR_PROC, "PROC", GPUFREQ_LIMIT_PRIO_7,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE},
{KIR_PTPOD, "PTPOD", GPUFREQ_LIMIT_PRIO_6,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE},
{KIR_THERMAL, "THERMAL", GPUFREQ_LIMIT_PRIO_5,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE},
{KIR_BATT_OC, "BATT_OC", GPUFREQ_LIMIT_PRIO_5,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE},
{KIR_BATT_LOW, "BATT_LOW", GPUFREQ_LIMIT_PRIO_5,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE},
{KIR_BATT_PERCENT, "BATT_PERCENT", GPUFREQ_LIMIT_PRIO_5,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE},
{KIR_PBM, "PBM", GPUFREQ_LIMIT_PRIO_5,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE},
{KIR_POLICY, "POLICY", GPUFREQ_LIMIT_PRIO_4,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE,
LIMIT_IDX_DEFAULT, LIMIT_ENABLE},
};
/**************************************************
* Structures
**************************************************/
struct opp_table_info {
unsigned int gpufreq_khz;
unsigned int gpufreq_vgpu;
unsigned int gpufreq_vsram;
enum g_posdiv_power_enum gpufreq_post_divider;
unsigned int gpufreq_aging_margin;
};
struct g_clk_info {
struct clk *clk_mux;
struct clk *clk_main_parent;
struct clk *clk_sub_parent;
struct clk *subsys_bg3d;
struct clk *mtcmos_mfg0;
struct clk *mtcmos_mfg1;
struct clk *mtcmos_mfg2;
struct clk *mtcmos_mfg3;
struct clk *mtcmos_mfg4;
struct clk *mtcmos_mfg5;
struct clk *mtcmos_mfg6;
};
struct g_pmic_info {
struct regulator *reg_vgpu;
struct regulator *reg_vsram_gpu;
};
/**************************************************
* External functions declaration
**************************************************/
extern bool mtk_get_gpu_loading(unsigned int *pLoading);
extern unsigned int mt_get_abist_freq(unsigned int idx);
/**************************************************
* global value definition
**************************************************/
struct opp_table_info *g_opp_table;
/**************************************************
* PTPOD definition
**************************************************/
unsigned int g_ptpod_opp_idx_table_segment[] = {
0, 4, 8, 11,
14, 16, 18, 20,
22, 24, 26, 28,
30, 32, 34, 36
};
/**************************************************
* GPU OPP table definition
**************************************************/
struct opp_table_info g_opp_table_segment_1[] = {
GPUOP(950000, 80000, 80000, POSDIV_POWER_4, 1875), /* 0 sign off */
GPUOP(941000, 79375, 79375, POSDIV_POWER_4, 1875), /* 1 */
GPUOP(932000, 78750, 78750, POSDIV_POWER_4, 1875), /* 2 */
GPUOP(923000, 78125, 78125, POSDIV_POWER_4, 1875), /* 3 */
GPUOP(915000, 77500, 77500, POSDIV_POWER_4, 1875), /* 4 */
GPUOP(906000, 76875, 76875, POSDIV_POWER_4, 1875), /* 5 */
GPUOP(897000, 76250, 76250, POSDIV_POWER_4, 1875), /* 6 */
GPUOP(888000, 75625, 75625, POSDIV_POWER_4, 1875), /* 7 */
GPUOP(880000, 75000, 75000, POSDIV_POWER_4, 1875), /* 8 sign off */
GPUOP(865000, 74375, 75000, POSDIV_POWER_4, 1875), /* 9 */
GPUOP(850000, 73750, 75000, POSDIV_POWER_4, 1875), /*10 */
GPUOP(835000, 73125, 75000, POSDIV_POWER_4, 1875), /*11 */
GPUOP(820000, 72500, 75000, POSDIV_POWER_4, 1875), /*12 */
GPUOP(805000, 71875, 75000, POSDIV_POWER_4, 1875), /*13 */
GPUOP(790000, 71250, 75000, POSDIV_POWER_4, 1875), /*14 */
GPUOP(775000, 70625, 75000, POSDIV_POWER_4, 1875), /*15 */
GPUOP(760000, 70000, 75000, POSDIV_POWER_4, 1250), /*16 */
GPUOP(745000, 69375, 75000, POSDIV_POWER_4, 1250), /*17 */
GPUOP(730000, 68750, 75000, POSDIV_POWER_4, 1250), /*18 */
GPUOP(715000, 68125, 75000, POSDIV_POWER_4, 1250), /*19 */
GPUOP(700000, 67500, 75000, POSDIV_POWER_4, 1250), /*20 */
GPUOP(685000, 66875, 75000, POSDIV_POWER_4, 1250), /*21 */
GPUOP(670000, 66250, 75000, POSDIV_POWER_4, 1250), /*22 */
GPUOP(655000, 65625, 75000, POSDIV_POWER_4, 1250), /*23 */
GPUOP(640000, 65000, 75000, POSDIV_POWER_4, 1250), /*24 sign off */
GPUOP(619000, 64375, 75000, POSDIV_POWER_4, 1250), /*25 */
GPUOP(598000, 63750, 75000, POSDIV_POWER_4, 1250), /*26 */
GPUOP(577000, 63125, 75000, POSDIV_POWER_4, 1250), /*27 */
GPUOP(556000, 62500, 75000, POSDIV_POWER_4, 625), /*28 */
GPUOP(535000, 61875, 75000, POSDIV_POWER_4, 625), /*29 */
GPUOP(515000, 61250, 75000, POSDIV_POWER_4, 625), /*30 */
GPUOP(494000, 60625, 75000, POSDIV_POWER_4, 625), /*31 */
GPUOP(473000, 60000, 75000, POSDIV_POWER_4, 625), /*32 */
GPUOP(452000, 59375, 75000, POSDIV_POWER_4, 625), /*33 */
GPUOP(431000, 58750, 75000, POSDIV_POWER_4, 625), /*34 */
GPUOP(410000, 58125, 75000, POSDIV_POWER_4, 625), /*35 */
GPUOP(390000, 57500, 75000, POSDIV_POWER_4, 625), /*36 sign off */
};
struct opp_table_info g_opp_table_segment_2[] = {
GPUOP(950000, 80000, 80000, POSDIV_POWER_4, 1875), /* 0 sign off */
GPUOP(941000, 79375, 79375, POSDIV_POWER_4, 1875), /* 1 */
GPUOP(932000, 78750, 78750, POSDIV_POWER_4, 1875), /* 2 */
GPUOP(923000, 78125, 78125, POSDIV_POWER_4, 1875), /* 3 */
GPUOP(915000, 77500, 77500, POSDIV_POWER_4, 1875), /* 4 */
GPUOP(906000, 76875, 76875, POSDIV_POWER_4, 1875), /* 5 */
GPUOP(897000, 76250, 76250, POSDIV_POWER_4, 1875), /* 6 */
GPUOP(888000, 75625, 75625, POSDIV_POWER_4, 1875), /* 7 */
GPUOP(880000, 75000, 75000, POSDIV_POWER_4, 1875), /* 8 sign off */
GPUOP(865000, 74375, 75000, POSDIV_POWER_4, 1875), /* 9 */
GPUOP(850000, 73750, 75000, POSDIV_POWER_4, 1875), /*10 */
GPUOP(835000, 73125, 75000, POSDIV_POWER_4, 1875), /*11 */
GPUOP(820000, 72500, 75000, POSDIV_POWER_4, 1875), /*12 */
GPUOP(805000, 71875, 75000, POSDIV_POWER_4, 1875), /*13 */
GPUOP(790000, 71250, 75000, POSDIV_POWER_4, 1875), /*14 */
GPUOP(775000, 70625, 75000, POSDIV_POWER_4, 1875), /*15 */
GPUOP(760000, 70000, 75000, POSDIV_POWER_4, 1250), /*16 */
GPUOP(745000, 69375, 75000, POSDIV_POWER_4, 1250), /*17 */
GPUOP(730000, 68750, 75000, POSDIV_POWER_4, 1250), /*18 */
GPUOP(715000, 68125, 75000, POSDIV_POWER_4, 1250), /*19 */
GPUOP(700000, 67500, 75000, POSDIV_POWER_4, 1250), /*20 */
GPUOP(685000, 66875, 75000, POSDIV_POWER_4, 1250), /*21 */
GPUOP(670000, 66250, 75000, POSDIV_POWER_4, 1250), /*22 */
GPUOP(655000, 65625, 75000, POSDIV_POWER_4, 1250), /*23 */
GPUOP(640000, 65000, 75000, POSDIV_POWER_4, 1250), /*24 sign off */
GPUOP(619000, 65000, 75000, POSDIV_POWER_4, 1250), /*25 */
GPUOP(598000, 64375, 75000, POSDIV_POWER_4, 1250), /*26 */
GPUOP(577000, 63750, 75000, POSDIV_POWER_4, 1250), /*27 */
GPUOP(556000, 63750, 75000, POSDIV_POWER_4, 625), /*28 */
GPUOP(535000, 63125, 75000, POSDIV_POWER_4, 625), /*29 */
GPUOP(515000, 62500, 75000, POSDIV_POWER_4, 625), /*30 */
GPUOP(494000, 62500, 75000, POSDIV_POWER_4, 625), /*31 */
GPUOP(473000, 61875, 75000, POSDIV_POWER_4, 625), /*32 */
GPUOP(452000, 61250, 75000, POSDIV_POWER_4, 625), /*33 */
GPUOP(431000, 61250, 75000, POSDIV_POWER_4, 625), /*34 */
GPUOP(410000, 60625, 75000, POSDIV_POWER_4, 625), /*35 */
GPUOP(390000, 60000, 75000, POSDIV_POWER_4, 625), /*36 sign off */
};
struct opp_table_info g_opp_table_segment_3[] = {
GPUOP(950000, 80000, 80000, POSDIV_POWER_4, 1875), /* 0 sign off */
GPUOP(941000, 79375, 79375, POSDIV_POWER_4, 1875), /* 1 */
GPUOP(932000, 78750, 78750, POSDIV_POWER_4, 1875), /* 2 */
GPUOP(923000, 78125, 78125, POSDIV_POWER_4, 1875), /* 3 */
GPUOP(915000, 77500, 77500, POSDIV_POWER_4, 1875), /* 4 */
GPUOP(906000, 76875, 76875, POSDIV_POWER_4, 1875), /* 5 */
GPUOP(897000, 76250, 76250, POSDIV_POWER_4, 1875), /* 6 */
GPUOP(888000, 75625, 75625, POSDIV_POWER_4, 1875), /* 7 */
GPUOP(880000, 75000, 75000, POSDIV_POWER_4, 1875), /* 8 sign off */
GPUOP(865000, 74375, 75000, POSDIV_POWER_4, 1875), /* 9 */
GPUOP(850000, 73750, 75000, POSDIV_POWER_4, 1875), /*10 */
GPUOP(835000, 73125, 75000, POSDIV_POWER_4, 1875), /*11 */
GPUOP(820000, 72500, 75000, POSDIV_POWER_4, 1875), /*12 */
GPUOP(805000, 71875, 75000, POSDIV_POWER_4, 1875), /*13 */
GPUOP(790000, 71250, 75000, POSDIV_POWER_4, 1875), /*14 */
GPUOP(775000, 70625, 75000, POSDIV_POWER_4, 1875), /*15 */
GPUOP(760000, 70000, 75000, POSDIV_POWER_4, 1250), /*16 */
GPUOP(745000, 69375, 75000, POSDIV_POWER_4, 1250), /*17 */
GPUOP(730000, 68750, 75000, POSDIV_POWER_4, 1250), /*18 */
GPUOP(715000, 68125, 75000, POSDIV_POWER_4, 1250), /*19 */
GPUOP(700000, 67500, 75000, POSDIV_POWER_4, 1250), /*20 */
GPUOP(685000, 66875, 75000, POSDIV_POWER_4, 1250), /*21 */
GPUOP(670000, 66250, 75000, POSDIV_POWER_4, 1250), /*22 */
GPUOP(655000, 65625, 75000, POSDIV_POWER_4, 1250), /*23 */
GPUOP(640000, 65000, 75000, POSDIV_POWER_4, 1250), /*24 sign off */
GPUOP(619000, 65000, 75000, POSDIV_POWER_4, 1250), /*25 */
GPUOP(598000, 65000, 75000, POSDIV_POWER_4, 1250), /*26 */
GPUOP(577000, 64375, 75000, POSDIV_POWER_4, 1250), /*27 */
GPUOP(556000, 64375, 75000, POSDIV_POWER_4, 625), /*28 */
GPUOP(535000, 64375, 75000, POSDIV_POWER_4, 625), /*29 */
GPUOP(515000, 63750, 75000, POSDIV_POWER_4, 625), /*30 */
GPUOP(494000, 63750, 75000, POSDIV_POWER_4, 625), /*31 */
GPUOP(473000, 63750, 75000, POSDIV_POWER_4, 625), /*32 */
GPUOP(452000, 63125, 75000, POSDIV_POWER_4, 625), /*33 */
GPUOP(431000, 63125, 75000, POSDIV_POWER_4, 625), /*34 */
GPUOP(410000, 63125, 75000, POSDIV_POWER_4, 625), /*35 */
GPUOP(390000, 62500, 75000, POSDIV_POWER_4, 625), /*36 sign off */
};
#endif /* ___MT_GPUFREQ_INTERNAL_PLAT_H___ */
@@ -0,0 +1,175 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2021 MediaTek Inc.
*/
#ifndef ___MT_GPUFREQ_PLAT_H___
#define ___MT_GPUFREQ_PLAT_H___
#include <linux/module.h>
#include <linux/clk.h>
//#include "mtk_ram_console.h"
#define MT_GPUFREQ_BRINGUP 0
#define MT_GPUFREQ_KICKER_PBM_READY 1
#define MT_GPUFREQ_STATIC_PWR_READY2USE 1
#define MT_GPUFREQ_DYNAMIC_POWER_TABLE_UPDATE 1
#define GPUFERQ_TAG "[GPU/DVFS] "
#define gpufreq_pr_info(fmt, args...) pr_info(GPUFERQ_TAG fmt, ##args)
#define gpufreq_pr_debug(fmt, args...) pr_debug(GPUFERQ_TAG fmt, ##args)
#ifdef CONFIG_MTK_GPU_SUPPORT
#define gpufreq_pr_logbuf(fmt, args...) \
do { \
gpufreq_pr_debug(fmt, ##args); \
ged_log_buf_print2(gpufreq_ged_log, GED_LOG_ATTR_TIME, fmt, ##args); \
} while (0)
#else
#define gpufreq_pr_logbuf(fmt, args...) gpufreq_pr_debug(fmt, ##args)
#endif
/* TxCy: Stack x, Core y */
#define T0C0 (1 << 0)
#define T1C0 (1 << 1)
#define T2C0 (1 << 2)
#define T3C0 (1 << 3)
#define T0C1 (1 << 4)
#define T1C1 (1 << 5)
#define T2C1 (1 << 6)
#define T3C1 (1 << 7)
#define T0C2 (1 << 8)
#define T1C2 (1 << 9)
#define T2C2 (1 << 10)
#define T3C2 (1 << 11)
#define T0C3 (1 << 12)
#define T1C3 (1 << 13)
#define T2C3 (1 << 14)
#define T3C3 (1 << 15)
#define T4C0 (1 << 16)
#define T5C0 (1 << 17)
#define T6C0 (1 << 18)
#define T7C0 (1 << 19)
#define T4C1 (1 << 20)
#define T5C1 (1 << 21)
#define T6C1 (1 << 22)
#define T7C1 (1 << 23)
#define MFG2_SHADER_STACK0 (T0C0)
#define MFG3_SHADER_STACK2 (T2C0)
#define MFG5_SHADER_STACK4 (T4C0)
#define MT_GPU_SHADER_PRESENT_3 (T0C0 | T2C0 | T4C0)
struct mt_gpufreq_power_table_info {
unsigned int gpufreq_khz;
unsigned int gpufreq_vgpu;
unsigned int gpufreq_power;
};
enum mt_gpufreq_kicker {
KIR_STRESS,
KIR_PROC,
KIR_PTPOD,
KIR_THERMAL,
KIR_BATT_OC,
KIR_BATT_LOW,
KIR_BATT_PERCENT,
KIR_PBM,
KIR_POLICY,
NUM_OF_KIR
};
enum mt_power_state {
POWER_OFF = 0,
POWER_ON,
};
enum mt_cg_state {
CG_OFF = 0,
CG_ON,
CG_KEEP,
};
enum mt_mtcmos_state {
MTCMOS_OFF = 0,
MTCMOS_ON,
MTCMOS_KEEP,
};
enum mt_buck_state {
BUCK_OFF = 0,
BUCK_ON,
BUCK_KEEP,
};
/**
* MTK GPUFREQ API
*/
extern unsigned int mt_gpufreq_bringup(void);
extern unsigned int mt_gpufreq_not_ready(void);
extern unsigned int mt_gpufreq_get_dvfs_en(void);
extern unsigned int mt_gpufreq_power_ctl_en(void);
extern unsigned int mt_gpufreq_get_cust_init_en(void);
extern unsigned int mt_gpufreq_get_cur_freq_index(void);
extern unsigned int mt_gpufreq_get_cur_freq(void);
extern unsigned int mt_gpufreq_get_limit_user(unsigned int limit_user);
extern unsigned int mt_gpufreq_get_cur_volt(void);
extern unsigned int mt_gpufreq_get_dvfs_table_num(void);
extern unsigned int mt_gpufreq_get_real_dvfs_table_num(void);
extern unsigned int mt_gpufreq_target(unsigned int request_idx,
enum mt_gpufreq_kicker);
extern unsigned int mt_gpufreq_update_volt(unsigned int pmic_volt[],
unsigned int array_size);
extern unsigned int mt_gpufreq_get_freq_by_real_idx(unsigned int idx);
extern unsigned int mt_gpufreq_get_volt_by_real_idx(unsigned int idx);
extern unsigned int mt_gpufreq_get_vsram_by_real_idx(unsigned int idx);
extern unsigned int mt_gpufreq_get_freq_by_idx(unsigned int idx);
extern unsigned int mt_gpufreq_get_volt_by_idx(unsigned int idx);
extern unsigned int mt_gpufreq_get_vsram_by_idx(unsigned int idx);
extern unsigned int mt_gpufreq_get_ori_opp_idx(unsigned int idx);
extern struct mt_gpufreq_power_table_info *pass_gpu_table_to_eara(void);
extern unsigned int mt_gpufreq_get_seg_max_opp_index(void);
extern void mt_gpufreq_thermal_protect(unsigned int limited_power);
extern void mt_gpufreq_restore_default_volt(void);
extern void mt_gpufreq_enable_by_ptpod(void);
extern void mt_gpufreq_disable_by_ptpod(void);
extern unsigned int mt_gpufreq_get_max_power(void);
extern unsigned int mt_gpufreq_get_min_power(void);
extern unsigned int mt_gpufreq_get_thermal_limit_index(void);
extern unsigned int mt_gpufreq_get_thermal_limit_freq(void);
extern void mt_gpufreq_set_power_limit_by_pbm(unsigned int limited_power);
extern unsigned int mt_gpufreq_get_leakage_mw(void);
extern unsigned int mt_gpufreq_get_leakage_no_lock(void);
extern int mt_gpufreq_get_cur_ceiling_idx(void);
extern void mt_gpufreq_set_loading(unsigned int gpu_loading); /* legacy */
extern void mt_gpufreq_power_control(enum mt_power_state, enum mt_cg_state,
enum mt_mtcmos_state, enum mt_buck_state);
extern void mt_gpufreq_set_timestamp(void);
extern void mt_gpufreq_check_bus_idle(void);
extern unsigned int mt_gpufreq_get_shader_present(void);
extern void mt_gpufreq_dump_infra_status(void);
extern int mt_gpufreq_is_dfd_force_dump(void);
extern void mt_gpufreq_software_trigger_dfd(void);
extern void mt_gpufreq_wdt_reset(void);
/**
* power limit notification
*/
typedef void (*gpufreq_power_limit_notify)(unsigned int);
extern void mt_gpufreq_power_limit_notify_registerCB(
gpufreq_power_limit_notify pCB);
/**
* input boost notification
*/
typedef void (*gpufreq_input_boost_notify)(unsigned int);
extern void mt_gpufreq_input_boost_notify_registerCB(
gpufreq_input_boost_notify pCB);
/**
* notify to ged
*/
extern unsigned int (*ged_kpi_get_limit_user_fp)(
unsigned int limit_user);
#endif /* ___MT_GPUFREQ_PLAT_H___ */