Skip to content

Commit

Permalink
spi-no-cs hack
Browse files Browse the repository at this point in the history
  • Loading branch information
dlech committed Dec 7, 2023
1 parent 38b10d6 commit 457adbe
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
10 changes: 10 additions & 0 deletions Documentation/devicetree/bindings/iio/adc/adi,ad7944.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ properties:
reg: true
spi-max-frequency: true
spi-cpha: true
spi-no-cs: true

adi,spi-mode:
$ref: /schemas/types.yaml#/definitions/string
Expand Down Expand Up @@ -163,6 +164,15 @@ allOf:
else:
properties:
adi,next-in-chain: false
- if:
properties:
adi,spi-mode:
enum:
3-wire
chain
then:
required:
- spi-no-cs
- if:
required:
- turbo-gpios
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ properties:
description:
The device requires the chip select active high.

spi-no-cs:
$ref: /schemas/types.yaml#/definitions/flag
description:
The device does not have a chip select line.

spi-lsb-first:
$ref: /schemas/types.yaml#/definitions/flag
description:
Expand Down
1 change: 1 addition & 0 deletions arch/arm/boot/dts/xilinx/zynq-zed-adv7511-ad7985.dts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
reg = <0>;
// TODO: awaiting HDL fix for CPHA
// spi-cpha;
spi-no-cs;
spi-max-frequency = <111111111>; /* 9 ns period */
adi,spi-mode = "3-wire";
cnv-gpios = <&axi_spi_engine_0 0 GPIO_ACTIVE_HIGH>;
Expand Down
16 changes: 8 additions & 8 deletions drivers/spi/spi-axi-spi-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,17 @@ static void spi_engine_gen_cs(struct spi_engine_program *p, bool dry,
struct spi_device *spi, bool assert,
struct spi_engine_gpio_state *gpio_state)
{
// TODO: uncomment when we have GPIO support in HDL currently, this
// causes all data in the DMA buffer to be 0
unsigned int mask = 0xff;

// unsigned int mask = 0xff;
if (spi->mode & SPI_NO_CS)
return;

// if (assert)
// mask ^= BIT(spi_get_chipselect(spi, 0));
if (assert)
mask ^= BIT(spi_get_chipselect(spi, 0));

// gpio_state->value = (mask & ~gpio_state->mask) | (gpio_state->value & gpio_state->mask);
gpio_state->value = (mask & ~gpio_state->mask) | (gpio_state->value & gpio_state->mask);

// spi_engine_program_add_cmd(p, dry, SPI_ENGINE_CMD_ASSERT(0, gpio_state->value));
spi_engine_program_add_cmd(p, dry, SPI_ENGINE_CMD_ASSERT(0, gpio_state->value));
}

/*
Expand Down Expand Up @@ -1262,7 +1262,7 @@ static int spi_engine_probe(struct platform_device *pdev)
}

host->dev.of_node = pdev->dev.of_node;
host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_3WIRE;
host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_3WIRE | SPI_NO_CS;
host->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
host->max_speed_hz = clk_get_rate(spi_engine->ref_clk) / 2;
host->transfer_one_message = spi_engine_transfer_one_message;
Expand Down
2 changes: 2 additions & 0 deletions drivers/spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2239,6 +2239,8 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
spi->mode |= SPI_LSB_FIRST;
if (of_property_read_bool(nc, "spi-cs-high"))
spi->mode |= SPI_CS_HIGH;
if (of_property_read_bool(nc, "spi-no-cs"))
spi->mode |= SPI_NO_CS;

/* Device DUAL/QUAD mode */
if (!of_property_read_u32(nc, "spi-tx-bus-width", &value)) {
Expand Down

0 comments on commit 457adbe

Please sign in to comment.