[coreboot-gerrit] New patch to review for coreboot: lib: Add generic smbus library

Naresh Solanki (naresh.solanki@intel.com) gerrit at coreboot.org
Tue Nov 15 15:40:50 CET 2016


Naresh Solanki (naresh.solanki at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17432

-gerrit

commit 7c21dd029e57a9a546a6c99f5a887ced66b244d3
Author: Naresh G Solanki <naresh.solanki at intel.com>
Date:   Tue Nov 15 16:34:13 2016 +0530

    lib: Add generic smbus library
    
    Add generic smbus that can be used for example to fetch spd.
    Mainboard or SoC need to define device specific method to read/write smbus.
    
    Change-Id: I177af10bd127f0ebe3d6eefa70a923e7f55c45ab
    Signed-off-by: Naresh G Solanki <naresh.solanki at intel.com>
---
 src/Kconfig                 |  8 ++++++++
 src/include/generic_smbus.h | 22 ++++++++++++++++++++++
 src/lib/Makefile.inc        |  2 ++
 src/lib/generic_smbus.c     | 34 ++++++++++++++++++++++++++++++++++
 4 files changed, 66 insertions(+)

diff --git a/src/Kconfig b/src/Kconfig
index d6ada63..4551dff 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -316,6 +316,14 @@ config GENERIC_GPIO_LIB
 	  implies configurability usually found on SoCs, particularly the
 	  ability to control internal pull resistors.
 
+config GENERIC_SMBUS
+	bool
+	default n
+	help
+	  If enabled, mainboard or soc need to define function definition for
+	  doing smbus read & write. These function can be used to fetch spd over
+	  smbus.
+
 config BOARD_ID_AUTO
 	bool
 	default n
diff --git a/src/include/generic_smbus.h b/src/include/generic_smbus.h
new file mode 100644
index 0000000..d9cf8fa
--- /dev/null
+++ b/src/include/generic_smbus.h
@@ -0,0 +1,22 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef GENERIC_SMBUS_H
+#define GENERIC_SMBUS_H
+
+char generic_smbus_read_byte(u8 dev_address, u8 index);
+char generic_smbus_write_byte(u8 dev_address, u8 index, u8 value);
+
+#endif
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 36591ad..4ebdcb3 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -269,3 +269,5 @@ $(objcbfs)/%.debug.rmod: $(objcbfs)/%.debug | $(RMODTOOL)
 
 $(obj)/%.elf.rmod: $(obj)/%.elf | $(RMODTOOL)
 	$(RMODTOOL) -i $< -o $@
+
+romstage-$(CONFIG_GENERIC_SMBUS) += generic_smbus.c
diff --git a/src/lib/generic_smbus.c b/src/lib/generic_smbus.c
new file mode 100644
index 0000000..0ecea96
--- /dev/null
+++ b/src/lib/generic_smbus.c
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 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 <arch/byteorder.h>
+#include <cbfs.h>
+#include <console/console.h>
+#include <generic_smbus.h>
+#include <string.h>
+
+char __attribute__((weak)) generic_smbus_read_byte(u8 dev_address, u8 index)
+{
+	printk(BIOS_ERR, "%s: Not implemented", __func__);
+	return -1;
+}
+
+char __attribute__((weak)) generic_smbus_write_byte(u8 dev_address, u8 index,
+						u8 value)
+{
+	printk(BIOS_ERR, "%s: Not implemented", __func__);
+	return -1;
+}
+



More information about the coreboot-gerrit mailing list