From patchwork Tue Nov 26 08:16:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Heider X-Patchwork-Id: 1200801 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VHihpcxE"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 47McKb4M9Vz9sP3 for ; Tue, 26 Nov 2019 19:20:35 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3274BC21F01; Tue, 26 Nov 2019 08:20:26 +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=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, 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 168BCC21F76; Tue, 26 Nov 2019 08:16:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7F3B5C21F49; Tue, 26 Nov 2019 08:16:20 +0000 (UTC) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by lists.denx.de (Postfix) with ESMTPS id DC9A9C21E3A for ; Tue, 26 Nov 2019 08:16:06 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id 4so17985292wro.7 for ; Tue, 26 Nov 2019 00:16:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=STXqCAh1W9tZ50XVv4RGisNMQUpE5G3Vw0qCpJnTkE0=; b=VHihpcxEPU0TCrvuwvOKwxV/eUbBEX+VpAkksGnlHctsNHxgfNcRYUNhI9GFi0CZNr LhoTvBjXYcLH7rAEXjY0EC2TvKnaBMzYYXkpMiZ1pBLrvCHv5YDtfyTru/rBJPGWCbUr ct2+ni3P7YsPYV7q2oyR0xHx4pOHh2o0al9Mk6OLouCnSfO826kCMsh+EoB3ptfJbsRm dCJws/QkexhmSHXWWQ7aeTJ0GpHPr32+cfkDglmZclG3huPin7uPt6rg91y72in7Fi3F 0rq7UCwrKzS/hVBV6gnpG3cbxiiDbH5TsDN5w7ld/pJySMfgIMTRpTDuB1qWJavVGkuR DxnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=STXqCAh1W9tZ50XVv4RGisNMQUpE5G3Vw0qCpJnTkE0=; b=hNC3uIkDhcpv0RYY+C1n7NXIdSS/Ti+EY7mo3LyVWJ/7cTNn1bljHvOf46CajE0/lR DMBLFtfUMVEUOjMQp81zW978Rk2rif4kLhZYhXTtKM6WF+x3a7maHFDkn897eAwornp0 PaA6QDUTt7XuzpEUSk271kWoF12/ZB8XHlPZdnWxi0u8aS7ySPaDdkQkKRJO0m0tIkdH 3Fr33uF6ACOIugLA2uIfHA4zrmVbTMygHD2NOAdld61dPuTdqZ/0t3rb3XxVDnxIDl2j 3QobY/puu9uAcNQzwTV3RW1J6kvQARgptJaeZR5tbUWMqupVnSHvBxkdeAyKrq2CFxvU RyIA== X-Gm-Message-State: APjAAAVzs8/Q5zP9csi7W9t0TPJ84uprIQ6lWYLccz4Qnes34MFIAygB dIq2K0pDvgS4fvGnrBUtOqo= X-Google-Smtp-Source: APXvYqxno5asG2HneSgRTEtcCu+uCZJXusOI+TAddzLHMjJoW7ekKqcGoYEJ1XKVLzfmjKsHnZHj/A== X-Received: by 2002:a5d:530f:: with SMTP id e15mr36917124wrv.119.1574756166525; Tue, 26 Nov 2019 00:16:06 -0800 (PST) Received: from mamamia.internal (a89-183-34-158.net-htp.de. [89.183.34.158]) by smtp.gmail.com with ESMTPSA id c1sm13436855wrs.24.2019.11.26.00.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2019 00:16:06 -0800 (PST) From: Andre Heider To: Jagan Teki , Maxime Ripard Date: Tue, 26 Nov 2019 09:16:00 +0100 Message-Id: <20191126081602.2264519-3-a.heider@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191126081602.2264519-1-a.heider@gmail.com> References: <20191126081602.2264519-1-a.heider@gmail.com> MIME-Version: 1.0 Cc: Ondrej Jirman , u-boot@lists.denx.de, Jernej Skrabec Subject: [U-Boot] [PATCH v2 2/4] arm: sunxi: add a config option to fixup a Bluetooth address 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" Some Bluetooth controllers, like the BCM4345C5 of the Orange Pi 3, ship with the controller default address. Add a config option to fix it up so it can function properly. Signed-off-by: Andre Heider Tested-by: Ondrej Jirman --- arch/arm/mach-sunxi/Kconfig | 12 ++++++++++++ board/sunxi/board.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 16d41b83af..b41c64870e 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -1009,4 +1009,16 @@ config PINE64_DT_SELECTION option, the device tree selection code specific to Pine64 which utilizes the DRAM size will be enabled. +config FIXUP_BDADDR + string "Fixup the Bluetooth controller address" + depends on MACH_SUN50I_H6 + default "" + help + This option specifies the DT compatible name of the Bluetooth + controller for which to set the "local-bd-address" property. + Set this option if your device ships with the Bluetooth controller + default address. + The used address is "bdaddr" if set, and "ethaddr" with the LSB + flipped elsewise. + endif diff --git a/board/sunxi/board.c b/board/sunxi/board.c index bb35d6b66e..89851102d1 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -856,6 +856,34 @@ int misc_init_r(void) return 0; } +static void fixup_bd_address(void *blob) +{ +#ifdef CONFIG_FIXUP_BDADDR + /* Some devices ship with a Bluetooth controller default address. + * Set a valid address through the device tree. + */ + uchar tmp[ETH_ALEN], bdaddr[ETH_ALEN]; + int i; + + if (strlen(CONFIG_FIXUP_BDADDR) < 1) + return; + + if (!eth_env_get_enetaddr("bdaddr", tmp)) { + if (!eth_env_get_enetaddr("ethaddr", tmp)) + return; + + tmp[ETH_ALEN - 1] ^= 1; + } + + /* Addresses need to be in the binary format of the corresponding stack */ + for (i = 0; i < ETH_ALEN; ++i) + bdaddr[i] = tmp[ETH_ALEN - i - 1]; + + do_fixup_by_compat(blob, CONFIG_FIXUP_BDADDR, + "local-bd-address", bdaddr, ETH_ALEN, 1); +#endif +} + int ft_board_setup(void *blob, bd_t *bd) { int __maybe_unused r; @@ -866,6 +894,8 @@ int ft_board_setup(void *blob, bd_t *bd) */ setup_environment(blob); + fixup_bd_address(blob); + #ifdef CONFIG_VIDEO_DT_SIMPLEFB r = sunxi_simplefb_setup(blob); if (r)