blob: c13a1a60995fc702352148f066cbaf4ca219cba0 [file] [log] [blame]
Angel Ponsf5627e82020-04-05 15:46:52 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lijian Zhao9bb684a2017-10-30 17:03:06 -07002
Lijian Zhao9bb684a2017-10-30 17:03:06 -07003#include <device/device.h>
Chris Chingb8dc63b2017-12-06 14:26:15 -07004#include <drivers/i2c/designware/dw_i2c.h>
Lijian Zhao9bb684a2017-10-30 17:03:06 -07005#include <soc/pci_devs.h>
Lijian Zhao9bb684a2017-10-30 17:03:06 -07006
Aaron Durbin9aee8192018-01-22 20:29:25 -07007int dw_i2c_soc_devfn_to_bus(unsigned int devfn)
Lijian Zhao9bb684a2017-10-30 17:03:06 -07008{
9 switch (devfn) {
10 case PCH_DEVFN_I2C0:
11 return 0;
12 case PCH_DEVFN_I2C1:
13 return 1;
14 case PCH_DEVFN_I2C2:
15 return 2;
16 case PCH_DEVFN_I2C3:
17 return 3;
18 case PCH_DEVFN_I2C4:
19 return 4;
20 case PCH_DEVFN_I2C5:
21 return 5;
22 }
23 return -1;
24}
25
Aaron Durbin9aee8192018-01-22 20:29:25 -070026int dw_i2c_soc_bus_to_devfn(unsigned int bus)
Lijian Zhao9bb684a2017-10-30 17:03:06 -070027{
28 switch (bus) {
29 case 0:
30 return PCH_DEVFN_I2C0;
31 case 1:
32 return PCH_DEVFN_I2C1;
33 case 2:
34 return PCH_DEVFN_I2C2;
35 case 3:
36 return PCH_DEVFN_I2C3;
37 case 4:
38 return PCH_DEVFN_I2C4;
39 case 5:
40 return PCH_DEVFN_I2C5;
41 }
42 return -1;
43}