diff options
Diffstat (limited to 'drivers/net/wan/cycx_drv.c')
-rw-r--r-- | drivers/net/wan/cycx_drv.c | 81 |
1 files changed, 37 insertions, 44 deletions
diff --git a/drivers/net/wan/cycx_drv.c b/drivers/net/wan/cycx_drv.c index 164c3624ba89..2a3ecae67a90 100644 --- a/drivers/net/wan/cycx_drv.c +++ b/drivers/net/wan/cycx_drv.c | |||
@@ -48,6 +48,8 @@ | |||
48 | * Aug 8, 1998 acme Initial version. | 48 | * Aug 8, 1998 acme Initial version. |
49 | */ | 49 | */ |
50 | 50 | ||
51 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
52 | |||
51 | #include <linux/init.h> /* __init */ | 53 | #include <linux/init.h> /* __init */ |
52 | #include <linux/module.h> | 54 | #include <linux/module.h> |
53 | #include <linux/kernel.h> /* printk(), and other useful stuff */ | 55 | #include <linux/kernel.h> /* printk(), and other useful stuff */ |
@@ -81,10 +83,9 @@ static u16 checksum(u8 *buf, u32 len); | |||
81 | /* Global Data */ | 83 | /* Global Data */ |
82 | 84 | ||
83 | /* private data */ | 85 | /* private data */ |
84 | static const char modname[] = "cycx_drv"; | ||
85 | static const char fullname[] = "Cyclom 2X Support Module"; | 86 | static const char fullname[] = "Cyclom 2X Support Module"; |
86 | static const char copyright[] = "(c) 1998-2003 Arnaldo Carvalho de Melo " | 87 | static const char copyright[] = |
87 | "<acme@conectiva.com.br>"; | 88 | "(c) 1998-2003 Arnaldo Carvalho de Melo <acme@conectiva.com.br>"; |
88 | 89 | ||
89 | /* Hardware configuration options. | 90 | /* Hardware configuration options. |
90 | * These are arrays of configuration options used by verification routines. | 91 | * These are arrays of configuration options used by verification routines. |
@@ -110,8 +111,8 @@ static const long cycx_2x_irq_options[] = { 7, 3, 5, 9, 10, 11, 12, 15 }; | |||
110 | 111 | ||
111 | static int __init cycx_drv_init(void) | 112 | static int __init cycx_drv_init(void) |
112 | { | 113 | { |
113 | printk(KERN_INFO "%s v%u.%u %s\n", fullname, MOD_VERSION, MOD_RELEASE, | 114 | pr_info("%s v%u.%u %s\n", |
114 | copyright); | 115 | fullname, MOD_VERSION, MOD_RELEASE, copyright); |
115 | 116 | ||
116 | return 0; | 117 | return 0; |
117 | } | 118 | } |
@@ -139,18 +140,16 @@ int cycx_setup(struct cycx_hw *hw, void *cfm, u32 len, unsigned long dpmbase) | |||
139 | 140 | ||
140 | /* Verify IRQ configuration options */ | 141 | /* Verify IRQ configuration options */ |
141 | if (!get_option_index(cycx_2x_irq_options, hw->irq)) { | 142 | if (!get_option_index(cycx_2x_irq_options, hw->irq)) { |
142 | printk(KERN_ERR "%s: IRQ %d is invalid!\n", modname, hw->irq); | 143 | pr_err("IRQ %d is invalid!\n", hw->irq); |
143 | return -EINVAL; | 144 | return -EINVAL; |
144 | } | 145 | } |
145 | 146 | ||
146 | /* Setup adapter dual-port memory window and test memory */ | 147 | /* Setup adapter dual-port memory window and test memory */ |
147 | if (!dpmbase) { | 148 | if (!dpmbase) { |
148 | printk(KERN_ERR "%s: you must specify the dpm address!\n", | 149 | pr_err("you must specify the dpm address!\n"); |
149 | modname); | ||
150 | return -EINVAL; | 150 | return -EINVAL; |
151 | } else if (!get_option_index(cyc2x_dpmbase_options, dpmbase)) { | 151 | } else if (!get_option_index(cyc2x_dpmbase_options, dpmbase)) { |
152 | printk(KERN_ERR "%s: memory address 0x%lX is invalid!\n", | 152 | pr_err("memory address 0x%lX is invalid!\n", dpmbase); |
153 | modname, dpmbase); | ||
154 | return -EINVAL; | 153 | return -EINVAL; |
155 | } | 154 | } |
156 | 155 | ||
@@ -158,13 +157,12 @@ int cycx_setup(struct cycx_hw *hw, void *cfm, u32 len, unsigned long dpmbase) | |||
158 | hw->dpmsize = CYCX_WINDOWSIZE; | 157 | hw->dpmsize = CYCX_WINDOWSIZE; |
159 | 158 | ||
160 | if (!detect_cyc2x(hw->dpmbase)) { | 159 | if (!detect_cyc2x(hw->dpmbase)) { |
161 | printk(KERN_ERR "%s: adapter Cyclom 2X not found at " | 160 | pr_err("adapter Cyclom 2X not found at address 0x%lX!\n", |
162 | "address 0x%lX!\n", modname, dpmbase); | 161 | dpmbase); |
163 | return -EINVAL; | 162 | return -EINVAL; |
164 | } | 163 | } |
165 | 164 | ||
166 | printk(KERN_INFO "%s: found Cyclom 2X card at address 0x%lX.\n", | 165 | pr_info("found Cyclom 2X card at address 0x%lX\n", dpmbase); |
167 | modname, dpmbase); | ||
168 | 166 | ||
169 | /* Load firmware. If loader fails then shut down adapter */ | 167 | /* Load firmware. If loader fails then shut down adapter */ |
170 | err = load_cyc2x(hw, cfm, len); | 168 | err = load_cyc2x(hw, cfm, len); |
@@ -339,7 +337,7 @@ static int cycx_data_boot(void __iomem *addr, u8 *code, u32 len) | |||
339 | for (i = 0 ; i < len ; i += CFM_LOAD_BUFSZ) | 337 | for (i = 0 ; i < len ; i += CFM_LOAD_BUFSZ) |
340 | if (buffer_load(addr, code + i, | 338 | if (buffer_load(addr, code + i, |
341 | min_t(u32, CFM_LOAD_BUFSZ, (len - i))) < 0) { | 339 | min_t(u32, CFM_LOAD_BUFSZ, (len - i))) < 0) { |
342 | printk(KERN_ERR "%s: Error !!\n", modname); | 340 | pr_err("Error !!\n"); |
343 | return -1; | 341 | return -1; |
344 | } | 342 | } |
345 | 343 | ||
@@ -370,7 +368,7 @@ static int cycx_code_boot(void __iomem *addr, u8 *code, u32 len) | |||
370 | for (i = 0 ; i < len ; i += CFM_LOAD_BUFSZ) | 368 | for (i = 0 ; i < len ; i += CFM_LOAD_BUFSZ) |
371 | if (buffer_load(addr, code + i, | 369 | if (buffer_load(addr, code + i, |
372 | min_t(u32, CFM_LOAD_BUFSZ, (len - i)))) { | 370 | min_t(u32, CFM_LOAD_BUFSZ, (len - i)))) { |
373 | printk(KERN_ERR "%s: Error !!\n", modname); | 371 | pr_err("Error !!\n"); |
374 | return -1; | 372 | return -1; |
375 | } | 373 | } |
376 | 374 | ||
@@ -391,23 +389,20 @@ static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len) | |||
391 | u16 cksum; | 389 | u16 cksum; |
392 | 390 | ||
393 | /* Announce */ | 391 | /* Announce */ |
394 | printk(KERN_INFO "%s: firmware signature=\"%s\"\n", modname, | 392 | pr_info("firmware signature=\"%s\"\n", cfm->signature); |
395 | cfm->signature); | ||
396 | 393 | ||
397 | /* Verify firmware signature */ | 394 | /* Verify firmware signature */ |
398 | if (strcmp(cfm->signature, CFM_SIGNATURE)) { | 395 | if (strcmp(cfm->signature, CFM_SIGNATURE)) { |
399 | printk(KERN_ERR "%s:load_cyc2x: not Cyclom-2X firmware!\n", | 396 | pr_err("load_cyc2x: not Cyclom-2X firmware!\n"); |
400 | modname); | ||
401 | return -EINVAL; | 397 | return -EINVAL; |
402 | } | 398 | } |
403 | 399 | ||
404 | printk(KERN_INFO "%s: firmware version=%u\n", modname, cfm->version); | 400 | pr_info("firmware version=%u\n", cfm->version); |
405 | 401 | ||
406 | /* Verify firmware module format version */ | 402 | /* Verify firmware module format version */ |
407 | if (cfm->version != CFM_VERSION) { | 403 | if (cfm->version != CFM_VERSION) { |
408 | printk(KERN_ERR "%s:%s: firmware format %u rejected! " | 404 | pr_err("%s: firmware format %u rejected! Expecting %u.\n", |
409 | "Expecting %u.\n", | 405 | __func__, cfm->version, CFM_VERSION); |
410 | modname, __func__, cfm->version, CFM_VERSION); | ||
411 | return -EINVAL; | 406 | return -EINVAL; |
412 | } | 407 | } |
413 | 408 | ||
@@ -419,23 +414,22 @@ static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len) | |||
419 | if (((len - sizeof(struct cycx_firmware) - 1) != cfm->info.codesize) || | 414 | if (((len - sizeof(struct cycx_firmware) - 1) != cfm->info.codesize) || |
420 | */ | 415 | */ |
421 | if (cksum != cfm->checksum) { | 416 | if (cksum != cfm->checksum) { |
422 | printk(KERN_ERR "%s:%s: firmware corrupted!\n", | 417 | pr_err("%s: firmware corrupted!\n", __func__); |
423 | modname, __func__); | 418 | pr_err(" cdsize = 0x%x (expected 0x%lx)\n", |
424 | printk(KERN_ERR " cdsize = 0x%x (expected 0x%lx)\n", | 419 | len - (int)sizeof(struct cycx_firmware) - 1, |
425 | len - (int)sizeof(struct cycx_firmware) - 1, | 420 | cfm->info.codesize); |
426 | cfm->info.codesize); | 421 | pr_err(" chksum = 0x%x (expected 0x%x)\n", |
427 | printk(KERN_ERR " chksum = 0x%x (expected 0x%x)\n", | 422 | cksum, cfm->checksum); |
428 | cksum, cfm->checksum); | ||
429 | return -EINVAL; | 423 | return -EINVAL; |
430 | } | 424 | } |
431 | 425 | ||
432 | /* If everything is ok, set reset, data and code pointers */ | 426 | /* If everything is ok, set reset, data and code pointers */ |
433 | img_hdr = (struct cycx_fw_header *)&cfm->image; | 427 | img_hdr = (struct cycx_fw_header *)&cfm->image; |
434 | #ifdef FIRMWARE_DEBUG | 428 | #ifdef FIRMWARE_DEBUG |
435 | printk(KERN_INFO "%s:%s: image sizes\n", __func__, modname); | 429 | pr_info("%s: image sizes\n", __func__); |
436 | printk(KERN_INFO " reset=%lu\n", img_hdr->reset_size); | 430 | pr_info(" reset=%lu\n", img_hdr->reset_size); |
437 | printk(KERN_INFO " data=%lu\n", img_hdr->data_size); | 431 | pr_info(" data=%lu\n", img_hdr->data_size); |
438 | printk(KERN_INFO " code=%lu\n", img_hdr->code_size); | 432 | pr_info(" code=%lu\n", img_hdr->code_size); |
439 | #endif | 433 | #endif |
440 | reset_image = ((u8 *)img_hdr) + sizeof(struct cycx_fw_header); | 434 | reset_image = ((u8 *)img_hdr) + sizeof(struct cycx_fw_header); |
441 | data_image = reset_image + img_hdr->reset_size; | 435 | data_image = reset_image + img_hdr->reset_size; |
@@ -443,15 +437,14 @@ static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len) | |||
443 | 437 | ||
444 | /*---- Start load ----*/ | 438 | /*---- Start load ----*/ |
445 | /* Announce */ | 439 | /* Announce */ |
446 | printk(KERN_INFO "%s: loading firmware %s (ID=%u)...\n", modname, | 440 | pr_info("loading firmware %s (ID=%u)...\n", |
447 | cfm->descr[0] ? cfm->descr : "unknown firmware", | 441 | cfm->descr[0] ? cfm->descr : "unknown firmware", |
448 | cfm->info.codeid); | 442 | cfm->info.codeid); |
449 | 443 | ||
450 | for (i = 0 ; i < 5 ; i++) { | 444 | for (i = 0 ; i < 5 ; i++) { |
451 | /* Reset Cyclom hardware */ | 445 | /* Reset Cyclom hardware */ |
452 | if (!reset_cyc2x(hw->dpmbase)) { | 446 | if (!reset_cyc2x(hw->dpmbase)) { |
453 | printk(KERN_ERR "%s: dpm problem or board not found\n", | 447 | pr_err("dpm problem or board not found\n"); |
454 | modname); | ||
455 | return -EINVAL; | 448 | return -EINVAL; |
456 | } | 449 | } |
457 | 450 | ||
@@ -468,19 +461,19 @@ static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len) | |||
468 | msleep_interruptible(1 * 1000); | 461 | msleep_interruptible(1 * 1000); |
469 | } | 462 | } |
470 | 463 | ||
471 | printk(KERN_ERR "%s: reset not started.\n", modname); | 464 | pr_err("reset not started\n"); |
472 | return -EINVAL; | 465 | return -EINVAL; |
473 | 466 | ||
474 | reset_loaded: | 467 | reset_loaded: |
475 | /* Load data.bin */ | 468 | /* Load data.bin */ |
476 | if (cycx_data_boot(hw->dpmbase, data_image, img_hdr->data_size)) { | 469 | if (cycx_data_boot(hw->dpmbase, data_image, img_hdr->data_size)) { |
477 | printk(KERN_ERR "%s: cannot load data file.\n", modname); | 470 | pr_err("cannot load data file\n"); |
478 | return -EINVAL; | 471 | return -EINVAL; |
479 | } | 472 | } |
480 | 473 | ||
481 | /* Load code.bin */ | 474 | /* Load code.bin */ |
482 | if (cycx_code_boot(hw->dpmbase, code_image, img_hdr->code_size)) { | 475 | if (cycx_code_boot(hw->dpmbase, code_image, img_hdr->code_size)) { |
483 | printk(KERN_ERR "%s: cannot load code file.\n", modname); | 476 | pr_err("cannot load code file\n"); |
484 | return -EINVAL; | 477 | return -EINVAL; |
485 | } | 478 | } |
486 | 479 | ||
@@ -493,7 +486,7 @@ reset_loaded: | |||
493 | /* Arthur Ganzert's tip: wait a while after the firmware loading... | 486 | /* Arthur Ganzert's tip: wait a while after the firmware loading... |
494 | seg abr 26 17:17:12 EST 1999 - acme */ | 487 | seg abr 26 17:17:12 EST 1999 - acme */ |
495 | msleep_interruptible(7 * 1000); | 488 | msleep_interruptible(7 * 1000); |
496 | printk(KERN_INFO "%s: firmware loaded!\n", modname); | 489 | pr_info("firmware loaded!\n"); |
497 | 490 | ||
498 | /* enable interrupts */ | 491 | /* enable interrupts */ |
499 | cycx_inten(hw); | 492 | cycx_inten(hw); |