xref: /linux/drivers/misc/amd-sbi/tsi-core.c (revision d4f8babf8e8ffb8cd75d12d1003d2a2c17a53420)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * tsi-core.c - file defining SB-TSI protocols compliant
4  *              AMD SoC device.
5  *
6  * Copyright (C) 2026 Advanced Micro Devices, Inc.
7  */
8 
9 #include <linux/module.h>
10 #include <linux/misc/tsi.h>
11 
12 /* I2C transfer function */
13 static int sbtsi_i2c_xfer(struct sbtsi_data *data, u8 reg, u8 *val, bool is_read)
14 {
15 	if (is_read) {
16 		int ret = i2c_smbus_read_byte_data(data->client, reg);
17 
18 		if (ret < 0)
19 			return ret;
20 		*val = ret;
21 		return 0;
22 	}
23 	return i2c_smbus_write_byte_data(data->client, reg, *val);
24 }
25 
26 int sbtsi_xfer(struct sbtsi_data *data, u8 reg, u8 *val, bool is_read)
27 {
28 	return sbtsi_i2c_xfer(data, reg, val, is_read);
29 }
30 EXPORT_SYMBOL_GPL(sbtsi_xfer);
31