[coreboot-gerrit] Change in coreboot[master]: drivers/spi: Get rid of spi_get_config
Furquan Shaikh (Code Review)
gerrit at coreboot.org
Sun Apr 9 21:35:57 CEST 2017
Furquan Shaikh has submitted this change and it was merged. ( https://review.coreboot.org/19203 )
Change subject: drivers/spi: Get rid of spi_get_config
......................................................................
drivers/spi: Get rid of spi_get_config
There is only one user for spi_get_config i.e. SPI ACPI. Also, the
values provided by spi_get_config are constant for now. Thus, get rid
of the spi_get_config call and fill in these constant values in SPI
ACPI code itself. If there is a need in the future to change these,
appropriate device-tree configs can be added.
BUG=b:36873582
Change-Id: Ied38e2670784ee3317bb12e542666c224bd9e819
Signed-off-by: Furquan Shaikh <furquan at chromium.org>
Reviewed-on: https://review.coreboot.org/19203
Reviewed-by: Aaron Durbin <adurbin at chromium.org>
Tested-by: build bot (Jenkins)
---
M src/drivers/spi/acpi/acpi.c
M src/drivers/spi/spi-generic.c
M src/include/spi-generic.h
M src/soc/intel/common/block/gspi/gspi.c
4 files changed, 8 insertions(+), 58 deletions(-)
Approvals:
Aaron Durbin: Looks good to me, approved
build bot (Jenkins): Verified
diff --git a/src/drivers/spi/acpi/acpi.c b/src/drivers/spi/acpi/acpi.c
index 028a37c..102780f 100644
--- a/src/drivers/spi/acpi/acpi.c
+++ b/src/drivers/spi/acpi/acpi.c
@@ -76,13 +76,15 @@
struct drivers_spi_acpi_config *config = dev->chip_info;
const char *scope = acpi_device_scope(dev);
const char *path = acpi_device_path(dev);
- struct spi_cfg spi_cfg;
- struct spi_slave slave;
- int bus = -1, cs = dev->path.spi.cs;
struct acpi_spi spi = {
- .device_select = cs,
+ .device_select = dev->path.spi.cs,
.speed = config->speed ? : 1 * MHz,
.resource = scope,
+ .device_select_polarity = SPI_POLARITY_LOW,
+ .wire_mode = SPI_4_WIRE_MODE,
+ .data_bit_length = 8,
+ .clock_phase = SPI_CLOCK_PHASE_FIRST,
+ .clock_polarity = SPI_POLARITY_LOW,
};
int curr_index = 0;
int irq_gpio_index = -1;
@@ -92,10 +94,9 @@
if (!dev->enabled || !scope)
return;
- bus = spi_acpi_get_bus(dev);
- if (bus == -1) {
+ if (spi_acpi_get_bus(dev) == -1) {
printk(BIOS_ERR, "%s: ERROR: Cannot get bus for device.\n",
- dev_path(dev));
+ dev_path(dev));
return;
}
@@ -103,23 +104,6 @@
printk(BIOS_ERR, "%s: ERROR: HID required.\n", dev_path(dev));
return;
}
-
- if (spi_setup_slave(bus, cs, &slave)) {
- printk(BIOS_ERR, "%s: ERROR: SPI setup failed.\n",
- dev_path(dev));
- return;
- }
-
- if (spi_get_config(&slave, &spi_cfg)) {
- printk(BIOS_ERR, "%s: ERROR: SPI get config failed.\n",
- dev_path(dev));
- return;
- }
-
- spi.device_select_polarity = spi_cfg.cs_polarity;
- spi.wire_mode = spi_cfg.wire_mode;
- spi.data_bit_length = spi_cfg.data_bit_length;
- spi.clock_phase = spi_cfg.clk_phase;
/* Device */
acpigen_write_scope(scope);
diff --git a/src/drivers/spi/spi-generic.c b/src/drivers/spi/spi-generic.c
index 3ef437c..805e17a 100644
--- a/src/drivers/spi/spi-generic.c
+++ b/src/drivers/spi/spi-generic.c
@@ -88,16 +88,6 @@
return -1;
}
-int spi_get_config(const struct spi_slave *slave, struct spi_cfg *cfg)
-{
- const struct spi_ctrlr *ctrlr = slave->ctrlr;
-
- if (ctrlr && ctrlr->get_config)
- return ctrlr->get_config(slave, cfg);
-
- return -1;
-}
-
void __attribute__((weak)) spi_init(void)
{
/* Default weak implementation - do nothing. */
diff --git a/src/include/spi-generic.h b/src/include/spi-generic.h
index cc3d3cf..7d957a0 100644
--- a/src/include/spi-generic.h
+++ b/src/include/spi-generic.h
@@ -90,7 +90,6 @@
/*-----------------------------------------------------------------------
* Representation of a SPI contoller.
*
- * get_config: Get configuration of SPI bus
* claim_bus: Claim SPI bus and prepare for communication.
* release_bus: Release SPI bus.
* setup: Setup given SPI device bus.
@@ -98,8 +97,6 @@
* xfer_vector: Vector of SPI transfer operations.
*/
struct spi_ctrlr {
- int (*get_config)(const struct spi_slave *slave,
- struct spi_cfg *cfg);
int (*claim_bus)(const struct spi_slave *slave);
void (*release_bus)(const struct spi_slave *slave);
int (*setup)(const struct spi_slave *slave);
diff --git a/src/soc/intel/common/block/gspi/gspi.c b/src/soc/intel/common/block/gspi/gspi.c
index f3c1460..74b9475 100644
--- a/src/soc/intel/common/block/gspi/gspi.c
+++ b/src/soc/intel/common/block/gspi/gspi.c
@@ -307,26 +307,6 @@
return 0;
}
-static int gspi_ctrlr_get_config(const struct spi_slave *dev,
- struct spi_cfg *cfg)
-{
- unsigned int gspi_bus;
-
- /* Currently, only chip select 0 is supported. */
- if (dev->cs != 0) {
- printk(BIOS_ERR, "%s: Invalid CS value: cs=%u.\n", __func__,
- dev->cs);
- return -1;
- }
-
- if (gspi_soc_spi_to_gspi_bus(dev->bus, &gspi_bus)) {
- printk(BIOS_ERR, "%s: Failed to find GSPI bus for SPI %u.\n",
- __func__, dev->bus);
- return -1;
- }
- return gspi_get_soc_spi_cfg(gspi_bus, cfg);
-}
-
static int gspi_cs_assert(const struct spi_slave *dev)
{
return gspi_cs_change(dev, CS_ASSERT);
@@ -627,7 +607,6 @@
}
const struct spi_ctrlr gspi_ctrlr = {
- .get_config = gspi_ctrlr_get_config,
.claim_bus = gspi_cs_assert,
.release_bus = gspi_cs_deassert,
.setup = gspi_ctrlr_setup,
--
To view, visit https://review.coreboot.org/19203
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ied38e2670784ee3317bb12e542666c224bd9e819
Gerrit-PatchSet: 6
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Furquan Shaikh <furquan at google.com>
Gerrit-Reviewer: Aaron Durbin <adurbin at chromium.org>
Gerrit-Reviewer: Duncan Laurie <dlaurie at chromium.org>
Gerrit-Reviewer: Furquan Shaikh <furquan at google.com>
Gerrit-Reviewer: Paul Menzel <paulepanter at users.sourceforge.net>
Gerrit-Reviewer: Subrata Banik <subrata.banik at intel.com>
Gerrit-Reviewer: build bot (Jenkins)
More information about the coreboot-gerrit
mailing list