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

+19
View File
@@ -0,0 +1,19 @@
ifneq (,$(filter $(CONFIG_MTK_PLATFORM), "mt6785" "mt6853" "mt6768" "mt6885" "mt6893" "mt6873"))
else
ccflags-y += -I$(srctree)/drivers/misc/mediatek/sspm/
obj-$(CONFIG_MTK_QOS_FRAMEWORK) += mtk_qos.o
mtk_qos-objs := qos-v79.o mtk_qos_common.o mtk_qos_bound.o mtk_qos_sysfs.o
ifneq ($(CONFIG_MACH_MT6761),)
obj-$(CONFIG_MTK_QOS_FRAMEWORK) += mtk_qos_legacy.o
mtk_qos_legacy-objs := qos-v61.o
endif
ifneq ($(CONFIG_MACH_MT6765),)
obj-$(CONFIG_MTK_QOS_FRAMEWORK) += mtk_qos_legacy.o
mtk_qos_legacy-objs := qos-v61.o
endif
endif
+170
View File
@@ -0,0 +1,170 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/io.h>
#include <linux/notifier.h>
#include "mtk_qos_bound.h"
#include "mtk_qos_ipi.h"
#include <sspm_define.h>
#include <sspm_reservedmem.h>
__weak int dram_steps_freq(unsigned int step) { return 0; }
static int qos_bound_enabled;
static int qos_bound_stress_enabled;
static int qos_bound_log_enabled;
static unsigned int qos_bound_count;
static unsigned int qos_bound_buf[3];
static BLOCKING_NOTIFIER_HEAD(qos_bound_chain_head);
static struct qos_bound *bound;
int is_qos_bound_enabled(void)
{
return qos_bound_enabled;
}
void qos_bound_enable(int enable)
{
#if defined(CONFIG_MTK_TINYSYS_SSPM_SUPPORT)
struct qos_ipi_data qos_ipi_d;
qos_ipi_d.cmd = QOS_IPI_QOS_BOUND_ENABLE;
qos_ipi_d.u.qos_bound_enable.enable = enable;
bound = (struct qos_bound *)
sspm_sbuf_get(qos_ipi_to_sspm_command(&qos_ipi_d, 2));
smp_mb(); /* init bound before flag enabled */
#endif
qos_bound_enabled = enable;
}
int is_qos_bound_stress_enabled(void)
{
return qos_bound_stress_enabled;
}
void qos_bound_stress_enable(int enable)
{
#if defined(CONFIG_MTK_TINYSYS_SSPM_SUPPORT)
struct qos_ipi_data qos_ipi_d;
qos_ipi_d.cmd = QOS_IPI_QOS_BOUND_STRESS_ENABLE;
qos_ipi_d.u.qos_bound_stress_enable.enable = enable;
qos_ipi_to_sspm_command(&qos_ipi_d, 2);
#endif
qos_bound_stress_enabled = enable;
}
int is_qos_bound_log_enabled(void)
{
return qos_bound_log_enabled;
}
void qos_bound_log_enable(int enable)
{
qos_bound_log_enabled = enable;
}
unsigned int get_qos_bound_count(void)
{
return qos_bound_count;
}
unsigned int *get_qos_bound_buf(void)
{
return qos_bound_buf;
}
void qos_bound_init(void)
{
qos_bound_enable(1);
}
struct qos_bound *get_qos_bound(void)
{
return bound;
}
int get_qos_bound_bw_threshold(int state)
{
int val = dram_steps_freq(0) * 4;
if (state == QOS_BOUND_BW_FULL)
return val * QOS_BOUND_BW_FULL_PCT / 100;
else if (state == QOS_BOUND_BW_CONGESTIVE)
return val * QOS_BOUND_BW_CONGESTIVE_PCT / 100;
return 0;
}
unsigned short get_qos_bound_idx(void)
{
if (!is_qos_bound_enabled())
return 0;
return bound->idx;
}
int register_qos_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&qos_bound_chain_head, nb);
}
EXPORT_SYMBOL_GPL(register_qos_notifier);
int unregister_qos_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_unregister(&qos_bound_chain_head, nb);
}
EXPORT_SYMBOL_GPL(unregister_qos_notifier);
int qos_notifier_call_chain(unsigned long val, void *v)
{
int ret = NOTIFY_DONE;
struct qos_bound *bound;
struct qos_bound_stat *stat;
unsigned short idx, state;
int i;
if (!is_qos_bound_enabled())
return ret;
if (v == NULL) {
pr_info("detect bound null ptr(%d)\n",
is_qos_bound_enabled());
return ret;
}
bound = (struct qos_bound *) v;
state = bound->state;
if (state > 0 && state <= 4) {
for (i = 0; (state & (1 << i)) == 0; i++)
;
qos_bound_count++;
qos_bound_buf[i]++;
}
if (is_qos_bound_log_enabled()) {
idx = bound->idx;
stat = &bound->stats[bound->idx];
pr_info("idx: %hu, state: %hu, num: %hu, event: %hu\n",
idx, state,
stat->num, stat->event);
for (i = 0; i < NR_QOS_EMIBM_TYPE; i++)
pr_info("emibw [%d]: mon: %hu, req: %hu\n", i,
stat->emibw_mon[i],
stat->emibw_req[i]);
for (i = 0; i < NR_QOS_SMIBM_TYPE; i++)
pr_info("smibw [%d]: mon: %hu, req: %hu\n", i,
stat->smibw_mon[i],
stat->smibw_req[i]);
for (i = 0; i < NR_QOS_LAT_TYPE; i++)
pr_info("lat [%d]: mon: %hu\n", i, stat->lat_mon[i]);
}
ret = blocking_notifier_call_chain(&qos_bound_chain_head, val, v);
return notifier_to_errno(ret);
}
+82
View File
@@ -0,0 +1,82 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __MTK_QOS_BOUND_H__
#define __MTK_QOS_BOUND_H__
#define QOS_BOUND_BUF_SIZE 64
#define QOS_BOUND_BW_FREE 0x1
#define QOS_BOUND_BW_CONGESTIVE 0x2
#define QOS_BOUND_BW_FULL 0x4
#define QOS_BOUND_BW_CONGESTIVE_PCT 70
#define QOS_BOUND_BW_FULL_PCT 95
enum qos_emibm_type {
QOS_EMIBM_TOTAL,
QOS_EMIBM_CPU,
QOS_EMIBM_GPU,
QOS_EMIBM_MM,
QOS_EMIBM_MD,
NR_QOS_EMIBM_TYPE
};
enum qos_smibm_type {
QOS_SMIBM_VENC,
QOS_SMIBM_CAM,
QOS_SMIBM_IMG,
QOS_SMIBM_MDP,
QOS_SMIBM_GPU,
QOS_SMIBM_APU,
QOS_SMIBM_VPU0,
QOS_SMIBM_VPU1,
QOS_SMIBM_MDLA,
NR_QOS_SMIBM_TYPE
};
enum qos_lat_type {
QOS_LAT_CPU,
QOS_LAT_VPU0,
QOS_LAT_VPU1,
QOS_LAT_MDLA,
NR_QOS_LAT_TYPE
};
struct qos_bound_stat {
unsigned short num;
unsigned short event;
unsigned short emibw_mon[NR_QOS_EMIBM_TYPE];
unsigned short emibw_req[NR_QOS_EMIBM_TYPE];
unsigned short smibw_mon[NR_QOS_SMIBM_TYPE];
unsigned short smibw_req[NR_QOS_SMIBM_TYPE];
unsigned short lat_mon[NR_QOS_LAT_TYPE];
};
struct qos_bound {
unsigned short idx;
unsigned short state;
struct qos_bound_stat stats[QOS_BOUND_BUF_SIZE];
};
extern void qos_bound_init(void);
extern struct qos_bound *get_qos_bound(void);
extern int get_qos_bound_bw_threshold(int state);
extern unsigned short get_qos_bound_idx(void);
extern int register_qos_notifier(struct notifier_block *nb);
extern int unregister_qos_notifier(struct notifier_block *nb);
extern int qos_notifier_call_chain(unsigned long val, void *v);
extern int is_qos_bound_enabled(void);
extern void qos_bound_enable(int enable);
extern int is_qos_bound_stress_enabled(void);
extern void qos_bound_stress_enable(int enable);
extern int is_qos_bound_log_enabled(void);
extern void qos_bound_log_enable(int enable);
extern unsigned int get_qos_bound_count(void);
extern unsigned int *get_qos_bound_buf(void);
#endif
+148
View File
@@ -0,0 +1,148 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/device.h>
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/of_device.h>
#include <linux/kthread.h>
#include <sspm_ipi.h>
#include <sspm_ipi_pin.h>
#include "mtk_qos_ipi.h"
#include "mtk_qos_sram.h"
#include "mtk_qos_bound.h"
#include "mtk_qos_sysfs.h"
#include "mtk_qos_common.h"
struct mtk_qos *m_qos;
static void __iomem *qos_sram_base;
static unsigned int qos_sram_bound;
int qos_ipi_to_sspm_command(void *buffer, int slot)
{
#if defined(CONFIG_MTK_TINYSYS_SSPM_SUPPORT)
int ack_data = 0;
struct qos_ipi_data *qos_ipi = buffer;
if (!m_qos)
return -EACCES;
if (m_qos->soc->ipi_pin[qos_ipi->cmd].valid == false)
return -EPERM;
qos_ipi->cmd = m_qos->soc->ipi_pin[qos_ipi->cmd].id;
sspm_ipi_send_sync(IPI_ID_QOS, IPI_OPT_POLLING,
buffer, slot, &ack_data, 1);
return ack_data;
#else
return 0;
#endif
}
void qos_ipi_init(struct mtk_qos *qos)
{
if (qos->soc->qos_ipi_recv_handler)
kthread_run(qos->soc->qos_ipi_recv_handler,
qos, "qos_ipi_recv");
}
u32 qos_sram_read(u32 id)
{
u32 offset;
if (!m_qos)
return 0;
if (m_qos->soc->sram_pin[id].valid == false)
return 0;
if (id >= QOS_SRAM_ID_MAX)
return 0;
offset = m_qos->soc->sram_pin[id].offset;
if (!qos_sram_base || offset >= qos_sram_bound)
return 0;
return readl(qos_sram_base + offset);
}
void qos_sram_write(u32 id, u32 val)
{
u32 offset;
if (!m_qos)
return;
if (m_qos->soc->sram_pin[id].valid == false)
return;
if (id >= QOS_SRAM_ID_MAX)
return;
offset = m_qos->soc->sram_pin[id].offset;
if (!qos_sram_base || offset >= qos_sram_bound)
return;
writel(val, qos_sram_base + offset);
}
void qos_sram_init(void __iomem *regs, unsigned int bound)
{
int i;
qos_sram_base = regs;
qos_sram_bound = bound;
pr_info("qos_sram addr:0x%x len:%d\n",
qos_sram_base, qos_sram_bound);
for (i = 0; i < bound; i += 4)
writel(0x0, qos_sram_base+i);
}
int mtk_qos_probe(struct platform_device *pdev,
const struct mtk_qos_soc *soc)
{
struct resource *res;
struct mtk_qos *qos;
qos = devm_kzalloc(&pdev->dev, sizeof(*qos), GFP_KERNEL);
if (!qos)
return -ENOMEM;
qos->soc = of_device_get_match_data(&pdev->dev);
if (!qos->soc)
return -EINVAL;
qos->soc = soc;
qos->dev = &pdev->dev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
qos->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(qos->regs))
return PTR_ERR(qos->regs);
qos->regsize = (unsigned int) resource_size(res);
m_qos = qos;
qos_sram_init(qos->regs, qos->regsize);
qos_add_interface(&pdev->dev);
qos_ipi_init(qos);
if (qos->soc->ipi_pin[QOS_IPI_QOS_BOUND].valid == true)
qos_bound_init();
platform_set_drvdata(pdev, qos);
pr_info("mtkqos:%s done\n", __func__);
return 0;
}
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("MediaTek QoS driver");
@@ -0,0 +1,32 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __MTK_QOS_COMMON_H__
#define __MTK_QOS_COMMON_H__
#include <sspm_ipi.h>
#include <sspm_ipi_pin.h>
struct mtk_qos;
struct mtk_qos_soc {
const struct qos_ipi_cmd *ipi_pin;
const struct qos_sram_addr *sram_pin;
int (*qos_sspm_init)(void);
int (*qos_ipi_recv_handler)(void *arg);
};
struct mtk_qos {
struct device *dev;
const struct mtk_qos_soc *soc;
int dram_type;
void __iomem *regs;
unsigned int regsize;
};
extern int mtk_qos_probe(struct platform_device *pdev,
const struct mtk_qos_soc *soc);
#endif
+89
View File
@@ -0,0 +1,89 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __MTK_QOS_IPI_H__
#define __MTK_QOS_IPI_H__
struct qos_ipi_cmd {
int id;
bool valid;
};
enum {
QOS_IPI_QOS_ENABLE,
QOS_IPI_SWPM_INIT,
QOS_IPI_UPOWER_DATA_TRANSFER,
QOS_IPI_UPOWER_DUMP_TABLE,
QOS_IPI_GET_GPU_BW,
QOS_IPI_SWPM_ENABLE,
QOS_IPI_QOS_BOUND,
QOS_IPI_QOS_BOUND_ENABLE,
QOS_IPI_QOS_BOUND_STRESS_ENABLE,
QOS_IPI_SMI_MET_MON,
QOS_IPI_SETUP_GPU_INFO,
QOS_IPI_SWPM_SET_UPDATE_CNT,
};
struct qos_ipi_data {
unsigned int cmd;
union {
struct {
unsigned int dvfsrc_en;
unsigned int dram_type;
} dvfsrc_enable;
struct {
unsigned int vcore_dvfs_opp;
unsigned int vcore_uv;
unsigned int ddr_khz;
} opp_table;
struct {
unsigned int vcore_dvfs_opp;
unsigned int vcore_opp;
} vcore_opp;
struct {
unsigned int vcore_dvfs_opp;
unsigned int ddr_opp;
} ddr_opp;
struct {
unsigned int dram_addr;
unsigned int dram_size;
unsigned int dram_ch_num;
} swpm_init;
struct {
unsigned int type;
unsigned int enable;
} swpm_enable;
struct {
unsigned int type;
unsigned int cnt;
} swpm_set_update_cnt;
struct {
unsigned int arg[3];
} upower_data;
struct {
unsigned int state;
} qos_bound;
struct {
unsigned int enable;
} qos_bound_enable;
struct {
unsigned int enable;
} qos_bound_stress_enable;
struct {
unsigned int ena;
unsigned int enc[4];
} smi_met_mon;
struct {
unsigned int addr;
unsigned int addr_hi;
unsigned int size;
} gpu_info;
} u;
};
extern int qos_ipi_to_sspm_command(void *buffer, int slot);
#endif
+46
View File
@@ -0,0 +1,46 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __MTK_QOS_SRAM_H__
#define __MTK_QOS_SRAM_H__
struct qos_sram_addr {
int offset;
bool valid;
};
enum {
QOS_DEBUG_0,
QOS_DEBUG_1,
QOS_DEBUG_2,
QOS_DEBUG_3,
QOS_DEBUG_4,
MM_SMI_VENC,
MM_SMI_CAM,
MM_SMI_IMG,
MM_SMI_MDP,
MM_SMI_CLK,
MM_SMI_CLR,
MM_SMI_EXE,
MM_SMI_DUMP,
APU_CLK,
APU_BW_NORD,
DVFSRC_TIMESTAMP_OFFSET,
CM_STALL_RATIO_ID_0,
CM_STALL_RATIO_ID_1,
CM_STALL_RATIO_ID_2,
CM_STALL_RATIO_ID_3,
CM_STALL_RATIO_ID_4,
CM_STALL_RATIO_ID_5,
CM_STALL_RATIO_ID_6,
CM_STALL_RATIO_ID_7,
QOS_TOTAL_BW,
QOS_SRAM_ID_MAX,
};
extern u32 qos_sram_read(u32 id);
extern void qos_sram_write(u32 id, u32 val);
extern void qos_sram_init(void __iomem *regs, unsigned int bound);
#endif
+102
View File
@@ -0,0 +1,102 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/sysfs.h>
#include "mtk_qos_bound.h"
static ssize_t qos_bound_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", is_qos_bound_enabled());
}
static ssize_t qos_bound_enable_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int val = 0;
if (kstrtoint(buf, 10, &val))
return -EINVAL;
qos_bound_enable(val);
return count;
}
static DEVICE_ATTR_RW(qos_bound_enable);
static ssize_t qos_bound_stress_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", is_qos_bound_stress_enabled());
}
static ssize_t qos_bound_stress_enable_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int val = 0;
if (kstrtoint(buf, 10, &val))
return -EINVAL;
qos_bound_stress_enable(val);
return count;
}
static DEVICE_ATTR_RW(qos_bound_stress_enable);
static ssize_t qos_bound_log_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", is_qos_bound_log_enabled());
}
static ssize_t qos_bound_log_enable_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int val = 0;
if (kstrtoint(buf, 10, &val))
return -EINVAL;
qos_bound_log_enable(val);
return count;
}
static DEVICE_ATTR_RW(qos_bound_log_enable);
static ssize_t qos_bound_status_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned int qos_bound_count = get_qos_bound_count();
unsigned int *qos_bound_buf = get_qos_bound_buf();
return sprintf(buf, "count: %d, free: %d, cong: %d, full: %d\n",
qos_bound_count, qos_bound_buf[0],
qos_bound_buf[1], qos_bound_buf[2]);
}
static DEVICE_ATTR_RO(qos_bound_status);
static struct attribute *qos_attrs[] = {
&dev_attr_qos_bound_enable.attr,
&dev_attr_qos_bound_stress_enable.attr,
&dev_attr_qos_bound_log_enable.attr,
&dev_attr_qos_bound_status.attr,
NULL,
};
static struct attribute_group qos_attr_group = {
.name = "qos",
.attrs = qos_attrs,
};
int qos_add_interface(struct device *dev)
{
return sysfs_create_group(&dev->kobj, &qos_attr_group);
}
void qos_remove_interface(struct device *dev)
{
sysfs_remove_group(&dev->kobj, &qos_attr_group);
}
+12
View File
@@ -0,0 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __MTK_QOS_SYSFS_H__
#define __MTK_QOS_SYSFS_H__
extern int qos_add_interface(struct device *dev);
extern void qos_remove_interface(struct device *dev);
#endif
+236
View File
@@ -0,0 +1,236 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/device.h>
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/of_device.h>
#include <linux/kthread.h>
#include <sspm_ipi.h>
#include <sspm_ipi_pin.h>
#include <linux/arm-smccc.h>
#include <linux/soc/mediatek/mtk_sip_svc.h>
#include "mtk_qos_ipi.h"
#include "mtk_qos_sram.h"
#include "mtk_qos_common.h"
static const struct qos_ipi_cmd mt6761_qos_ipi_pin[] = {
[QOS_IPI_QOS_ENABLE] = {
.id = 0,
.valid = true,
},
[QOS_IPI_QOS_BOUND] = {
.id = 0x100,
.valid = false,
},
[QOS_IPI_QOS_BOUND_ENABLE] = {
.id = 0x100,
.valid = false,
},
[QOS_IPI_QOS_BOUND_STRESS_ENABLE] = {
.id = 0x100,
.valid = false,
},
[QOS_IPI_SWPM_INIT] = {
.id = 5,
.valid = true,
},
[QOS_IPI_UPOWER_DATA_TRANSFER] = {
.id = 6,
.valid = true,
},
[QOS_IPI_UPOWER_DUMP_TABLE] = {
.id = 7,
.valid = true,
},
[QOS_IPI_GET_GPU_BW] = {
.id = 8,
.valid = true,
},
[QOS_IPI_SWPM_ENABLE] = {
.id = 9,
.valid = true,
},
[QOS_IPI_SMI_MET_MON] = {
.id = 0x100,
.valid = false,
},
[QOS_IPI_SETUP_GPU_INFO] = {
.id = 0x100,
.valid = false,
},
[QOS_IPI_SWPM_SET_UPDATE_CNT] = {
.id = 0x100,
.valid = false,
},
};
static const struct qos_sram_addr mt6761_qos_sram_pin[] = {
[QOS_DEBUG_0] = {
.offset = 0x38,
.valid = true,
},
[QOS_DEBUG_1] = {
.offset = 0x3C,
.valid = true,
},
[QOS_DEBUG_2] = {
.offset = 0x40,
.valid = true,
},
[QOS_DEBUG_3] = {
.offset = 0x44,
.valid = true,
},
[QOS_DEBUG_4] = {
.offset = 0x48,
.valid = true,
},
[MM_SMI_VENC] = {
.offset = 0x100,
.valid = false,
},
[MM_SMI_CAM] = {
.offset = 0x100,
.valid = false,
},
[MM_SMI_IMG] = {
.offset = 0x100,
.valid = false,
},
[MM_SMI_MDP] = {
.offset = 0x100,
.valid = false,
},
[MM_SMI_CLK] = {
.offset = 0x100,
.valid = false,
},
[MM_SMI_CLR] = {
.offset = 0x100,
.valid = false,
},
[MM_SMI_EXE] = {
.offset = 0x100,
.valid = false,
},
[MM_SMI_DUMP] = {
.offset = 0x100,
.valid = false,
},
[APU_CLK] = {
.offset = 0x100,
.valid = false,
},
[APU_BW_NORD] = {
.offset = 0x100,
.valid = false,
},
[DVFSRC_TIMESTAMP_OFFSET] = {
.offset = 0x100,
.valid = false,
},
[CM_STALL_RATIO_ID_0] = {
.offset = 0x100,
.valid = false,
},
[CM_STALL_RATIO_ID_1] = {
.offset = 0x100,
.valid = false,
},
[CM_STALL_RATIO_ID_2] = {
.offset = 0x100,
.valid = false,
},
[CM_STALL_RATIO_ID_3] = {
.offset = 0x100,
.valid = false,
},
[CM_STALL_RATIO_ID_4] = {
.offset = 0x100,
.valid = false,
},
[CM_STALL_RATIO_ID_5] = {
.offset = 0x100,
.valid = false,
},
[CM_STALL_RATIO_ID_6] = {
.offset = 0x100,
.valid = false,
},
[CM_STALL_RATIO_ID_7] = {
.offset = 0x100,
.valid = false,
},
[QOS_TOTAL_BW] = {
.offset = 0x20,
.valid = true,
},
};
static const struct mtk_qos_soc mt6761_qos_data = {
.ipi_pin = mt6761_qos_ipi_pin,
.sram_pin = mt6761_qos_sram_pin,
.qos_sspm_init = NULL,
.qos_ipi_recv_handler = NULL,
};
static int mt6761_qos_probe(struct platform_device *pdev)
{
return mtk_qos_probe(pdev, &mt6761_qos_data);
}
static const struct of_device_id mtk_qos_of_match[] = {
{
.compatible = "mediatek,mt6761-qos",
.data = &mt6761_qos_data,
}, {
.compatible = "mediatek,mt6765-qos",
.data = &mt6761_qos_data,
}, {
/* sentinel */
},
};
static int mt6761_qos_remove(struct platform_device *pdev)
{
return 0;
}
static struct platform_driver mt6761_qos_platdrv = {
.probe = mt6761_qos_probe,
.remove = mt6761_qos_remove,
.driver = {
.name = "mt6761-qos",
.of_match_table = mtk_qos_of_match,
},
};
static int __init mt6761_qos_init(void)
{
int ret = 0;
ret = platform_driver_register(&mt6761_qos_platdrv);
return ret;
}
late_initcall(mt6761_qos_init)
static void __exit mt6761_qos_exit(void)
{
platform_driver_unregister(&mt6761_qos_platdrv);
}
module_exit(mt6761_qos_exit)
+283
View File
@@ -0,0 +1,283 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/device.h>
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/of_device.h>
#include <linux/kthread.h>
#include <sspm_ipi.h>
#include <sspm_ipi_pin.h>
#include <linux/arm-smccc.h>
#include <linux/soc/mediatek/mtk_sip_svc.h>
#include "mtk_qos_ipi.h"
#include "mtk_qos_sram.h"
#include "mtk_qos_bound.h"
#include "mtk_qos_common.h"
static const struct qos_ipi_cmd mt6779_qos_ipi_pin[] = {
[QOS_IPI_QOS_ENABLE] = {
.id = 0,
.valid = true,
},
[QOS_IPI_QOS_BOUND] = {
.id = 10,
.valid = true,
},
[QOS_IPI_QOS_BOUND_ENABLE] = {
.id = 11,
.valid = true,
},
[QOS_IPI_QOS_BOUND_STRESS_ENABLE] = {
.id = 12,
.valid = true,
},
[QOS_IPI_SWPM_INIT] = {
.id = 5,
.valid = true,
},
[QOS_IPI_UPOWER_DATA_TRANSFER] = {
.id = 6,
.valid = true,
},
[QOS_IPI_UPOWER_DUMP_TABLE] = {
.id = 7,
.valid = true,
},
[QOS_IPI_GET_GPU_BW] = {
.id = 8,
.valid = true,
},
[QOS_IPI_SWPM_ENABLE] = {
.id = 9,
.valid = true,
},
[QOS_IPI_SMI_MET_MON] = {
.id = 13,
.valid = true,
},
[QOS_IPI_SETUP_GPU_INFO] = {
.id = 14,
.valid = true,
},
[QOS_IPI_SWPM_SET_UPDATE_CNT] = {
.id = 15,
.valid = true,
},
};
static const struct qos_sram_addr mt6779_qos_sram_pin[] = {
[QOS_DEBUG_0] = {
.offset = 0,
.valid = true,
},
[QOS_DEBUG_1] = {
.offset = 0x4,
.valid = true,
},
[QOS_DEBUG_2] = {
.offset = 0x8,
.valid = true,
},
[QOS_DEBUG_3] = {
.offset = 0xC,
.valid = true,
},
[QOS_DEBUG_4] = {
.offset = 0x10,
.valid = true,
},
[MM_SMI_VENC] = {
.offset = 0x20,
.valid = true,
},
[MM_SMI_CAM] = {
.offset = 0x24,
.valid = true,
},
[MM_SMI_IMG] = {
.offset = 0x28,
.valid = true,
},
[MM_SMI_MDP] = {
.offset = 0x2C,
.valid = true,
},
[MM_SMI_CLK] = {
.offset = 0x30,
.valid = true,
},
[MM_SMI_CLR] = {
.offset = 0x34,
.valid = true,
},
[MM_SMI_EXE] = {
.offset = 0x38,
.valid = true,
},
[MM_SMI_DUMP] = {
.offset = 0x3C,
.valid = true,
},
[APU_CLK] = {
.offset = 0x48,
.valid = true,
},
[APU_BW_NORD] = {
.offset = 0x4C,
.valid = true,
},
[DVFSRC_TIMESTAMP_OFFSET] = {
.offset = 0x50,
.valid = true,
},
[CM_STALL_RATIO_ID_0] = {
.offset = 0x60,
.valid = true,
},
[CM_STALL_RATIO_ID_1] = {
.offset = 0x64,
.valid = true,
},
[CM_STALL_RATIO_ID_2] = {
.offset = 0x68,
.valid = true,
},
[CM_STALL_RATIO_ID_3] = {
.offset = 0x6C,
.valid = true,
},
[CM_STALL_RATIO_ID_4] = {
.offset = 0x70,
.valid = true,
},
[CM_STALL_RATIO_ID_5] = {
.offset = 0x74,
.valid = true,
},
[CM_STALL_RATIO_ID_6] = {
.offset = 0x78,
.valid = true,
},
[CM_STALL_RATIO_ID_7] = {
.offset = 0x7C,
.valid = true,
},
[QOS_TOTAL_BW] = {
.offset = 0x100,
.valid = false,
},
};
static int mt6779_qos_sspm_init(void)
{
struct qos_ipi_data qos_ipi_d;
qos_ipi_d.cmd = QOS_IPI_QOS_ENABLE;
qos_ipi_to_sspm_command(&qos_ipi_d, 1);
return 0;
}
static int mt6779_qos_ipi_recv_handler(void *arg)
{
#if defined(CONFIG_MTK_TINYSYS_SSPM_SUPPORT)
struct ipi_action qos_isr;
struct qos_ipi_data qos_ipi_d;
struct mtk_qos *qos = arg;
unsigned int rdata, ret;
qos_isr.data = &qos_ipi_d;
ret = sspm_ipi_recv_registration(IPI_ID_QOS, &qos_isr);
if (ret) {
pr_info("mtkqos:%s, sspm register fail(%u)\n", __func__, ret);
return 0;
}
qos->soc->qos_sspm_init();
do {
rdata = 0;
sspm_ipi_recv_wait(IPI_ID_QOS);
if (qos_ipi_d.cmd == mt6779_qos_ipi_pin[QOS_IPI_QOS_BOUND].id)
qos_notifier_call_chain(
qos_ipi_d.u.qos_bound.state,
get_qos_bound());
else
pr_info("mtkqos: %s wrong QoS IPI command: %d\n",
__func__, qos_ipi_d.cmd);
} while (!kthread_should_stop());
#endif
return 0;
}
static const struct mtk_qos_soc mt6779_qos_data = {
.ipi_pin = mt6779_qos_ipi_pin,
.sram_pin = mt6779_qos_sram_pin,
.qos_sspm_init = mt6779_qos_sspm_init,
.qos_ipi_recv_handler = mt6779_qos_ipi_recv_handler,
};
static int mt6779_qos_probe(struct platform_device *pdev)
{
return mtk_qos_probe(pdev, &mt6779_qos_data);
}
static const struct of_device_id mtk_qos_of_match[] = {
{
.compatible = "mediatek,mt6779-qos",
.data = &mt6779_qos_data,
}, {
/* sentinel */
},
};
static int mt6779_qos_remove(struct platform_device *pdev)
{
return 0;
}
static struct platform_driver mt6779_qos_platdrv = {
.probe = mt6779_qos_probe,
.remove = mt6779_qos_remove,
.driver = {
.name = "mt6779-qos",
.of_match_table = mtk_qos_of_match,
},
};
static int __init mt6779_qos_init(void)
{
int ret = 0;
ret = platform_driver_register(&mt6779_qos_platdrv);
return ret;
}
late_initcall(mt6779_qos_init)
static void __exit mt6779_qos_exit(void)
{
platform_driver_unregister(&mt6779_qos_platdrv);
}
module_exit(mt6779_qos_exit)
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("MediaTek QoS driver");