From patchwork Thu Dec 14 11:54:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 121915 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6709904qgn; Thu, 14 Dec 2017 04:03:51 -0800 (PST) X-Google-Smtp-Source: ACJfBos02NHbO1vOHs6YjF2AHNqUUp/ZPqzPc1+dIjfzqdCI/XhtwBf3MEP0e6+qBBYnRsUc3FGP X-Received: by 10.80.241.218 with SMTP id y26mr11967295edl.120.1513253031724; Thu, 14 Dec 2017 04:03:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513253031; cv=none; d=google.com; s=arc-20160816; b=nanbvm++iFbzTpSr+LRR7p28t40i/S6Cx8S9XCgHAs7yYhXQAXzJ6EUAMaSPqUp/E6 wTVhX63RlFLiliYLW1bO9qfvegsW5xcHyAnj7qu2uXg6aSrkuhRnqOy7wWtm7ScYjMV/ pMO6jyuBf0dTKMcx8pYJ1NjxROstBixsdP6wVjsvc7WOcBbq/6mGtHULK9gUh0KovPXH fgxFxwJ4ZMs6wPhCX7q96DW3zhgKHyJJ6RCBC18vVIeXODvl7cTqbTiEfS4Zr/az/bcW RUJcv92LV5Kt5ezhaAlMVIURHFU8I8qKCBsV5bUOzeSeFCYV94f7SqYQHDB2O9KE02Zs CbuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=VC8W/ZdjPV6sykM4SVGK+IyPxWZOfwvtc1MPM8k8Iyw=; b=sNdv/IvA8lgIlX176Lci9K5/GulTaD4BetyxkfYjouYc5021Xv+sUY5OZqY2N7Q0ZL Gbci1dcXdA7mY4EpEm6LeNKlYPzS+X/b6fKmBwK8+IoJGaTIMlq9SgESSxw0NJvVLezB rFqZJLXaVe+q8tZNeJRRx2JfcbVlSc+h0HW/2IV9kvAmbOUzeCTWeJ4fS2s6RW9AnRFs IXgbH7fpCK6xfwUzgrRoNl9KZKyKMGMpGtQ19KXeiF/jbNCj5FSRCNRrVjC2Ca3t4cXD pw98HDUJtR+NsGpJ+xASyDeLGNPFr3wwjlhP6wMdc6Hct98js71k4MoPj/Q/ej3ZOVlN 7rPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IpWJd6b1; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id c47si88918edb.86.2017.12.14.04.03.51; Thu, 14 Dec 2017 04:03:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IpWJd6b1; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 30E8EC21EEF; Thu, 14 Dec 2017 12:01:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 689FFC21E3B; Thu, 14 Dec 2017 11:55:12 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C9D84C21F02; Thu, 14 Dec 2017 11:54:24 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by lists.denx.de (Postfix) with ESMTPS id C048EC21E10 for ; Thu, 14 Dec 2017 11:54:19 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id t8so10763548wmc.3 for ; Thu, 14 Dec 2017 03:54:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Z5Eclz80VgbVc8W/HEjESRVQW+jWN1QZhdY9oYIs8mM=; b=IpWJd6b18Q+grbrwGZtfQS7Pxil0Sb9Fps4eeDiMzuFH5BnTmymy0kfO7NymnYGAaM 1BibWR6wDcuwhCtEzLjqMqckC3koORJxaRc4wPylN6Tedn+I49Y5YPDMcDSHx88XQ4E6 4u+zkWrmGqo6JS06WxmP8+JfAz2nQaBVwLjTc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z5Eclz80VgbVc8W/HEjESRVQW+jWN1QZhdY9oYIs8mM=; b=KqtNsngPCmXmJ/nfCk59C1iHSUn9B4DZbCkq89CKTsDNukN/vMxb51y2xQa5HIs0Mt a0fb9U8mr7XI0UslVXi8RFBUNBzKN4gB/z+JLPosIgpGHHMFPLRQqaNfN0r2ZqT/q6og 00ZW0zMBjDUNW+UpfXQ+V6L/uvn3bu9GYQQTiUMK6mk6Rq+OpIOpfhxevAgcmndQ+68O IkSc+TYAc/PhsxKckHMOm3ebnliGt8zR7fslhGgwZscpoo2xFBP28PI0hhDC+AdDJTVP TvhCtiGO1eWr9Nd8WPqMmiccAL3PIS/tEySvCWfnfRxuqT2O2d0gwmN+7YYsRNV3WnSB HUzQ== X-Gm-Message-State: AKGB3mL6tdU9fhVbVKAmqlDJ8bvk4vYXwtk86V1Fpreu9szKHqRvc+Ud ZF6q9/rPPfmaut4LnwFUP9H+8dRkbIY= X-Received: by 10.28.154.7 with SMTP id c7mr1834052wme.80.1513252459377; Thu, 14 Dec 2017 03:54:19 -0800 (PST) Received: from igloo.80.58.61.254 (141.pool85-51-114.dynamic.orange.es. [85.51.114.141]) by smtp.gmail.com with ESMTPSA id e197sm11797509wmf.42.2017.12.14.03.54.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Dec 2017 03:54:18 -0800 (PST) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, u-boot@lists.denx.de Date: Thu, 14 Dec 2017 12:54:01 +0100 Message-Id: <1513252441-29520-8-git-send-email-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513252441-29520-1-git-send-email-jorge.ramirez-ortiz@linaro.org> References: <1513252441-29520-1-git-send-email-jorge.ramirez-ortiz@linaro.org> MIME-Version: 1.0 Subject: [U-Boot] [PATCH 8/8] db410c: update wlan and bt mac addresses from firmware X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The firmware that runs before u-boot modifies u-boot's device tree adding the local-mac-address and local-bd-address properties for the compatibles "qcom,wcnss-bt" and "qcom,wcnss-wlan". This commit reads that firmware, retrieves the properties and fixups the device tree that is passed to the kernel before booting. Signed-off-by: Jorge Ramirez-Ortiz --- arch/arm/dts/dragonboard410c.dts | 10 ++++++ board/qualcomm/dragonboard410c/Makefile | 1 + board/qualcomm/dragonboard410c/dragonboard410c.c | 46 ++++++++++++++++++++---- board/qualcomm/dragonboard410c/lowlevel_init.S | 28 +++++++++++++++ configs/dragonboard410c_defconfig | 1 + 5 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 board/qualcomm/dragonboard410c/lowlevel_init.S diff --git a/arch/arm/dts/dragonboard410c.dts b/arch/arm/dts/dragonboard410c.dts index 7746622..5753f90 100644 --- a/arch/arm/dts/dragonboard410c.dts +++ b/arch/arm/dts/dragonboard410c.dts @@ -86,6 +86,16 @@ clock-frequency = <200000000>; }; + wcnss { + bt { + compatible="qcom,wcnss-bt"; + }; + + wifi { + compatible="qcom,wcnss-wlan"; + } + }; + spmi@200f000 { compatible = "qcom,spmi-pmic-arb"; reg = <0x200f800 0x200 0x2400000 0x400000 0x2c00000 0x400000>; diff --git a/board/qualcomm/dragonboard410c/Makefile b/board/qualcomm/dragonboard410c/Makefile index cd67808..5082383 100644 --- a/board/qualcomm/dragonboard410c/Makefile +++ b/board/qualcomm/dragonboard410c/Makefile @@ -5,4 +5,5 @@ # obj-y := dragonboard410c.o +obj-y += lowlevel_init.o extra-y += head.o diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c index 848e278..65ed9a3 100644 --- a/board/qualcomm/dragonboard410c/dragonboard410c.c +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c @@ -13,6 +13,12 @@ DECLARE_GLOBAL_DATA_PTR; +/* pointer to the device tree ammended by the firmware */ +extern unsigned long fw_dtb; + +static char wlan_mac[ARP_HLEN]; +static char bt_mac[ARP_HLEN]; + int dram_init(void) { gd->ram_size = PHYS_SDRAM_1_SIZE; @@ -27,7 +33,6 @@ int dram_init_banksize(void) return 0; } - int board_prepare_usb(enum usb_init_type type) { static struct udevice *pmic_gpio; @@ -96,11 +101,6 @@ int board_prepare_usb(enum usb_init_type type) return 0; } -int board_init(void) -{ - return 0; -} - /* Check for vol- button - if pressed - stop autoboot */ int misc_init_r(void) { @@ -131,6 +131,40 @@ int misc_init_r(void) env_set("bootdelay", "-1"); printf("Power button pressed - dropping to console.\n"); } +} + +int board_init(void) +{ + int offset, len; + char *mac; + + /* take a copy of the firmware information (the user could unknownly + overwrite that DDR via tftp or other means) */ + + offset = fdt_node_offset_by_compatible(fw_dtb, -1, "qcom,wcnss-wlan"); + if (offset >= 0) { + mac = fdt_getprop(fw_dtb, offset, "local-mac-address", &len); + if (mac) + memcpy(wlan_mac, mac, ARP_HLEN); + } + + offset = fdt_node_offset_by_compatible(fw_dtb, -1, "qcom,wcnss-bt"); + if (offset >= 0) { + mac = fdt_getprop(fw_dtb, offset, "local-bd-address", &len); + if (mac) + memcpy(bt_mac, mac, ARP_HLEN); + } + + return 0; +} + +int ft_board_setup(void *blob, bd_t *bd) +{ + do_fixup_by_compat(blob, "qcom,wcnss-wlan", "local-mac-address", + wlan_mac, ARP_HLEN, 1); + + do_fixup_by_compat(blob, "qcom,wcnss-bt", "local-mac-address", + bt_mac, ARP_HLEN, 1); return 0; } diff --git a/board/qualcomm/dragonboard410c/lowlevel_init.S b/board/qualcomm/dragonboard410c/lowlevel_init.S new file mode 100644 index 0000000..15b2d0c --- /dev/null +++ b/board/qualcomm/dragonboard410c/lowlevel_init.S @@ -0,0 +1,28 @@ +/* + * (C) Copyright 2016 + * Cédric Schieli + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include + +.align 8 +.global fw_dtb +fw_dtb: + .dword 0x0 + +/* + * Routine: save_boot_params (called after reset from start.S) + * Description: save ATAG/FDT address provided by the firmware at boot time + */ + +.global save_boot_params +save_boot_params: + + /* The firmware provided ATAG/FDT address can be found in r2/x0 */ + adr x8, fw_dtb + str x0, [x8] + + /* Returns */ + b save_boot_params_ret diff --git a/configs/dragonboard410c_defconfig b/configs/dragonboard410c_defconfig index 4c04544..570ee6d 100644 --- a/configs/dragonboard410c_defconfig +++ b/configs/dragonboard410c_defconfig @@ -45,3 +45,4 @@ CONFIG_USB_ETHER_SMSC95XX=y CONFIG_OF_LIBFDT_OVERLAY=y CONFIG_OF_CONTROL=y CONFIG_ENV_IS_IN_MMC=y +CONFIG_OF_BOARD_SETUP=y