Fixed MTP to work with TWRP

This commit is contained in:
awab228 2018-06-19 23:16:04 +02:00
commit f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions

44
include/scsc/api/bhcs.h Normal file
View file

@ -0,0 +1,44 @@
/****************************************************************************
*
* Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved
*
****************************************************************************/
/****************************************************************************
* FILE
* bhcs.h - Bluetooth Host Configuration Structure
*
* DESCRIPTION
* This file specifies the layout of the Bluetooth Host Configuration
* Structure. The structure is written by the host and passed to the
* firmware as an argument to the service start callback function in
* the form of an offset that must be converted to a local address.
*
* ASSUMPTIONS
* The host and the firmware has the same endiannes.
* The ABI on the host and the firmware results in the same memory
* layout of the defined structure.
*
*/
#ifndef BHCS_H__
#define BHCS_H__
/* The version of the BHCS structure. Must be written to the version field
* by the host and confirmed to match the define by the firmware. Increment
* the version when changing the layout of the structure. This also serves
* as a rudimentary endianess check. */
#define BHCS_VERSION 2
struct BHCS {
uint32_t version; /* BHCS_VERSION */
uint32_t bsmhcp_protocol_offset; /* BSMHCP_PROTOCOL structure offset */
uint32_t bsmhcp_protocol_length; /* BSMHCP_PROTOCOL structure length */
uint32_t configuration_offset; /* Binary configuration data offset */
uint32_t configuration_length; /* Binary configuration data length */
uint32_t bluetooth_address_lap; /* Lower Address Part 00..23 */
uint8_t bluetooth_address_uap; /* Upper Address Part 24..31 */
uint16_t bluetooth_address_nap; /* Non-significant 32..47 */
};
#endif /* BHCS_H__ */

366
include/scsc/api/bsmhcp.h Normal file
View file

@ -0,0 +1,366 @@
/****************************************************************************
*
* Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved
*
****************************************************************************/
/****************************************************************************
* FILE
* bsmhcp.h - Bluetooth Shared Memory Host Controller Protocol
*
* DESCRIPTION
* This file specifies the layout of the Bluetooth Shared Memory
* Host Controller Protocol as described in SC-505753-DD
*/
#ifndef __BSMHCP_H__
#define __BSMHCP_H__
#define BSMHCP_TRANSFER_RING_CMD_SIZE (8)
#define BSMHCP_TRANSFER_RING_EVT_SIZE (32)
#define BSMHCP_TRANSFER_RING_ACL_SIZE (32)
/* Of the buffers in BSMHCP_TRANSFER_RING_ACL_SIZE, reserve a number for ULP
* operation. */
#define BSMHCP_TRANSFER_RING_ACL_ULP_RESERVED (4)
#define BSMHCP_TRANSFER_RING_SCO_SIZE (0)
#define BSMHCP_TRANSFER_RING_ACL_COUNT (36)
#define BSMHCP_TRANSFER_RING_TIMING_COUNT (64)
#define BSMHCP_CMD_EVT_BUFFER_SIZE (258)
#define BSMHCP_ACL_BUFFER_SIZE (1024)
#define BSMHCP_ACL_PACKET_SIZE (1021)
#define BSMHCP_ULP_PACKET_SIZE BSMHCP_ACL_PACKET_SIZE
#define BSMHCP_SCO_PACKET_SIZE (0)
#define BSMHCP_DATA_BUFFER_CMD_SIZE \
BSMHCP_TRANSFER_RING_CMD_SIZE
#define BSMHCP_DATA_BUFFER_EVT_SIZE \
BSMHCP_TRANSFER_RING_EVT_SIZE
#define BSMHCP_DATA_BUFFER_TX_ACL_SIZE \
(BSMHCP_TRANSFER_RING_ACL_SIZE - 2)
#define BSMHCP_DATA_BUFFER_RX_ACL_SIZE \
BSMHCP_TRANSFER_RING_ACL_SIZE
#define BSMHCP_EVENT_TYPE_NONE (0x00)
#define BSMHCP_EVENT_TYPE_CONNECTED (0x01)
#define BSMHCP_EVENT_TYPE_DISCONNECTED (0x02)
#define BSMHCP_ACL_BC_FLAG_BCAST_NON (0x00)
#define BSMHCP_ACL_BC_FLAG_BCAST_ACTIVE (0x40)
#define BSMHCP_ACL_BC_FLAG_BCAST_ALL (0x80)
#define BSMHCP_ACL_BC_FLAG_BCAST_RSVD (0xC0)
#define BSMHCP_ACL_BC_FLAG_BCAST_MASK (0xC0)
#define BSMHCP_ACL_PB_FLAG_START_NONFLUSH (0x00)
#define BSMHCP_ACL_PB_FLAG_CONT (0x10)
#define BSMHCP_ACL_PB_FLAG_START_FLUSH (0x20)
#define BSMHCP_ACL_PB_FLAG_RSVD_3 (0x30)
#define BSMHCP_ACL_PB_FLAG_MASK (0x30)
#define BSMHCP_ACL_L2CAP_FLAG_NON (0x00)
#define BSMHCP_ACL_L2CAP_FLAG_END (0x01)
#define BSMHCP_ACL_L2CAP_FLAG_MASK (0x01)
#define BSMHCP_SERVICE_BT_STATE_INACTIVE (0x00)
#define BSMHCP_SERVICE_BT_STATE_ACTIVE (0x01)
#define BSMHCP_CONTROLLER_STATE_ACTIVE (0x00000001)
#define BSMHCP_HCI_CONNECTION_HANDLE_LOOPBACK (0x4000)
#define BSMHCP_ALIGNMENT (32)
#define BSMHCP_FEATURE_LPA2DP (0x00000001)
#define BSMHCP_FEATURE_M4_INTERRUPTS (0x00000002)
#define BSMHCP_FEATURE_FW_INFORMATION (0x00000004)
#define BSMHCP_CONTROL_START_PANIC (0x10DEAD01)
#define BSMHCP_CONTROL_STOP_PANIC (0x0201DEAD)
#define BSMHCP_CONTROL_CONNECTION_PANIC (0xDEAD2002)
#define BSMHCP_FW_INFO_USER_DEFINED_COUNT (96)
#define BSMHCP_TIMING_SOURCE_ITIME (0)
#define BSMHCP_TIMING_SOURCE_ITIME_L1 (1)
#define BSMHCP_TIMING_SOURCE_RADIO_TX (2)
#define BSMHCP_TIMING_SOURCE_RADIO_RX (3)
#define BSMHCP_TIMING_SOURCE_RADIO_LC (4)
#define BSMHCP_TIMING_SOURCE_COUNT (5)
#define BSMHCP_DEBUG_INIT (0xFFFF)
#define BSMHCP_DEBUG_TIMESTAMP (0x0000)
#define BSMHCP_DEBUG_WRAP (0x0001)
#define BSMHCP_DEBUG_STRING (0x0002)
#define BSMHCP_DEBUG_FROM_AIR (0x0003)
#define BSMHCP_DEBUG_TO_AIR (0x0004)
#define BSMHCP_DEBUG_SPEEDY (0x0005)
#define BSMHCP_DEBUG_BINARY_DATA (0x0006)
#define BSMHCP_DEBUG_FILTER_BOOT (0x00000001)
#define BSMHCP_DEBUG_FILTER_SPEEDY (0x00000002)
#define BSMHCP_DEBUG_FILTER_RADIO (0x00000004)
#define BSMHCP_DEBUG_FILTER_SMM_ACL (0x00000008)
#define BSMHCP_DEBUG_FILTER_SMM_HCI (0x00000010)
#define BSMHCP_DEBUG_FILTER_LC (0x00000020)
#define BSMHCP_DEBUG_FILTER_LC_PAGE (0x00000040)
#define BSMHCP_DEBUG_FILTER_RADIOTEST (0x00000080)
#define BSMHCP_DEBUG_FILTER_FROM_AIR_DATA (0x00000100)
#define BSMHCP_DEBUG_FILTER_TO_AIR_DATA (0x00000200)
#define BSMHCP_DEBUG_FILTER_LM (0x00000400)
#define BSMHCP_DEBUG_FILTER_FSM (0x00000800)
#define BSMHCP_DEBUG_SPEEDY_FLAG_APB_CYCLE_DONE (0x00000002)
#define BSMHCP_DEBUG_SPEEDY_FLAG_APB_CYCLE_ERR (0x00000004)
#define BSMHCP_DEBUG_SPEEDY_FLAG_TIMEOUT_ERROR (0x00000008)
#define BSMHCP_DEBUG_SPEEDY_FLAG_WRITE (0x00000010)
#define BSMHCP_DEBUG_SPEEDY_FLAG_FOREGROUND (0x00000020)
#define BSMHCP_DEBUG_IDENTIFIER_HCI_CMD (0x00000000)
#define BSMHCP_DEBUG_IDENTIFIER_HCI_EVT (0x00000001)
#define BSMHCP_DEBUG_STRING_MAX (0x0100)
#define BSMHCP_DEBUG_POOL_SIZE (512 * 1024)
#define BSMHCP_INCREASE_INDEX(index, limit) \
((index) = ((index) + 1) % (limit))
#define BSMHCP_HAS_ROOM(write, read, limit) \
((((write) + 1) % (limit)) != (read))
struct BSMHCP_TD_CONTROL {
uint16_t length;
uint8_t data[BSMHCP_CMD_EVT_BUFFER_SIZE];
};
struct BSMHCP_TD_HCI_EVT {
uint16_t length;
uint16_t hci_connection_handle;
uint16_t event_type;
uint8_t data[BSMHCP_CMD_EVT_BUFFER_SIZE];
};
struct BSMHCP_TD_ACL_RX {
uint16_t hci_connection_handle;
uint16_t length;
uint8_t broadcast_flag;
uint8_t packet_boundary;
uint8_t disconnected;
uint8_t reserved;
uint8_t data[BSMHCP_ACL_BUFFER_SIZE];
};
struct BSMHCP_TD_ACL_TX_DATA {
uint16_t length;
uint8_t buffer_index;
uint8_t flags;
uint16_t hci_connection_handle;
uint16_t l2cap_cid;
};
struct BSMHCP_TD_ACL_TX_FREE {
uint8_t buffer_index;
uint8_t reserved;
uint16_t hci_connection_handle;
};
struct BSMHCP_ACL_TR_DRV_INDEX {
uint32_t read_free;
uint32_t write_data;
};
struct BSMHCP_ACL_TR_CTRL_INDEX {
uint32_t read_data;
uint32_t write_free;
};
struct BSMHCP_INDEX {
uint32_t read;
uint32_t write;
};
struct BSMHCP_DEBUG {
uint16_t type;
uint16_t length;
uint32_t timestamp;
};
struct BSMHCP_DEBUG_AIR_PACKET {
uint16_t type;
uint16_t length;
uint32_t timestamp;
uint8_t am_addr;
uint8_t lnk_type;
uint8_t pkt_type;
uint8_t link_flow;
uint8_t link_arqn;
uint8_t link_seqn;
uint8_t chan_type;
uint8_t l2cap_flow;
uint16_t payload_num_data_bytes;
uint16_t bb_pwr_status;
uint16_t payload_num_voice_bytes;
uint32_t access_code_sync_time;
uint32_t event_type;
uint16_t channel;
};
struct BSMHCP_DEBUG_SPEEDY_PACKET {
uint16_t type;
uint16_t length;
uint32_t timestamp;
uint32_t address;
uint32_t data;
uint32_t flags;
};
struct BSMHCP_DEBUG_BINARY_DATA_PACKET {
uint16_t type;
uint16_t length;
uint32_t timestamp;
uint32_t identifier;
};
struct BSMHCP_TIMING_PACKET {
uint16_t source;
uint16_t sequence_number;
uint32_t interrupt_enter;
uint32_t critical_section_enter;
uint32_t time[4];
uint32_t critical_section_leave;
uint32_t interrupt_leave;
};
struct BSMHCP_FW_INFO {
uint32_t r4_from_ap_interrupt_count;
uint32_t m4_from_ap_interrupt_count;
uint32_t r4_to_ap_interrupt_count;
uint32_t m4_to_ap_interrupt_count;
uint32_t bt_deep_sleep_time_total;
uint32_t bt_deep_sleep_wakeup_duration;
uint32_t sched_n_messages;
uint32_t user_defined_count;
uint32_t user_defined[BSMHCP_FW_INFO_USER_DEFINED_COUNT];
};
struct BSMHCP_HEADER {
/* AP RW - M4/R4 RO - 64 octets */
uint32_t magic_value; /* 0x00 */
uint16_t ap_to_fg_m4_int_src; /* 0x04 */
uint8_t service_request; /* 0x06 */
uint8_t reserved1; /* 0x07 */
uint32_t acl_buffer_size; /* 0x08 */
uint32_t cmd_evt_buffer_size; /* 0x0C */
uint32_t acl_tx_buffers; /* 0x10 */
uint16_t ap_to_bg_int_src; /* 0x14 */
uint16_t ap_to_fg_int_src; /* 0x16 */
uint16_t bg_to_ap_int_src; /* 0x18 */
uint16_t fg_to_ap_int_src; /* 0x1A */
uint32_t mailbox_offset; /* 0x1C */
uint32_t debug_output_offset; /* 0x20 */
uint32_t mailbox_hci_cmd_write; /* 0x24 */
uint32_t mailbox_hci_evt_read; /* 0x28 */
uint32_t mailbox_acl_tx_write; /* 0x2C */
uint32_t mailbox_acl_free_read; /* 0x30 */
uint32_t mailbox_acl_rx_read; /* 0x34 */
uint32_t mailbox_debug_read; /* 0x38 */
uint32_t smm_output_filter; /* 0x3C */
/* AP RO - R4 RW - M4 NA - 32 octets */
uint16_t panic_deathbed_confession; /* 0x40 */
uint16_t panic_diatribe_value; /* 0x42 */
uint32_t mailbox_hci_cmd_read; /* 0x44 */
uint32_t mailbox_hci_evt_write; /* 0x48 */
uint32_t controller_flags; /* 0x4C */
uint32_t firmware_features; /* 0x50 */
uint16_t reserved_u16; /* 0x54 */
uint8_t service_state; /* 0x56 */
uint8_t reserved_u8; /* 0x57 */
uint32_t mailbox_r4_debug_write; /* 0x58 */
uint8_t reserved3[0x04]; /* 0x5C */
/* AP RO - R4 NA - M4 RW - 32 octets */
uint32_t mailbox_acl_tx_read; /* 0x60 */
uint32_t mailbox_acl_free_write; /* 0x64 */
uint32_t mailbox_acl_rx_write; /* 0x68 */
uint32_t mailbox_timing_write; /* 0x6C */
uint32_t mailbox_m4_debug_write; /* 0x70 */
uint8_t reserved4[0x0C]; /* 0x74 */
/* AP RO - R4/M4 RW - 32 octets */
uint32_t mailbox_debug_write; /* 0x80 */
uint8_t reserved5[0x1C]; /* 0x84 */
/* AP RW - M4/R4 RO */
uint32_t mailbox_timing_read; /* 0xA0 */
uint32_t debug_r4_offset; /* 0xA4 */
uint32_t debug_r4_length; /* 0xA8 */
uint32_t debug_m4_offset; /* 0xAC */
uint32_t debug_m4_length; /* 0xB0 */
uint32_t mailbox_r4_debug_read; /* 0xB4 */
uint32_t mailbox_m4_debug_read; /* 0xB8 */
uint16_t info_ap_to_bg_int_src; /* 0xBC */
uint16_t info_bg_to_ap_int_src; /* 0xBE */
uint32_t mxlog_filter; /* 0xC0 */
uint32_t firmware_control; /* 0xC4 */
uint8_t reserved6[0x24]; /* 0xC8 */
/* Obsolete region - not used */
uint32_t smm_debug_read; /* 0xEC */
uint32_t smm_debug_write; /* 0xF0 */
uint32_t smm_exception; /* 0xF4 */
uint32_t avdtp_detect_stream_id; /* 0xF8 */
uint32_t smm_int_ready; /* 0xFE */
};
struct BSMHCP_PROTOCOL {
/* header offset: 0x00000000 */
volatile struct BSMHCP_HEADER header;
/* from AP */
struct BSMHCP_TD_CONTROL /* offset: 0x00000100 */
hci_cmd_transfer_ring[BSMHCP_TRANSFER_RING_CMD_SIZE];
uint8_t /* offset: 0x00000920 */
to_air_reserved[0x2080];
struct BSMHCP_TD_ACL_TX_DATA /* offset: 0x000029A0 */
acl_tx_data_transfer_ring[BSMHCP_TRANSFER_RING_ACL_SIZE];
uint8_t /* offset: 0x00002AA0 */
acl_tx_buffer[BSMHCP_DATA_BUFFER_TX_ACL_SIZE]
[BSMHCP_ACL_BUFFER_SIZE];
/* Padding used to ensure minimum 32 octets between sections */
uint8_t reserved[0x20]; /* offset: 0x0000A2A0 */
/* to AP */
struct BSMHCP_TD_HCI_EVT /* offset: 0x0000A2C0 */
hci_evt_transfer_ring[BSMHCP_TRANSFER_RING_EVT_SIZE];
struct BSMHCP_TIMING_PACKET /* offset: 0x0000C3C0 */
timing_transfer_ring[BSMHCP_TRANSFER_RING_TIMING_COUNT];
struct BSMHCP_FW_INFO /* offset: 0x0000CCC0 */
information;
uint8_t /* offset: 0x0000CCC0 + sizoef(struct BSMHCP_FW_INFO) */
from_air_reserved[0x1780 - sizeof(struct BSMHCP_FW_INFO)];
struct BSMHCP_TD_ACL_RX /* offset: 0x0000E440 */
acl_rx_transfer_ring[BSMHCP_TRANSFER_RING_ACL_SIZE];
struct BSMHCP_TD_ACL_TX_FREE /* offset: 0x00016540 */
acl_tx_free_transfer_ring[BSMHCP_TRANSFER_RING_ACL_SIZE];
};
#define BSMHCP_TD_ACL_RX_CONTROL_SIZE \
(sizeof(struct BSMHCP_TD_ACL_RX) - BSMHCP_ACL_BUFFER_SIZE)
#define BSMHCP_PROTOCOL_MAGICVALUE \
((BSMHCP_ACL_BUFFER_SIZE | BSMHCP_CMD_EVT_BUFFER_SIZE | \
(offsetof(struct BSMHCP_PROTOCOL, acl_tx_buffer) << 15)) ^ \
sizeof(struct BSMHCP_PROTOCOL))
#endif /* __BSMHCP_H__ */

21
include/scsc/kic/slsi_kic.h Executable file
View file

@ -0,0 +1,21 @@
/****************************************************************************
*
* Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved
*
****************************************************************************/
#ifndef __SLSI_KIC_H
#define __SLSI_KIC_H
#include <scsc/kic/slsi_kic_prim.h>
int slsi_kic_system_event_ind(enum slsi_kic_system_event_category event_cat,
enum slsi_kic_system_events event, gfp_t flags);
int slsi_kic_service_information_ind(enum slsi_kic_technology_type tech,
struct slsi_kic_service_info *info);
int slsi_kic_firmware_event_ind(uint16_t firmware_event_type, uint32_t tech_type,
uint32_t contain_type,
struct slsi_kic_firmware_event_ccp_host *event);
#endif /* #ifndef __SLSI_KIC_H */

65
include/scsc/kic/slsi_kic_bt.h Executable file
View file

@ -0,0 +1,65 @@
/****************************************************************************
*
* Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved
*
****************************************************************************/
#ifndef __SLSI_KIC_BT_H
#define __SLSI_KIC_BT_H
#include <scsc/kic/slsi_kic_prim.h>
/**
* struct slsi_kic_bt_ops - backend description for BT service driver ops.
*
* This struct is registered by the BT service driver during initilisation
* in order provide BT specific services, which can be used by KIC.
*
* All callbacks except where otherwise noted should return 0 on success or a
* negative error code.
*
* @trigger_recovery: Trigger a BT firmware subsystem recovery. The variable
* @type specifies the recovery type.
*/
struct slsi_kic_bt_ops {
int (*trigger_recovery)(void *priv, enum slsi_kic_test_recovery_type type);
};
#ifdef CONFIG_SAMSUNG_KIC
/**
* slsi_kic_bt_ops_register - register bt_ops with KIC
*
* @priv: Private pointer, which will be included in all calls from KIC.
* @bt_ops: The bt_ops to register.
*
* Returns 0 on success or a negative error code.
*/
int slsi_kic_bt_ops_register(void *priv, struct slsi_kic_bt_ops *bt_ops);
/**
* slsi_kic_bt_ops_unregister - unregister bt_ops with KIC
*
* @bt_ops: The bt_ops to unregister.
*
* After this call, no more requests can be made, but the call may sleep to wait
* for an outstanding request that is being handled.
*/
void slsi_kic_bt_ops_unregister(struct slsi_kic_bt_ops *bt_ops);
#else
#define slsi_kic_bt_ops_register(a, b) \
do { \
(void)(a); \
(void)(b); \
} while (0)
#define slsi_kic_bt_ops_unregister(a) \
do { \
(void)(a); \
} while (0)
#endif /* CONFIG_SAMSUNG_KIC */
#endif /* #ifndef __SLSI_KIC_BT_H */

50
include/scsc/kic/slsi_kic_cm.h Executable file
View file

@ -0,0 +1,50 @@
/****************************************************************************
*
* Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved
*
****************************************************************************/
#ifndef __SLSI_KIC_CM_H
#define __SLSI_KIC_CM_H
#include <scsc/kic/slsi_kic_prim.h>
/**
* struct slsi_kic_cm_ops - backend description for Chip Manager (CM) driver ops
*
* This struct is registered by the Chip Manager driver during initilisation
* in order provide CM specific services, which can be used by KIC.
*
* All callbacks except where otherwise noted should return 0 on success or a
* negative error code.
*
* @trigger_recovery: Trigger a firmware crash, which requires a full chip
* recovery.
* @type specifies the recovery type.
*/
struct slsi_kic_cm_ops {
int (*trigger_recovery)(void *priv, enum slsi_kic_test_recovery_type type);
};
/**
* slsi_kic_cm_ops_register - register cm_ops with KIC
*
* @priv: Private pointer, which will be included in all calls from KIC.
* @wifi_ops: The wifi_ops to register.
*
* Returns 0 on success or a negative error code.
*/
int slsi_kic_cm_ops_register(void *priv, struct slsi_kic_cm_ops *cm_ops);
/**
* slsi_kic_cm_ops_unregister - unregister cm_ops with KIC
*
* @cm_ops: The cm_ops to unregister.
*
* After this call, no more requests can be made, but the call may sleep to wait
* for an outstanding request that is being handled.
*/
void slsi_kic_cm_ops_unregister(struct slsi_kic_cm_ops *cm_ops);
#endif /* #ifndef __SLSI_KIC_CM_H */

70
include/scsc/kic/slsi_kic_lib.h Executable file
View file

@ -0,0 +1,70 @@
/****************************************************************************
*
* Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved
*
****************************************************************************/
#ifndef __SLSI_KIC_LIB_H
#define __SLSI_KIC_LIB_H
#ifdef CONFIG_SLSI_KIC_API_ENABLED
#include <scsc/kic/slsi_kic.h>
#endif
#include <scsc/kic/slsi_kic_prim.h>
/**
* Library functions for sending information to kernel KIC, which will process
* the event and take appropriate action, i.e. forward to relevant user
* processes etc.
*/
#ifdef CONFIG_SLSI_KIC_API_ENABLED
static inline void slsi_kic_system_event(enum slsi_kic_system_event_category event_cat,
enum slsi_kic_system_events event, gfp_t flags)
{
(void)slsi_kic_system_event_ind(event_cat, event, flags);
}
static inline void slsi_kic_service_information(enum slsi_kic_technology_type tech,
struct slsi_kic_service_info *info)
{
(void)slsi_kic_service_information_ind(tech, info);
}
static inline void slsi_kic_firmware_event(uint16_t firmware_event_type,
enum slsi_kic_technology_type tech_type,
uint32_t contain_type,
struct slsi_kic_firmware_event_ccp_host *event)
{
(void)slsi_kic_firmware_event_ind(firmware_event_type, tech_type,
contain_type, event);
}
#else
#define slsi_kic_system_event(a, b, c) \
do { \
(void)(a); \
(void)(b); \
(void)(c); \
} while (0)
#define slsi_kic_service_information(a, b) \
do { \
(void)(a); \
(void)(b); \
} while (0)
#define slsi_kic_firmware_event(a, b, c, d) \
do { \
(void)(a); \
(void)(b); \
(void)(c); \
(void)(d); \
} while (0)
#endif
#endif /* #ifndef __SLSI_KIC_LIB_H */

View file

@ -0,0 +1,420 @@
/****************************************************************************
*
* Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved
*
****************************************************************************/
#ifndef __SLSI_KIC_PRIM_H
#define __SLSI_KIC_PRIM_H
#ifdef __KERNEL__
#include <net/netlink.h>
#else
#include <netlink/attr.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define SLSI_KIC_INTERFACE_VERSION_MAJOR 1
#define SLSI_KIC_INTERFACE_VERSION_MINOR 0
/**
* Common
*/
enum slsi_kic_technology_type {
slsi_kic_technology_type_curator,
slsi_kic_technology_type_bt,
slsi_kic_technology_type_wifi,
slsi_kic_technology_type_audio,
slsi_kic_technology_type_gnss,
slsi_kic_technology_type_nfc,
slsi_kic_technology_type_janitor,
slsi_kic_technology_type_common,
/* keep last */
slsi_kic_technology_type__after_last,
slsi_kic_technology_type_max_category = slsi_kic_technology_type__after_last - 1
};
static const char *const slsi_kic_technology_type_text[slsi_kic_technology_type_max_category + 1] = {
"curator",
"bt",
"wifi",
"audio",
"gnss",
"nfc",
"janitor"
};
/**
* System events
*/
enum slsi_kic_system_event_category {
slsi_kic_system_event_category_initialisation,
slsi_kic_system_event_category_deinitialisation,
slsi_kic_system_event_category_error,
slsi_kic_system_event_category_recovery,
/* keep last */
slsi_kic_system_category__after_last,
slsi_kic_system_category_max_category = slsi_kic_system_category__after_last - 1
};
static const char *const slsi_kic_system_category_text[slsi_kic_system_category_max_category + 1] = {
"Initialisation",
"Deinitialisation",
"Error",
"Recovery"
};
enum slsi_kic_system_events {
slsi_kic_system_events_wifi_on,
slsi_kic_system_events_wifi_off,
slsi_kic_system_events_wifi_suspend,
slsi_kic_system_events_wifi_resume,
slsi_kic_system_events_wifi_service_driver_attached,
slsi_kic_system_events_wifi_service_driver_detached,
slsi_kic_system_events_wifi_firmware_patch_downloaded,
slsi_kic_system_events_wifi_service_driver_started,
slsi_kic_system_events_wifi_service_driver_stopped,
slsi_kic_system_events_bt_on,
slsi_kic_system_events_bt_off,
slsi_kic_system_events_bt_service_driver_attached,
slsi_kic_system_events_bt_service_driver_detached,
slsi_kic_system_events_bt_firmware_patch_downloaded,
slsi_kic_system_events_curator_firmware_patch_downloaded,
slsi_kic_system_events_sdio_powered,
slsi_kic_system_events_sdio_inserted,
slsi_kic_system_events_sdio_removed,
slsi_kic_system_events_sdio_powered_off,
slsi_kic_system_events_sdio_error,
slsi_kic_system_events_uart_powered,
slsi_kic_system_events_uart_powered_off,
slsi_kic_system_events_uart_error,
slsi_kic_system_events_coredump_in_progress,
slsi_kic_system_events_coredump_done,
slsi_kic_system_events_subsystem_crashed,
slsi_kic_system_events_subsystem_recovered,
slsi_kic_system_events_host_ready_ind,
/* keep last */
slsi_kic_system_events__after_last,
slsi_kic_system_events_max_event = slsi_kic_system_events__after_last - 1
};
static const char *const slsi_kic_system_event_text[slsi_kic_system_events_max_event + 1] = {
"Wi-Fi on",
"Wi-Fi off",
"Wi-Fi suspend",
"Wi-Fi resume",
"Wi-Fi service driver attached",
"Wi-Fi service driver detached",
"Wi-Fi firmware patch downloaded",
"Wi-Fi service driver started",
"Wi-Fi service driver stopped",
"BT on",
"BT off",
"BT service driver attached",
"BT service driver detached",
"BT firmware patch downloaded",
"Curator firmware patch downloaded",
"SDIO powered",
"SDIO inserted",
"SDIO removed",
"SDIO powered off",
"SDIO error",
"UART powered",
"UART powered off",
"UART error",
"Coredump in progress",
"Coredump done",
"Subsystem has crashed",
"Subsystem has been recovered",
"CCP Host ready Ind sent"
};
/**
* Time stamp
*/
struct slsi_kic_timestamp {
uint64_t tv_sec; /* seconds */
uint64_t tv_nsec; /* nanoseconds */
};
/* Policy */
enum slsi_kic_attr_timestamp_attributes {
__SLSI_KIC_ATTR_TIMESTAMP_INVALID,
SLSI_KIC_ATTR_TIMESTAMP_TV_SEC,
SLSI_KIC_ATTR_TIMESTAMP_TV_NSEC,
/* keep last */
__SLSI_KIC_ATTR_TIMESTAMP_AFTER_LAST,
SLSI_KIC_ATTR_TIMESTAMP_MAX = __SLSI_KIC_ATTR_TIMESTAMP_AFTER_LAST - 1
};
/**
* Firmware event
*/
enum slsi_kic_firmware_event_type {
slsi_kic_firmware_event_type_panic,
slsi_kic_firmware_event_type_fault,
/* keep last */
slsi_kic_firmware_events__after_last,
slsi_kic_firmware_events_max_event = slsi_kic_firmware_events__after_last - 1
};
static const char *const slsi_kic_firmware_event_type_text[slsi_kic_firmware_events_max_event + 1] = {
"Firmware panic",
"Firmware fault"
};
enum slsi_kic_firmware_container_type {
slsi_kic_firmware_container_type_ccp_host,
};
/*
* Firmware event: CCP host container
*/
#define SLSI_KIC_FIRMWARE_EVENT_CCP_HOST_ARG_LENGTH 16
struct slsi_kic_firmware_event_ccp_host {
uint32_t id;
uint32_t level;
char *level_string;
uint32_t timestamp;
uint32_t cpu;
uint32_t occurences;
uint32_t arg_length;
uint8_t *arg;
};
/**
* Trigger recovery
*/
enum slsi_kic_test_recovery_type {
slsi_kic_test_recovery_type_subsystem_panic,
slsi_kic_test_recovery_type_emulate_firmware_no_response,
slsi_kic_test_recovery_type_watch_dog,
slsi_kic_test_recovery_type_chip_crash,
slsi_kic_test_recovery_type_service_start_panic,
slsi_kic_test_recovery_type_service_stop_panic,
};
enum slsi_kic_test_recovery_status {
slsi_kic_test_recovery_status_ok,
slsi_kic_test_recovery_status_error_invald_param,
slsi_kic_test_recovery_status_error_send_msg,
};
/* Policy */
enum slsi_kic_attr_firmware_event_ccp_host_attributes {
__SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_INVALID,
SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_ID,
SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_LEVEL,
SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_LEVEL_STRING,
SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_TIMESTAMP,
SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_CPU,
SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_OCCURENCES,
SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_ARG,
/* keep last */
__SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_AFTER_LAST,
SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_MAX = __SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_AFTER_LAST - 1
};
/**
* System information
*/
struct slsi_kic_service_info {
char ver_str[128];
uint16_t fw_api_major;
uint16_t fw_api_minor;
uint16_t release_product;
uint16_t host_release_iteration;
uint16_t host_release_candidate;
};
/* Policy */
enum slsi_kic_attr_service_info_attributes {
__SLSI_KIC_ATTR_SERVICE_INFO_INVALID,
SLSI_KIC_ATTR_SERVICE_INFO_VER_STR,
SLSI_KIC_ATTR_SERVICE_INFO_FW_API_MAJOR,
SLSI_KIC_ATTR_SERVICE_INFO_FW_API_MINOR,
SLSI_KIC_ATTR_SERVICE_INFO_RELEASE_PRODUCT,
SLSI_KIC_ATTR_SERVICE_INFO_HOST_RELEASE_ITERATION,
SLSI_KIC_ATTR_SERVICE_INFO_HOST_RELEASE_CANDIDATE,
/* keep last */
__SLSI_KIC_ATTR_SERVICE_INFO_AFTER_LAST,
SLSI_KIC_ATTR_SERVICE_INFO_MAX = __SLSI_KIC_ATTR_SERVICE_INFO_AFTER_LAST - 1
};
/**
* enum slsi_kic_commands - supported Samsung KIC commands
*
* @SLSI_KIC_CMD_UNSPEC: unspecified command to catch errors
* @SLSI_KIC_CMD_KIC_INTERFACE_VERSION_NUMBER_REQ: Requests the KIC interface
* version numbers to be send back.
* @SLSI_KIC_CMD_SYSTEM_EVENT_IND: Indicate a system event to user space.
* @SLSI_KIC_CMD_SERVICE_INFORMATION_REQ: Requests information for all
* already enabled subsystems.
* @SLSI_KIC_CMD_SERVICE_INFORMATION_IND: Indicate that a new subsystem has
* been started and the information for this subsystem.
* @SLSI_KIC_CMD_TEST_TRIGGER_RECOVERY_REQ: Triggers a recovery (crash) for a
* subsystem specified in the primitive.
* @SLSI_KIC_CMD_FIRMWARE_EVENT_IND: Indicates a firmware event to user space.
* @SLSI_KIC_CMD_ECHO_REQ: Request an echo (test primitive, which will be
* removed later).
*
* @SLSI_KIC_CMD_MAX: highest used command number
* @__SLSI_KIC_CMD_AFTER_LAST: internal use
*/
enum slsi_kic_commands {
/* Do not change the order or add anything between, this is ABI! */
SLSI_KIC_CMD_UNSPEC,
SLSI_KIC_CMD_KIC_INTERFACE_VERSION_NUMBER_REQ,
SLSI_KIC_CMD_SYSTEM_EVENT_IND,
SLSI_KIC_CMD_SERVICE_INFORMATION_REQ,
SLSI_KIC_CMD_SERVICE_INFORMATION_IND,
SLSI_KIC_CMD_TEST_TRIGGER_RECOVERY_REQ,
SLSI_KIC_CMD_FIRMWARE_EVENT_IND,
SLSI_KIC_CMD_ECHO_REQ,
/* add new commands above here */
/* used to define SLSI_KIC_CMD_MAX below */
__SLSI_KIC_CMD_AFTER_LAST,
SLSI_KIC_CMD_MAX = __SLSI_KIC_CMD_AFTER_LAST - 1
};
/**
* enum slsi_kic_attrs - Samsung KIC netlink attributes
*
* @SLSI_KIC_ATTR_UNSPEC: unspecified attribute to catch errors
* @SLSI_KIC_ATTR_KIC_VERSION_MAJOR: KIC version number - increments when the
* interface is updated with backward incompatible changes.
* @SLSI_KIC_ATTR_KIC_VERSION_MINOR: KIC version number - increments when the
* interface is updated with backward compatible changes.
* @SLSI_KIC_ATTR_TECHNOLOGY_TYPE: Technology type
* @SLSI_KIC_ATTR_SYSTEM_EVENT_CATEGORY: System event category
* @SLSI_KIC_ATTR_SYSTEM_EVENT: System event
* @SLSI_KIC_ATTR_SERVICE_INFO: Pass service info to user space.
* @SLSI_KIC_ATTR_NUMBER_OF_ENCODED_SERVICES: The attribute is used to determine
* the number of encoded services in the payload
* @SLSI_KIC_ATTR_TEST_RECOVERY_TYPE: Specifies the recovery type.
* @SLSI_KIC_ATTR_TIMESTAMP: A timestamp - ideally nano second resolution and
* precision, but it's platform dependent.
* @SLSI_KIC_ATTR_FIRMWARE_EVENT_TYPE: A firmware even type - panic or fault
* @SLSI_KIC_ATTR_FIRMWARE_CONTAINER_TYPE: Indicates container type carried in
* payload.
* @SLSI_KIC_ATTR_FIRMWARE_EVENT_CONTAINER_CCP_HOST: The firmware event data.
* @SLSI_KIC_ATTR_TRIGGER_RECOVERY_STATUS: Indicates if the recovery has been
* successfully triggered. The recovery signalling will happen afterwards as
* normal system events.
* @SLSI_KIC_ATTR_ECHO: An echo test primitive, which will be removed later.
*
* @SLSI_KIC_ATTR_MAX: highest attribute number currently defined
* @__SLSI_KIC_ATTR_AFTER_LAST: internal use
*/
enum slsi_kic_attrs {
/* Do not change the order or add anything between, this is ABI! */
SLSI_KIC_ATTR_UNSPEC,
SLSI_KIC_ATTR_KIC_VERSION_MAJOR,
SLSI_KIC_ATTR_KIC_VERSION_MINOR,
SLSI_KIC_ATTR_TECHNOLOGY_TYPE,
SLSI_KIC_ATTR_SYSTEM_EVENT_CATEGORY,
SLSI_KIC_ATTR_SYSTEM_EVENT,
SLSI_KIC_ATTR_SERVICE_INFO,
SLSI_KIC_ATTR_NUMBER_OF_ENCODED_SERVICES,
SLSI_KIC_ATTR_TEST_RECOVERY_TYPE,
SLSI_KIC_ATTR_TIMESTAMP,
SLSI_KIC_ATTR_FIRMWARE_EVENT_TYPE,
SLSI_KIC_ATTR_FIRMWARE_CONTAINER_TYPE,
SLSI_KIC_ATTR_FIRMWARE_EVENT_CONTAINER_CCP_HOST,
SLSI_KIC_ATTR_TRIGGER_RECOVERY_STATUS,
SLSI_KIC_ATTR_ECHO,
/* Add attributes here, update the policy below */
__SLSI_KIC_ATTR_AFTER_LAST,
SLSI_KIC_ATTR_MAX = __SLSI_KIC_ATTR_AFTER_LAST - 1
};
/* Policy for the attributes */
static const struct nla_policy slsi_kic_attr_policy[SLSI_KIC_ATTR_MAX + 1] = {
[SLSI_KIC_ATTR_KIC_VERSION_MAJOR] = { .type = NLA_U32 },
[SLSI_KIC_ATTR_KIC_VERSION_MINOR] = { .type = NLA_U32 },
[SLSI_KIC_ATTR_TECHNOLOGY_TYPE] = { .type = NLA_U32 },
[SLSI_KIC_ATTR_SYSTEM_EVENT_CATEGORY] = { .type = NLA_U32 },
[SLSI_KIC_ATTR_SYSTEM_EVENT] = { .type = NLA_U32 },
[SLSI_KIC_ATTR_SERVICE_INFO] = { .type = NLA_NESTED, },
[SLSI_KIC_ATTR_NUMBER_OF_ENCODED_SERVICES] = { .type = NLA_U32 },
[SLSI_KIC_ATTR_TEST_RECOVERY_TYPE] = { .type = NLA_U32 },
[SLSI_KIC_ATTR_TIMESTAMP] = { .type = NLA_NESTED },
[SLSI_KIC_ATTR_FIRMWARE_EVENT_TYPE] = { .type = NLA_U16 },
[SLSI_KIC_ATTR_FIRMWARE_CONTAINER_TYPE] = { .type = NLA_U32 },
[SLSI_KIC_ATTR_FIRMWARE_EVENT_CONTAINER_CCP_HOST] = { .type = NLA_NESTED },
[SLSI_KIC_ATTR_TRIGGER_RECOVERY_STATUS] = { .type = NLA_U32 },
[SLSI_KIC_ATTR_ECHO] = { .type = NLA_U32 },
};
/* Policy for the slsi_kic_firmware_event_ccp_host attribute */
static const struct nla_policy slsi_kic_attr_firmware_event_ccp_host_policy[SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_MAX + 1] = {
[SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_ID] = { .type = NLA_U32 },
[SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_LEVEL] = { .type = NLA_U32 },
#ifdef __KERNEL__
[SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_LEVEL_STRING] = { .type = NLA_STRING, .len = 128 },
#else
[SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_LEVEL_STRING] = { .type = NLA_STRING, .maxlen = 128 },
#endif
[SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_TIMESTAMP] = { .type = NLA_U32 },
[SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_CPU] = { .type = NLA_U32 },
[SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_OCCURENCES] = { .type = NLA_U32 },
#ifdef __KERNEL__
[SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_ARG] = { .type = NLA_UNSPEC,
.len = SLSI_KIC_FIRMWARE_EVENT_CCP_HOST_ARG_LENGTH },
#else
[SLSI_KIC_ATTR_FIRMWARE_EVENT_CCP_HOST_ARG] = { .type = NLA_UNSPEC,
.maxlen = SLSI_KIC_FIRMWARE_EVENT_CCP_HOST_ARG_LENGTH },
#endif
};
/* Policy for the slsi_kic_service_info attribute */
static const struct nla_policy slsi_kic_attr_service_info_policy[SLSI_KIC_ATTR_SERVICE_INFO_MAX + 1] = {
#ifdef __KERNEL__
[SLSI_KIC_ATTR_SERVICE_INFO_VER_STR] = { .type = NLA_STRING, .len = 128 },
#else
[SLSI_KIC_ATTR_SERVICE_INFO_VER_STR] = { .type = NLA_STRING, .maxlen = 128 },
#endif
[SLSI_KIC_ATTR_SERVICE_INFO_FW_API_MAJOR] = { .type = NLA_U16 },
[SLSI_KIC_ATTR_SERVICE_INFO_FW_API_MINOR] = { .type = NLA_U16 },
[SLSI_KIC_ATTR_SERVICE_INFO_RELEASE_PRODUCT] = { .type = NLA_U16 },
[SLSI_KIC_ATTR_SERVICE_INFO_HOST_RELEASE_ITERATION] = { .type = NLA_U16 },
[SLSI_KIC_ATTR_SERVICE_INFO_HOST_RELEASE_CANDIDATE] = { .type = NLA_U16 },
};
/* Policy for the slsi_kic_timestamp attribute */
static const struct nla_policy slsi_kic_attr_timestamp_policy[SLSI_KIC_ATTR_TIMESTAMP_MAX + 1] = {
[SLSI_KIC_ATTR_TIMESTAMP_TV_SEC] = { .type = NLA_U64 },
[SLSI_KIC_ATTR_TIMESTAMP_TV_NSEC] = { .type = NLA_U64 },
};
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* #ifndef __SLSI_KIC_PRIM_H */

View file

@ -0,0 +1,64 @@
/****************************************************************************
*
* Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved
*
****************************************************************************/
#ifndef __SLSI_KIC_WIFI_H
#define __SLSI_KIC_WIFI_H
#include <scsc/kic/slsi_kic_prim.h>
/**
* struct slsi_kic_wifi_ops - backend description for Wi-Fi service driver ops.
*
* This struct is registered by the Wi-Fi service driver during initilisation
* in order provide Wi-Fi specific services, which can be used by KIC.
*
* All callbacks except where otherwise noted should return 0 on success or a
* negative error code.
*
* @trigger_recovery: Trigger a Wi-Fi firmware subsystem recovery. The variable
* @type specifies the recovery type.
*/
struct slsi_kic_wifi_ops {
int (*trigger_recovery)(void *priv, enum slsi_kic_test_recovery_type type);
};
#ifdef CONFIG_SAMSUNG_KIC
/**
* slsi_kic_wifi_ops_register - register wifi_ops with KIC
*
* @priv: Private pointer, which will be included in all calls from KIC.
* @wifi_ops: The wifi_ops to register.
*
* Returns 0 on success or a negative error code.
*/
int slsi_kic_wifi_ops_register(void *priv, struct slsi_kic_wifi_ops *wifi_ops);
/**
* slsi_kic_wifi_ops_unregister - unregister wifi_ops with KIC
*
* @wifi_ops: The wifi_ops to unregister.
*
* After this call, no more requests can be made, but the call may sleep to wait
* for an outstanding request that is being handled.
*/
void slsi_kic_wifi_ops_unregister(struct slsi_kic_wifi_ops *wifi_ops);
#else
#define slsi_kic_wifi_ops_register(a, b) \
do { \
(void)(a); \
(void)(b); \
} while (0)
#define slsi_kic_wifi_ops_unregister(a) \
do { \
(void)(a); \
} while (0)
#endif /* CONFIG_SAMSUNG_KIC */
#endif /* #ifndef __SLSI_KIC_WIFI_H */

697
include/scsc/scsc_logring.h Normal file
View file

@ -0,0 +1,697 @@
/****************************************************************************
*
* Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
****************************************************************************/
#ifndef _SCSC_LOGRING_H_
#define _SCSC_LOGRING_H_
#include <linux/types.h>
#include <linux/types.h>
#include <linux/printk.h>
#include <linux/device.h>
#define CONFIG_SCSC_DEBUG_COMPATIBILITY 1
/* NOTE_CREATING_TAGS: when adding a tag here REMEMBER to add it also
* where required, taking care to maintain the same ordering.
* (Search 4 NOTE_CREATING_TAGS)
*/
enum scsc_logring_tags {
FIRST_TAG,
FIRST_BIN_TAG = FIRST_TAG,
BINARY = FIRST_BIN_TAG,
BIN_WIFI_CTRL_RX,
BIN_WIFI_DATA_RX,
BIN_WIFI_CTRL_TX,
BIN_WIFI_DATA_TX,
LAST_BIN_TAG = BIN_WIFI_DATA_TX,
NO_TAG,
WLBT = NO_TAG,
WIFI_RX,
WIFI_TX,
BT_COMMON,
BT_H4,
BT_FW,
BT_RX,
BT_TX,
CPKTBUFF,
FW_LOAD,
FW_PANIC,
GDB_TRANS,
MIF,
CLK20,
CLK20_TEST,
MX_FILE,
MX_FW,
MX_SAMPLER,
MXLOG_TRANS,
MXMAN,
MXMAN_TEST,
MXMGT_TRANS,
MX_MMAP,
MX_PROC,
PANIC_MON,
PCIE_MIF,
PLAT_MIF,
KIC_COMMON,
#ifdef CONFIG_SCSC_DEBUG_COMPATIBILITY
SLSI_INIT_DEINIT,
SLSI_NETDEV,
SLSI_CFG80211,
SLSI_MLME,
SLSI_SUMMARY_FRAMES,
SLSI_HYDRA,
SLSI_TX,
SLSI_RX,
SLSI_UDI,
SLSI_WIFI_FCQ,
SLSI_HIP,
SLSI_HIP_INIT_DEINIT,
SLSI_HIP_FW_DL,
SLSI_HIP_SDIO_OP,
SLSI_HIP_PS,
SLSI_HIP_TH,
SLSI_HIP_FH,
SLSI_HIP_SIG,
SLSI_FUNC_TRACE,
SLSI_TEST,
SLSI_SRC_SINK,
SLSI_FW_TEST,
SLSI_RX_BA,
SLSI_TDLS,
SLSI_GSCAN,
SLSI_MBULK,
SLSI_FLOWC,
#endif
TEST_ME,
MAX_TAG = TEST_ME /* keep it last */
};
#define NODEV_LABEL ""
#define SCSC_SDEV_2_DEV(sdev) \
(((sdev) && (sdev)->wiphy) ? &((sdev)->wiphy->dev) : NULL)
#define SCSC_NDEV_2_DEV(ndev) \
((ndev) ? SCSC_SDEV_2_DEV(((struct netdev_vif *)netdev_priv(ndev))->sdev) : NULL)
#define SCSC_TAG_FMT(tag, fmt) "[" # tag "]: %-5s: - %s: "fmt
#define SCSC_TAG_DBG_FMT(tag, fmt) "[" # tag "]: %s: "fmt
#define SCSC_DEV_FMT(fmt) "%-5s: - %s: "fmt
#define SCSC_DBG_FMT(fmt) "%s: "fmt
#ifdef CONFIG_SCSC_PRINTK
int scsc_printk_tag(int force, int tag, const char *fmt, ...);
int scsc_printk_tag_dev(int force, int tag, struct device *dev, const char *fmt, ...);
int scsc_printk_tag_dev_lvl(int force, int tag, struct device *dev, int lvl, const char *fmt, ...);
int scsc_printk_tag_lvl(int tag, int lvl, const char *fmt, ...);
int scsc_printk_bin(int force, int tag, int dlev, const void *start, size_t len);
/**
* This fields helps in trimming the behavior respect the kernel ring buffer:
* - NO_FORCE_PRK: the tag-based filtering mechanism is obeyed.
* - FORCE_PRK: the tag-based filtering is bypassed by this macro and message
* always get to the kernel ring buffer
* - NO_ECHO_PRK: disable completely the printk redirect.
*/
#define NO_FORCE_PRK 0
#define FORCE_PRK 1
#define NO_ECHO_PRK 2
#define SCSC_PRINTK(args ...) scsc_printk_tag(NO_FORCE_PRK, WLBT, \
args)
#define SCSC_PRINTK_TAG(tag, args ...) scsc_printk_tag(NO_FORCE_PRK, (tag), \
args)
#define SCSC_PRINTK_BIN(start, len) scsc_printk_bin(NO_FORCE_PRK, BINARY, \
-1, (start), (len))
#define SCSC_EMERG(fmt, args...) scsc_printk_tag(NO_FORCE_PRK, WLBT, \
KERN_EMERG SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_ALERT(fmt, args...) scsc_printk_tag(NO_FORCE_PRK, WLBT, \
KERN_ALERT SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_CRIT(fmt, args...) scsc_printk_tag(NO_FORCE_PRK, WLBT, \
KERN_CRIT SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_ERR(fmt, args...) scsc_printk_tag(NO_FORCE_PRK, WLBT, \
KERN_ERR SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_WARNING(fmt, args...) scsc_printk_tag(NO_FORCE_PRK, WLBT, \
KERN_WARNING SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_NOTICE(fmt, args...) scsc_printk_tag(NO_FORCE_PRK, WLBT, \
KERN_NOTICE SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_INFO(fmt, args...) scsc_printk_tag(NO_FORCE_PRK, WLBT, \
KERN_INFO SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_DEBUG(fmt, args...) scsc_printk_tag(NO_FORCE_PRK, WLBT, \
KERN_DEBUG SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_EMERG(tag, fmt, args...) scsc_printk_tag(NO_FORCE_PRK, (tag), \
KERN_EMERG SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_ALERT(tag, fmt, args...) scsc_printk_tag(NO_FORCE_PRK, (tag), \
KERN_ALERT SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_CRIT(tag, fmt, args ...) scsc_printk_tag(NO_FORCE_PRK, (tag), \
KERN_CRIT SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_ERR(tag, fmt, args...) scsc_printk_tag(NO_FORCE_PRK, (tag), \
KERN_ERR SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_WARNING(tag, fmt, args...) scsc_printk_tag(NO_FORCE_PRK, (tag), \
KERN_WARNING SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_NOTICE(tag, fmt, args...) scsc_printk_tag(NO_FORCE_PRK, (tag), \
KERN_NOTICE SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_INFO(tag, fmt, args...) scsc_printk_tag(NO_FORCE_PRK, (tag), \
KERN_INFO SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_DEBUG(tag, fmt, args...) scsc_printk_tag(NO_FORCE_PRK, (tag), \
KERN_DEBUG SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_ERR_SDEV(sdev, tag, fmt, args...) \
scsc_printk_tag_dev(NO_FORCE_PRK, (tag), SCSC_SDEV_2_DEV((sdev)), \
KERN_ERR SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_WARNING_SDEV(sdev, tag, fmt, args...) \
scsc_printk_tag_dev(NO_FORCE_PRK, (tag), SCSC_SDEV_2_DEV((sdev)), \
KERN_WARNING SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_INFO_SDEV(sdev, tag, fmt, args...) \
scsc_printk_tag_dev(NO_FORCE_PRK, (tag), SCSC_SDEV_2_DEV((sdev)), \
KERN_INFO SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_DEBUG_SDEV(sdev, tag, fmt, args...) \
scsc_printk_tag_dev(NO_FORCE_PRK, (tag), SCSC_SDEV_2_DEV((sdev)), \
KERN_DEBUG SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_ERR_NDEV(ndev, tag, fmt, args...) \
scsc_printk_tag_dev(NO_FORCE_PRK, (tag), SCSC_NDEV_2_DEV((ndev)), \
KERN_ERR SCSC_DEV_FMT(fmt), \
((ndev) ? netdev_name(ndev) : NODEV_LABEL), \
__func__, ## args)
#define SCSC_TAG_WARNING_NDEV(ndev, tag, fmt, args...) \
scsc_printk_tag_dev(NO_FORCE_PRK, (tag), SCSC_NDEV_2_DEV((ndev)), \
KERN_WARNING SCSC_DEV_FMT(fmt), \
((ndev) ? netdev_name(ndev) : NODEV_LABEL), \
__func__, ## args)
#define SCSC_TAG_INFO_NDEV(ndev, tag, fmt, args...) \
scsc_printk_tag_dev(NO_FORCE_PRK, (tag), SCSC_NDEV_2_DEV((ndev)), \
KERN_INFO SCSC_DEV_FMT(fmt), \
((ndev) ? netdev_name(ndev) : NODEV_LABEL), \
__func__, ## args)
#define SCSC_TAG_DEBUG_NDEV(ndev, tag, fmt, args...) \
scsc_printk_tag_dev(NO_FORCE_PRK, (tag), SCSC_NDEV_2_DEV((ndev)), \
KERN_DEBUG SCSC_DEV_FMT(fmt), \
((ndev) ? netdev_name(ndev) : NODEV_LABEL), \
__func__, ## args)
#define SCSC_TAG_ERR_DEV(tag, dev, fmt, args...) \
scsc_printk_tag_dev(NO_FORCE_PRK, (tag), dev, \
KERN_ERR SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_WARNING_DEV(tag, dev, fmt, args...) \
scsc_printk_tag_dev(NO_FORCE_PRK, (tag), dev, \
KERN_WARNING SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_INFO_DEV(tag, dev, fmt, args...) \
scsc_printk_tag_dev(NO_FORCE_PRK, (tag), dev, \
KERN_INFO SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_TAG_DEBUG_DEV(tag, dev, fmt, args...) \
scsc_printk_tag_dev(NO_FORCE_PRK, (tag), dev, \
KERN_DEBUG SCSC_DBG_FMT(fmt), \
__func__, ## args)
#define SCSC_ERR_SDEV(sdev, fmt, args...) \
SCSC_TAG_ERR_SDEV(sdev, WLBT, fmt, ## args)
#define SCSC_WARNING_SDEV(sdev, fmt, args...) \
SCSC_TAG_WARNING_SDEV(sdev, WLBT, fmt, ## args)
#define SCSC_INFO_SDEV(sdev, fmt, args...) \
SCSC_TAG_INFO_SDEV(sdev, WLBT, fmt, ## args)
#define SCSC_ERR_NDEV(ndev, fmt, args...) \
SCSC_TAG_ERR_NDEV(ndev, WLBT, fmt, ## args)
#define SCSC_WARNING_NDEV(ndev, fmt, args...) \
SCSC_TAG_WARNING_NDEV(ndev, WLBT, fmt, ## args)
#define SCSC_INFO_NDEV(ndev, fmt, args...) \
SCSC_TAG_INFO_NDEV(ndev, WLBT, fmt, ## args)
#define SCSC_BIN_EMERG(start, len) scsc_printk_bin(NO_FORCE_PRK, BINARY, 0, \
(start), (len))
#define SCSC_BIN_ALERT(start, len) scsc_printk_bin(NO_FORCE_PRK, BINARY, 1, \
(start), (len))
#define SCSC_BIN_CRIT(start, len) scsc_printk_bin(NO_FORCE_PRK, BINARY, 2, \
(start), (len))
#define SCSC_BIN_ERR(start, len) scsc_printk_bin(NO_FORCE_PRK, BINARY, 3, \
(start), (len))
#define SCSC_BIN_WARNING(start, len) scsc_printk_bin(NO_FORCE_PRK, BINARY, 4, \
(start), (len))
#define SCSC_BIN_NOTICE(start, len) scsc_printk_bin(NO_FORCE_PRK, BINARY, 5, \
(start), (len))
#define SCSC_BIN_INFO(start, len) scsc_printk_bin(NO_FORCE_PRK, BINARY, 6, \
(start), (len))
#define SCSC_BIN_DEBUG(start, len) scsc_printk_bin(NO_FORCE_PRK, BINARY, 7, \
(start), (len))
#define SCSC_BIN_TAG_EMERG(tag, start, len) scsc_printk_bin(NO_FORCE_PRK, (tag), 0, \
(start), (len))
#define SCSC_BIN_TAG_ALERT(tag, start, len) scsc_printk_bin(NO_FORCE_PRK, (tag), 1, \
(start), (len))
#define SCSC_BIN_TAG_CRIT(tag, start, len) scsc_printk_bin(NO_FORCE_PRK, (tag), 2, \
(start), (len))
#define SCSC_BIN_TAG_ERR(tag, start, len) scsc_printk_bin(NO_FORCE_PRK, (tag), 3, \
(start), (len))
#define SCSC_BIN_TAG_WARNING(tag, start, len) scsc_printk_bin(NO_FORCE_PRK, (tag), 4, \
(start), (len))
#define SCSC_BIN_TAG_NOTICE(tag, start, len) scsc_printk_bin(NO_FORCE_PRK, (tag), 5, \
(start), (len))
#define SCSC_BIN_TAG_INFO(tag, start, len) scsc_printk_bin(NO_FORCE_PRK, (tag), 6, \
(start), (len))
#define SCSC_BIN_TAG_DEBUG(tag, start, len) scsc_printk_bin(NO_FORCE_PRK, (tag), 7, \
(start), (len))
/*
* These macros forces a redundant copy of their output to kernel log buffer and
* console through standard kernel facilities, NO matter how the tag-based
* filtering is configured and NO matter what the value in
* scsc_redirect_to_printk_droplvl module param.
*/
#define SCSC_PRINTK_FF(args ...) scsc_printk_tag(FORCE_PRK, WLBT, args)
#define SCSC_PRINTK_TAG_FF(tag, args ...) scsc_printk_tag(FORCE_PRK, (tag), args)
#define SCSC_PRINTK_BIN_FF(start, len) scsc_printk_bin(FORCE_PRK, -1, \
(start), (len))
#define SCSC_EMERG_FF(args ...) scsc_printk_tag(FORCE_PRK, WLBT, \
KERN_EMERG args)
#define SCSC_ALERT_FF(args ...) scsc_printk_tag(FORCE_PRK, WLBT, \
KERN_ALERT args)
#define SCSC_CRIT_FF(args ...) scsc_printk_tag(FORCE_PRK, WLBT, \
KERN_CRIT args)
#define SCSC_ERR_FF(args ...) scsc_printk_tag(FORCE_PRK, WLBT, \
KERN_ERR args)
#define SCSC_WARNING_FF(args ...) scsc_printk_tag(FORCE_PRK, WLBT, \
KERN_WARNING args)
#define SCSC_NOTICE_FF(args ...) scsc_printk_tag(FORCE_PRK, WLBT, \
KERN_NOTICE args)
#define SCSC_INFO_FF(args ...) scsc_printk_tag(FORCE_PRK, WLBT, \
KERN_INFO args)
#define SCSC_DEBUG_FF(args ...) scsc_printk_tag(FORCE_PRK, WLBT, \
KERN_DEBUG args)
#define SCSC_TAG_EMERG_FF(tag, args ...) scsc_printk_tag(FORCE_PRK, (tag), \
KERN_EMERG args)
#define SCSC_TAG_ALERT_FF(tag, args ...) scsc_printk_tag(FORCE_PRK, (tag), \
KERN_ALERT args)
#define SCSC_TAG_CRIT_FF(tag, args ...) scsc_printk_tag(FORCE_PRK, (tag), \
KERN_CRIT args)
#define SCSC_TAG_ERR_FF(tag, args ...) scsc_printk_tag(FORCE_PRK, (tag), \
KERN_ERR args)
#define SCSC_TAG_WARNING_FF(tag, args ...) scsc_printk_tag(FORCE_PRK, (tag), \
KERN_WARNING args)
#define SCSC_TAG_NOTICE_FF(tag, args ...) scsc_printk_tag(FORCE_PRK, (tag), \
KERN_NOTICE args)
#define SCSC_TAG_INFO_FF(tag, args ...) scsc_printk_tag(FORCE_PRK, (tag), \
KERN_INFO args)
#define SCSC_TAG_DEBUG_FF(tag, args ...) scsc_printk_tag(FORCE_PRK, (tag), \
KERN_DEBUG args)
#define SCSC_BIN_EMERG_FF(start, len) scsc_printk_bin(FORCE_PRK, 0, \
(start), (len))
#define SCSC_BIN_ALERT_FF(start, len) scsc_printk_bin(FORCE_PRK, 1, \
(start), (len))
#define SCSC_BIN_CRIT_FF(start, len) scsc_printk_bin(FORCE_PRK, 2, \
(start), (len))
#define SCSC_BIN_ERR_FF(start, len) scsc_printk_bin(FORCE_PRK, 3, \
(start), (len))
#define SCSC_BIN_WARNING_FF(start, len) scsc_printk_bin(FORCE_PRK, 4, \
(start), (len))
#define SCSC_BIN_NOTICE_FF(start, len) scsc_printk_bin(FORCE_PRK, 5, \
(start), (len))
#define SCSC_BIN_INFO_FF(start, len) scsc_printk_bin(FORCE_PRK, 6, \
(start), (len))
#define SCSC_BIN_DEBUG_FF(start, len) scsc_printk_bin(FORCE_PRK, 7, \
(start), (len))
#define SCSC_TAG_LVL(tag, lvl, fmt, args...) \
scsc_printk_tag_lvl((tag), (lvl), fmt, ## args)
#define SCSC_TAG_DEV_LVL(tag, lvl, dev, fmt, args...) \
scsc_printk_tag_dev_lvl(NO_FORCE_PRK, (tag), (dev), (lvl), fmt, ## args)
#define SCSC_TAG_DBG1_SDEV(sdev, tag, fmt, args...) \
SCSC_TAG_DEV_LVL((tag), 7, SCSC_SDEV_2_DEV((sdev)), \
SCSC_DBG_FMT(fmt), __func__, ## args)
#define SCSC_TAG_DBG2_SDEV(sdev, tag, fmt, args...) \
SCSC_TAG_DEV_LVL((tag), 8, SCSC_SDEV_2_DEV((sdev)), \
SCSC_DBG_FMT(fmt), __func__, ## args)
#define SCSC_TAG_DBG3_SDEV(sdev, tag, fmt, args...) \
SCSC_TAG_DEV_LVL((tag), 9, SCSC_SDEV_2_DEV((sdev)), \
SCSC_DBG_FMT(fmt), __func__, ## args)
#define SCSC_TAG_DBG4_SDEV(sdev, tag, fmt, args...) \
SCSC_TAG_DEV_LVL((tag), 10, SCSC_SDEV_2_DEV((sdev)), \
SCSC_DBG_FMT(fmt), __func__, ## args)
#define SCSC_TAG_DBG1_NDEV(ndev, tag, fmt, args...) \
SCSC_TAG_DEV_LVL((tag), 7, SCSC_NDEV_2_DEV((ndev)), SCSC_DEV_FMT(fmt), \
((ndev) ? netdev_name(ndev) : NODEV_LABEL), \
__func__, ## args)
#define SCSC_TAG_DBG2_NDEV(ndev, tag, fmt, args...) \
SCSC_TAG_DEV_LVL((tag), 8, SCSC_NDEV_2_DEV((ndev)), SCSC_DEV_FMT(fmt), \
((ndev) ? netdev_name(ndev) : NODEV_LABEL), \
__func__, ## args)
#define SCSC_TAG_DBG3_NDEV(ndev, tag, fmt, args...) \
SCSC_TAG_DEV_LVL((tag), 9, SCSC_NDEV_2_DEV((ndev)), SCSC_DEV_FMT(fmt), \
((ndev) ? netdev_name(ndev) : NODEV_LABEL), \
__func__, ## args)
#define SCSC_TAG_DBG4_NDEV(ndev, tag, fmt, args...) \
SCSC_TAG_DEV_LVL((tag), 10, SCSC_NDEV_2_DEV((ndev)), SCSC_DEV_FMT(fmt), \
((ndev) ? netdev_name(ndev) : NODEV_LABEL), \
__func__, ## args)
#define SCSC_TAG_DBG1(tag, fmt, args ...) \
SCSC_TAG_LVL((tag), 7, fmt, ## args)
#define SCSC_TAG_DBG2(tag, fmt, args ...) \
SCSC_TAG_LVL((tag), 8, fmt, ## args)
#define SCSC_TAG_DBG3(tag, fmt, args ...) \
SCSC_TAG_LVL((tag), 9, fmt, ## args)
#define SCSC_TAG_DBG4(tag, fmt, args ...) \
SCSC_TAG_LVL((tag), 10, fmt, ## args)
#else /* CONFIG_SCSC_PRINTK */
#define SCSC_TAG_LVL(tag, lvl, fmt, args...) \
do {\
if ((lvl) < 7)\
printk_emit(0, (lvl), NULL, 0, fmt, ## args);\
} while (0)
#define SCSC_TAG_DEV_LVL(tag, lvl, dev, fmt, args...) \
do {\
if ((lvl) < 7)\
dev_printk_emit((lvl), (dev), fmt, ## args);\
} while (0)
#define SCSC_PRINTK(fmt, args ...) printk(fmt, ## args)
#define SCSC_PRINTK_TAG(tag, fmt, args ...) printk("[" # tag "] "fmt, ## args)
#define SCSC_PRINTK_BIN(start, len) print_hex_dump(KERN_INFO, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_PRINTK_FF(fmt, args ...) printk(fmt, ## args)
#define SCSC_PRINTK_TAG_FF(tag, fmt, args ...) printk("[" # tag "] "fmt, ## args)
#define SCSC_PRINTK_BIN_FF(start, len) print_hex_dump(KERN_INFO, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_EMERG(fmt, args...) pr_emerg(SCSC_DBG_FMT(fmt), __func__, ## args)
#define SCSC_ALERT(fmt, args...) pr_alert(SCSC_DBG_FMT(fmt), __func__, ## args)
#define SCSC_CRIT(fmt, args...) pr_crit(SCSC_DBG_FMT(fmt), __func__, ## args)
#define SCSC_ERR(fmt, args...) pr_err(SCSC_DBG_FMT(fmt), __func__, ## args)
#define SCSC_WARNING(fmt, args...) pr_warn(SCSC_DBG_FMT(fmt), __func__, ## args)
#define SCSC_NOTICE(fmt, args...) pr_notice(SCSC_DBG_FMT(fmt), __func__, ## args)
#define SCSC_INFO(fmt, args...) pr_info(SCSC_DBG_FMT(fmt), __func__, ## args)
#define SCSC_DEBUG(args...) do {} while (0)
/* Reverting to pr_* keeping the [tag] */
#define SCSC_TAG_EMERG(tag, fmt, args...) \
pr_emerg(SCSC_TAG_DBG_FMT(tag, fmt), __func__, ## args)
#define SCSC_TAG_ALERT(tag, fmt, args...) \
pr_alert(SCSC_TAG_DBG_FMT(tag, fmt), __func__, ## args)
#define SCSC_TAG_CRIT(tag, fmt, args...) \
pr_crit(SCSC_TAG_DBG_FMT(tag, fmt), __func__, ## args)
#define SCSC_TAG_ERR(tag, fmt, args...) \
pr_err(SCSC_TAG_DBG_FMT(tag, fmt), __func__, ## args)
#define SCSC_TAG_WARNING(tag, fmt, args...) \
pr_warn(SCSC_TAG_DBG_FMT(tag, fmt), __func__, ## args)
#define SCSC_TAG_NOTICE(tag, fmt, args...) \
pr_notice(SCSC_TAG_DBG_FMT(tag, fmt), __func__, ## args)
#define SCSC_TAG_INFO(tag, fmt, args...) \
pr_info(SCSC_TAG_DBG_FMT(tag, fmt), __func__, ## args)
#define SCSC_TAG_DEBUG(tag, fmt, args...) do {} while (0)
#define SCSC_BIN_EMERG(start, len) print_hex_dump(KERN_EMERG, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_ALERT(start, len) print_hex_dump(KERN_ALERT, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_CRIT(start, len) print_hex_dump(KERN_CRIT, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_ERR(start, len) print_hex_dump(KERN_ERR, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_WARNING(start, len) print_hex_dump(KERN_WARNING, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_NOTICE(start, len) print_hex_dump(KERN_NOTICE, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_INFO(start, len) print_hex_dump(KERN_INFO, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_DEBUG(start, len) do {} while (0)
#define SCSC_BIN_TAG_EMERG(tag, start, len) print_hex_dump(KERN_EMERG, \
"[" # tag "]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_TAG_ALERT(tag, start, len) print_hex_dump(KERN_ALERT, \
"[" # tag "]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_TAG_CRIT(tag, start, len) print_hex_dump(KERN_CRIT, \
"[" # tag "]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_TAG_ERR(tag, start, len) print_hex_dump(KERN_ERR, \
"[" # tag "]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_TAG_WARNING(tag, start, len) print_hex_dump(KERN_WARNING, \
"[" # tag "]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_TAG_NOTICE(tag, start, len) print_hex_dump(KERN_NOTICE, \
"[" # tag "]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_TAG_INFO(tag, start, len) print_hex_dump(KERN_INFO, \
"[" # tag "]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_TAG_DEBUG(tag, start, len) do {} while (0)
#define SCSC_EMERG_FF(args ...) pr_emerg(args)
#define SCSC_ALERT_FF(args ...) pr_alert(args)
#define SCSC_CRIT_FF(args ...) pr_crit(args)
#define SCSC_ERR_FF(args ...) pr_err(args)
#define SCSC_WARNING_FF(args ...) pr_warn(args)
#define SCSC_NOTICE_FF(args ...) pr_notice(args)
#define SCSC_INFO_FF(args ...) pr_info(args)
#define SCSC_DEBUG_FF(args ...) do {} while (0)
#define SCSC_TAG_EMERG_FF(tag, fmt, args ...) pr_emerg(SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_ALERT_FF(tag, fmt, args ...) pr_alert(SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_CRIT_FF(tag, fmt, args ...) pr_crit(SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_ERR_FF(tag, fmt, args ...) pr_err(SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_WARNING_FF(tag, fmt, args ...) pr_warn(SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_NOTICE_FF(tag, fmt, args ...) pr_notice(SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_INFO_FF(tag, fmt, args ...) pr_info(SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_DEBUG_FF(tag, fmt, args ...) do {} while (0)
#define SCSC_BIN_EMERG_FF(start, len) print_hex_dump(KERN_EMERG, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_ALERT_FF(start, len) print_hex_dump(KERN_ALERT, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_CRIT_FF(start, len) print_hex_dump(KERN_CRIT, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_ERR_FF(start, len) print_hex_dump(KERN_ERR, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_WARNING_FF(start, len) print_hex_dump(KERN_WARNING, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_NOTICE_FF(start, len) print_hex_dump(KERN_NOTICE, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_INFO_FF(start, len) print_hex_dump(KERN_INFO, \
"[BINARY]->|", \
DUMP_PREFIX_ADDRESS, \
16, 4, start, \
len, true)
#define SCSC_BIN_DEBUG_FF(start, len) do {} while (0)
#define SCSC_TAG_ERR_SDEV(sdev, tag, fmt, args...) \
dev_err(SCSC_SDEV_2_DEV((sdev)), SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_WARNING_SDEV(sdev, tag, fmt, args...) \
dev_warn(SCSC_SDEV_2_DEV((sdev)), SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_INFO_SDEV(sdev, tag, fmt, args...) \
dev_info(SCSC_SDEV_2_DEV((sdev)), SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_DEBUG_SDEV(sdev, tag, fmt, args...) do {} while (0)
#define SCSC_TAG_ERR_NDEV(ndev, tag, fmt, args...) \
dev_err(SCSC_NDEV_2_DEV((ndev)), SCSC_TAG_FMT(tag, fmt), \
((ndev) ? netdev_name(ndev) : NODEV_LABEL), __func__, ## args)
#define SCSC_TAG_WARNING_NDEV(ndev, tag, fmt, args...) \
dev_warn(SCSC_NDEV_2_DEV((ndev)), SCSC_TAG_FMT(tag, fmt), \
((ndev) ? netdev_name(ndev) : NODEV_LABEL), __func__, ## args)
#define SCSC_TAG_INFO_NDEV(ndev, tag, fmt, args...) \
dev_info(SCSC_NDEV_2_DEV((ndev)), SCSC_TAG_FMT(tag, fmt), \
((ndev) ? netdev_name(ndev) : NODEV_LABEL), __func__, ## args)
#define SCSC_TAG_DEBUG_NDEV(ndev, tag, fmt, args...) do {} while (0)
#define SCSC_TAG_ERR_DEV(tag, dev, fmt, args...) \
dev_err(dev, SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_WARNING_DEV(tag, dev, fmt, args...) \
dev_warn(dev, SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_INFO_DEV(tag, dev, fmt, args...) \
dev_info(dev, SCSC_TAG_DBG_FMT(tag, fmt), \
__func__, ## args)
#define SCSC_TAG_DEBUG_DEV(tag, dev, fmt, args...) do {} while (0)
#define SCSC_ERR_SDEV(sdev, fmt, args...) \
SCSC_TAG_ERR_SDEV(sdev, WLBT, fmt, ## args)
#define SCSC_WARNING_SDEV(sdev, fmt, args...) \
SCSC_TAG_WARNING_SDEV(sdev, WLBT, fmt, ## args)
#define SCSC_INFO_SDEV(sdev, fmt, args...) \
SCSC_TAG_INFO_SDEV(sdev, WLBT, fmt, ## args)
#define SCSC_ERR_NDEV(ndev, fmt, args...) \
SCSC_TAG_ERR_NDEV(ndev, WLBT, fmt, ## args)
#define SCSC_WARNING_NDEV(ndev, fmt, args...) \
SCSC_TAG_WARNING_NDEV(ndev, WLBT, fmt, ## args)
#define SCSC_INFO_NDEV(ndev, fmt, args...) \
SCSC_TAG_INFO_NDEV(ndev, WLBT, fmt, ## args)
#define SCSC_TAG_DBG1_SDEV(sdev, tag, fmt, args...) do {} while (0)
#define SCSC_TAG_DBG2_SDEV(sdev, tag, fmt, args...) do {} while (0)
#define SCSC_TAG_DBG3_SDEV(sdev, tag, fmt, args...) do {} while (0)
#define SCSC_TAG_DBG4_SDEV(sdev, tag, fmt, args...) do {} while (0)
#define SCSC_TAG_DBG1_NDEV(ndev, tag, fmt, args...) do {} while (0)
#define SCSC_TAG_DBG2_NDEV(ndev, tag, fmt, args...) do {} while (0)
#define SCSC_TAG_DBG3_NDEV(ndev, tag, fmt, args...) do {} while (0)
#define SCSC_TAG_DBG4_NDEV(ndev, tag, fmt, args...) do {} while (0)
#define SCSC_TAG_DBG1(tag, fmt, args ...) do {} while (0)
#define SCSC_TAG_DBG2(tag, fmt, args ...) do {} while (0)
#define SCSC_TAG_DBG3(tag, fmt, args ...) do {} while (0)
#define SCSC_TAG_DBG4(tag, fmt, args ...) do {} while (0)
#endif
#endif /* _SCSC_LOGRING_H_ */

View file

@ -0,0 +1,16 @@
/****************************************************************************
*
* Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved
*
****************************************************************************/
#ifndef _SCSC_MIFRAM_H
#define _SCSC_MIFRAM_H
/*
* Portable reference to DRAM address.
* In practice this should native R4 relative address.
*/
typedef s32 scsc_mifram_ref;
#endif

273
include/scsc/scsc_mx.h Normal file
View file

@ -0,0 +1,273 @@
/****************************************************************************
*
* Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved
*
****************************************************************************/
#ifndef _SCSC_CORE_H
#define _SCSC_CORE_H
#include <linux/types.h>
#include "scsc_mifram.h"
#define SCSC_PANIC_CODE_FW 0
#define SCSC_PANIC_CODE_HOST 1
struct device;
struct firmware;
struct scsc_mx;
enum scsc_service_id {
SCSC_SERVICE_ID_NULL = 0,
SCSC_SERVICE_ID_WLAN = 1,
SCSC_SERVICE_ID_BT = 2,
SCSC_SERVICE_ID_ANT = 3,
SCSC_SERVICE_ID_R4DBG = 4,
SCSC_SERVICE_ID_ECHO = 5,
SCSC_SERVICE_ID_DBG_SAMPLER = 6,
SCSC_SERVICE_ID_CLK20MHZ = 7,
SCSC_SERVICE_ID_INVALID = 0xff,
};
enum scsc_module_client_reason {
SCSC_MODULE_CLIENT_REASON_HW_PROBE = 0,
SCSC_MODULE_CLIENT_REASON_HW_REMOVE = 1,
SCSC_MODULE_CLIENT_REASON_RECOVERY = 2,
SCSC_MODULE_CLIENT_REASON_INVALID = 0xff,
};
/* Core Driver Module registration */
struct scsc_mx_module_client {
char *name;
void (*probe)(struct scsc_mx_module_client *module_client, struct scsc_mx *mx, enum scsc_module_client_reason reason);
void (*remove)(struct scsc_mx_module_client *module_client, struct scsc_mx *mx, enum scsc_module_client_reason reason);
};
/* Service Client interface */
struct scsc_service_client;
struct scsc_service_client {
/** Called on Maxwell failure. The Client should Stop all SDRAM & MIF
* Mailbox access as fast as possible and inform the Manager by calling
* client_stopped() */
void (*stop_on_failure)(struct scsc_service_client *client);
/** Called when Maxwell failure has handled and the Maxwell has been
* reset. The Client should assume that any Maxwell resources it held are
* invalid */
void (*failure_reset)(struct scsc_service_client *client, u16 scsc_panic_code);
};
/* WARNING: THIS IS INTERRUPT CONTEXT!
* here: some serious warnings about not blocking or doing anything lengthy at all
*/
typedef void (*scsc_mifintrbit_handler)(int which_bit, void *data);
/*
* Core Module Inteface
*/
int scsc_mx_module_register_client_module(struct scsc_mx_module_client *module_client);
void scsc_mx_module_unregister_client_module(struct scsc_mx_module_client *module_client);
int scsc_mx_module_reset(void);
/*
* Core Instance interface
*/
/** 1st thing to do is call open and return service managment interface*/
struct scsc_service *scsc_mx_service_open(struct scsc_mx *mx, enum scsc_service_id id, struct scsc_service_client *client, int *status);
/*
* Service interface
*/
/** pass a portable dram reference and returns kernel pointer (basically is dealing with the pointers) */
void *scsc_mx_service_mif_addr_to_ptr(struct scsc_service *service, scsc_mifram_ref ref);
int scsc_mx_service_mif_ptr_to_addr(struct scsc_service *service, void *mem_ptr, scsc_mifram_ref *ref);
int scsc_mx_service_start(struct scsc_service *service, scsc_mifram_ref ref);
int scsc_mx_service_stop(struct scsc_service *service);
void scsc_mx_service_close(struct scsc_service *service);
int scsc_mx_service_mif_dump_registers(struct scsc_service *service);
/** Signal a failure detected by the Client. This will trigger the systemwide
* failure handling procedure: _All_ Clients will be called back via
* their stop_on_failure() handler as a side-effect. */
void scsc_mx_service_service_failed(struct scsc_service *service);
/* MEMORY Interface*/
/** Allocate a contiguous block of SDRAM accessible to Client Driver */
int scsc_mx_service_mifram_alloc(struct scsc_service *service, size_t nbytes, scsc_mifram_ref *ref, u32 align);
/** Free a contiguous block of SDRAM */
void scsc_mx_service_mifram_free(struct scsc_service *service, scsc_mifram_ref ref);
/* MBOX Interface */
/** Allocate n contiguous mailboxes. Outputs index of first mbox, returns FALSE if cant allocate n contiguous mailboxes. */
bool scsc_mx_service_alloc_mboxes(struct scsc_service *service, int n, int *first_mbox_index);
/** Free n contiguous mailboxes. */
void scsc_service_free_mboxes(struct scsc_service *service, int n, int first_mbox_index);
/** Get kernel-space pointer to a mailbox.
* The pointer can be cached as it is guaranteed not to change between service start & stop.
**/
u32 *scsc_mx_service_get_mbox_ptr(struct scsc_service *service, int mbox_index);
/* IRQ Interface */
/* Getters/Setters */
/* From R4/M4 */
int scsc_service_mifintrbit_bit_mask_status_get(struct scsc_service *service);
int scsc_service_mifintrbit_get(struct scsc_service *service);
void scsc_service_mifintrbit_bit_clear(struct scsc_service *service, int which_bit);
void scsc_service_mifintrbit_bit_mask(struct scsc_service *service, int which_bit);
void scsc_service_mifintrbit_bit_unmask(struct scsc_service *service, int which_bit);
/* To R4/M4 */
enum scsc_mifintr_target {
SCSC_MIFINTR_TARGET_R4 = 0,
SCSC_MIFINTR_TARGET_M4 = 1
};
void scsc_service_mifintrbit_bit_set(struct scsc_service *service, int which_bit, enum scsc_mifintr_target dir);
/* Register an interrupt handler -TOHOST direction.
* Function returns the IRQ associated , -EIO if all interrupts have been assigned */
int scsc_service_mifintrbit_register_tohost(struct scsc_service *service, scsc_mifintrbit_handler handler, void *data);
/* Unregister an interrupt handler associated with a bit -TOHOST direction */
int scsc_service_mifintrbit_unregister_tohost(struct scsc_service *service, int which_bit);
/* Get an interrupt bit associated with the target (R4/M4) -FROMHOST direction
* Function returns the IRQ bit associated , -EIO if error */
int scsc_service_mifintrbit_alloc_fromhost(struct scsc_service *service, enum scsc_mifintr_target dir);
/* Free an interrupt bit associated with the target (R4/M4) -FROMHOST direction
* Function returns the 0 if succedes , -EIO if error */
int scsc_service_mifintrbit_free_fromhost(struct scsc_service *service, int which_bit, enum scsc_mifintr_target dir);
/*
* Return a kernel device associated 1:1 with the Maxwell instance.
* This is published only for the purpose of associating service drivers
* with a Maxwell instance for logging purposes. Clients should not make
* any assumptions about the device type. In some configurations this may
* be the associated host-interface device (AXI/PCIe),
* but this may change in future.
*/
struct device *scsc_service_get_device(struct scsc_service *service);
int scsc_service_force_panic(struct scsc_service *service);
/* Reads a configuration file into memory.
*
* Path is relative to the currently selected firmware configuration
* subdirectory.
* Returns pointer to data or NULL if file not found.
* Call mx140_file_release_conf()to release the memory.
*/
int mx140_file_request_conf(struct scsc_mx *mx, const struct firmware **conf, const char *config_path);
/* Reads a debug configuration file into memory.
*
* Path is relative to the currently selected firmware configuration
* subdirectory.
* Returns pointer to data or NULL if file not found.
* Call mx140_file_release_conf()to release the memory.
*/
int mx140_file_request_debug_conf(struct scsc_mx *mx, const struct firmware **conf, const char *config_path);
/* Read device configuration file into memory.
*
* Path is relative to the device configuration directory.
* Returns pointer to data or NULL if file not found.
* Call mx140_file_release_conf() to release the memory.
* This call is only used for configuration files that are
* device instance specific (e.g. mac addresses)
*/
int mx140_file_request_device_conf(struct scsc_mx *mx, const struct firmware **conf, const char *config_path);
/* Release configuration file memory
*
* If conf is NULL, has no effect.
*/
void mx140_file_release_conf(struct scsc_mx *mx, const struct firmware *conf);
/* Read device configuration file into memory.
*
* Path is absolute.
* Returns pointer to data or NULL if file not found.
* Call mx140_release_file() to release the memory.
*/
int mx140_request_file(struct scsc_mx *mx, char *path, const struct firmware **firmp);
/* Release configuration file memory allocated with mx140_request_file()
*
* If firmp is NULL, has no effect.
*/
int mx140_release_file(struct scsc_mx *mx, const struct firmware *firmp);
/* 20 MHz clock API.
* The mx140 device uses a clock that is also required by the USB driver.
* This API allows the USB/clock driver to inform the mx140 driver that the
* clock is required and that it must boot and/or keep the clock running.
*/
enum mx140_clk20mhz_status {
MX140_CLK_SUCCESS = 0, /* Returned successfully */
MX140_CLK_STARTED, /* mx140 has started the clock */
MX140_CLK_STOPPED, /* mx140 has stopped the clock */
MX140_CLK_NOT_STARTED, /* failed to start the clock */
MX140_CLK_NOT_STOPPED, /* failed to stop the clock */
MX140_CLK_ASYNC_FAIL, /* mx140 failure, async call */
};
/* Register for 20 MHz clock API callbacks
*
* Parameters:
* client_cb:
* If client provides non-NULL client_cb, the request is asynchronous and
* the client will be called back when the clock service is started.
* If client_cb is NULL, the request is blocking.
* data:
* opaque context for the client, and will be passed back in any callback
*
* Note it is possible that the callback may be made in the context of the
* calling request/release function.
*
* Returns 0 on success
*/
int mx140_clk20mhz_register(void (*client_cb)(void *data, enum mx140_clk20mhz_status event), void *data);
/* Unregister for 20 MHz clock API callbacks.
* After this call is made, the mx140 driver will no longer call back.
*/
void mx140_clk20mhz_unregister(void);
/* Client request that the clock be available.
*
* If a callback was installed via mx140_clk20mhz_register(), the mx140 driver
* will call back when the clock is available. If no callback was installed,
* the request is blocking and will return when the clock is running.
*
* Returns:
* mx140_clk20mhz_status if a blocking attempt was made to start the clock,
* MX140_CLK_SUCCESS if the request will happen asynchronously, or,
* -ve error code on other error.
*
*/
int mx140_clk20mhz_request(void);
/* Client informs that the clock is no longer needed
*
* Returns:
* mx140_clk20mhz_status if a blocking attempt was made to stop the clock,
* MX140_CLK_SUCCESS if the request will happen asynchronously, or,
* -ve error code on other error.
*/
int mx140_clk20mhz_release(void);
/*
* for set test mode.
*
*/
bool slsi_is_232338_test_mode_enabled(void);
int mx140_log_dump(void);
#endif

View file

@ -0,0 +1,17 @@
/****************************************************************************
*
* Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved
*
*****************************************************************************/
#ifndef _SCSC_RELEASE_H
#define _SCSC_RELEASE_H
#define SCSC_RELEASE_PRODUCT 1
#define SCSC_RELEASE_ITERATION 37
#define SCSC_RELEASE_CANDIDATE 1
#endif

44
include/scsc/trace.h Normal file
View file

@ -0,0 +1,44 @@
/****************************************************************************
*
* Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved
*
****************************************************************************/
/*
* Copyright (C) 2009 Cambridge Silicon Radio Ltd.
*
* Refer to LICENSE.txt included with this source code for details on
* the license terms.
*/
#ifndef __OSKA_LINUX_TRACE_H
#define __OSKA_LINUX_TRACE_H
#include <linux/kernel.h>
#ifndef OS_TRACE_PREFIX
# define OS_TRACE_PREFIX ""
#endif
#ifndef pr_warn
#define pr_warn pr_warning
#endif
#define OSKA_DEBUG /* TODO: not getting defined by buildsys */
#define os_trace_err(format, ...) pr_err(OS_TRACE_PREFIX "cmerr: " format "\n", ## __VA_ARGS__)
#define os_trace_warn(format, ...) pr_warn(OS_TRACE_PREFIX format "\n", ## __VA_ARGS__)
#ifdef OSKA_DEBUG
#ifdef ANDROID_BUILD
#undef os_trace_warn
#define os_trace_warn(format, ...) pr_err(OS_TRACE_PREFIX format "\n", ## __VA_ARGS__)
#define os_trace_info(format, ...) pr_err(OS_TRACE_PREFIX format "\n", ## __VA_ARGS__)
#define os_trace_dbg(format, ...) pr_err(OS_TRACE_PREFIX format "\n", ## __VA_ARGS__)
#else
#define os_trace_info(format, ...) pr_info(OS_TRACE_PREFIX format "\n", ## __VA_ARGS__)
#define os_trace_dbg(format, ...) pr_info(OS_TRACE_PREFIX format "\n", ## __VA_ARGS__)
#endif
#else
#define os_trace_info(format, ...)
#define os_trace_dbg(format, ...)
#endif
#endif /* #ifndef __OSKA_LINUX_TRACE_H */