aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/atm/fore200e.c
diff options
context:
space:
mode:
authorChas Williams <chas@cmf.nrl.navy.mil>2008-06-17 19:23:11 -0400
committerDavid S. Miller <davem@davemloft.net>2008-06-17 19:23:11 -0400
commite92481f95375aa2702ea5018b0295792ae0fa9c1 (patch)
tree9e3415425daa7a39935c012d1decb8f257ee708d /drivers/atm/fore200e.c
parent7255ca3f3c928fec6d9ce607fed7d0a4f4fca6f7 (diff)
atm: [fore200e] convert to use request_firmware()
Signed-off-by: Chas Williams <chas@cmf.nrl.navy.mil> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/atm/fore200e.c')
-rw-r--r--drivers/atm/fore200e.c130
1 files changed, 65 insertions, 65 deletions
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index 432181ed7bb5..d5c1bbfbe79d 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -36,6 +36,7 @@
36#include <linux/atm_suni.h> 36#include <linux/atm_suni.h>
37#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/firmware.h>
39#include <asm/io.h> 40#include <asm/io.h>
40#include <asm/string.h> 41#include <asm/string.h>
41#include <asm/page.h> 42#include <asm/page.h>
@@ -45,7 +46,7 @@
45#include <asm/uaccess.h> 46#include <asm/uaccess.h>
46#include <asm/atomic.h> 47#include <asm/atomic.h>
47 48
48#ifdef CONFIG_ATM_FORE200E_SBA 49#ifdef CONFIG_SBUS
49#include <asm/idprom.h> 50#include <asm/idprom.h>
50#include <asm/sbus.h> 51#include <asm/sbus.h>
51#include <asm/openprom.h> 52#include <asm/openprom.h>
@@ -382,9 +383,6 @@ fore200e_shutdown(struct fore200e* fore200e)
382 case FORE200E_STATE_START_FW: 383 case FORE200E_STATE_START_FW:
383 /* nothing to do for that state */ 384 /* nothing to do for that state */
384 385
385 case FORE200E_STATE_LOAD_FW:
386 /* nothing to do for that state */
387
388 case FORE200E_STATE_RESET: 386 case FORE200E_STATE_RESET:
389 /* nothing to do for that state */ 387 /* nothing to do for that state */
390 388
@@ -405,7 +403,7 @@ fore200e_shutdown(struct fore200e* fore200e)
405} 403}
406 404
407 405
408#ifdef CONFIG_ATM_FORE200E_PCA 406#ifdef CONFIG_PCI
409 407
410static u32 fore200e_pca_read(volatile u32 __iomem *addr) 408static u32 fore200e_pca_read(volatile u32 __iomem *addr)
411{ 409{
@@ -658,10 +656,10 @@ fore200e_pca_proc_read(struct fore200e* fore200e, char *page)
658 pci_dev->bus->number, PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn)); 656 pci_dev->bus->number, PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
659} 657}
660 658
661#endif /* CONFIG_ATM_FORE200E_PCA */ 659#endif /* CONFIG_PCI */
662 660
663 661
664#ifdef CONFIG_ATM_FORE200E_SBA 662#ifdef CONFIG_SBUS
665 663
666static u32 664static u32
667fore200e_sba_read(volatile u32 __iomem *addr) 665fore200e_sba_read(volatile u32 __iomem *addr)
@@ -907,7 +905,7 @@ fore200e_sba_proc_read(struct fore200e* fore200e, char *page)
907 905
908 return sprintf(page, " SBUS slot/device:\t\t%d/'%s'\n", sbus_dev->slot, sbus_dev->prom_name); 906 return sprintf(page, " SBUS slot/device:\t\t%d/'%s'\n", sbus_dev->slot, sbus_dev->prom_name);
909} 907}
910#endif /* CONFIG_ATM_FORE200E_SBA */ 908#endif /* CONFIG_SBUS */
911 909
912 910
913static void 911static void
@@ -2552,13 +2550,53 @@ fore200e_monitor_puts(struct fore200e* fore200e, char* str)
2552 while (fore200e_monitor_getc(fore200e) >= 0); 2550 while (fore200e_monitor_getc(fore200e) >= 0);
2553} 2551}
2554 2552
2553#ifdef __LITTLE_ENDIAN
2554#define FW_EXT ".bin"
2555#else
2556#define FW_EXT "_ecd.bin2"
2557#endif
2555 2558
2556static int __devinit 2559static int __devinit
2557fore200e_start_fw(struct fore200e* fore200e) 2560fore200e_load_and_start_fw(struct fore200e* fore200e)
2558{ 2561{
2559 int ok; 2562 const struct firmware *firmware;
2560 char cmd[ 48 ]; 2563 struct device *device;
2561 struct fw_header* fw_header = (struct fw_header*) fore200e->bus->fw_data; 2564 struct fw_header *fw_header;
2565 u32 *fw_data, fw_size;
2566 u32 __iomem *load_addr;
2567 char buf[48];
2568 int err = -ENODEV;
2569
2570 if (strcmp(fore200e->bus->model_name, "PCA-200E") == 0)
2571 device = &((struct pci_dev *) fore200e->bus_dev)->dev;
2572#ifdef CONFIG_SBUS
2573 else if (strcmp(fore200e->bus->model_name, "SBA-200E") == 0)
2574 device = &((struct sbus_dev *) fore200e->bus_dev)->ofdev.dev;
2575#endif
2576 else
2577 return err;
2578
2579 sprintf(buf, "%s%s", fore200e->bus->proc_name, FW_EXT);
2580 if (request_firmware(&firmware, buf, device) == 1) {
2581 printk(FORE200E "missing %s firmware image\n", fore200e->bus->model_name);
2582 return err;
2583 }
2584
2585 fw_data = (u32 *) firmware->data;
2586 fw_size = firmware->size / sizeof(u32);
2587 fw_header = (struct fw_header *) firmware->data;
2588 load_addr = fore200e->virt_base + le32_to_cpu(fw_header->load_offset);
2589
2590 DPRINTK(2, "device %s firmware being loaded at 0x%p (%d words)\n",
2591 fore200e->name, load_addr, fw_size);
2592
2593 if (le32_to_cpu(fw_header->magic) != FW_HEADER_MAGIC) {
2594 printk(FORE200E "corrupted %s firmware image\n", fore200e->bus->model_name);
2595 goto release;
2596 }
2597
2598 for (; fw_size--; fw_data++, load_addr++)
2599 fore200e->bus->write(le32_to_cpu(*fw_data), load_addr);
2562 2600
2563 DPRINTK(2, "device %s firmware being started\n", fore200e->name); 2601 DPRINTK(2, "device %s firmware being started\n", fore200e->name);
2564 2602
@@ -2567,46 +2605,22 @@ fore200e_start_fw(struct fore200e* fore200e)
2567 fore200e_spin(100); 2605 fore200e_spin(100);
2568#endif 2606#endif
2569 2607
2570 sprintf(cmd, "\rgo %x\r", le32_to_cpu(fw_header->start_offset)); 2608 sprintf(buf, "\rgo %x\r", le32_to_cpu(fw_header->start_offset));
2609 fore200e_monitor_puts(fore200e, buf);
2571 2610
2572 fore200e_monitor_puts(fore200e, cmd); 2611 if (fore200e_io_poll(fore200e, &fore200e->cp_monitor->bstat, BSTAT_CP_RUNNING, 1000) == 0) {
2573
2574 ok = fore200e_io_poll(fore200e, &fore200e->cp_monitor->bstat, BSTAT_CP_RUNNING, 1000);
2575 if (ok == 0) {
2576 printk(FORE200E "device %s firmware didn't start\n", fore200e->name); 2612 printk(FORE200E "device %s firmware didn't start\n", fore200e->name);
2577 return -ENODEV; 2613 goto release;
2578 } 2614 }
2579 2615
2580 printk(FORE200E "device %s firmware started\n", fore200e->name); 2616 printk(FORE200E "device %s firmware started\n", fore200e->name);
2581 2617
2582 fore200e->state = FORE200E_STATE_START_FW; 2618 fore200e->state = FORE200E_STATE_START_FW;
2583 return 0; 2619 err = 0;
2584}
2585 2620
2586 2621release:
2587static int __devinit 2622 release_firmware(firmware);
2588fore200e_load_fw(struct fore200e* fore200e) 2623 return err;
2589{
2590 __le32* fw_data = (__le32*) fore200e->bus->fw_data;
2591 u32 fw_size = (u32) *fore200e->bus->fw_size / sizeof(u32);
2592
2593 struct fw_header* fw_header = (struct fw_header*) fw_data;
2594
2595 u32 __iomem *load_addr = fore200e->virt_base + le32_to_cpu(fw_header->load_offset);
2596
2597 DPRINTK(2, "device %s firmware being loaded at 0x%p (%d words)\n",
2598 fore200e->name, load_addr, fw_size);
2599
2600 if (le32_to_cpu(fw_header->magic) != FW_HEADER_MAGIC) {
2601 printk(FORE200E "corrupted %s firmware image\n", fore200e->bus->model_name);
2602 return -ENODEV;
2603 }
2604
2605 for (; fw_size--; fw_data++, load_addr++)
2606 fore200e->bus->write(le32_to_cpu(*fw_data), load_addr);
2607
2608 fore200e->state = FORE200E_STATE_LOAD_FW;
2609 return 0;
2610} 2624}
2611 2625
2612 2626
@@ -2652,10 +2666,7 @@ fore200e_init(struct fore200e* fore200e)
2652 if (fore200e_reset(fore200e, 1) < 0) 2666 if (fore200e_reset(fore200e, 1) < 0)
2653 return -ENODEV; 2667 return -ENODEV;
2654 2668
2655 if (fore200e_load_fw(fore200e) < 0) 2669 if (fore200e_load_and_start_fw(fore200e) < 0)
2656 return -ENODEV;
2657
2658 if (fore200e_start_fw(fore200e) < 0)
2659 return -ENODEV; 2670 return -ENODEV;
2660 2671
2661 if (fore200e_initialize(fore200e) < 0) 2672 if (fore200e_initialize(fore200e) < 0)
@@ -2689,7 +2700,7 @@ fore200e_init(struct fore200e* fore200e)
2689 return 0; 2700 return 0;
2690} 2701}
2691 2702
2692#ifdef CONFIG_ATM_FORE200E_PCA 2703#ifdef CONFIG_PCI
2693static int __devinit 2704static int __devinit
2694fore200e_pca_detect(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent) 2705fore200e_pca_detect(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
2695{ 2706{
@@ -2804,7 +2815,7 @@ fore200e_module_init(void)
2804 } 2815 }
2805 } 2816 }
2806 2817
2807#ifdef CONFIG_ATM_FORE200E_PCA 2818#ifdef CONFIG_PCI
2808 if (!pci_register_driver(&fore200e_pca_driver)) 2819 if (!pci_register_driver(&fore200e_pca_driver))
2809 return 0; 2820 return 0;
2810#endif 2821#endif
@@ -2821,7 +2832,7 @@ fore200e_module_cleanup(void)
2821{ 2832{
2822 struct fore200e *fore200e, *next; 2833 struct fore200e *fore200e, *next;
2823 2834
2824#ifdef CONFIG_ATM_FORE200E_PCA 2835#ifdef CONFIG_PCI
2825 pci_unregister_driver(&fore200e_pca_driver); 2836 pci_unregister_driver(&fore200e_pca_driver);
2826#endif 2837#endif
2827 2838
@@ -3140,19 +3151,9 @@ static const struct atmdev_ops fore200e_ops =
3140}; 3151};
3141 3152
3142 3153
3143#ifdef CONFIG_ATM_FORE200E_PCA
3144extern const unsigned char _fore200e_pca_fw_data[];
3145extern const unsigned int _fore200e_pca_fw_size;
3146#endif
3147#ifdef CONFIG_ATM_FORE200E_SBA
3148extern const unsigned char _fore200e_sba_fw_data[];
3149extern const unsigned int _fore200e_sba_fw_size;
3150#endif
3151
3152static const struct fore200e_bus fore200e_bus[] = { 3154static const struct fore200e_bus fore200e_bus[] = {
3153#ifdef CONFIG_ATM_FORE200E_PCA 3155#ifdef CONFIG_PCI
3154 { "PCA-200E", "pca200e", 32, 4, 32, 3156 { "PCA-200E", "pca200e", 32, 4, 32,
3155 _fore200e_pca_fw_data, &_fore200e_pca_fw_size,
3156 fore200e_pca_read, 3157 fore200e_pca_read,
3157 fore200e_pca_write, 3158 fore200e_pca_write,
3158 fore200e_pca_dma_map, 3159 fore200e_pca_dma_map,
@@ -3173,9 +3174,8 @@ static const struct fore200e_bus fore200e_bus[] = {
3173 fore200e_pca_proc_read, 3174 fore200e_pca_proc_read,
3174 }, 3175 },
3175#endif 3176#endif
3176#ifdef CONFIG_ATM_FORE200E_SBA 3177#ifdef CONFIG_SBUS
3177 { "SBA-200E", "sba200e", 32, 64, 32, 3178 { "SBA-200E", "sba200e", 32, 64, 32,
3178 _fore200e_sba_fw_data, &_fore200e_sba_fw_size,
3179 fore200e_sba_read, 3179 fore200e_sba_read,
3180 fore200e_sba_write, 3180 fore200e_sba_write,
3181 fore200e_sba_dma_map, 3181 fore200e_sba_dma_map,