Bluetooth: btusb: Use an error label for error paths
Subsystems (4)
PATCH v2 1/3 Bluetooth: btusb: Use an error label for error paths
Use a label to remove the repetetive cleanup, for error cases.
---
v2: same as v1
drivers/bluetooth/btusb.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/bluetooth/btusb.c +9 -10
@@ -2991,18 +2991,15 @@ static int btusb_probe(struct usb_interface *intf, err =usb_set_interface (data->udev,0 ,0 );if (err <0 ) {BT_ERR ("failed to set interface 0, alt 0 %d" , err); -hci_free_dev (hdev); -return err; + goto out_free_dev; } }if (data->isoc) { err =usb_driver_claim_interface (&btusb_driver, data->isoc, data); -if (err <0 ) { -hci_free_dev (hdev); -return err; - } +if (err <0 ) + goto out_free_dev; }#ifdef CONFIG_BT_HCIBTUSB_BCM
@@ -3016,14 +3013,16 @@ static int btusb_probe(struct usb_interface *intf,#endif err =hci_register_dev (hdev); -if (err <0 ) { -hci_free_dev (hdev); -return err; - } +if (err <0 ) + goto out_free_dev;usb_set_intfdata (intf, data);return 0 ; + +out_free_dev: +hci_free_dev (hdev); +return err; }static void btusb_disconnect (struct usb_interface *intf)
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 2/3 Bluetooth: btusb: Add out-of-band wakeup support
Some onboard BT chips (e.g. Marvell 8997) contain a wakeup pin that can be connected to a gpio on the CPU side, and can be used to wakeup the host out-of-band. This can be useful in situations where the in-band wakeup is not possible or not preferable (e.g. the in-band wakeup may require the USB host controller to remain active, and hence consuming more system power during system sleep).
The oob gpio interrupt to be used for wakeup on the CPU side, is read from the device tree node, (using standard interrupt descriptors). A devcie tree binding document is also added for the driver. The compatible string is in compliance with Documentation/devicetree/bindings/usb/usb-device.txt
---
v2: * Use interrupt-names ("wakeup") instead of assuming first interrupt.
* Leave it on device tree to specify IRQ flags (level /edge triggered)
* Mark the device as non wakeable on exit.
Documentation/devicetree/bindings/net/btusb.txt | 40 ++++++++++++ drivers/bluetooth/btusb.c | 84 +++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/btusb.txt
Documentation/devicetree/bindings/net/btusb.txt new file +40 -0
@@ -0,0 +1,40 @@ +Generic Bluetooth controller over USB (btusb driver) +--------------------------------------------------- + +Required properties: + + - compatible : should comply with the format "usbVID,PID" specified in + Documentation/devicetree/bindings/usb/usb-device.txt + At the time of writing, the only OF supported devices + (more may be added later) are: + + "usb1286,204e" (Marvell 8997) + +Optional properties: + + - interrupt-parent: phandle of the parent interrupt controller + - interrupt-names: (see below) + - interrupts : The interrupt specified by the name "wakeup" is the interrupt + that shall be used for out-of-band wake-on-bt. Driver will + request this interrupt for wakeup. During system suspend, the + irq will be enabled so that the bluetooth chip can wakeup host + platform out of band. During system resume, the irq will be + disabled to make sure unnecessary interrupt is not received. + +Example: + +Following example uses irq pin number 3 of gpio0 for out of band wake-on-bt: + +&usb_host1_ehci { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + mvl_bt1: bt@1 { + compatible = "usb1286,204e"; + reg = <1>; + interrupt-parent = <&gpio0>; + interrupt-name = "wakeup"; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; + }; +};
drivers/bluetooth/btusb.c +84 -0
132 lines not on this page · raw message
Signature · 1 line
2.8.0.rc3.226.g39d4020
Re: [PATCH v2 2/3] Bluetooth: btusb: Add out-of-band wakeup support
Hi Rajat,
Quoted 7 lines · Rajat Jain
Some onboard BT chips (e.g. Marvell 8997) contain a wakeup pin that can be connected to a gpio on the CPU side, and can be used to wakeup the host out-of-band. This can be useful in situations where the in-band wakeup is not possible or not preferable (e.g. the in-band wakeup may require the USB host controller to remain active, and hence consuming more system power during system sleep).
Quoted 7 lines
The oob gpio interrupt to be used for wakeup on the CPU side, is read from the device tree node, (using standard interrupt descriptors). A devcie tree binding document is also added for the driver. The compatible string is in compliance with
Documentation/devicetree/bindings/usb/usb-device.txtSigned-off-by Rajat Jain <[email protected]>
A few small comments below, but other than those, for the whole series:
Quoted 17 lines
---
v2: * Use interrupt-names ("wakeup") instead of assuming first interrupt.
* Leave it on device tree to specify IRQ flags (level /edge triggered)
* Mark the device as non wakeable on exit.Documentation/devicetree/bindings/net/btusb.txt | 40 ++++++++++++ drivers/bluetooth/btusb.c | 84 +++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/btusb.txtDocumentation/devicetree/bindings/net/btusb.txt new file +1
-0@@ -0,0 +1,40 @@ +Generic Bluetooth controller over USB (btusb driver)
Documentation/devicetree/bindings/net/btusb.txt line 11
Quoted 10 lines
Documentation/devicetree/bindings/net/btusb.txt new file +10
-0+--------------------------------------------------- + +Required properties: + + - compatible : should comply with the format "usbVID,PID" specified in + Documentation/devicetree/bindings/usb/usb-device.txt + At the time of writing, the only OF supported devices + (more may be added later) are: + + "usb1286,204e" (Marvell 8997)
I don't know if anyone cares about these sort of organizational aspects, but in patch 3 you're extending this binding with device-specific Marvell bindings. Seems like it'd be good to have some clear way to correlate those 2. e.g., add a reference to marvell-bt-sd8xxx.txt (or marvell-bt-8xxx.txt, once you rename it) in patch 3.
Quoted 72 lines
Documentation/devicetree/bindings/net/btusb.txt new file +29
-0+ +Optional properties: + + - interrupt-parent: phandle of the parent interrupt controller + - interrupt-names: (see below) + - interrupts : The interrupt specified by the name "wakeup" is the interrupt + that shall be used for out-of-band wake-on-bt. Driver will + request this interrupt for wakeup. During system suspend, the + irq will be enabled so that the bluetooth chip can wakeup host + platform out of band. During system resume, the irq will be + disabled to make sure unnecessary interrupt is not received. + +Example: + +Following example uses irq pin number 3 of gpio0 for out of band wake-on-bt: + +&usb_host1_ehci { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + mvl_bt1: bt@1 { + compatible = "usb1286,204e"; + reg = <1>; + interrupt-parent = <&gpio0>; + interrupt-name = "wakeup"; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; + }; +};drivers/bluetooth/btusb.c +14
-0@@ -24,6 +24,8 @@#include <linux/module.h> #include <linux/usb.h> #include <linux/firmware.h> +#include <linux/of_device.h> +#include <linux/of_irq.h> #include <asm/unaligned.h> #include <net/bluetooth/bluetooth.h> @@ -369,6 +371,7 @@ static const struct usb_device_id blacklist_table[] = {#define BTUSB_BOOTING 9#define BTUSB_RESET_RESUME 10#define BTUSB_DIAG_RUNNING 11 +#define BTUSB_OOB_WAKE_DISABLED 12struct btusb_data {struct hci_dev *hdev;@@ -416,6 +419,8 @@ struct btusb_data {int (*recv_bulk)(struct btusb_data *data,void *buffer,int count);int (*setup_on_usb)(struct hci_dev *hdev); + +int oob_wake_irq;/* irq for out-of-band wake-on-bt */ };static inline void btusb_free_frags (struct btusb_data *data)@@ -2728,6 +2733,65 @@ static int btusb_bcm_set_diag(struct hci_dev *hdev, bool enable) }#endif +#ifdef CONFIG_PM +static irqreturn_t btusb_oob_wake_handler (int irq,void *priv) +{ +struct btusb_data *data = priv; + +/* Disable only if not already disabled (keep it balanced) */ +if (!test_and_set_bit (BTUSB_OOB_WAKE_DISABLED , &data->flags)) { +disable_irq_nosync (irq); +disable_irq_wake (irq);
drivers/bluetooth/btusb.c static int btusb_bcm_set_diag(struct hci_dev *hdev, bool enable) · line 2754
Quoted 10 lines
drivers/bluetooth/btusb.c +10
-0+ } +pm_wakeup_event (&data->udev->dev,0 ); +return IRQ_HANDLED ; +} + +static const struct of_device_id btusb_match_table[] = { + { .compatible ="usb1286,204e" }, + { } +}; +MODULE_DEVICE_TABLE (of, btusb_match_table);
You define a match table here, but you also define essentially same table for Marvell-specific additions in patch 3. It looks like maybe it's legal to have more than one OF table in a module? But it seems like it would get confusing, besides being somewhat strange to maintain. It might also produce duplicate 'modinfo' output.
If you really want to independently opt into device-tree-specified interrupts vs. Marvell-specific interrrupt configuration, then you should probably just merge the latter into the former table, and implement a Marvell/GPIO flag to stick in the .data field of this table.
Or it might be fine to drop one or both "match" checks. Particularly for the Marvell-specific stuff, it's probably fair just to check if it has an ->of_node and if 'id->driver_info & BTUSB_MARVELL'. Any other Marvell device-specific quirks could probably be keyed off of the (weirdly-named?) blacklist_table[], which already matches PID/VID.
Quoted 79 lines
drivers/bluetooth/btusb.c +54
-0+ +/* Use an oob wakeup pin? */ +static int btusb_config_oob_wake (struct hci_dev *hdev) +{ +struct btusb_data *data =hci_get_drvdata (hdev); +struct device *dev = &data->udev->dev; +int irq, ret; + +if (!of_match_device (btusb_match_table, dev)) +return 0 ; + +/* Move on if no IRQ specified */ + irq =of_irq_get_byname (dev->of_node,"wakeup" ); +if (irq <=0 ) { +bt_dev_dbg (hdev,"%s: no OOB Wakeup IRQ in DT" , __func__); +return 0 ; + } + +set_bit (BTUSB_OOB_WAKE_DISABLED , &data->flags); + + ret =devm_request_irq (&hdev->dev, irq, btusb_oob_wake_handler, +0 ,"OOB Wake-on-BT" , data); +if (ret) { +bt_dev_err (hdev,"%s: IRQ request failed" , __func__); +return ret; + } + + ret =device_init_wakeup (dev, true); +if (ret) { +bt_dev_err (hdev,"%s: failed to init_wakeup\n" , __func__); +return ret; + } + + data->oob_wake_irq = irq; +disable_irq (irq); +bt_dev_info (hdev,"OOB Wake-on-BT configured at IRQ %u\n" , irq); +return 0 ; +} +#endif +static int btusb_probe (struct usb_interface *intf,const struct usb_device_id *id) {@@ -2849,6 +2913,11 @@ static int btusb_probe(struct usb_interface *intf, hdev->send = btusb_send_frame; hdev->notify = btusb_notify; +#ifdef CONFIG_PM + err =btusb_config_oob_wake (hdev); +if (err) + goto out_free_dev; +#endif if (id->driver_info &BTUSB_CW6622 )set_bit (HCI_QUIRK_BROKEN_STORED_LINK_KEY , &hdev->quirks);@@ -3061,6 +3130,9 @@ static void btusb_disconnect(struct usb_interface *intf)usb_driver_release_interface (&btusb_driver, data->isoc); } +if (data->oob_wake_irq) +device_init_wakeup (&data->udev->dev, false); +hci_free_dev (hdev); }@@ -3089,6 +3161,12 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)btusb_stop_traffic (data);usb_kill_anchored_urbs (&data->tx_anchor); +if (data->oob_wake_irq &&device_may_wakeup (&data->udev->dev)) { +clear_bit (BTUSB_OOB_WAKE_DISABLED , &data->flags); +enable_irq_wake (data->oob_wake_irq); +enable_irq (data->oob_wake_irq); + } +/* Optionally request a device reset on resume, but only when * wakeups are disabled. If wakeups are enabled we assume the * device will stay powered up throughout suspend.
drivers/bluetooth/btusb.c static int btusb_resume(struct usb_interface *intf) · line 3204
Quoted 1 line
drivers/bluetooth/btusb.c +0
-0@@ -3126,6 +3204,12 @@ static int btusb_resume(struct usb_interface *intf)if (--data->suspend_count)
Not related to your patch exactly, but isn't this 'suspend_count' stuff useless? I'd send a patch, but it might conflict with yours. Just wanted to note it and see if I'm crazy...
Brian
Quoted 14 lines
drivers/bluetooth/btusb.c +6
-0return 0 ; +/* Disable only if not already disabled (keep it balanced) */ +if (!test_and_set_bit (BTUSB_OOB_WAKE_DISABLED , &data->flags)) { +disable_irq (data->oob_wake_irq); +disable_irq_wake (data->oob_wake_irq); + } +if (!test_bit (HCI_RUNNING , &hdev->flags)) goto done;Signature · 1 line
2.8.0.rc3.226.g39d4020
Re: [PATCH v2 2/3] Bluetooth: btusb: Add out-of-band wakeup support
Hi Brian,
Quoted 47 lines · Brian Norris
Hi Rajat,
Quoted 7 lines · Rajat Jain
Some onboard BT chips (e.g. Marvell 8997) contain a wakeup pin that can be connected to a gpio on the CPU side, and can be used to wakeup the host out-of-band. This can be useful in situations where the in-band wakeup is not possible or not preferable (e.g. the in-band wakeup may require the USB host controller to remain active, and hence consuming more system power during system sleep).
Quoted 7 lines
The oob gpio interrupt to be used for wakeup on the CPU side, is read from the device tree node, (using standard interrupt descriptors). A devcie tree binding document is also added for the driver. The compatible string is in compliance with
Documentation/devicetree/bindings/usb/usb-device.txtSigned-off-by Rajat Jain <[email protected]>A few small comments below, but other than those, for the whole series:
Reviewed-by Brian Norris <[email protected]>Quoted 25 lines
---
v2: * Use interrupt-names ("wakeup") instead of assuming first interrupt.
* Leave it on device tree to specify IRQ flags (level /edge triggered)
* Mark the device as non wakeable on exit.Documentation/devicetree/bindings/net/btusb.txt | 40 ++++++++++++ drivers/bluetooth/btusb.c | 84 +++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/btusb.txtDocumentation/devicetree/bindings/net/btusb.txt new file +9
-0@@ -0,0 +1,40 @@ +Generic Bluetooth controller over USB (btusb driver) +--------------------------------------------------- + +Required properties: + + - compatible : should comply with the format "usbVID,PID" specified in + Documentation/devicetree/bindings/usb/usb-device.txt + At the time of writing, the only OF supported devices + (more may be added later) are:
Quoted 8 lines
Documentation/devicetree/bindings/net/btusb.txt line 11
Quoted 2 lines
Documentation/devicetree/bindings/net/btusb.txt new file +2
-0+ + "usb1286,204e" (Marvell 8997)I don't know if anyone cares about these sort of organizational aspects, but in patch 3 you're extending this binding with device-specific Marvell bindings. Seems like it'd be good to have some clear way to correlate those 2. e.g., add a reference to marvell-bt-sd8xxx.txt (or marvell-bt-8xxx.txt, once you rename it) in patch 3.
Good idea, I'll do it. (I'll add a reference to marvell-bt-8xxx.txt in btusb.txt).
Quoted 90 lines
Quoted 73 lines
Documentation/devicetree/bindings/net/btusb.txt new file +29
-0+ +Optional properties: + + - interrupt-parent: phandle of the parent interrupt controller + - interrupt-names: (see below) + - interrupts : The interrupt specified by the name "wakeup" is the interrupt + that shall be used for out-of-band wake-on-bt. Driver will + request this interrupt for wakeup. During system suspend, the + irq will be enabled so that the bluetooth chip can wakeup host + platform out of band. During system resume, the irq will be + disabled to make sure unnecessary interrupt is not received. + +Example: + +Following example uses irq pin number 3 of gpio0 for out of band wake-on-bt: + +&usb_host1_ehci { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + mvl_bt1: bt@1 { + compatible = "usb1286,204e"; + reg = <1>; + interrupt-parent = <&gpio0>; + interrupt-name = "wakeup"; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; + }; +};drivers/bluetooth/btusb.c +14
-0@@ -24,6 +24,8 @@#include <linux/module.h> #include <linux/usb.h> #include <linux/firmware.h> +#include <linux/of_device.h> +#include <linux/of_irq.h> #include <asm/unaligned.h> #include <net/bluetooth/bluetooth.h> @@ -369,6 +371,7 @@ static const struct usb_device_id blacklist_table[] = {#define BTUSB_BOOTING 9#define BTUSB_RESET_RESUME 10#define BTUSB_DIAG_RUNNING 11 +#define BTUSB_OOB_WAKE_DISABLED 12struct btusb_data {struct hci_dev *hdev;@@ -416,6 +419,8 @@ struct btusb_data {int (*recv_bulk)(struct btusb_data *data,void *buffer,int count);int (*setup_on_usb)(struct hci_dev *hdev); + +int oob_wake_irq;/* irq for out-of-band wake-on-bt */ };static inline void btusb_free_frags (struct btusb_data *data)@@ -2728,6 +2733,65 @@ static int btusb_bcm_set_diag(struct hci_dev *hdev, bool enable) }#endif +#ifdef CONFIG_PM +static irqreturn_t btusb_oob_wake_handler (int irq,void *priv) +{ +struct btusb_data *data = priv; + +/* Disable only if not already disabled (keep it balanced) */ +if (!test_and_set_bit (BTUSB_OOB_WAKE_DISABLED , &data->flags)) { +disable_irq_nosync (irq); +disable_irq_wake (irq);drivers/bluetooth/btusb.c static int btusb_bcm_set_diag(struct hci_dev *hdev, bool enable) · line 2754
Quoted 10 lines
drivers/bluetooth/btusb.c +10
-0+ } +pm_wakeup_event (&data->udev->dev,0 ); +return IRQ_HANDLED ; +} + +static const struct of_device_id btusb_match_table[] = { + { .compatible ="usb1286,204e" }, + { } +}; +MODULE_DEVICE_TABLE (of, btusb_match_table);You define a match table here, but you also define essentially same table for Marvell-specific additions in patch 3. It looks like maybe it's legal to have more than one OF table in a module? But it seems like it would get confusing, besides being somewhat strange to maintain. It might also produce duplicate 'modinfo' output.
Quoted 4 lines
If you really want to independently opt into device-tree-specified interrupts vs. Marvell-specific interrrupt configuration, then you should probably just merge the latter into the former table, and implement a Marvell/GPIO flag to stick in the .data field of this table.
The data we want to stick (The pin number on the chip) is board specific rather than being chip specific, and hence .data may not be useful here.
Quoted 6 lines
Or it might be fine to drop one or both "match" checks. Particularly for the Marvell-specific stuff, it's probably fair just to check if it has an ->of_node and if '
id->driver_info&BTUSB_MARVELL'. Any other Marvell device-specific quirks could probably be keyed off of the (weirdly-named?) blacklist_table[], which already matches PID/VID.
Yup, I think I can remove the compatible string checks.
I'll be sending a V3.
Quoted 102 lines
Quoted 80 lines
drivers/bluetooth/btusb.c +54
-0+ +/* Use an oob wakeup pin? */ +static int btusb_config_oob_wake (struct hci_dev *hdev) +{ +struct btusb_data *data =hci_get_drvdata (hdev); +struct device *dev = &data->udev->dev; +int irq, ret; + +if (!of_match_device (btusb_match_table, dev)) +return 0 ; + +/* Move on if no IRQ specified */ + irq =of_irq_get_byname (dev->of_node,"wakeup" ); +if (irq <=0 ) { +bt_dev_dbg (hdev,"%s: no OOB Wakeup IRQ in DT" , __func__); +return 0 ; + } + +set_bit (BTUSB_OOB_WAKE_DISABLED , &data->flags); + + ret =devm_request_irq (&hdev->dev, irq, btusb_oob_wake_handler, +0 ,"OOB Wake-on-BT" , data); +if (ret) { +bt_dev_err (hdev,"%s: IRQ request failed" , __func__); +return ret; + } + + ret =device_init_wakeup (dev, true); +if (ret) { +bt_dev_err (hdev,"%s: failed to init_wakeup\n" , __func__); +return ret; + } + + data->oob_wake_irq = irq; +disable_irq (irq); +bt_dev_info (hdev,"OOB Wake-on-BT configured at IRQ %u\n" , irq); +return 0 ; +} +#endif +static int btusb_probe (struct usb_interface *intf,const struct usb_device_id *id) {@@ -2849,6 +2913,11 @@ static int btusb_probe(struct usb_interface *intf, hdev->send = btusb_send_frame; hdev->notify = btusb_notify; +#ifdef CONFIG_PM + err =btusb_config_oob_wake (hdev); +if (err) + goto out_free_dev; +#endif if (id->driver_info &BTUSB_CW6622 )set_bit (HCI_QUIRK_BROKEN_STORED_LINK_KEY , &hdev->quirks);@@ -3061,6 +3130,9 @@ static void btusb_disconnect(struct usb_interface *intf)usb_driver_release_interface (&btusb_driver, data->isoc); } +if (data->oob_wake_irq) +device_init_wakeup (&data->udev->dev, false); +hci_free_dev (hdev); }@@ -3089,6 +3161,12 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)btusb_stop_traffic (data);usb_kill_anchored_urbs (&data->tx_anchor); +if (data->oob_wake_irq &&device_may_wakeup (&data->udev->dev)) { +clear_bit (BTUSB_OOB_WAKE_DISABLED , &data->flags); +enable_irq_wake (data->oob_wake_irq); +enable_irq (data->oob_wake_irq); + } +/* Optionally request a device reset on resume, but only when * wakeups are disabled. If wakeups are enabled we assume the * device will stay powered up throughout suspend. drivers/bluetooth/btusb.c static int btusb_resume(struct usb_interface *intf) · line 3204
Quoted 1 line
drivers/bluetooth/btusb.c +0
-0@@ -3126,6 +3204,12 @@ static int btusb_resume(struct usb_interface *intf)if (--data->suspend_count)Not related to your patch exactly, but isn't this '
suspend_count' stuff useless? I'd send a patch, but it might conflict with yours. Just wanted to note it and see if I'm crazy...Brian
Quoted 14 lines
drivers/bluetooth/btusb.c +6
-1return 0 ; +/* Disable only if not already disabled (keep it balanced) */ +if (!test_and_set_bit (BTUSB_OOB_WAKE_DISABLED , &data->flags)) { +disable_irq (data->oob_wake_irq); +disable_irq_wake (data->oob_wake_irq); + } +if (!test_bit (HCI_RUNNING , &hdev->flags)) goto done; --2.8.0.rc3.226.g39d4020
Re: [PATCH v2 2/3] Bluetooth: btusb: Add out-of-band wakeup support
Quoted 19 lines · Rajat Jain
Quoted 18 lines · Brian Norris
drivers/bluetooth/btusb.c static int btusb_bcm_set_diag(struct hci_dev *hdev, bool enable) · line 2754
Quoted 10 lines · Rajat Jain
drivers/bluetooth/btusb.c +5
-0+static const struct of_device_id btusb_match_table[] = { + { .compatible ="usb1286,204e" }, + { } +}; +MODULE_DEVICE_TABLE (of, btusb_match_table);You define a match table here, but you also define essentially same table for Marvell-specific additions in patch 3. It looks like maybe it's legal to have more than one OF table in a module? But it seems like it would get confusing, besides being somewhat strange to maintain. It might also produce duplicate 'modinfo' output.
Quoted 8 lines
Quoted 4 lines
If you really want to independently opt into device-tree-specified interrupts vs. Marvell-specific interrrupt configuration, then you should probably just merge the latter into the former table, and implement a Marvell/GPIO flag to stick in the .data field of this table.
The data we want to stick (The pin number on the chip) is board specific rather than being chip specific, and hence .data may not be useful here.
I just meant that if you conceptually wanted Marvell devices to "opt in" to this, then you could turn the .data field into some kind of flag or struct for describing capabilities (e.g., MARVELL_GPIO_WAKE or similar), effectively merging the two tables instead of having two mostly-overlapping tables.
But you could do the same by putting such flag(s) in the {btusb,blacklist}_table[], or add such flag(s) later whenever there's a Marvell device that doesn't support this feature.
Quoted 9 lines
Quoted 5 lines
Or it might be fine to drop one or both "match" checks. Particularly for the Marvell-specific stuff, it's probably fair just to check if it has an ->of_node and if '
id->driver_info&BTUSB_MARVELL'. Any other Marvell device-specific quirks could probably be keyed off of the (weirdly-named?) blacklist_table[], which already matches PID/VID.Yup, I think I can remove the compatible string checks.
I'll be sending a V3.
Great!
Brian
PATCH v2 3/3 Bluetooth: btusb: Configure Marvell to use one of the pins for oob wakeup
In reply to Rajat JainThe Marvell devices may have many gpio pins, and hence for wakeup on these out-of-band pins, the chip needs to be told which pin is to be used for wakeup, using an hci command.
Thus, we read the pin number etc from the device tree node and send a command to the chip.
---
v2: Fix the binding document to specify to use "wakeup" interrupt-name
.../{marvell-bt-sd8xxx.txt => marvell-bt-8xxx.txt} | 46 ++++++++++++++---
drivers/bluetooth/btusb.c | 59 ++++++++++++++++++++++
2 files changed, 97 insertions(+), 8 deletions(-)
rename Documentation/devicetree/bindings/net/{marvell-bt-sd8xxx.txt => marvell-bt-8xxx.txt} (50%)Documentation/devicetree/bindings/net/marvell-bt-8xxx.txt renamed from Documentation/devicetree/bindings/net/marvell-bt-sd8xxx.txt +38 -8
@@ -1,16 +1,21 @@ -Marvell 8897/8997 (sd8897/sd8997) bluetooth SDIO devices +Marvell 8897/8997 (sd8897/sd8997) bluetooth devices (SDIO or USB based) ------ +The 8997 devices supports multiple interfaces. When used on SDIO interfaces, +the btmrvl driver is used and when used on USB interface, the btusb driver is +used. Required properties: - compatible : should be one of the following: - * "marvell,sd8897-bt" - * "marvell,sd8997-bt" + * "marvell,sd8897-bt" (for SDIO) + * "marvell,sd8997-bt" (for SDIO) + * "usb1286,204e" (for USB) Optional properties: - marvell,cal-data: Calibration data downloaded to the device during initialization. This is an array of 28 values(u8). + This is only applicable to SDIO devices. - marvell,wakeup-pin: It represents wakeup pin number of the bluetooth chip. firmware will use the pin to wakeup host system (u16).
@@ -18,10 +23,15 @@ Optional properties: platform. The value will be configured to firmware. This is needed to work chip's sleep feature as expected (u16). - interrupt-parent: phandle of the parent interrupt controller - - interrupts : interrupt pin number to the cpu. Driver will request an irq based - on this interrupt number. During system suspend, the irq will be - enabled so that the bluetooth chip can wakeup host platform under - certain condition. During system resume, the irq will be disabled + - interrupt-names: Used only for USB based devices (See below) + - interrupts : specifies the interrupt pin number to the cpu. For SDIO, the + driver will use the first interrupt specified in the interrupt + array. For USB based devices, the driver will use the interrupt + named "wakeup" from the interrupt-names and interrupt arrays. + The driver will request an irq based on this interrupt number. + During system suspend, the irq will be enabled so that the + bluetooth chip can wakeup host platform under certain + conditions. During system resume, the irq will be disabled to make sure unnecessary interrupt is not received. Example:
@@ -29,7 +39,9 @@ Example: IRQ pin 119 is used as system wakeup source interrupt. wakeup pin 13 and gap 100ms are configured so that firmware can wakeup host using this device side pin and wakeup latency. -calibration data is also available in below example. + +Example for SDIO device follows (calibration data is also available in +below example). &mmc3 { status = "okay";
@@ -54,3 +66,21 @@ calibration data is also available in below example. marvell,wakeup-gap-ms = /bits/ 16 <0x64>; }; }; + +Example for USB device: + +&usb_host1_ohci { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + mvl_bt1: bt@1 { + compatible = "usb1286,204e"; + reg = <1>; + interrupt-parent = <&gpio0>; + interrupt-names = "wakeup"; + interrupts = <119 IRQ_TYPE_LEVEL_LOW>; + marvell,wakeup-pin = /bits/ 16 <0x0d>; + marvell,wakeup-gap-ms = /bits/ 16 <0x64>; + }; +};
drivers/bluetooth/btusb.c +59 -0
71 lines not on this page · raw message
Signature · 1 line
2.8.0.rc3.226.g39d4020