From patchwork Tue Jan 14 10:40:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Neeraj Sanjay Kale X-Patchwork-Id: 13938605 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2058.outbound.protection.outlook.com [40.107.22.58]) (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 5A7CF1C4617; Tue, 14 Jan 2025 10:39:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736851186; cv=fail; b=jknZ0bxMortCw4j9jzDxxaQZ3UMBPJhSbARJoHI9syHeuFeVbst9968qaB3IG8lX82baCJrzsjjNTR7FjliitYiyajfpMUz5YYCtJz67Tt0wO9EY85tsutK8TydgoT2x/QoPFYvtc569uKyfC6RFPvdEKwGgk2mZ502sWRdQ0OU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736851186; c=relaxed/simple; bh=qEwOgUuNtM3MeGJu+fGRwOdHtEdlmeqDutKE/H3W7xM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=jC1BrVBslMSiEhwAFx/R8vJKiQVrhrTR3bhzIK9k5ROcEs2365hdf59SJ6vK3EiC3nMv6XPOB0yjoZ1nUi/QgfYG/Vd7Y7cEPxk6y1sWsMq0F3Z+FhH3+NLZdiL6EMmtKy/D9Uh36LXhgmG1KyeGekH+Jl+ISDBHM/N5pb8QF4Q= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=lGeb8pB/; arc=fail smtp.client-ip=40.107.22.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="lGeb8pB/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eZuIgKvid6oP8UV2fQi8tmsnpN1aAUnAZlCLbAKk5n1yabie/FjEyxxfRwnLcPB493Z4EX1e0axFVfi4Hp1TTa0QEcztNryVSNPbBO3+XKWcp3rA1kO5X6hLqFY983xer/inzz9kD48PGhqWqOcvbZ1Wi2Z0FMl+BKzL+c0LE0UbjQZlPlpemAcFRNZnlAptkTuNkQ0r3TtctuuMrwzQqqw8YvqENS85fcn24a7GrCrMFk+Ns3raD2BdW1AA+gBGL6pNY6bUJ86QWChK6WidAkMn/LnnmPpDTrJ+T3k6lX7x9TqvZdsTGqfeHjQkZo04h+7ztY5dJjfSSyblkJEd2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=J3GfMA54z6RQBfAsc5L3IwjxdztoEiO/a87y148hXfw=; b=Yu99x3fE4UCpgsjdLoYtAh0CmF0AHS2e7stezN6WmOyRgEgLq0oPZO4VRRuJy192wEjOnjNYLGxskMXNNYktaiuS85HrZ6L+ou2LX55nsvY4ZY+z0uCcBEmOQmdpC420s+lbPPPG0dX+9wXRGAiZWJ0+Mcmzfg0xhMkV7PufQpL/8gJe8aphJ9EF9YdIuPOny7wgeFPtIM/NZyNgJstclFilt5hrZQkmNN2agU+aMeodELAJUqN4m3YiwxJoT0Y+uTLVoihhZaSDrXDVPenojjnyZsJCsGqAxgYFF5tOwJErze+zqwb0AchrRZJCmYtsLKbDIczIe+0EUNMvC1HEFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J3GfMA54z6RQBfAsc5L3IwjxdztoEiO/a87y148hXfw=; b=lGeb8pB/E/g9+1Q1CZeJ+TVTm7u+oSveqsugWR2WDTrzWV4dVQXR1uifS4/zc069qSKuHSLqlT1prTSTWruAOlqhh3VV7ftrnwckMc5/QA00ES0atOPHRpz7uKg1wNscBpxIH+89BvZdVCRP6/KW0Ji6JMufJDCGGetrLA8tmwK7779Uu2oiAuowIHerkjKlpB3uKaeUUyNzdGZATdf1X3K9f72+6/YPIJ1OmrtkGDLrAzNUHmZrQTrI0lJPAdXUPsQ+E5K5VFsV/Lqy4GnGKb0PvVKNM4dRRDA7VxXPm7KpJXUseUtRo1vc7+ZGeDmoD5ynYis+QSTbZxL1YUkAZw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS4PR04MB9692.eurprd04.prod.outlook.com (2603:10a6:20b:4fe::20) by GV1PR04MB10377.eurprd04.prod.outlook.com (2603:10a6:150:1d1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.18; Tue, 14 Jan 2025 10:39:41 +0000 Received: from AS4PR04MB9692.eurprd04.prod.outlook.com ([fe80::a2bf:4199:6415:f299]) by AS4PR04MB9692.eurprd04.prod.outlook.com ([fe80::a2bf:4199:6415:f299%3]) with mapi id 15.20.8335.015; Tue, 14 Jan 2025 10:39:41 +0000 From: Neeraj Sanjay Kale To: marcel@holtmann.org, luiz.dentz@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, amitkumar.karwar@nxp.com, neeraj.sanjaykale@nxp.com, sherry.sun@nxp.com, ziniu.wang_1@nxp.com, johan.korsnes@remarkable.no, kristian.krohn@remarkable.no, manjeet.gupta@nxp.com Subject: [PATCH v1 2/2] Bluetooth: btnxpuart: Add support for set BD address Date: Tue, 14 Jan 2025 16:10:33 +0530 Message-Id: <20250114104033.2324297-2-neeraj.sanjaykale@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250114104033.2324297-1-neeraj.sanjaykale@nxp.com> References: <20250114104033.2324297-1-neeraj.sanjaykale@nxp.com> X-ClientProxiedBy: SGXP274CA0008.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::20) To AS4PR04MB9692.eurprd04.prod.outlook.com (2603:10a6:20b:4fe::20) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS4PR04MB9692:EE_|GV1PR04MB10377:EE_ X-MS-Office365-Filtering-Correlation-Id: 44ff5e1f-694a-4d25-f26b-08dd3487c0a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?tr6bcMcvw+wFtY7DAsgL1YhQjZugaHq?= =?utf-8?q?tbNUgTuKYTTZDX/MrYNlHgBQ+HdwNtnPADHYc0ZJ8s/X16AOBc/6VIaMTJGkoNBkq?= =?utf-8?q?86OTJRmBP4ZzzyHuB3YAvs7XsMmV6IvD80DmCwTHMe9gDgR6hhUNqk94ZfBdbqR4h?= =?utf-8?q?IGbZ2sHN+C/uuIVjypZXdjgWIUepSWrGcGRqxAk2X38xmzDvI9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okrq+zYPr1VUSiiutfutmFRgQ9Bh72?= =?utf-8?q?RhNao/BxjOZkYIB7h8p1ye1i4oucbD+QMphxCxqs/WefO54NM7KA/RVjFaRekyD/0?= =?utf-8?q?xtOifj9ooA7e62vtkyt3FycuIZMg/V0G+pOx6Nw0woz8nQT13N391HV1t+nNza2ZZ?= =?utf-8?q?RAoNLqHMyMjAJpOzenLhx8J8NJOf4pBu1vpQVQWZMOTntpb1dgYIK7Lgq6gY7ZAmG?= =?utf-8?q?an1y5ZMRf0txNurudTL1WK2VAWu0DLY1pVyimQkZbNRXFxKuVzvi+x5t7UN6ePZ5e?= =?utf-8?q?Sm9D+DRAdvdRkRKj/4aXVKKJVUI5M3z6X1UWAOliqaYgM2+EJC6lKEIN3FKegWJxp?= =?utf-8?q?yVJBJ1MU7+F?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS4PR04MB9692.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(52116014)(1800799024)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?IZFEX/TdQgmRhdVmNaNV7w39Mu0c?= =?utf-8?q?pMZCf7SyetEKfmjiO+Gw0633A4E5KFTm5ET/VJr9zq5RwwJZmh5Z1oKFHPJqZRWed?= =?utf-8?q?Ydt2KEx+DAh6BTzEMSlTlICtc1OB0EJ7iNHYVkgteqO4X0zEbpF+5SN8M9oXOY1T5?= =?utf-8?q?Qxfn4r5OID3TyXYPvrgYuSNvLi8UhzlN8B7VNY1gr74hebPA87nFyfhKt02BkHAip?= =?utf-8?q?vsseYr2Myfn/jYCEQ1X3680L5w42Jdy1TbQY9nSQl1bOaH2UApQ0BfzW9haR0MO/M?= =?utf-8?q?EijYKuHah4SqTM+tla3BjdN1W3ZNIAqHa855Aw5wH2uXlupmcV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BPZo1LnDE?= =?utf-8?q?+OmXttqNMT/7vq6cZp1Boob3xP5pkckw2YCzrnQaUER/n6AKVRYnWLPMS/ZBq98uz?= =?utf-8?q?1wAYqATewLS/0CVlMMz6u5KftaGmZ442xj8KEEcgIfouqI7qVZj5xYY0mwvw/IuU1?= =?utf-8?q?JtObSWJoH6hxCBHF3VJIGOGk5KapJwx8aUZXnEukNAsLQhhuMtG0rzUGJH2FfzIES?= =?utf-8?q?IZoxKA8Z4g+iRQVrt/q1Xp5qIompmA9lSkRJlRgVbqE1DqBkpPU6kdfbVO9+WVsw6?= =?utf-8?q?n/tNiWOC03MCXF/71WOuYya1mw3I0wdJpHthhJ/br5rmUI+zQfpehVDX68BhW7zDT?= =?utf-8?q?JHVjpPBMUYNBmAWEvNq9CuvswOOY29hjgQ=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44ff5e1f-694a-4d25-f26b-08dd3487c0a0 X-MS-Exchange-CrossTenant-AuthSource: AS4PR04MB9692.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2025 10:39:41.5221 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: k+fKvV+NLizMWgcvybjB1X42Q6cuptq0iOpemcBGZ8N8+57aotzdpAA7pqSIZh888LLGwQF9np01vjcsIJHNaVzPUpsnwgdZd2zD76C0MVw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10377 This adds support for setting BD address during hci registration. NXP FW does not allow vendor commands unless it receives a reset command after FW download and initialization done. As a workaround, the .set_bdaddr callback function will first send the HCI reset command, followed by the actual vendor command to set BD address. Signed-off-by: Loic Poulain Signed-off-by: Johan Korsnes Signed-off-by: Kristian Husevåg Krohn Tested-by: Neeraj Sanjay Kale Signed-off-by: Neeraj Sanjay Kale --- drivers/bluetooth/btnxpuart.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c index 1230045d78a5..deb546a4e664 100644 --- a/drivers/bluetooth/btnxpuart.c +++ b/drivers/bluetooth/btnxpuart.c @@ -1197,6 +1197,34 @@ static int nxp_set_ind_reset(struct hci_dev *hdev, void *data) return hci_recv_frame(hdev, skb); } +static int nxp_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) +{ + u8 data[8] = { 0xfe, 0x06, 0, 0, 0, 0, 0, 0 }; + struct sk_buff *skb; + int err; + + memcpy(data + 2, bdaddr, 6); + + skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + err = PTR_ERR(skb); + bt_dev_err(hdev, "Reset before setting local-bd-addr failed (%ld)", + PTR_ERR(skb)); + return err; + } + kfree_skb(skb); + + skb = __hci_cmd_sync(hdev, 0xfc22, sizeof(data), data, HCI_CMD_TIMEOUT); + if (IS_ERR(skb)) { + err = PTR_ERR(skb); + bt_dev_err(hdev, "Changing device address failed (%d)", err); + return err; + } + kfree_skb(skb); + + return 0; +} + /* NXP protocol */ static int nxp_setup(struct hci_dev *hdev) { @@ -1547,8 +1575,12 @@ static int nxp_serdev_probe(struct serdev_device *serdev) hdev->send = nxp_enqueue; hdev->hw_error = nxp_hw_err; hdev->shutdown = nxp_shutdown; + hdev->set_bdaddr = nxp_set_bdaddr; + SET_HCIDEV_DEV(hdev, &serdev->dev); + set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks); + if (hci_register_dev(hdev) < 0) { dev_err(&serdev->dev, "Can't register HCI device\n"); goto probe_fail;