From 52f29743b153e89ca38db5d7a207c676c4c70207 Mon Sep 17 00:00:00 2001 From: Aamir Bohra Date: Wed, 19 Apr 2017 18:19:14 +0530 Subject: soc/intel/common/block: Add Intel common SMBus code Add below code support under intel/common/block: * SMBus read/write byte APIs * Common SMBus initialization code Change-Id: I936143a334c31937d557c6828e5876d35b133567 Signed-off-by: Aamir Bohra Reviewed-on: https://review.coreboot.org/19372 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Arthur Heymans --- src/soc/intel/common/block/smbus/smbus_early.c | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/soc/intel/common/block/smbus/smbus_early.c (limited to 'src/soc/intel/common/block/smbus/smbus_early.c') diff --git a/src/soc/intel/common/block/smbus/smbus_early.c b/src/soc/intel/common/block/smbus/smbus_early.c new file mode 100644 index 0000000000..e0c4d9c649 --- /dev/null +++ b/src/soc/intel/common/block/smbus/smbus_early.c @@ -0,0 +1,52 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2017 Intel Corporation. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include "smbuslib.h" + +static const struct reg_script smbus_init_script[] = { + /* Set SMBus I/O base address */ + REG_PCI_WRITE32(PCI_BASE_ADDRESS_4, SMBUS_IO_BASE), + /* Set SMBus enable */ + REG_PCI_WRITE8(HOSTC, HST_EN), + /* Enable I/O access */ + REG_PCI_WRITE16(PCI_COMMAND, PCI_COMMAND_IO), + /* Disable interrupts */ + REG_IO_WRITE8(SMBUS_IO_BASE + SMBHSTCTL, 0), + /* Clear errors */ + REG_IO_WRITE8(SMBUS_IO_BASE + SMBHSTSTAT, 0xff), + /* Indicate the end of this array by REG_SCRIPT_END */ + REG_SCRIPT_END, +}; + +u8 smbus_read_byte(u32 smbus_dev, u8 addr, u8 offset) +{ + return smbus_read8(SMBUS_IO_BASE, addr, offset); +} + +u8 smbus_write_byte(u32 smbus_dev, u8 addr, u8 offset, u8 value) +{ + return smbus_write8(SMBUS_IO_BASE, addr, offset, value); +} + +void smbus_common_init(void) +{ + reg_script_run_on_dev(PCH_DEV_SMBUS, smbus_init_script); +} -- cgit v1.2.3