123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987 |
- #include "hal_api.h"
- #ifdef CONFIG_WIN
- #include "wcss_version.h"
- #endif
- #define R0_INDEX 0
- #define R2_INDEX 1
- #define HWREG_INDEX(_reg_group) _reg_group ## _ ## INDEX
- #define BASE_LSB_GROUP R0
- #define BASE_MSB_GROUP R0
- #define ID_GROUP R0
- #define STATUS_GROUP R0
- #define MISC_GROUP R0
- #define HP_ADDR_LSB_GROUP R0
- #define HP_ADDR_MSB_GROUP R0
- #define PRODUCER_INT_SETUP_GROUP R0
- #define PRODUCER_INT_STATUS_GROUP R0
- #define PRODUCER_FULL_COUNTER_GROUP R0
- #define MSI1_BASE_LSB_GROUP R0
- #define MSI1_BASE_MSB_GROUP R0
- #define MSI1_DATA_GROUP R0
- #define HP_TP_SW_OFFSET_GROUP R0
- #define TP_ADDR_LSB_GROUP R0
- #define TP_ADDR_MSB_GROUP R0
- #define CONSUMER_INT_SETUP_IX0_GROUP R0
- #define CONSUMER_INT_SETUP_IX1_GROUP R0
- #define CONSUMER_INT_STATUS_GROUP R0
- #define CONSUMER_EMPTY_COUNTER_GROUP R0
- #define CONSUMER_PREFETCH_TIMER_GROUP R0
- #define CONSUMER_PREFETCH_STATUS_GROUP R0
- #define HP_GROUP R2
- #define TP_GROUP R2
- #define SRNG_DST_REG_OFFSET(_reg, _reg_group) \
- HWIO_REO_ ## _reg_group ## _REO2SW1_RING_ ## _reg##_ADDR(0)
- #define SRNG_SRC_REG_OFFSET(_reg, _reg_group) \
- HWIO_TCL_ ## _reg_group ## _SW2TCL1_RING_ ## _reg ## _ADDR(0)
- #define _SRNG_DST_FLD(_reg_group, _reg_fld) \
- HWIO_REO_ ## _reg_group ## _REO2SW1_RING_ ## _reg_fld
- #define _SRNG_SRC_FLD(_reg_group, _reg_fld) \
- HWIO_TCL_ ## _reg_group ## _SW2TCL1_RING_ ## _reg_fld
- #define _SRNG_FLD(_reg_group, _reg_fld, _dir) \
- _SRNG_ ## _dir ## _FLD(_reg_group, _reg_fld)
- #define SRNG_DST_FLD(_reg, _f) _SRNG_FLD(_reg ## _GROUP, _reg ## _ ## _f, DST)
- #define SRNG_SRC_FLD(_reg, _f) _SRNG_FLD(_reg ## _GROUP, _reg ## _ ## _f, SRC)
- #define SRNG_SRC_R0_START_OFFSET SRNG_SRC_REG_OFFSET(BASE_LSB, R0)
- #define SRNG_DST_R0_START_OFFSET SRNG_DST_REG_OFFSET(BASE_LSB, R0)
- #define SRNG_SRC_R2_START_OFFSET SRNG_SRC_REG_OFFSET(HP, R2)
- #define SRNG_DST_R2_START_OFFSET SRNG_DST_REG_OFFSET(HP, R2)
- #define SRNG_SRC_START_OFFSET(_reg_group) \
- SRNG_SRC_ ## _reg_group ## _START_OFFSET
- #define SRNG_DST_START_OFFSET(_reg_group) \
- SRNG_DST_ ## _reg_group ## _START_OFFSET
- #define SRNG_REG_ADDR(_srng, _reg, _reg_group, _dir) \
- ((_srng)->hwreg_base[HWREG_INDEX(_reg_group)] + \
- SRNG_ ## _dir ## _REG_OFFSET(_reg, _reg_group) - \
- SRNG_ ## _dir ## _START_OFFSET(_reg_group))
- #define SRNG_DST_ADDR(_srng, _reg) \
- SRNG_REG_ADDR(_srng, _reg, _reg ## _GROUP, DST)
- #define SRNG_SRC_ADDR(_srng, _reg) \
- SRNG_REG_ADDR(_srng, _reg, _reg ## _GROUP, SRC)
- #define SRNG_REG_WRITE(_srng, _reg, _value, _dir) \
- hif_write32_mb(SRNG_ ## _dir ## _ADDR(_srng, _reg), (_value))
- #define SRNG_REG_READ(_srng, _reg, _dir) \
- hif_read32_mb(SRNG_ ## _dir ## _ADDR(_srng, _reg))
- #define SRNG_SRC_REG_WRITE(_srng, _reg, _value) \
- SRNG_REG_WRITE(_srng, _reg, _value, SRC)
- #define SRNG_DST_REG_WRITE(_srng, _reg, _value) \
- SRNG_REG_WRITE(_srng, _reg, _value, DST)
- #define SRNG_SRC_REG_READ(_srng, _reg) \
- SRNG_REG_READ(_srng, _reg, SRC)
- #define _SRNG_FM(_reg_fld) _reg_fld ## _BMSK
- #define _SRNG_FS(_reg_fld) _reg_fld ## _SHFT
- #define SRNG_SM(_reg_fld, _val) \
- (((_val) << _SRNG_FS(_reg_fld)) & _SRNG_FM(_reg_fld))
- #define SRNG_MS(_reg_fld, _val) \
- (((_val) & _SRNG_FM(_reg_fld)) >> _SRNG_FS(_reg_fld))
- #define HAL_SRNG_CONFIG(_hal_soc, _ring_type) (&hw_srng_table[_ring_type])
- static struct hal_hw_srng_config hw_srng_table[] = {
-
- {
- .start_ring_id = HAL_SRNG_REO2SW1,
- .max_rings = 4,
- .entry_size = sizeof(struct reo_destination_ring) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_DST_RING,
- .reg_start = {
- HWIO_REO_R0_REO2SW1_RING_BASE_LSB_ADDR(
- SEQ_WCSS_UMAC_REO_REG_OFFSET),
- HWIO_REO_R2_REO2SW1_RING_HP_ADDR(
- SEQ_WCSS_UMAC_REO_REG_OFFSET)
- },
- .reg_size = {
- HWIO_REO_R0_REO2SW2_RING_BASE_LSB_ADDR(0) -
- HWIO_REO_R0_REO2SW1_RING_BASE_LSB_ADDR(0),
- HWIO_REO_R2_REO2SW1_RING_HP_ADDR(0) -
- HWIO_REO_R2_REO2SW2_RING_HP_ADDR(0),
- },
- },
- {
-
- .start_ring_id = HAL_SRNG_REO2TCL,
- .max_rings = 1,
- .entry_size = sizeof(struct reo_destination_ring) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_DST_RING,
- .reg_start = {
- HWIO_REO_R0_REO2TCL_RING_BASE_LSB_ADDR(
- SEQ_WCSS_UMAC_REO_REG_OFFSET),
- HWIO_REO_R2_REO2TCL_RING_HP_ADDR(
- SEQ_WCSS_UMAC_REO_REG_OFFSET)
- },
-
- .reg_size = {},
- },
- {
- .start_ring_id = HAL_SRNG_SW2REO,
- .max_rings = 1,
- .entry_size = sizeof(struct reo_entrance_ring) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_SRC_RING,
- .reg_start = {
- HWIO_REO_R0_SW2REO_RING_BASE_LSB_ADDR(
- SEQ_WCSS_UMAC_REO_REG_OFFSET),
- HWIO_REO_R2_SW2REO_RING_HP_ADDR(
- SEQ_WCSS_UMAC_REO_REG_OFFSET)
- },
-
- .reg_size = {},
- },
- {
- .start_ring_id = HAL_SRNG_REO_CMD,
- .max_rings = 1,
- .entry_size = (sizeof(struct tlv_32_hdr) +
- sizeof(struct reo_get_queue_stats)) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_SRC_RING,
- .reg_start = {
- HWIO_REO_R0_REO_CMD_RING_BASE_LSB_ADDR(
- SEQ_WCSS_UMAC_REO_REG_OFFSET),
- HWIO_REO_R2_REO_CMD_RING_HP_ADDR(
- SEQ_WCSS_UMAC_REO_REG_OFFSET),
- },
-
- .reg_size = {},
- },
- {
- .start_ring_id = HAL_SRNG_REO_STATUS,
- .max_rings = 1,
- .entry_size = (sizeof(struct tlv_32_hdr) +
- sizeof(struct reo_get_queue_stats_status)) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_DST_RING,
- .reg_start = {
- HWIO_REO_R0_REO_STATUS_RING_BASE_LSB_ADDR(
- SEQ_WCSS_UMAC_REO_REG_OFFSET),
- HWIO_REO_R2_REO_STATUS_RING_HP_ADDR(
- SEQ_WCSS_UMAC_REO_REG_OFFSET),
- },
-
- .reg_size = {},
- },
- {
- .start_ring_id = HAL_SRNG_SW2TCL1,
- .max_rings = 3,
- .entry_size = (sizeof(struct tlv_32_hdr) +
- sizeof(struct tcl_data_cmd)) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_SRC_RING,
- .reg_start = {
- HWIO_TCL_R0_SW2TCL1_RING_BASE_LSB_ADDR(
- SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET),
- HWIO_TCL_R2_SW2TCL1_RING_HP_ADDR(
- SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET),
- },
- .reg_size = {
- HWIO_TCL_R0_SW2TCL2_RING_BASE_LSB_ADDR(0) -
- HWIO_TCL_R0_SW2TCL1_RING_BASE_LSB_ADDR(0),
- HWIO_TCL_R2_SW2TCL2_RING_HP_ADDR(0) -
- HWIO_TCL_R2_SW2TCL1_RING_HP_ADDR(0),
- },
- },
- {
- .start_ring_id = HAL_SRNG_SW2TCL_CMD,
- .max_rings = 1,
- .entry_size = (sizeof(struct tlv_32_hdr) +
- sizeof(struct tcl_gse_cmd)) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_SRC_RING,
- .reg_start = {
- HWIO_TCL_R0_SW2TCL_CMD_RING_BASE_LSB_ADDR(
- SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET),
- HWIO_TCL_R2_SW2TCL_CMD_RING_HP_ADDR(
- SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET),
- },
-
- .reg_size = {},
- },
- {
- .start_ring_id = HAL_SRNG_TCL_STATUS,
- .max_rings = 1,
- .entry_size = (sizeof(struct tlv_32_hdr) +
- sizeof(struct tcl_status_ring)) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_DST_RING,
- .reg_start = {
- HWIO_TCL_R0_TCL_STATUS1_RING_BASE_LSB_ADDR(
- SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET),
- HWIO_TCL_R2_TCL_STATUS1_RING_HP_ADDR(
- SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET),
- },
-
- .reg_size = {},
- },
- {
- .start_ring_id = HAL_SRNG_CE_0_SRC,
- .max_rings = 12,
- .entry_size = sizeof(struct ce_src_desc) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_SRC_RING,
- .reg_start = {
- HWIO_WFSS_CE_CHANNEL_DST_R0_DEST_RING_BASE_LSB_ADDR(
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_0_CHANNEL_SRC_REG_OFFSET),
- HWIO_WFSS_CE_CHANNEL_DST_R2_DEST_RING_HP_ADDR(
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_0_CHANNEL_SRC_REG_OFFSET),
- },
- .reg_size = {
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_1_CHANNEL_SRC_REG_OFFSET -
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_0_CHANNEL_SRC_REG_OFFSET,
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_1_CHANNEL_SRC_REG_OFFSET -
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_0_CHANNEL_SRC_REG_OFFSET,
- },
- },
- {
- .start_ring_id = HAL_SRNG_CE_0_DST,
- .max_rings = 12,
- .entry_size = 8 >> 2,
-
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_SRC_RING,
- .reg_start = {
- HWIO_WFSS_CE_CHANNEL_DST_R0_DEST_RING_BASE_LSB_ADDR(
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_0_CHANNEL_DST_REG_OFFSET),
- HWIO_WFSS_CE_CHANNEL_DST_R2_DEST_RING_HP_ADDR(
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_0_CHANNEL_DST_REG_OFFSET),
- },
- .reg_size = {
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_1_CHANNEL_DST_REG_OFFSET -
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_0_CHANNEL_DST_REG_OFFSET,
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_1_CHANNEL_DST_REG_OFFSET -
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_0_CHANNEL_DST_REG_OFFSET,
- },
- },
- {
- .start_ring_id = HAL_SRNG_CE_0_DST_STATUS,
- .max_rings = 12,
- .entry_size = sizeof(struct ce_stat_desc) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_DST_RING,
- .reg_start = {
- HWIO_WFSS_CE_CHANNEL_DST_R0_STATUS_RING_BASE_LSB_ADDR(
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_0_CHANNEL_DST_REG_OFFSET),
- HWIO_WFSS_CE_CHANNEL_DST_R2_STATUS_RING_HP_ADDR(
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_0_CHANNEL_DST_REG_OFFSET),
- },
-
- .reg_size = {
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_1_CHANNEL_DST_REG_OFFSET -
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_0_CHANNEL_DST_REG_OFFSET,
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_1_CHANNEL_DST_REG_OFFSET -
- SEQ_WCSS_UMAC_WFSS_CE_0_REG_WFSS_CE_0_CHANNEL_DST_REG_OFFSET,
- },
- },
- {
- .start_ring_id = HAL_SRNG_WBM_IDLE_LINK,
- .max_rings = 1,
- .entry_size = sizeof(struct wbm_link_descriptor_ring) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_SRC_RING,
- .reg_start = {
- HWIO_WBM_R0_WBM_IDLE_LINK_RING_BASE_LSB_ADDR(SEQ_WCSS_UMAC_WBM_REG_OFFSET),
- HWIO_WBM_R2_WBM_IDLE_LINK_RING_HP_ADDR(SEQ_WCSS_UMAC_WBM_REG_OFFSET),
- },
-
- .reg_size = {},
- },
- {
- .start_ring_id = HAL_SRNG_WBM_SW_RELEASE,
- .max_rings = 1,
- .entry_size = sizeof(struct wbm_release_ring) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_SRC_RING,
- .reg_start = {
- HWIO_WBM_R0_SW_RELEASE_RING_BASE_LSB_ADDR(SEQ_WCSS_UMAC_WBM_REG_OFFSET),
- HWIO_WBM_R2_SW_RELEASE_RING_HP_ADDR(SEQ_WCSS_UMAC_WBM_REG_OFFSET),
- },
-
- .reg_size = {},
- },
- {
- .start_ring_id = HAL_SRNG_WBM2SW0_RELEASE,
- .max_rings = 4,
- .entry_size = sizeof(struct wbm_release_ring) >> 2,
- .lmac_ring = FALSE,
- .ring_dir = HAL_SRNG_DST_RING,
- .reg_start = {
- HWIO_WBM_R0_WBM2SW0_RELEASE_RING_BASE_LSB_ADDR(SEQ_WCSS_UMAC_WBM_REG_OFFSET),
- HWIO_WBM_R2_WBM2SW0_RELEASE_RING_HP_ADDR(SEQ_WCSS_UMAC_WBM_REG_OFFSET),
- },
- .reg_size = {
- HWIO_WBM_R0_WBM2SW1_RELEASE_RING_BASE_LSB_ADDR(SEQ_WCSS_UMAC_WBM_REG_OFFSET) -
- HWIO_WBM_R0_WBM2SW0_RELEASE_RING_BASE_LSB_ADDR(SEQ_WCSS_UMAC_WBM_REG_OFFSET),
- HWIO_WBM_R2_WBM2SW1_RELEASE_RING_HP_ADDR(SEQ_WCSS_UMAC_WBM_REG_OFFSET) -
- HWIO_WBM_R2_WBM2SW0_RELEASE_RING_HP_ADDR(SEQ_WCSS_UMAC_WBM_REG_OFFSET),
- },
- },
- {
- .start_ring_id = HAL_SRNG_WMAC1_SW2RXDMA0_BUF,
- .max_rings = 2,
-
- .entry_size = sizeof(struct wbm_buffer_ring) >> 2,
- .lmac_ring = TRUE,
- .ring_dir = HAL_SRNG_SRC_RING,
-
- .reg_start = {},
- .reg_size = {},
- },
- {
- .start_ring_id = HAL_SRNG_WMAC1_RXDMA2SW0,
- .max_rings = 1,
- .entry_size = sizeof(struct reo_entrance_ring) >> 2,
- .lmac_ring = TRUE,
- .ring_dir = HAL_SRNG_DST_RING,
-
- .reg_start = {},
- .reg_size = {},
- },
- {
- .start_ring_id = HAL_SRNG_WMAC1_SW2RXDMA2_BUF,
- .max_rings = 1,
- .entry_size = sizeof(struct wbm_buffer_ring) >> 2,
- .lmac_ring = TRUE,
- .ring_dir = HAL_SRNG_SRC_RING,
-
- .reg_start = {},
- .reg_size = {},
- },
- {
- .start_ring_id = HAL_SRNG_WMAC1_SW2RXDMA1_STATBUF,
- .max_rings = 1,
- .entry_size = sizeof(struct wbm_buffer_ring) >> 2,
- .lmac_ring = TRUE,
- .ring_dir = HAL_SRNG_SRC_RING,
-
- .reg_start = {},
- .reg_size = {},
- },
- {
- .start_ring_id = HAL_SRNG_WMAC1_RXDMA2SW1,
- .max_rings = 1,
- .entry_size = sizeof(struct reo_entrance_ring) >> 2,
- .lmac_ring = TRUE,
- .ring_dir = HAL_SRNG_DST_RING,
-
- .reg_start = {},
- .reg_size = {},
- },
- };
- void *hal_attach(void *hif_handle, qdf_device_t qdf_dev)
- {
- struct hal_soc *hal;
- int i;
- hal = qdf_mem_malloc(sizeof(*hal));
- if (!hal) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "%s: hal_soc allocation failed\n", __func__);
- goto fail0;
- }
- hal->hif_handle = hif_handle;
- hal->dev_base_addr = hif_get_dev_ba(hif_handle);
- hal->qdf_dev = qdf_dev;
- hal->shadow_rdptr_mem_vaddr = (uint32_t *)qdf_mem_alloc_consistent(
- qdf_dev, qdf_dev->dev, sizeof(*(hal->shadow_rdptr_mem_vaddr)) *
- HAL_SRNG_ID_MAX, &(hal->shadow_rdptr_mem_paddr));
- if (!hal->shadow_rdptr_mem_paddr) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "%s: hal->shadow_rdptr_mem_paddr allocation failed\n",
- __func__);
- goto fail1;
- }
- hal->shadow_wrptr_mem_vaddr =
- (uint32_t *)qdf_mem_alloc_consistent(qdf_dev, qdf_dev->dev,
- sizeof(*(hal->shadow_wrptr_mem_vaddr)) * HAL_MAX_LMAC_RINGS,
- &(hal->shadow_wrptr_mem_paddr));
- if (!hal->shadow_wrptr_mem_vaddr) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "%s: hal->shadow_wrptr_mem_vaddr allocation failed\n",
- __func__);
- goto fail2;
- }
- for (i = 0; i < HAL_SRNG_ID_MAX; i++) {
- hal->srng_list[i].initialized = 0;
- hal->srng_list[i].ring_id = i;
- }
- return (void *)hal;
- fail2:
- qdf_mem_free_consistent(qdf_dev, qdf_dev->dev,
- sizeof(*(hal->shadow_rdptr_mem_vaddr)) * HAL_SRNG_ID_MAX,
- hal->shadow_rdptr_mem_vaddr, hal->shadow_rdptr_mem_paddr, 0);
- fail1:
- qdf_mem_free(hal);
- fail0:
- return NULL;
- }
- extern void hal_detach(void *hal_soc)
- {
- struct hal_soc *hal = (struct hal_soc *)hal_soc;
- qdf_mem_free_consistent(hal->qdf_dev, hal->qdf_dev->dev,
- sizeof(*(hal->shadow_rdptr_mem_vaddr)) * HAL_SRNG_ID_MAX,
- hal->shadow_rdptr_mem_vaddr, hal->shadow_rdptr_mem_paddr, 0);
- qdf_mem_free_consistent(hal->qdf_dev, hal->qdf_dev->dev,
- sizeof(*(hal->shadow_wrptr_mem_vaddr)) * HAL_MAX_LMAC_RINGS,
- hal->shadow_wrptr_mem_vaddr, hal->shadow_wrptr_mem_paddr, 0);
- qdf_mem_free(hal);
- return;
- }
- static inline void hal_srng_src_hw_init(struct hal_soc *hal,
- struct hal_srng *srng)
- {
- uint32_t reg_val = 0;
- uint64_t tp_addr = 0;
- HIF_INFO("%s: hw_init srng %d", __func__, srng->ring_id);
- if (srng->flags & HAL_SRNG_MSI_INTR) {
- SRNG_SRC_REG_WRITE(srng, MSI1_BASE_LSB,
- srng->msi_addr & 0xffffffff);
- reg_val = SRNG_SM(SRNG_SRC_FLD(MSI1_BASE_MSB, ADDR),
- (uint64_t)(srng->msi_addr) >> 32) |
- SRNG_SM(SRNG_SRC_FLD(MSI1_BASE_MSB,
- MSI1_ENABLE), 1);
- SRNG_SRC_REG_WRITE(srng, MSI1_BASE_MSB, reg_val);
- SRNG_SRC_REG_WRITE(srng, MSI1_DATA, srng->msi_data);
- }
- HIF_INFO("%s: hw_init srng (msi_end) %d", __func__, srng->ring_id);
- SRNG_SRC_REG_WRITE(srng, BASE_LSB, srng->ring_base_paddr & 0xffffffff);
- reg_val = SRNG_SM(SRNG_SRC_FLD(BASE_MSB, RING_BASE_ADDR_MSB),
- ((uint64_t)(srng->ring_base_paddr) >> 32)) |
- SRNG_SM(SRNG_SRC_FLD(BASE_MSB, RING_SIZE),
- srng->entry_size * srng->num_entries);
- SRNG_SRC_REG_WRITE(srng, BASE_MSB, reg_val);
- #if defined(WCSS_VERSION) && (WCSS_VERSION > 81)
- reg_val = SRNG_SM(SRNG_SRC_FLD(ID, ENTRY_SIZE), srng->entry_size);
- #else
- reg_val = SRNG_SM(SRNG_SRC_FLD(ID, RING_ID), srng->ring_id) |
- SRNG_SM(SRNG_SRC_FLD(ID, ENTRY_SIZE), srng->entry_size);
- #endif
- SRNG_SRC_REG_WRITE(srng, ID, reg_val);
- reg_val = ((srng->flags & HAL_SRNG_DATA_TLV_SWAP) ?
- SRNG_SM(SRNG_SRC_FLD(MISC, DATA_TLV_SWAP_BIT), 1) : 0) |
- ((srng->flags & HAL_SRNG_RING_PTR_SWAP) ?
- SRNG_SM(SRNG_SRC_FLD(MISC, HOST_FW_SWAP_BIT), 1) : 0) |
- ((srng->flags & HAL_SRNG_MSI_SWAP) ?
- SRNG_SM(SRNG_SRC_FLD(MISC, MSI_SWAP_BIT), 1) : 0);
-
- reg_val |= SRNG_SM(SRNG_SRC_FLD(MISC, LOOPCNT_DISABLE), 1);
- SRNG_SRC_REG_WRITE(srng, MISC, reg_val);
-
- reg_val = 0;
- if (srng->intr_timer_thres_us) {
- reg_val |= SRNG_SM(SRNG_SRC_FLD(CONSUMER_INT_SETUP_IX0,
- INTERRUPT_TIMER_THRESHOLD),
- srng->intr_timer_thres_us >> 3);
- }
- if (srng->intr_batch_cntr_thres_entries) {
- reg_val |= SRNG_SM(SRNG_SRC_FLD(CONSUMER_INT_SETUP_IX0,
- BATCH_COUNTER_THRESHOLD),
- srng->intr_batch_cntr_thres_entries *
- srng->entry_size);
- }
- SRNG_SRC_REG_WRITE(srng, CONSUMER_INT_SETUP_IX0, reg_val);
- if (srng->flags & HAL_SRNG_LOW_THRES_INTR_ENABLE) {
- reg_val |= SRNG_SM(SRNG_SRC_FLD(CONSUMER_INT_SETUP_IX1,
- LOW_THRESHOLD), srng->u.src_ring.low_threshold);
- }
- SRNG_SRC_REG_WRITE(srng, CONSUMER_INT_SETUP_IX1, reg_val);
- tp_addr = (uint64_t)(hal->shadow_rdptr_mem_paddr +
- ((unsigned long)(srng->u.src_ring.tp_addr) -
- (unsigned long)(hal->shadow_rdptr_mem_vaddr)));
- SRNG_SRC_REG_WRITE(srng, TP_ADDR_LSB, tp_addr & 0xffffffff);
- SRNG_SRC_REG_WRITE(srng, TP_ADDR_MSB, tp_addr >> 32);
-
- SRNG_SRC_REG_WRITE(srng, HP, 0);
- SRNG_SRC_REG_WRITE(srng, TP, 0);
- *(srng->u.src_ring.tp_addr) = 0;
- }
- static inline void hal_ce_dst_setup(struct hal_soc *hal, struct hal_srng *srng,
- int ring_num)
- {
- uint32_t reg_val = 0;
- uint32_t reg_addr;
- struct hal_hw_srng_config *ring_config =
- HAL_SRNG_CONFIG(hal, CE_DST);
-
- reg_addr = HWIO_WFSS_CE_CHANNEL_DST_R0_DEST_CTRL_ADDR(
- ring_config->reg_start[R0_INDEX] +
- (ring_num * ring_config->reg_size[R0_INDEX]));
- reg_val = HAL_REG_READ(hal, reg_addr);
- reg_val &= ~HWIO_WFSS_CE_CHANNEL_DST_R0_DEST_CTRL_DEST_MAX_LENGTH_BMSK;
- reg_val |= srng->u.dst_ring.max_buffer_length &
- HWIO_WFSS_CE_CHANNEL_DST_R0_DEST_CTRL_DEST_MAX_LENGTH_BMSK;
- HAL_REG_WRITE(hal, reg_addr, reg_val);
- }
- static inline void hal_srng_dst_hw_init(struct hal_soc *hal,
- struct hal_srng *srng)
- {
- uint32_t reg_val = 0;
- uint64_t hp_addr = 0;
- HIF_INFO("%s: hw_init srng %d", __func__, srng->ring_id);
- if (srng->flags & HAL_SRNG_MSI_INTR) {
- SRNG_DST_REG_WRITE(srng, MSI1_BASE_LSB,
- srng->msi_addr & 0xffffffff);
- reg_val = SRNG_SM(SRNG_DST_FLD(MSI1_BASE_MSB, ADDR),
- (uint64_t)(srng->msi_addr) >> 32) |
- SRNG_SM(SRNG_DST_FLD(MSI1_BASE_MSB,
- MSI1_ENABLE), 1);
- SRNG_DST_REG_WRITE(srng, MSI1_BASE_MSB, reg_val);
- SRNG_DST_REG_WRITE(srng, MSI1_DATA, srng->msi_data);
- }
- HIF_INFO("%s: hw_init srng msi end %d", __func__, srng->ring_id);
- SRNG_DST_REG_WRITE(srng, BASE_LSB, srng->ring_base_paddr & 0xffffffff);
- reg_val = SRNG_SM(SRNG_DST_FLD(BASE_MSB, RING_BASE_ADDR_MSB),
- ((uint64_t)(srng->ring_base_paddr) >> 32)) |
- SRNG_SM(SRNG_DST_FLD(BASE_MSB, RING_SIZE),
- srng->entry_size * srng->num_entries);
- SRNG_DST_REG_WRITE(srng, BASE_MSB, reg_val);
- reg_val = SRNG_SM(SRNG_DST_FLD(ID, RING_ID), srng->ring_id) |
- SRNG_SM(SRNG_DST_FLD(ID, ENTRY_SIZE), srng->entry_size);
- SRNG_DST_REG_WRITE(srng, ID, reg_val);
- reg_val = ((srng->flags & HAL_SRNG_DATA_TLV_SWAP) ?
- SRNG_SM(SRNG_DST_FLD(MISC, DATA_TLV_SWAP_BIT), 1) : 0) |
- ((srng->flags & HAL_SRNG_RING_PTR_SWAP) ?
- SRNG_SM(SRNG_DST_FLD(MISC, HOST_FW_SWAP_BIT), 1) : 0) |
- ((srng->flags & HAL_SRNG_MSI_SWAP) ?
- SRNG_SM(SRNG_DST_FLD(MISC, MSI_SWAP_BIT), 1) : 0);
- SRNG_DST_REG_WRITE(srng, MISC, reg_val);
-
- reg_val = 0;
- if (srng->intr_timer_thres_us) {
- reg_val |= SRNG_SM(SRNG_DST_FLD(PRODUCER_INT_SETUP,
- INTERRUPT_TIMER_THRESHOLD),
- srng->intr_timer_thres_us >> 3);
- }
- if (srng->intr_batch_cntr_thres_entries) {
- reg_val |= SRNG_SM(SRNG_DST_FLD(PRODUCER_INT_SETUP,
- BATCH_COUNTER_THRESHOLD),
- srng->intr_batch_cntr_thres_entries *
- srng->entry_size);
- }
- SRNG_DST_REG_WRITE(srng, PRODUCER_INT_SETUP, reg_val);
- hp_addr = (uint64_t)(hal->shadow_rdptr_mem_paddr +
- ((unsigned long)(srng->u.dst_ring.hp_addr) -
- (unsigned long)(hal->shadow_rdptr_mem_vaddr)));
- SRNG_DST_REG_WRITE(srng, HP_ADDR_LSB, hp_addr & 0xffffffff);
- SRNG_DST_REG_WRITE(srng, HP_ADDR_MSB, hp_addr >> 32);
-
- SRNG_DST_REG_WRITE(srng, HP, 0);
- SRNG_DST_REG_WRITE(srng, TP, 0);
- *(srng->u.dst_ring.hp_addr) = 0;
- }
- static inline void hal_srng_hw_init(struct hal_soc *hal,
- struct hal_srng *srng)
- {
- if (srng->ring_dir == HAL_SRNG_SRC_RING)
- hal_srng_src_hw_init(hal, srng);
- else
- hal_srng_dst_hw_init(hal, srng);
- }
- void *hal_srng_setup(void *hal_soc, int ring_type, int ring_num,
- int mac_id, struct hal_srng_params *ring_params)
- {
- int ring_id;
- struct hal_soc *hal = (struct hal_soc *)hal_soc;
- struct hal_srng *srng;
- struct hal_hw_srng_config *ring_config =
- HAL_SRNG_CONFIG(hal, ring_type);
- void *dev_base_addr;
- int i;
- if (ring_num >= ring_config->max_rings) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "%s: ring_num exceeded maximum no. of supported rings\n",
- __func__);
- return NULL;
- }
- if (ring_config->lmac_ring) {
- ring_id = ring_config->start_ring_id + ring_num +
- (mac_id * HAL_MAX_RINGS_PER_LMAC);
- } else {
- ring_id = ring_config->start_ring_id + ring_num;
- }
-
- srng = &(hal->srng_list[ring_id]);
- if (srng->initialized) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "%s: Ring (ring_type, ring_num) already initialized\n",
- __func__);
- return NULL;
- }
- dev_base_addr = hal->dev_base_addr;
- srng->ring_id = ring_id;
- srng->ring_dir = ring_config->ring_dir;
- srng->ring_base_paddr = ring_params->ring_base_paddr;
- srng->ring_base_vaddr = ring_params->ring_base_vaddr;
- srng->entry_size = ring_config->entry_size;
- srng->num_entries = ring_params->num_entries;
- srng->ring_size = srng->num_entries * srng->entry_size;
- srng->ring_size_mask = srng->ring_size - 1;
- srng->msi_addr = ring_params->msi_addr;
- srng->msi_data = ring_params->msi_data;
- srng->intr_timer_thres_us = ring_params->intr_timer_thres_us;
- srng->intr_batch_cntr_thres_entries =
- ring_params->intr_batch_cntr_thres_entries;
- for (i = 0 ; i < MAX_SRNG_REG_GROUPS; i++) {
- srng->hwreg_base[i] = dev_base_addr + ring_config->reg_start[i]
- + (ring_num * ring_config->reg_size[i]);
- }
-
- qdf_mem_zero(srng->ring_base_vaddr, (srng->entry_size *
- srng->num_entries) << 2);
- srng->flags = ring_params->flags;
- #ifdef BIG_ENDIAN_HOST
-
- srng->flags |= HAL_SRNG_DATA_TLV_SWAP;
- srng->flags |= HAL_SRNG_MSI_SWAP;
- srng->flags |= HAL_SRNG_RING_PTR_SWAP;
- #endif
- if (srng->ring_dir == HAL_SRNG_SRC_RING) {
- srng->u.src_ring.hp = 0;
- srng->u.src_ring.reap_hp = srng->ring_size -
- srng->entry_size;
- srng->u.src_ring.tp_addr =
- &(hal->shadow_rdptr_mem_vaddr[ring_id]);
- srng->u.src_ring.low_threshold = ring_params->low_threshold;
- if (ring_config->lmac_ring) {
-
- srng->u.src_ring.hp_addr =
- &(hal->shadow_wrptr_mem_vaddr[ring_id -
- HAL_SRNG_LMAC1_ID_START]);
- srng->flags |= HAL_SRNG_LMAC_RING;
- } else {
- srng->u.src_ring.hp_addr = SRNG_SRC_ADDR(srng, HP);
- }
- } else {
-
- srng->u.dst_ring.loop_cnt = 1;
- srng->u.dst_ring.tp = 0;
- srng->u.dst_ring.hp_addr =
- &(hal->shadow_rdptr_mem_vaddr[ring_id]);
- if (ring_config->lmac_ring) {
-
- srng->u.dst_ring.tp_addr =
- &(hal->shadow_wrptr_mem_vaddr[ring_id -
- HAL_SRNG_LMAC1_ID_START]);
- srng->flags |= HAL_SRNG_LMAC_RING;
- } else {
- srng->u.dst_ring.tp_addr = SRNG_DST_ADDR(srng, TP);
- }
- }
- if (!(ring_config->lmac_ring)) {
- hal_srng_hw_init(hal, srng);
- if (ring_type == CE_DST) {
- srng->u.dst_ring.max_buffer_length = ring_params->max_buffer_length;
- hal_ce_dst_setup(hal, srng, ring_num);
- }
- }
- SRNG_LOCK_INIT(&srng->lock);
- return (void *)srng;
- }
- void hal_srng_cleanup(void *hal_soc, void *hal_srng)
- {
- struct hal_srng *srng = (struct hal_srng *)hal_srng;
- SRNG_LOCK_DESTROY(&srng->lock);
- srng->initialized = 0;
- }
- uint32_t hal_srng_get_entrysize(void *hal_soc, int ring_type)
- {
- struct hal_hw_srng_config *ring_config =
- HAL_SRNG_CONFIG(hal, ring_type);
- return ring_config->entry_size << 2;
- }
- extern void hal_get_srng_params(void *hal_soc, void *hal_ring,
- struct hal_srng_params *ring_params)
- {
- struct hal_srng *srng = (struct hal_srng *)hal_ring;
- ring_params->ring_base_paddr = srng->ring_base_paddr;
- ring_params->ring_base_vaddr = srng->ring_base_vaddr;
- ring_params->num_entries = srng->num_entries;
- ring_params->msi_addr = srng->msi_addr;
- ring_params->msi_data = srng->msi_data;
- ring_params->intr_timer_thres_us = srng->intr_timer_thres_us;
- ring_params->intr_batch_cntr_thres_entries =
- srng->intr_batch_cntr_thres_entries;
- ring_params->low_threshold = srng->u.src_ring.low_threshold;
- ring_params->flags = srng->flags;
- ring_params->ring_id = srng->ring_id;
- }
|