Stephen Carlson | e36d49c | 2021-06-22 16:35:20 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2014 Freescale Semiconductor, Inc. |
| 4 | * Copyright 2020-21 NXP |
| 5 | * Copyright 2021 Microsoft Corporation |
| 6 | */ |
| 7 | |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 8 | #include <stdio.h> |
Stephen Carlson | e36d49c | 2021-06-22 16:35:20 -0700 | [diff] [blame] | 9 | #include <i2c.h> |
| 10 | #include "i2c_common.h" |
| 11 | |
Tom Rini | 952cc38 | 2022-12-04 10:14:13 -0500 | [diff] [blame] | 12 | #if CONFIG_IS_ENABLED(DM_I2C) |
Stephen Carlson | e36d49c | 2021-06-22 16:35:20 -0700 | [diff] [blame] | 13 | |
| 14 | /* If DM is in use, retrieve the chip for the specified bus number */ |
| 15 | int fsl_i2c_get_device(int address, int bus, DEVICE_HANDLE_T *dev) |
| 16 | { |
| 17 | int ret = i2c_get_chip_for_busnum(bus, address, 1, dev); |
| 18 | |
| 19 | if (ret) |
| 20 | printf("I2C: Bus %d has no device with address 0x%02X\n", |
| 21 | bus, address); |
| 22 | return ret; |
| 23 | } |
| 24 | |
| 25 | #else |
| 26 | |
| 27 | /* Handle is passed directly */ |
| 28 | int fsl_i2c_get_device(int address, int bus, DEVICE_HANDLE_T *dev) |
| 29 | { |
| 30 | *dev = address; |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | #endif |