blob: 77a7b6aedd7b7899146cb430e8b95e19f4b260a4 [file] [log] [blame]
Stephen Carlsone36d49c2021-06-22 16:35:20 -07001/* 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 Rini952cc382022-12-04 10:14:13 -050012#if CONFIG_IS_ENABLED(DM_I2C)
Stephen Carlsone36d49c2021-06-22 16:35:20 -070013#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
28int fsl_i2c_get_device(int address, int bus, DEVICE_HANDLE_T *dev);
29
30#endif