linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v7 0/1] Bluetooth: mediatek: add gpio pin to reset bt
@ 2025-09-05  8:40 Zhangchao Zhang
  2025-09-05  8:40 ` [PATCH v7 1/1] " Zhangchao Zhang
  0 siblings, 1 reply; 7+ messages in thread
From: Zhangchao Zhang @ 2025-09-05  8:40 UTC (permalink / raw)
  To: Marcel Holtmann, Matthias Brugger, Krzysztof Kozlowski,
	Luiz Von Dentz, AngeloGioacchino Del Regno
  Cc: Sean Wang, Jiande Lu, Deren Wu, Chris Lu, Hao Qin,
	linux-bluetooth, linux-kernel, linux-arm-kernel, linux-mediatek,
	Zhangchao Zhang

Reset Bluetooth using hardware pin via dts

Compared with the previously submitted version, the following
information are some specific revision histories


V6-->V7 modifications:
-Change the gpio_direction_output interface to the gpiod_set_value_cansleep
   and gpiod_put interface.
-Remove the schedule_delayed_work asynchronous operation.
-Delete the #gpio-cell attribute in the yaml file, remove the #gpio-cell
   in the required field, and simplify the contents of the descriptions.

V5-->V6 modifications:
-Add specific revisions in the changes from v4 to v5.
-Add hardware pin title and descriptions to dt-binding submission
   information.
-Modify the title descriptions in the dt-binding file.
-Add 7925 what is it.
-Wrap the descriptions of MT7925 chip uses the USB bus appropriately.
-Change the compatible string to mediatek,mt7925-bluetooth in
   the dt-binding file and driver code.
-Drop gpio-controlelr properties in the dt-binding file.
-Modify the descriptions of the reset-gpios
   properties in the dt-binding file.
-Change the node information of reset-gpios in bluetooth
   from high level valid to low level valid.

V4-->V5 modifications:
-Correct the spelling error of word provides mentioned in V1.
-Drop the xhci0 node and status property in the dt-binding file.
-Modify the bt_reset tag node to bluetooth in the dt-binding file.
-Add #gpio-cell descriptions to properties, nodes and requests.
-Make a separate patch for the changes to dt-binding.

V3-->V4 modifications:
-Modify submission information why use hardware pin to reset Bluetooth.
-Write historical commit information into the cover letter.
-Modify dt binding format information and
   the explanation text in the dt-binding file.

V2-->V3 modifications:
-Changed the capitalization of co-developer names,
   using the correct capitalization of abbreviations and full
   name, and corrected obvious spelling errors.
-Add a revision history.
-Remove the "BT Driver" in the prefix.
-Add the bt-binding document, include inforamtion related to reset
   pin and compatibility matching.
-Add a comment before the schedule_delayed_work function call,
   although schedule_delayed_work is asynchronous, there is no risk.
   Even if it is not completed within 200ms, it will only postpone
   the subsequent probe and will not have any impact.
-Add a comment before the btmtk_reset_by_gpio function call,
   if the compatibility filed or pin cannot be found in the dts
   files, it can still reset bluetooth using software reset.

V2 modifications:
-Modify gpio to GPIO, SW to software,
   and fix other obvious spelling errors.

-- 
2.45.2



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v7 1/1] Bluetooth: mediatek: add gpio pin to reset bt
  2025-09-05  8:40 [PATCH v7 0/1] Bluetooth: mediatek: add gpio pin to reset bt Zhangchao Zhang
@ 2025-09-05  8:40 ` Zhangchao Zhang
  2025-09-05  8:43   ` Krzysztof Kozlowski
  2025-09-06 11:04   ` kernel test robot
  0 siblings, 2 replies; 7+ messages in thread
From: Zhangchao Zhang @ 2025-09-05  8:40 UTC (permalink / raw)
  To: Marcel Holtmann, Matthias Brugger, Krzysztof Kozlowski,
	Luiz Von Dentz, AngeloGioacchino Del Regno
  Cc: Sean Wang, Jiande Lu, Deren Wu, Chris Lu, Hao Qin,
	linux-bluetooth, linux-kernel, linux-arm-kernel, linux-mediatek,
	Zhangchao Zhang

Makes the platform Bluetooth to be reset by hardware pin,
it provides two methods to do it for mediatek controller,
and it has been tested locally many times and can reset normally.

When an exception occurs, resetting Bluetooth by hardware pin
is more stable than resetting Bluetooth by software.
If the corresponding pin is not found in dts,
bluetooth can also be reset successfully.

Co-developed: Hao Qin <hao.qin@mediatek.com>
Co-developed: Chris Lu <chris.lu@mediatek.com>
Co-developed: Jiande Lu <jiande.lu@mediatek.com>
Signed-off-by: Zhangchao Zhang <ot_zhangchao.zhang@mediatek.com>
---
 drivers/bluetooth/btmtk.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
index 4390fd571dbd..29d6a93f255d 100644
--- a/drivers/bluetooth/btmtk.c
+++ b/drivers/bluetooth/btmtk.c
@@ -6,6 +6,8 @@
 #include <linux/firmware.h>
 #include <linux/usb.h>
 #include <linux/iopoll.h>
+#include <linux/gpio/consumer.h>
+#include <linux/of.h>
 #include <linux/unaligned.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -359,11 +361,41 @@ int btmtk_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
 }
 EXPORT_SYMBOL_GPL(btmtk_set_bdaddr);
 
+static int btmtk_hw_gpio_reset(struct hci_dev *hdev, struct btmtk_data *reset_work)
+{
+	struct gpio_desc *reset_gpio;
+
+	/* Find device node*/
+	hdev->dev.of_node = of_find_compatible_node(NULL, NULL, "mediatek,mt7925-bluetooth");
+	reset_gpio = gpiod_get_optional(hdev->dev.of_node, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(reset_gpio))
+		return PTR_ERR(reset_gpio);
+
+	if (!reset_gpio)
+		return -ENODEV;
+
+	if (test_and_set_bit(BTMTK_HW_RESET_ACTIVE, &reset_work->flags)) {
+		bt_dev_err(hdev, "last reset failed? Not resetting again");
+		gpiod_put(reset_gpio);
+		return -EBUSY;
+	}
+	gpiod_set_value_cansleep(reset_gpio, 0);
+	msleep(100);
+	gpiod_set_value_cansleep(reset_gpio, 1);
+	gpiod_put(reset_gpio);
+	return 0;
+}
+
 void btmtk_reset_sync(struct hci_dev *hdev)
 {
 	struct btmtk_data *reset_work = hci_get_priv(hdev);
 	int err;
 
+	/* Try hardware GPIO reset*/
+	err = btmtk_hw_gpio_reset(hdev, reset_work);
+	if (!err)
+		return;
+	/* Otherwise, do software reset */
 	hci_dev_lock(hdev);
 
 	err = hci_cmd_sync_queue(hdev, reset_work->reset_sync, NULL, NULL);
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v7 1/1] Bluetooth: mediatek: add gpio pin to reset bt
  2025-09-05  8:40 ` [PATCH v7 1/1] " Zhangchao Zhang
@ 2025-09-05  8:43   ` Krzysztof Kozlowski
  2025-09-10 23:29     ` Sean Wang
  2025-09-06 11:04   ` kernel test robot
  1 sibling, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-09-05  8:43 UTC (permalink / raw)
  To: Zhangchao Zhang, Marcel Holtmann, Matthias Brugger,
	Luiz Von Dentz, AngeloGioacchino Del Regno
  Cc: Sean Wang, Jiande Lu, Deren Wu, Chris Lu, Hao Qin,
	linux-bluetooth, linux-kernel, linux-arm-kernel, linux-mediatek

On 05/09/2025 10:40, Zhangchao Zhang wrote:
> Makes the platform Bluetooth to be reset by hardware pin,
> it provides two methods to do it for mediatek controller,
> and it has been tested locally many times and can reset normally.
> 
> When an exception occurs, resetting Bluetooth by hardware pin
> is more stable than resetting Bluetooth by software.
> If the corresponding pin is not found in dts,
> bluetooth can also be reset successfully.
> 
> Co-developed: Hao Qin <hao.qin@mediatek.com>
> Co-developed: Chris Lu <chris.lu@mediatek.com>
> Co-developed: Jiande Lu <jiande.lu@mediatek.com>
> Signed-off-by: Zhangchao Zhang <ot_zhangchao.zhang@mediatek.com>
> ---
>  drivers/bluetooth/btmtk.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
> index 4390fd571dbd..29d6a93f255d 100644
> --- a/drivers/bluetooth/btmtk.c
> +++ b/drivers/bluetooth/btmtk.c
> @@ -6,6 +6,8 @@
>  #include <linux/firmware.h>
>  #include <linux/usb.h>
>  #include <linux/iopoll.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/of.h>
>  #include <linux/unaligned.h>
>  
>  #include <net/bluetooth/bluetooth.h>
> @@ -359,11 +361,41 @@ int btmtk_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
>  }
>  EXPORT_SYMBOL_GPL(btmtk_set_bdaddr);
>  
> +static int btmtk_hw_gpio_reset(struct hci_dev *hdev, struct btmtk_data *reset_work)
> +{
> +	struct gpio_desc *reset_gpio;
> +
> +	/* Find device node*/
> +	hdev->dev.of_node = of_find_compatible_node(NULL, NULL, "mediatek,mt7925-bluetooth");

Nothing improved.

You just keep ignoring comments.

NAK

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v7 1/1] Bluetooth: mediatek: add gpio pin to reset bt
  2025-09-05  8:40 ` [PATCH v7 1/1] " Zhangchao Zhang
  2025-09-05  8:43   ` Krzysztof Kozlowski
@ 2025-09-06 11:04   ` kernel test robot
  1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2025-09-06 11:04 UTC (permalink / raw)
  To: Zhangchao Zhang, Marcel Holtmann, Matthias Brugger,
	Krzysztof Kozlowski, Luiz Von Dentz, AngeloGioacchino Del Regno
  Cc: llvm, oe-kbuild-all, Sean Wang, Jiande Lu, Deren Wu, Chris Lu,
	Hao Qin, linux-bluetooth, linux-kernel, linux-arm-kernel,
	linux-mediatek, Zhangchao Zhang

Hi Zhangchao,

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.17-rc4 next-20250905]
[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/Zhangchao-Zhang/Bluetooth-mediatek-add-gpio-pin-to-reset-bt/20250905-164341
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
patch link:    https://lore.kernel.org/r/20250905084059.26959-2-ot_zhangchao.zhang%40mediatek.com
patch subject: [PATCH v7 1/1] Bluetooth: mediatek: add gpio pin to reset bt
config: x86_64-buildonly-randconfig-001-20250906 (https://download.01.org/0day-ci/archive/20250906/202509061837.tyzBvcs9-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250906/202509061837.tyzBvcs9-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/202509061837.tyzBvcs9-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/bluetooth/btmtk.c:370:34: error: incompatible pointer types passing 'struct device_node *' to parameter of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
     370 |         reset_gpio = gpiod_get_optional(hdev->dev.of_node, "reset", GPIOD_OUT_HIGH);
         |                                         ^~~~~~~~~~~~~~~~~
   include/linux/gpio/consumer.h:72:66: note: passing argument to parameter 'dev' here
      72 | struct gpio_desc *__must_check gpiod_get_optional(struct device *dev,
         |                                                                  ^
   1 error generated.


vim +370 drivers/bluetooth/btmtk.c

   363	
   364	static int btmtk_hw_gpio_reset(struct hci_dev *hdev, struct btmtk_data *reset_work)
   365	{
   366		struct gpio_desc *reset_gpio;
   367	
   368		/* Find device node*/
   369		hdev->dev.of_node = of_find_compatible_node(NULL, NULL, "mediatek,mt7925-bluetooth");
 > 370		reset_gpio = gpiod_get_optional(hdev->dev.of_node, "reset", GPIOD_OUT_HIGH);
   371		if (IS_ERR(reset_gpio))
   372			return PTR_ERR(reset_gpio);
   373	
   374		if (!reset_gpio)
   375			return -ENODEV;
   376	
   377		if (test_and_set_bit(BTMTK_HW_RESET_ACTIVE, &reset_work->flags)) {
   378			bt_dev_err(hdev, "last reset failed? Not resetting again");
   379			gpiod_put(reset_gpio);
   380			return -EBUSY;
   381		}
   382		gpiod_set_value_cansleep(reset_gpio, 0);
   383		msleep(100);
   384		gpiod_set_value_cansleep(reset_gpio, 1);
   385		gpiod_put(reset_gpio);
   386		return 0;
   387	}
   388	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v7 1/1] Bluetooth: mediatek: add gpio pin to reset bt
  2025-09-05  8:43   ` Krzysztof Kozlowski
@ 2025-09-10 23:29     ` Sean Wang
  2025-09-11  6:07       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 7+ messages in thread
From: Sean Wang @ 2025-09-10 23:29 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Zhangchao Zhang
  Cc: Marcel Holtmann, Matthias Brugger, Luiz Von Dentz,
	AngeloGioacchino Del Regno, Sean Wang, Jiande Lu, Deren Wu,
	Chris Lu, Hao Qin, linux-bluetooth, linux-kernel,
	linux-arm-kernel, linux-mediatek

Hi Krzysztof,

Sorry again for the confusion. I believe Zhangchao is still new to the
upstream process, and we’ll work together to improve this. Since this
series has become a bit hard to follow, would you agree that it might
be better for us to restart with a clean patch that addresses the
review comments? A clean version would make it easier for reviewers to
focus on the current issues without being distracted by earlier
mistakes.

Hi Zhangchao,

Please note that both btusb.c (with DT and ACPI) and btmtksdio.c (with
DT) already support reset_gpio. Our goal should be to benefit from
these existing mechanisms while ensuring that this patch does not
introduce any regressions. If the current mechanisms do not fully meet
your requirements, it’s important to clearly explain why, so we can
adapt the existing framework rather than creating a separate one.

And please remember to carefully respect and respond to reviewer
feedback, reviewers volunteer their time and experience to help us
keep the subsystem clean and consistent. It’s a valuable opportunity
for us to learn and to ensure smoother integration.

                          Sean

On Fri, Sep 5, 2025 at 3:44 AM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On 05/09/2025 10:40, Zhangchao Zhang wrote:
> > Makes the platform Bluetooth to be reset by hardware pin,
> > it provides two methods to do it for mediatek controller,
> > and it has been tested locally many times and can reset normally.
> >
> > When an exception occurs, resetting Bluetooth by hardware pin
> > is more stable than resetting Bluetooth by software.
> > If the corresponding pin is not found in dts,
> > bluetooth can also be reset successfully.
> >
> > Co-developed: Hao Qin <hao.qin@mediatek.com>
> > Co-developed: Chris Lu <chris.lu@mediatek.com>
> > Co-developed: Jiande Lu <jiande.lu@mediatek.com>
> > Signed-off-by: Zhangchao Zhang <ot_zhangchao.zhang@mediatek.com>
> > ---
> >  drivers/bluetooth/btmtk.c | 32 ++++++++++++++++++++++++++++++++
> >  1 file changed, 32 insertions(+)
> >
> > diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
> > index 4390fd571dbd..29d6a93f255d 100644
> > --- a/drivers/bluetooth/btmtk.c
> > +++ b/drivers/bluetooth/btmtk.c
> > @@ -6,6 +6,8 @@
> >  #include <linux/firmware.h>
> >  #include <linux/usb.h>
> >  #include <linux/iopoll.h>
> > +#include <linux/gpio/consumer.h>
> > +#include <linux/of.h>
> >  #include <linux/unaligned.h>
> >
> >  #include <net/bluetooth/bluetooth.h>
> > @@ -359,11 +361,41 @@ int btmtk_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
> >  }
> >  EXPORT_SYMBOL_GPL(btmtk_set_bdaddr);
> >
> > +static int btmtk_hw_gpio_reset(struct hci_dev *hdev, struct btmtk_data *reset_work)
> > +{
> > +     struct gpio_desc *reset_gpio;
> > +
> > +     /* Find device node*/
> > +     hdev->dev.of_node = of_find_compatible_node(NULL, NULL, "mediatek,mt7925-bluetooth");
>
> Nothing improved.
>
> You just keep ignoring comments.
>
> NAK
>
> Best regards,
> Krzysztof
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v7 1/1] Bluetooth: mediatek: add gpio pin to reset bt
  2025-09-10 23:29     ` Sean Wang
@ 2025-09-11  6:07       ` Krzysztof Kozlowski
  2025-09-12  0:10         ` Sean Wang
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-09-11  6:07 UTC (permalink / raw)
  To: Sean Wang, Zhangchao Zhang
  Cc: Marcel Holtmann, Matthias Brugger, Luiz Von Dentz,
	AngeloGioacchino Del Regno, Sean Wang, Jiande Lu, Deren Wu,
	Chris Lu, Hao Qin, linux-bluetooth, linux-kernel,
	linux-arm-kernel, linux-mediatek

On 11/09/2025 01:29, Sean Wang wrote:
> Hi Krzysztof,
> 
> Sorry again for the confusion. I believe Zhangchao is still new to the
> upstream process, and we’ll work together to improve this. Since this
> series has become a bit hard to follow, would you agree that it might
> be better for us to restart with a clean patch that addresses the
> review comments? A clean version would make it easier for reviewers to
> focus on the current issues without being distracted by earlier
> mistakes.

No. If you cannot send v7 of patchset as real patchset, sending again v1
won't change anything.

For seven versions contributor did not bother to respond to feedback and
did not care to read submitting patches how this process looks like.

Effect is this totally broken v7.

This patch introduces undocumented ABI which kernel tools, if used, also
point out.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v7 1/1] Bluetooth: mediatek: add gpio pin to reset bt
  2025-09-11  6:07       ` Krzysztof Kozlowski
@ 2025-09-12  0:10         ` Sean Wang
  0 siblings, 0 replies; 7+ messages in thread
From: Sean Wang @ 2025-09-12  0:10 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Zhangchao Zhang, Marcel Holtmann, Matthias Brugger,
	Luiz Von Dentz, AngeloGioacchino Del Regno, Sean Wang, Jiande Lu,
	Deren Wu, Chris Lu, Hao Qin, linux-bluetooth, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Thu, Sep 11, 2025 at 1:07 AM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On 11/09/2025 01:29, Sean Wang wrote:
> > Hi Krzysztof,
> >
> > Sorry again for the confusion. I believe Zhangchao is still new to the
> > upstream process, and we’ll work together to improve this. Since this
> > series has become a bit hard to follow, would you agree that it might
> > be better for us to restart with a clean patch that addresses the
> > review comments? A clean version would make it easier for reviewers to
> > focus on the current issues without being distracted by earlier
> > mistakes.
>
> No. If you cannot send v7 of patchset as real patchset, sending again v1
> won't change anything.
>
> For seven versions contributor did not bother to respond to feedback and
> did not care to read submitting patches how this process looks like.
>
> Effect is this totally broken v7.
>
> This patch introduces undocumented ABI which kernel tools, if used, also
> point out.
>
> Best regards,
> Krzysztof

Hi Krzysztof,

Thanks for the feedback and for spending time reviewing this driver.
We’ll continue with v8 instead of restarting from v1, and hope it will
be improved to meet the requirements.

                          Sean


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-09-12  0:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-05  8:40 [PATCH v7 0/1] Bluetooth: mediatek: add gpio pin to reset bt Zhangchao Zhang
2025-09-05  8:40 ` [PATCH v7 1/1] " Zhangchao Zhang
2025-09-05  8:43   ` Krzysztof Kozlowski
2025-09-10 23:29     ` Sean Wang
2025-09-11  6:07       ` Krzysztof Kozlowski
2025-09-12  0:10         ` Sean Wang
2025-09-06 11:04   ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).