blob: 840ad6618314d4836f622bc5aaf15f3b92aab736 [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. */
12#ifdef CONFIG_DM_I2C
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
28int fsl_i2c_get_device(int address, int bus, DEVICE_HANDLE_T *dev);
29
30#endif