Skip to content

Commit 30b4da6

Browse files
bastien-curutchetkrzk
authored andcommitted
memory: ti-aemif: Wrap CS timings into a struct
CS timings are store in the struct aemif_cs_data along with other CS parameters. It isn't convenient for exposing CS timings to other drivers without also exposing the other parameters. Wrap the CS timings in a new struct aemif_cs_timings to simplify their export in upcoming patches. Signed-off-by: Bastien Curutchet <[email protected]> Reviewed-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krzysztof Kozlowski <[email protected]>
1 parent b3d57e1 commit 30b4da6

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

drivers/memory/ti-aemif.c

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -80,28 +80,36 @@
8080
ASIZE_MAX)
8181

8282
/**
83-
* struct aemif_cs_data: structure to hold cs parameters
84-
* @cs: chip-select number
83+
* struct aemif_cs_timings: structure to hold CS timings
8584
* @wstrobe: write strobe width, number of cycles - 1
8685
* @rstrobe: read strobe width, number of cycles - 1
8786
* @wsetup: write setup width, number of cycles - 1
8887
* @whold: write hold width, number of cycles - 1
8988
* @rsetup: read setup width, number of cycles - 1
9089
* @rhold: read hold width, number of cycles - 1
9190
* @ta: minimum turn around time, number of cycles - 1
92-
* @enable_ss: enable/disable select strobe mode
93-
* @enable_ew: enable/disable extended wait mode
94-
* @asize: width of the asynchronous device's data bus
9591
*/
96-
struct aemif_cs_data {
97-
u8 cs;
92+
struct aemif_cs_timings {
9893
u32 wstrobe;
9994
u32 rstrobe;
10095
u32 wsetup;
10196
u32 whold;
10297
u32 rsetup;
10398
u32 rhold;
10499
u32 ta;
100+
};
101+
102+
/**
103+
* struct aemif_cs_data: structure to hold CS parameters
104+
* @timings: timings configuration
105+
* @cs: chip-select number
106+
* @enable_ss: enable/disable select strobe mode
107+
* @enable_ew: enable/disable extended wait mode
108+
* @asize: width of the asynchronous device's data bus
109+
*/
110+
struct aemif_cs_data {
111+
struct aemif_cs_timings timings;
112+
u8 cs;
105113
u8 enable_ss;
106114
u8 enable_ew;
107115
u8 asize;
@@ -179,9 +187,10 @@ static int aemif_config_abus(struct platform_device *pdev, int csnum)
179187

180188
offset = A1CR_OFFSET + (data->cs - aemif->cs_offset) * 4;
181189

182-
set = TA(data->ta) |
183-
RHOLD(data->rhold) | RSTROBE(data->rstrobe) | RSETUP(data->rsetup) |
184-
WHOLD(data->whold) | WSTROBE(data->wstrobe) | WSETUP(data->wsetup);
190+
set = TA(data->timings.ta) |
191+
RHOLD(data->timings.rhold) | RSTROBE(data->timings.rstrobe) |
192+
RSETUP(data->timings.rsetup) | WHOLD(data->timings.whold) |
193+
WSTROBE(data->timings.wstrobe) | WSETUP(data->timings.wsetup);
185194

186195
set |= (data->asize & ACR_ASIZE_MASK);
187196
if (data->enable_ew)
@@ -215,13 +224,13 @@ static void aemif_get_hw_params(struct platform_device *pdev, int csnum)
215224
offset = A1CR_OFFSET + (data->cs - aemif->cs_offset) * 4;
216225
val = readl(aemif->base + offset);
217226

218-
data->ta = TA_VAL(val);
219-
data->rhold = RHOLD_VAL(val);
220-
data->rstrobe = RSTROBE_VAL(val);
221-
data->rsetup = RSETUP_VAL(val);
222-
data->whold = WHOLD_VAL(val);
223-
data->wstrobe = WSTROBE_VAL(val);
224-
data->wsetup = WSETUP_VAL(val);
227+
data->timings.ta = TA_VAL(val);
228+
data->timings.rhold = RHOLD_VAL(val);
229+
data->timings.rstrobe = RSTROBE_VAL(val);
230+
data->timings.rsetup = RSETUP_VAL(val);
231+
data->timings.whold = WHOLD_VAL(val);
232+
data->timings.wstrobe = WSTROBE_VAL(val);
233+
data->timings.wsetup = WSETUP_VAL(val);
225234
data->enable_ew = EW_VAL(val);
226235
data->enable_ss = SSTROBE_VAL(val);
227236
data->asize = val & ASIZE_MAX;
@@ -272,55 +281,55 @@ static int of_aemif_parse_abus_config(struct platform_device *pdev,
272281
if (ret < 0)
273282
return ret;
274283

275-
data->ta = ret;
284+
data->timings.ta = ret;
276285
}
277286

278287
if (!of_property_read_u32(np, "ti,cs-read-hold-ns", &val)) {
279288
ret = aemif_calc_rate(pdev, val, clk_rate, RHOLD_MAX);
280289
if (ret < 0)
281290
return ret;
282291

283-
data->rhold = ret;
292+
data->timings.rhold = ret;
284293
}
285294

286295
if (!of_property_read_u32(np, "ti,cs-read-strobe-ns", &val)) {
287296
ret = aemif_calc_rate(pdev, val, clk_rate, RSTROBE_MAX);
288297
if (ret < 0)
289298
return ret;
290299

291-
data->rstrobe = ret;
300+
data->timings.rstrobe = ret;
292301
}
293302

294303
if (!of_property_read_u32(np, "ti,cs-read-setup-ns", &val)) {
295304
ret = aemif_calc_rate(pdev, val, clk_rate, RSETUP_MAX);
296305
if (ret < 0)
297306
return ret;
298307

299-
data->rsetup = ret;
308+
data->timings.rsetup = ret;
300309
}
301310

302311
if (!of_property_read_u32(np, "ti,cs-write-hold-ns", &val)) {
303312
ret = aemif_calc_rate(pdev, val, clk_rate, WHOLD_MAX);
304313
if (ret < 0)
305314
return ret;
306315

307-
data->whold = ret;
316+
data->timings.whold = ret;
308317
}
309318

310319
if (!of_property_read_u32(np, "ti,cs-write-strobe-ns", &val)) {
311320
ret = aemif_calc_rate(pdev, val, clk_rate, WSTROBE_MAX);
312321
if (ret < 0)
313322
return ret;
314323

315-
data->wstrobe = ret;
324+
data->timings.wstrobe = ret;
316325
}
317326

318327
if (!of_property_read_u32(np, "ti,cs-write-setup-ns", &val)) {
319328
ret = aemif_calc_rate(pdev, val, clk_rate, WSETUP_MAX);
320329
if (ret < 0)
321330
return ret;
322331

323-
data->wsetup = ret;
332+
data->timings.wsetup = ret;
324333
}
325334

326335
if (!of_property_read_u32(np, "ti,cs-bus-width", &val))

0 commit comments

Comments
 (0)