On 08/07/2025 08:01, 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@xxxxxxxxxxxx> > Co-developed: Chris Lu <chris.lu@xxxxxxxxxxxx> > Co-developed: Jiande Lu <jiande.lu@xxxxxxxxxxxx> > Signed-off-by: Zhangchao Zhang <ot_zhangchao.zhang@xxxxxxxxxxxx> > --- > drivers/bluetooth/btmtk.c | 69 +++++++++++++++++++++++++++++++++++++++ > drivers/bluetooth/btmtk.h | 5 +++ > 2 files changed, 74 insertions(+) > > diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c > index 4390fd571dbd..cdb90143be61 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/of.h> > +#include <linux/of_gpio.h> > #include <linux/unaligned.h> > > #include <net/bluetooth/bluetooth.h> > @@ -109,6 +111,65 @@ static void btmtk_coredump_notify(struct hci_dev *hdev, int state) > } > } > > +static void btmtk_reset_by_gpio_work(struct work_struct *work) > +{ > + struct btmtk_reset_gpio *reset_gpio_data = > + container_of(work, struct btmtk_reset_gpio, reset_work.work); > + > + gpio_direction_output(reset_gpio_data->gpio_number, 1); > + kfree(reset_gpio_data); > +} > + > +static int btmtk_reset_by_gpio(struct hci_dev *hdev) > +{ > + struct btmtk_data *data = hci_get_priv(hdev); > + struct btmtk_reset_gpio *reset_gpio_data; > + struct device_node *node; > + int reset_gpio_number; > + > + node = of_find_compatible_node(NULL, NULL, "mediatek,mt7925-bluetooth"); No. You don't take GPIOs from random node. You take them from your device with proper API, instead of: > + if (node) { > + reset_gpio_number = of_get_named_gpio(node, "reset-gpios", 0); legacy OF API. This only points that your driver model is broken or your hardware description is wrong. Best regards, Krzysztof