diff mbox series

[v2,02/39] spi: Add SPI mode enums

Message ID 20200308214442.v2.2.I83a459a3914c56ca81dcdfa7e01d83c54f7ab914@changeid
State Superseded
Headers show
Series dm: Add programmatic generation of ACPI tables (part A) | expand

Commit Message

Simon Glass March 9, 2020, 3:44 a.m. UTC
With ACPI we need to describe the settings of the SPI bus. Add enums to
handle this.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
---

Changes in v2:
- Don't bracket the definitions with DM_SPI

 include/spi.h | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

Comments

Wolfgang Wallner March 9, 2020, 7:38 a.m. UTC | #1
-----"Simon Glass" <sjg at chromium.org> schrieb: -----
> 
> With ACPI we need to describe the settings of the SPI bus. Add enums to
> handle this.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> ---
> 
> Changes in v2:
> - Don't bracket the definitions with DM_SPI
> 
>  include/spi.h | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)

Reviewed-by: Wolfgang Wallner <wolfgang.wallner at br-automation.com>
Andy Shevchenko March 9, 2020, 7:41 a.m. UTC | #2
On Mon, Mar 9, 2020 at 5:45 AM Simon Glass <sjg at chromium.org> wrote:
>
> With ACPI we need to describe the settings of the SPI bus. Add enums to
> handle this.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> ---
>
> Changes in v2:
> - Don't bracket the definitions with DM_SPI
>
>  include/spi.h | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
>
> diff --git a/include/spi.h b/include/spi.h
> index 852f570eaa..2092940f4c 100644
> --- a/include/spi.h
> +++ b/include/spi.h
> @@ -66,6 +66,39 @@ struct dm_spi_slave_platdata {
>
>  #endif /* CONFIG_DM_SPI */
>
> +/**
> + * enum spi_clock_phase - indicates  the clock phase to use for SPI (CPHA)
> + *
> + * @SPI_CLOCK_PHASE_FIRST: Data sampled on the first phase
> + * @SPI_CLOCK_PHASE_SECOND: Data sampled on the second phase
> + */
> +enum spi_clock_phase {
> +       SPI_CLOCK_PHASE_FIRST,
> +       SPI_CLOCK_PHASE_SECOND

I always forget if absence of comma in such cases (where it's not
obvious that the last item in the enum, struct or array is a
terminator line) is U-Boot style, but I this the rule of thumb is to
have comma at the end to simplify extension or adjustment  in the
future.

> +};
> +
> +/**
> + * enum spi_wire_mode - indicates the number of wires used for SPI
> + *
> + * @SPI_4_WIRE_MODE: Normal bidirectional mode with MOSI and MISO
> + * @SPI_3_WIRE_MODE: Unidirectional version with a single data line SISO
> + */
> +enum spi_wire_mode {
> +       SPI_4_WIRE_MODE,
> +       SPI_3_WIRE_MODE
> +};
> +
> +/**
> + * enum spi_polarity - indicates the polarity of the SPI bus (CPOL)
> + *
> + * @SPI_POLARITY_LOW: Clock is low in idle state
> + * @SPI_POLARITY_HIGH: Clock is high in idle state
> + */
> +enum spi_polarity {
> +       SPI_POLARITY_LOW,
> +       SPI_POLARITY_HIGH
> +};
> +
>  /**
>   * struct spi_slave - Representation of a SPI slave
>   *
> --
> 2.25.1.481.gfbce0eb801-goog
>
diff mbox series

Patch

diff --git a/include/spi.h b/include/spi.h
index 852f570eaa..2092940f4c 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -66,6 +66,39 @@  struct dm_spi_slave_platdata {
 
 #endif /* CONFIG_DM_SPI */
 
+/**
+ * enum spi_clock_phase - indicates  the clock phase to use for SPI (CPHA)
+ *
+ * @SPI_CLOCK_PHASE_FIRST: Data sampled on the first phase
+ * @SPI_CLOCK_PHASE_SECOND: Data sampled on the second phase
+ */
+enum spi_clock_phase {
+	SPI_CLOCK_PHASE_FIRST,
+	SPI_CLOCK_PHASE_SECOND
+};
+
+/**
+ * enum spi_wire_mode - indicates the number of wires used for SPI
+ *
+ * @SPI_4_WIRE_MODE: Normal bidirectional mode with MOSI and MISO
+ * @SPI_3_WIRE_MODE: Unidirectional version with a single data line SISO
+ */
+enum spi_wire_mode {
+	SPI_4_WIRE_MODE,
+	SPI_3_WIRE_MODE
+};
+
+/**
+ * enum spi_polarity - indicates the polarity of the SPI bus (CPOL)
+ *
+ * @SPI_POLARITY_LOW: Clock is low in idle state
+ * @SPI_POLARITY_HIGH: Clock is high in idle state
+ */
+enum spi_polarity {
+	SPI_POLARITY_LOW,
+	SPI_POLARITY_HIGH
+};
+
 /**
  * struct spi_slave - Representation of a SPI slave
  *