Skip to content

Commit 18380c5

Browse files
gastmaierbluncan
authored andcommitted
apollo: spi: Set 4 wire spi through parameters
Simplifies identifying which SPI are 4-wire or 3-wire. Also, for vck190, since the SPI interface only has 3 outputs, route adf4030 to the third. The adf4030 linux driver defaults to 4-wire, and 3-wire (datasheet default) can be set through devicetree property adi,spi-3wire-enable. Signed-off-by: Jorge Marques <jorge.marques@analog.com>
1 parent cbed3eb commit 18380c5

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

projects/ad9084_ebz/common/ad9084_ebz_spi.v

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737

3838
module ad9084_ebz_spi #(
3939

40-
parameter NUM_OF_SLAVES = 8
40+
parameter NUM_OF_SLAVES = 8,
41+
parameter IS_4WIRE = 8'b00000001
4142
) (
4243
input [NUM_OF_SLAVES-1:0] spi_csn,
4344
input spi_clk,
@@ -58,6 +59,8 @@ module ad9084_ebz_spi #(
5859
wire spi_csn_s;
5960
wire spi_enable_s;
6061

62+
wire [NUM_OF_SLAVES-1:0] spi_csn_4wire;
63+
6164
// check on rising edge and change on falling edge
6265

6366
assign spi_csn_s = & spi_csn;
@@ -87,7 +90,15 @@ module ad9084_ebz_spi #(
8790

8891
// io buffer
8992

90-
assign spi_miso = (spi_csn[0] == 1'b0) ? spi_miso_in : spi_sdio;
93+
genvar i;
94+
95+
generate
96+
for (i = 0; i < NUM_OF_SLAVES ; i = i + 1) begin
97+
assign spi_csn_4wire[i] = (IS_4WIRE[i] == 1'b1) ? spi_csn[i] : 1'b1;
98+
end
99+
endgenerate
100+
101+
assign spi_miso = (&spi_csn_4wire == 1'b0) ? spi_miso_in : spi_sdio;
91102
assign spi_sdio = (spi_enable_s == 1'b1) ? 1'bz : spi_mosi;
92103

93104
endmodule

projects/ad9084_ebz/fm87/system_top.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ module system_top #(
227227
assign spi2_sclk = spi_clk;
228228

229229
ad9084_ebz_spi #(
230-
.NUM_OF_SLAVES(2)
230+
.NUM_OF_SLAVES(2),
231+
.IS_4WIRE(2'b01)
231232
) i_spi (
232233
.spi_csn (spi_csn[1:0]),
233234
.spi_clk (spi_clk),

projects/ad9084_ebz/vck190/system_top.v

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,15 @@ module system_top #(
262262
.O (tx_device_clk));
263263

264264
// spi
265-
assign spi2_cs[5:0] = spi_csn[5:0];
265+
assign spi2_cs[1:0] = spi_csn[1:0];
266+
assign spi2_cs[4] = spi_csn[2];
266267
assign spi2_sclk = spi_clk;
267268

268269
ad9084_ebz_spi #(
269-
.NUM_OF_SLAVES(2)
270+
.NUM_OF_SLAVES(3),
271+
.IS_4WIRE(3'b101)
270272
) i_spi (
271-
.spi_csn (spi_csn[1:0]),
273+
.spi_csn (spi_csn[2:0]),
272274
.spi_clk (spi_clk),
273275
.spi_mosi (spi_sdio),
274276
.spi_miso (spi_sdo),

projects/ad9084_ebz/vcu118/system_top.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ module system_top #(
319319
assign spi2_sclk = spi_clk;
320320

321321
ad9084_ebz_spi #(
322-
.NUM_OF_SLAVES(2)
322+
.NUM_OF_SLAVES(2),
323+
.IS_4WIRE(2'b01)
323324
) i_spi (
324325
.spi_csn (spi_csn[1:0]),
325326
.spi_clk (spi_clk),

projects/ad9084_ebz/vpk180/system_top.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ module system_top #(
289289
assign spi2_sclk = spi_clk;
290290

291291
ad9084_ebz_spi #(
292-
.NUM_OF_SLAVES(2)
292+
.NUM_OF_SLAVES(2),
293+
.IS_4WIRE(2'b01)
293294
) i_spi (
294295
.spi_csn (spi_csn[1:0]),
295296
.spi_clk (spi_clk),

0 commit comments

Comments
 (0)