mirror of
https://github.com/torvalds/linux.git
synced 2024-11-12 07:01:57 +00:00
USB: ezusb: add support for Cypress FX2LP
This Patch adds support for the newer Cypress FX2LP. It also adapts three drivers currently using ezusb to the interface change. (whiteheat and keyspan[_pda]) Signed-off-by: René Bürgel <rene.buergel@sohard.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9fa5780bee
commit
cc183e2a5e
@ -14,11 +14,25 @@
|
|||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
|
|
||||||
/* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */
|
struct ezusb_fx_type {
|
||||||
#define CPUCS_REG 0x7F92
|
/* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */
|
||||||
|
unsigned short cpucs_reg;
|
||||||
|
unsigned short max_internal_adress;
|
||||||
|
};
|
||||||
|
|
||||||
/* Command for writing to internal memory */
|
struct ezusb_fx_type ezusb_fx1 = {
|
||||||
|
.cpucs_reg = 0x7F92,
|
||||||
|
.max_internal_adress = 0x1B3F,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ezusb_fx_type ezusb_fx2 = {
|
||||||
|
.cpucs_reg = 0xE600,
|
||||||
|
.max_internal_adress = 0x3FFF,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Commands for writing to memory */
|
||||||
#define WRITE_INT_RAM 0xA0
|
#define WRITE_INT_RAM 0xA0
|
||||||
|
#define WRITE_EXT_RAM 0xA3
|
||||||
|
|
||||||
int ezusb_writememory(struct usb_device *dev, int address,
|
int ezusb_writememory(struct usb_device *dev, int address,
|
||||||
unsigned char *data, int length, __u8 request)
|
unsigned char *data, int length, __u8 request)
|
||||||
@ -44,13 +58,24 @@ int ezusb_writememory(struct usb_device *dev, int address,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(ezusb_writememory);
|
EXPORT_SYMBOL_GPL(ezusb_writememory);
|
||||||
|
|
||||||
int ezusb_set_reset(struct usb_device *dev, unsigned char reset_bit)
|
int ezusb_set_reset(struct usb_device *dev, unsigned short cpucs_reg,
|
||||||
|
unsigned char reset_bit)
|
||||||
{
|
{
|
||||||
int response = ezusb_writememory(dev, CPUCS_REG, &reset_bit, 1, WRITE_INT_RAM);
|
int response = ezusb_writememory(dev, cpucs_reg, &reset_bit, 1, WRITE_INT_RAM);
|
||||||
if (response < 0)
|
if (response < 0)
|
||||||
dev_err(&dev->dev, "%s-%d failed: %d\n",
|
dev_err(&dev->dev, "%s-%d failed: %d\n",
|
||||||
__func__, reset_bit, response);
|
__func__, reset_bit, response);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(ezusb_set_reset);
|
|
||||||
|
|
||||||
|
int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit)
|
||||||
|
{
|
||||||
|
return ezusb_set_reset(dev, ezusb_fx1.cpucs_reg, reset_bit);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(ezusb_fx1_set_reset);
|
||||||
|
|
||||||
|
int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit)
|
||||||
|
{
|
||||||
|
return ezusb_set_reset(dev, ezusb_fx2.cpucs_reg, reset_bit);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(ezusb_fx2_set_reset);
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
#include <linux/usb/serial.h>
|
#include <linux/usb/serial.h>
|
||||||
|
#include <linux/usb/ezusb.h>
|
||||||
#include "keyspan.h"
|
#include "keyspan.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1245,7 +1246,7 @@ static int keyspan_fake_startup(struct usb_serial *serial)
|
|||||||
dev_dbg(&serial->dev->dev, "Uploading Keyspan %s firmware.\n", fw_name);
|
dev_dbg(&serial->dev->dev, "Uploading Keyspan %s firmware.\n", fw_name);
|
||||||
|
|
||||||
/* download the firmware image */
|
/* download the firmware image */
|
||||||
response = ezusb_set_reset(serial->dev, 1);
|
response = ezusb_fx1_set_reset(serial->dev, 1);
|
||||||
|
|
||||||
record = (const struct ihex_binrec *)fw->data;
|
record = (const struct ihex_binrec *)fw->data;
|
||||||
|
|
||||||
@ -1264,7 +1265,7 @@ static int keyspan_fake_startup(struct usb_serial *serial)
|
|||||||
release_firmware(fw);
|
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->dev, 0);
|
response = ezusb_fx1_set_reset(serial->dev, 0);
|
||||||
|
|
||||||
/* we don't want this device to have a driver assigned to it. */
|
/* we don't want this device to have a driver assigned to it. */
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
#include <linux/usb/serial.h>
|
#include <linux/usb/serial.h>
|
||||||
|
#include <linux/usb/ezusb.h>
|
||||||
|
|
||||||
/* make a simple define to handle if we are compiling keyspan_pda or xircom support */
|
/* make a simple define to handle if we are compiling keyspan_pda or xircom support */
|
||||||
#if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE)
|
#if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE)
|
||||||
@ -678,7 +679,7 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
|
|||||||
const struct firmware *fw;
|
const struct firmware *fw;
|
||||||
|
|
||||||
/* download the firmware here ... */
|
/* download the firmware here ... */
|
||||||
response = ezusb_set_reset(serial->dev, 1);
|
response = ezusb_fx1_set_reset(serial->dev, 1);
|
||||||
|
|
||||||
if (0) { ; }
|
if (0) { ; }
|
||||||
#ifdef KEYSPAN
|
#ifdef KEYSPAN
|
||||||
@ -718,7 +719,7 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
|
|||||||
release_firmware(fw);
|
release_firmware(fw);
|
||||||
/* bring device out of reset. Renumeration will occur in a moment
|
/* bring device out of reset. Renumeration will occur in a moment
|
||||||
and the new device will bind to the real driver */
|
and the new device will bind to the real driver */
|
||||||
response = ezusb_set_reset(serial->dev, 0);
|
response = ezusb_fx1_set_reset(serial->dev, 0);
|
||||||
|
|
||||||
/* we want this device to fail to have a driver assigned to it. */
|
/* we want this device to fail to have a driver assigned to it. */
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <linux/serial_reg.h>
|
#include <linux/serial_reg.h>
|
||||||
#include <linux/serial.h>
|
#include <linux/serial.h>
|
||||||
#include <linux/usb/serial.h>
|
#include <linux/usb/serial.h>
|
||||||
|
#include <linux/usb/ezusb.h>
|
||||||
#include <linux/firmware.h>
|
#include <linux/firmware.h>
|
||||||
#include <linux/ihex.h>
|
#include <linux/ihex.h>
|
||||||
#include "whiteheat.h" /* WhiteHEAT specific commands */
|
#include "whiteheat.h" /* WhiteHEAT specific commands */
|
||||||
@ -211,7 +212,7 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
response = ezusb_set_reset(serial->dev, 1);
|
response = ezusb_fx1_set_reset(serial->dev, 1);
|
||||||
|
|
||||||
record = (const struct ihex_binrec *)loader_fw->data;
|
record = (const struct ihex_binrec *)loader_fw->data;
|
||||||
while (record) {
|
while (record) {
|
||||||
@ -228,7 +229,7 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
|
|||||||
record = ihex_next_binrec(record);
|
record = ihex_next_binrec(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
response = ezusb_set_reset(serial->dev, 0);
|
response = ezusb_fx1_set_reset(serial->dev, 0);
|
||||||
|
|
||||||
record = (const struct ihex_binrec *)firmware_fw->data;
|
record = (const struct ihex_binrec *)firmware_fw->data;
|
||||||
while (record && be32_to_cpu(record->addr) < 0x1b40)
|
while (record && be32_to_cpu(record->addr) < 0x1b40)
|
||||||
@ -248,7 +249,7 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
|
|||||||
++record;
|
++record;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = ezusb_set_reset(serial->dev, 1);
|
response = ezusb_fx1_set_reset(serial->dev, 1);
|
||||||
|
|
||||||
record = (const struct ihex_binrec *)firmware_fw->data;
|
record = (const struct ihex_binrec *)firmware_fw->data;
|
||||||
while (record && be32_to_cpu(record->addr) < 0x1b40) {
|
while (record && be32_to_cpu(record->addr) < 0x1b40) {
|
||||||
@ -266,7 +267,7 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
|
|||||||
++record;
|
++record;
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
response = ezusb_set_reset(serial->dev, 0);
|
response = ezusb_fx1_set_reset(serial->dev, 0);
|
||||||
out:
|
out:
|
||||||
release_firmware(loader_fw);
|
release_firmware(loader_fw);
|
||||||
release_firmware(firmware_fw);
|
release_firmware(firmware_fw);
|
||||||
|
16
include/linux/usb/ezusb.h
Normal file
16
include/linux/usb/ezusb.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef __EZUSB_H
|
||||||
|
#define __EZUSB_H
|
||||||
|
|
||||||
|
|
||||||
|
extern int ezusb_writememory(struct usb_device *dev, int address,
|
||||||
|
unsigned char *data, int length, __u8 bRequest);
|
||||||
|
|
||||||
|
extern int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit);
|
||||||
|
extern int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit);
|
||||||
|
|
||||||
|
extern int ezusb_fx1_ihex_firmware_download(struct usb_device *dev,
|
||||||
|
const char *firmware_path);
|
||||||
|
extern int ezusb_fx2_ihex_firmware_download(struct usb_device *dev,
|
||||||
|
const char *firmware_path);
|
||||||
|
|
||||||
|
#endif /* __EZUSB_H */
|
@ -301,10 +301,6 @@ extern void usb_serial_port_softint(struct usb_serial_port *port);
|
|||||||
extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message);
|
extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message);
|
||||||
extern int usb_serial_resume(struct usb_interface *intf);
|
extern int usb_serial_resume(struct usb_interface *intf);
|
||||||
|
|
||||||
extern int ezusb_writememory(struct usb_device *dev, int address,
|
|
||||||
unsigned char *data, int length, __u8 bRequest);
|
|
||||||
extern int ezusb_set_reset(struct usb_device *dev, unsigned char reset_bit);
|
|
||||||
|
|
||||||
/* USB Serial console functions */
|
/* USB Serial console functions */
|
||||||
#ifdef CONFIG_USB_SERIAL_CONSOLE
|
#ifdef CONFIG_USB_SERIAL_CONSOLE
|
||||||
extern void usb_serial_console_init(int minor);
|
extern void usb_serial_console_init(int minor);
|
||||||
|
Loading…
Reference in New Issue
Block a user