[PATCH v4 12/35] acpi: Support generation of SPI descriptor
Bin Meng
bmeng.cn at gmail.com
Mon Jul 13 07:48:58 CEST 2020
Hi Simon,
On Mon, Jul 13, 2020 at 12:22 PM Bin Meng <bmeng.cn at gmail.com> wrote:
>
> On Wed, Jul 8, 2020 at 3:12 AM Simon Glass <sjg at chromium.org> wrote:
> >
> > Add a function to write a SPI descriptor to the generated ACPI code.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > Reviewed-by: Wolfgang Wallner <wolfgang.wallner at br-automation.com>
> > Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> > ---
> >
> > Changes in v4:
> > - Move SPI macros to next patch
> > - Rename the length-writing functions to indicate they are for large resources
> >
> > Changes in v3:
> > - Make acpi_device_write_spi() static
> > - Add an extra comment about scope to acpi_device_set_spi()
> > - Use BIT() in a few places
> > - Resist the temptation to go to >80 characters
> >
> > Changes in v2:
> > - Fix memset of SPI descriptor
> >
> > drivers/spi/sandbox_spi.c | 11 ++++
> > include/acpi/acpi_device.h | 39 ++++++++++++
> > include/spi.h | 4 +-
> > lib/acpi/acpi_device.c | 124 +++++++++++++++++++++++++++++++++++++
> > test/dm/acpigen.c | 36 +++++++++++
> > 5 files changed, 212 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/spi/sandbox_spi.c b/drivers/spi/sandbox_spi.c
> > index 570ae285f2..77797bf096 100644
> > --- a/drivers/spi/sandbox_spi.c
> > +++ b/drivers/spi/sandbox_spi.c
> > @@ -21,6 +21,7 @@
> > #include <linux/errno.h>
> > #include <asm/spi.h>
> > #include <asm/state.h>
> > +#include <dm/acpi.h>
> > #include <dm/device-internal.h>
> >
> > #ifndef CONFIG_SPI_IDLE_VAL
> > @@ -133,6 +134,15 @@ static int sandbox_spi_get_mmap(struct udevice *dev, ulong *map_basep,
> > return 0;
> > }
> >
> > +static int sandbox_spi_get_name(const struct udevice *dev, char *out_name)
> > +{
> > + return acpi_copy_name(out_name, "SSPI");
> > +}
> > +
> > +struct acpi_ops sandbox_spi_acpi_ops = {
> > + .get_name = sandbox_spi_get_name,
> > +};
> > +
> > static const struct dm_spi_ops sandbox_spi_ops = {
> > .xfer = sandbox_spi_xfer,
> > .set_speed = sandbox_spi_set_speed,
> > @@ -151,4 +161,5 @@ U_BOOT_DRIVER(sandbox_spi) = {
> > .id = UCLASS_SPI,
> > .of_match = sandbox_spi_ids,
> > .ops = &sandbox_spi_ops,
> > + ACPI_OPS_PTR(&sandbox_spi_acpi_ops)
> > };
> > diff --git a/include/acpi/acpi_device.h b/include/acpi/acpi_device.h
> > index 9ba395771e..848ccb9434 100644
> > --- a/include/acpi/acpi_device.h
> > +++ b/include/acpi/acpi_device.h
> > @@ -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
> > diff --git a/include/spi.h b/include/spi.h
> > index 7fca646759..fd931d221a 100644
> > --- a/include/spi.h
> > +++ b/include/spi.h
> > @@ -13,8 +13,8 @@
> > #include <linux/bitops.h>
> >
> > /* SPI mode flags */
> > -#define SPI_CPHA BIT(0) /* clock phase */
> > -#define SPI_CPOL BIT(1) /* clock polarity */
> > +#define SPI_CPHA BIT(0) /* clock phase (1 = SPI_CLOCK_PHASE_SECOND) */
> > +#define SPI_CPOL BIT(1) /* clock polarity (1 = SPI_POLARITY_HIGH) */
> > #define SPI_MODE_0 (0|0) /* (original MicroWire) */
> > #define SPI_MODE_1 (0|SPI_CPHA)
> > #define SPI_MODE_2 (SPI_CPOL|0)
> > diff --git a/lib/acpi/acpi_device.c b/lib/acpi/acpi_device.c
> > index c0d5a9acae..b628fa1337 100644
> > --- a/lib/acpi/acpi_device.c
> > +++ b/lib/acpi/acpi_device.c
> > @@ -492,3 +492,127 @@ int acpi_device_write_i2c_dev(struct acpi_ctx *ctx, const struct udevice *dev)
> >
> > return ret;
> > }
> > +
> > +#ifdef CONFIG_SPI
>
> Dropped this #ifdef when applying
It seems that CONFIG_SPI cannot be dropped?
Please check the build failure @
https://dev.azure.com/bmeng/GitHub/_build/results?buildId=256&view=logs&j=8a1d3be7-a4c9-55b6-774d-e7f1a8f80847&t=b2f224a7-1103-5b52-edbc-3784ae727e03
Please suggest what should be the best to move on.
Regards,
Bin
More information about the U-Boot
mailing list