From patchwork Tue Jan 14 14:19:12 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: 13938827 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2041.outbound.protection.outlook.com [40.107.21.41]) (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 656D413B7A3; Tue, 14 Jan 2025 14:18:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736864286; cv=fail; b=lmmQwhzfTcjLbFDdU4c/MkX8rqzbfaCTmMFp3Woqj8kgybevNuRWh0JE723t+2hzgZHUx+tandXfzf9JHSKjvCWtdMSgvbmbCR5rdrrr3/sJLgy9nFTkBG/db3hsDlq7Ap16BjPEFHnh84Cq+2sUjgRIOlpDBBGyh7DgM2RlSaA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736864286; c=relaxed/simple; bh=qEwOgUuNtM3MeGJu+fGRwOdHtEdlmeqDutKE/H3W7xM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=RyZBlfvDns6L7X8mHR28DPLCcd20fvii8xTugDO1zBwiG0pTuP2qn192NIbo6lLslK8dcmgLFdnDNDk6XpfeUQxLm4Q428YmJnGZNuVQdwQrDcBStbhwI5iQfH5SKaqkh1sXFFAQUZpgT3FxsZMzIUn+2/XyqMvBsWw5wwLSXzk= 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=iVEaU5Ac; arc=fail smtp.client-ip=40.107.21.41 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="iVEaU5Ac" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IGFxjJ89DhJunm3B6GmI8xVHXYAjm/w+BOrbwjXzg/HSAu7oU9hdELKG/zWpi5uzstbyp3h1i0IzN1CVS4MgB/cMJbQuOU6oYSbwuN9DJDTZknYO3lCLga8+wQnT8H7gz935G5+bsnu5Tc9alONU0gH83gmSX4CmuZXMN/VvTPz/NWWssSDjvaIPvubjHvzwmXEhq3JpEA2Zqa2TlsZuleMuQDmrDPafKFSyAIOlQXcsv1/gb9aTzE5J3VhL6A7Tdd/na86L6hGOFfFvJyDMDcxkIty8ryUkQVwFC5KTtJLJD+EwN4Vg71y9Sud3b7/4FwlSRqoHSv2gocIkCbs36w== 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=WbjB4OEISWJ3W+Yv4N0KU/HueoeutzLpU9vA6Fk88FROs5LjF8lfjS/4/Tc3yRKym3LqGfT3ed7oDDkoDIMGW83mkyVj64I97nfS7ZuQT60uzu8ZqzVbayhNg/x9SBm62mkz4L9+cGwCHbufQjEPBQLROlFF62wes9GhqeDtNctzi2t1i/A0kVe4nBAHEpRtci3WoJM8b+Br0mzwCd7F7GTR7/kxnRzmKWGN9x8K1voNmA9Te0ss4bGtuBAEIxjFQOmaMd3A+MjZAPybv6c7I9bpZIxXfW52QpDjrFiaCn+76tJRfcJO1PoGgmGZhnbHHGx3sJUP/nB101RiBO1aSQ== 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=iVEaU5AcxSuCRSt7FLE4hJPbVJoSr1qH/lBKqIbe7289WYZHY2Wy94CKtgXHYwIUQT+sE+miQGH1fXG9GPrJ9K+xfzv5YromEg0S1rTZwlZFdOleH51d+LfNj/HUIt/1mQdeXERutlbpAsA4wzvdpSJyhTaY4dNtsSAzjG0nePeyAuUiAJ6e5tONHjkDaaSDn/bn8s7HHhyELB1OKTd39aRAVVpw/sClJahITGl3oo6j6Ws5KIhJL7OwEPyPD1qK+w9l3woj7L7GZMCJwsYcuWfZ3tH4j2U0w0p7RFLRT+geU1WIBcBYjDshNdSvU6O4ytODxsE7Ad0+JU8VeCnmGA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PA4PR04MB9687.eurprd04.prod.outlook.com (2603:10a6:102:270::15) by DB8PR04MB6812.eurprd04.prod.outlook.com (2603:10a6:10:f8::21) 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 14:18:03 +0000 Received: from PA4PR04MB9687.eurprd04.prod.outlook.com ([fe80::742e:a5ac:15f4:116a]) by PA4PR04MB9687.eurprd04.prod.outlook.com ([fe80::742e:a5ac:15f4:116a%5]) with mapi id 15.20.8335.015; Tue, 14 Jan 2025 14:18:03 +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 v3 2/2] Bluetooth: btnxpuart: Add support for set BD address Date: Tue, 14 Jan 2025 19:49:12 +0530 Message-Id: <20250114141912.2363131-2-neeraj.sanjaykale@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250114141912.2363131-1-neeraj.sanjaykale@nxp.com> References: <20250114141912.2363131-1-neeraj.sanjaykale@nxp.com> X-ClientProxiedBy: SG2PR02CA0109.apcprd02.prod.outlook.com (2603:1096:4:92::25) To PA4PR04MB9687.eurprd04.prod.outlook.com (2603:10a6:102:270::15) 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: PA4PR04MB9687:EE_|DB8PR04MB6812:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a1fae63-1319-42dd-e27c-08dd34a641af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?oKm1YJrZbhcM7guh1b07TJVvQVdR0nM?= =?utf-8?q?dwyKaCWTbaKF7s7QIlHyMitLgo+8NoAYa89BT+s00ELr+ij+KqrdZAgkwNrXiQoOP?= =?utf-8?q?6Q6JJY3d4baazpmE6IzhkTtkAMqlXxgz+h831yZUs3F7TIobtaaW60dFt4It4I13E?= =?utf-8?q?jTYeGBBTAFz2z3URB1jdHP7UcmUfEfAR64V94wOm0Cdv/Xqe0pdb63DJFBG1G8tgA?= =?utf-8?q?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35Ei4O0gswi7I/EfKXu+Isb/Ntk4gz2O+mjdaGAH60GtTiunW2MdrtX?= =?utf-8?q?6AFbeHcNN56ARjx1oJZEUl2tKD6Zj7U/YYp6WoGtGrQhPkIUsJZktcX+13iIWKc6Y?= =?utf-8?q?9WIwdMfgJl5uKY4nHCEaut29NlxceQcbWPq5evI4wJl8LMtTk+i/LoZ378VVeEgu+?= =?utf-8?q?SmdlavKRDrHzVZ/UmeNJgksogK2Qpb+CmQ3S8Ez7+SEOauXq6r3XidNNJxP28dFzL?= =?utf-8?q?/fvQpLL9qw2Smv98w6/cX0iSHbld7amlRXG413qHtgEcvmG0er7axCmcXc4C7D2p2?= =?utf-8?q?TnnwNYD8Q0N?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR04MB9687.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?x3yqUASOOafAQWX3pUCj6cqu/S+q?= =?utf-8?q?LUmiIJIVR27wf3ePqgVwJvonysnwvwc7v6N25TdYv98IL/rHtW+JYqHGBZ5wRd828?= =?utf-8?q?IpWktBZn33H9tzbyUprqkVz46aCBWrAhoZ0J/G+5V8sRZJkj8I4rreo/ph+BoyDCq?= =?utf-8?q?z7k5vjnF5QFMFeVmzpfrj7IycnMmeCSfX/cJHGMl2dF/tPulQhqXnynWCS5fxAzZM?= =?utf-8?q?bRP2RI1qW2TLAl/lGIVmvykHYJusZwgfkWIJRHu//L7DbTb4C7KQ514hpRHfZsSm2?= =?utf-8?q?lApiTrQrwAcoyCVbfavUX6/wEJFxbvrKQUffaa6q1mztQ7ZuVMaIeYOkh27mSnLWS?= =?utf-8?q?aNf/79XsCmogGc/2dHTA5ZBf62S7+R7yj6M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da6eie1zMufzjGwMq?= =?utf-8?q?nSBumq9xmPYqo6O085ZROcs0V7cQHj2Qm1lKM6nyq02DRTJYH6aqlhoh7aVScqsFk?= =?utf-8?q?0nt+PXYH48qdgefW5R98ZyOIdG6NjVnpe7S2h4sWWosEDjPNK7+YBfK06gDVSuvKe?= =?utf-8?q?awGlwZDmSosJR5nc6n1GvTZrUhq5nY/W2saZJa6CraMKZ5eETabUR89yqbRyOFfMx?= =?utf-8?q?E9i9BZn/J1WAySFgOTyBD8EFlznddaVD9s7xL3IkZ7asqz78lca/2GMn4cI+r6ugh?= =?utf-8?q?0O+Px+7ukhNV/Oh2uKD+rxNjOscveV1wFw=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a1fae63-1319-42dd-e27c-08dd34a641af X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9687.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2025 14:18:02.9500 (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: fY/nNWHD7er+Ay9+oxiisBUH9CRSxJMxFNv4a5bsf2+fB8n4oKRWvolyRzO19yLYa8wp2vvsXAycWLNUGuCwwgsBCJqUWzNPHS1Rjv+wPzE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6812 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;