• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/device.h>
4 #include <drivers/i2c/designware/dw_i2c.h>
5 #include <soc/pci_devs.h>
6 
dw_i2c_soc_devfn_to_bus(unsigned int devfn)7 int dw_i2c_soc_devfn_to_bus(unsigned int devfn)
8 {
9 	switch (devfn) {
10 	case PCI_DEVFN_I2C0:
11 		return 0;
12 	case PCI_DEVFN_I2C1:
13 		return 1;
14 	case PCI_DEVFN_I2C2:
15 		return 2;
16 	case PCI_DEVFN_I2C3:
17 		return 3;
18 	case PCI_DEVFN_I2C4:
19 		return 4;
20 	case PCI_DEVFN_I2C5:
21 		return 5;
22 	}
23 	return -1;
24 }
25 
dw_i2c_soc_bus_to_devfn(unsigned int bus)26 int dw_i2c_soc_bus_to_devfn(unsigned int bus)
27 {
28 	switch (bus) {
29 	case 0:
30 		return PCI_DEVFN_I2C0;
31 	case 1:
32 		return PCI_DEVFN_I2C1;
33 	case 2:
34 		return PCI_DEVFN_I2C2;
35 	case 3:
36 		return PCI_DEVFN_I2C3;
37 	case 4:
38 		return PCI_DEVFN_I2C4;
39 	case 5:
40 		return PCI_DEVFN_I2C5;
41 	}
42 	return -1;
43 }
44