Werner Zeh (werner.zeh(a)siemens.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15516
-gerrit
commit 9190665e4cede1950f08dd781d8d3b35e02e34ea
Author: Werner Zeh <werner.zeh(a)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(a)siemens.com>
---
src/drivers/intel/i210/i210.c | 10 +---------
src/drivers/intel/i210/i210.h | 8 ++++++++
src/mainboard/siemens/mc_tcu3/mainboard.c | 5 ++---
src/vendorcode/siemens/hwilib/hwilib.h | 5 +++--
4 files changed, 14 insertions(+), 14 deletions(-)
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..83a0ae0 100644
--- a/src/mainboard/siemens/mc_tcu3/mainboard.c
+++ b/src/mainboard/siemens/mc_tcu3/mainboard.c
@@ -35,12 +35,11 @@
/** \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])
+extern 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..9ccb3fe 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. */
@@ -136,6 +137,6 @@ 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]);
+extern enum cb_err mainboard_get_mac_address(struct device *dev,
+ uint8_t mac[6]);
#endif /* SIEMENS_HWI_LIB_H_ */
Werner Zeh (werner.zeh(a)siemens.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15517
-gerrit
commit 450473cb4f241b6b39624ba2778aa437d118ee3e
Author: Werner Zeh <werner.zeh(a)siemens.com>
Date: Thu Jun 30 08:21:17 2016 +0200
siemens/mc_bdx1: Set up MAC address for available i210 MACs
Enable the usage of DRIVER_INTEL_I210 and provide a function to search
for a valid MAC address for all i210 devices using hwilib.
Change-Id: Ic0f4f1579364cf5b0111334a05a8a0926785318b
Signed-off-by: Werner Zeh <werner.zeh(a)siemens.com>
---
src/mainboard/siemens/mc_bdx1/Kconfig | 2 +
src/mainboard/siemens/mc_bdx1/mainboard.c | 73 +++++++++++++++++++++++++++++++
src/mainboard/siemens/mc_tcu3/mainboard.c | 2 +-
3 files changed, 76 insertions(+), 1 deletion(-)
diff --git a/src/mainboard/siemens/mc_bdx1/Kconfig b/src/mainboard/siemens/mc_bdx1/Kconfig
index e33b14a..f947f3d 100644
--- a/src/mainboard/siemens/mc_bdx1/Kconfig
+++ b/src/mainboard/siemens/mc_bdx1/Kconfig
@@ -9,6 +9,8 @@ config BOARD_SPECIFIC_OPTIONS
select TSC_MONOTONIC_TIMER
select HAVE_FSP_BIN if FSP_PACKAGE_DEFAULT
select CBFS_AUTOGEN_ATTRIBUTES
+ select USE_SIEMENS_HWILIB
+ select DRIVER_INTEL_I210
config MAINBOARD_DIR
string
diff --git a/src/mainboard/siemens/mc_bdx1/mainboard.c b/src/mainboard/siemens/mc_bdx1/mainboard.c
index 58da036..4772761 100644
--- a/src/mainboard/siemens/mc_bdx1/mainboard.c
+++ b/src/mainboard/siemens/mc_bdx1/mainboard.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2007-2009 coresystems GmbH
* Copyright (C) 2011 Google Inc.
+ * Copyright (C) 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
@@ -29,7 +30,10 @@
#include <arch/io.h>
#include <arch/interrupt.h>
#include <boot/coreboot_tables.h>
+#include <hwilib.h>
+#define MAX_PATH_DEPTH 14
+#define MAX_NUM_MAPPINGS 10
/*
* mainboard_enable is executed as first thing after enumerate_buses().
* This is the earliest point to add customization.
@@ -38,6 +42,75 @@ static void mainboard_enable(device_t dev)
{
}
+/** \brief This function can decide if a given MAC address is valid or not.
+ * Currently, addresses filled with 0xff or 0x00 are not valid.
+ * @param mac Buffer to the MAC address to check
+ * @return 0 if address is not valid, otherwise 1
+ */
+static uint8_t is_mac_adr_valid(uint8_t mac[6])
+{
+ uint8_t buf[6];
+
+ memset(buf, 0, sizeof(buf));
+ if (!memcmp(buf, mac, sizeof(buf)))
+ return 0;
+ memset(buf, 0xff, sizeof(buf));
+ if (!memcmp(buf, mac, sizeof(buf)))
+ return 0;
+ return 1;
+}
+ /** \brief This function will search for a MAC address which can be assigned
+ * to a MACPHY.
+ * @param dev pointer to PCI device
+ * @param mac buffer where to store the MAC address
+ * @return cb_err CB_ERR or CB_SUCCESS
+ */
+extern enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[6])
+{
+ struct bus *parent = dev->bus;
+ uint8_t buf[16], mapping[16], i = 0, chain_len = 0;
+
+ memset(buf, 0, sizeof(buf));
+ memset(mapping, 0, sizeof(mapping));
+
+ /* The first entry in the tree is the device itself. */
+ buf[0] = dev->path.pci.devfn;
+ for (i = 1; i < MAX_PATH_DEPTH && parent->dev->bus->subordinate; i++) {
+ buf[i] = parent->dev->path.pci.devfn;
+ parent = parent->dev->bus;
+ }
+ if (i == MAX_PATH_DEPTH) {
+ /* The path is deeper than MAX_PATH_DEPTH devices, error. */
+ printk(BIOS_ERR, "Too many bridges for %s\n", dev_path(dev));
+ return CB_ERR;
+ }
+ chain_len = i;
+ /* Now construct the mapping based on the device chain starting from */
+ /* root bridge device to the device itself. */
+ mapping[0] = 1;
+ mapping[1] = chain_len;
+ for (i = 1; i <= chain_len; i++)
+ mapping[i + 3] = buf[chain_len - i];
+
+ /* Open main hwinfo block */
+ if (hwilib_find_blocks("hwinfo.hex") != CB_SUCCESS)
+ return CB_ERR;
+ /* Now try to find a valid MAC address in hwinfo for this mapping.*/
+ for (i = 0; i < MAX_NUM_MAPPINGS; i++) {
+ if ((hwilib_get_field(XMac1Mapping + i, buf, 16) == 16) &&
+ !(memcmp(buf, mapping, chain_len + 4))) {
+ /* There is a matching mapping available, get MAC address. */
+ if ((hwilib_get_field(XMac1 + i, mac, 6) == 6) &&
+ (is_mac_adr_valid(mac)))
+ return CB_SUCCESS;
+ else
+ return CB_ERR;
+ } else
+ continue;
+ }
+ /* No MAC address found for */
+ return CB_ERR;
+}
struct chip_operations mainboard_ops = {
.enable_dev = mainboard_enable,
diff --git a/src/mainboard/siemens/mc_tcu3/mainboard.c b/src/mainboard/siemens/mc_tcu3/mainboard.c
index 83a0ae0..9ac6dc0 100644
--- a/src/mainboard/siemens/mc_tcu3/mainboard.c
+++ b/src/mainboard/siemens/mc_tcu3/mainboard.c
@@ -35,7 +35,7 @@
/** \brief This function will search for a MAC address which can be assigned
* to a MACPHY.
- * @param dev pointer to 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
*/
the following patch was just integrated into master:
commit 61f4b42f2c1bdf5fb09ad4ba22e8420c6f9fbe00
Author: Werner Zeh <werner.zeh(a)siemens.com>
Date: Wed Jun 29 07:17:21 2016 +0200
fsp_broadwell_de: Enable Super I/O address range decode
If there is an external 16550 like UART, one needs to enable
the appropriate address ranges before console_init() is called
so that the init sequence can reach the external UART. Otherwise
the UART will only start working in ramstage and will produce
unreadable characters in romstage due to the lack of initialization.
Tested-on: Siemens MC_BDX1
Change-Id: Iafc5b5b6df14916c5ed778928521d4a8f539cf46
Signed-off-by: Werner Zeh <werner.zeh(a)siemens.com>
Reviewed-on: https://review.coreboot.org/15495
Tested-by: build bot (Jenkins)
Reviewed-by: York Yang <york.yang(a)intel.com>
Reviewed-by: Paul Menzel <paulepanter(a)users.sourceforge.net>
See https://review.coreboot.org/15495 for details.
-gerrit
Shaunak Saha (shaunak.saha(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15460
-gerrit
commit c3cccd41289df90fed19f9378d34caedc710142a
Author: Shaunak Saha <shaunak.saha(a)intel.com>
Date: Mon Jun 27 23:00:15 2016 -0700
soc/apollolake: Expose a function to read pmc bar
This patch exposes a function to read pmc bar.
PMC bar is read in function read_pmc_mmio_bar which
is defined static in file pmutil.c. This patch exposes
that functionality to call it from other files.
BUG=chrome-os-partner:53438
TEST= Read the PMC bar value properly from outside
pmutil file.
Change-Id: I26ee13e6ab95d3a8991c7f8ea4b3856ceb015d10
Signed-off-by: Shaunak Saha <shaunak.saha(a)intel.com>
---
src/soc/intel/apollolake/include/soc/pm.h | 1 +
src/soc/intel/apollolake/pmutil.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/src/soc/intel/apollolake/include/soc/pm.h b/src/soc/intel/apollolake/include/soc/pm.h
index 8da9088..72f74a6 100644
--- a/src/soc/intel/apollolake/include/soc/pm.h
+++ b/src/soc/intel/apollolake/include/soc/pm.h
@@ -171,6 +171,7 @@ void disable_pm1_control(uint32_t mask);
void enable_gpe(uint32_t mask);
void disable_gpe(uint32_t mask);
void disable_all_gpe(void);
+uintptr_t get_pmc_mmio_bar(void);
void global_reset_enable(bool enable);
void global_reset_lock(void);
diff --git a/src/soc/intel/apollolake/pmutil.c b/src/soc/intel/apollolake/pmutil.c
index f8b2fdf..f25adfb 100644
--- a/src/soc/intel/apollolake/pmutil.c
+++ b/src/soc/intel/apollolake/pmutil.c
@@ -34,6 +34,11 @@ static uintptr_t read_pmc_mmio_bar(void)
return bar & ~PCI_BASE_ADDRESS_MEM_ATTR_MASK;
}
+uintptr_t get_pmc_mmio_bar(void)
+{
+ return read_pmc_mmio_bar();
+}
+
static void print_num_status_bits(int num_bits, uint32_t status,
const char * const bit_names[])
{
Werner Zeh (werner.zeh(a)siemens.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15517
-gerrit
commit 0e7f01c483fc50dfc8807d74aacb1688813386e2
Author: Werner Zeh <werner.zeh(a)siemens.com>
Date: Thu Jun 30 08:21:17 2016 +0200
siemens/mc_bdx1: Set up MAC address for available i210 MACs
Enable the usage of DRIVER_INTEL_I210 and provide a function to search
for a valid MAC address for all i210 devices using hwilib.
Change-Id: Ic0f4f1579364cf5b0111334a05a8a0926785318b
Signed-off-by: Werner Zeh <werner.zeh(a)siemens.com>
---
src/mainboard/siemens/mc_bdx1/Kconfig | 2 +
src/mainboard/siemens/mc_bdx1/mainboard.c | 74 +++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+)
diff --git a/src/mainboard/siemens/mc_bdx1/Kconfig b/src/mainboard/siemens/mc_bdx1/Kconfig
index e33b14a..f947f3d 100644
--- a/src/mainboard/siemens/mc_bdx1/Kconfig
+++ b/src/mainboard/siemens/mc_bdx1/Kconfig
@@ -9,6 +9,8 @@ config BOARD_SPECIFIC_OPTIONS
select TSC_MONOTONIC_TIMER
select HAVE_FSP_BIN if FSP_PACKAGE_DEFAULT
select CBFS_AUTOGEN_ATTRIBUTES
+ select USE_SIEMENS_HWILIB
+ select DRIVER_INTEL_I210
config MAINBOARD_DIR
string
diff --git a/src/mainboard/siemens/mc_bdx1/mainboard.c b/src/mainboard/siemens/mc_bdx1/mainboard.c
index 58da036..dcba7d6 100644
--- a/src/mainboard/siemens/mc_bdx1/mainboard.c
+++ b/src/mainboard/siemens/mc_bdx1/mainboard.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2007-2009 coresystems GmbH
* Copyright (C) 2011 Google Inc.
+ * Copyright (C) 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
@@ -29,7 +30,10 @@
#include <arch/io.h>
#include <arch/interrupt.h>
#include <boot/coreboot_tables.h>
+#include <hwilib.h>
+#define MAX_PATH_DEPTH 14
+#define MAX_NUM_MAPPINGS 10
/*
* mainboard_enable is executed as first thing after enumerate_buses().
* This is the earliest point to add customization.
@@ -38,6 +42,76 @@ static void mainboard_enable(device_t dev)
{
}
+/** \brief This function can decide if a given MAC address is valid or not.
+ * Currently, addresses filled with 0xff or 0x00 are not valid.
+ * @param mac Buffer to the MAC address to check
+ * @return 0 if address is not valid, otherwise 1
+ */
+static uint8_t is_mac_adr_valid(uint8_t mac[6])
+{
+ uint8_t buf[6];
+
+ memset(buf, 0, sizeof(buf));
+ if (!memcmp(buf, mac, sizeof(buf)))
+ return 0;
+ memset(buf, 0xff, sizeof(buf));
+ if (!memcmp(buf, mac, sizeof(buf)))
+ return 0;
+ return 1;
+}
+ /** \brief This function will search for a MAC address which can be assigned
+ * to a MACPHY.
+ * @param dev pointer to PCI device
+ * @param mac buffer where to store the MAC address
+ * @return cb_err CB_ERR or CB_SUCCESS
+ */
+extern enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[6])
+{
+ struct bus *parent = dev->bus;
+ uint8_t buf[16], mapping[16], i = 0, chain_len = 0;
+
+ memset(buf, 0, sizeof(buf));
+ memset(mapping, 0, sizeof(mapping));
+
+ /* The first entry in the tree is the device itself. */
+ buf[0] = dev->path.pci.devfn;
+ for (i = 1; i < MAX_PATH_DEPTH && parent->dev->bus->subordinate; i++) {
+ buf[i] = parent->dev->path.pci.devfn;
+ parent = parent->dev->bus;
+ }
+ if (i == MAX_PATH_DEPTH) {
+ /* The path is deeper than MAX_PATH_DEPTH devices, error. */
+ printk(BIOS_ERR, "Too many bridges for %s\n", dev_path(dev));
+ return CB_ERR;
+ }
+ chain_len = i;
+ /* Now construct the mapping based on the device chain starting from */
+ /* root bridge device to the device itself. */
+ mapping[0] = 1;
+ mapping[1] = chain_len;
+ for (i = 1; i <= chain_len; i++)
+ mapping[i + 3] = buf[chain_len - i];
+
+ /* Open main hwinfo block */
+ if (hwilib_find_blocks("hwinfo.hex") != CB_SUCCESS)
+ return CB_ERR;
+ /* Now try to find a valid MAC address in hwinfo for this mapping.*/
+ for (i = 0; i < MAX_NUM_MAPPINGS; i++) {
+ if ((hwilib_get_field(XMac1Mapping + i, buf, 16) == 16) &&
+ !(memcmp(buf, mapping, chain_len + 4))) {
+ /* There is a matching mapping available, get MAC address. */
+ if ((hwilib_get_field(XMac1 + i, mac, 6) == 6) &&
+ (is_mac_adr_valid(mac))) {
+ return CB_SUCCESS;
+ } else {
+ return CB_ERR;
+ }
+ } else
+ continue;
+ }
+ /* No MAC address found for */
+ return CB_ERR;
+}
struct chip_operations mainboard_ops = {
.enable_dev = mainboard_enable,