acpi: Support generation of SPI descriptor

Add a function to write a SPI descriptor to the generated ACPI code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
Simon Glass
2020-07-07 13:11:49 -06:00
committed by Bin Meng
parent 31e1787ec1
commit 70e5e67a4d
5 changed files with 212 additions and 2 deletions

View File

@@ -10,6 +10,7 @@
#define __ACPI_DEVICE_H
#include <i2c.h>
#include <spi.h>
#include <linux/bitops.h>
struct acpi_ctx;
@@ -186,8 +187,11 @@ struct acpi_gpio {
/* ACPI Descriptors for Serial Bus interfaces */
#define ACPI_SERIAL_BUS_TYPE_I2C 1
#define ACPI_SERIAL_BUS_TYPE_SPI 2
#define ACPI_I2C_SERIAL_BUS_REVISION_ID 1 /* TODO: upgrade to 2 */
#define ACPI_I2C_TYPE_SPECIFIC_REVISION_ID 1
#define ACPI_SPI_SERIAL_BUS_REVISION_ID 1
#define ACPI_SPI_TYPE_SPECIFIC_REVISION_ID 1
/**
* struct acpi_i2c - representation of an ACPI I2C device
@@ -204,6 +208,29 @@ struct acpi_i2c {
const char *resource;
};
/**
* struct acpi_spi - representation of an ACPI SPI device
*
* @device_select: Chip select used by this device (typically 0)
* @device_select_polarity: Polarity for the device
* @wire_mode: Number of wires used for SPI
* @speed: Bus speed in Hz
* @data_bit_length: Word length for SPI (typically 8)
* @clock_phase: Clock phase to capture data
* @clock_polarity: Bus polarity
* @resource: Resource name for the SPI controller
*/
struct acpi_spi {
u16 device_select;
enum spi_polarity device_select_polarity;
enum spi_wire_mode wire_mode;
unsigned int speed;
u8 data_bit_length;
enum spi_clock_phase clock_phase;
enum spi_polarity clock_polarity;
const char *resource;
};
/**
* acpi_device_path() - Get the full path to an ACPI device
*
@@ -303,4 +330,16 @@ int acpi_device_write_interrupt_or_gpio(struct acpi_ctx *ctx,
*/
int acpi_device_write_i2c_dev(struct acpi_ctx *ctx, const struct udevice *dev);
/**
* acpi_device_write_spi_dev() - Write a SPI device to ACPI
*
* This writes a serial bus descriptor for the SPI device so that ACPI can use
* it
*
* @ctx: ACPI context pointer
* @dev: SPI device to write
* @return 0 if OK, -ve on error
*/
int acpi_device_write_spi_dev(struct acpi_ctx *ctx, const struct udevice *dev);
#endif