Skip to content

Commit 29a584d

Browse files
dbiswas-devRuss Weight
authored andcommitted
fpga: dfl: Update the dfl emif driver support revision 1
The next generation (revision 1) of the DFL EMIF feature device requires support for more than 4 memory banks. It does not support the selective clearing of memory banks. A capability register replaces the previous control register, and contains a bitmask to indicate the presence of each memory bank. This bitmask aligns with the previous control register bitmask that served the same purpose. The control and capability registers are treated like a C Union structure in order to support both the new and old revisions of the EMIF device. Signed-off-by: Debarati Biswas <debaratix.biswas@intel.com> Signed-off-by: Russ Weight <russell.h.weight@intel.com>
1 parent 4ae5e95 commit 29a584d

1 file changed

Lines changed: 50 additions & 5 deletions

File tree

drivers/memory/dfl-emif.c

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,23 @@
2424
#define EMIF_STAT_CLEAR_BUSY_SFT 16
2525
#define EMIF_CTRL 0x10
2626
#define EMIF_CTRL_CLEAR_EN_SFT 0
27-
#define EMIF_CTRL_CLEAR_EN_MSK GENMASK_ULL(3, 0)
27+
#define EMIF_CTRL_CLEAR_EN_MSK GENMASK_ULL(7, 0)
2828

2929
#define EMIF_POLL_INVL 10000 /* us */
3030
#define EMIF_POLL_TIMEOUT 5000000 /* us */
3131

32+
/*
33+
* The Capability Register replaces the Control Register (at the same
34+
* offset) for EMIF feature revisions > 0. The bitmask that indicates
35+
* the presence of memory channels exists in both the Capability Register
36+
* and Control Register definitions. These can be thought of as a C union.
37+
* The Capability Register definitions are used to check for the existence
38+
* of a memory channel, and the Control Register definitions are used for
39+
* managing the memory-clear functionality in revision 0.
40+
*/
41+
#define EMIF_CAPABILITY_BASE 0x10
42+
#define EMIF_CAPABILITY_CHN_MSK GENMASK_ULL(7, 0)
43+
3244
struct dfl_emif {
3345
struct device *dev;
3446
void __iomem *base;
@@ -106,16 +118,30 @@ emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 0);
106118
emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 1);
107119
emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 2);
108120
emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 3);
121+
emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 4);
122+
emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 5);
123+
emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 6);
124+
emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 7);
109125

110126
emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 0);
111127
emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 1);
112128
emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 2);
113129
emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 3);
130+
emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 4);
131+
emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 5);
132+
emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 6);
133+
emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 7);
134+
114135

115136
emif_clear_attr(0);
116137
emif_clear_attr(1);
117138
emif_clear_attr(2);
118139
emif_clear_attr(3);
140+
emif_clear_attr(4);
141+
emif_clear_attr(5);
142+
emif_clear_attr(6);
143+
emif_clear_attr(7);
144+
119145

120146
static struct attribute *dfl_emif_attrs[] = {
121147
&emif_attr_inf0_init_done.attr.attr,
@@ -134,6 +160,22 @@ static struct attribute *dfl_emif_attrs[] = {
134160
&emif_attr_inf3_cal_fail.attr.attr,
135161
&emif_attr_inf3_clear.attr.attr,
136162

163+
&emif_attr_inf4_init_done.attr.attr,
164+
&emif_attr_inf4_cal_fail.attr.attr,
165+
&emif_attr_inf4_clear.attr.attr,
166+
167+
&emif_attr_inf5_init_done.attr.attr,
168+
&emif_attr_inf5_cal_fail.attr.attr,
169+
&emif_attr_inf5_clear.attr.attr,
170+
171+
&emif_attr_inf6_init_done.attr.attr,
172+
&emif_attr_inf6_cal_fail.attr.attr,
173+
&emif_attr_inf6_clear.attr.attr,
174+
175+
&emif_attr_inf7_init_done.attr.attr,
176+
&emif_attr_inf7_cal_fail.attr.attr,
177+
&emif_attr_inf7_clear.attr.attr,
178+
137179
NULL,
138180
};
139181

@@ -146,12 +188,15 @@ static umode_t dfl_emif_visible(struct kobject *kobj,
146188
u64 val;
147189

148190
/*
149-
* This device supports upto 4 memory interfaces, but not all
191+
* This device supports up to 8 memory interfaces, but not all
150192
* interfaces are used on different platforms. The read out value of
151-
* CLEAN_EN field (which is a bitmap) could tell how many interfaces
152-
* are available.
193+
* CAPABILITY_CHN_MSK field (which is a bitmap) indicates which
194+
* interfaces are available.
153195
*/
154-
val = FIELD_GET(EMIF_CTRL_CLEAR_EN_MSK, readq(de->base + EMIF_CTRL));
196+
if (dfl_feature_revision(de->base) > 0 && strstr(attr->name, "_clear"))
197+
return 0;
198+
199+
val = FIELD_GET(EMIF_CAPABILITY_CHN_MSK, readq(de->base + EMIF_CAPABILITY_BASE));
155200

156201
return (val & BIT_ULL(eattr->index)) ? attr->mode : 0;
157202
}

0 commit comments

Comments
 (0)