Commit c4667746 authored by David Woodhouse's avatar David Woodhouse Committed by David Woodhouse

dabusb: use request_firmware()

Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 04a33e40
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -38,9 +38,10 @@
#include <linux/delay.h>
#include <linux/usb.h>
#include <linux/mutex.h>
#include <linux/firmware.h>
#include <linux/ihex.h>
#include "dabusb.h"
#include "dabfirmware.h"
/*
* Version Information
......@@ -297,7 +298,8 @@ static int dabusb_bulk (pdabusb_t s, pbulk_transfer_t pb)
return ret;
}
/* --------------------------------------------------------------------- */
static int dabusb_writemem (pdabusb_t s, int pos, unsigned char *data, int len)
static int dabusb_writemem (pdabusb_t s, int pos, const unsigned char *data,
int len)
{
int ret;
unsigned char *transfer_buffer = kmalloc (len, GFP_KERNEL);
......@@ -324,24 +326,35 @@ static int dabusb_8051_reset (pdabusb_t s, unsigned char reset_bit)
static int dabusb_loadmem (pdabusb_t s, const char *fname)
{
int ret;
PINTEL_HEX_RECORD ptr = firmware;
const struct ihex_binrec *rec;
const struct firmware *fw;
dbg("Enter dabusb_loadmem (internal)");
ret = request_ihex_firmware(&fw, "dabusb/firmware.fw", &s->usbdev->dev);
if (ret) {
err("Failed to load \"dabusb/firmware.fw\": %d\n", ret);
goto out;
}
ret = dabusb_8051_reset (s, 1);
while (ptr->Type == 0) {
dbg("dabusb_writemem: %04X %p %d)", ptr->Address, ptr->Data, ptr->Length);
for (rec = (const struct ihex_binrec *)fw->data; rec;
rec = ihex_next_binrec(rec)) {
dbg("dabusb_writemem: %04X %p %d)", be32_to_cpu(rec->addr),
rec->data, be16_to_cpu(rec->len));
ret = dabusb_writemem (s, ptr->Address, ptr->Data, ptr->Length);
ret = dabusb_writemem(s, be32_to_cpu(rec->addr), rec->data,
be16_to_cpu(rec->len));
if (ret < 0) {
err("dabusb_writemem failed (%d %04X %p %d)", ret, ptr->Address, ptr->Data, ptr->Length);
err("dabusb_writemem failed (%d %04X %p %d)", ret,
be32_to_cpu(rec->addr), rec->data,
be16_to_cpu(rec->len));
break;
}
ptr++;
}
ret = dabusb_8051_reset (s, 0);
release_firmware(fw);
out:
dbg("dabusb_loadmem: exit");
return ret;
......@@ -376,9 +389,9 @@ static int dabusb_fpga_init (pdabusb_t s, pbulk_transfer_t b)
static int dabusb_fpga_download (pdabusb_t s, const char *fname)
{
pbulk_transfer_t b = kmalloc (sizeof (bulk_transfer_t), GFP_KERNEL);
const struct firmware *fw;
unsigned int blen, n;
int ret;
unsigned char *buf = bitstream;
dbg("Enter dabusb_fpga_download (internal)");
......@@ -387,10 +400,16 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname)
return -ENOMEM;
}
ret = request_firmware(&fw, "dabusb/bitstream.bin", &s->usbdev->dev);
if (ret) {
err("Failed to load \"dabusb/bitstream.bin\": %d\n", ret);
return ret;
}
b->pipe = 1;
ret = dabusb_fpga_clear (s, b);
mdelay (10);
blen = buf[73] + (buf[72] << 8);
blen = fw->data[73] + (fw->data[72] << 8);
dbg("Bitstream len: %i", blen);
......@@ -402,7 +421,7 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname)
for (n = 0; n <= blen + 60; n += 60) {
// some cclks for startup
b->size = 64;
memcpy (b->data + 4, buf + 74 + n, 60);
memcpy (b->data + 4, fw->data + 74 + n, 60);
ret = dabusb_bulk (s, b);
if (ret < 0) {
err("dabusb_bulk failed.");
......@@ -413,6 +432,7 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname)
ret = dabusb_fpga_init (s, b);
kfree (b);
release_firmware(fw);
dbg("exit dabusb_fpga_download");
......
......@@ -29,6 +29,9 @@ fw-shipped-$(CONFIG_SND_MAESTRO3) += ess/maestro3_assp_kernel.fw \
ess/maestro3_assp_minisrc.fw
fw-shipped-$(CONFIG_SND_YMFPCI) += yamaha/ds1_ctrl.fw yamaha/ds1_dsp.fw \
yamaha/ds1e_ctrl.fw
fw-shipped-$(CONFIG_TIGON3) += tigon/tg3.bin tigon/tg3_tso.bin \
tigon/tg3_tso5.bin
fw-shipped-$(CONFIG_USB_DABUSB) += dabusb/firmware.fw dabusb/bitstream.bin
fw-shipped-$(CONFIG_USB_EMI26) += emi26/loader.fw emi26/firmware.fw \
emi26/bitstream.fw
fw-shipped-$(CONFIG_USB_EMI62) += emi62/loader.fw emi62/bitstream.fw \
......
......@@ -249,3 +249,19 @@ Licence: Allegedly GPLv2+, but no source visible. Marked:
Found in hex form in kernel source.
--------------------------------------------------------------------------
Driver: DABUSB -- Digital Audio Broadcasting (DAB) Receiver for USB and Linux
File: dabusb/firmware.fw
File: dabusb/bitstream.bin
Licence: Distributable
* Copyright (C) 1999 BayCom GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that redistributions of source
* code retain the above copyright notice and this comment without
* modification.
--------------------------------------------------------------------------
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment