Commit cd36e9ef authored by Jaswinder Singh Rajput's avatar Jaswinder Singh Rajput Committed by David S. Miller

myri_sbus: use request_firmware

Firmware blob looks like this...

        __be16 lanai4_data_size
        unsigned char lanai4_code[]
Signed-off-by: default avatarJaswinder Singh Rajput <jaswinderrajput@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 81c52285
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -25,6 +25,7 @@ static char version[] = ...@@ -25,6 +25,7 @@ static char version[] =
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/firmware.h>
#include <net/dst.h> #include <net/dst.h>
#include <net/arp.h> #include <net/arp.h>
...@@ -43,7 +44,6 @@ static char version[] = ...@@ -43,7 +44,6 @@ static char version[] =
#include <asm/irq.h> #include <asm/irq.h>
#include "myri_sbus.h" #include "myri_sbus.h"
#include "myri_code.h"
/* #define DEBUG_DETECT */ /* #define DEBUG_DETECT */
/* #define DEBUG_IRQ */ /* #define DEBUG_IRQ */
...@@ -81,6 +81,9 @@ static char version[] = ...@@ -81,6 +81,9 @@ static char version[] =
#define DHDR(x) #define DHDR(x)
#endif #endif
/* Firmware name */
#define FWNAME "myricom/lanai.bin"
static void myri_reset_off(void __iomem *lp, void __iomem *cregs) static void myri_reset_off(void __iomem *lp, void __iomem *cregs)
{ {
/* Clear IRQ mask. */ /* Clear IRQ mask. */
...@@ -171,10 +174,11 @@ static int myri_do_handshake(struct myri_eth *mp) ...@@ -171,10 +174,11 @@ static int myri_do_handshake(struct myri_eth *mp)
static int __devinit myri_load_lanai(struct myri_eth *mp) static int __devinit myri_load_lanai(struct myri_eth *mp)
{ {
const struct firmware *fw;
struct net_device *dev = mp->dev; struct net_device *dev = mp->dev;
struct myri_shmem __iomem *shmem = mp->shmem; struct myri_shmem __iomem *shmem = mp->shmem;
void __iomem *rptr; void __iomem *rptr;
int i; int i, lanai4_data_size;
myri_disable_irq(mp->lregs, mp->cregs); myri_disable_irq(mp->lregs, mp->cregs);
myri_reset_on(mp->cregs); myri_reset_on(mp->cregs);
...@@ -186,13 +190,27 @@ static int __devinit myri_load_lanai(struct myri_eth *mp) ...@@ -186,13 +190,27 @@ static int __devinit myri_load_lanai(struct myri_eth *mp)
if (mp->eeprom.cpuvers >= CPUVERS_3_0) if (mp->eeprom.cpuvers >= CPUVERS_3_0)
sbus_writel(mp->eeprom.cval, mp->lregs + LANAI_CVAL); sbus_writel(mp->eeprom.cval, mp->lregs + LANAI_CVAL);
i = request_firmware(&fw, FWNAME, &mp->myri_op->dev);
if (i) {
printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
FWNAME, i);
return i;
}
if (fw->size < 2) {
printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
fw->size, FWNAME);
release_firmware(fw);
return -EINVAL;
}
lanai4_data_size = fw->data[0] << 8 | fw->data[1];
/* Load executable code. */ /* Load executable code. */
for (i = 0; i < sizeof(lanai4_code); i++) for (i = 2; i < fw->size; i++)
sbus_writeb(lanai4_code[i], rptr + (lanai4_code_off * 2) + i); sbus_writeb(fw->data[i], rptr++);
/* Load data segment. */ /* Load data segment. */
for (i = 0; i < sizeof(lanai4_data); i++) for (i = 0; i < lanai4_data_size; i++)
sbus_writeb(lanai4_data[i], rptr + (lanai4_data_off * 2) + i); sbus_writeb(0, rptr++);
/* Set device address. */ /* Set device address. */
sbus_writeb(0, &shmem->addr[0]); sbus_writeb(0, &shmem->addr[0]);
...@@ -228,6 +246,7 @@ static int __devinit myri_load_lanai(struct myri_eth *mp) ...@@ -228,6 +246,7 @@ static int __devinit myri_load_lanai(struct myri_eth *mp)
if (mp->eeprom.cpuvers == CPUVERS_4_0) if (mp->eeprom.cpuvers == CPUVERS_4_0)
sbus_writel(0, mp->lregs + LANAI_VERS); sbus_writel(0, mp->lregs + LANAI_VERS);
release_firmware(fw);
return i; return i;
} }
...@@ -1078,7 +1097,10 @@ static int __devinit myri_sbus_probe(struct of_device *op, const struct of_devic ...@@ -1078,7 +1097,10 @@ static int __devinit myri_sbus_probe(struct of_device *op, const struct of_devic
/* Load code onto the LANai. */ /* Load code onto the LANai. */
DET(("Loading LANAI firmware\n")); DET(("Loading LANAI firmware\n"));
myri_load_lanai(mp); if (myri_load_lanai(mp)) {
printk(KERN_ERR "MyriCOM: Cannot Load LANAI firmware.\n");
goto err_free_irq;
}
if (register_netdev(dev)) { if (register_netdev(dev)) {
printk("MyriCOM: Cannot register device.\n"); printk("MyriCOM: Cannot register device.\n");
...@@ -1159,3 +1181,4 @@ module_init(myri_sbus_init); ...@@ -1159,3 +1181,4 @@ module_init(myri_sbus_init);
module_exit(myri_sbus_exit); module_exit(myri_sbus_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_FIRMWARE(FWNAME);
...@@ -40,6 +40,7 @@ fw-shipped-$(CONFIG_CHELSIO_T3) += cxgb3/t3b_psram-1.1.0.bin \ ...@@ -40,6 +40,7 @@ fw-shipped-$(CONFIG_CHELSIO_T3) += cxgb3/t3b_psram-1.1.0.bin \
fw-shipped-$(CONFIG_DVB_TTUSB_BUDGET) += ttusb-budget/dspbootcode.bin fw-shipped-$(CONFIG_DVB_TTUSB_BUDGET) += ttusb-budget/dspbootcode.bin
fw-shipped-$(CONFIG_E100) += e100/d101m_ucode.bin e100/d101s_ucode.bin \ fw-shipped-$(CONFIG_E100) += e100/d101m_ucode.bin e100/d101s_ucode.bin \
e100/d102e_ucode.bin e100/d102e_ucode.bin
fw-shipped-$(CONFIG_MYRI_SBUS) += myricom/lanai.bin
fw-shipped-$(CONFIG_PCMCIA_SMC91C92) += ositech/Xilinx7OD.bin fw-shipped-$(CONFIG_PCMCIA_SMC91C92) += ositech/Xilinx7OD.bin
fw-shipped-$(CONFIG_SMCTR) += tr_smctr.bin fw-shipped-$(CONFIG_SMCTR) += tr_smctr.bin
fw-shipped-$(CONFIG_SND_KORG1212) += korg/k1212.dsp fw-shipped-$(CONFIG_SND_KORG1212) += korg/k1212.dsp
......
...@@ -543,3 +543,13 @@ Licence: Allegedly GPL, but no source visible. Marked: ...@@ -543,3 +543,13 @@ Licence: Allegedly GPL, but no source visible. Marked:
Found in hex form in kernel source. Found in hex form in kernel source.
-------------------------------------------------------------------------- --------------------------------------------------------------------------
Driver: MYRI_SBUS - MyriCOM Gigabit Ethernet
File: myricom/lanai.bin
Licence: Unknown
Found in hex form in kernel source.
--------------------------------------------------------------------------
This source diff could not be displayed because it is too large. You can view the blob instead.
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