soc/intel/common/gspi: Use GSPI bus id to map to the controller

Currently SPI bus id is used to map to the controller in order to set
the controller state. In certain platforms SPI bus id might not be
exactly the same as GSPI bus id. For example, in Intel platforms SPI bus
id 0 maps to fast spi i.e. SPI going to the flash and SPI bus id 1 .. n
map to GSPI bus id 0 .. n-1. Hence using SPI bus id leads to mapping to the
GSPI controller that is not enabled. Use the GSPI id bus so that the right
controller is set to active state. This fixes the regression introduced
by CB:34449

BUG=b:135941367
TEST=Boot to ChromeOS.

Change-Id: I792ab1fa6529f5317218896ad05321f8f17cedcd
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34761
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Subrata Banik <subrata.banik@intel.com>
This commit is contained in:
Karthikeyan Ramasubramanian 2019-08-06 13:34:03 -06:00 committed by Martin Roth
parent 3a4511eb6c
commit c6e3708174
1 changed files with 7 additions and 9 deletions

View File

@ -452,15 +452,6 @@ static int gspi_ctrlr_setup(const struct spi_slave *dev)
struct gspi_ctrlr_params params, *p = &params;
const struct device *device;
devfn = gspi_soc_bus_to_devfn(dev->bus);
if (devfn < 0) {
printk(BIOS_ERR, "%s: No GSPI controller found on SPI bus %u.\n",
__func__, dev->bus);
return -1;
}
device = pcidev_path_on_root(devfn);
/* Only chip select 0 is supported. */
if (dev->cs != 0) {
printk(BIOS_ERR, "%s: Invalid CS value: cs=%u.\n", __func__,
@ -478,6 +469,13 @@ static int gspi_ctrlr_setup(const struct spi_slave *dev)
return -1;
}
devfn = gspi_soc_bus_to_devfn(p->gspi_bus);
/*
* devfn is already validated as part of gspi_ctrlr_params_init.
* No need to revalidate it again.
*/
device = pcidev_path_on_root(devfn);
/* Ensure controller is in D0 state */
lpss_set_power_state(device, STATE_D0);