Commit e92481f9 authored by Chas Williams's avatar Chas Williams Committed by David S. Miller

atm: [fore200e] convert to use request_firmware()

Signed-off-by: default avatarChas Williams <chas@cmf.nrl.navy.mil>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7255ca3f
......@@ -325,81 +325,22 @@ config ATM_IA_DEBUG
speed of the driver, and the size of your syslog files! When
inactive, they will have only a modest impact on performance.
config ATM_FORE200E_MAYBE
config ATM_FORE200E
tristate "FORE Systems 200E-series"
depends on PCI || SBUS
depends on (PCI || SBUS)
select FW_LOADER
---help---
This is a driver for the FORE Systems 200E-series ATM adapter
cards. It simultaneously supports PCA-200E and SBA-200E models
on PCI and SBUS hosts. Say Y (or M to compile as a module
named fore_200e) here if you have one of these ATM adapters.
Note that the driver will actually be compiled only if you
additionally enable the support for PCA-200E and/or SBA-200E
cards.
See the file <file:Documentation/networking/fore200e.txt> for
further details.
config ATM_FORE200E_PCA
bool "PCA-200E support"
depends on ATM_FORE200E_MAYBE && PCI
help
Say Y here if you want your PCA-200E cards to be probed.
config ATM_FORE200E_PCA_DEFAULT_FW
bool "Use default PCA-200E firmware (normally enabled)"
depends on ATM_FORE200E_PCA
help
Use the default PCA-200E firmware data shipped with the driver.
Normal users do not have to deal with the firmware stuff, so
they should say Y here.
config ATM_FORE200E_PCA_FW
string "Pathname of user-supplied binary firmware"
depends on ATM_FORE200E_PCA && !ATM_FORE200E_PCA_DEFAULT_FW
default ""
help
This defines the pathname of an alternative PCA-200E binary
firmware image supplied by the user. This pathname may be
absolute or relative to the drivers/atm directory.
The driver comes with an adequate firmware image, so normal users do
not have to supply an alternative one. They just say Y to "Use
default PCA-200E firmware" instead.
config ATM_FORE200E_SBA
bool "SBA-200E support"
depends on ATM_FORE200E_MAYBE && SBUS
help
Say Y here if you want your SBA-200E cards to be probed.
config ATM_FORE200E_SBA_DEFAULT_FW
bool "Use default SBA-200E firmware (normally enabled)"
depends on ATM_FORE200E_SBA
help
Use the default SBA-200E firmware data shipped with the driver.
Normal users do not have to deal with the firmware stuff, so
they should say Y here.
config ATM_FORE200E_SBA_FW
string "Pathname of user-supplied binary firmware"
depends on ATM_FORE200E_SBA && !ATM_FORE200E_SBA_DEFAULT_FW
default ""
help
This defines the pathname of an alternative SBA-200E binary
firmware image supplied by the user. This pathname may be
absolute or relative to the drivers/atm directory.
The driver comes with an adequate firmware image, so normal users do
not have to supply an alternative one. They just say Y to "Use
default SBA-200E firmware", above.
config ATM_FORE200E_USE_TASKLET
bool "Defer interrupt work to a tasklet"
depends on (PCI || SBUS) && (ATM_FORE200E_PCA || ATM_FORE200E_SBA)
depends on ATM_FORE200E
default n
help
This defers work to be done by the interrupt handler to a
......@@ -408,7 +349,7 @@ config ATM_FORE200E_USE_TASKLET
config ATM_FORE200E_TX_RETRY
int "Maximum number of tx retries"
depends on (PCI || SBUS) && (ATM_FORE200E_PCA || ATM_FORE200E_SBA)
depends on ATM_FORE200E
default "16"
---help---
Specifies the number of times the driver attempts to transmit
......@@ -425,7 +366,7 @@ config ATM_FORE200E_TX_RETRY
config ATM_FORE200E_DEBUG
int "Debugging level (0-3)"
depends on (PCI || SBUS) && (ATM_FORE200E_PCA || ATM_FORE200E_SBA)
depends on ATM_FORE200E
default "0"
help
Specifies the level of debugging messages issued by the driver.
......@@ -436,12 +377,6 @@ config ATM_FORE200E_DEBUG
the performances of the driver, and the size of your syslog files!
Keep the debugging level to 0 during normal operations.
config ATM_FORE200E
tristate
depends on (PCI || SBUS) && (ATM_FORE200E_PCA || ATM_FORE200E_SBA)
default m if ATM_FORE200E_MAYBE!=y
default y if ATM_FORE200E_MAYBE=y
config ATM_HE
tristate "ForeRunner HE Series"
depends on PCI
......
......@@ -3,14 +3,6 @@
#
fore_200e-objs := fore200e.o
hostprogs-y := fore200e_mkfirm
# Files generated that shall be removed upon make clean
clean-files := atmsar11.bin atmsar11.bin1 atmsar11.bin2 pca200e.bin \
pca200e.bin1 pca200e.bin2 pca200e_ecd.bin pca200e_ecd.bin1 \
pca200e_ecd.bin2 sba200e_ecd.bin sba200e_ecd.bin1 sba200e_ecd.bin2
# Firmware generated that shall be removed upon make clean
clean-files += fore200e_pca_fw.c fore200e_sba_fw.c
obj-$(CONFIG_ATM_ZATM) += zatm.o uPD98402.o
obj-$(CONFIG_ATM_NICSTAR) += nicstar.o
......@@ -36,38 +28,7 @@ obj-$(CONFIG_ATM_TCP) += atmtcp.o
obj-$(CONFIG_ATM_FIRESTREAM) += firestream.o
obj-$(CONFIG_ATM_LANAI) += lanai.o
ifeq ($(CONFIG_ATM_FORE200E_PCA),y)
fore_200e-objs += fore200e_pca_fw.o
# guess the target endianess to choose the right PCA-200E firmware image
ifeq ($(CONFIG_ATM_FORE200E_PCA_DEFAULT_FW),y)
byteorder.h := include$(if $(patsubst $(srctree),,$(objtree)),2)/asm/byteorder.h
CONFIG_ATM_FORE200E_PCA_FW := $(obj)/pca200e$(if $(shell $(CC) $(KBUILD_CPPFLAGS) -E -dM $(byteorder.h) | grep ' __LITTLE_ENDIAN '),.bin,_ecd.bin2)
endif
endif
ifeq ($(CONFIG_ATM_FORE200E_SBA),y)
fore_200e-objs += fore200e_sba_fw.o
ifeq ($(CONFIG_ATM_FORE200E_SBA_DEFAULT_FW),y)
CONFIG_ATM_FORE200E_SBA_FW := $(obj)/sba200e_ecd.bin2
endif
endif
obj-$(CONFIG_ATM_HE) += he.o
ifeq ($(CONFIG_ATM_HE_USE_SUNI),y)
obj-$(CONFIG_ATM_HE) += suni.o
endif
# FORE Systems 200E-series firmware magic
$(obj)/fore200e_pca_fw.c: $(patsubst "%", %, $(CONFIG_ATM_FORE200E_PCA_FW)) \
$(obj)/fore200e_mkfirm
$(obj)/fore200e_mkfirm -k -b _fore200e_pca_fw \
-i $(CONFIG_ATM_FORE200E_PCA_FW) -o $@
$(obj)/fore200e_sba_fw.c: $(patsubst "%", %, $(CONFIG_ATM_FORE200E_SBA_FW)) \
$(obj)/fore200e_mkfirm
$(obj)/fore200e_mkfirm -k -b _fore200e_sba_fw \
-i $(CONFIG_ATM_FORE200E_SBA_FW) -o $@
# deal with the various suffixes of the binary firmware images
$(obj)/%.bin $(obj)/%.bin1 $(obj)/%.bin2: $(src)/%.data
objcopy -Iihex $< -Obinary $@.gz
gzip -n -df $@.gz
......@@ -36,6 +36,7 @@
#include <linux/atm_suni.h>
#include <linux/dma-mapping.h>
#include <linux/delay.h>
#include <linux/firmware.h>
#include <asm/io.h>
#include <asm/string.h>
#include <asm/page.h>
......@@ -45,7 +46,7 @@
#include <asm/uaccess.h>
#include <asm/atomic.h>
#ifdef CONFIG_ATM_FORE200E_SBA
#ifdef CONFIG_SBUS
#include <asm/idprom.h>
#include <asm/sbus.h>
#include <asm/openprom.h>
......@@ -382,9 +383,6 @@ fore200e_shutdown(struct fore200e* fore200e)
case FORE200E_STATE_START_FW:
/* nothing to do for that state */
case FORE200E_STATE_LOAD_FW:
/* nothing to do for that state */
case FORE200E_STATE_RESET:
/* nothing to do for that state */
......@@ -405,7 +403,7 @@ fore200e_shutdown(struct fore200e* fore200e)
}
#ifdef CONFIG_ATM_FORE200E_PCA
#ifdef CONFIG_PCI
static u32 fore200e_pca_read(volatile u32 __iomem *addr)
{
......@@ -658,10 +656,10 @@ fore200e_pca_proc_read(struct fore200e* fore200e, char *page)
pci_dev->bus->number, PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
}
#endif /* CONFIG_ATM_FORE200E_PCA */
#endif /* CONFIG_PCI */
#ifdef CONFIG_ATM_FORE200E_SBA
#ifdef CONFIG_SBUS
static u32
fore200e_sba_read(volatile u32 __iomem *addr)
......@@ -907,7 +905,7 @@ fore200e_sba_proc_read(struct fore200e* fore200e, char *page)
return sprintf(page, " SBUS slot/device:\t\t%d/'%s'\n", sbus_dev->slot, sbus_dev->prom_name);
}
#endif /* CONFIG_ATM_FORE200E_SBA */
#endif /* CONFIG_SBUS */
static void
......@@ -2552,13 +2550,53 @@ fore200e_monitor_puts(struct fore200e* fore200e, char* str)
while (fore200e_monitor_getc(fore200e) >= 0);
}
#ifdef __LITTLE_ENDIAN
#define FW_EXT ".bin"
#else
#define FW_EXT "_ecd.bin2"
#endif
static int __devinit
fore200e_start_fw(struct fore200e* fore200e)
{
int ok;
char cmd[ 48 ];
struct fw_header* fw_header = (struct fw_header*) fore200e->bus->fw_data;
fore200e_load_and_start_fw(struct fore200e* fore200e)
{
const struct firmware *firmware;
struct device *device;
struct fw_header *fw_header;
u32 *fw_data, fw_size;
u32 __iomem *load_addr;
char buf[48];
int err = -ENODEV;
if (strcmp(fore200e->bus->model_name, "PCA-200E") == 0)
device = &((struct pci_dev *) fore200e->bus_dev)->dev;
#ifdef CONFIG_SBUS
else if (strcmp(fore200e->bus->model_name, "SBA-200E") == 0)
device = &((struct sbus_dev *) fore200e->bus_dev)->ofdev.dev;
#endif
else
return err;
sprintf(buf, "%s%s", fore200e->bus->proc_name, FW_EXT);
if (request_firmware(&firmware, buf, device) == 1) {
printk(FORE200E "missing %s firmware image\n", fore200e->bus->model_name);
return err;
}
fw_data = (u32 *) firmware->data;
fw_size = firmware->size / sizeof(u32);
fw_header = (struct fw_header *) firmware->data;
load_addr = fore200e->virt_base + le32_to_cpu(fw_header->load_offset);
DPRINTK(2, "device %s firmware being loaded at 0x%p (%d words)\n",
fore200e->name, load_addr, fw_size);
if (le32_to_cpu(fw_header->magic) != FW_HEADER_MAGIC) {
printk(FORE200E "corrupted %s firmware image\n", fore200e->bus->model_name);
goto release;
}
for (; fw_size--; fw_data++, load_addr++)
fore200e->bus->write(le32_to_cpu(*fw_data), load_addr);
DPRINTK(2, "device %s firmware being started\n", fore200e->name);
......@@ -2567,46 +2605,22 @@ fore200e_start_fw(struct fore200e* fore200e)
fore200e_spin(100);
#endif
sprintf(cmd, "\rgo %x\r", le32_to_cpu(fw_header->start_offset));
sprintf(buf, "\rgo %x\r", le32_to_cpu(fw_header->start_offset));
fore200e_monitor_puts(fore200e, buf);
fore200e_monitor_puts(fore200e, cmd);
ok = fore200e_io_poll(fore200e, &fore200e->cp_monitor->bstat, BSTAT_CP_RUNNING, 1000);
if (ok == 0) {
if (fore200e_io_poll(fore200e, &fore200e->cp_monitor->bstat, BSTAT_CP_RUNNING, 1000) == 0) {
printk(FORE200E "device %s firmware didn't start\n", fore200e->name);
return -ENODEV;
goto release;
}
printk(FORE200E "device %s firmware started\n", fore200e->name);
fore200e->state = FORE200E_STATE_START_FW;
return 0;
}
err = 0;
static int __devinit
fore200e_load_fw(struct fore200e* fore200e)
{
__le32* fw_data = (__le32*) fore200e->bus->fw_data;
u32 fw_size = (u32) *fore200e->bus->fw_size / sizeof(u32);
struct fw_header* fw_header = (struct fw_header*) fw_data;
u32 __iomem *load_addr = fore200e->virt_base + le32_to_cpu(fw_header->load_offset);
DPRINTK(2, "device %s firmware being loaded at 0x%p (%d words)\n",
fore200e->name, load_addr, fw_size);
if (le32_to_cpu(fw_header->magic) != FW_HEADER_MAGIC) {
printk(FORE200E "corrupted %s firmware image\n", fore200e->bus->model_name);
return -ENODEV;
}
for (; fw_size--; fw_data++, load_addr++)
fore200e->bus->write(le32_to_cpu(*fw_data), load_addr);
fore200e->state = FORE200E_STATE_LOAD_FW;
return 0;
release:
release_firmware(firmware);
return err;
}
......@@ -2652,10 +2666,7 @@ fore200e_init(struct fore200e* fore200e)
if (fore200e_reset(fore200e, 1) < 0)
return -ENODEV;
if (fore200e_load_fw(fore200e) < 0)
return -ENODEV;
if (fore200e_start_fw(fore200e) < 0)
if (fore200e_load_and_start_fw(fore200e) < 0)
return -ENODEV;
if (fore200e_initialize(fore200e) < 0)
......@@ -2689,7 +2700,7 @@ fore200e_init(struct fore200e* fore200e)
return 0;
}
#ifdef CONFIG_ATM_FORE200E_PCA
#ifdef CONFIG_PCI
static int __devinit
fore200e_pca_detect(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
{
......@@ -2804,7 +2815,7 @@ fore200e_module_init(void)
}
}
#ifdef CONFIG_ATM_FORE200E_PCA
#ifdef CONFIG_PCI
if (!pci_register_driver(&fore200e_pca_driver))
return 0;
#endif
......@@ -2821,7 +2832,7 @@ fore200e_module_cleanup(void)
{
struct fore200e *fore200e, *next;
#ifdef CONFIG_ATM_FORE200E_PCA
#ifdef CONFIG_PCI
pci_unregister_driver(&fore200e_pca_driver);
#endif
......@@ -3140,19 +3151,9 @@ static const struct atmdev_ops fore200e_ops =
};
#ifdef CONFIG_ATM_FORE200E_PCA
extern const unsigned char _fore200e_pca_fw_data[];
extern const unsigned int _fore200e_pca_fw_size;
#endif
#ifdef CONFIG_ATM_FORE200E_SBA
extern const unsigned char _fore200e_sba_fw_data[];
extern const unsigned int _fore200e_sba_fw_size;
#endif
static const struct fore200e_bus fore200e_bus[] = {
#ifdef CONFIG_ATM_FORE200E_PCA
#ifdef CONFIG_PCI
{ "PCA-200E", "pca200e", 32, 4, 32,
_fore200e_pca_fw_data, &_fore200e_pca_fw_size,
fore200e_pca_read,
fore200e_pca_write,
fore200e_pca_dma_map,
......@@ -3173,9 +3174,8 @@ static const struct fore200e_bus fore200e_bus[] = {
fore200e_pca_proc_read,
},
#endif
#ifdef CONFIG_ATM_FORE200E_SBA
#ifdef CONFIG_SBUS
{ "SBA-200E", "sba200e", 32, 64, 32,
_fore200e_sba_fw_data, &_fore200e_sba_fw_size,
fore200e_sba_read,
fore200e_sba_write,
fore200e_sba_dma_map,
......
......@@ -754,7 +754,6 @@ typedef enum fore200e_state {
FORE200E_STATE_CONFIGURE, /* bus interface configured */
FORE200E_STATE_MAP, /* board space mapped in host memory */
FORE200E_STATE_RESET, /* board resetted */
FORE200E_STATE_LOAD_FW, /* firmware loaded */
FORE200E_STATE_START_FW, /* firmware started */
FORE200E_STATE_INITIALIZE, /* initialize command successful */
FORE200E_STATE_INIT_CMDQ, /* command queue initialized */
......@@ -803,8 +802,6 @@ typedef struct fore200e_bus {
int descr_alignment; /* tpd/rpd/rbd DMA alignment requirement */
int buffer_alignment; /* rx buffers DMA alignment requirement */
int status_alignment; /* status words DMA alignment requirement */
const unsigned char* fw_data; /* address of firmware data start */
const unsigned int* fw_size; /* address of firmware data size */
u32 (*read)(volatile u32 __iomem *);
void (*write)(u32, volatile u32 __iomem *);
u32 (*dma_map)(struct fore200e*, void*, int, int);
......
These microcode data are placed under the terms of the GNU General Public License.
We would prefer you not to distribute modified versions of it and not to ask
for assembly or other microcode source.
Copyright (c) 1995-2000 FORE Systems, Inc., as an unpublished work. This
notice does not imply unrestricted or public access to these materials which
are a trade secret of FORE Systems, Inc. or its subsidiaries or affiliates
(together referred to as "FORE"), and which may not be reproduced, used, sold
or transferred to any third party without FORE's prior written consent. All
rights reserved.
U.S. Government Restricted Rights. If you are licensing the Software on
behalf of the U.S. Government ("Government"), the following provisions apply
to you. If the software is supplied to the Department of Defense ("DoD"), it
is classified as "Commercial Computer Software" under paragraph 252.227-7014
of the DoD Supplement to the Federal Acquisition Regulations ("DFARS") (or any
successor regulations) and the Government is acquiring only the license
rights granted herein (the license rights customarily provided to non-Government
users). If the Software is supplied to any unit or agency of the Government
other than the DoD, it is classified as "Restricted Computer Software" and
the Government's rights in the Software are defined in paragraph 52.227-19 of
the Federal Acquisition Regulations ("FAR") (or any successor regulations) or,
in the cases of NASA, in paragraph 18.52.227-86 of the NASA Supplement to the FAR
(or any successor regulations).
FORE Systems is a registered trademark, and ForeRunner, ForeRunnerLE, and
ForeThought are trademarks of FORE Systems, Inc. All other brands or product
names are trademarks or registered trademarks of their respective holders.
/*
mkfirm.c: generates a C readable file from a binary firmware image
Christophe Lizzi (lizzi@{csti.fr, cnam.fr}), June 1999.
This software may be used and distributed according to the terms
of the GNU General Public License, incorporated herein by reference.
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <time.h>
char* default_basename = "pca200e"; /* was initially written for the PCA-200E firmware */
char* default_infname = "<stdin>";
char* default_outfname = "<stdout>";
char* progname;
int verbose = 0;
int inkernel = 0;
void usage(void)
{
fprintf(stderr,
"%s: [-v] [-k] [-b basename ] [-i firmware.bin] [-o firmware.c]\n",
progname);
exit(-1);
}
int main(int argc, char** argv)
{
time_t now;
char* infname = NULL;
char* outfname = NULL;
char* basename = NULL;
FILE* infile;
FILE* outfile;
unsigned firmsize;
int c;
progname = *(argv++);
while (argc > 1) {
if ((*argv)[0] == '-') {
switch ((*argv)[1]) {
case 'i':
if (argc-- < 3)
usage();
infname = *(++argv);
break;
case 'o':
if (argc-- < 3)
usage();
outfname = *(++argv);
break;
case 'b':
if (argc-- < 3)
usage();
basename = *(++argv);
break;
case 'v':
verbose = 1;
break;
case 'k':
inkernel = 1;
break;
default:
usage();
}
}
else {
usage();
}
argc--;
argv++;
}
if (infname != NULL) {
infile = fopen(infname, "r");
if (infile == NULL) {
fprintf(stderr, "%s: can't open %s for reading\n",
progname, infname);
exit(-2);
}
}
else {
infile = stdin;
infname = default_infname;
}
if (outfname) {
outfile = fopen(outfname, "w");
if (outfile == NULL) {
fprintf(stderr, "%s: can't open %s for writing\n",
progname, outfname);
exit(-3);
}
}
else {
outfile = stdout;
outfname = default_outfname;
}
if (basename == NULL)
basename = default_basename;
if (verbose) {
fprintf(stderr, "%s: input file = %s\n", progname, infname );
fprintf(stderr, "%s: output file = %s\n", progname, outfname );
fprintf(stderr, "%s: firmware basename = %s\n", progname, basename );
}
time(&now);
fprintf(outfile, "/*\n generated by %s from %s on %s"
" DO NOT EDIT!\n*/\n\n",
progname, infname, ctime(&now));
if (inkernel)
fprintf(outfile, "#include <linux/init.h>\n\n" );
/* XXX force 32 bit alignment? */
fprintf(outfile, "const unsigned char%s %s_data[] = {\n",
inkernel ? " __initdata" : "", basename );
c = getc(infile);
fprintf(outfile,"\t0x%02x", c);
firmsize = 1;
while ((c = getc(infile)) >= 0) {
if (firmsize++ % 8)
fprintf(outfile,", 0x%02x", c);
else
fprintf(outfile,",\n\t0x%02x", c);
}
fprintf(outfile, "\n};\n\n");
fprintf(outfile, "const unsigned int%s %s_size = %u;\n",
inkernel ? " __initdata" : "", basename, firmsize );
if (infile != stdin)
fclose(infile);
if (outfile != stdout)
fclose(outfile);
if(verbose)
fprintf(stderr, "%s: firmware size = %u\n", progname, firmsize);
exit(0);
}
This diff is collapsed.
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