From patchwork Tue Dec 3 08:45:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Heider X-Patchwork-Id: 1203563 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="WbsWMZcl"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 47RwZw6nbsz9sP6 for ; Tue, 3 Dec 2019 19:47:04 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 83F98C21DC1; Tue, 3 Dec 2019 08:46: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=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 39652C21DDC; Tue, 3 Dec 2019 08:45:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 711ACC21D56; Tue, 3 Dec 2019 08:45:52 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by lists.denx.de (Postfix) with ESMTPS id 0AA0EC21C27 for ; Tue, 3 Dec 2019 08:45:52 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id y11so2561898wrt.6 for ; Tue, 03 Dec 2019 00:45:52 -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=FZSJMSVub8x5ZLTTlmwLsTw8i2Ard34+2O1zLLcTmzk=; b=WbsWMZcl29YJmjZGiJeHCh1nvrgufHQZnPgUvkmojfLD6dwVRc93V5WMSX+aQRtwuB CYGzRPgKjMi+WpENIC9bpnvPJmPFnyD7oQYe379C/raWjZbBD8WVdfnXMbv/Lo4hO4u+ 9v/ehiZPJYy6/lbCn3aPVFl4v+9+8k4NIOT62gm8zvsBChKPd+sYfTyg9meDg+A1jYsV +a/dzXIYrdvEVwbnAOQ1b22st0EzwGwcDM40mPIkBaywkvlhp+FHa5yAbGOHLItuXCuA 4ov7VyGdhFkog/3iy/4RLICA9N143c0EO7srCsjw7rupsjHZnuH8vXdzZ+XyRo6LP/He c8kg== 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=FZSJMSVub8x5ZLTTlmwLsTw8i2Ard34+2O1zLLcTmzk=; b=Yt7cq3mv1RdA7WlJyNqErW+keEYFoQLj1mFC2tMjjNJhuiKf1ln6qEOIVRFxWMJ/MN 6qdgGTpuOl/AMRbWQKbUFu+5ZHUFFaB8QvG4SWZ5cnk1x8r/ecUpBj0XRSgrVjgbdWID Iensky4pzmILMBDqPyHDU1hiPhrxxSvoWPwyee3GtuDvAtk3dLE5rmw4TSyBRQNHCDTe B5glEDZBdUfbH5C/e7EaB6PqaYkJx+t4aGOL7IxsDqzzvtf6XcvA8R+WcnCiB6MyW4jB Rh9C/nSyD3M7PaVGvnVJJxZDCthKkQiXzqJiG0DbSVBkUwo7gx5CQ/f5s6uoKloQrYfS TB/Q== X-Gm-Message-State: APjAAAXuZwwdx/xTy2a+tF7BrIuQenCZ3sAAmUBMVvjxVqI9OE0z0JHW PwMKXMm7EwSaSbJ4Tf3M6RU= X-Google-Smtp-Source: APXvYqyZGsGhW9NMCQfC7bOSIdem4NKYmrOmLZFbV/tyng9SrG18z+rRTZAIOl3Dt+hOCW2cVeOnFg== X-Received: by 2002:a05:6000:118d:: with SMTP id g13mr4017596wrx.141.1575362751668; Tue, 03 Dec 2019 00:45:51 -0800 (PST) Received: from mamamia.internal (a89-183-66-130.net-htp.de. [89.183.66.130]) by smtp.gmail.com with ESMTPSA id u1sm2150866wmc.3.2019.12.03.00.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 00:45:51 -0800 (PST) From: Andre Heider To: Jagan Teki , Maxime Ripard Date: Tue, 3 Dec 2019 09:45:37 +0100 Message-Id: <20191203084539.1956677-3-a.heider@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203084539.1956677-1-a.heider@gmail.com> References: <20191203084539.1956677-1-a.heider@gmail.com> MIME-Version: 1.0 Cc: Ondrej Jirman , u-boot@lists.denx.de, Jernej Skrabec Subject: [U-Boot] [PATCH v3 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. Tested-by: Ondrej Jirman Signed-off-by: Andre Heider --- arch/arm/mach-sunxi/Kconfig | 11 +++++++++++ board/sunxi/board.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 16d41b83af..4513c07ffb 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -1009,4 +1009,15 @@ 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" + 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 42bec3a4d8..4311d4cba2 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -876,6 +876,38 @@ int misc_init_r(void) return 0; } +static void fixup_bd_address(void *blob) +{ + /* Some devices ship with a Bluetooth controller default address. + * Set a valid address through the device tree. + */ + uchar tmp[ETH_ALEN], bdaddr[ETH_ALEN]; + unsigned int sid[4]; + int i; + + if (!CONFIG_FIXUP_BDADDR[0]) + return; + + if (eth_env_get_enetaddr("bdaddr", tmp)) { + /* Convert between the binary formats of the corresponding stacks */ + for (i = 0; i < ETH_ALEN; ++i) + bdaddr[i] = tmp[ETH_ALEN - i - 1]; + } else { + if (!get_unique_sid(sid)) + return; + + bdaddr[0] = ((sid[3] >> 0) & 0xff) ^ 1; + bdaddr[1] = (sid[3] >> 8) & 0xff; + bdaddr[2] = (sid[3] >> 16) & 0xff; + bdaddr[3] = (sid[3] >> 24) & 0xff; + bdaddr[4] = (sid[0] >> 0) & 0xff; + bdaddr[5] = 0x02; + } + + do_fixup_by_compat(blob, CONFIG_FIXUP_BDADDR, + "local-bd-address", bdaddr, ETH_ALEN, 1); +} + int ft_board_setup(void *blob, bd_t *bd) { int __maybe_unused r; @@ -886,6 +918,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)