2019-05-27 13:55:21 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2016-06-08 16:50:58 +07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015-2016 MediaTek Inc.
|
|
|
|
* Author: Honghui Zhang <honghui.zhang@mediatek.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MTK_IOMMU_H_
|
|
|
|
#define _MTK_IOMMU_H_
|
|
|
|
|
|
|
|
#include <linux/clk.h>
|
|
|
|
#include <linux/component.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/io.h>
|
2019-02-05 23:37:31 +07:00
|
|
|
#include <linux/io-pgtable.h>
|
2016-06-08 16:50:58 +07:00
|
|
|
#include <linux/iommu.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <soc/mediatek/smi.h>
|
|
|
|
|
|
|
|
struct mtk_iommu_suspend_reg {
|
|
|
|
u32 standard_axi_mode;
|
|
|
|
u32 dcm_dis;
|
|
|
|
u32 ctrl_reg;
|
|
|
|
u32 int_control0;
|
|
|
|
u32 int_main_control;
|
2018-03-18 08:52:54 +07:00
|
|
|
u32 ivrp_paddr;
|
2016-06-08 16:50:58 +07:00
|
|
|
};
|
|
|
|
|
2017-08-21 18:00:16 +07:00
|
|
|
enum mtk_iommu_plat {
|
|
|
|
M4U_MT2701,
|
|
|
|
M4U_MT2712,
|
|
|
|
M4U_MT8173,
|
|
|
|
};
|
|
|
|
|
2016-06-08 16:50:58 +07:00
|
|
|
struct mtk_iommu_domain;
|
|
|
|
|
|
|
|
struct mtk_iommu_data {
|
|
|
|
void __iomem *base;
|
|
|
|
int irq;
|
|
|
|
struct device *dev;
|
|
|
|
struct clk *bclk;
|
|
|
|
phys_addr_t protect_base; /* protect memory base */
|
|
|
|
struct mtk_iommu_suspend_reg reg;
|
|
|
|
struct mtk_iommu_domain *m4u_dom;
|
|
|
|
struct iommu_group *m4u_group;
|
|
|
|
struct mtk_smi_iommu smi_imu; /* SMI larb iommu info */
|
|
|
|
bool enable_4GB;
|
2017-07-06 23:55:30 +07:00
|
|
|
bool tlb_flush_active;
|
2017-02-03 18:57:32 +07:00
|
|
|
|
|
|
|
struct iommu_device iommu;
|
2017-08-21 18:00:16 +07:00
|
|
|
enum mtk_iommu_plat m4u_plat;
|
2017-08-21 18:00:17 +07:00
|
|
|
|
|
|
|
struct list_head list;
|
2016-06-08 16:50:58 +07:00
|
|
|
};
|
|
|
|
|
2016-08-09 20:46:46 +07:00
|
|
|
static inline int compare_of(struct device *dev, void *data)
|
2016-06-08 16:50:58 +07:00
|
|
|
{
|
|
|
|
return dev->of_node == data;
|
|
|
|
}
|
|
|
|
|
2016-10-19 17:30:34 +07:00
|
|
|
static inline void release_of(struct device *dev, void *data)
|
|
|
|
{
|
|
|
|
of_node_put(data);
|
|
|
|
}
|
|
|
|
|
2016-08-09 20:46:46 +07:00
|
|
|
static inline int mtk_iommu_bind(struct device *dev)
|
2016-06-08 16:50:58 +07:00
|
|
|
{
|
|
|
|
struct mtk_iommu_data *data = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
return component_bind_all(dev, &data->smi_imu);
|
|
|
|
}
|
|
|
|
|
2016-08-09 20:46:46 +07:00
|
|
|
static inline void mtk_iommu_unbind(struct device *dev)
|
2016-06-08 16:50:58 +07:00
|
|
|
{
|
|
|
|
struct mtk_iommu_data *data = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
component_unbind_all(dev, &data->smi_imu);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|