starfire: use request_firmware()
Subsystems (3)
PATCH 4/4 starfire: use request_firmware()
Firmware blob is big endian
Signed-off-by Jaswinder Singh Rajput <[email protected]>
--- drivers/net/starfire.c | 54 +++++- drivers/net/starfire_firmware.h | 346 --------------------------------- drivers/net/starfire_firmware.pl | 31 --- firmware/Makefile | 2 + firmware/WHENCE | 19 ++ firmware/adaptec/starfire_rx.bin.ihex | 53 +++++ firmware/adaptec/starfire_tx.bin.ihex | 53 +++++ 7 files changed, 175 insertions(+), 383 deletions(-) delete mode 100644 drivers/net/starfire_firmware.h delete mode 100644 drivers/net/starfire_firmware.pl create mode 100644 firmware/adaptec/starfire_rx.bin.ihex create mode 100644 firmware/adaptec/starfire_tx.bin.ihex
drivers/net/starfire.c +48 -6
@@ -42,11 +42,11 @@#include <linux/mii.h> #include <linux/if_vlan.h> #include <linux/mm.h> +#include <linux/firmware.h> #include <asm/processor.h> /* Processor type for cache alignment. */ #include <asm/uaccess.h> #include <asm/io.h> -#include "starfire_firmware.h" /* * The current frame processor firmware fails to checksum a fragment * of length 1. If and when this is fixed, the #define below can be removed.
@@ -173,6 +173,10 @@ static int full_duplex[MAX_UNITS] = {0, };#define skb_first_frag_len (skb) skb_headlen(skb)#define skb_num_frags (skb) (skb_shinfo(skb)->nr_frags + 1) +/* Firmware names */ +#define FIRMWARE_RX "adaptec/starfire_rx.bin" +#define FIRMWARE_TX "adaptec/starfire_tx.bin" +/* These identify the driver base version and may not be removed. */ static char version[] =KERN_INFO "starfire.c:v1.03 7/26/2000 Written by Donald Becker <[email protected]>\n"
@@ -182,6 +186,8 @@ MODULE_AUTHOR("Donald Becker <[email protected]>");MODULE_DESCRIPTION ("Adaptec Starfire Ethernet driver" );MODULE_LICENSE ("GPL" );MODULE_VERSION (DRV_VERSION ); +MODULE_FIRMWARE (FIRMWARE_RX ); +MODULE_FIRMWARE (FIRMWARE_TX );module_param (max_interrupt_work, int,0 );module_param (mtu, int,0 );
@@ -902,9 +908,12 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int valstatic int netdev_open (struct net_device *dev) { +const struct firmware *fw_rx, *fw_tx; +const __be32 *fw_rx_data, *fw_tx_data;struct netdev_private *np =netdev_priv (dev);void __iomem *ioaddr = np->base;int i, retval; +size_t tx_size, rx_size;size_t tx_done_q_size, rx_done_q_size, tx_ring_size, rx_ring_size;/* Do we ever need to reset the chip??? */
@@ -1040,11 +1049,40 @@ static int netdev_open(struct net_device *dev)writel (ETH_P_8021Q , ioaddr + VlanType);#endif /* VLAN_SUPPORT */ + retval =request_firmware (&fw_rx,FIRMWARE_RX , &np->pci_dev->dev); +if (retval) { +printk (KERN_ERR "starfire: Failed to load firmware \"%s\"\n" , +FIRMWARE_RX ); +return retval; + } +if (fw_rx->size %4 ) { +printk (KERN_ERR "starfire: bogus length %zu in \"%s\"\n" , + fw_rx->size,FIRMWARE_RX ); + retval = -EINVAL ; + goto out_rx; + } + retval =request_firmware (&fw_tx,FIRMWARE_TX , &np->pci_dev->dev); +if (retval) { +printk (KERN_ERR "starfire: Failed to load firmware \"%s\"\n" , +FIRMWARE_TX ); + goto out_rx; + } +if (fw_tx->size %4 ) { +printk (KERN_ERR "starfire: bogus length %zu in \"%s\"\n" , + fw_tx->size,FIRMWARE_TX ); + retval = -EINVAL ; + goto out_tx; + } + fw_rx_data = (const __be32 *)&fw_rx->data[0 ]; + fw_tx_data = (const __be32 *)&fw_tx->data[0 ]; + rx_size = fw_rx->size /4 ; + tx_size = fw_tx->size /4 ; +/* Load Rx/Tx firmware into the frame processors */ -for (i =0 ; i <FIRMWARE_RX_SIZE *2 ; i++) -writel (firmware_rx[i], ioaddr + RxGfpMem + i *4 ); -for (i =0 ; i <FIRMWARE_TX_SIZE *2 ; i++) -writel (firmware_tx[i], ioaddr + TxGfpMem + i *4 ); +for (i =0 ; i < rx_size; i++) +writel (be32_to_cpup (&fw_rx_data[i]), ioaddr + RxGfpMem + i *4 ); +for (i =0 ; i < tx_size; i++) +writel (be32_to_cpup (&fw_tx_data[i]), ioaddr + TxGfpMem + i *4 );if (enable_hw_cksum)/* Enable the Rx and Tx units, and the Rx/Tx frame processors. */ writel (TxEnable|TxGFPEnable|RxEnable|RxGFPEnable, ioaddr + GenCtrl);
@@ -1056,7 +1094,11 @@ static int netdev_open(struct net_device *dev)printk (KERN_DEBUG "%s: Done netdev_open().\n" , dev->name); -return 0 ; +out_tx: +release_firmware (fw_tx); +out_rx: +release_firmware (fw_rx); +return retval; }
drivers/net/starfire_firmware.h deleted +0 -346
346 lines not on this page · raw message
drivers/net/starfire_firmware.pl deleted +0 -31
@@ -1,31 +0,0 @@ -#!/usr/bin/perl - -# This script can be used to generate a new starfire_firmware.h -# from GFP_RX.DAT and GFP_TX.DAT, files included with the DDK -# and also with the Novell drivers. - -open FW, "GFP_RX.DAT" || die; -open FWH, ">starfire_firmware.h" || die; - -printf(FWH "static u32 firmware_rx[] = {\n"); -$counter = 0; -while ($foo = <FW>) { - chomp; - printf(FWH " 0x%s, 0x0000%s,\n", substr($foo, 4, 8), substr($foo, 0, 4)); - $counter++; -} - -close FW; -open FW, "GFP_TX.DAT" || die; - -printf(FWH "};\t/* %d Rx instructions */\n#define FIRMWARE_RX_SIZE %d\n\nstatic u32 firmware_tx[] = {\n", $counter, $counter); -$counter = 0; -while ($foo = <FW>) { - chomp; - printf(FWH " 0x%s, 0x0000%s,\n", substr($foo, 4, 8), substr($foo, 0, 4)); - $counter++; -} - -close FW; -printf(FWH "};\t/* %d Tx instructions */\n#define FIRMWARE_TX_SIZE %d\n", $counter, $counter); -close(FWH);
firmware/Makefile +2 -0
@@ -27,6 +27,8 @@ else acenic-objs := acenic/tg1.bin acenic/tg2.bin endif fw-shipped-$(CONFIG_ACENIC) += $(acenic-objs) +fw-shipped-$(CONFIG_ADAPTEC_STARFIRE) += adaptec/starfire_rx.bin \ + adaptec/starfire_tx.bin fw-shipped-$(CONFIG_ATARI_DSP56K) += dsp56k/bootstrap.bin fw-shipped-$(CONFIG_ATM_AMBASSADOR) += atmsar11.fw fw-shipped-$(CONFIG_CASSINI) += sun/cassini.bin
firmware/WHENCE +19 -0
@@ -402,3 +402,22 @@ Licence: Found in hex form in kernel source. -------------------------------------------------------------------------- + +Driver: ADAPTEC_STARFIRE - Adaptec Starfire/DuraLAN support + +File: adaptec/starfire_rx.bin +File: adaptec/starfire_tx.bin + +Licence: Allegedly GPLv2, but no source visible. + +Found in hex form in kernel source, with the following notice: + + BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE IT IS LICENSED "AS IS" AND + THERE IS NO WARRANTY FOR THE PROGRAM, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTIBILITY OR FITNESS FOR A PARTICULAR PURPOSE + (TO THE EXTENT PERMITTED BY APPLICABLE LAW). USE OF THE PROGRAM IS AT YOUR + OWN RISK. IN NO EVENT WILL ADAPTEC OR ITS LICENSORS BE LIABLE TO YOU FOR + DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES + ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM. + +--------------------------------------------------------------------------
firmware/adaptec/starfire_rx.bin.ihex new file +53 -0
53 lines not on this page · raw message
firmware/adaptec/starfire_tx.bin.ihex new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
1.5.5.1
From: Jaswinder Singh Rajput <[email protected]>
Date: Tue, 30 Dec 2008 14:11:50 +0530
Quoted 3 lines
Firmware blob is big endian
Signed-off-by Jaswinder Singh Rajput <[email protected]>
Applied.