High Speed Synchronous Serial Interface (HSI)
Introduction #
High Speed Synchronous Interface (HSI) is a full duplex, low latency protocol, that is optimized for die-level interconnect between an Application Processor and a Baseband chipset. It has been specified by the MIPI alliance in 2003 and implemented by multiple vendors since then.
The HSI interface supports full duplex communication over multiple channels (typically 8) and is capable of reaching speeds up to 200 Mbit/s.
The serial protocol uses two signals, DATA and FLAG as combined data and clock signals and an additional READY signal for flow control. An additional WAKE signal can be used to wakeup the chips from standby modes. The signals are commonly prefixed by AC for signals going from the application die to the cellular die and CA for signals going the other way around.
+------------+ +---------------+
| Cellular | | Application |
| Die | | Die |
| | - - - - - - CAWAKE - - - - - - >| |
| T|------------ CADATA ------------>|R |
| X|------------ CAFLAG ------------>|X |
| |<----------- ACREADY ------------| |
| | | |
| | | |
| |< - - - - - ACWAKE - - - - - - -| |
| R|<----------- ACDATA -------------|T |
| X|<----------- ACFLAG -------------|X |
| |------------ CAREADY ----------->| |
| | | |
| | | |
+------------+ +---------------+
HSI Subsystem in Linux #
In the Linux kernel the hsi subsystem is supposed to be used for HSI devices. The hsi subsystem contains drivers for hsi controllers including support for multi-port controllers and provides a generic API for using the HSI ports.
It also contains HSI client drivers, which make use of the generic API to implement a protocol used on the HSI interface. These client drivers can use an arbitrary number of channels.
hsi-char Device #
Each port automatically registers a generic client driver called hsi_char, which provides a character device for userspace representing the HSI port. It can be used to communicate via HSI from userspace. Userspace may configure the hsi_char device using the following ioctl commands:
-
HSC_RESET
flush the HSI port
-
HSC_SET_PM
enable or disable the client.
-
HSC_SEND_BREAK
send break
-
HSC_SET_RX
set RX configuration
-
HSC_GET_RX
get RX configuration
-
HSC_SET_TX
set TX configuration
-
HSC_GET_TX
get TX configuration
The kernel HSI API #
struct hsi_channel #
channel resource used by the hsi clients
Definition
;
Members
id: Channel numbername: Channel name
struct hsi_config #
Configuration for RX/TX HSI modules
Definition
;
Members
mode: Bit transmission mode (STREAM or FRAME)channels: Channel resources used by the clientnum_channels: Number of channel resourcesnum_hw_channels: Number of channels the transceiver is configured for [1..16]speed: Max bit transmission speed (Kbit/s){unnamed_union}: anonymousflow: RX flow type (SYNCHRONIZED or PIPELINE)arb_mode: Arbitration mode for TX frame (Round robin, priority)
struct hsi_board_info #
HSI client board info
Definition
;
Members
name: Name for the HSI devicehsi_id: HSI controller id where the client sitsport: Port number in the controller where the client sitstx_cfg: HSI TX configurationrx_cfg: HSI RX configurationplatform_data: Platform related dataarchdata: Architecture-dependent device data
struct hsi_client #
HSI client attached to an HSI port
Definition
;
Members
device: Driver model representation of the devicetx_cfg: HSI TX configurationrx_cfg: HSI RX configuration
struct hsi_client_driver #
Driver associated to an HSI client
Definition
;
Members
driver: Driver model representation of the driver
struct hsi_msg #
HSI message descriptor
Definition
;
Members
link: Free to use by the current descriptor ownercl: HSI device client that issues the transfersgt: Head of the scatterlist arraycontext: Client context data associated to the transfercomplete: Transfer completion callbackdestructor: Destructor to free resources when flushingstatus: Status of the transfer when completedactual_len: Actual length of data transferred on completionchannel: Channel were to TX/RX the messagettype: Transfer type (TX if set, RX otherwise)break_frame: if true HSI will send/receive a break frame. Data buffers are ignored in the request.
struct hsi_port #
HSI port device
Definition
;
Members
device: Driver model representation of the devicetx_cfg: Current TX path configurationrx_cfg: Current RX path configurationnum: Port numbershared: Set when port can be shared by different clientsclaimed: Reference count of clients which claimed the portlock: Serialize port claimasync: Asynchronous transfer callbacksetup: Callback to set the HSI client configurationflush: Callback to clean the HW state and destroy all pending transfersstart_tx: Callback to inform that a client wants to TX datastop_tx: Callback to inform that a client no longer wishes to TX datarelease: Callback to inform that a client no longer uses the portn_head: Notifier chain for signaling port events to the clients.
struct hsi_controller #
HSI controller device
Definition
;
Members
device: Driver model representation of the deviceowner: Pointer to the module owning the controllerid: HSI controller IDnum_ports: Number of ports in the HSI controllerport: Array of HSI ports
hsi_id() #
unsigned int Get HSI controller ID associated to a client
Parameters
struct hsi_client *cl: Pointer to a HSI client
Description
Return the controller id where the client is attached to
hsi_port_id() #
unsigned int Gets the port number a client is attached to
Parameters
struct hsi_client *cl: Pointer to HSI client
Description
Return the port number associated to the client
hsi_setup() #
int Configure the client's port
Parameters
struct hsi_client *cl: Pointer to the HSI client
Description
When sharing ports, clients should either relay on a single client setup or have the same setup for all of them.
Return -errno on failure, 0 on success
hsi_flush() #
int Flush all pending transactions on the client's port
Parameters
struct hsi_client *cl: Pointer to the HSI client
Description
This function will destroy all pending hsi_msg in the port and reset the HW port so it is ready to receive and transmit from a clean state.
Return -errno on failure, 0 on success
hsi_async_read() #
int Submit a read transfer
Parameters
struct hsi_client *cl: Pointer to the HSI clientstruct hsi_msg *msg: HSI message descriptor of the transfer
Description
Return -errno on failure, 0 on success
hsi_async_write() #
int Submit a write transfer
Parameters
struct hsi_client *cl: Pointer to the HSI clientstruct hsi_msg *msg: HSI message descriptor of the transfer
Description
Return -errno on failure, 0 on success
hsi_start_tx() #
int Signal the port that the client wants to start a TX
Parameters
struct hsi_client *cl: Pointer to the HSI client
Description
Return -errno on failure, 0 on success
hsi_stop_tx() #
int Signal the port that the client no longer wants to transmit
Parameters
struct hsi_client *cl: Pointer to the HSI client
Description
Return -errno on failure, 0 on success
hsi_port_unregister_clients() #
void Unregister an HSI port
Parameters
struct hsi_port *port: The HSI port to unregister
hsi_unregister_controller() #
void Unregister an HSI controller
Parameters
struct hsi_controller *hsi: The HSI controller to register
hsi_register_controller() #
int Register an HSI controller and its ports
Parameters
struct hsi_controller *hsi: The HSI controller to register
Description
Returns -errno on failure, 0 on success.
hsi_register_client_driver() #
int Register an HSI client to the HSI bus
Parameters
struct hsi_client_driver *drv: HSI client driver to register
Description
Returns -errno on failure, 0 on success.
hsi_put_controller() #
void Free an HSI controller
Parameters
struct hsi_controller *hsi: Pointer to the HSI controller to freed
Description
HSI controller drivers should only use this function if they need to free their allocated hsi_controller structures before a successful call to hsi_register_controller. Other use is not allowed.
hsi_alloc_controller() #
struct hsi_controller * Allocate an HSI controller and its ports
Parameters
unsigned int n_ports: Number of ports on the HSI controllergfp_t flags: Kernel allocation flags
Description
Return NULL on failure or a pointer to an hsi_controller on success.
hsi_free_msg() #
void Free an HSI message
Parameters
struct hsi_msg *msg: Pointer to the HSI message
Description
Client is responsible to free the buffers pointed by the scatterlists.
hsi_alloc_msg() #
struct hsi_msg * Allocate an HSI message
Parameters
unsigned int nents: Number of memory entriesgfp_t flags: Kernel allocation flags
Description
nents can be 0. This mainly makes sense for read transfer. In that case, HSI drivers will call the complete callback when there is data to be read without consuming it.
Return NULL on failure or a pointer to an hsi_msg on success.
hsi_async() #
int Submit an HSI transfer to the controller
Parameters
struct hsi_client *cl: HSI client sending the transferstruct hsi_msg *msg: The HSI transfer passed to controller
Description
The HSI message must have the channel, ttype, complete and destructor fields set beforehand. If nents > 0 then the client has to initialize also the scatterlists to point to the buffers to write to or read from.
HSI controllers relay on pre-allocated buffers from their clients and they do not allocate buffers on their own.
Once the HSI message transfer finishes, the HSI controller calls the complete callback with the status and actual_len fields of the HSI message updated. The complete callback can be called before returning from hsi_async.
Returns -errno on failure or 0 on success
hsi_claim_port() #
int Claim the HSI client's port
Parameters
struct hsi_client *cl: HSI client that wants to claim its portunsigned int share: Flag to indicate if the client wants to share the port or not.
Description
Returns -errno on failure, 0 on success.
hsi_release_port() #
void Release the HSI client's port
Parameters
struct hsi_client *cl: HSI client which previously claimed its port
hsi_register_port_event() #
int Register a client to receive port events
Parameters
struct hsi_client *cl: HSI client that wants to receive port eventsvoid (*handler)(struct hsi_client *, unsigned long): Event handler callback
Description
Clients should register a callback to be able to receive events from the ports. Registration should happen after claiming the port. The handler can be called in interrupt context.
Returns -errno on error, or 0 on success.
hsi_unregister_port_event() #
int Stop receiving port events for a client
Parameters
struct hsi_client *cl: HSI client that wants to stop receiving port events
Description
Clients should call this function before releasing their associated port.
Returns -errno on error, or 0 on success.
hsi_event() #
int Notifies clients about port events
Parameters
struct hsi_port *port: Port where the event occurredunsigned long event: The event type
Description
Clients should not be concerned about wake line behavior. However, due to a race condition in HSI HW protocol, clients need to be notified about wake line changes, so they can implement a workaround for it.
Events: HSI_EVENT_START_RX - Incoming wake line high HSI_EVENT_STOP_RX - Incoming wake line down
Returns -errno on error, or 0 on success.
hsi_get_channel_id_by_name() #
int acquire channel id by channel name
Parameters
struct hsi_client *cl: HSI client, which uses the channelchar *name: name the channel is known under
Description
Clients can call this function to get the hsi channel ids similar to requesting IRQs or GPIOs by name. This function assumes the same channel configuration is used for RX and TX.
Returns -errno on error or channel id on success.