Skip to content

Commit fa6bd54

Browse files
fancerbebarino
authored andcommitted
clk: baikal-t1: Add DDR/PCIe directly controlled resets support
Aside with a set of the trigger-like resets Baikal-T1 CCU provides two additional blocks with directly controlled reset signals. In particular it concerns DDR full and initial resets and various PCIe sub-domains resets. Let's add the direct reset assertion/de-assertion of the corresponding flags support into the Baikal-T1 CCU driver then. It will be required at least for the PCIe platform driver. Obviously the DDR controller isn't supposed to be fully reset in the kernel, so the corresponding controls are added just for the sake of the interface implementation completeness. Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Link: https://lore.kernel.org/r/20220929225402.9696-8-Sergey.Semin@baikalelectronics.ru Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent c0cd3b1 commit fa6bd54

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

drivers/clk/baikal-t1/ccu-rst.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,29 @@
3535
#define CCU_AXI_HWA_BASE 0x054
3636
#define CCU_AXI_SRAM_BASE 0x058
3737

38+
#define CCU_SYS_DDR_BASE 0x02c
3839
#define CCU_SYS_SATA_REF_BASE 0x060
3940
#define CCU_SYS_APB_BASE 0x064
41+
#define CCU_SYS_PCIE_BASE 0x144
4042

4143
#define CCU_RST_DELAY_US 1
4244

4345
#define CCU_RST_TRIG(_base, _ofs) \
4446
{ \
47+
.type = CCU_RST_TRIG, \
48+
.base = _base, \
49+
.mask = BIT(_ofs), \
50+
}
51+
52+
#define CCU_RST_DIR(_base, _ofs) \
53+
{ \
54+
.type = CCU_RST_DIR, \
4555
.base = _base, \
4656
.mask = BIT(_ofs), \
4757
}
4858

4959
struct ccu_rst_info {
60+
enum ccu_rst_type type;
5061
unsigned int base;
5162
unsigned int mask;
5263
};
@@ -79,13 +90,25 @@ static const struct ccu_rst_info axi_rst_info[] = {
7990
static const struct ccu_rst_info sys_rst_info[] = {
8091
[CCU_SYS_SATA_REF_RST] = CCU_RST_TRIG(CCU_SYS_SATA_REF_BASE, 1),
8192
[CCU_SYS_APB_RST] = CCU_RST_TRIG(CCU_SYS_APB_BASE, 1),
93+
[CCU_SYS_DDR_FULL_RST] = CCU_RST_DIR(CCU_SYS_DDR_BASE, 1),
94+
[CCU_SYS_DDR_INIT_RST] = CCU_RST_DIR(CCU_SYS_DDR_BASE, 2),
95+
[CCU_SYS_PCIE_PCS_PHY_RST] = CCU_RST_DIR(CCU_SYS_PCIE_BASE, 0),
96+
[CCU_SYS_PCIE_PIPE0_RST] = CCU_RST_DIR(CCU_SYS_PCIE_BASE, 4),
97+
[CCU_SYS_PCIE_CORE_RST] = CCU_RST_DIR(CCU_SYS_PCIE_BASE, 8),
98+
[CCU_SYS_PCIE_PWR_RST] = CCU_RST_DIR(CCU_SYS_PCIE_BASE, 9),
99+
[CCU_SYS_PCIE_STICKY_RST] = CCU_RST_DIR(CCU_SYS_PCIE_BASE, 10),
100+
[CCU_SYS_PCIE_NSTICKY_RST] = CCU_RST_DIR(CCU_SYS_PCIE_BASE, 11),
101+
[CCU_SYS_PCIE_HOT_RST] = CCU_RST_DIR(CCU_SYS_PCIE_BASE, 12),
82102
};
83103

84104
static int ccu_rst_reset(struct reset_controller_dev *rcdev, unsigned long idx)
85105
{
86106
struct ccu_rst *rst = to_ccu_rst(rcdev);
87107
const struct ccu_rst_info *info = &rst->rsts_info[idx];
88108

109+
if (info->type != CCU_RST_TRIG)
110+
return -EOPNOTSUPP;
111+
89112
regmap_update_bits(rst->sys_regs, info->base, info->mask, info->mask);
90113

91114
/* The next delay must be enough to cover all the resets. */
@@ -94,8 +117,51 @@ static int ccu_rst_reset(struct reset_controller_dev *rcdev, unsigned long idx)
94117
return 0;
95118
}
96119

120+
static int ccu_rst_set(struct reset_controller_dev *rcdev,
121+
unsigned long idx, bool high)
122+
{
123+
struct ccu_rst *rst = to_ccu_rst(rcdev);
124+
const struct ccu_rst_info *info = &rst->rsts_info[idx];
125+
126+
if (info->type != CCU_RST_DIR)
127+
return high ? -EOPNOTSUPP : 0;
128+
129+
return regmap_update_bits(rst->sys_regs, info->base,
130+
info->mask, high ? info->mask : 0);
131+
}
132+
133+
static int ccu_rst_assert(struct reset_controller_dev *rcdev,
134+
unsigned long idx)
135+
{
136+
return ccu_rst_set(rcdev, idx, true);
137+
}
138+
139+
static int ccu_rst_deassert(struct reset_controller_dev *rcdev,
140+
unsigned long idx)
141+
{
142+
return ccu_rst_set(rcdev, idx, false);
143+
}
144+
145+
static int ccu_rst_status(struct reset_controller_dev *rcdev,
146+
unsigned long idx)
147+
{
148+
struct ccu_rst *rst = to_ccu_rst(rcdev);
149+
const struct ccu_rst_info *info = &rst->rsts_info[idx];
150+
u32 val;
151+
152+
if (info->type != CCU_RST_DIR)
153+
return -EOPNOTSUPP;
154+
155+
regmap_read(rst->sys_regs, info->base, &val);
156+
157+
return !!(val & info->mask);
158+
}
159+
97160
static const struct reset_control_ops ccu_rst_ops = {
98161
.reset = ccu_rst_reset,
162+
.assert = ccu_rst_assert,
163+
.deassert = ccu_rst_deassert,
164+
.status = ccu_rst_status,
99165
};
100166

101167
struct ccu_rst *ccu_rst_hw_register(const struct ccu_rst_init_data *rst_init)

drivers/clk/baikal-t1/ccu-rst.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313

1414
struct ccu_rst_info;
1515

16+
/*
17+
* enum ccu_rst_type - CCU Reset types
18+
* @CCU_RST_TRIG: Self-deasserted reset signal.
19+
* @CCU_RST_DIR: Directly controlled reset signal.
20+
*/
21+
enum ccu_rst_type {
22+
CCU_RST_TRIG,
23+
CCU_RST_DIR,
24+
};
25+
1626
/*
1727
* struct ccu_rst_init_data - CCU Resets initialization data
1828
* @sys_regs: Baikal-T1 System Controller registers map.

0 commit comments

Comments
 (0)