[coreboot-gerrit] Patch set updated for coreboot: Chromeos: Implement wifi_regulatory_domain using "regions" key in VPD

Hannah Williams (hannah.williams@intel.com) gerrit at coreboot.org
Tue Jan 12 16:59:33 CET 2016


Hannah Williams (hannah.williams at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12743

-gerrit

commit f5a0c5e088a40569dcb9ef9ddd305ae90454a69a
Author: Felix Durairaj <felixx.durairaj at intel.com>
Date:   Fri Nov 20 16:18:42 2015 -0800

    Chromeos: Implement wifi_regulatory_domain using "regions" key in VPD
    
    Implement wifi_regulatory_domain function by getting country code from
    VPD
    
    CQ-DEPEND=CL:12744
    
    Original-Reviewed-on: https://chromium-review.googlesource.com/314385
    Original-Reviewed-by: Pratikkumar V Prajapati <pratikkumar.v.prajapati at intel.com>
    Original-Reviewed-by: Aaron Durbin <adurbin at chromium.org>
    Original-Tested-by: Hannah Williams <hannah.williams at intel.com>
    
    Change-Id: Ia6a24df110a3860d404d345571007ae8965e9564
    Signed-off-by: fdurairx <felixx.durairaj at intel.com>
    Signed-off-by: Hannah Williams <hannah.williams at intel.com>
---
 src/vendorcode/google/chromeos/Makefile.inc |  1 +
 src/vendorcode/google/chromeos/cros_vpd.h   |  2 +
 src/vendorcode/google/chromeos/wrdd.c       | 76 +++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+)

diff --git a/src/vendorcode/google/chromeos/Makefile.inc b/src/vendorcode/google/chromeos/Makefile.inc
index 00fcd2f..adb51b4 100644
--- a/src/vendorcode/google/chromeos/Makefile.inc
+++ b/src/vendorcode/google/chromeos/Makefile.inc
@@ -38,6 +38,7 @@ ramstage-$(CONFIG_HAVE_ACPI_TABLES) += gnvs.c
 ramstage-$(CONFIG_CHROMEOS_RAMOOPS) += ramoops.c
 romstage-y += vpd_decode.c
 ramstage-y += vpd_decode.c cros_vpd.c vpd_mac.c vpd_serialno.c vpd_calibration.c
+ramstage-y += wrdd.c
 ifeq ($(CONFIG_ARCH_X86)$(CONFIG_ARCH_MIPS),)
 bootblock-y += watchdog.c
 ramstage-y += watchdog.c
diff --git a/src/vendorcode/google/chromeos/cros_vpd.h b/src/vendorcode/google/chromeos/cros_vpd.h
index 19658c2..ca9c320 100644
--- a/src/vendorcode/google/chromeos/cros_vpd.h
+++ b/src/vendorcode/google/chromeos/cros_vpd.h
@@ -7,6 +7,8 @@
 #ifndef __CROS_VPD_H__
 #define __CROS_VPD_H__
 
+#define CROS_VPD_WIFI_DOMAINKEY "regions"
+
 /*
  * Reads VPD string value by key.
  *
diff --git a/src/vendorcode/google/chromeos/wrdd.c b/src/vendorcode/google/chromeos/wrdd.c
new file mode 100644
index 0000000..ab27cc0
--- /dev/null
+++ b/src/vendorcode/google/chromeos/wrdd.c
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2012 Google Inc.
+ * Copyright (C) 2015 Intel Corp.
+ *
+ * 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 <console/console.h>
+#include <cpu/cpu.h>
+#include <types.h>
+#include <string.h>
+#include <wrdd.h>
+#include "cros_vpd.h"
+
+/*
+ * wrdd_domain_value is ISO 3166-2
+ * ISO 3166-2 code consists of two parts, separated by a hyphen
+ * The first part is the ISO 3166-1 alpha-2 code of the country;
+ * The second part is a string of up to three alphanumeric characters
+ */
+struct wrdd_code_value_pair {
+	const char *code;
+	u16 value;
+};
+
+/* Retrieve the regulatory domain information from VPD and
+ * return it as an uint16.
+ * WARNING: if domain information is not found in the VPD,
+ * this function will fall back to the default value
+ */
+uint16_t wifi_regulatory_domain(void)
+{
+	static struct wrdd_code_value_pair wrdd_table[] = {
+		{
+			/* Indonesia
+			 * Alpha-2 code         'ID'
+			 * Full name            'the Republic of Indonesia'
+			 * Alpha-3 code         'IDN'
+			 * Numeric code         '360'
+			 */
+			.code = "id",
+			.value = WRDD_REGULATORY_DOMAIN_INDONESIA
+		}
+	};
+	const char *wrdd_domain_key = CROS_VPD_WIFI_DOMAINKEY;
+	int i;
+	struct wrdd_code_value_pair *p;
+	/* wrdd_domain_value is ISO 3166-2 */
+	char wrdd_domain_code[7];
+
+	/* If not found for any reason fall backto the default value */
+	if (!cros_vpd_gets(wrdd_domain_key, wrdd_domain_code,
+		sizeof(wrdd_domain_code))) {
+		printk(BIOS_DEBUG,
+		"Error: Could not locate '%s' in VPD\n", wrdd_domain_key);
+		return WRDD_DEFAULT_REGULATORY_DOMAIN;
+	}
+	printk(BIOS_DEBUG, "Found '%s'='%s' in VPD\n",
+		wrdd_domain_key, wrdd_domain_code);
+
+	for (i = 0; i < ARRAY_SIZE(wrdd_table); i++) {
+		p = &wrdd_table[i];
+		if (strncmp(p->code, wrdd_domain_code,
+			ARRAY_SIZE(wrdd_domain_code)) == 0)
+			return p->value;
+	}
+	return WRDD_DEFAULT_REGULATORY_DOMAIN;
+}



More information about the coreboot-gerrit mailing list