cassini: use request_firmware

Firmware blob looks like this...
        __le16 load_address
        unsigned char data[]

[akpm@linux-foundation.org: include vmalloc.h]
Signed-off-by: Jaswinder Singh <jaswinder@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jaswinder Singh 2008-09-22 19:27:10 -07:00 committed by David S. Miller
parent 5e687220a0
commit fcaa40669c
5 changed files with 207 additions and 1523 deletions

View File

@ -74,6 +74,7 @@
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/vmalloc.h>
#include <linux/ioport.h>
#include <linux/pci.h>
#include <linux/mm.h>
@ -91,6 +92,7 @@
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/mutex.h>
#include <linux/firmware.h>
#include <net/checksum.h>
@ -197,6 +199,7 @@ static int link_mode;
MODULE_AUTHOR("Adrian Sun (asun@darksunrising.com)");
MODULE_DESCRIPTION("Sun Cassini(+) ethernet driver");
MODULE_LICENSE("GPL");
MODULE_FIRMWARE("sun/cassini.bin");
module_param(cassini_debug, int, 0);
MODULE_PARM_DESC(cassini_debug, "Cassini bitmapped debugging message enable value");
module_param(link_mode, int, 0);
@ -812,9 +815,44 @@ static int cas_reset_mii_phy(struct cas *cp)
return (limit <= 0);
}
static int cas_saturn_firmware_init(struct cas *cp)
{
const struct firmware *fw;
const char fw_name[] = "sun/cassini.bin";
int err;
if (PHY_NS_DP83065 != cp->phy_id)
return 0;
err = request_firmware(&fw, fw_name, &cp->pdev->dev);
if (err) {
printk(KERN_ERR "cassini: Failed to load firmware \"%s\"\n",
fw_name);
return err;
}
if (fw->size < 2) {
printk(KERN_ERR "cassini: bogus length %zu in \"%s\"\n",
fw->size, fw_name);
err = -EINVAL;
goto out;
}
cp->fw_load_addr= fw->data[1] << 8 | fw->data[0];
cp->fw_size = fw->size - 2;
cp->fw_data = vmalloc(cp->fw_size);
if (!cp->fw_data) {
err = -ENOMEM;
printk(KERN_ERR "cassini: \"%s\" Failed %d\n", fw_name, err);
goto out;
}
memcpy(cp->fw_data, &fw->data[2], cp->fw_size);
out:
release_firmware(fw);
return err;
}
static void cas_saturn_firmware_load(struct cas *cp)
{
cas_saturn_patch_t *patch = cas_saturn_patch;
int i;
cas_phy_powerdown(cp);
@ -833,11 +871,9 @@ static void cas_saturn_firmware_load(struct cas *cp)
/* download new firmware */
cas_phy_write(cp, DP83065_MII_MEM, 0x1);
cas_phy_write(cp, DP83065_MII_REGE, patch->addr);
while (patch->addr) {
cas_phy_write(cp, DP83065_MII_REGD, patch->val);
patch++;
}
cas_phy_write(cp, DP83065_MII_REGE, cp->fw_load_addr);
for (i = 0; i < cp->fw_size; i++)
cas_phy_write(cp, DP83065_MII_REGD, cp->fw_data[i]);
/* enable firmware */
cas_phy_write(cp, DP83065_MII_REGE, 0x8ff8);
@ -5108,6 +5144,9 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
cas_reset(cp, 0);
if (cas_check_invariants(cp))
goto err_out_iounmap;
if (cp->cas_flags & CAS_FLAG_SATURN)
if (cas_saturn_firmware_init(cp))
goto err_out_iounmap;
cp->init_block = (struct cas_init_block *)
pci_alloc_consistent(pdev, sizeof(struct cas_init_block),
@ -5217,6 +5256,9 @@ static void __devexit cas_remove_one(struct pci_dev *pdev)
cp = netdev_priv(dev);
unregister_netdev(dev);
if (cp->fw_data)
vfree(cp->fw_data);
mutex_lock(&cp->pm_mutex);
flush_scheduled_work();
if (cp->hw_running)

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,7 @@ fw-external-y := $(subst ",,$(CONFIG_EXTRA_FIRMWARE))
fw-shipped-$(CONFIG_ATARI_DSP56K) += dsp56k/bootstrap.bin
fw-shipped-$(CONFIG_ATM_AMBASSADOR) += atmsar11.fw
fw-shipped-$(CONFIG_CASSINI) += sun/cassini.bin
fw-shipped-$(CONFIG_COMPUTONE) += intelliport2.bin
fw-shipped-$(CONFIG_DVB_TTUSB_BUDGET) += ttusb-budget/dspbootcode.bin
fw-shipped-$(CONFIG_SMCTR) += tr_smctr.bin

View File

@ -339,3 +339,13 @@ Licence: Allegedly GPLv2+, but no source visible. Marked:
Found in hex form in kernel source.
--------------------------------------------------------------------------
Driver: CASSINI - Sun Cassini
File: sun/cassini.bin
Licence: Unknown
Found in hex form in kernel source.
--------------------------------------------------------------------------

View File

@ -0,0 +1,143 @@
:1000000000827E82090000000000008E8EFFCE82FA
:1000100025FF010FCE8426FF0111CE853DDFE58649
:1000200039B78FF87EC3C2964784F38A009747CECC
:100030008233FF010F9646840C8104270B96468479
:100040000C810827577E8425964784F38A049747B6
:10005000CE8254FF010F9646840C81042638B612D6
:1000600020842026037E8425967BD67CFE8F56BD79
:10007000F7B6FE8F4EBDEC8EBDFAF7BDF728CE82E7
:1000800082FF010F9646840C8104260AB612208452
:100090002027B57E8425BDF71F7E841F964784F3F5
:1000A0008A089747DEE1AD00CE82AFFF010F7E8464
:1000B00025964185102606962385402706BDED002E
:1000C0007E83A2DE42BDEB8E9624840827037E83C6
:1000D000DF967BD67CFE8F56BDF7B6FE8F50BDEC0B
:1000E0008EBDFAF78611C649BDE412CE82EFFF013C
:1000F0000F9646840C81002717C649BDE491240D54
:10010000B612208520260CCE82C1FF010F7E8425E9
:100110007E8416FE8F52BDEC8EBDFAF7866AC64904
:10012000BDE412CE8327FF010F9646840C81002781
:100130000AC649BDE49125067E84257E8416B6183C
:1001400070BB19702A0481AF2E19967BF62007FA2E
:100150002027C4388138270BF62007FA2027CB0840
:100160007E82D3BDF7668674C649BDE412CE837124
:10017000FF010F9646840C8108260AC649BDE4910A
:1001800025067E84257E8416BDF73E260EBDE50934
:100190002606CE82C1FF010F7E8425FE8F54BDEC62
:1001A0008EBDFAF7BDF733860FC651BDE412CE837C
:1001B000B2FF010F9646840C8108265CB61220849B
:1001C0003F813A271C9623854027037E8425C6510C
:1001D000BDE49125037E8425CE82C1FF010F7E847C
:1001E00025BDF8377C007ACE83EEFF010F7E842593
:1001F0009646840C81082620962484082629B61861
:1002000082BB1982B1013B2209B6122084378132A8
:100210002715BDF8447E82C1BDF71FBDF844BDFC63
:1002200029CE8225FF010F39964784FC8A00974723
:10023000CE8434FF011196468403810227037E8514
:100240001E964784FC8A029747DEE1AD008601B71F
:100250001251BDF714B6103184FDB71031BDF81E30
:100260009681D682FE8F5ABDF7B6FE8F5CBDEC8EAE
:10027000BDFAF78608D600C51026028B20C651BDF0
:10028000E412CE8486FF011196468403810227037F
:100290007E850FC651BDE49125037E851E9644855B
:1002A00010260AB61250BA013C851027A8BDF76681
:1002B000CE84B7FF01117E851E96468403810226F7
:1002C00050B612308403810127037E851E96448533
:1002D000102613B61250BA013C85102609CE84535D
:1002E000FF01117E851EB610318A02B71031BD851F
:1002F0001FBDF8377C0080CE84FEFF01117E851E75
:100300009646840381022609B612308403810127B0
:100310000FBDF844BDF70BBDFC29CE8426FF0111AB
:1003200039D622C40FB61230BA12328404270D9681
:100330002285042705CA107E853ACA20D72239862D
:1003400000978318CE1C00BDEB4696578501270207
:100350004F3985022701397F8F7D8604B7120486C5
:1003600008B712078610B7120C8607B71206B68FA9
:100370007DB712708601BA1204B71204010101019F
:100380000101B6120484FE8A02B7120401010101C0
:10039000010186FDB41204B71204B612008408816C
:1003A000082716B68F7D810C27088B04B78F7D7EBA
:1003B000856C860397407E896E8607B712065FF7C5
:1003C0008F825FF78F7FF78F70F78F71F78F72F7DC
:1003D0008F73F78F74F78F75F78F76F78F77F78FA7
:1003E00078F78F79F78F7AF78F7BB612048A10B778
:1003F000120486E4B71270B71207F71205F7120954
:100400008608BA1204B7120486F7B41204B71204AD
:10041000010101010101B61208277F8180260B86A8
:1004200008CE8F79BD897B7E868E8140260B86041F
:10043000CE8F76BD897B7E868E8120260B8602CE6E
:100440008F73BD897B7E868E8110260B8601CE8FB1
:1004500070BD897B7E868E8108260B8608CE8F79BB
:10046000BD897F7E868E8104260B8604CE8F76BD65
:10047000897F7E868E8102260B8A02CE8F73BD898C
:100480007F7E868E810126088601CE8F70BD897F92
:10049000B68F7F810F26037E8747B61209840381BA
:1004A0000327067C12097E85FEB6120684078107A3
:1004B00027088B01B712067E86D5B68F82260A7C66
:1004C0008F824FB712067E85C0B61206843F813FE9
:1004D00027108B08B71206B6120984FCB712097EE2
:1004E00085FECE8F7018CE8F84C60CBD896FCE8FDF
:1004F0008418CE8F70C60CBD896FD683C14F2D0373
:100500007E8740B68F7F8107270F810B2715810DCE
:10051000271B810E27217E8740F78F7B8602B78FAE
:100520007A201CF78F788602B78F772012F78F75A5
:100530008602B78F742008F78F728602B78F717E9C
:100540008747860497407E896ECE8F72BD89F7CE2D
:100550008F75BD89F7CE8F78BD89F7CE8F7BBD892A
:10056000F74FB78F7DB78F81B68F7227477C8F7D0E
:10057000B68F75273F7C8F7DB68F7827377C8F7D30
:10058000B68F7B272F7F8F7D7C8F817A8F72271B81
:100590007C8F7D7A8F7527167C8F7D7A8F782711D7
:1005A0007C8F7D7A8F7B270C7E87837A8F757A8FFD
:1005B000787A8F7BCEC1FCF68F7D3AA600B7127099
:1005C000B68F7226037E87FAB68F75260A18CE8FED
:1005D00073BD89D57E87FAB68F78260A18CE8F76B6
:1005E000BD89D57E87FAB68F7B260A18CE8F79BD56
:1005F00089D57E87FA860597407E8900B68F7581FA
:10060000072EF2F61206C4F81BB71206B68F7881D1
:10061000072EE2484848F61206C4C71BB71206B6B2
:100620008F7B81072ECFF61205C4F81BB712058603
:1006300000F68F71BD89948601F68F74BD8994860A
:1006400002F68F77BD89948603F68F7ABD8994CEA2
:100650008F70A60181012707810327037E8866A684
:1006600000B88F818401260B8C8F792C0E08080826
:100670007E8850B612048A40B71204B6120484FB76
:1006800084EFB71204B6120736B68F7C4848B7120B
:10069000078601BA1204B7120401010101010186A3
:1006A000FEB41204B712048602BA1204B71204860A
:1006B000FDB41204B7120432B71207B61200840850
:1006C0008108270F7C82082607867697407E896EF0
:1006D0007E86ECB68F7F810F273CBDE6C7B7120D33
:1006E000BDE6CBB612048A20B71204CEFFFFB612C5
:1006F00000810C26050926F6271CB6120484DFB7F4
:100700001204968381072C057C0083200696838B38
:100710000897837E85417F8F7E8680B7120C860185
:10072000B78F7DB6120C847FB7120C8A80B7120C7B
:10073000860ABD8A06B6120A2A09B6120CBA8F7D3D
:10074000B7120CB68F7E8160271A8B20B78F7EB6CA
:10075000120C849FBA8F7EB7120CB68F7D48B78F6C
:100760007D7E8921B612048A20B71204BD8A0A4F01
:1007700039A60018A7000818085A26F539366C0063
:1007800032BA8F7FB78F7FB612098403A701B612E2
:1007900006843FA70239368603B78F8032C1002610
:1007A00006B78F7C7E89C9C1012718C102270CC1F9
:1007B000032700F68F800505F78F80F68F800505EB
:1007C000F78F80F68F800505F78F80F68F8053F4C2
:1007D00012071BB7120739CE8F70A60018E6001853
:1007E000A700E700A60118E60118A701E701A60285
:1007F00018E60218A702E70239A6008407E600C43B
:10080000385454541BA700394A26FD399622840FC8
:1008100097228601B78F70B61207B78F71F6120C48
:10082000C40FC80FF78F72F68F72B68F71840327CB
:10083000148101271C81022724F48F70272A962215
:100840008A807E8A64F48F70271E96228A107E8AA0
:1008500064F48F70271296228A207E8A64F48F7047
:10086000270696228A409722748F71748F71788F31
:1008700070B68F70851027AFD622C41058B612708C
:1008800081E4273681E1260C96228420441BD6225F
:10089000C4CF20235881C6260D9622844044441B91
:1008A000D622C4AF2011588127260F962284804477
:1008B00044441BD622C46F1B972239270C7C820626
:0D08C000BDD9EDB682077E8AB97F82063968
:00000001FF
/* firmware patch for NS_DP83065 */