00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef _SDIO_EVENT_LOG_H
00015 #define _SDIO_EVENT_LOG_H
00016
00017 #ifdef __linux
00018 # define SDIOEMB_DEBUG_HAVE_EVENT_LOG
00019 #endif
00020
00021 #ifndef SDIOEMB_DEBUG_EVENT_LOG_LEN
00022 # define SDIOEMB_DEBUG_EVENT_LOG_LEN 0
00023 #endif
00024
00025 #ifndef SDIOEMB_DEBUG_DATA_BUFFER_LEN
00026 # define SDIOEMB_DEBUG_DATA_BUFFER_LEN 0
00027 #endif
00028
00029 #if SDIOEMB_DEBUG_EVENT_LOG_LEN > 0 && defined(SDIOEMB_DEBUG_HAVE_EVENT_LOG)
00030
00031 #define SDIOEMB_DEBUG_EVENT_LOG
00032
00033 enum sdio_event_type {
00034 SDIOEMB_EVENT_CMD, SDIOEMB_EVENT_CARD_INT, SDIOEMB_EVENT_INT_ACKED,
00035 SDIOEMB_EVENT_POWER_ON, SDIOEMB_EVENT_POWER_OFF, SDIOEMB_EVENT_RESET,
00036 SDIOEMB_EVENT_CLOCK_FREQ,
00037 };
00038
00039 struct sdio_event_entry {
00040 unsigned seq_num;
00041 unsigned long time_ms;
00042 enum sdio_event_type type;
00043 union {
00044 struct {
00045 unsigned flags;
00046 union {
00047 struct sdioemb_cmd_resp sdio;
00048 struct cspi_cmd_resp cspi;
00049 };
00050 int status;
00051 #if SDIOEMB_DEBUG_DATA_BUFFER_LEN > 0
00052 struct {
00053 unsigned total_length;
00054 unsigned length;
00055 unsigned start;
00056 uint8_t *buffer;
00057 struct sdio_event_entry *next;
00058 } data;
00059 #endif
00060 } cmd;
00061 unsigned functions;
00062 int val;
00063 };
00064 };
00065
00066
00067 struct sdio_event_log {
00068 struct sdio_event_entry *entries;
00069 unsigned head;
00070 unsigned tail;
00071 unsigned seq_num;
00072 os_spinlock_t lock;
00073
00074 #if SDIOEMB_DEBUG_DATA_BUFFER_LEN > 0
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 uint8_t *data_buffer;
00086 unsigned data_start;
00087 unsigned data_total;
00088 struct sdio_event_entry *data_head;
00089 struct sdio_event_entry *data_tail;
00090 #endif
00091 };
00092
00093 #if SDIOEMB_DEBUG_DATA_BUFFER_LEN > 0
00094 extern unsigned sdioemb_debug_event_log_data_len;
00095 #endif
00096
00097 void sdio_event_log_init(struct sdioemb_slot *slot);
00098 void sdio_event_log_deinit(struct sdioemb_slot *slot);
00099 void sdio_event_log(struct sdioemb_slot *slot, enum sdio_event_type type, ...);
00100 void sdio_event_log_set_response(struct sdioemb_slot *slot, const struct sdioemb_cmd *cmd);
00101
00102 struct sdio_event_entry *sdio_event_log_get_entry(struct sdioemb_slot *slot, unsigned n);
00103 uint8_t sdio_event_log_get_data(struct sdio_event_entry *e, unsigned i);
00104
00105 void sdio_os_event_log_init(struct sdioemb_slot *slot);
00106 void sdio_os_event_log_deinit(struct sdioemb_slot *slot);
00107
00108 #else
00109
00110 #undef SDIOEMB_DEBUG_EVENT_LOG
00111
00112 #define sdio_event_log_init(s)
00113 #define sdio_event_log_deinit(s)
00114 #define sdio_event_log(s, t, ...)
00115 #define sdio_event_log_set_response(s, c)
00116
00117 #endif
00118
00119 #endif