aboutsummaryrefslogtreecommitdiff
path: root/src/soc/intel/apollolake
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2016-11-09 17:09:40 -0600
committerAaron Durbin <adurbin@chromium.org>2016-11-11 03:11:45 +0100
commit4668ba77eaf0418eac37fe67ba06a450d3eafe88 (patch)
tree9d659fa7a43a43f4a69f302251f0c70420663ec9 /src/soc/intel/apollolake
parented14a4e0df25e55cea2b72a87087aaeb3540c785 (diff)
soc/intel/common/lpss_i2c: simplify API and use common config structure
The apollolake and skylake had duplicate stanzas of code for initializing the i2c buses. Additionally, they also had very similar structures for providing settings for the i2c speed control. Introduce a new struct lpss_i2c_bus_config and utilize it in both apollolake and skylake thereby removing the need for SoC-specific structres. The new structure is used for initializing a bus fully as the lpss i2c API is simplified in that lpss_i2c_init() is only required to be called. The struct lpss_i2c_bus_config structure is passed in for both initializing and filling in the SSDT information. The formerly exposed functions are made static to reduce the external API exposure. BUG=chrome-os-partner:58889 Change-Id: Ib4fa8a7a4de052da75c778a7658741a5a8e0e6b9 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/17348 Reviewed-by: Furquan Shaikh <furquan@google.com> Tested-by: build bot (Jenkins) Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Diffstat (limited to 'src/soc/intel/apollolake')
-rw-r--r--src/soc/intel/apollolake/chip.h11
-rw-r--r--src/soc/intel/apollolake/i2c.c18
-rw-r--r--src/soc/intel/apollolake/i2c_early.c14
3 files changed, 5 insertions, 38 deletions
diff --git a/src/soc/intel/apollolake/chip.h b/src/soc/intel/apollolake/chip.h
index 6c3bcd8cad..dd301067cc 100644
--- a/src/soc/intel/apollolake/chip.h
+++ b/src/soc/intel/apollolake/chip.h
@@ -28,15 +28,6 @@
#define CLKREQ_DISABLED 0xf
#define APOLLOLAKE_I2C_DEV_MAX 8
-struct apollolake_i2c_config {
- /* Bus should be enabled prior to ramstage with temporary base */
- int early_init;
- /* Bus speed in Hz, default is I2C_SPEED_FAST (400 KHz) */
- enum i2c_speed speed;
- /* Specific bus speed configuration */
- struct lpss_i2c_speed_config speed_config[LPSS_I2C_SPEED_CONFIG_COUNT];
-};
-
/* Serial IRQ control. SERIRQ_QUIET is the default (0). */
enum serirq_mode {
SERIRQ_QUIET,
@@ -95,7 +86,7 @@ struct soc_intel_apollolake_config {
enum serirq_mode serirq_mode;
/* I2C bus configuration */
- struct apollolake_i2c_config i2c[APOLLOLAKE_I2C_DEV_MAX];
+ struct lpss_i2c_bus_config i2c[APOLLOLAKE_I2C_DEV_MAX];
uint8_t gpe0_dw1; /* GPE0_63_32 STS/EN */
uint8_t gpe0_dw2; /* GPE0_95_64 STS/EN */
diff --git a/src/soc/intel/apollolake/i2c.c b/src/soc/intel/apollolake/i2c.c
index 1c16a06058..69cb4b8d5f 100644
--- a/src/soc/intel/apollolake/i2c.c
+++ b/src/soc/intel/apollolake/i2c.c
@@ -60,24 +60,12 @@ static int i2c_dev_to_bus(struct device *dev)
static void i2c_dev_init(struct device *dev)
{
struct soc_intel_apollolake_config *config = dev->chip_info;
- const struct lpss_i2c_speed_config *sptr;
- enum i2c_speed speed;
- int i, bus = i2c_dev_to_bus(dev);
+ int bus = i2c_dev_to_bus(dev);
if (!config || bus < 0)
return;
- speed = config->i2c[bus].speed ? : I2C_SPEED_FAST;
- lpss_i2c_init(bus, speed);
-
- /* Apply custom speed config if it has been set by the board */
- for (i = 0; i < LPSS_I2C_SPEED_CONFIG_COUNT; i++) {
- sptr = &config->i2c[bus].speed_config[i];
- if (sptr->speed == speed) {
- lpss_i2c_set_speed_config(bus, sptr);
- break;
- }
- }
+ lpss_i2c_init(bus, &config->i2c[bus]);
}
static void i2c_fill_ssdt(struct device *dev)
@@ -89,7 +77,7 @@ static void i2c_fill_ssdt(struct device *dev)
return;
acpigen_write_scope(acpi_device_path(dev));
- lpss_i2c_acpi_fill_ssdt(config->i2c[bus].speed_config);
+ lpss_i2c_acpi_fill_ssdt(&config->i2c[bus]);
acpigen_pop_len();
}
diff --git a/src/soc/intel/apollolake/i2c_early.c b/src/soc/intel/apollolake/i2c_early.c
index 82883f847d..7c188a8544 100644
--- a/src/soc/intel/apollolake/i2c_early.c
+++ b/src/soc/intel/apollolake/i2c_early.c
@@ -29,8 +29,6 @@ static int i2c_early_init_bus(unsigned bus)
{
ROMSTAGE_CONST struct soc_intel_apollolake_config *config;
ROMSTAGE_CONST struct device *tree_dev;
- const struct lpss_i2c_speed_config *sptr;
- enum i2c_speed speed;
pci_devfn_t dev;
int devfn;
uintptr_t base;
@@ -72,21 +70,11 @@ static int i2c_early_init_bus(unsigned bus)
write32(reg, value);
/* Initialize the controller */
- speed = config->i2c[bus].speed ? : I2C_SPEED_FAST;
- if (lpss_i2c_init(bus, speed) < 0) {
+ if (lpss_i2c_init(bus, &config->i2c[bus]) < 0) {
printk(BIOS_ERR, "I2C%u failed to initialize\n", bus);
return -1;
}
- /* Apply custom speed config if it has been set by the board */
- for (value = 0; value < LPSS_I2C_SPEED_CONFIG_COUNT; value++) {
- sptr = &config->i2c[bus].speed_config[value];
- if (sptr->speed == speed) {
- lpss_i2c_set_speed_config(bus, sptr);
- break;
- }
- }
-
return 0;
}