[Feature] add GA346 baseline version
Change-Id: Ic62933698569507dcf98240cdf5d9931ae34348f
diff --git a/src/kernel/linux/v4.19/include/soc/mediatek/emi.h b/src/kernel/linux/v4.19/include/soc/mediatek/emi.h
new file mode 100755
index 0000000..1e5a793
--- /dev/null
+++ b/src/kernel/linux/v4.19/include/soc/mediatek/emi.h
@@ -0,0 +1,96 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2019 MediaTek Inc.
+ */
+#ifndef __EMI_H__
+#define __EMI_H__
+
+#include <linux/irqreturn.h>
+#define MTK_EMIMPU_NO_PROTECTION 0
+#define MTK_EMIMPU_SEC_RW 1
+#define MTK_EMIMPU_SEC_RW_NSEC_R 2
+#define MTK_EMIMPU_SEC_RW_NSEC_W 3
+#define MTK_EMIMPU_SEC_R_NSEC_R 4
+#define MTK_EMIMPU_FORBIDDEN 5
+#define MTK_EMIMPU_SEC_R_NSEC_RW 6
+
+#define MTK_EMIMPU_UNLOCK false
+#define MTK_EMIMPU_LOCK true
+
+#define MTK_EMIMPU_SET 0
+#define MTK_EMIMPU_CLEAR 1
+#define MTK_EMIMPU_READ 2
+#define MTK_EMIMPU_SLVERR 3
+#define MTK_EMIDBG_DUMP 4
+#define MTK_EMIDBG_MSG 5
+
+#define MTK_EMIMPU_READ_SA 0
+#define MTK_EMIMPU_READ_EA 1
+#define MTK_EMIMPU_READ_APC 2
+#define MTK_EMI_MAX_TOKEN 4
+
+#define MTK_EMI_MAX_CMD_LEN 4096
+
+struct emi_addr_map {
+ int emi;
+ int channel;
+ int rank;
+ int bank;
+ int row;
+ int column;
+};
+
+struct reg_info_t {
+ unsigned int offset;
+ unsigned int value;
+ unsigned int leng;
+};
+
+struct emimpu_region_t {
+ unsigned long long start;
+ unsigned long long end;
+ unsigned int rg_num;
+ bool lock;
+ unsigned int *apc;
+};
+
+typedef irqreturn_t (*emimpu_pre_handler)(
+ unsigned int emi_id, struct reg_info_t *dump, unsigned int leng);
+typedef void (*emimpu_post_clear)(unsigned int emi_id);
+typedef void (*emimpu_md_handler)(
+ unsigned int emi_id, struct reg_info_t *dump, unsigned int leng);
+typedef void (*emimpu_debug_dump)(void);
+
+struct emimpu_dbg_cb {
+ emimpu_debug_dump func;
+ struct emimpu_dbg_cb *next_dbg_cb;
+};
+
+/* mtk emicen api */
+unsigned int mtk_emicen_get_ch_cnt(void);
+unsigned int mtk_emicen_get_rk_cnt(void);
+unsigned int mtk_emicen_get_rk_size(unsigned int rk_id);
+int mtk_emicen_addr2dram(unsigned long addr, struct emi_addr_map *map);
+
+/* mtk emidbg api */
+void mtk_emidbg_dump(void);
+
+/* mtk emimpu api */
+int emimpu_ap_region_init(void);
+int mtk_emimpu_init_region(
+ struct emimpu_region_t *rg_info, unsigned int rg_num);
+int mtk_emimpu_set_addr(struct emimpu_region_t *rg_info,
+ unsigned long long start, unsigned long long end);
+int mtk_emimpu_set_apc(struct emimpu_region_t *rg_info,
+ unsigned int d_num, unsigned int apc);
+int mtk_emimpu_lock_region(struct emimpu_region_t *rg_info, bool lock);
+int mtk_emimpu_set_protection(struct emimpu_region_t *rg_info);
+int mtk_emimpu_free_region(struct emimpu_region_t *rg_info);
+int mtk_emimpu_clear_protection(struct emimpu_region_t *rg_info);
+int mtk_emimpu_prehandle_register(emimpu_pre_handler bypass_func);
+int mtk_emimpu_postclear_register(emimpu_post_clear clear_func);
+int mtk_emimpu_md_handling_register(emimpu_md_handler md_handling_func);
+int mtk_emimpu_debugdump_register(emimpu_debug_dump debug_func);
+void mtk_clear_md_violation(void);
+
+#endif /* __EMI_H__ */
diff --git a/src/kernel/linux/v4.19/include/soc/mediatek/mmqos.h b/src/kernel/linux/v4.19/include/soc/mediatek/mmqos.h
new file mode 100644
index 0000000..860b623
--- /dev/null
+++ b/src/kernel/linux/v4.19/include/soc/mediatek/mmqos.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2019 MediaTek Inc.
+ * Author: Anthony Huang <anthony.huang@mediatek.com>
+ */
+#ifndef MTK_MMQOS_H
+#define MTK_MMQOS_H
+
+enum hrt_type {
+ HRT_MD,
+ HRT_CAM,
+ HRT_DISP,
+ HRT_TYPE_NUM
+};
+
+enum {
+ BW_THROTTLE_START = 1,
+ BW_THROTTLE_START_RECOVER,
+ BW_THROTTLE_END
+};
+
+#if IS_ENABLED(CONFIG_INTERCONNECT_MTK_MMQOS_COMMON)
+void mtk_mmqos_wait_throttle_done(void);
+s32 mtk_mmqos_set_hrt_bw(enum hrt_type type, u32 bw);
+s32 mtk_mmqos_get_avail_hrt_bw(enum hrt_type type);
+s32 mtk_mmqos_register_bw_throttle_notifier(struct notifier_block *nb);
+s32 mtk_mmqos_unregister_bw_throttle_notifier(struct notifier_block *nb);
+#else
+static inline void
+mtk_mmqos_wait_throttle_done(void) { return; }
+
+static inline s32
+mtk_mmqos_set_hrt_bw(enum hrt_type type, u32 bw) { return 0; }
+
+static inline s32
+mtk_mmqos_get_avail_hrt_bw(enum hrt_type type) { return -1; }
+
+static inline s32
+mtk_mmqos_register_bw_throttle_notifier(struct notifier_block *nb) { return 0; }
+
+static inline s32
+mtk_mmqos_unregister_bw_throttle_notifier(struct notifier_block *nb)
+{ return 0; }
+#endif
+
+#endif /* MTK_MMQOS_H */
diff --git a/src/kernel/linux/v4.19/include/soc/mediatek/smi.h b/src/kernel/linux/v4.19/include/soc/mediatek/smi.h
new file mode 100644
index 0000000..300a700
--- /dev/null
+++ b/src/kernel/linux/v4.19/include/soc/mediatek/smi.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2015-2016 MediaTek Inc.
+ * Author: Yong Wu <yong.wu@mediatek.com>
+ */
+#ifndef MTK_IOMMU_SMI_H
+#define MTK_IOMMU_SMI_H
+
+#include <linux/bitops.h>
+#include <linux/device.h>
+
+#if IS_ENABLED(CONFIG_MTK_SMI)
+
+#define MTK_LARB_NR_MAX 16
+
+#define MTK_SMI_MMU_EN(port) BIT(port)
+
+struct mtk_smi_larb_iommu {
+ struct device *dev;
+ unsigned int mmu;
+};
+
+struct mtk_smi_iommu {
+ struct mtk_smi_larb_iommu larb_imu[MTK_LARB_NR_MAX];
+};
+
+void mtk_smi_common_bw_set(struct device *dev, const u32 port, const u32 val);
+void mtk_smi_larb_bw_set(struct device *dev, const u32 port, const u32 val);
+
+#else
+
+static inline void
+mtk_smi_common_bw_set(struct device *dev, const u32 port, const u32 val) { }
+static inline void
+mtk_smi_larb_bw_set(struct device *dev, const u32 port, const u32 val) { }
+
+#endif
+
+#endif