soc/mediatek: Correct value's data type to u8 in dptx
[coreboot2.git] / src / soc / intel / apollolake / i2c.c
blob110117beae08bc5c0b5d3678936d675badae2706
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/device.h>
4 #include <device/pci_def.h>
5 #include <drivers/i2c/designware/dw_i2c.h>
6 #include <soc/pci_devs.h>
8 /* Convert I2C bus number to PCI device and function */
9 int dw_i2c_soc_bus_to_devfn(unsigned int bus)
11 if (bus <= 3)
12 return PCI_DEVFN(PCH_DEV_SLOT_SIO1, bus);
13 else if (bus >= 4 && bus <= 7)
14 return PCI_DEVFN(PCH_DEV_SLOT_SIO2, (bus - 4));
15 else
16 return -1;
19 /* Convert PCI device and function to I2C bus number */
20 int dw_i2c_soc_devfn_to_bus(unsigned int devfn)
22 if (PCI_SLOT(devfn) == PCH_DEV_SLOT_SIO1)
23 return PCI_FUNC(devfn);
24 else if (PCI_SLOT(devfn) == PCH_DEV_SLOT_SIO2)
25 return PCI_FUNC(devfn) + 4;
26 else
27 return -1;