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 | |
| 8 | #ifndef __NXP_I2C_COMMON_H__ |
| 9 | #define __NXP_I2C_COMMON_H__ |
| 10 | |
| 11 | /* Common functionality shared by the I2C drivers for VID and the mux. */ |
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 | #define DEVICE_HANDLE_T struct udevice * |
| 14 | |
| 15 | #define I2C_READ(dev, register, data, length) \ |
| 16 | dm_i2c_read(dev, register, data, length) |
| 17 | #define I2C_WRITE(dev, register, data, length) \ |
| 18 | dm_i2c_write(dev, register, data, length) |
| 19 | #else |
| 20 | #define DEVICE_HANDLE_T int |
| 21 | |
| 22 | #define I2C_READ(dev, register, data, length) \ |
| 23 | i2c_read(dev, register, 1, data, length) |
| 24 | #define I2C_WRITE(dev, register, data, length) \ |
| 25 | i2c_write(dev, register, 1, data, length) |
| 26 | #endif |
| 27 | |
| 28 | int fsl_i2c_get_device(int address, int bus, DEVICE_HANDLE_T *dev); |
| 29 | |
| 30 | #endif |