x86: i2c: Move system binding code to dw_i2c.c

The code fragment to bind the instances of the I2C driver is not
platform specific but is driver specific.

All the information required to bind a driver instance comes from
CONFIG_ variables.  Having the binding code with the driver code
avoids duplicating the code fragments in each platform where the
driver may be used.

Change-Id: I9ea132c9340437ccb292bb8f3fa3d3a2b2a794db
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
This commit is contained in:
Dirk Brandewie 2015-09-17 06:32:31 -07:00 committed by Anas Nashif
commit 6865fb658f
2 changed files with 47 additions and 51 deletions

View file

@ -175,54 +175,3 @@ struct device * const uart_devs[] = {
};
#endif
#if CONFIG_I2C
#include <i2c/dw_i2c.h>
extern void dw_i2c_isr(struct device *port);
#if CONFIG_DW_I2C0
void i2c_config_0_irq(struct device *port);
struct dw_i2c_rom_config i2c_config_dw_0 = {
.base_address = CONFIG_DW_I2C0_BASE,
.interrupt_vector = CONFIG_DW_I2C0_IRQ,
.pci_dev.class = CONFIG_DW_I2C_CLASS,
.pci_dev.bus = CONFIG_DW_I2C0_BUS,
.pci_dev.dev = CONFIG_DW_I2C0_DEV,
.pci_dev.vendor_id = CONFIG_DW_I2C_VENDOR_ID,
.pci_dev.device_id = CONFIG_DW_I2C_DEVICE_ID,
.pci_dev.function = CONFIG_DW_I2C0_FUNCTION,
.pci_dev.bar = CONFIG_DW_I2C0_BAR,
.config_func = i2c_config_0_irq
};
struct dw_i2c_dev_config i2c_0_runtime;
DECLARE_DEVICE_INIT_CONFIG(i2c_0,
CONFIG_DW_I2C0_NAME,
&dw_i2c_initialize,
&i2c_config_dw_0);
pure_init(i2c_0, &i2c_0_runtime);
IRQ_CONNECT_STATIC(dw_i2c_0,
CONFIG_DW_I2C0_IRQ,
CONFIG_DW_I2C0_INT_PRIORITY,
dw_i2c_isr_0,
0);
void i2c_config_0_irq(struct device *port)
{
struct dw_i2c_rom_config *config = port->config->config_info;
IRQ_CONFIG(dw_i2c_0, config->interrupt_vector);
}
void dw_i2c_isr_0(void *unused)
{
dw_i2c_isr(&__initconfig_i2c_01);
}
#endif /* CONFIG_DW_I2C0 */
#endif /* CONFIG_DW */

View file

@ -608,3 +608,50 @@ int dw_i2c_initialize(struct device *port)
return DEV_OK;
}
/* system bindings */
#if CONFIG_DW_I2C0
void i2c_config_0_irq(struct device *port);
struct dw_i2c_rom_config i2c_config_dw_0 = {
.base_address = CONFIG_DW_I2C0_BASE,
.interrupt_vector = CONFIG_DW_I2C0_IRQ,
#if CONFIG_PCI
.pci_dev.class = CONFIG_DW_I2C_CLASS,
.pci_dev.bus = CONFIG_DW_I2C0_BUS,
.pci_dev.dev = CONFIG_DW_I2C0_DEV,
.pci_dev.vendor_id = CONFIG_DW_I2C_VENDOR_ID,
.pci_dev.device_id = CONFIG_DW_I2C_DEVICE_ID,
.pci_dev.function = CONFIG_DW_I2C0_FUNCTION,
.pci_dev.bar = CONFIG_DW_I2C0_BAR,
#endif
.config_func = i2c_config_0_irq
};
struct dw_i2c_dev_config i2c_0_runtime;
DECLARE_DEVICE_INIT_CONFIG(i2c_0,
CONFIG_DW_I2C0_NAME,
&dw_i2c_initialize,
&i2c_config_dw_0);
pure_init(i2c_0, &i2c_0_runtime);
IRQ_CONNECT_STATIC(dw_i2c_0,
CONFIG_DW_I2C0_IRQ,
CONFIG_DW_I2C0_INT_PRIORITY,
dw_i2c_isr_0,
0);
void i2c_config_0_irq(struct device *port)
{
struct dw_i2c_rom_config *config = port->config->config_info;
IRQ_CONFIG(dw_i2c_0, config->interrupt_vector);
}
void dw_i2c_isr_0(void *unused)
{
dw_i2c_isr(&__initconfig_i2c_01);
}
#endif /* CONFIG_DW_I2C0 */