Michał Żygowski has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/30757
Change subject: [RFC] src/device/smbus: add extended addressing functions ......................................................................
[RFC] src/device/smbus: add extended addressing functions
Found this on one of private repositories I have access to. Do not have any use case for it yet.
Signed-off-by: Michał Żygowski michal.zygowski@3mdeb.com Change-Id: I5dcfc6bf33ef7baaa619f84b2ce0ab8e179a44b3 --- M src/device/smbus_ops.c M src/include/device/smbus.h M src/include/device/smbus_def.h 3 files changed, 64 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/57/30757/1
diff --git a/src/device/smbus_ops.c b/src/device/smbus_ops.c index c91f415..26cd956 100644 --- a/src/device/smbus_ops.c +++ b/src/device/smbus_ops.c @@ -90,3 +90,20 @@ return ops_smbus_bus(get_pbus_smbus(dev))->block_write(dev, cmd, bytes, buffer); } + +int smbus_extended_read_byte(struct device *dev, u16 addr) +{ + CHECK_PRESENCE(extended_read_byte); + + return ops_smbus_bus(get_pbus_smbus(dev))->extended_read_byte(dev, + addr); +} + +int smbus_extended_write_byte(struct device *dev, u16 addr, u8 val) +{ + CHECK_PRESENCE(extended_write_byte); + + return ops_smbus_bus(get_pbus_smbus(dev))->extended_write_byte(dev, + addr, + val); +} \ No newline at end of file diff --git a/src/include/device/smbus.h b/src/include/device/smbus.h index de6cf40..cb3f826 100644 --- a/src/include/device/smbus.h +++ b/src/include/device/smbus.h @@ -1,3 +1,22 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2014 Sage Electronic Engineering, LLC. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc. + */ + #ifndef DEVICE_SMBUS_H #define DEVICE_SMBUS_H
@@ -15,6 +34,8 @@ int (*block_read)(struct device *dev, u8 cmd, u8 bytes, u8 *buffer); int (*block_write)(struct device *dev, u8 cmd, u8 bytes, const u8 *buffer); + int (*extended_read_byte)(struct device *dev, u16 addr); + int (*extended_write_byte)(struct device *dev, u16 addr, u8 value); };
static inline const struct smbus_bus_operations *ops_smbus_bus(struct bus *bus) @@ -54,6 +75,10 @@ int smbus_block_read(struct device *dev, u8 cmd, u8 bytes, u8 *buffer); int smbus_block_write(struct device *dev, u8 cmd, u8 bytes, const u8 *buffer);
+int smbus_extended_read_byte(struct device *dev, u16 addr); +int smbus_extended_write_byte(struct device *dev, u16 addr, u8 val); + + #if IS_ENABLED(CONFIG_SMBUS_HAS_AUX_CHANNELS) void smbus_switch_to_channel(uint8_t channel_number); uint8_t smbus_get_current_channel(void); diff --git a/src/include/device/smbus_def.h b/src/include/device/smbus_def.h index 61d7861..cac08cc 100644 --- a/src/include/device/smbus_def.h +++ b/src/include/device/smbus_def.h @@ -1,10 +1,31 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2014 Sage Electronic Engineering, LLC. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc. + */ + + #ifndef DEVICE_SMBUS_DEF_H #define DEVICE_SMBUS_DEF_H
#include <types.h>
/* Error results are negative success is >= 0 */ -#define SMBUS_ERROR CB_ERR +#define SMBUS_SUCCESS CB_SUCCESS +#define SMBUS_ERROR CB_ERR #define SMBUS_WAIT_UNTIL_READY_TIMEOUT CB_I2C_BUSY #define SMBUS_WAIT_UNTIL_DONE_TIMEOUT CB_I2C_TIMEOUT #define SMBUS_WAIT_UNTIL_ACTIVE_TIMEOUT CB_I2C_NO_DEVICE