From patchwork Tue Feb 4 09:37:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Heider X-Patchwork-Id: 1233197 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.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.a=rsa-sha256 header.s=20161025 header.b=e6QukjU3; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48BflY0F0Gz9shj for ; Tue, 4 Feb 2020 20:38:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 309BC81AAC; Tue, 4 Feb 2020 10:38:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="e6QukjU3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5AB3C81A95; Tue, 4 Feb 2020 10:38:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_HELO_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 158D481A95 for ; Tue, 4 Feb 2020 10:38:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=a.heider@gmail.com Received: by mail-wm1-x344.google.com with SMTP id c84so2642903wme.4 for ; Tue, 04 Feb 2020 01:38:09 -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=mXerZmUfxHIcRBpTDNo7Cmu3lRCZ7ZL60OULtvVYbT0=; b=e6QukjU3zN5ObfYH1CiWAMGMf1ovNTmtZEF96Ks0q/JbZ/FQ+mQSH7kuNgkmpgmQi9 mSQLJ64M/3HOgtPjINe8jrc6q1crady+rpzNgHEI1tHSF/AM9zMgm56sqYYTGTdXyIuT KrZhjF/woCgaz/Zfkb2mt49By99QrOc+3rzmKQ1U1PAHV6AGoiIlVFtqBpR6jSBdPU2y OCoeAVNOHZTZ6HqOqLG5rPbPlaAIpq6NmVilkBjQmd1ezKPkJyH9Zw1J92uS6OL+yc4l z+2dAbCmuLhqg/QBOJKQkYwxGQJiA5vRMwOT2PNsAeR1ijF32aVAKgF0lGFxH9ikKOJT 7TOw== 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=mXerZmUfxHIcRBpTDNo7Cmu3lRCZ7ZL60OULtvVYbT0=; b=UGo4mLE0/nEC7ZA/OKu+VeZRF7tHHA5vzVEkp8gVQLpZQ8b4yRkj4SuTcfsed7XN5x k++rES6reYTmijQQhL6qQ6+l04BIhWFvmykc9ylTcD+0ZZwBXwX2ZxaBa1Sjp5Zq3A8e V7jNjRD3XWLQJmll3JDocaQrubE/5Brm9ITBN+CECo1Rut5xxCqRN/IEMWxktNOGOpvt hKHNoThg7Ek7aTVj2gaBbsLGDGAAiiWHQWi1AReBXYH4WvvoCFSK95HIzO4iR0rIt7vd M9bBgfovzhqWt+rFu8lWJmpDTTIay4UcmN4Orw1fC7gqboTJIW+G+IHrFI0ea9Tz/sDO GuWw== X-Gm-Message-State: APjAAAWp9rYgYB+1ph4jyPgRISZrnRxjzMRZpukQgiW9pmKzwB3lrBYI NFMEaYF8Ue2bCEOjUDEKg60= X-Google-Smtp-Source: APXvYqwxgSJs3XwfAA7xTsp/fDLzYzNKPcNn8H9xlKBQ2DVXswRx4xS+zjAOfBpbp4WLEsw0Cs2XGA== X-Received: by 2002:a05:600c:34b:: with SMTP id u11mr4695527wmd.69.1580809089305; Tue, 04 Feb 2020 01:38:09 -0800 (PST) Received: from mamamia.internal (a89-183-45-130.net-htp.de. [89.183.45.130]) by smtp.gmail.com with ESMTPSA id q130sm3345425wme.19.2020.02.04.01.38.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 01:38:08 -0800 (PST) From: Andre Heider To: Jagan Teki , Maxime Ripard Subject: [PATCH v4 2/4] arm: sunxi: add a config option to fixup a Bluetooth address Date: Tue, 4 Feb 2020 10:37:56 +0100 Message-Id: <20200204093758.584725-3-a.heider@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200204093758.584725-1-a.heider@gmail.com> References: <20200204093758.584725-1-a.heider@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ondrej Jirman , u-boot@lists.denx.de, Jernej Skrabec Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean 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 Acked-by: Maxime Ripard --- 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 3a3b673430..4c6977e8fb 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -1010,4 +1010,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 e670793479..c05682a331 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -878,6 +878,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; @@ -888,6 +920,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)