aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2008-05-30 10:35:47 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2008-07-10 09:49:14 -0400
commitb8e24bfabb03527d1c876fcaf24cccb05e1cbc65 (patch)
treeed02482cfc823d96691ad78afb034b819f64b295
parentae93a55bf948753de0bb8e43fa9c027f786abb05 (diff)
emi62: use request_firmware()
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
-rw-r--r--drivers/usb/misc/emi62.c130
-rw-r--r--drivers/usb/misc/emi62_fw_m.h8853
-rw-r--r--drivers/usb/misc/emi62_fw_s.h8837
-rw-r--r--firmware/Makefile2
-rw-r--r--firmware/WHENCE23
-rw-r--r--firmware/emi62/bitstream.HEX4372
-rw-r--r--firmware/emi62/loader.HEX107
-rw-r--r--firmware/emi62/midi.HEX1266
-rw-r--r--firmware/emi62/spdif.HEX1257
9 files changed, 7100 insertions, 17747 deletions
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c
index 1a2b79ac5e10..20886c21e739 100644
--- a/drivers/usb/misc/emi62.c
+++ b/drivers/usb/misc/emi62.c
@@ -16,15 +16,8 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/usb.h> 17#include <linux/usb.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19 19#include <linux/firmware.h>
20#define MAX_INTEL_HEX_RECORD_LENGTH 16 20#include <linux/ihex.h>
21typedef struct _INTEL_HEX_RECORD
22{
23 __u32 length;
24 __u32 address;
25 __u32 type;
26 __u8 data[MAX_INTEL_HEX_RECORD_LENGTH];
27} INTEL_HEX_RECORD, *PINTEL_HEX_RECORD;
28 21
29/* include firmware (variables)*/ 22/* include firmware (variables)*/
30 23
@@ -33,9 +26,9 @@ typedef struct _INTEL_HEX_RECORD
33//#undef SPDIF /* if you want MIDI uncomment this line */ 26//#undef SPDIF /* if you want MIDI uncomment this line */
34 27
35#ifdef SPDIF 28#ifdef SPDIF
36# include "emi62_fw_s.h" /* spdif fw */ 29#define FIRMWARE_FW "emi62/spdif.fw"
37#else 30#else
38# include "emi62_fw_m.h" /* midi fw */ 31#define FIRMWARE_FW "emi62/midi.fw"
39#endif 32#endif
40 33
41#define EMI62_VENDOR_ID 0x086a /* Emagic Soft-und Hardware GmBH */ 34#define EMI62_VENDOR_ID 0x086a /* Emagic Soft-und Hardware GmBH */
@@ -48,7 +41,9 @@ typedef struct _INTEL_HEX_RECORD
48#define CPUCS_REG 0x7F92 /* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ 41#define CPUCS_REG 0x7F92 /* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */
49#define INTERNAL_RAM(address) (address <= MAX_INTERNAL_ADDRESS) 42#define INTERNAL_RAM(address) (address <= MAX_INTERNAL_ADDRESS)
50 43
51static int emi62_writememory( struct usb_device *dev, int address, unsigned char *data, int length, __u8 bRequest); 44static int emi62_writememory(struct usb_device *dev, int address,
45 const unsigned char *data, int length,
46 __u8 bRequest);
52static int emi62_set_reset(struct usb_device *dev, unsigned char reset_bit); 47static int emi62_set_reset(struct usb_device *dev, unsigned char reset_bit);
53static int emi62_load_firmware (struct usb_device *dev); 48static int emi62_load_firmware (struct usb_device *dev);
54static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *id); 49static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *id);
@@ -58,7 +53,9 @@ static void __exit emi62_exit (void);
58 53
59 54
60/* thanks to drivers/usb/serial/keyspan_pda.c code */ 55/* thanks to drivers/usb/serial/keyspan_pda.c code */
61static int emi62_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request) 56static int emi62_writememory(struct usb_device *dev, int address,
57 const unsigned char *data, int length,
58 __u8 request)
62{ 59{
63 int result; 60 int result;
64 unsigned char *buffer = kmemdup(data, length, GFP_KERNEL); 61 unsigned char *buffer = kmemdup(data, length, GFP_KERNEL);
@@ -91,9 +88,12 @@ static int emi62_set_reset (struct usb_device *dev, unsigned char reset_bit)
91 88
92static int emi62_load_firmware (struct usb_device *dev) 89static int emi62_load_firmware (struct usb_device *dev)
93{ 90{
91 const struct firmware *loader_fw = NULL;
92 const struct firmware *bitstream_fw = NULL;
93 const struct firmware *firmware_fw = NULL;
94 const struct ihex_binrec *rec;
94 int err; 95 int err;
95 int i; 96 int i;
96 int pos = 0; /* Position in hex record */
97 __u32 addr; /* Address to write */ 97 __u32 addr; /* Address to write */
98 __u8 *buf; 98 __u8 *buf;
99 99
@@ -105,6 +105,22 @@ static int emi62_load_firmware (struct usb_device *dev)
105 goto wraperr; 105 goto wraperr;
106 } 106 }
107 107
108 err = request_ihex_firmware(&loader_fw, "emi62/loader.fw", &dev->dev);
109 if (err)
110 goto nofw;
111
112 err = request_ihex_firmware(&bitstream_fw, "emi62/bitstream.fw",
113 &dev->dev);
114 if (err)
115 goto nofw;
116
117 err = request_ihex_firmware(&firmware_fw, FIRMWARE_FW, &dev->dev);
118 if (err) {
119 nofw:
120 err( "%s - request_firmware() failed", __func__);
121 goto wraperr;
122 }
123
108 /* Assert reset (stop the CPU in the EMI) */ 124 /* Assert reset (stop the CPU in the EMI) */
109 err = emi62_set_reset(dev,1); 125 err = emi62_set_reset(dev,1);
110 if (err < 0) { 126 if (err < 0) {
@@ -112,13 +128,18 @@ static int emi62_load_firmware (struct usb_device *dev)
112 goto wraperr; 128 goto wraperr;
113 } 129 }
114 130
131 rec = (const struct ihex_binrec *)loader_fw->data;
132
115 /* 1. We need to put the loader for the FPGA into the EZ-USB */ 133 /* 1. We need to put the loader for the FPGA into the EZ-USB */
116 for (i=0; g_emi62_loader[i].type == 0; i++) { 134 while (rec) {
117 err = emi62_writememory(dev, g_emi62_loader[i].address, g_emi62_loader[i].data, g_emi62_loader[i].length, ANCHOR_LOAD_INTERNAL); 135 err = emi62_writememory(dev, be32_to_cpu(rec->addr),
136 rec->data, be16_to_cpu(rec->len),
137 ANCHOR_LOAD_INTERNAL);
118 if (err < 0) { 138 if (err < 0) {
119 err("%s - error loading firmware: error = %d", __func__, err); 139 err("%s - error loading firmware: error = %d", __func__, err);
120 goto wraperr; 140 goto wraperr;
121 } 141 }
142 rec = ihex_next_binrec(rec);
122 } 143 }
123 144
124 /* De-assert reset (let the CPU run) */ 145 /* De-assert reset (let the CPU run) */
@@ -132,15 +153,16 @@ static int emi62_load_firmware (struct usb_device *dev)
132 /* 2. We upload the FPGA firmware into the EMI 153 /* 2. We upload the FPGA firmware into the EMI
133 * Note: collect up to 1023 (yes!) bytes and send them with 154 * Note: collect up to 1023 (yes!) bytes and send them with
134 * a single request. This is _much_ faster! */ 155 * a single request. This is _much_ faster! */
156 rec = (const struct ihex_binrec *)bitstream_fw->data;
135 do { 157 do {
136 i = 0; 158 i = 0;
137 addr = g_emi62bs[pos].address; 159 addr = be32_to_cpu(rec->addr);
138 160
139 /* intel hex records are terminated with type 0 element */ 161 /* intel hex records are terminated with type 0 element */
140 while ((g_emi62bs[pos].type == 0) && (i + g_emi62bs[pos].length < FW_LOAD_SIZE)) { 162 while (rec && (i + be16_to_cpu(rec->len) < FW_LOAD_SIZE)) {
141 memcpy(buf + i, g_emi62bs[pos].data, g_emi62bs[pos].length); 163 memcpy(buf + i, rec->data, be16_to_cpu(rec->len));
142 i += g_emi62bs[pos].length; 164 i += be16_to_cpu(rec->len);
143 pos++; 165 rec = ihex_next_binrec(rec);
144 } 166 }
145 err = emi62_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA); 167 err = emi62_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA);
146 if (err < 0) { 168 if (err < 0) {
@@ -157,8 +179,11 @@ static int emi62_load_firmware (struct usb_device *dev)
157 } 179 }
158 180
159 /* 3. We need to put the loader for the firmware into the EZ-USB (again...) */ 181 /* 3. We need to put the loader for the firmware into the EZ-USB (again...) */
160 for (i=0; g_emi62_loader[i].type == 0; i++) { 182 for (rec = (const struct ihex_binrec *)loader_fw->data;
161 err = emi62_writememory(dev, g_emi62_loader[i].address, g_emi62_loader[i].data, g_emi62_loader[i].length, ANCHOR_LOAD_INTERNAL); 183 rec; rec = ihex_next_binrec(rec)) {
184 err = emi62_writememory(dev, be32_to_cpu(rec->addr),
185 rec->data, be16_to_cpu(rec->len),
186 ANCHOR_LOAD_INTERNAL);
162 if (err < 0) { 187 if (err < 0) {
163 err("%s - error loading firmware: error = %d", __func__, err); 188 err("%s - error loading firmware: error = %d", __func__, err);
164 goto wraperr; 189 goto wraperr;
@@ -175,29 +200,19 @@ static int emi62_load_firmware (struct usb_device *dev)
175 200
176 /* 4. We put the part of the firmware that lies in the external RAM into the EZ-USB */