[coreboot-gerrit] Patch set updated for coreboot: intel/i210: Change API for function mainboard_get_mac_address()

Werner Zeh (werner.zeh@siemens.com) gerrit at coreboot.org
Mon Jul 4 09:19:28 CEST 2016


Werner Zeh (werner.zeh at siemens.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15516

-gerrit

commit 7ee4e42c12f08833fa921ae50f0026acf65e685b
Author: Werner Zeh <werner.zeh at siemens.com>
Date:   Wed Jun 29 07:53:47 2016 +0200

    intel/i210: Change API for function mainboard_get_mac_address()
    
    The function mainboard_get_mac_address() is used to get a MAC address
    for a given i210 PCI device. Instead of passing pure numbers for PCI
    bus, device and function pass the device pointer to this function. In
    this way the function can retrieve the needed values itself as well as
    have the pointer to the device tree so that PCI path can be evaluated
    there.
    
    Change-Id: I2335d995651baa5e23a0448f5f32310dcd394f9b
    Signed-off-by: Werner Zeh <werner.zeh at siemens.com>
---
 src/drivers/intel/i210/Makefile.inc       | 19 +++++++++++++++++--
 src/drivers/intel/i210/i210.c             | 10 +---------
 src/drivers/intel/i210/i210.h             |  8 ++++++++
 src/mainboard/siemens/mc_tcu3/mainboard.c |  6 +++---
 src/vendorcode/siemens/hwilib/hwilib.h    |  4 +---
 5 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/src/drivers/intel/i210/Makefile.inc b/src/drivers/intel/i210/Makefile.inc
index a696022..c3dac65 100644
--- a/src/drivers/intel/i210/Makefile.inc
+++ b/src/drivers/intel/i210/Makefile.inc
@@ -1,5 +1,20 @@
-ifeq ($(CONFIG_DRIVER_INTEL_I210),y)
+##
+## This file is part of the coreboot project.
+##
+## Copyright 2016 Siemens AG
+##
+## 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.
+##
 
-ramstage-y += i210.c
+ramstage-$(CONFIG_DRIVER_INTEL_I210)+= i210.c
 
+ifeq ($(CONFIG_DRIVER_INTEL_I210),y)
+CFLAGS_x86_32 += -Isrc/drivers/intel/i210
 endif
diff --git a/src/drivers/intel/i210/i210.c b/src/drivers/intel/i210/i210.c
index c5e0c4e..c55eecc 100644
--- a/src/drivers/intel/i210/i210.c
+++ b/src/drivers/intel/i210/i210.c
@@ -14,20 +14,13 @@
  */
 
 #include "i210.h"
-#include <device/device.h>
 #include <console/console.h>
 #include <device/pci.h>
 #include <device/pci_ids.h>
 #include <device/pci_ops.h>
 #include <string.h>
-#include <types.h>
 #include <delay.h>
 
-/* We need one function we can call to get a MAC address to use */
-/* This function can be coded somewhere else but must exist. */
-extern enum cb_err mainboard_get_mac_address(uint16_t bus, uint8_t devfn,
-					     uint8_t mac[6]);
-
 /* This is a private function to wait for a bit mask in a given register */
 /* To avoid endless loops, a time-out is implemented here. */
 static int wait_done(uint32_t* reg, uint32_t mask)
@@ -202,8 +195,7 @@ static void init(struct device *dev)
 	enum cb_err status;
 
 	/*Check first whether there is a valid MAC address available */
-	status = mainboard_get_mac_address(dev->bus->subordinate,
-					   dev->path.pci.devfn, adr_to_set);
+	status = mainboard_get_mac_address(dev, adr_to_set);
 	if (status != CB_SUCCESS) {
 		printk(BIOS_ERR, "I210: No valid MAC address found\n");
 		return;
diff --git a/src/drivers/intel/i210/i210.h b/src/drivers/intel/i210/i210.h
index b19b584..e3179b7 100644
--- a/src/drivers/intel/i210/i210.h
+++ b/src/drivers/intel/i210/i210.h
@@ -16,6 +16,9 @@
 #ifndef _INTEL_I210_H_
 #define _INTEL_I210_H_
 
+#include <types.h>
+#include <device/device.h>
+
 #define I210_PCI_MEM_BAR_OFFSET	0x10
 #define I210_REG_EECTRL		0x12010	  /* Offset for EEPROM control reg */
 #define  I210_FLUPD		0x800000  /* Start flash update bit */
@@ -38,4 +41,9 @@
 #define I210_CHECKSUM_ERROR	0x00000010
 #define I210_FLASH_UPDATE_ERROR	0x00000020
 
+/* We need one function we can call to get a MAC address to use */
+/* This function can be coded somewhere else but must exist. */
+extern enum cb_err mainboard_get_mac_address(struct device *dev,
+						uint8_t mac[6]);
+
 #endif /* _INTEL_I210_H_ */
diff --git a/src/mainboard/siemens/mc_tcu3/mainboard.c b/src/mainboard/siemens/mc_tcu3/mainboard.c
index 009c34d..a11ff26 100644
--- a/src/mainboard/siemens/mc_tcu3/mainboard.c
+++ b/src/mainboard/siemens/mc_tcu3/mainboard.c
@@ -30,17 +30,17 @@
 #include <arch/interrupt.h>
 #include <boot/coreboot_tables.h>
 #include <hwilib.h>
+#include <i210.h>
 #include "lcd_panel.h"
 
 
 /** \brief This function will search for a MAC address which can be assigned
  *         to a MACPHY.
- * @param  pci_bdf Bus, device and function of the given PCI-device
+ * @param  dev     pointer to PCI device
  * @param  mac     buffer where to store the MAC address
  * @return cb_err  CB_ERR or CB_SUCCESS
  */
-enum cb_err mainboard_get_mac_address(uint16_t bus, uint8_t devfn,
-					uint8_t mac[6])
+enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[6])
 {
 	uint8_t mac_adr[6];
 	uint32_t i;
diff --git a/src/vendorcode/siemens/hwilib/hwilib.h b/src/vendorcode/siemens/hwilib/hwilib.h
index d858091..c0ae733 100644
--- a/src/vendorcode/siemens/hwilib/hwilib.h
+++ b/src/vendorcode/siemens/hwilib/hwilib.h
@@ -17,6 +17,7 @@
 #define SIEMENS_HWI_LIB_H_
 
 #include <types.h>
+#include <device/device.h>
 
 
 /* Declare all supported fields which can be get with hwilib. */
@@ -135,7 +136,4 @@ enum cb_err hwilib_find_blocks (const char *hwi_filename);
  */
 uint32_t hwilib_get_field (hwinfo_field_t field, uint8_t *data, uint32_t maxlen);
 
-/* This functions needs to be implemented for every mainboard that uses i210. */
-enum cb_err mainboard_get_mac_address(uint16_t bus, uint8_t devfn,
-					uint8_t mac[6]);
 #endif /* SIEMENS_HWI_LIB_H_ */



More information about the coreboot-gerrit mailing list