From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED22144BCB2 for ; Thu, 7 May 2026 15:25:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778167508; cv=none; b=Rfqex6zx5O9RDhoUnkdDD10WTOOZlpi2y30Php7216iUfgleEK14qes9A5Gfx4jXorqoJnGFUucyIUKveQd95Ev4bexdupOcGcUkBeIxA31ATne3bmcbj7FutMCAS3uwA3YpTee3+bvacmJnuJEguwCgaDIplD5CLKQLPCv/KAQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778167508; c=relaxed/simple; bh=/5JSpbZRWY5COHZDhN4gNF7Jnw0iPmpuvearF0ixaPA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SIibkZd5sLZoF4Jjc9XLZWVuVvg0e6eUE64b/h7wvUbbPQIwoUaxjbsorbJhAKeVyZmmDL/g4tJ+gtP2aYj5CzxMMINAU2JOZ1U4ZgElNcoJCPUiaWOaNU6mTIvnamIRcVygJct53BEqZBTbX4F87PYDVKipvurSzkB81ShH3jo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=OBsau1YP; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=DHONmrzn; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="OBsau1YP"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="DHONmrzn" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 647BdZ7q3157321 for ; Thu, 7 May 2026 15:25:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= kVKEAS8GhVMCCsKzWvqDs3cunTV/p/7YyYFmPXPEJtI=; b=OBsau1YP7Yy+Iv0k Uq5fle1uCLNF61w2iOsc5BgnzsyKJrCSbaMr3P4ys20u8HSD5tSJmzwaB3UsTu1/ 65eX6tYgK/vJ2IVXY1nORGIG2vRygbP9teOOJffIvXS9DQq/l+CTaCkjAQPuPRXG 1ScKblMYBSjQFTZjjKwMpQ8ytpsegGBp9EB0LwFrONQgBdA8et8K4uclP2xCXQio f6cC/i5TRqDx0gumanbzk9exuVFBX0rmg9+a3QZ6CUuFWfgXkx5gnzYYGO+Aa+co KjEk5eF+GrUEiIC+/d3AGbGi+HC8STjRLvTuU8aN+urzheNgt37w6Ospq8pnDa43 1SueFg== Received: from mail-vk1-f200.google.com (mail-vk1-f200.google.com [209.85.221.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e0mhf28gb-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 07 May 2026 15:25:01 +0000 (GMT) Received: by mail-vk1-f200.google.com with SMTP id 71dfb90a1353d-56f6ef62af1so2208740e0c.1 for ; Thu, 07 May 2026 08:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1778167501; x=1778772301; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=kVKEAS8GhVMCCsKzWvqDs3cunTV/p/7YyYFmPXPEJtI=; b=DHONmrznETmLNj+/HA2W9VThA2sxk1CHvggZE5NPbGJ/OWjx0mZcuN7jIXRDZv1u4f JbbS71anhoD2uxxG6+D4M2TRl71dW1twRmWC0UJEzBd39A45NN79yvolOeGEAJmo0mta 7QliufA6Zb8fnAKDPx3jOpUEUPmFooQW1a4YwG3pvgsWCoheqK/BoHVT0Bc7gwed4kSU zOHQM7rVvIh6iT3+zhAJ4gPonh0g32ROILXv5WoKG49HL1tEx088By3w717gjm3S8sPo QV/D+DgbeMUGP3LTx0xqp6UJBHwV3hkrccMpf0Jt0QJKLFUXJ5YcXWQOEZeWqgGGcTuy 2uyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778167501; x=1778772301; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=kVKEAS8GhVMCCsKzWvqDs3cunTV/p/7YyYFmPXPEJtI=; b=X/0z1NCT+NTs4oCXyzlqZNT9qmfT0aHI+pMxrNfAHqGh7aYjPjfz1vIuaYZe9OkFfH YlYshh+fQ7kBivF61EpBSsE6t3dex+Bx9nyXD5+lve3vyKiJRRkKdPkbBXgoMsy8Udnm Syhk5Fxj95hMbuTfcFDNxs62Lqfkge/wMAglXExUiUOYZQTAW9bGucUofv52qCzLBJnM JFIJg8YO+8D7t2etb/OapX1fBKfepru50wQLDyLPAu0dsKVwcrKcQePJ44UvN6jLh94Z Fc0Gm4qKzf2YiPatRSuf7Xa+f4TjnZsna1M0PLBiHni4tYUAo9ip+9FM0igfhKGmKA+L gsNg== X-Gm-Message-State: AOJu0YwnS3WHbgkVf6wRhhIqA4Wv+h8lVKErBIEm6DhV66TWhItpCMpy oOS+buerCRCNvC0U6Lq9PMSwjMwhHng0UDYG7Ur2fc8Xsou6zCVVBgLkfUcqYRHdEFU3GVF6vco 02+fx+Xt/UnCRAaX/g5DM2eawlm0iRzZO5Mg/7P2TqfseIyLedDm6AFxVdXb3DyE= X-Gm-Gg: AeBDievaK7A4DPC4Mzpg6r3WFps64261SpOtyqvbuZODqr9H3ps9oKg837cn6es6vXY ZuYawNxb/j6nGK/w0e4BdO80hr11jLOhYkbE1SOITbUOZ47dwEdxIrrwDq0bCS1bHQ3zcLaFlvd /DsDFz7FT/kiU43IsCzOO7Eaip1G9YnClQt2yB9x4m16V1+urgU5KzIWKx/2Thz9mj2Knd4Es8u G9/OSaxSRNQVjLM3n0WPst3DSkRbstGdv8W06uklb/Yj8iGZf9+p2vvF95ceYp7CW5psJLoLQCY MnRi1br7M00QIbra8i3wt7Emq+HBgP/i01vJ7vNR9U1JHGv+DGAoWtK0bI7+8Fn+7/REkxYfNcw ui3xP60R/XuFiHVOt0HrPV9CMxnTV9fmYCE4wA0+RVaFFZG76nVKzyjEWoPrffbQW0bAxIiaCTT FUvTnP+83QtNvce84Hx/cVHqPg0dQ= X-Received: by 2002:a05:6122:a07:b0:56b:8e17:25f5 with SMTP id 71dfb90a1353d-575595c4094mr5143475e0c.11.1778167501244; Thu, 07 May 2026 08:25:01 -0700 (PDT) X-Received: by 2002:a05:6122:a07:b0:56b:8e17:25f5 with SMTP id 71dfb90a1353d-575595c4094mr5143393e0c.11.1778167500580; Thu, 07 May 2026 08:25:00 -0700 (PDT) Received: from QCOM-eG0v1AUPpu.na.qualcomm.com ([2a01:e0a:830:450:b16a:3475:ec42:bcfa]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-bca583dd7e4sm240966b.58.2026.05.07.08.24.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:24:59 -0700 (PDT) From: Loic Poulain Date: Thu, 07 May 2026 17:24:41 +0200 Subject: [PATCH v2 6/8] Bluetooth: hci_sync: Add NVMEM-backed BD address retrieval Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260507-block-as-nvmem-v2-6-bf17edd5134e@oss.qualcomm.com> References: <20260507-block-as-nvmem-v2-0-bf17edd5134e@oss.qualcomm.com> In-Reply-To: <20260507-block-as-nvmem-v2-0-bf17edd5134e@oss.qualcomm.com> To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Jens Axboe , Johannes Berg , Jeff Johnson , Bartosz Golaszewski , Marcel Holtmann , Luiz Augusto von Dentz , Balakrishna Godavarthi , Rocky Liao , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Srinivas Kandagatla , Andrew Lunn , Heiner Kallweit , Russell King , Saravana Kannan Cc: linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-block@vger.kernel.org, linux-wireless@vger.kernel.org, ath10k@lists.infradead.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, daniel@makrotopia.org, Loic Poulain X-Mailer: b4 0.14.2 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA3MDE1NCBTYWx0ZWRfXy5bPR6mf7zOV MmZN2pAa+hSmqMjvHS1YowoXOQ1mA7brE9bjJNThcj/rOVZidAupraVQU1ndrYIF01NTfBCqt3s zbhbn7drfqh8l3sl/5aizza59c8IJyrc1MsfhLiHbssnDt/+wgrXkwE9JJLiVsviNzGbmiXIzzV WUg4kYiI7DbG3z8jdj8I70+U7KlZUrcJhzZ9up67H6BIpBSZpM2iYxssGGaTdiqc8sGeOzLa+1J PTbxsOAoBC22TshkcfymLo0Z8d7HB2JmacL4NX/A1x7jlP21NOooqtHPPAxWwh6n4wRh/eYV/78 r/+w0hjIqUO1aGRHG83P0kT6vfs2bY4S+1HWswLdTcBiIUaYT69OPCmEq0SgMwpcgdIrSOHCVqM 1WB8M0YkiDDe7KXMEdnjzYoPESAzERhGuGEpxkvnZzoWDgHjhk57qU8exy+methjuzQEPTGnWtD mUSX0mcewUyrP2TTSZQ== X-Proofpoint-ORIG-GUID: mvofw-UxvpC4UxVIz7H1_S7TaugYt4sT X-Authority-Analysis: v=2.4 cv=SuagLvO0 c=1 sm=1 tr=0 ts=69fcaece cx=c_pps a=wuOIiItHwq1biOnFUQQHKA==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=tQ7bI2BnKgK5Av-YYOwA:9 a=QEXdDO2ut3YA:10 a=XD7yVLdPMpWraOa8Un9W:22 X-Proofpoint-GUID: mvofw-UxvpC4UxVIz7H1_S7TaugYt4sT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-07_01,2026-05-06_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 adultscore=0 phishscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605070154 Some devices store the Bluetooth BD address in non-volatile memory, which can be accessed through the NVMEM framework. Similar to Ethernet or WiFi MAC addresses, add support for reading the BD address from a 'local-bd-address' NVMEM cell. As with the device-tree provided BD address, add a quirk to indicate whether a device or platform should attempt to read the address from NVMEM when no valid in-chip address is present. Also add a quirk to indicate if the address is stored in big-endian byte order. Signed-off-by: Loic Poulain --- include/net/bluetooth/hci.h | 18 ++++++++++++++++++ net/bluetooth/hci_sync.c | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 572b1c620c5d653a1fe10b26c1b0ba33e8f4968f..7686466d1109253b0d75edeb5f6a99fb98ce4cc6 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -164,6 +164,24 @@ enum { */ HCI_QUIRK_BDADDR_PROPERTY_BROKEN, + /* When this quirk is set, the public Bluetooth address + * initially reported by HCI Read BD Address command + * is considered invalid. The public BD Address can be + * retrieved via a 'local-bd-address' NVMEM cell. + * + * This quirk can be set before hci_register_dev is called or + * during the hdev->setup vendor callback. + */ + HCI_QUIRK_USE_BDADDR_NVMEM, + + /* When this quirk is set, the Bluetooth Device Address provided by + * the 'local-bd-address' NVMEM is stored in big-endian order. + * + * This quirk can be set before hci_register_dev is called or + * during the hdev->setup vendor callback. + */ + HCI_QUIRK_BDADDR_NVMEM_BE, + /* When this quirk is set, the duplicate filtering during * scanning is based on Bluetooth devices addresses. To allow * RSSI based updates, restart scanning if needed. diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index fd3aacdea512a37c22b9a2be90c89ddca4b4d99f..589ccdfa26c1281d6eb979370523fff0d7920302 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -7,6 +7,7 @@ */ #include +#include #include #include @@ -3588,6 +3589,37 @@ int hci_powered_update_sync(struct hci_dev *hdev) return 0; } +/** + * hci_dev_get_bd_addr_from_nvmem - Get the Bluetooth Device Address + * (BD_ADDR) for a HCI device from + * an NVMEM cell. + * @hdev: The HCI device + * + * Search for 'local-bd-address' NVMEM cell in the device firmware node. + * + * All-zero BD addresses are rejected (unprovisioned). + */ +static int hci_dev_get_bd_addr_from_nvmem(struct hci_dev *hdev) +{ + struct device_node *np = dev_of_node(hdev->dev.parent); + u8 ba[sizeof(bdaddr_t)]; + int err; + + if (!np) + return -ENODEV; + + err = of_get_nvmem_eui48(np, "local-bd-address", ba); + if (err) + return err; + + if (hci_test_quirk(hdev, HCI_QUIRK_BDADDR_NVMEM_BE)) + baswap(&hdev->public_addr, (bdaddr_t *)ba); + else + bacpy(&hdev->public_addr, (bdaddr_t *)ba); + + return 0; +} + /** * hci_dev_get_bd_addr_from_property - Get the Bluetooth Device Address * (BD_ADDR) for a HCI device from @@ -5042,12 +5074,17 @@ static int hci_dev_setup_sync(struct hci_dev *hdev) * its setup callback. */ invalid_bdaddr = hci_test_quirk(hdev, HCI_QUIRK_INVALID_BDADDR) || - hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY); + hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY) || + hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_NVMEM); if (!ret) { if (hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY) && !bacmp(&hdev->public_addr, BDADDR_ANY)) hci_dev_get_bd_addr_from_property(hdev); + if (hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_NVMEM) && + !bacmp(&hdev->public_addr, BDADDR_ANY)) + hci_dev_get_bd_addr_from_nvmem(hdev); + if (invalid_bdaddr && bacmp(&hdev->public_addr, BDADDR_ANY) && hdev->set_bdaddr) { ret = hdev->set_bdaddr(hdev, &hdev->public_addr); -- 2.34.1