aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/myri_sbus.c
diff options
context:
space:
mode:
authorJaswinder Singh Rajput <jaswinderrajput@gmail.com>2009-04-04 19:38:42 -0400
committerDavid S. Miller <davem@davemloft.net>2009-04-04 19:38:42 -0400
commitcd36e9efaa5195396ae5344c6ce32c2b0048df6a (patch)
treedeb336eb607f73fe4c23e3b3cb1aaf9151546970 /drivers/net/myri_sbus.c
parent81c522851436dbc058c9c0c11b32e60d76b180ce (diff)
myri_sbus: use request_firmware
Firmware blob looks like this... __be16 lanai4_data_size unsigned char lanai4_code[] Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/myri_sbus.c')
-rw-r--r--drivers/net/myri_sbus.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index 08534c08d30..9a802adba9a 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -25,6 +25,7 @@ static char version[] =
25#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
26#include <linux/of.h> 26#include <linux/of.h>
27#include <linux/of_device.h> 27#include <linux/of_device.h>
28#include <linux/firmware.h>
28 29
29#include <net/dst.h> 30#include <net/dst.h>
30#include <net/arp.h> 31#include <net/arp.h>
@@ -43,7 +44,6 @@ static char version[] =
43#include <asm/irq.h> 44#include <asm/irq.h>
44 45
45#include "myri_sbus.h" 46#include "myri_sbus.h"
46#include "myri_code.h"
47 47
48/* #define DEBUG_DETECT */ 48/* #define DEBUG_DETECT */
49/* #define DEBUG_IRQ */ 49/* #define DEBUG_IRQ */
@@ -81,6 +81,9 @@ static char version[] =
81#define DHDR(x) 81#define DHDR(x)
82#endif 82#endif
83 83
84/* Firmware name */
85#define FWNAME "myricom/lanai.bin"
86
84static void myri_reset_off(void __iomem *lp, void __iomem *cregs) 87static void myri_reset_off(void __iomem *lp, void __iomem *cregs)
85{ 88{
86 /* Clear IRQ mask. */ 89 /* Clear IRQ mask. */
@@ -171,10 +174,11 @@ static int myri_do_handshake(struct myri_eth *mp)
171 174
172static int __devinit myri_load_lanai(struct myri_eth *mp) 175static int __devinit myri_load_lanai(struct myri_eth *mp)
173{ 176{
177 const struct firmware *fw;
174 struct net_device *dev = mp->dev; 178 struct net_device *dev = mp->dev;
175 struct myri_shmem __iomem *shmem = mp->shmem; 179 struct myri_shmem __iomem *shmem = mp->shmem;
176 void __iomem *rptr; 180 void __iomem *rptr;
177 int i; 181 int i, lanai4_data_size;
178 182
179 myri_disable_irq(mp->lregs, mp->cregs); 183 myri_disable_irq(mp->lregs, mp->cregs);
180 myri_reset_on(mp->cregs); 184 myri_reset_on(mp->cregs);
@@ -186,13 +190,27 @@ static int __devinit myri_load_lanai(struct myri_eth *mp)
186 if (mp->eeprom.cpuvers >= CPUVERS_3_0) 190 if (mp->eeprom.cpuvers >= CPUVERS_3_0)
187 sbus_writel(mp->eeprom.cval, mp->lregs + LANAI_CVAL); 191 sbus_writel(mp->eeprom.cval, mp->lregs + LANAI_CVAL);
188 192
193 i = request_firmware(&fw, FWNAME, &mp->myri_op->dev);
194 if (i) {
195 printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
196 FWNAME, i);
197 return i;
198 }
199 if (fw->size < 2) {
200 printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
201 fw->size, FWNAME);
202 release_firmware(fw);
203 return -EINVAL;
204 }
205 lanai4_data_size = fw->data[0] << 8 | fw->data[1];
206
189 /* Load executable code. */ 207 /* Load executable code. */
190 for (i = 0; i < sizeof(lanai4_code); i++) 208 for (i = 2; i < fw->size; i++)
191 sbus_writeb(lanai4_code[i], rptr + (lanai4_code_off * 2) + i); 209 sbus_writeb(fw->data[i], rptr++);
192 210
193 /* Load data segment. */ 211 /* Load data segment. */
194 for (i = 0; i < sizeof(lanai4_data); i++) 212 for (i = 0; i < lanai4_data_size; i++)
195 sbus_writeb(lanai4_data[i], rptr + (lanai4_data_off * 2) + i); 213 sbus_writeb(0, rptr++);
196 214
197 /* Set device address. */ 215 /* Set device address. */
198 sbus_writeb(0, &shmem->addr[0]); 216 sbus_writeb(0, &shmem->addr[0]);
@@ -228,6 +246,7 @@ static int __devinit myri_load_lanai(struct myri_eth *mp)
228 if (mp->eeprom.cpuvers == CPUVERS_4_0) 246 if (mp->eeprom.cpuvers == CPUVERS_4_0)
229 sbus_writel(0, mp->lregs + LANAI_VERS); 247 sbus_writel(0, mp->lregs + LANAI_VERS);
230 248
249 release_firmware(fw);
231 return i; 250 return i;
232} 251}
233 252
@@ -1078,7 +1097,10 @@ static int __devinit myri_sbus_probe(struct of_device *op, const struct of_devic
1078 1097
1079 /* Load code onto the LANai. */ 1098 /* Load code onto the LANai. */
1080 DET(("Loading LANAI firmware\n")); 1099 DET(("Loading LANAI firmware\n"));
1081 myri_load_lanai(mp); 1100 if (myri_load_lanai(mp)) {
1101 printk(KERN_ERR "MyriCOM: Cannot Load LANAI firmware.\n");
1102 goto err_free_irq;
1103 }
1082 1104
1083 if (register_netdev(dev)) { 1105 if (register_netdev(dev)) {
1084 printk("MyriCOM: Cannot register device.\n"); 1106 printk("MyriCOM: Cannot register device.\n");
@@ -1159,3 +1181,4 @@ module_init(myri_sbus_init);
1159module_exit(myri_sbus_exit); 1181module_exit(myri_sbus_exit);
1160 1182
1161MODULE_LICENSE("GPL"); 1183MODULE_LICENSE("GPL");
1184MODULE_FIRMWARE(FWNAME);