drivers/i2c/designware: reduce API complication for bus config

Right now dw_i2c_get_soc_cfg() is expecting the SoC to implement
that callback for obtaining the bus config. However, we're currently
forcing another parameter of struct device so one can do the lookup.
This works for Intel-based systems since the struct device was needed
to program the BAR, etc. However, from an API standpoint, it just
complicates matters by needing to obtain the struct device. The SoC
already has knowlege of its own devices so it can get the config
itself by bus number. Therefore, remove that contraint from the API.

BUG=b:70232394

Change-Id: Id8558f5deedda0963a46a532a7bf984e168fb270
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/23420
Reviewed-by: Subrata Banik <subrata.banik@intel.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
Aaron Durbin 2018-01-24 16:58:18 -07:00
parent d861d4e7c3
commit b94a27506e
6 changed files with 13 additions and 11 deletions

View File

@ -772,7 +772,7 @@ void dw_i2c_dev_init(struct device *dev)
if (bus < 0)
return;
config = dw_i2c_get_soc_cfg(bus, dev);
config = dw_i2c_get_soc_cfg(bus);
if (!config)
return;
@ -806,7 +806,7 @@ void dw_i2c_acpi_fill_ssdt(struct device *dev)
if (bus < 0)
return;
bcfg = dw_i2c_get_soc_cfg(bus, dev);
bcfg = dw_i2c_get_soc_cfg(bus);
if (!bcfg)
return;

View File

@ -102,8 +102,7 @@ int dw_i2c_soc_bus_to_devfn(unsigned int bus);
*
* Returns NULL if i2c config is not found
*/
const struct dw_i2c_bus_config *dw_i2c_get_soc_cfg(unsigned int bus,
const struct device *dev);
const struct dw_i2c_bus_config *dw_i2c_get_soc_cfg(unsigned int bus);
/* Get I2C controller base address */
uintptr_t dw_i2c_base_address(unsigned int bus);

View File

@ -21,10 +21,11 @@
#include <soc/pci_devs.h>
#include "chip.h"
const struct dw_i2c_bus_config *dw_i2c_get_soc_cfg(unsigned int bus,
const struct device *dev)
const struct dw_i2c_bus_config *dw_i2c_get_soc_cfg(unsigned int bus)
{
const struct soc_intel_apollolake_config *config;
const struct device *dev = dev_find_slot(0, SA_DEVFN_ROOT);
if (!dev || !dev->chip_info) {
printk(BIOS_ERR, "%s: Could not find SoC devicetree config!\n",
__func__);

View File

@ -22,10 +22,11 @@
#include <soc/pci_devs.h>
#include "chip.h"
const struct dw_i2c_bus_config *dw_i2c_get_soc_cfg(unsigned int bus,
const struct device *dev)
const struct dw_i2c_bus_config *dw_i2c_get_soc_cfg(unsigned int bus)
{
const struct soc_intel_cannonlake_config *config;
const struct device *dev = dev_find_slot(0, SA_DEVFN_ROOT);
if (!dev || !dev->chip_info) {
printk(BIOS_ERR, "%s: Could not find SoC devicetree config!\n",
__func__);

View File

@ -47,7 +47,7 @@ static int lpss_i2c_early_init_bus(unsigned int bus)
}
/* Skip if not enabled for early init */
config = dw_i2c_get_soc_cfg(bus, tree_dev);
config = dw_i2c_get_soc_cfg(bus);
if (!config || !config->early_init) {
printk(BIOS_DEBUG, "I2C%u not enabled for early init\n", bus);
return -1;

View File

@ -20,10 +20,11 @@
#include <soc/pci_devs.h>
#include "chip.h"
const struct dw_i2c_bus_config *dw_i2c_get_soc_cfg(unsigned int bus,
const struct device *dev)
const struct dw_i2c_bus_config *dw_i2c_get_soc_cfg(unsigned int bus)
{
const struct soc_intel_skylake_config *config;
const struct device *dev = dev_find_slot(0, SA_DEVFN_ROOT);
if (!dev || !dev->chip_info) {
printk(BIOS_ERR, "%s: Could not find SoC devicetree config!\n",
__func__);