blob: d5c43de02161070dba1c8274e624393b2a5a4f16 [file] [log] [blame]
/* uart.h - Nordic BLE UART based Bluetooth driver */
/*
* Copyright (c) 2015-2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* IPC Uart power management driver.
*/
extern struct driver ipc_uart_ns16550_driver;
int nble_open(void);
/**
* This function triggers the sending of PDU buffer over UART.
*
* This constructs an IPC message header and triggers the sending of it and
* message buffer. If a transmission is already ongoing, it will fail.
* In this case upper layer needs to queue the message buffer.
*
* @param dev structure of the opened device
* @param handle structure of opened IPC uart channel
* @param len length of message to send
* @param p_data message buffer to send
*
* @return IPC_UART_ERROR_OK TX has been initiated, IPC_UART_TX_BUSY a
* transmission is already going, message needs to be queued
*
* @note This function needs to be executed with (UART) irq off to avoid
* pre-emption from uart_ipc_isr causing state variable corruption.
* It also called from uart_ipc_isr() to send the next IPC message.
*/
int ipc_uart_ns16550_send_pdu(struct device *dev, void *handle, int len,
void *p_data);
/**
* This function registers a callback function being called on TX start/end.
*
* This constructs an IPC message header and triggers the sending of it and
* message buffer. If a transmission is already ongoing, it will fail. In
* this case upper layer needs to queue the message buffer.
*
* @param dev structure of the opened device
* @param cb callback function for OOB sleep mode handling called at tx start
* and end
* @param param parameter passed to cb when being called
*/
void ipc_uart_ns16550_set_tx_cb(struct device *dev, void (*cb)(bool, void*),
void *param);
/**
* Opens a UART channel for QRK/BLE Core IPC, and defines the callback function
* for receiving IPC messages.
*
* @param channel IPC channel ID to use
* @param cb Callback to handle messages
*
* @return
* - Pointer to channel structure if success,
* - NULL if opening fails.
*/
void *ipc_uart_channel_open(int channel, int (*cb)(int chan, int request,
int len, void *data));
/**
* The frame is a message.
*/
#define IPC_MSG_TYPE_MESSAGE 0x1
/**
* Requests to free a message.
*/
#define IPC_MSG_TYPE_FREE 0x2
/**
* Sets the MessageBox as synchronized.
*/
#define IPC_MSG_TYPE_SYNC 0x3
/**
* Allocates a port.
*
* This request is always flowing from a slave to the master.
*/
#define IPC_REQUEST_ALLOC_PORT 0x10
/**
* Registers a service.
*
* This request is always flowing from a slave to the master.
*/
#define IPC_REQUEST_REGISTER_SERVICE 0x11
/**
* Unregisters a service.
*/
#define IPC_REQUEST_DEREGISTER_SERVICE 0x12
/**
* The message is for test commands engine.
*/
#define IPC_REQUEST_REG_TCMD_ENGINE 0x13
/**
* Registers a Service Manager Proxy to the Service Manager.
*
* This request always flow from a slave to the master.
*/
#define IPC_REQUEST_REGISTER_PROXY 0x14
/**
* Notifies a panic (for log dump).
*/
#define IPC_PANIC_NOTIFICATION 0x15
/**
* The message is for power management.
*/
#define IPC_REQUEST_POWER_MANAGEMENT 0x16
/**
* Sends the log of a slave to the master (for log aggregation).
*/
#define IPC_REQUEST_LOGGER 0x17
/**
* The message is for power management (deep sleep).
*/
#define IPC_REQUEST_INFRA_PM 0x18