Message ID | 20231228092014.23184-1-peter.tsao@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-12530-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1887726dyb; Thu, 28 Dec 2023 01:21:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVs65iLxuJX0/GCBlg32MjPMoMHCekabqRfM0XFQE+8qGbhv9Wz/0ZZxmUAiSaaa5uiAzY X-Received: by 2002:a05:620a:2a10:b0:781:7916:416e with SMTP id o16-20020a05620a2a1000b007817916416emr368004qkp.57.1703755281690; Thu, 28 Dec 2023 01:21:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703755281; cv=none; d=google.com; s=arc-20160816; b=nPpU6VgpULn5h09bt6B1AmfVOhFfvYttu07WVxkYAuxWizU4F9Xr2EZQ2EqwWcSJH7 0OSBacGdGVJfC1k/9lRwgxSnhFw8Q9r84IjwG/zu2iI/eU6412SqPD+UtbK7qO2RuITR yLct3DhlGzVvV4LG4lwYQbceb51uZ+E87AqVTr/s3IAjte/wCCDa2/zWCH19lmk4gu65 rOwIG8b4KLmbVaNoXj77qNe9jnULO4anNuu7zhrX41Oe+DA6G923UwUP4hBqhf0PSDfR qqbzRfEyYjReRLmevdNskm7jMQ8wSqVQjzO4N6tDNFlLrFKnoIok83IaoraF6rY8JPPq KP7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature; bh=j3gssqpamwVPINxlyQtLb57s1xKFMi9YNYYa36A9GTc=; fh=TvbcpTo3kxlLI+DhnobLka+5sLXvhFQ2s1C+6uxOBzA=; b=RrOfJeqQnw78fD7Va5H1YP1RgHZ97ykKzyyUNghlA/9G7vJHOhRZT9V8LPx2Ec7bAy 3ymlDVOkU/1T4b1ejwbD9J1atdkpJYan8qMkC7+dMwqUw5r6sQT/j/yA538k+GWzh+ho JFPp3g1p3MEpIP6S1yCVizWR/zERHKBLa8FM0k+aCBZS7gadCYxOrTwVDYXSuzwDBjLN JBCio672icdGnUkq+8kRaQWf3mDjGNnp6TpMoXGuv1l80a6r7kvdj3ZbMDdGHfzQtVjl X+Y+MOJdTeby9KuaH3WBWMvqYMnlVkALzcJaxMz3pRU1oS9mRTyNhzalobFYdYJ25W51 pNtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=HRFKcLfp; spf=pass (google.com: domain of linux-kernel+bounces-12530-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12530-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i7-20020a05620a404700b007816487ec74si2542731qko.385.2023.12.28.01.21.21 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 01:21:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12530-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=HRFKcLfp; spf=pass (google.com: domain of linux-kernel+bounces-12530-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12530-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7A8321C21C6A for <ouuuleilei@gmail.com>; Thu, 28 Dec 2023 09:21:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13D506ABC; Thu, 28 Dec 2023 09:21:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="HRFKcLfp" X-Original-To: linux-kernel@vger.kernel.org Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (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 E30CA63A8; Thu, 28 Dec 2023 09:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: 6569d70ca56211eea2298b7352fd921d-20231228 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=j3gssqpamwVPINxlyQtLb57s1xKFMi9YNYYa36A9GTc=; b=HRFKcLfpYpbEOnq6iJ5vg00qcFDCOt8Kt2Cg4f7fcZgEFqdPp22CBXwnfO7sSdE/WS/yqyBhd8DWpDTOwLSHiXBxax0CkpMYTz1D9a4+fICcMAsRnN8u6IrSNDWPC69EWmzWAR47+6ABxR1CsydQ2bUz1jWxjgJN3gygHxo4sRI=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:006e0797-2d99-40df-a4da-1c69c029b265,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:5d391d7,CLOUDID:b4b64282-8d4f-477b-89d2-1e3bdbef96d1,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 6569d70ca56211eea2298b7352fd921d-20231228 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw02.mediatek.com (envelope-from <peter.tsao@mediatek.com>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2133886294; Thu, 28 Dec 2023 17:20:52 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 28 Dec 2023 17:20:51 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 28 Dec 2023 17:20:51 +0800 From: Peter Tsao <peter.tsao@mediatek.com> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, Luiz Von Dentz <luiz.dentz@gmail.com> CC: Sean Wang <sean.wang@mediatek.com>, Deren Wu <deren.Wu@mediatek.com>, Chris Lu <chris.lu@mediatek.com>, Aaron Hou <aaron.hou@mediatek.com>, Steve Lee <steve.lee@mediatek.com>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, linux-kernel <linux-kernel@vger.kernel.org>, linux-mediatek <linux-mediatek@lists.infradead.org>, Peter Tsao <peter.tsao@mediatek.com> Subject: [PATCH] Bluetooth: btusb: Fix MT7925 fail to send download patch command Date: Thu, 28 Dec 2023 17:20:14 +0800 Message-ID: <20231228092014.23184-1-peter.tsao@mediatek.com> X-Mailer: git-send-email 2.18.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786516898406102944 X-GMAIL-MSGID: 1786516898406102944 |
Series |
Bluetooth: btusb: Fix MT7925 fail to send download patch command
|
|
Commit Message
Peter Tsao
Dec. 28, 2023, 9:20 a.m. UTC
Write the register 0x18011100[1] = 1 to avoid the device enter sleep
state during download patch flow on specific platform.
Error log:
Bluetooth: hci0: Execution of wmt command timed out
Bluetooth: hci0: Failed to send wmt patch dwnld (-110)
Bluetooth: hci0: Failed to set up firmware (-110)
Signed-off-by: Peter Tsao <peter.tsao@mediatek.com>
---
drivers/bluetooth/btmtk.h | 3 +++
drivers/bluetooth/btusb.c | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
Comments
Hi Peter, kernel test robot noticed the following build errors: [auto build test ERROR on bluetooth/master] [also build test ERROR on bluetooth-next/master linus/master v6.7-rc7 next-20231222] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Peter-Tsao/Bluetooth-btusb-Fix-MT7925-fail-to-send-download-patch-command/20231228-172328 base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master patch link: https://lore.kernel.org/r/20231228092014.23184-1-peter.tsao%40mediatek.com patch subject: [PATCH] Bluetooth: btusb: Fix MT7925 fail to send download patch command config: i386-buildonly-randconfig-002-20231229 (https://download.01.org/0day-ci/archive/20231229/202312290838.c0zcBoUz-lkp@intel.com/config) compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231229/202312290838.c0zcBoUz-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202312290838.c0zcBoUz-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/bluetooth/btusb.c:3122:49: error: use of undeclared identifier 'val' 3122 | btusb_mtk_uhw_reg_read(data, MT7925_SLPPROT, &val); | ^ drivers/bluetooth/btusb.c:3123:3: error: use of undeclared identifier 'val' 3123 | val |= SLPPROT_BYPASS; | ^ drivers/bluetooth/btusb.c:3124:49: error: use of undeclared identifier 'val' 3124 | btusb_mtk_uhw_reg_write(data, MT7925_SLPPROT, val); | ^ 3 errors generated. vim +/val +3122 drivers/bluetooth/btusb.c 3068 3069 static int btusb_mtk_setup(struct hci_dev *hdev) 3070 { 3071 struct btusb_data *data = hci_get_drvdata(hdev); 3072 struct btmtk_hci_wmt_params wmt_params; 3073 ktime_t calltime, delta, rettime; 3074 struct btmtk_tci_sleep tci_sleep; 3075 unsigned long long duration; 3076 struct sk_buff *skb; 3077 const char *fwname; 3078 int err, status; 3079 u32 dev_id = 0; 3080 char fw_bin_name[64]; 3081 u32 fw_version = 0; 3082 u8 param; 3083 struct btmediatek_data *mediatek; 3084 3085 calltime = ktime_get(); 3086 3087 err = btusb_mtk_id_get(data, 0x80000008, &dev_id); 3088 if (err < 0) { 3089 bt_dev_err(hdev, "Failed to get device id (%d)", err); 3090 return err; 3091 } 3092 3093 if (!dev_id || dev_id != 0x7663) { 3094 err = btusb_mtk_id_get(data, 0x70010200, &dev_id); 3095 if (err < 0) { 3096 bt_dev_err(hdev, "Failed to get device id (%d)", err); 3097 return err; 3098 } 3099 err = btusb_mtk_id_get(data, 0x80021004, &fw_version); 3100 if (err < 0) { 3101 bt_dev_err(hdev, "Failed to get fw version (%d)", err); 3102 return err; 3103 } 3104 } 3105 3106 mediatek = hci_get_priv(hdev); 3107 mediatek->dev_id = dev_id; 3108 mediatek->reset_sync = btusb_mtk_reset; 3109 3110 err = btmtk_register_coredump(hdev, btusb_driver.name, fw_version); 3111 if (err < 0) 3112 bt_dev_err(hdev, "Failed to register coredump (%d)", err); 3113 3114 switch (dev_id) { 3115 case 0x7663: 3116 fwname = FIRMWARE_MT7663; 3117 break; 3118 case 0x7668: 3119 fwname = FIRMWARE_MT7668; 3120 break; 3121 case 0x7925: > 3122 btusb_mtk_uhw_reg_read(data, MT7925_SLPPROT, &val); 3123 val |= SLPPROT_BYPASS; 3124 btusb_mtk_uhw_reg_write(data, MT7925_SLPPROT, val); 3125 fallthrough; 3126 case 0x7922: 3127 case 0x7961: 3128 if (dev_id == 0x7925) 3129 snprintf(fw_bin_name, sizeof(fw_bin_name), 3130 "mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin", 3131 dev_id & 0xffff, dev_id & 0xffff, (fw_version & 0xff) + 1); 3132 else 3133 snprintf(fw_bin_name, sizeof(fw_bin_name), 3134 "mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin", 3135 dev_id & 0xffff, (fw_version & 0xff) + 1); 3136 3137 err = btmtk_setup_firmware_79xx(hdev, fw_bin_name, 3138 btusb_mtk_hci_wmt_sync); 3139 if (err < 0) { 3140 bt_dev_err(hdev, "Failed to set up firmware (%d)", err); 3141 return err; 3142 } 3143 3144 /* It's Device EndPoint Reset Option Register */ 3145 btusb_mtk_uhw_reg_write(data, MTK_EP_RST_OPT, MTK_EP_RST_IN_OUT_OPT); 3146 3147 /* Enable Bluetooth protocol */ 3148 param = 1; 3149 wmt_params.op = BTMTK_WMT_FUNC_CTRL; 3150 wmt_params.flag = 0; 3151 wmt_params.dlen = sizeof(param); 3152 wmt_params.data = ¶m; 3153 wmt_params.status = NULL; 3154 3155 err = btusb_mtk_hci_wmt_sync(hdev, &wmt_params); 3156 if (err < 0) { 3157 bt_dev_err(hdev, "Failed to send wmt func ctrl (%d)", err); 3158 return err; 3159 } 3160 3161 hci_set_msft_opcode(hdev, 0xFD30); 3162 hci_set_aosp_capable(hdev); 3163 goto done; 3164 default: 3165 bt_dev_err(hdev, "Unsupported hardware variant (%08x)", 3166 dev_id); 3167 return -ENODEV; 3168 } 3169 3170 /* Query whether the firmware is already download */ 3171 wmt_params.op = BTMTK_WMT_SEMAPHORE; 3172 wmt_params.flag = 1; 3173 wmt_params.dlen = 0; 3174 wmt_params.data = NULL; 3175 wmt_params.status = &status; 3176 3177 err = btusb_mtk_hci_wmt_sync(hdev, &wmt_params); 3178 if (err < 0) { 3179 bt_dev_err(hdev, "Failed to query firmware status (%d)", err); 3180 return err; 3181 } 3182 3183 if (status == BTMTK_WMT_PATCH_DONE) { 3184 bt_dev_info(hdev, "firmware already downloaded"); 3185 goto ignore_setup_fw; 3186 } 3187 3188 /* Setup a firmware which the device definitely requires */ 3189 err = btmtk_setup_firmware(hdev, fwname, 3190 btusb_mtk_hci_wmt_sync); 3191 if (err < 0) 3192 return err; 3193 3194 ignore_setup_fw: 3195 err = readx_poll_timeout(btusb_mtk_func_query, hdev, status, 3196 status < 0 || status != BTMTK_WMT_ON_PROGRESS, 3197 2000, 5000000); 3198 /* -ETIMEDOUT happens */ 3199 if (err < 0) 3200 return err; 3201 3202 /* The other errors happen in btusb_mtk_func_query */ 3203 if (status < 0) 3204 return status; 3205 3206 if (status == BTMTK_WMT_ON_DONE) { 3207 bt_dev_info(hdev, "function already on"); 3208 goto ignore_func_on; 3209 } 3210 3211 /* Enable Bluetooth protocol */ 3212 param = 1; 3213 wmt_params.op = BTMTK_WMT_FUNC_CTRL; 3214 wmt_params.flag = 0; 3215 wmt_params.dlen = sizeof(param); 3216 wmt_params.data = ¶m; 3217 wmt_params.status = NULL; 3218 3219 err = btusb_mtk_hci_wmt_sync(hdev, &wmt_params); 3220 if (err < 0) { 3221 bt_dev_err(hdev, "Failed to send wmt func ctrl (%d)", err); 3222 return err; 3223 } 3224 3225 ignore_func_on: 3226 /* Apply the low power environment setup */ 3227 tci_sleep.mode = 0x5; 3228 tci_sleep.duration = cpu_to_le16(0x640); 3229 tci_sleep.host_duration = cpu_to_le16(0x640); 3230 tci_sleep.host_wakeup_pin = 0; 3231 tci_sleep.time_compensation = 0; 3232 3233 skb = __hci_cmd_sync(hdev, 0xfc7a, sizeof(tci_sleep), &tci_sleep, 3234 HCI_INIT_TIMEOUT); 3235 if (IS_ERR(skb)) { 3236 err = PTR_ERR(skb); 3237 bt_dev_err(hdev, "Failed to apply low power setting (%d)", err); 3238 return err; 3239 } 3240 kfree_skb(skb); 3241 3242 done: 3243 rettime = ktime_get(); 3244 delta = ktime_sub(rettime, calltime); 3245 duration = (unsigned long long)ktime_to_ns(delta) >> 10; 3246 3247 bt_dev_info(hdev, "Device setup in %llu usecs", duration); 3248 3249 return 0; 3250 } 3251
Hi Peter, kernel test robot noticed the following build errors: [auto build test ERROR on bluetooth/master] [also build test ERROR on bluetooth-next/master linus/master v6.7-rc7 next-20231222] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Peter-Tsao/Bluetooth-btusb-Fix-MT7925-fail-to-send-download-patch-command/20231228-172328 base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master patch link: https://lore.kernel.org/r/20231228092014.23184-1-peter.tsao%40mediatek.com patch subject: [PATCH] Bluetooth: btusb: Fix MT7925 fail to send download patch command config: arm64-defconfig (https://download.01.org/0day-ci/archive/20231229/202312291253.5LoPimum-lkp@intel.com/config) compiler: aarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231229/202312291253.5LoPimum-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202312291253.5LoPimum-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/bluetooth/btusb.c: In function 'btusb_mtk_setup': >> drivers/bluetooth/btusb.c:3122:63: error: 'val' undeclared (first use in this function) 3122 | btusb_mtk_uhw_reg_read(data, MT7925_SLPPROT, &val); | ^~~ drivers/bluetooth/btusb.c:3122:63: note: each undeclared identifier is reported only once for each function it appears in vim +/val +3122 drivers/bluetooth/btusb.c 3068 3069 static int btusb_mtk_setup(struct hci_dev *hdev) 3070 { 3071 struct btusb_data *data = hci_get_drvdata(hdev); 3072 struct btmtk_hci_wmt_params wmt_params; 3073 ktime_t calltime, delta, rettime; 3074 struct btmtk_tci_sleep tci_sleep; 3075 unsigned long long duration; 3076 struct sk_buff *skb; 3077 const char *fwname; 3078 int err, status; 3079 u32 dev_id = 0; 3080 char fw_bin_name[64]; 3081 u32 fw_version = 0; 3082 u8 param; 3083 struct btmediatek_data *mediatek; 3084 3085 calltime = ktime_get(); 3086 3087 err = btusb_mtk_id_get(data, 0x80000008, &dev_id); 3088 if (err < 0) { 3089 bt_dev_err(hdev, "Failed to get device id (%d)", err); 3090 return err; 3091 } 3092 3093 if (!dev_id || dev_id != 0x7663) { 3094 err = btusb_mtk_id_get(data, 0x70010200, &dev_id); 3095 if (err < 0) { 3096 bt_dev_err(hdev, "Failed to get device id (%d)", err); 3097 return err; 3098 } 3099 err = btusb_mtk_id_get(data, 0x80021004, &fw_version); 3100 if (err < 0) { 3101 bt_dev_err(hdev, "Failed to get fw version (%d)", err); 3102 return err; 3103 } 3104 } 3105 3106 mediatek = hci_get_priv(hdev); 3107 mediatek->dev_id = dev_id; 3108 mediatek->reset_sync = btusb_mtk_reset; 3109 3110 err = btmtk_register_coredump(hdev, btusb_driver.name, fw_version); 3111 if (err < 0) 3112 bt_dev_err(hdev, "Failed to register coredump (%d)", err); 3113 3114 switch (dev_id) { 3115 case 0x7663: 3116 fwname = FIRMWARE_MT7663; 3117 break; 3118 case 0x7668: 3119 fwname = FIRMWARE_MT7668; 3120 break; 3121 case 0x7925: > 3122 btusb_mtk_uhw_reg_read(data, MT7925_SLPPROT, &val); 3123 val |= SLPPROT_BYPASS; 3124 btusb_mtk_uhw_reg_write(data, MT7925_SLPPROT, val); 3125 fallthrough; 3126 case 0x7922: 3127 case 0x7961: 3128 if (dev_id == 0x7925) 3129 snprintf(fw_bin_name, sizeof(fw_bin_name), 3130 "mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin", 3131 dev_id & 0xffff, dev_id & 0xffff, (fw_version & 0xff) + 1); 3132 else 3133 snprintf(fw_bin_name, sizeof(fw_bin_name), 3134 "mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin", 3135 dev_id & 0xffff, (fw_version & 0xff) + 1); 3136 3137 err = btmtk_setup_firmware_79xx(hdev, fw_bin_name, 3138 btusb_mtk_hci_wmt_sync); 3139 if (err < 0) { 3140 bt_dev_err(hdev, "Failed to set up firmware (%d)", err); 3141 return err; 3142 } 3143 3144 /* It's Device EndPoint Reset Option Register */ 3145 btusb_mtk_uhw_reg_write(data, MTK_EP_RST_OPT, MTK_EP_RST_IN_OUT_OPT); 3146 3147 /* Enable Bluetooth protocol */ 3148 param = 1; 3149 wmt_params.op = BTMTK_WMT_FUNC_CTRL; 3150 wmt_params.flag = 0; 3151 wmt_params.dlen = sizeof(param); 3152 wmt_params.data = ¶m; 3153 wmt_params.status = NULL; 3154 3155 err = btusb_mtk_hci_wmt_sync(hdev, &wmt_params); 3156 if (err < 0) { 3157 bt_dev_err(hdev, "Failed to send wmt func ctrl (%d)", err); 3158 return err; 3159 } 3160 3161 hci_set_msft_opcode(hdev, 0xFD30); 3162 hci_set_aosp_capable(hdev); 3163 goto done; 3164 default: 3165 bt_dev_err(hdev, "Unsupported hardware variant (%08x)", 3166 dev_id); 3167 return -ENODEV; 3168 } 3169 3170 /* Query whether the firmware is already download */ 3171 wmt_params.op = BTMTK_WMT_SEMAPHORE; 3172 wmt_params.flag = 1; 3173 wmt_params.dlen = 0; 3174 wmt_params.data = NULL; 3175 wmt_params.status = &status; 3176 3177 err = btusb_mtk_hci_wmt_sync(hdev, &wmt_params); 3178 if (err < 0) { 3179 bt_dev_err(hdev, "Failed to query firmware status (%d)", err); 3180 return err; 3181 } 3182 3183 if (status == BTMTK_WMT_PATCH_DONE) { 3184 bt_dev_info(hdev, "firmware already downloaded"); 3185 goto ignore_setup_fw; 3186 } 3187 3188 /* Setup a firmware which the device definitely requires */ 3189 err = btmtk_setup_firmware(hdev, fwname, 3190 btusb_mtk_hci_wmt_sync); 3191 if (err < 0) 3192 return err; 3193 3194 ignore_setup_fw: 3195 err = readx_poll_timeout(btusb_mtk_func_query, hdev, status, 3196 status < 0 || status != BTMTK_WMT_ON_PROGRESS, 3197 2000, 5000000); 3198 /* -ETIMEDOUT happens */ 3199 if (err < 0) 3200 return err; 3201 3202 /* The other errors happen in btusb_mtk_func_query */ 3203 if (status < 0) 3204 return status; 3205 3206 if (status == BTMTK_WMT_ON_DONE) { 3207 bt_dev_info(hdev, "function already on"); 3208 goto ignore_func_on; 3209 } 3210 3211 /* Enable Bluetooth protocol */ 3212 param = 1; 3213 wmt_params.op = BTMTK_WMT_FUNC_CTRL; 3214 wmt_params.flag = 0; 3215 wmt_params.dlen = sizeof(param); 3216 wmt_params.data = ¶m; 3217 wmt_params.status = NULL; 3218 3219 err = btusb_mtk_hci_wmt_sync(hdev, &wmt_params); 3220 if (err < 0) { 3221 bt_dev_err(hdev, "Failed to send wmt func ctrl (%d)", err); 3222 return err; 3223 } 3224 3225 ignore_func_on: 3226 /* Apply the low power environment setup */ 3227 tci_sleep.mode = 0x5; 3228 tci_sleep.duration = cpu_to_le16(0x640); 3229 tci_sleep.host_duration = cpu_to_le16(0x640); 3230 tci_sleep.host_wakeup_pin = 0; 3231 tci_sleep.time_compensation = 0; 3232 3233 skb = __hci_cmd_sync(hdev, 0xfc7a, sizeof(tci_sleep), &tci_sleep, 3234 HCI_INIT_TIMEOUT); 3235 if (IS_ERR(skb)) { 3236 err = PTR_ERR(skb); 3237 bt_dev_err(hdev, "Failed to apply low power setting (%d)", err); 3238 return err; 3239 } 3240 kfree_skb(skb); 3241 3242 done: 3243 rettime = ktime_get(); 3244 delta = ktime_sub(rettime, calltime); 3245 duration = (unsigned long long)ktime_to_ns(delta) >> 10; 3246 3247 bt_dev_info(hdev, "Device setup in %llu usecs", duration); 3248 3249 return 0; 3250 } 3251
diff --git a/drivers/bluetooth/btmtk.h b/drivers/bluetooth/btmtk.h index 56f5502baadf..8b582077a01f 100644 --- a/drivers/bluetooth/btmtk.h +++ b/drivers/bluetooth/btmtk.h @@ -22,6 +22,9 @@ #define MT7921_DLSTATUS 0x7c053c10 #define BT_DL_STATE BIT(1) +#define MT7925_SLPPROT 0x18011100 +#define SLPPROT_BYPASS BIT(1) + #define MTK_COREDUMP_SIZE (1024 * 1000) #define MTK_COREDUMP_END "coredump end" #define MTK_COREDUMP_END_LEN (sizeof(MTK_COREDUMP_END)) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 7835170b1d66..842fda0527db 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -3120,9 +3120,13 @@ static int btusb_mtk_setup(struct hci_dev *hdev) case 0x7668: fwname = FIRMWARE_MT7668; break; + case 0x7925: + btusb_mtk_uhw_reg_read(data, MT7925_SLPPROT, &val); + val |= SLPPROT_BYPASS; + btusb_mtk_uhw_reg_write(data, MT7925_SLPPROT, val); + fallthrough; case 0x7922: case 0x7961: - case 0x7925: if (dev_id == 0x7925) snprintf(fw_bin_name, sizeof(fw_bin_name), "mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",