Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | /* |
| 4 | * This file is created based on Intel Alder Lake Processor PCH Datasheet |
| 5 | * Document number: 621483 |
| 6 | * Chapter number: 13 |
| 7 | */ |
| 8 | |
| 9 | #include <device/device.h> |
| 10 | #include <drivers/i2c/designware/dw_i2c.h> |
| 11 | #include <soc/pci_devs.h> |
| 12 | |
| 13 | int dw_i2c_soc_devfn_to_bus(unsigned int devfn) |
| 14 | { |
| 15 | switch (devfn) { |
| 16 | case PCH_DEVFN_I2C0: |
| 17 | return 0; |
| 18 | case PCH_DEVFN_I2C1: |
| 19 | return 1; |
| 20 | case PCH_DEVFN_I2C2: |
| 21 | return 2; |
| 22 | case PCH_DEVFN_I2C3: |
| 23 | return 3; |
| 24 | case PCH_DEVFN_I2C4: |
| 25 | return 4; |
| 26 | case PCH_DEVFN_I2C5: |
| 27 | return 5; |
Varshit B Pandya | 339f0e7 | 2021-07-14 11:08:23 +0530 | [diff] [blame] | 28 | case PCH_DEVFN_I2C6: |
| 29 | return 6; |
| 30 | case PCH_DEVFN_I2C7: |
| 31 | return 7; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 32 | } |
| 33 | return -1; |
| 34 | } |
| 35 | |
| 36 | int dw_i2c_soc_bus_to_devfn(unsigned int bus) |
| 37 | { |
| 38 | switch (bus) { |
| 39 | case 0: |
| 40 | return PCH_DEVFN_I2C0; |
| 41 | case 1: |
| 42 | return PCH_DEVFN_I2C1; |
| 43 | case 2: |
| 44 | return PCH_DEVFN_I2C2; |
| 45 | case 3: |
| 46 | return PCH_DEVFN_I2C3; |
| 47 | case 4: |
| 48 | return PCH_DEVFN_I2C4; |
| 49 | case 5: |
| 50 | return PCH_DEVFN_I2C5; |
Varshit B Pandya | 339f0e7 | 2021-07-14 11:08:23 +0530 | [diff] [blame] | 51 | case 6: |
| 52 | return PCH_DEVFN_I2C6; |
| 53 | case 7: |
| 54 | return PCH_DEVFN_I2C7; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 55 | } |
| 56 | return -1; |
| 57 | } |