Skip to content

Commit 1865ffe

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 b04dd32 commit 1865ffe

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
@@ -36,7 +36,8 @@
3636
`timescale 1ns/100ps
3737

3838
module ad9084_ebz_spi #(
39-
parameter NUM_OF_SLAVES = 8
39+
parameter NUM_OF_SLAVES = 8,
40+
parameter IS_4WIRE = 8'b00000001
4041
) (
4142
input [NUM_OF_SLAVES-1:0] spi_csn,
4243
input spi_clk,
@@ -57,6 +58,8 @@ module ad9084_ebz_spi #(
5758
wire spi_csn_s;
5859
wire spi_enable_s;
5960

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

6265
assign spi_csn_s = & spi_csn;
@@ -86,7 +89,15 @@ module ad9084_ebz_spi #(
8689

8790
// io buffer
8891

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

92103
endmodule

projects/ad9084_ebz/fm87/system_top.v

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

226226
ad9084_ebz_spi #(
227-
.NUM_OF_SLAVES(2)
227+
.NUM_OF_SLAVES(2),
228+
.IS_4WIRE(2'b01)
228229
) i_spi (
229230
.spi_csn (spi_csn[1:0]),
230231
.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
@@ -313,7 +313,8 @@ module system_top #(
313313
assign spi2_sclk = spi_clk;
314314

315315
ad9084_ebz_spi #(
316-
.NUM_OF_SLAVES(2)
316+
.NUM_OF_SLAVES(2),
317+
.IS_4WIRE(2'b01)
317318
) i_spi (
318319
.spi_csn (spi_csn[1:0]),
319320
.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
@@ -286,7 +286,8 @@ module system_top #(
286286
assign spi2_sclk = spi_clk;
287287

288288
ad9084_ebz_spi #(
289-
.NUM_OF_SLAVES(2)
289+
.NUM_OF_SLAVES(2),
290+
.IS_4WIRE(2'b01)
290291
) i_spi (
291292
.spi_csn (spi_csn[1:0]),
292293
.spi_clk (spi_clk),

0 commit comments

Comments
 (0)