Skip to content

Commit c4ec743

Browse files
tpetazzoniJason Cooper
authored andcommitted
memory: mvebu-devbus: add Orion5x support
This commit adds support for the Orion5x family of Marvell processors into the mvebu-devbus driver. It differs from the already supported Armada 370/XP by: * Having a single register (instead of two) for doing all the timing configuration. * Having a few less timing configuration parameters. For this reason, a separate compatible string "marvell,orion-devbus" is introduced. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Tested-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Link: https://lkml.kernel.org/r/1398202002-28530-9-git-send-email-thomas.petazzoni@free-electrons.com Signed-off-by: Jason Cooper <jason@lakedaemon.net>
1 parent 30bd30b commit c4ec743

2 files changed

Lines changed: 106 additions & 26 deletions

File tree

‎Documentation/devicetree/bindings/memory-controllers/mvebu-devbus.txt‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ The actual devices are instantiated from the child nodes of a Device Bus node.
66

77
Required properties:
88

9-
- compatible: Currently only Armada 370/XP SoC are supported,
10-
with this compatible string:
9+
- compatible: Armada 370/XP SoC are supported using the
10+
"marvell,mvebu-devbus" compatible string.
1111

12-
marvell,mvebu-devbus
12+
Orion5x SoC are supported using the
13+
"marvell,orion-devbus" compatible string.
1314

1415
- reg: A resource specifier for the register space.
1516
This is the base address of a chip select within
@@ -22,36 +23,43 @@ Required properties:
2223
integer values for each chip-select line in use:
2324
0 <physical address of mapping> <size>
2425

25-
Mandatory timing properties for child nodes:
26+
Timing properties for child nodes:
2627

2728
Read parameters:
2829

2930
- devbus,turn-off-ps: Defines the time during which the controller does not
3031
drive the AD bus after the completion of a device read.
3132
This prevents contentions on the Device Bus after a read
3233
cycle from a slow device.
34+
Mandatory.
3335

34-
- devbus,bus-width: Defines the bus width (e.g. <16>)
36+
- devbus,bus-width: Defines the bus width, in bits (e.g. <16>).
37+
Mandatory.
3538

3639
- devbus,badr-skew-ps: Defines the time delay from from A[2:0] toggle,
3740
to read data sample. This parameter is useful for
3841
synchronous pipelined devices, where the address
3942
precedes the read data by one or two cycles.
43+
Mandatory.
4044

4145
- devbus,acc-first-ps: Defines the time delay from the negation of
4246
ALE[0] to the cycle that the first read data is sampled
4347
by the controller.
48+
Mandatory.
4449

4550
- devbus,acc-next-ps: Defines the time delay between the cycle that
4651
samples data N and the cycle that samples data N+1
4752
(in burst accesses).
53+
Mandatory.
4854

4955
- devbus,rd-setup-ps: Defines the time delay between DEV_CSn assertion to
5056
DEV_OEn assertion. If set to 0 (default),
5157
DEV_OEn and DEV_CSn are asserted at the same cycle.
5258
This parameter has no affect on <acc-first-ps> parameter
5359
(no affect on first data sample). Set <rd-setup-ps>
5460
to a value smaller than <acc-first-ps>.
61+
Mandatory for "marvell,mvebu-devbus"
62+
compatible string, ignored otherwise.
5563

5664
- devbus,rd-hold-ps: Defines the time between the last data sample to the
5765
de-assertion of DEV_CSn. If set to 0 (default),
@@ -62,27 +70,34 @@ Read parameters:
6270
last data sampled. Also this parameter has no
6371
affect on <turn-off-ps> parameter.
6472
Set <rd-hold-ps> to a value smaller than <turn-off-ps>.
73+
Mandatory for "marvell,mvebu-devbus"
74+
compatible string, ignored otherwise.
6575

6676
Write parameters:
6777

6878
- devbus,ale-wr-ps: Defines the time delay from the ALE[0] negation cycle
6979
to the DEV_WEn assertion.
80+
Mandatory.
7081

7182
- devbus,wr-low-ps: Defines the time during which DEV_WEn is active.
7283
A[2:0] and Data are kept valid as long as DEV_WEn
7384
is active. This parameter defines the setup time of
7485
address and data to DEV_WEn rise.
86+
Mandatory.
7587

7688
- devbus,wr-high-ps: Defines the time during which DEV_WEn is kept
7789
inactive (high) between data beats of a burst write.
7890
DEV_A[2:0] and Data are kept valid (do not toggle) for
7991
<wr-high-ps> - <tick> ps.
8092
This parameter defines the hold time of address and
8193
data after DEV_WEn rise.
94+
Mandatory.
8295

8396
- devbus,sync-enable: Synchronous device enable.
8497
1: True
8598
0: False
99+
Mandatory for "marvell,mvebu-devbus" compatible
100+
string, ignored otherwise.
86101

87102
An example for an Armada XP GP board, with a 16 MiB NOR device as child
88103
is showed below. Note that the Device Bus driver is in charge of allocating

‎drivers/memory/mvebu-devbus.c‎

Lines changed: 86 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Marvell EBU SoC Device Bus Controller
33
* (memory controller for NOR/NAND/SRAM/FPGA devices)
44
*
5-
* Copyright (C) 2013 Marvell
5+
* Copyright (C) 2013-2014 Marvell
66
*
77
* This program is free software: you can redistribute it and/or modify
88
* it under the terms of the GNU General Public License as published by
@@ -44,6 +44,34 @@
4444
#define ARMADA_READ_PARAM_OFFSET 0x0
4545
#define ARMADA_WRITE_PARAM_OFFSET 0x4
4646

47+
#define ORION_RESERVED (0x2 << 30)
48+
#define ORION_BADR_SKEW_SHIFT 28
49+
#define ORION_WR_HIGH_EXT_BIT BIT(27)
50+
#define ORION_WR_HIGH_EXT_MASK 0x8
51+
#define ORION_WR_LOW_EXT_BIT BIT(26)
52+
#define ORION_WR_LOW_EXT_MASK 0x8
53+
#define ORION_ALE_WR_EXT_BIT BIT(25)
54+
#define ORION_ALE_WR_EXT_MASK 0x8
55+
#define ORION_ACC_NEXT_EXT_BIT BIT(24)
56+
#define ORION_ACC_NEXT_EXT_MASK 0x10
57+
#define ORION_ACC_FIRST_EXT_BIT BIT(23)
58+
#define ORION_ACC_FIRST_EXT_MASK 0x10
59+
#define ORION_TURN_OFF_EXT_BIT BIT(22)
60+
#define ORION_TURN_OFF_EXT_MASK 0x8
61+
#define ORION_DEV_WIDTH_SHIFT 20
62+
#define ORION_WR_HIGH_SHIFT 17
63+
#define ORION_WR_HIGH_MASK 0x7
64+
#define ORION_WR_LOW_SHIFT 14
65+
#define ORION_WR_LOW_MASK 0x7
66+
#define ORION_ALE_WR_SHIFT 11
67+
#define ORION_ALE_WR_MASK 0x7
68+
#define ORION_ACC_NEXT_SHIFT 7
69+
#define ORION_ACC_NEXT_MASK 0xF
70+
#define ORION_ACC_FIRST_SHIFT 3
71+
#define ORION_ACC_FIRST_MASK 0xF
72+
#define ORION_TURN_OFF_SHIFT 0
73+
#define ORION_TURN_OFF_MASK 0x7
74+
4775
struct devbus_read_params {
4876
u32 bus_width;
4977
u32 badr_skew;
@@ -96,7 +124,6 @@ static int devbus_get_timing_params(struct devbus *devbus,
96124
{
97125
int err;
98126

99-
/* Get read timings */
100127
err = of_property_read_u32(node, "devbus,bus-width", &r->bus_width);
101128
if (err < 0) {
102129
dev_err(devbus->dev,
@@ -138,24 +165,25 @@ static int devbus_get_timing_params(struct devbus *devbus,
138165
if (err < 0)
139166
return err;
140167

141-
err = get_timing_param_ps(devbus, node, "devbus,rd-setup-ps",
142-
&r->rd_setup);
143-
if (err < 0)
144-
return err;
145-
146-
err = get_timing_param_ps(devbus, node, "devbus,rd-hold-ps",
147-
&r->rd_hold);
148-
if (err < 0)
149-
return err;
150-
151-
/* Get write timings */
152-
err = of_property_read_u32(node, "devbus,sync-enable",
153-
&w->sync_enable);
154-
if (err < 0) {
155-
dev_err(devbus->dev,
156-
"%s has no 'devbus,sync-enable' property\n",
157-
node->full_name);
158-
return err;
168+
if (of_device_is_compatible(devbus->dev->of_node, "marvell,mvebu-devbus")) {
169+
err = get_timing_param_ps(devbus, node, "devbus,rd-setup-ps",
170+
&r->rd_setup);
171+
if (err < 0)
172+
return err;
173+
174+
err = get_timing_param_ps(devbus, node, "devbus,rd-hold-ps",
175+
&r->rd_hold);
176+
if (err < 0)
177+
return err;
178+
179+
err = of_property_read_u32(node, "devbus,sync-enable",
180+
&w->sync_enable);
181+
if (err < 0) {
182+
dev_err(devbus->dev,
183+
"%s has no 'devbus,sync-enable' property\n",
184+
node->full_name);
185+
return err;
186+
}
159187
}
160188

161189
err = get_timing_param_ps(devbus, node, "devbus,ale-wr-ps",
@@ -176,6 +204,39 @@ static int devbus_get_timing_params(struct devbus *devbus,
176204
return 0;
177205
}
178206

207+
static void devbus_orion_set_timing_params(struct devbus *devbus,
208+
struct device_node *node,
209+
struct devbus_read_params *r,
210+
struct devbus_write_params *w)
211+
{
212+
u32 value;
213+
214+
/*
215+
* The hardware designers found it would be a good idea to
216+
* split most of the values in the register into two fields:
217+
* one containing all the low-order bits, and another one
218+
* containing just the high-order bit. For all of those
219+
* fields, we have to split the value into these two parts.
220+
*/
221+
value = (r->turn_off & ORION_TURN_OFF_MASK) << ORION_TURN_OFF_SHIFT |
222+
(r->acc_first & ORION_ACC_FIRST_MASK) << ORION_ACC_FIRST_SHIFT |
223+
(r->acc_next & ORION_ACC_NEXT_MASK) << ORION_ACC_NEXT_SHIFT |
224+
(w->ale_wr & ORION_ALE_WR_MASK) << ORION_ALE_WR_SHIFT |
225+
(w->wr_low & ORION_WR_LOW_MASK) << ORION_WR_LOW_SHIFT |
226+
(w->wr_high & ORION_WR_HIGH_MASK) << ORION_WR_HIGH_SHIFT |
227+
r->bus_width << ORION_DEV_WIDTH_SHIFT |
228+
((r->turn_off & ORION_TURN_OFF_EXT_MASK) ? ORION_TURN_OFF_EXT_BIT : 0) |
229+
((r->acc_first & ORION_ACC_FIRST_EXT_MASK) ? ORION_ACC_FIRST_EXT_BIT : 0) |
230+
((r->acc_next & ORION_ACC_NEXT_EXT_MASK) ? ORION_ACC_NEXT_EXT_BIT : 0) |
231+
((w->ale_wr & ORION_ALE_WR_EXT_MASK) ? ORION_ALE_WR_EXT_BIT : 0) |
232+
((w->wr_low & ORION_WR_LOW_EXT_MASK) ? ORION_WR_LOW_EXT_BIT : 0) |
233+
((w->wr_high & ORION_WR_HIGH_EXT_MASK) ? ORION_WR_HIGH_EXT_BIT : 0) |
234+
(r->badr_skew << ORION_BADR_SKEW_SHIFT) |
235+
ORION_RESERVED;
236+
237+
writel(value, devbus->base);
238+
}
239+
179240
static void devbus_armada_set_timing_params(struct devbus *devbus,
180241
struct device_node *node,
181242
struct devbus_read_params *r,
@@ -255,7 +316,10 @@ static int mvebu_devbus_probe(struct platform_device *pdev)
255316
return err;
256317

257318
/* Set the new timing parameters */
258-
devbus_armada_set_timing_params(devbus, node, &r, &w);
319+
if (of_device_is_compatible(node, "marvell,orion-devbus"))
320+
devbus_orion_set_timing_params(devbus, node, &r, &w);
321+
else
322+
devbus_armada_set_timing_params(devbus, node, &r, &w);
259323

260324
/*
261325
* We need to create a child device explicitly from here to
@@ -271,6 +335,7 @@ static int mvebu_devbus_probe(struct platform_device *pdev)
271335

272336
static const struct of_device_id mvebu_devbus_of_match[] = {
273337
{ .compatible = "marvell,mvebu-devbus" },
338+
{ .compatible = "marvell,orion-devbus" },
274339
{},
275340
};
276341
MODULE_DEVICE_TABLE(of, mvebu_devbus_of_match);

0 commit comments

Comments
 (0)