2 * Broadcom STB SoCs Bus Unit Interface controls
4 * Copyright (C) 2015, Broadcom Corporation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #define pr_fmt(fmt) "brcmstb: " KBUILD_MODNAME ": " fmt
18 #include <linux/kernel.h>
20 #include <linux/of_address.h>
21 #include <linux/syscore_ops.h>
23 #define CPU_CREDIT_REG_OFFSET 0x184
24 #define CPU_CREDIT_REG_MCPx_WR_PAIRING_EN_MASK 0x70000000
26 static void __iomem *cpubiuctrl_base;
27 static bool mcp_wr_pairing_en;
29 static int __init mcp_write_pairing_set(void)
36 creds = readl_relaxed(cpubiuctrl_base + CPU_CREDIT_REG_OFFSET);
37 if (mcp_wr_pairing_en) {
38 pr_info("MCP: Enabling write pairing\n");
39 writel_relaxed(creds | CPU_CREDIT_REG_MCPx_WR_PAIRING_EN_MASK,
40 cpubiuctrl_base + CPU_CREDIT_REG_OFFSET);
41 } else if (creds & CPU_CREDIT_REG_MCPx_WR_PAIRING_EN_MASK) {
42 pr_info("MCP: Disabling write pairing\n");
43 writel_relaxed(creds & ~CPU_CREDIT_REG_MCPx_WR_PAIRING_EN_MASK,
44 cpubiuctrl_base + CPU_CREDIT_REG_OFFSET);
46 pr_info("MCP: Write pairing already disabled\n");
52 static int __init setup_hifcpubiuctrl_regs(void)
54 struct device_node *np;
57 np = of_find_compatible_node(NULL, NULL, "brcm,brcmstb-cpu-biu-ctrl");
59 pr_err("missing BIU control node\n");
63 cpubiuctrl_base = of_iomap(np, 0);
64 if (!cpubiuctrl_base) {
65 pr_err("failed to remap BIU control base\n");
70 mcp_wr_pairing_en = of_property_read_bool(np, "brcm,write-pairing");
76 #ifdef CONFIG_PM_SLEEP
77 static u32 cpu_credit_reg_dump; /* for save/restore */
79 static int brcmstb_cpu_credit_reg_suspend(void)
83 readl_relaxed(cpubiuctrl_base + CPU_CREDIT_REG_OFFSET);
87 static void brcmstb_cpu_credit_reg_resume(void)
90 writel_relaxed(cpu_credit_reg_dump,
91 cpubiuctrl_base + CPU_CREDIT_REG_OFFSET);
94 static struct syscore_ops brcmstb_cpu_credit_syscore_ops = {
95 .suspend = brcmstb_cpu_credit_reg_suspend,
96 .resume = brcmstb_cpu_credit_reg_resume,
101 void __init brcmstb_biuctrl_init(void)
105 setup_hifcpubiuctrl_regs();
107 ret = mcp_write_pairing_set();
109 pr_err("MCP: Unable to disable write pairing!\n");
113 #ifdef CONFIG_PM_SLEEP
114 register_syscore_ops(&brcmstb_cpu_credit_syscore_ops);