qlogicpti: use request_firmware
PATCH 1/1 qlogicpti: use request_firmware
From: Jaswinder Singh <[email protected]>
Firmware blob is little endian
Thanks to Stephen Rothwell for fixing typos
--- drivers/scsi/qlogicpti.c | 63 ++- drivers/scsi/qlogicpti_asm.c | 1160 -------------------------------------- firmware/Makefile | 1 + firmware/WHENCE | 10 + firmware/qlogic/isp1000.bin.ihex | 1158 +++++++++++++++++++++++++++++++++++++ 5 files changed, 1210 insertions(+), 1182 deletions(-) delete mode 100644 drivers/scsi/qlogicpti_asm.c create mode 100644 firmware/qlogic/isp1000.bin.ihex
drivers/scsi/qlogicpti.c +41 -22
@@ -28,6 +28,7 @@#include <linux/dma-mapping.h> #include <linux/of.h> #include <linux/of_device.h> +#include <linux/firmware.h> #include <asm/byteorder.h>
@@ -53,8 +54,6 @@#define DEFAULT_LOOP_COUNT 10000 -#include "qlogicpti_asm.c" -static struct qlogicpti *qptichain =NULL ;static DEFINE_SPINLOCK (qptichain_lock);
@@ -465,16 +464,32 @@ static int qlogicpti_reset_hardware(struct Scsi_Host *host)static int __devinit qlogicpti_load_firmware (struct qlogicpti *qpti) { +const struct firmware *fw; +const char fwname[] ="qlogic/isp1000.bin" ; +const __le16 *fw_data;struct Scsi_Host *host = qpti->qhost;unsigned short csum =0 ;unsigned short param[6 ]; -unsigned short *risc_code, risc_code_addr, risc_code_length; +unsigned short risc_code_addr, risc_code_length; +int err;unsigned long flags;int i, timeout; - risc_code = &sbus_risc_code01[0 ]; + err =request_firmware (&fw, fwname, &qpti->op->dev); +if (err) { +printk (KERN_ERR "Failed to load image \"%s\" err %d\n" , + fwname, err); +return err; + } +if (fw->size %2 ) { +printk (KERN_ERR "Bogus length %zu in image \"%s\"\n" , + fw->size, fwname); + err = -EINVAL ; + goto outfirm; + } + fw_data = (const __le16 *)&fw->data[0 ]; risc_code_addr =0x1000 ;/* all f/w modules load at 0x1000 */ - risc_code_length = sbus_risc_code_length01; + risc_code_length = fw->size /2 ;spin_lock_irqsave (host->host_lock, flags);
@@ -482,12 +497,12 @@ static int __devinit qlogicpti_load_firmware(struct qlogicpti *qpti)* afterwards via the mailbox commands. */ for (i =0 ; i < risc_code_length; i++) - csum += risc_code[i]; + csum +=__le16_to_cpu (fw_data[i]);if (csum) { -spin_unlock_irqrestore (host->host_lock, flags);printk (KERN_EMERG "qlogicpti%d: Aieee, firmware checksum failed!" , qpti->qpti_id); -return 1 ; + err =1 ; + goto out; }sbus_writew (SBUS_CTRL_RESET , qpti->qregs +SBUS_CTRL );sbus_writew ((DMA_CTRL_CCLEAR |DMA_CTRL_CIRQ ), qpti->qregs +CMD_DMA_CTRL );
@@ -496,9 +511,9 @@ static int __devinit qlogicpti_load_firmware(struct qlogicpti *qpti)while (--timeout && (sbus_readw (qpti->qregs +SBUS_CTRL ) &SBUS_CTRL_RESET ))udelay (20 );if (!timeout) { -spin_unlock_irqrestore (host->host_lock, flags);printk (KERN_EMERG "qlogicpti%d: Cannot reset the ISP." , qpti->qpti_id); -return 1 ; + err =1 ; + goto out; }sbus_writew (HCCTRL_RESET , qpti->qregs +HCCTRL );
@@ -536,21 +551,21 @@ static int __devinit qlogicpti_load_firmware(struct qlogicpti *qpti)if (qlogicpti_mbox_command (qpti, param,1 )) {printk (KERN_EMERG "qlogicpti%d: Cannot stop firmware for reload.\n" , qpti->qpti_id); -spin_unlock_irqrestore (host->host_lock, flags); -return 1 ; + err =1 ; + goto out; }/* Load it up.. */ for (i =0 ; i < risc_code_length; i++) { param[0 ] =MBOX_WRITE_RAM_WORD ; param[1 ] = risc_code_addr + i; - param[2 ] = risc_code[i]; + param[2 ] =__le16_to_cpu (fw_data[i]);if (qlogicpti_mbox_command (qpti, param,1 ) || param[0 ] !=MBOX_COMMAND_COMPLETE ) {printk ("qlogicpti%d: Firmware dload failed, I'm bolixed!\n" , qpti->qpti_id); -spin_unlock_irqrestore (host->host_lock, flags); -return 1 ; + err =1 ; + goto out; } }
@@ -569,8 +584,8 @@ static int __devinit qlogicpti_load_firmware(struct qlogicpti *qpti) (param[0] != MBOX_COMMAND_COMPLETE)) {printk (KERN_EMERG "qlogicpti%d: New firmware csum failure!\n" , qpti->qpti_id); -spin_unlock_irqrestore (host->host_lock, flags); -return 1 ; + err =1 ; + goto out; }/* Start using newly downloaded firmware. */
@@ -583,8 +598,8 @@ static int __devinit qlogicpti_load_firmware(struct qlogicpti *qpti) (param[0] != MBOX_COMMAND_COMPLETE)) {printk (KERN_EMERG "qlogicpti%d: AboutFirmware cmd fails.\n" , qpti->qpti_id); -spin_unlock_irqrestore (host->host_lock, flags); -return 1 ; + err =1 ; + goto out; }/* Snag the major and minor revisions from the result. */
@@ -599,8 +614,8 @@ static int __devinit qlogicpti_load_firmware(struct qlogicpti *qpti) (param[0] != MBOX_COMMAND_COMPLETE)) {printk (KERN_EMERG "qlogicpti%d: could not set clock rate.\n" , qpti->qpti_id); -spin_unlock_irqrestore (host->host_lock, flags); -return 1 ; + err =1 ; + goto out; }if (qpti->is_pti !=0 ) {
@@ -616,8 +631,11 @@ static int __devinit qlogicpti_load_firmware(struct qlogicpti *qpti)qlogicpti_mbox_command (qpti, param,1 ); } +out:spin_unlock_irqrestore (host->host_lock, flags); -return 0 ; +outfirm: +release_firmware (fw); +return err; }static int qlogicpti_verify_tmon (struct qlogicpti *qpti)
@@ -1458,6 +1476,7 @@ MODULE_DESCRIPTION("QlogicISP SBUS driver");MODULE_AUTHOR ("David S. Miller ([email protected])" );MODULE_LICENSE ("GPL" );MODULE_VERSION ("2.1" ); +MODULE_FIRMWARE ("qlogic/isp1000.bin" );module_init (qpti_init);module_exit (qpti_exit);
drivers/scsi/qlogicpti_asm.c deleted +0 -1160
1,160 lines not on this page · raw message
firmware/Makefile +1 -0
@@ -43,6 +43,7 @@ fw-shipped-$(CONFIG_SCSI_ADVANSYS) += advansys/mcode.bin advansys/38C1600.bin \ advansys/3550.bin advansys/38C0800.bin fw-shipped-$(CONFIG_SCSI_QLOGIC_1280) += qlogic/1040.bin qlogic/1280.bin \ qlogic/12160.bin +fw-shipped-$(CONFIG_SCSI_QLOGICPTI) += qlogic/isp1000.bin fw-shipped-$(CONFIG_SMCTR) += tr_smctr.bin fw-shipped-$(CONFIG_SND_KORG1212) += korg/k1212.dsp fw-shipped-$(CONFIG_SND_MAESTRO3) += ess/maestro3_assp_kernel.fw \
firmware/WHENCE +10 -0
@@ -448,3 +448,13 @@ Licence: Allegedly GPLv2+, but no source visible. Found in hex form in kernel source. -------------------------------------------------------------------------- + +Driver: SCSI_QLOGICPTI - PTI Qlogic, ISP Driver + +File: qlogic/isp1000.bin + +Licence: Unknown + +Found in hex form in kernel source. + +--------------------------------------------------------------------------
firmware/qlogic/isp1000.bin.ihex new file +1158 -0
1,158 lines not on this page · raw message
Signature · 5 lines
1.6.0.6 -- David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
James Bottomley
maintainerQuoted 8 lines · David Woodhouse
From: Jaswinder Singh <[email protected]>
Firmware blob is little endian
Thanks to Stephen Rothwell for fixing typos
Signed-off-by Jaswinder Singh <[email protected]>Signed-off-by David Woodhouse <[email protected]>
Quoted 9 lines
--- drivers/scsi/qlogicpti.c | 63 ++- drivers/scsi/qlogicpti_asm.c | 1160 -------------------------------------- firmware/Makefile | 1 + firmware/WHENCE | 10 + firmware/qlogic/isp1000.bin.ihex | 1158 +++++++++++++++++++++++++++++++++++++ 5 files changed, 1210 insertions(+), 1182 deletions(-) delete mode 100644 drivers/scsi/qlogicpti_asm.c create mode 100644 firmware/qlogic/isp1000.bin.ihex
I'm assuming this fixes the open firmware conversion bug?
What about the missing Kconfig piece? FW_LOADER must be selected otherwise you can build a config where the device can't possibly work.
James
Quoted 1 line · James Bottomley
I'm assuming this fixes the open firmware conversion bug?
Which bug was that?
Quoted 2 lines
What about the missing
Kconfigpiece?FW_LOADERmust be selected otherwise you can build a config where the device can't possibly work.
I thought we'd started off doing that, but then removed it again; someone went on a crusade _removing_ 'select FW_LOADER' from drivers which use request_firmware().
I think the logic was that you can only turn off FW_LOADER if you define CONFIG_EMBEDDED anyway... although I was never quite sure why that mattered. We can do it either way; I don't really care.
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
James Bottomley
maintainerQuoted 4 lines · David Woodhouse
Quoted 1 line · James Bottomley
I'm assuming this fixes the open firmware conversion bug?
Which bug was that?
This one:
Subject: linux-next: scsi tree build failure
Date: Wed, 31 Dec 2008 03:16:39 +1100 (Tue, 10:16 CST)
Hi James,
Today's linux-next build (sparc defconfig) failed like this:
drivers/scsi/qlogicpti.c: In function 'qlogicpti_load_firmware':drivers/scsi/qlogicpti.c:480: error: 'struct qlogicpti' has no member named 'sdev'
An interaction between commit 68175399c8b5ee90960e78c1bb8e3353e71fbf33 ("[SCSI] qlogicpti: use request_firmware") from the scsi tree and commit 5dc2536bb8d8adb5fdfbe76cd6fdcdf9de3f40f8 ("qlogicpti: Convert to pure OF driver") which is in Linus' tree.
The version of the firmware commit that has been in the firmware tree since Nov 19 has this conflict corrected.
I have left it for today (as it is getting way to late). Please fix it up for tomorrow.
Quoted 25 lines · James Bottomley
Quoted 4 lines · David Woodhouse
Quoted 1 line · James Bottomley
I'm assuming this fixes the open firmware conversion bug?
Which bug was that?
This one:
Subject: linux-next: scsi tree build failure
Date: Wed, 31 Dec 2008 03:16:39 +1100 (Tue, 10:16 CST)Hi James,
Today's linux-next build (sparc defconfig) failed like this:
drivers/scsi/qlogicpti.c: In function 'qlogicpti_load_firmware':drivers/scsi/qlogicpti.c:480: error: 'struct qlogicpti' has no member named 'sdev'An interaction between commit
68175399c8b5ee90960e78c1bb8e3353e71fbf33("[SCSI] qlogicpti: userequest_firmware") from the scsi tree and commit5dc2536bb8d8adb5fdfbe76cd6fdcdf9de3f40f8("qlogicpti: Convert to pure OF driver") which is in Linus' tree.
Quoted 6 lines
The version of the firmware commit that has been in the firmware tree since Nov 19 has this conflict corrected.
I have left it for today (as it is getting way to late). Please fix it up for tomorrow.
I am sorry, it was my typo mistake because I was doing manual merge and I do not have toolchain to check it but linux-next and David patch was correct. Thats why I am thankful to Stephen to fix typos in qlogicpti.
So I prepared all 3 SCSI firmware patches based on latest scsi-misc-2.6 . Please pull it.
The following changes since commit 8efdbd01b6b99c4470c7dd2c40b78d242abbd23a:
Martin K. Petersen (1):
[SCSI] scsi_debug: DIF/DIX support
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jaswinder/scsi-misc-2.6.git master
Jaswinder Singh Rajput (3):
qla1280: use request_firmware
advansys: use request_firmware
qlogicpti: use request_firmware
drivers/scsi/advansys.c | 1737 ++--------------------------- drivers/scsi/ql1040_fw.h | 2130 ------------------------------------ drivers/scsi/ql12160_fw.h | 1811 ------------------------------ drivers/scsi/ql1280_fw.h | 2048 ---------------------------------- drivers/scsi/qla1280.c | 121 ++- drivers/scsi/qla1280.h | 6 + drivers/scsi/qlogicpti.c | 65 +- drivers/scsi/qlogicpti_asm.c | 1160 -------------------- firmware/Makefile | 5 + firmware/WHENCE | 37 + firmware/advansys/3550.bin.ihex | 317 ++++++ firmware/advansys/38C0800.bin.ihex | 336 ++++++ firmware/advansys/38C1600.bin.ihex | 398 +++++++ firmware/advansys/mcode.bin.ihex | 147 +++ firmware/qlogic/1040.bin.ihex | 2111 +++++++++++++++++++++++++++++++++++ firmware/qlogic/12160.bin.ihex | 1771 ++++++++++++++++++++++++++++++ firmware/qlogic/1280.bin.ihex | 2008 +++++++++++++++++++++++++++++++++ firmware/qlogic/isp1000.bin.ihex | 1158 ++++++++++++++++++++ 18 files changed, 8524 insertions(+), 8842 deletions(-) delete mode 100644 drivers/scsi/ql1040_fw.h delete mode 100644 drivers/scsi/ql12160_fw.h delete mode 100644 drivers/scsi/ql1280_fw.h delete mode 100644 drivers/scsi/qlogicpti_asm.c create mode 100644 firmware/advansys/3550.bin.ihex create mode 100644 firmware/advansys/38C0800.bin.ihex create mode 100644 firmware/advansys/38C1600.bin.ihex create mode 100644 firmware/advansys/mcode.bin.ihex create mode 100644 firmware/qlogic/1040.bin.ihex create mode 100644 firmware/qlogic/12160.bin.ihex create mode 100644 firmware/qlogic/1280.bin.ihex create mode 100644 firmware/qlogic/isp1000.bin.ihex
Thanks
--
JSR