0001
0002
0003
0004
0005
0006 #include <linux/export.h>
0007 #include <linux/jiffies.h>
0008 #include <linux/regmap.h>
0009 #include <linux/mfd/syscon.h>
0010 #include <linux/soc/mediatek/infracfg.h>
0011 #include <asm/processor.h>
0012
0013 #define MTK_POLL_DELAY_US 10
0014 #define MTK_POLL_TIMEOUT (jiffies_to_usecs(HZ))
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
0029 bool reg_update)
0030 {
0031 u32 val;
0032 int ret;
0033
0034 if (reg_update)
0035 regmap_update_bits(infracfg, INFRA_TOPAXI_PROTECTEN, mask,
0036 mask);
0037 else
0038 regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_SET, mask);
0039
0040 ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
0041 val, (val & mask) == mask,
0042 MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
0043
0044 return ret;
0045 }
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 int mtk_infracfg_clear_bus_protection(struct regmap *infracfg, u32 mask,
0060 bool reg_update)
0061 {
0062 int ret;
0063 u32 val;
0064
0065 if (reg_update)
0066 regmap_update_bits(infracfg, INFRA_TOPAXI_PROTECTEN, mask, 0);
0067 else
0068 regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_CLR, mask);
0069
0070 ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
0071 val, !(val & mask),
0072 MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
0073
0074 return ret;
0075 }
0076
0077 static int __init mtk_infracfg_init(void)
0078 {
0079 struct regmap *infracfg;
0080
0081
0082
0083
0084
0085
0086
0087 infracfg = syscon_regmap_lookup_by_compatible("mediatek,mt8192-infracfg");
0088 if (!IS_ERR(infracfg))
0089 regmap_set_bits(infracfg, MT8192_INFRA_CTRL,
0090 MT8192_INFRA_CTRL_DISABLE_MFG2ACP);
0091 return 0;
0092 }
0093 postcore_initcall(mtk_infracfg_init);