18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2015-2016 MediaTek Inc.
48c2ecf20Sopenharmony_ci * Author: Yong Wu <yong.wu@mediatek.com>
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci#ifndef MTK_IOMMU_SMI_H
78c2ecf20Sopenharmony_ci#define MTK_IOMMU_SMI_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/bitops.h>
108c2ecf20Sopenharmony_ci#include <linux/device.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifdef CONFIG_MTK_SMI
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define MTK_LARB_NR_MAX		16
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#define MTK_SMI_MMU_EN(port)	BIT(port)
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistruct mtk_smi_larb_iommu {
198c2ecf20Sopenharmony_ci	struct device *dev;
208c2ecf20Sopenharmony_ci	unsigned int   mmu;
218c2ecf20Sopenharmony_ci};
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/*
248c2ecf20Sopenharmony_ci * mtk_smi_larb_get: Enable the power domain and clocks for this local arbiter.
258c2ecf20Sopenharmony_ci *                   It also initialize some basic setting(like iommu).
268c2ecf20Sopenharmony_ci * mtk_smi_larb_put: Disable the power domain and clocks for this local arbiter.
278c2ecf20Sopenharmony_ci * Both should be called in non-atomic context.
288c2ecf20Sopenharmony_ci *
298c2ecf20Sopenharmony_ci * Returns 0 if successful, negative on failure.
308c2ecf20Sopenharmony_ci */
318c2ecf20Sopenharmony_ciint mtk_smi_larb_get(struct device *larbdev);
328c2ecf20Sopenharmony_civoid mtk_smi_larb_put(struct device *larbdev);
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#else
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cistatic inline int mtk_smi_larb_get(struct device *larbdev)
378c2ecf20Sopenharmony_ci{
388c2ecf20Sopenharmony_ci	return 0;
398c2ecf20Sopenharmony_ci}
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistatic inline void mtk_smi_larb_put(struct device *larbdev) { }
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#endif
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#endif
46