drivers/usb/serial/whiteheat.c
Source file repositories/reference/linux-study-clean/drivers/usb/serial/whiteheat.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/serial/whiteheat.c- Extension
.c- Size
- 23899 bytes
- Lines
- 807
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/errno.hlinux/slab.hlinux/tty.hlinux/tty_driver.hlinux/tty_flip.hlinux/module.hlinux/spinlock.hlinux/mutex.hlinux/uaccess.hasm/termbits.hlinux/usb.hlinux/serial_reg.hlinux/serial.hlinux/usb/serial.hlinux/usb/ezusb.hwhiteheat.h
Detected Declarations
struct whiteheat_command_privatestruct whiteheat_privatefunction whiteheat_firmware_downloadfunction whiteheat_firmware_attachfunction whiteheat_attachfunction whiteheat_releasefunction whiteheat_port_probefunction whiteheat_port_removefunction whiteheat_openfunction whiteheat_closefunction whiteheat_tiocmgetfunction whiteheat_tiocmsetfunction whiteheat_get_serialfunction whiteheat_set_termiosfunction whiteheat_break_ctlfunction command_port_write_callbackfunction command_port_read_callbackfunction firm_send_commandfunction firm_openfunction firm_closefunction firm_setup_portfunction firm_set_rtsfunction firm_set_dtrfunction firm_set_breakfunction firm_purgefunction firm_get_dtr_rtsfunction firm_report_tx_donefunction start_command_portfunction stop_command_port
Annotated Snippet
struct whiteheat_command_private {
struct mutex mutex;
__u8 port_running;
__u8 command_finished;
wait_queue_head_t wait_command; /* for handling sleeping whilst
waiting for a command to
finish */
__u8 result_buffer[64];
};
struct whiteheat_private {
__u8 mcr; /* FIXME: no locking on mcr */
};
/* local function prototypes */
static int start_command_port(struct usb_serial *serial);
static void stop_command_port(struct usb_serial *serial);
static void command_port_write_callback(struct urb *urb);
static void command_port_read_callback(struct urb *urb);
static int firm_send_command(struct usb_serial_port *port, __u8 command,
__u8 *data, __u8 datasize);
static int firm_open(struct usb_serial_port *port);
static int firm_close(struct usb_serial_port *port);
static void firm_setup_port(struct tty_struct *tty);
static int firm_set_rts(struct usb_serial_port *port, __u8 onoff);
static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff);
static int firm_set_break(struct usb_serial_port *port, __u8 onoff);
static int firm_purge(struct usb_serial_port *port, __u8 rxtx);
static int firm_get_dtr_rts(struct usb_serial_port *port);
static int firm_report_tx_done(struct usb_serial_port *port);
#define COMMAND_PORT 4
#define COMMAND_TIMEOUT (2*HZ) /* 2 second timeout for a command */
#define COMMAND_TIMEOUT_MS 2000
/*****************************************************************************
* Connect Tech's White Heat prerenumeration driver functions
*****************************************************************************/
/* steps to download the firmware to the WhiteHEAT device:
- hold the reset (by writing to the reset bit of the CPUCS register)
- download the VEND_AX.HEX file to the chip using VENDOR_REQUEST-ANCHOR_LOAD
- release the reset (by writing to the CPUCS register)
- download the WH.HEX file for all addresses greater than 0x1b3f using
VENDOR_REQUEST-ANCHOR_EXTERNAL_RAM_LOAD
- hold the reset
- download the WH.HEX file for all addresses less than 0x1b40 using
VENDOR_REQUEST_ANCHOR_LOAD
- release the reset
- device renumerated itself and comes up as new device id with all
firmware download completed.
*/
static int whiteheat_firmware_download(struct usb_serial *serial,
const struct usb_device_id *id)
{
int response;
response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat_loader.fw");
if (response >= 0) {
response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat.fw");
if (response >= 0)
return 0;
}
return -ENOENT;
}
static int whiteheat_firmware_attach(struct usb_serial *serial)
{
/* We want this device to fail to have a driver assigned to it */
return 1;
}
/*****************************************************************************
* Connect Tech's White Heat serial driver functions
*****************************************************************************/
static int whiteheat_attach(struct usb_serial *serial)
{
struct usb_serial_port *command_port;
struct whiteheat_command_private *command_info;
struct whiteheat_hw_info *hw_info;
int pipe;
int ret;
int alen;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/slab.h`, `linux/tty.h`, `linux/tty_driver.h`, `linux/tty_flip.h`, `linux/module.h`, `linux/spinlock.h`.
- Detected declarations: `struct whiteheat_command_private`, `struct whiteheat_private`, `function whiteheat_firmware_download`, `function whiteheat_firmware_attach`, `function whiteheat_attach`, `function whiteheat_release`, `function whiteheat_port_probe`, `function whiteheat_port_remove`, `function whiteheat_open`, `function whiteheat_close`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.