smi.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2015-2016 MediaTek Inc.
  3. * Author: Yong Wu <yong.wu@mediatek.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef MTK_IOMMU_SMI_H
  15. #define MTK_IOMMU_SMI_H
  16. #include <linux/bitops.h>
  17. #include <linux/device.h>
  18. #ifdef CONFIG_MTK_SMI
  19. #define MTK_LARB_NR_MAX 8
  20. #define MTK_SMI_MMU_EN(port) BIT(port)
  21. struct mtk_smi_larb_iommu {
  22. struct device *dev;
  23. unsigned int mmu;
  24. };
  25. struct mtk_smi_iommu {
  26. unsigned int larb_nr;
  27. struct mtk_smi_larb_iommu larb_imu[MTK_LARB_NR_MAX];
  28. };
  29. /*
  30. * mtk_smi_larb_get: Enable the power domain and clocks for this local arbiter.
  31. * It also initialize some basic setting(like iommu).
  32. * mtk_smi_larb_put: Disable the power domain and clocks for this local arbiter.
  33. * Both should be called in non-atomic context.
  34. *
  35. * Returns 0 if successful, negative on failure.
  36. */
  37. int mtk_smi_larb_get(struct device *larbdev);
  38. void mtk_smi_larb_put(struct device *larbdev);
  39. #else
  40. static inline int mtk_smi_larb_get(struct device *larbdev)
  41. {
  42. return 0;
  43. }
  44. static inline void mtk_smi_larb_put(struct device *larbdev) { }
  45. #endif
  46. #endif