Commit 470c5736 authored by Lior Dotan's avatar Lior Dotan Committed by Greg Kroah-Hartman

Staging: slicoss: use request_firmware

This should make the driver use request_firmware() instead of a static
firmware.
Some obvious things are missing:
1) The unneeded header files are not removed yet. This is to keep the
   patch size small.
2) The .bin files are missing so the driver doesn't have what to load.
3) Testing. None of this was tested. It does compiles OK though :)
Signed-off-by: default avatarLior Dotan <liodot@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 66615321
...@@ -41,6 +41,40 @@ ...@@ -41,6 +41,40 @@
#ifndef __SLIC_DRIVER_H__ #ifndef __SLIC_DRIVER_H__
#define __SLIC_DRIVER_H__ #define __SLIC_DRIVER_H__
/* firmware stuff */
#define OASIS_UCODE_VERS_STRING "1.2"
#define OASIS_UCODE_VERS_DATE "2006/03/27 15:10:37"
#define OASIS_UCODE_HOSTIF_ID 3
static s32 ONumSections = 0x2;
static u32 OSectionSize[] = {
0x00004000, 0x00010000,
};
static u32 OSectionStart[] = {
0x00000000, 0x00008000,
};
#define MOJAVE_UCODE_VERS_STRING "1.2"
#define MOJAVE_UCODE_VERS_DATE "2006/03/27 15:12:22"
#define MOJAVE_UCODE_HOSTIF_ID 3
static s32 MNumSections = 0x2;
static u32 MSectionSize[] =
{
0x00008000, 0x00010000,
};
static u32 MSectionStart[] =
{
0x00000000, 0x00008000,
};
#define GB_RCVUCODE_VERS_STRING "1.2"
#define GB_RCVUCODE_VERS_DATE "2006/03/27 15:12:15"
static u32 OasisRcvUCodeLen = 512;
static u32 GBRcvUCodeLen = 512;
#define SECTION_SIZE 65536
struct slic_spinlock { struct slic_spinlock {
spinlock_t lock; spinlock_t lock;
......
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/firmware.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/mii.h> #include <linux/mii.h>
...@@ -105,15 +106,6 @@ ...@@ -105,15 +106,6 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include "slicinc.h" #include "slicinc.h"
#include "gbdownload.h"
#include "gbrcvucode.h"
#include "oasisrcvucode.h"
#ifdef DEBUG_MICROCODE
#include "oasisdbgdownload.h"
#else
#include "oasisdownload.h"
#endif
#if SLIC_DUMP_ENABLED #if SLIC_DUMP_ENABLED
#include "slicdump.h" #include "slicdump.h"
...@@ -2186,6 +2178,9 @@ static void slic_card_cleanup(struct sliccard *card) ...@@ -2186,6 +2178,9 @@ static void slic_card_cleanup(struct sliccard *card)
static int slic_card_download_gbrcv(struct adapter *adapter) static int slic_card_download_gbrcv(struct adapter *adapter)
{ {
const struct firmware *fw;
const char *file = "";
int ret;
__iomem struct slic_regs *slic_regs = adapter->slic_regs; __iomem struct slic_regs *slic_regs = adapter->slic_regs;
u32 codeaddr; u32 codeaddr;
unsigned char *instruction = NULL; unsigned char *instruction = NULL;
...@@ -2193,12 +2188,32 @@ static int slic_card_download_gbrcv(struct adapter *adapter) ...@@ -2193,12 +2188,32 @@ static int slic_card_download_gbrcv(struct adapter *adapter)
switch (adapter->devid) { switch (adapter->devid) {
case SLIC_2GB_DEVICE_ID: case SLIC_2GB_DEVICE_ID:
instruction = (unsigned char *)&OasisRcvUCode[0]; file = "oasis_rcv.bin";
rcvucodelen = OasisRcvUCodeLen;
break; break;
case SLIC_1GB_DEVICE_ID: case SLIC_1GB_DEVICE_ID:
instruction = (unsigned char *)&GBRcvUCode[0]; file = "gb_rcv.bin";
rcvucodelen = GBRcvUCodeLen; break;
default:
ASSERT(0);
break;
}
ret = request_firmware(&fw, file, &adapter->pcidev->dev);
if (ret) {
printk(KERN_ERR "SLICOSS: Failed to load firmware %s\n", file);
return ret;
}
instruction = (unsigned char *)fw->data;
rcvucodelen = fw->size;
switch (adapter->devid) {
case SLIC_2GB_DEVICE_ID:
if (rcvucodelen != OasisRcvUCodeLen)
return -EINVAL;
break;
case SLIC_1GB_DEVICE_ID:
if (rcvucodelen != GBRcvUCodeLen)
return -EINVAL;
break; break;
default: default:
ASSERT(0); ASSERT(0);
...@@ -2225,13 +2240,16 @@ static int slic_card_download_gbrcv(struct adapter *adapter) ...@@ -2225,13 +2240,16 @@ static int slic_card_download_gbrcv(struct adapter *adapter)
} }
/* download finished */ /* download finished */
release_firmware(fw);
WRITE_REG(slic_regs->slic_rcv_wcs, SLIC_RCVWCS_FINISH, FLUSH); WRITE_REG(slic_regs->slic_rcv_wcs, SLIC_RCVWCS_FINISH, FLUSH);
return 0; return 0;
} }
static int slic_card_download(struct adapter *adapter) static int slic_card_download(struct adapter *adapter)
{ {
const struct firmware *fw;
const char *file = "";
int ret;
u32 section; u32 section;
int thissectionsize; int thissectionsize;
int codeaddr; int codeaddr;
...@@ -2255,6 +2273,7 @@ static int slic_card_download(struct adapter *adapter) ...@@ -2255,6 +2273,7 @@ static int slic_card_download(struct adapter *adapter)
case SLIC_2GB_DEVICE_ID: case SLIC_2GB_DEVICE_ID:
/* DBG_MSG ("slicoss: %s devid==SLIC_2GB_DEVICE_ID sections[%x]\n", /* DBG_MSG ("slicoss: %s devid==SLIC_2GB_DEVICE_ID sections[%x]\n",
__func__, (uint) ONumSections); */ __func__, (uint) ONumSections); */
file = "slic_oasis.bin";
numsects = ONumSections; numsects = ONumSections;
for (i = 0; i < numsects; i++) { for (i = 0; i < numsects; i++) {
sectsize[i] = OSectionSize[i]; sectsize[i] = OSectionSize[i];
...@@ -2264,6 +2283,7 @@ static int slic_card_download(struct adapter *adapter) ...@@ -2264,6 +2283,7 @@ static int slic_card_download(struct adapter *adapter)
case SLIC_1GB_DEVICE_ID: case SLIC_1GB_DEVICE_ID:
/* DBG_MSG ("slicoss: %s devid==SLIC_1GB_DEVICE_ID sections[%x]\n", /* DBG_MSG ("slicoss: %s devid==SLIC_1GB_DEVICE_ID sections[%x]\n",
__func__, (uint) MNumSections); */ __func__, (uint) MNumSections); */
file = "slic_mojave.bin";
numsects = MNumSections; numsects = MNumSections;
for (i = 0; i < numsects; i++) { for (i = 0; i < numsects; i++) {
sectsize[i] = MSectionSize[i]; sectsize[i] = MSectionSize[i];
...@@ -2274,26 +2294,33 @@ static int slic_card_download(struct adapter *adapter) ...@@ -2274,26 +2294,33 @@ static int slic_card_download(struct adapter *adapter)
ASSERT(0); ASSERT(0);
break; break;
} }
ret = request_firmware(&fw, file, &adapter->pcidev->dev);
if (ret) {
printk(KERN_ERR "SLICOSS: Failed to load firmware %s\n", file);
return ret;
}
ASSERT(numsects <= 3); ASSERT(numsects <= 3);
for (section = 0; section < numsects; section++) { for (section = 0; section < numsects; section++) {
switch (adapter->devid) { switch (adapter->devid) {
case SLIC_2GB_DEVICE_ID: case SLIC_2GB_DEVICE_ID:
instruction = (u32 *) &OasisUCode[section][0]; instruction = (u32 *)(fw->data + (SECTION_SIZE *
section));
baseaddress = sectstart[section]; baseaddress = sectstart[section];
thissectionsize = sectsize[section] >> 3; thissectionsize = sectsize[section] >> 3;
lastinstruct = lastinstruct =
(u32 *) &OasisUCode[section][sectsize[section] - (u32 *)(fw->data + (SECTION_SIZE * section) +
8]; sectsize[section] - 8);
break; break;
case SLIC_1GB_DEVICE_ID: case SLIC_1GB_DEVICE_ID:
instruction = (u32 *) &MojaveUCode[section][0]; instruction = (u32 *)(fw->data + (SECTION_SIZE *
section));
baseaddress = sectstart[section]; baseaddress = sectstart[section];
thissectionsize = sectsize[section] >> 3; thissectionsize = sectsize[section] >> 3;
lastinstruct = lastinstruct =
(u32 *) &MojaveUCode[section][sectsize[section] (u32 *)(fw->data + (SECTION_SIZE * section) +
- 8]; sectsize[section] - 8);
break; break;
default: default:
ASSERT(0); ASSERT(0);
...@@ -2329,10 +2356,12 @@ static int slic_card_download(struct adapter *adapter) ...@@ -2329,10 +2356,12 @@ static int slic_card_download(struct adapter *adapter)
for (section = 0; section < numsects; section++) { for (section = 0; section < numsects; section++) {
switch (adapter->devid) { switch (adapter->devid) {
case SLIC_2GB_DEVICE_ID: case SLIC_2GB_DEVICE_ID:
instruction = (u32 *)&OasisUCode[section][0]; instruction = (u32 *)fw->data + (SECTION_SIZE *
section);
break; break;
case SLIC_1GB_DEVICE_ID: case SLIC_1GB_DEVICE_ID:
instruction = (u32 *)&MojaveUCode[section][0]; instruction = (u32 *)fw->data + (SECTION_SIZE *
section);
break; break;
default: default:
ASSERT(0); ASSERT(0);
...@@ -2374,13 +2403,13 @@ static int slic_card_download(struct adapter *adapter) ...@@ -2374,13 +2403,13 @@ static int slic_card_download(struct adapter *adapter)
thissectionsize[%x] failure[%x]\n", thissectionsize[%x] failure[%x]\n",
__func__, codeaddr, thissectionsize, __func__, codeaddr, thissectionsize,
failure); failure);
release_firmware(fw);
return -EIO; return -EIO;
} }
} }
} }
/* DBG_MSG ("slicoss: Compare done\n");*/ /* DBG_MSG ("slicoss: Compare done\n");*/
release_firmware(fw);
/* Everything OK, kick off the card */ /* Everything OK, kick off the card */
mdelay(10); mdelay(10);
WRITE_REG(slic_regs->slic_wcs, SLIC_WCS_START, FLUSH); WRITE_REG(slic_regs->slic_wcs, SLIC_WCS_START, FLUSH);
......
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