1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Common Header File for the Elan Digital Systems U132 adapter 4*4882a593Smuzhiyun * this file should be included by both the "ftdi-u132" and 5*4882a593Smuzhiyun * the "u132-hcd" modules. 6*4882a593Smuzhiyun * 7*4882a593Smuzhiyun * Copyright(C) 2006 Elan Digital Systems Limited 8*4882a593Smuzhiyun *(http://www.elandigitalsystems.com) 9*4882a593Smuzhiyun * 10*4882a593Smuzhiyun * Author and Maintainer - Tony Olech - Elan Digital Systems 11*4882a593Smuzhiyun *(tony.olech@elandigitalsystems.com) 12*4882a593Smuzhiyun * 13*4882a593Smuzhiyun * The driver was written by Tony Olech(tony.olech@elandigitalsystems.com) 14*4882a593Smuzhiyun * based on various USB client drivers in the 2.6.15 linux kernel 15*4882a593Smuzhiyun * with constant reference to the 3rd Edition of Linux Device Drivers 16*4882a593Smuzhiyun * published by O'Reilly 17*4882a593Smuzhiyun * 18*4882a593Smuzhiyun * The U132 adapter is a USB to CardBus adapter specifically designed 19*4882a593Smuzhiyun * for PC cards that contain an OHCI host controller. Typical PC cards 20*4882a593Smuzhiyun * are the Orange Mobile 3G Option GlobeTrotter Fusion card. 21*4882a593Smuzhiyun * 22*4882a593Smuzhiyun * The U132 adapter will *NOT *work with PC cards that do not contain 23*4882a593Smuzhiyun * an OHCI controller. A simple way to test whether a PC card has an 24*4882a593Smuzhiyun * OHCI controller as an interface is to insert the PC card directly 25*4882a593Smuzhiyun * into a laptop(or desktop) with a CardBus slot and if "lspci" shows 26*4882a593Smuzhiyun * a new USB controller and "lsusb -v" shows a new OHCI Host Controller 27*4882a593Smuzhiyun * then there is a good chance that the U132 adapter will support the 28*4882a593Smuzhiyun * PC card.(you also need the specific client driver for the PC card) 29*4882a593Smuzhiyun * 30*4882a593Smuzhiyun * Please inform the Author and Maintainer about any PC cards that 31*4882a593Smuzhiyun * contain OHCI Host Controller and work when directly connected to 32*4882a593Smuzhiyun * an embedded CardBus slot but do not work when they are connected 33*4882a593Smuzhiyun * via an ELAN U132 adapter. 34*4882a593Smuzhiyun * 35*4882a593Smuzhiyun * The driver consists of two modules, the "ftdi-u132" module is 36*4882a593Smuzhiyun * a USB client driver that interfaces to the FTDI chip within 37*4882a593Smuzhiyun * the U132 adapter manufactured by Elan Digital Systems, and the 38*4882a593Smuzhiyun * "u132-hcd" module is a USB host controller driver that talks 39*4882a593Smuzhiyun * to the OHCI controller within CardBus card that are inserted 40*4882a593Smuzhiyun * in the U132 adapter. 41*4882a593Smuzhiyun * 42*4882a593Smuzhiyun * The "ftdi-u132" module should be loaded automatically by the 43*4882a593Smuzhiyun * hot plug system when the U132 adapter is plugged in. The module 44*4882a593Smuzhiyun * initialises the adapter which mostly consists of synchronising 45*4882a593Smuzhiyun * the FTDI chip, before continuously polling the adapter to detect 46*4882a593Smuzhiyun * PC card insertions. As soon as a PC card containing a recognised 47*4882a593Smuzhiyun * OHCI controller is seen the "ftdi-u132" module explicitly requests 48*4882a593Smuzhiyun * the kernel to load the "u132-hcd" module. 49*4882a593Smuzhiyun * 50*4882a593Smuzhiyun * The "ftdi-u132" module provides the interface to the inserted 51*4882a593Smuzhiyun * PC card and the "u132-hcd" module uses the API to send and receive 52*4882a593Smuzhiyun * data. The API features call-backs, so that part of the "u132-hcd" 53*4882a593Smuzhiyun * module code will run in the context of one of the kernel threads 54*4882a593Smuzhiyun * of the "ftdi-u132" module. 55*4882a593Smuzhiyun * 56*4882a593Smuzhiyun */ 57*4882a593Smuzhiyun int ftdi_elan_switch_on_diagnostics(int number); 58*4882a593Smuzhiyun void ftdi_elan_gone_away(struct platform_device *pdev); 59*4882a593Smuzhiyun void start_usb_lock_device_tracing(void); 60*4882a593Smuzhiyun struct u132_platform_data { 61*4882a593Smuzhiyun u16 vendor; 62*4882a593Smuzhiyun u16 device; 63*4882a593Smuzhiyun u8 potpg; 64*4882a593Smuzhiyun void (*port_power) (struct device *dev, int is_on); 65*4882a593Smuzhiyun void (*reset) (struct device *dev); 66*4882a593Smuzhiyun }; 67*4882a593Smuzhiyun int usb_ftdi_elan_edset_single(struct platform_device *pdev, u8 ed_number, 68*4882a593Smuzhiyun void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 69*4882a593Smuzhiyun void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 70*4882a593Smuzhiyun int toggle_bits, int error_count, int condition_code, int repeat_number, 71*4882a593Smuzhiyun int halted, int skipped, int actual, int non_null)); 72*4882a593Smuzhiyun int usb_ftdi_elan_edset_output(struct platform_device *pdev, u8 ed_number, 73*4882a593Smuzhiyun void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 74*4882a593Smuzhiyun void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 75*4882a593Smuzhiyun int toggle_bits, int error_count, int condition_code, int repeat_number, 76*4882a593Smuzhiyun int halted, int skipped, int actual, int non_null)); 77*4882a593Smuzhiyun int usb_ftdi_elan_edset_empty(struct platform_device *pdev, u8 ed_number, 78*4882a593Smuzhiyun void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 79*4882a593Smuzhiyun void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 80*4882a593Smuzhiyun int toggle_bits, int error_count, int condition_code, int repeat_number, 81*4882a593Smuzhiyun int halted, int skipped, int actual, int non_null)); 82*4882a593Smuzhiyun int usb_ftdi_elan_edset_input(struct platform_device *pdev, u8 ed_number, 83*4882a593Smuzhiyun void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 84*4882a593Smuzhiyun void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 85*4882a593Smuzhiyun int toggle_bits, int error_count, int condition_code, int repeat_number, 86*4882a593Smuzhiyun int halted, int skipped, int actual, int non_null)); 87*4882a593Smuzhiyun int usb_ftdi_elan_edset_setup(struct platform_device *pdev, u8 ed_number, 88*4882a593Smuzhiyun void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 89*4882a593Smuzhiyun void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 90*4882a593Smuzhiyun int toggle_bits, int error_count, int condition_code, int repeat_number, 91*4882a593Smuzhiyun int halted, int skipped, int actual, int non_null)); 92*4882a593Smuzhiyun int usb_ftdi_elan_edset_flush(struct platform_device *pdev, u8 ed_number, 93*4882a593Smuzhiyun void *endp); 94*4882a593Smuzhiyun int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, int mem_offset, 95*4882a593Smuzhiyun u8 width, u32 *data); 96*4882a593Smuzhiyun int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, int mem_offset, 97*4882a593Smuzhiyun u8 width, u32 data); 98