linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Add DFU driver for Atheros Bluetooth chipset AR3011
@ 2010-01-20 20:01 Luis R. Rodriguez
  2010-01-20 20:27 ` Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Luis R. Rodriguez @ 2010-01-20 20:01 UTC (permalink / raw)
  To: torvalds, marcel
  Cc: linux-bluetooth, linux-kernel, mcgrof, Vikram Kandukuri,
	Vikram Kandukuri, Alicke Xu

From: Vikram Kandukuri <vkandukuri@atheros.com>

Signed-off-by: Vikram Kandukuri <vikram.kandukuri@atheros.com>
Signed-off-by: Alicke Xu <sxu@atheros.com>
Reviewed-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---

Linus, this was merged into linux-next already. The driver is small enough,
it just uploads firmware, I figured it would likely be welcomed into 2.6.33-rc5.
The patch is the same as it went into linux-next. The firmware is already
merged as part of the linux-firmware git tree.

Distributions who want ath3k as part of older kernels (distributions preparing
a release based on 2.6.32) can snatch the driver apart by using:

git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/ath3k.git

  Luis

 drivers/bluetooth/Kconfig  |   13 +++-
 drivers/bluetooth/Makefile |    1 +
 drivers/bluetooth/ath3k.c  |  187 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 200 insertions(+), 1 deletions(-)
 create mode 100644 drivers/bluetooth/ath3k.c

diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 652367a..058fbcc 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -195,5 +195,16 @@ config BT_MRVL_SDIO
 	  Say Y here to compile support for Marvell BT-over-SDIO driver
 	  into the kernel or say M to compile it as module.
 
-endmenu
+config BT_ATH3K
+	tristate "Atheros firmware download driver"
+	depends on BT_HCIBTUSB
+	select FW_LOADER
+	help
+	  Bluetooth firmware download driver.
+	  This driver loads the firmware into the Atheros Bluetooth
+	  chipset.
 
+	  Say Y here to compile support for "Atheros firmware download driver"
+	  into the kernel or say M to compile it as module (ath3k).
+
+endmenu
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index b3f57d2..7e5aed5 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_BT_HCIBTUART)	+= btuart_cs.o
 obj-$(CONFIG_BT_HCIBTUSB)	+= btusb.o
 obj-$(CONFIG_BT_HCIBTSDIO)	+= btsdio.o
 
+obj-$(CONFIG_BT_ATH3K)		+= ath3k.o
 obj-$(CONFIG_BT_MRVL)		+= btmrvl.o
 obj-$(CONFIG_BT_MRVL_SDIO)	+= btmrvl_sdio.o
 
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
new file mode 100644
index 0000000..add9485
--- /dev/null
+++ b/drivers/bluetooth/ath3k.c
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2008-2009 Atheros Communications Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/device.h>
+#include <linux/firmware.h>
+#include <linux/usb.h>
+#include <net/bluetooth/bluetooth.h>
+
+#define VERSION "1.0"
+
+
+static struct usb_device_id ath3k_table[] = {
+	/* Atheros AR3011 */
+	{ USB_DEVICE(0x0CF3, 0x3000) },
+	{ }	/* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(usb, ath3k_table);
+
+#define USB_REQ_DFU_DNLOAD	1
+#define BULK_SIZE		4096
+
+struct ath3k_data {
+	struct usb_device *udev;
+	u8 *fw_data;
+	u32 fw_size;
+	u32 fw_sent;
+};
+
+static int ath3k_load_firmware(struct ath3k_data *data,
+				unsigned char *firmware,
+				int count)
+{
+	u8 *send_buf;
+	int err, pipe, len, size, sent = 0;
+
+	BT_DBG("ath3k %p udev %p", data, data->udev);
+
+	pipe = usb_sndctrlpipe(data->udev, 0);
+
+	if ((usb_control_msg(data->udev, pipe,
+				USB_REQ_DFU_DNLOAD,
+				USB_TYPE_VENDOR, 0, 0,
+				firmware, 20, USB_CTRL_SET_TIMEOUT)) < 0) {
+		BT_ERR("Can't change to loading configuration err");
+		return -EBUSY;
+	}
+	sent += 20;
+	count -= 20;
+
+	send_buf = kmalloc(BULK_SIZE, GFP_ATOMIC);
+	if (!send_buf) {
+		BT_ERR("Can't allocate memory chunk for firmware");
+		return -ENOMEM;
+	}
+
+	while (count) {
+		size = min_t(uint, count, BULK_SIZE);
+		pipe = usb_sndbulkpipe(data->udev, 0x02);
+		memcpy(send_buf, firmware + sent, size);
+
+		err = usb_bulk_msg(data->udev, pipe, send_buf, size,
+					&len, 3000);
+
+		if (err || (len != size)) {
+			BT_ERR("Error in firmware loading err = %d,"
+				"len = %d, size = %d", err, len, size);
+			goto error;
+		}
+
+		sent  += size;
+		count -= size;
+	}
+
+	kfree(send_buf);
+	return 0;
+
+error:
+	kfree(send_buf);
+	return err;
+}
+
+static int ath3k_probe(struct usb_interface *intf,
+			const struct usb_device_id *id)
+{
+	const struct firmware *firmware;
+	struct usb_device *udev = interface_to_usbdev(intf);
+	struct ath3k_data *data;
+	int size;
+
+	BT_DBG("intf %p id %p", intf, id);
+
+	if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
+		return -ENODEV;
+
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->udev = udev;
+
+	if (request_firmware(&firmware, "ath3k-1.fw", &udev->dev) < 0) {
+		kfree(data);
+		return -EIO;
+	}
+
+	size = max_t(uint, firmware->size, 4096);
+	data->fw_data = kmalloc(size, GFP_KERNEL);
+	if (!data->fw_data) {
+		release_firmware(firmware);
+		kfree(data);
+		return -ENOMEM;
+	}
+
+	memcpy(data->fw_data, firmware->data, firmware->size);
+	data->fw_size = firmware->size;
+	data->fw_sent = 0;
+	release_firmware(firmware);
+
+	usb_set_intfdata(intf, data);
+	if (ath3k_load_firmware(data, data->fw_data, data->fw_size)) {
+		usb_set_intfdata(intf, NULL);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static void ath3k_disconnect(struct usb_interface *intf)
+{
+	struct ath3k_data *data = usb_get_intfdata(intf);
+
+	BT_DBG("ath3k_disconnect intf %p", intf);
+
+	kfree(data->fw_data);
+	kfree(data);
+}
+
+static struct usb_driver ath3k_driver = {
+	.name		= "ath3k",
+	.probe		= ath3k_probe,
+	.disconnect	= ath3k_disconnect,
+	.id_table	= ath3k_table,
+};
+
+static int __init ath3k_init(void)
+{
+	BT_INFO("Atheros AR30xx firmware driver ver %s", VERSION);
+	return usb_register(&ath3k_driver);
+}
+
+static void __exit ath3k_exit(void)
+{
+	usb_deregister(&ath3k_driver);
+}
+
+module_init(ath3k_init);
+module_exit(ath3k_exit);
+
+MODULE_AUTHOR("Atheros Communications");
+MODULE_DESCRIPTION("Atheros AR30xx firmware driver");
+MODULE_VERSION(VERSION);
+MODULE_LICENSE("GPL");
+MODULE_FIRMWARE("ath3k-1.fw");
-- 
1.6.3.3

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

* Re: [PATCH] Bluetooth: Add DFU driver for Atheros Bluetooth chipset AR3011
  2010-01-20 20:01 [PATCH] Bluetooth: Add DFU driver for Atheros Bluetooth chipset AR3011 Luis R. Rodriguez
@ 2010-01-20 20:27 ` Marcel Holtmann
  2010-01-20 21:08   ` Luis R. Rodriguez
  0 siblings, 1 reply; 6+ messages in thread
From: Marcel Holtmann @ 2010-01-20 20:27 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: torvalds, linux-bluetooth, linux-kernel, mcgrof, Vikram Kandukuri,
	Vikram Kandukuri, Alicke Xu, David Miller

Hi Luis,

> Signed-off-by: Vikram Kandukuri <vikram.kandukuri@atheros.com>
> Signed-off-by: Alicke Xu <sxu@atheros.com>
> Reviewed-by: Luis R. Rodriguez <lrodriguez@atheros.com>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> 
> Linus, this was merged into linux-next already. The driver is small enough,
> it just uploads firmware, I figured it would likely be welcomed into 2.6.33-rc5.
> The patch is the same as it went into linux-next. The firmware is already
> merged as part of the linux-firmware git tree.

what is going on here? Overstepping myself and also Dave for merging a
new driver at this point of time in the development cycle.

The driver is small and self-contained, I agree on that. But remember
the reason why it was not part of 2.6.33-rc1. You guys actually screwed
up the submission. And I didn't get any fixes for 1.5 month. Now you are
pushing it like this?

Dave, I have no objection to merging this. So if you are happy in taking
in it this late, I include it in the round of fixes that I am putting
together.

Regards

Marcel



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

* Re: [PATCH] Bluetooth: Add DFU driver for Atheros Bluetooth chipset AR3011
  2010-01-20 20:27 ` Marcel Holtmann
@ 2010-01-20 21:08   ` Luis R. Rodriguez
  2010-01-20 22:52     ` Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Luis R. Rodriguez @ 2010-01-20 21:08 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Luis Rodriguez, torvalds@linux-foundation.org,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	mcgrof@gmail.com, Vikram Kandukuri, SongXing Xu, David Miller

On Wed, Jan 20, 2010 at 12:27:48PM -0800, Marcel Holtmann wrote:
> Hi Luis,
> 
> > Signed-off-by: Vikram Kandukuri <vikram.kandukuri@atheros.com>
> > Signed-off-by: Alicke Xu <sxu@atheros.com>
> > Reviewed-by: Luis R. Rodriguez <lrodriguez@atheros.com>
> > Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> > ---
> >
> > Linus, this was merged into linux-next already. The driver is small enough,
> > it just uploads firmware, I figured it would likely be welcomed into 2.6.33-rc5.
> > The patch is the same as it went into linux-next. The firmware is already
> > merged as part of the linux-firmware git tree.
> 
> what is going on here? Overstepping myself and also Dave for merging a
> new driver at this point of time in the development cycle.

I poked you on January 14 about whether or not we can push ath3k into
the 2.6.33 series since it was merged as part of linux-next [1]. I didn't
get a reply to that so I figured I'd try this instead.

[1] http://article.gmane.org/gmane.linux.bluez.kernel/4202/match=ath3k

> The driver is small and self-contained, I agree on that. But remember
> the reason why it was not part of 2.6.33-rc1. You guys actually screwed
> up the submission. And I didn't get any fixes for 1.5 month.

Yeah that first set of patches sucked ass, even the later ones due to the
space crap, I agree completely, our bluetooth team needed to get familiarzed
with the upstream patch process and requirements.

> Now you are pushing it like this?

Well like I said I poked you about it on January, and got no reply. So yes.
I see no point to penalize users for not merging a driver into the 2.6.33
series if its already in linux-next, its so small, and the point of issue
was the original submission from a team completely new to the process.

So you justify not merging the driver into 2.6.33 because the team submitting
it did a terrible job on their first try submitting upstream?

> Dave, I have no objection to merging this. So if you are happy in taking
> in it this late, I include it in the round of fixes that I am putting
> together.

I'll clarify I am not trying to overstep on anyone, but if I get no replies
I will try to push through alternate routes.

Thanks,

  Luis

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

* Re: [PATCH] Bluetooth: Add DFU driver for Atheros Bluetooth chipset AR3011
  2010-01-20 21:08   ` Luis R. Rodriguez
@ 2010-01-20 22:52     ` Marcel Holtmann
  2010-01-20 22:56       ` David Miller
  2010-01-20 23:01       ` Luis R. Rodriguez
  0 siblings, 2 replies; 6+ messages in thread
From: Marcel Holtmann @ 2010-01-20 22:52 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: Luis Rodriguez, torvalds@linux-foundation.org,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	mcgrof@gmail.com, Vikram Kandukuri, SongXing Xu, David Miller

Hi Luis,

> > > Signed-off-by: Vikram Kandukuri <vikram.kandukuri@atheros.com>
> > > Signed-off-by: Alicke Xu <sxu@atheros.com>
> > > Reviewed-by: Luis R. Rodriguez <lrodriguez@atheros.com>
> > > Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> > > ---
> > >
> > > Linus, this was merged into linux-next already. The driver is small enough,
> > > it just uploads firmware, I figured it would likely be welcomed into 2.6.33-rc5.
> > > The patch is the same as it went into linux-next. The firmware is already
> > > merged as part of the linux-firmware git tree.
> > 
> > what is going on here? Overstepping myself and also Dave for merging a
> > new driver at this point of time in the development cycle.
> 
> I poked you on January 14 about whether or not we can push ath3k into
> the 2.6.33 series since it was merged as part of linux-next [1]. I didn't
> get a reply to that so I figured I'd try this instead.
> 
> [1] http://article.gmane.org/gmane.linux.bluez.kernel/4202/match=ath3k

sorry that I missed that email, I read the subject as FYI if you are
using that driver. Which I actually don't since nobody ever send me
hardware ;)

> > The driver is small and self-contained, I agree on that. But remember
> > the reason why it was not part of 2.6.33-rc1. You guys actually screwed
> > up the submission. And I didn't get any fixes for 1.5 month.
> 
> Yeah that first set of patches sucked ass, even the later ones due to the
> space crap, I agree completely, our bluetooth team needed to get familiarzed
> with the upstream patch process and requirements.
> 
> > Now you are pushing it like this?
> 
> Well like I said I poked you about it on January, and got no reply. So yes.
> I see no point to penalize users for not merging a driver into the 2.6.33
> series if its already in linux-next, its so small, and the point of issue
> was the original submission from a team completely new to the process.
> 
> So you justify not merging the driver into 2.6.33 because the team submitting
> it did a terrible job on their first try submitting upstream?

The patch got merged and is in bluetooth-next-2.6 tree. I normally try
to keep the submission to the changes before the merge window opens. And
then the part that didn't make it at that point will be just scheduled
for the next kernel.

If you guys were ready at least by -rc1, I would have most likely pushed
it to Dave right away, but you weren't. So I just decided that the next
merge window is good enough. Since you guys were not responding timely
to my reviews with an updated patch, I figured it doesn't really matter.
The driver is on its way into Linus' kernel. It will be just 2.6.34 at
this point.

> > Dave, I have no objection to merging this. So if you are happy in taking
> > in it this late, I include it in the round of fixes that I am putting
> > together.
> 
> I'll clarify I am not trying to overstep on anyone, but if I get no replies
> I will try to push through alternate routes.

If you feel strongly that the patch needs to go into the current
development kernel, then please mention it somewhere in its submission
to linux-bluetooth. To be honest, once I have it in bluetooth-next-2.6,
the likelihood that I cherry-pick it for the current development kernel
is not that high.

As I said, if Dave is willing to take it, then I cherry-pick it for you
and include it with my next round of fixes.

Regards

Marcel



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

* Re: [PATCH] Bluetooth: Add DFU driver for Atheros Bluetooth chipset AR3011
  2010-01-20 22:52     ` Marcel Holtmann
@ 2010-01-20 22:56       ` David Miller
  2010-01-20 23:01       ` Luis R. Rodriguez
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2010-01-20 22:56 UTC (permalink / raw)
  To: marcel
  Cc: lrodriguez, Luis.Rodriguez, torvalds, linux-bluetooth,
	linux-kernel, mcgrof, Vikram.Kandukuri, SongXing.Xu

From: Marcel Holtmann <marcel@holtmann.org>
Date: Wed, 20 Jan 2010 14:52:53 -0800

> sorry that I missed that email, I read the subject as FYI if you are
> using that driver. Which I actually don't since nobody ever send me
> hardware ;)

Marcel, you miss quite a few bluetooth patches I have to
say.

Why not setup patchwork for linux-bluetooth and that way there can
much less confusion and less situations like this?

Thanks.

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

* Re: [PATCH] Bluetooth: Add DFU driver for Atheros Bluetooth chipset AR3011
  2010-01-20 22:52     ` Marcel Holtmann
  2010-01-20 22:56       ` David Miller
@ 2010-01-20 23:01       ` Luis R. Rodriguez
  1 sibling, 0 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2010-01-20 23:01 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Luis Rodriguez, torvalds@linux-foundation.org,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	Vikram Kandukuri, SongXing Xu, David Miller

On Wed, Jan 20, 2010 at 2:52 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> As I said, if Dave is willing to take it, then I cherry-pick it for you
> and include it with my next round of fixes.

Well it enables hardware, so yes, I think it'd be good to add to
2.6.33-rc5, despite its historical issues on route upstream. Otherwise
I have to poke distributions to carry the driver externally anyway,
and I don't see the point in that if we still have a few RC cycles
left and this driver is really small.

Dave, please let me know if including this driver is unacceptable. I
honestly fail to understand the reasons for it to not go into
2.6.33-rcX.

  Luis

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

end of thread, other threads:[~2010-01-20 23:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-20 20:01 [PATCH] Bluetooth: Add DFU driver for Atheros Bluetooth chipset AR3011 Luis R. Rodriguez
2010-01-20 20:27 ` Marcel Holtmann
2010-01-20 21:08   ` Luis R. Rodriguez
2010-01-20 22:52     ` Marcel Holtmann
2010-01-20 22:56       ` David Miller
2010-01-20 23:01       ` Luis R. Rodriguez

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).