23 #include <linux/slab.h>
27 #define SAA7164_REV2_FIRMWARE "NXP7164-2010-03-10.1.fw"
28 #define SAA7164_REV2_FIRMWARE_SIZE 4019072
30 #define SAA7164_REV3_FIRMWARE "NXP7164-2010-03-10.1.fw"
31 #define SAA7164_REV3_FIRMWARE_SIZE 4019072
82 u32 dlflag_ack = dlflag + 4;
83 u32 drflag = dlflag_ack + 4;
84 u32 drflag_ack = drflag + 4;
85 u32 bleflag = drflag_ack + 4;
88 "%s(image=%p, size=%d, flags=0x%x, dst=%p, dstsize=0x%x)\n",
89 __func__, src, srcsize, dlflags, dst, dstsize);
91 if ((src ==
NULL) || (dst ==
NULL)) {
102 if (srcsize > (4*1048576)) {
107 memcpy(srcbuf, src, srcsize);
119 "%s() Download flag already set, please reboot\n",
135 for (offset = 0; srcsize > dstsize;
136 srcsize -= dstsize, offset += dstsize) {
139 memcpy(dst, srcbuf + offset, dstsize);
157 memcpy(dst, srcbuf+offset, srcsize);
206 u32 tmp, filesize,
version, err_flags, first_timeout, fwlength;
207 u32 second_timeout, updatebootloader = 1, bootloadersize = 0;
210 u32 bootloaderversion = 0, fwloadersize;
211 u8 *bootloaderoffset =
NULL, *fwloaderoffset;
227 if (version == 0x00) {
229 second_timeout = 100;
233 __func__, err_flags);
237 __func__, err_flags);
257 if (first_timeout == 0) {
259 "%s() no first image\n",
264 second_timeout -= 10;
265 if (second_timeout == 0) {
267 "%s() FW load time exceeded\n",
272 second_timeout -= 10;
273 if (second_timeout == 0) {
275 "%s() Unknown bootloader flags 0x%x\n",
276 __func__, err_flags);
289 second_timeout = 100;
293 __func__, err_flags);
296 __func__, err_flags);
301 "%s() firmware corrupt\n",
307 "%s() device memory corrupt\n",
318 if (first_timeout == 0) {
320 "%s() no second image\n",
324 }
else if (err_flags &
326 second_timeout -= 10;
327 if (second_timeout == 0) {
329 "%s() FW load time exceeded\n",
334 second_timeout -= 10;
335 if (second_timeout == 0) {
337 "%s() Unknown bootloader flags 0x%x\n",
338 __func__, err_flags);
367 while (first_timeout) {
374 "%s() All f/w loaded successfully\n",
379 if (first_timeout == 0) {
381 "%s() FW did not boot\n",
398 "%s() The firmware hung, probably bad firmware\n",
411 (version & 0x0000fc00) >> 10,
412 (version & 0x000003e0) >> 5,
413 (version & 0x0000001f),
414 (version & 0xffff0000) >> 16);
425 "(file not found?)\n", __func__);
432 if (fw->
size != fwlength) {
479 == 0x00) && (version == 0x00)) {
483 (bootloaderversion & 0x0000fc00) >> 10,
484 (bootloaderversion & 0x000003e0) >> 5,
485 (bootloaderversion & 0x0000001f),
486 (bootloaderversion & 0xffff0000) >> 16
489 "in file %d.%d.%d.%d\n",
490 (boothdr->
version & 0x0000fc00) >> 10,
491 (boothdr->
version & 0x000003e0) >> 5,
492 (boothdr->
version & 0x0000001f),
493 (boothdr->
version & 0xffff0000) >> 16
496 if (bootloaderversion == boothdr->
version)
497 updatebootloader = 0;
512 (fwhdr->version & 0x0000fc00) >> 10,
513 (fwhdr->version & 0x000003e0) >> 5,
514 (fwhdr->version & 0x0000001f),
515 (fwhdr->version & 0xffff0000) >> 16
518 if (version == fwhdr->version) {
525 if (updatebootloader) {
531 bootloaderoffset = (
u8 *)(fw->
data +
552 "bootloader d/l has failed\n");
556 "bootloader download complete.\n");
568 fwloaderoffset = bootloaderoffset + bootloadersize;
571 fwloadersize = (fwhdr->firmwaresize + fwhdr->bslsize) *