Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2971c579 authored by David Woodhouse's avatar David Woodhouse Committed by David Woodhouse
Browse files

keyspan: use request_firmware()

parent 0a2a736a
Loading
Loading
Loading
Loading
+12 −12
Original line number Original line Diff line number Diff line
@@ -304,19 +304,19 @@ config USB_SERIAL_KEYSPAN


config USB_SERIAL_KEYSPAN_MPR
config USB_SERIAL_KEYSPAN_MPR
	bool "USB Keyspan MPR Firmware"
	bool "USB Keyspan MPR Firmware"
	depends on USB_SERIAL_KEYSPAN
	depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
	help
	help
	  Say Y here to include firmware for the Keyspan MPR converter.
	  Say Y here to include firmware for the Keyspan MPR converter.


config USB_SERIAL_KEYSPAN_USA28
config USB_SERIAL_KEYSPAN_USA28
	bool "USB Keyspan USA-28 Firmware"
	bool "USB Keyspan USA-28 Firmware"
	depends on USB_SERIAL_KEYSPAN
	depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
	help
	help
	  Say Y here to include firmware for the USA-28 converter.
	  Say Y here to include firmware for the USA-28 converter.


config USB_SERIAL_KEYSPAN_USA28X
config USB_SERIAL_KEYSPAN_USA28X
	bool "USB Keyspan USA-28X Firmware"
	bool "USB Keyspan USA-28X Firmware"
	depends on USB_SERIAL_KEYSPAN
	depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
	help
	help
	  Say Y here to include firmware for the USA-28X converter.
	  Say Y here to include firmware for the USA-28X converter.
	  Be sure you have a USA-28X, there are also 28XA and 28XB
	  Be sure you have a USA-28X, there are also 28XA and 28XB
@@ -324,7 +324,7 @@ config USB_SERIAL_KEYSPAN_USA28X


config USB_SERIAL_KEYSPAN_USA28XA
config USB_SERIAL_KEYSPAN_USA28XA
	bool "USB Keyspan USA-28XA Firmware"
	bool "USB Keyspan USA-28XA Firmware"
	depends on USB_SERIAL_KEYSPAN
	depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
	help
	help
	  Say Y here to include firmware for the USA-28XA converter.
	  Say Y here to include firmware for the USA-28XA converter.
	  Be sure you have a USA-28XA, there are also 28X and 28XB
	  Be sure you have a USA-28XA, there are also 28X and 28XB
@@ -332,7 +332,7 @@ config USB_SERIAL_KEYSPAN_USA28XA


config USB_SERIAL_KEYSPAN_USA28XB
config USB_SERIAL_KEYSPAN_USA28XB
	bool "USB Keyspan USA-28XB Firmware"
	bool "USB Keyspan USA-28XB Firmware"
	depends on USB_SERIAL_KEYSPAN
	depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
	help
	help
	  Say Y here to include firmware for the USA-28XB converter.
	  Say Y here to include firmware for the USA-28XB converter.
	  Be sure you have a USA-28XB, there are also 28X and 28XA
	  Be sure you have a USA-28XB, there are also 28X and 28XA
@@ -340,43 +340,43 @@ config USB_SERIAL_KEYSPAN_USA28XB


config USB_SERIAL_KEYSPAN_USA19
config USB_SERIAL_KEYSPAN_USA19
	bool "USB Keyspan USA-19 Firmware"
	bool "USB Keyspan USA-19 Firmware"
	depends on USB_SERIAL_KEYSPAN
	depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
	help
	help
	  Say Y here to include firmware for the USA-19 converter.
	  Say Y here to include firmware for the USA-19 converter.


config USB_SERIAL_KEYSPAN_USA18X
config USB_SERIAL_KEYSPAN_USA18X
	bool "USB Keyspan USA-18X Firmware"
	bool "USB Keyspan USA-18X Firmware"
	depends on USB_SERIAL_KEYSPAN
	depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
	help
	help
	  Say Y here to include firmware for the USA-18X converter.
	  Say Y here to include firmware for the USA-18X converter.


config USB_SERIAL_KEYSPAN_USA19W
config USB_SERIAL_KEYSPAN_USA19W
	bool "USB Keyspan USA-19W Firmware"
	bool "USB Keyspan USA-19W Firmware"
	depends on USB_SERIAL_KEYSPAN
	depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
	help
	help
	  Say Y here to include firmware for the USA-19W converter.
	  Say Y here to include firmware for the USA-19W converter.


config USB_SERIAL_KEYSPAN_USA19QW
config USB_SERIAL_KEYSPAN_USA19QW
	bool "USB Keyspan USA-19QW Firmware"
	bool "USB Keyspan USA-19QW Firmware"
	depends on USB_SERIAL_KEYSPAN
	depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
	help
	help
	  Say Y here to include firmware for the USA-19QW converter.
	  Say Y here to include firmware for the USA-19QW converter.


config USB_SERIAL_KEYSPAN_USA19QI
config USB_SERIAL_KEYSPAN_USA19QI
	bool "USB Keyspan USA-19QI Firmware"
	bool "USB Keyspan USA-19QI Firmware"
	depends on USB_SERIAL_KEYSPAN
	depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
	help
	help
	  Say Y here to include firmware for the USA-19QI converter.
	  Say Y here to include firmware for the USA-19QI converter.


config USB_SERIAL_KEYSPAN_USA49W
config USB_SERIAL_KEYSPAN_USA49W
	bool "USB Keyspan USA-49W Firmware"
	bool "USB Keyspan USA-49W Firmware"
	depends on USB_SERIAL_KEYSPAN
	depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
	help
	help
	  Say Y here to include firmware for the USA-49W converter.
	  Say Y here to include firmware for the USA-49W converter.


config USB_SERIAL_KEYSPAN_USA49WLC
config USB_SERIAL_KEYSPAN_USA49WLC
	bool "USB Keyspan USA-49WLC Firmware"
	bool "USB Keyspan USA-49WLC Firmware"
	depends on USB_SERIAL_KEYSPAN
	depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
	help
	help
	  Say Y here to include firmware for the USA-49WLC converter.
	  Say Y here to include firmware for the USA-49WLC converter.


+42 −36
Original line number Original line Diff line number Diff line
@@ -105,6 +105,8 @@
#include <linux/tty_flip.h>
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/spinlock.h>
#include <linux/firmware.h>
#include <linux/ihex.h>
#include <asm/uaccess.h>
#include <asm/uaccess.h>
#include <linux/usb.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
#include <linux/usb/serial.h>
@@ -1339,13 +1341,13 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
	port->tty = NULL;
	port->tty = NULL;
}
}



	/* download the firmware to a pre-renumeration device */
	/* download the firmware to a pre-renumeration device */
static int keyspan_fake_startup (struct usb_serial *serial)
static int keyspan_fake_startup (struct usb_serial *serial)
{
{
	int 				response;
	int 				response;
	const struct ezusb_hex_record 	*record;
	const struct ihex_binrec 	*record;
	char				*fw_name;
	char				*fw_name;
	const struct firmware		*fw;


	dbg("Keyspan startup version %04x product %04x",
	dbg("Keyspan startup version %04x product %04x",
	    le16_to_cpu(serial->dev->descriptor.bcdDevice),
	    le16_to_cpu(serial->dev->descriptor.bcdDevice),
@@ -1359,72 +1361,60 @@ static int keyspan_fake_startup (struct usb_serial *serial)
		/* Select firmware image on the basis of idProduct */
		/* Select firmware image on the basis of idProduct */
	switch (le16_to_cpu(serial->dev->descriptor.idProduct)) {
	switch (le16_to_cpu(serial->dev->descriptor.idProduct)) {
	case keyspan_usa28_pre_product_id:
	case keyspan_usa28_pre_product_id:
		record = &keyspan_usa28_firmware[0];
		fw_name = "keyspan/usa28.fw";
		fw_name = "USA28";
		break;
		break;


	case keyspan_usa28x_pre_product_id:
	case keyspan_usa28x_pre_product_id:
		record = &keyspan_usa28x_firmware[0];
		fw_name = "keyspan/usa28x.fw";
		fw_name = "USA28X";
		break;
		break;


	case keyspan_usa28xa_pre_product_id:
	case keyspan_usa28xa_pre_product_id:
		record = &keyspan_usa28xa_firmware[0];
		fw_name = "keyspan/usa28xa.fw";
		fw_name = "USA28XA";
		break;
		break;


	case keyspan_usa28xb_pre_product_id:
	case keyspan_usa28xb_pre_product_id:
		record = &keyspan_usa28xb_firmware[0];
		fw_name = "keyspan/usa28xb.fw";
		fw_name = "USA28XB";
		break;
		break;


	case keyspan_usa19_pre_product_id:
	case keyspan_usa19_pre_product_id:
		record = &keyspan_usa19_firmware[0];
		fw_name = "keyspan/usa19.fw";
		fw_name = "USA19";
		break;
		break;
			     
			     
	case keyspan_usa19qi_pre_product_id:
	case keyspan_usa19qi_pre_product_id:
		record = &keyspan_usa19qi_firmware[0];
		fw_name = "keyspan/usa19qi.fw";
		fw_name = "USA19QI";
		break;
		break;
			     
			     
	case keyspan_mpr_pre_product_id:
	case keyspan_mpr_pre_product_id:
		record = &keyspan_mpr_firmware[0];
		fw_name = "keyspan/mpr.fw";
		fw_name = "MPR";
		break;
		break;


	case keyspan_usa19qw_pre_product_id:
	case keyspan_usa19qw_pre_product_id:
		record = &keyspan_usa19qw_firmware[0];
		fw_name = "keyspan/usa19qw.fw";
		fw_name = "USA19QI";
		break;
		break;
			     
			     
	case keyspan_usa18x_pre_product_id:
	case keyspan_usa18x_pre_product_id:
		record = &keyspan_usa18x_firmware[0];
		fw_name = "keyspan/usa18x.fw";
		fw_name = "USA18X";
		break;
		break;
			     
			     
	case keyspan_usa19w_pre_product_id:
	case keyspan_usa19w_pre_product_id:
		record = &keyspan_usa19w_firmware[0];
		fw_name = "keyspan/usa19w.fw";
		fw_name = "USA19W";
		break;
		break;
		
		
	case keyspan_usa49w_pre_product_id:
	case keyspan_usa49w_pre_product_id:
		record = &keyspan_usa49w_firmware[0];
		fw_name = "keyspan/usa49w.fw";
		fw_name = "USA49W";
		break;
		break;


	case keyspan_usa49wlc_pre_product_id:
	case keyspan_usa49wlc_pre_product_id:
		record = &keyspan_usa49wlc_firmware[0];
		fw_name = "keyspan/usa49wlc.fw";
		fw_name = "USA49WLC";
		break;
		break;


	default:
	default:
		record = NULL;
		dev_err(&serial->dev->dev, "Unknown product ID (%04x)\n",
		fw_name = "Unknown";
			le16_to_cpu(serial->dev->descriptor.idProduct));
		break;
		return 1;
	}
	}


	if (record == NULL) {
	if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) {
		dev_err(&serial->dev->dev, "Required keyspan firmware image (%s) unavailable.\n", fw_name);
		dev_err(&serial->dev->dev, "Required keyspan firmware image (%s) unavailable.\n", fw_name);
		return(1);
		return(1);
	}
	}
@@ -1434,19 +1424,22 @@ static int keyspan_fake_startup (struct usb_serial *serial)
		/* download the firmware image */
		/* download the firmware image */
	response = ezusb_set_reset(serial, 1);
	response = ezusb_set_reset(serial, 1);


	while(record->address != 0xffff) {
	record = (const struct ihex_binrec *)fw->data;
		response = ezusb_writememory(serial, record->address,

	while (record) {
		response = ezusb_writememory(serial, be32_to_cpu(record->addr),
					     (unsigned char *)record->data,
					     (unsigned char *)record->data,
					     record->data_size, 0xa0);
					     be16_to_cpu(record->len), 0xa0);
		if (response < 0) {
		if (response < 0) {
			dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan"
			dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan"
				"firmware (%d %04X %p %d)\n",
				"firmware (%d %04X %p %d)\n",
				response, 
				response, be32_to_cpu(record->addr),
				record->address, record->data, record->data_size);
				record->data, be16_to_cpu(record->len));
			break;
			break;
		}
		}
		record++;
		record = ihex_next_binrec(record);
	}
	}
	release_firmware(fw);
		/* bring device out of reset. Renumeration will occur in a
		/* bring device out of reset. Renumeration will occur in a
		   moment and the new device will bind to the real driver */
		   moment and the new device will bind to the real driver */
	response = ezusb_set_reset(serial, 0);
	response = ezusb_set_reset(serial, 0);
@@ -2756,6 +2749,19 @@ MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL");


MODULE_FIRMWARE("keyspan/usa28.fw");
MODULE_FIRMWARE("keyspan/usa28x.fw");
MODULE_FIRMWARE("keyspan/usa28xa.fw");
MODULE_FIRMWARE("keyspan/usa28xb.fw");
MODULE_FIRMWARE("keyspan/usa19.fw");
MODULE_FIRMWARE("keyspan/usa19qi.fw");
MODULE_FIRMWARE("keyspan/mpr.fw");
MODULE_FIRMWARE("keyspan/usa19qw.fw");
MODULE_FIRMWARE("keyspan/usa18x.fw");
MODULE_FIRMWARE("keyspan/usa19w.fw");
MODULE_FIRMWARE("keyspan/usa49w.fw");
MODULE_FIRMWARE("keyspan/usa49wlc.fw");

module_param(debug, bool, S_IRUGO | S_IWUSR);
module_param(debug, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Debug enabled or not");
MODULE_PARM_DESC(debug, "Debug enabled or not");
+0 −84
Original line number Original line Diff line number Diff line
@@ -103,90 +103,6 @@ static int keyspan_usa67_send_setup (struct usb_serial *serial,
					 struct usb_serial_port *port,
					 struct usb_serial_port *port,
					 int reset_port);
					 int reset_port);


/* Struct used for firmware - increased size of data section
   to allow Keyspan's 'C' firmware struct to be used unmodified */
struct ezusb_hex_record {
	__u16 address;
	__u8 data_size;
	__u8 data[64];
};

/* Conditionally include firmware images, if they aren't
   included create a null pointer instead.  Current 
   firmware images aren't optimised to remove duplicate
   addresses in the image itself. */
#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA28
	#include "keyspan_usa28_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa28_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA28X
	#include "keyspan_usa28x_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa28x_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA28XA
	#include "keyspan_usa28xa_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa28xa_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA28XB
	#include "keyspan_usa28xb_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa28xb_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA19
	#include "keyspan_usa19_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa19_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA19QI
	#include "keyspan_usa19qi_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa19qi_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_MPR
        #include "keyspan_mpr_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_mpr_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA19QW
	#include "keyspan_usa19qw_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa19qw_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA18X
	#include "keyspan_usa18x_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa18x_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA19W
	#include "keyspan_usa19w_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa19w_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA49W
	#include "keyspan_usa49w_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa49w_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA49WLC
        #include "keyspan_usa49wlc_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa49wlc_firmware = NULL;
#endif

/* Values used for baud rate calculation - device specific */
/* Values used for baud rate calculation - device specific */
#define	KEYSPAN_INVALID_BAUD_RATE		(-1)
#define	KEYSPAN_INVALID_BAUD_RATE		(-1)
#define	KEYSPAN_BAUD_RATE_OK			(0)
#define	KEYSPAN_BAUD_RATE_OK			(0)
+0 −286

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −447

File deleted.

Preview size limit exceeded, changes collapsed.

Loading