123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413 |
- /*
- * Copyright (c) 2018 The Linux Foundation. All rights reserved.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include "debug.h"
- #include "hif.h"
- #include "htc.h"
- #include "ce.h"
- #include "snoc.h"
- #include <linux/of.h>
- #include <linux/of_device.h>
- #include <linux/platform_device.h>
- #include <linux/regulator/consumer.h>
- #include <linux/clk.h>
- #define WCN3990_CE_ATTR_FLAGS 0
- #define ATH10K_SNOC_RX_POST_RETRY_MS 50
- #define CE_POLL_PIPE 4
- static char *const ce_name[] = {
- "WLAN_CE_0",
- "WLAN_CE_1",
- "WLAN_CE_2",
- "WLAN_CE_3",
- "WLAN_CE_4",
- "WLAN_CE_5",
- "WLAN_CE_6",
- "WLAN_CE_7",
- "WLAN_CE_8",
- "WLAN_CE_9",
- "WLAN_CE_10",
- "WLAN_CE_11",
- };
- static struct ath10k_wcn3990_vreg_info vreg_cfg[] = {
- {NULL, "vdd-0.8-cx-mx", 800000, 800000, 0, 0, false},
- {NULL, "vdd-1.8-xo", 1800000, 1800000, 0, 0, false},
- {NULL, "vdd-1.3-rfa", 1304000, 1304000, 0, 0, false},
- {NULL, "vdd-3.3-ch0", 3312000, 3312000, 0, 0, false},
- };
- static struct ath10k_wcn3990_clk_info clk_cfg[] = {
- {NULL, "cxo_ref_clk_pin", 0, false},
- };
- static void ath10k_snoc_htc_tx_cb(struct ath10k_ce_pipe *ce_state);
- static void ath10k_snoc_htt_tx_cb(struct ath10k_ce_pipe *ce_state);
- static void ath10k_snoc_htc_rx_cb(struct ath10k_ce_pipe *ce_state);
- static void ath10k_snoc_htt_rx_cb(struct ath10k_ce_pipe *ce_state);
- static void ath10k_snoc_htt_htc_rx_cb(struct ath10k_ce_pipe *ce_state);
- static const struct ath10k_snoc_drv_priv drv_priv = {
- .hw_rev = ATH10K_HW_WCN3990,
- .dma_mask = DMA_BIT_MASK(37),
- };
- static struct ce_attr host_ce_config_wlan[] = {
- /* CE0: host->target HTC control streams */
- {
- .flags = CE_ATTR_FLAGS,
- .src_nentries = 16,
- .src_sz_max = 2048,
- .dest_nentries = 0,
- .send_cb = ath10k_snoc_htc_tx_cb,
- },
- /* CE1: target->host HTT + HTC control */
- {
- .flags = CE_ATTR_FLAGS,
- .src_nentries = 0,
- .src_sz_max = 2048,
- .dest_nentries = 512,
- .recv_cb = ath10k_snoc_htt_htc_rx_cb,
- },
- /* CE2: target->host WMI */
- {
- .flags = CE_ATTR_FLAGS,
- .src_nentries = 0,
- .src_sz_max = 2048,
- .dest_nentries = 64,
- .recv_cb = ath10k_snoc_htc_rx_cb,
- },
- /* CE3: host->target WMI */
- {
- .flags = CE_ATTR_FLAGS,
- .src_nentries = 32,
- .src_sz_max = 2048,
- .dest_nentries = 0,
- .send_cb = ath10k_snoc_htc_tx_cb,
- },
- /* CE4: host->target HTT */
- {
- .flags = CE_ATTR_FLAGS | CE_ATTR_DIS_INTR,
- .src_nentries = 256,
- .src_sz_max = 256,
- .dest_nentries = 0,
- .send_cb = ath10k_snoc_htt_tx_cb,
- },
- /* CE5: target->host HTT (ipa_uc->target ) */
- {
- .flags = CE_ATTR_FLAGS,
- .src_nentries = 0,
- .src_sz_max = 512,
- .dest_nentries = 512,
- .recv_cb = ath10k_snoc_htt_rx_cb,
- },
- /* CE6: target autonomous hif_memcpy */
- {
- .flags = CE_ATTR_FLAGS,
- .src_nentries = 0,
- .src_sz_max = 0,
- .dest_nentries = 0,
- },
- /* CE7: ce_diag, the Diagnostic Window */
- {
- .flags = CE_ATTR_FLAGS,
- .src_nentries = 2,
- .src_sz_max = 2048,
- .dest_nentries = 2,
- },
- /* CE8: Target to uMC */
- {
- .flags = CE_ATTR_FLAGS,
- .src_nentries = 0,
- .src_sz_max = 2048,
- .dest_nentries = 128,
- },
- /* CE9 target->host HTT */
- {
- .flags = CE_ATTR_FLAGS,
- .src_nentries = 0,
- .src_sz_max = 2048,
- .dest_nentries = 512,
- .recv_cb = ath10k_snoc_htt_htc_rx_cb,
- },
- /* CE10: target->host HTT */
- {
- .flags = CE_ATTR_FLAGS,
- .src_nentries = 0,
- .src_sz_max = 2048,
- .dest_nentries = 512,
- .recv_cb = ath10k_snoc_htt_htc_rx_cb,
- },
- /* CE11: target -> host PKTLOG */
- {
- .flags = CE_ATTR_FLAGS,
- .src_nentries = 0,
- .src_sz_max = 2048,
- .dest_nentries = 512,
- .recv_cb = ath10k_snoc_htt_htc_rx_cb,
- },
- };
- static struct service_to_pipe target_service_to_ce_map_wlan[] = {
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VO),
- __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
- __cpu_to_le32(3),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VO),
- __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */
- __cpu_to_le32(2),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BK),
- __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
- __cpu_to_le32(3),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BK),
- __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */
- __cpu_to_le32(2),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BE),
- __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
- __cpu_to_le32(3),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BE),
- __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */
- __cpu_to_le32(2),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VI),
- __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
- __cpu_to_le32(3),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VI),
- __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */
- __cpu_to_le32(2),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_CONTROL),
- __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
- __cpu_to_le32(3),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_CONTROL),
- __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */
- __cpu_to_le32(2),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_RSVD_CTRL),
- __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
- __cpu_to_le32(0),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_RSVD_CTRL),
- __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */
- __cpu_to_le32(2),
- },
- { /* not used */
- __cpu_to_le32(ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS),
- __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
- __cpu_to_le32(0),
- },
- { /* not used */
- __cpu_to_le32(ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS),
- __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */
- __cpu_to_le32(2),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_DATA_MSG),
- __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
- __cpu_to_le32(4),
- },
- {
- __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_DATA_MSG),
- __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */
- __cpu_to_le32(1),
- },
- { /* not used */
- __cpu_to_le32(ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS),
- __cpu_to_le32(PIPEDIR_OUT),
- __cpu_to_le32(5),
- },
- { /* in = DL = target -> host */
- __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_DATA2_MSG),
- __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */
- __cpu_to_le32(9),
- },
- { /* in = DL = target -> host */
- __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_DATA3_MSG),
- __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */
- __cpu_to_le32(10),
- },
- { /* in = DL = target -> host pktlog */
- __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_LOG_MSG),
- __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */
- __cpu_to_le32(11),
- },
- /* (Additions here) */
- { /* must be last */
- __cpu_to_le32(0),
- __cpu_to_le32(0),
- __cpu_to_le32(0),
- },
- };
- void ath10k_snoc_write32(struct ath10k *ar, u32 offset, u32 value)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- iowrite32(value, ar_snoc->mem + offset);
- }
- u32 ath10k_snoc_read32(struct ath10k *ar, u32 offset)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- u32 val;
- val = ioread32(ar_snoc->mem + offset);
- return val;
- }
- static int __ath10k_snoc_rx_post_buf(struct ath10k_snoc_pipe *pipe)
- {
- struct ath10k_ce_pipe *ce_pipe = pipe->ce_hdl;
- struct ath10k *ar = pipe->hif_ce_state;
- struct ath10k_ce *ce = ath10k_ce_priv(ar);
- struct sk_buff *skb;
- dma_addr_t paddr;
- int ret;
- skb = dev_alloc_skb(pipe->buf_sz);
- if (!skb)
- return -ENOMEM;
- WARN_ONCE((unsigned long)skb->data & 3, "unaligned skb");
- paddr = dma_map_single(ar->dev, skb->data,
- skb->len + skb_tailroom(skb),
- DMA_FROM_DEVICE);
- if (unlikely(dma_mapping_error(ar->dev, paddr))) {
- ath10k_warn(ar, "failed to dma map snoc rx buf\n");
- dev_kfree_skb_any(skb);
- return -EIO;
- }
- ATH10K_SKB_RXCB(skb)->paddr = paddr;
- spin_lock_bh(&ce->ce_lock);
- ret = ce_pipe->ops->ce_rx_post_buf(ce_pipe, skb, paddr);
- spin_unlock_bh(&ce->ce_lock);
- if (ret) {
- dma_unmap_single(ar->dev, paddr, skb->len + skb_tailroom(skb),
- DMA_FROM_DEVICE);
- dev_kfree_skb_any(skb);
- return ret;
- }
- return 0;
- }
- static void ath10k_snoc_rx_post_pipe(struct ath10k_snoc_pipe *pipe)
- {
- struct ath10k *ar = pipe->hif_ce_state;
- struct ath10k_ce *ce = ath10k_ce_priv(ar);
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- struct ath10k_ce_pipe *ce_pipe = pipe->ce_hdl;
- int ret, num;
- if (pipe->buf_sz == 0)
- return;
- if (!ce_pipe->dest_ring)
- return;
- spin_lock_bh(&ce->ce_lock);
- num = __ath10k_ce_rx_num_free_bufs(ce_pipe);
- spin_unlock_bh(&ce->ce_lock);
- while (num--) {
- ret = __ath10k_snoc_rx_post_buf(pipe);
- if (ret) {
- if (ret == -ENOSPC)
- break;
- ath10k_warn(ar, "failed to post rx buf: %d\n", ret);
- mod_timer(&ar_snoc->rx_post_retry, jiffies +
- ATH10K_SNOC_RX_POST_RETRY_MS);
- break;
- }
- }
- }
- static void ath10k_snoc_rx_post(struct ath10k *ar)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- int i;
- for (i = 0; i < CE_COUNT; i++)
- ath10k_snoc_rx_post_pipe(&ar_snoc->pipe_info[i]);
- }
- static void ath10k_snoc_process_rx_cb(struct ath10k_ce_pipe *ce_state,
- void (*callback)(struct ath10k *ar,
- struct sk_buff *skb))
- {
- struct ath10k *ar = ce_state->ar;
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- struct ath10k_snoc_pipe *pipe_info = &ar_snoc->pipe_info[ce_state->id];
- struct sk_buff *skb;
- struct sk_buff_head list;
- void *transfer_context;
- unsigned int nbytes, max_nbytes;
- __skb_queue_head_init(&list);
- while (ath10k_ce_completed_recv_next(ce_state, &transfer_context,
- &nbytes) == 0) {
- skb = transfer_context;
- max_nbytes = skb->len + skb_tailroom(skb);
- dma_unmap_single(ar->dev, ATH10K_SKB_RXCB(skb)->paddr,
- max_nbytes, DMA_FROM_DEVICE);
- if (unlikely(max_nbytes < nbytes)) {
- ath10k_warn(ar, "rxed more than expected (nbytes %d, max %d)",
- nbytes, max_nbytes);
- dev_kfree_skb_any(skb);
- continue;
- }
- skb_put(skb, nbytes);
- __skb_queue_tail(&list, skb);
- }
- while ((skb = __skb_dequeue(&list))) {
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc rx ce pipe %d len %d\n",
- ce_state->id, skb->len);
- callback(ar, skb);
- }
- ath10k_snoc_rx_post_pipe(pipe_info);
- }
- static void ath10k_snoc_htc_rx_cb(struct ath10k_ce_pipe *ce_state)
- {
- ath10k_snoc_process_rx_cb(ce_state, ath10k_htc_rx_completion_handler);
- }
- static void ath10k_snoc_htt_htc_rx_cb(struct ath10k_ce_pipe *ce_state)
- {
- /* CE4 polling needs to be done whenever CE pipe which transports
- * HTT Rx (target->host) is processed.
- */
- ath10k_ce_per_engine_service(ce_state->ar, CE_POLL_PIPE);
- ath10k_snoc_process_rx_cb(ce_state, ath10k_htc_rx_completion_handler);
- }
- static void ath10k_snoc_htt_rx_deliver(struct ath10k *ar, struct sk_buff *skb)
- {
- skb_pull(skb, sizeof(struct ath10k_htc_hdr));
- ath10k_htt_t2h_msg_handler(ar, skb);
- }
- static void ath10k_snoc_htt_rx_cb(struct ath10k_ce_pipe *ce_state)
- {
- ath10k_ce_per_engine_service(ce_state->ar, CE_POLL_PIPE);
- ath10k_snoc_process_rx_cb(ce_state, ath10k_snoc_htt_rx_deliver);
- }
- static void ath10k_snoc_rx_replenish_retry(struct timer_list *t)
- {
- struct ath10k_pci *ar_snoc = from_timer(ar_snoc, t, rx_post_retry);
- struct ath10k *ar = ar_snoc->ar;
- ath10k_snoc_rx_post(ar);
- }
- static void ath10k_snoc_htc_tx_cb(struct ath10k_ce_pipe *ce_state)
- {
- struct ath10k *ar = ce_state->ar;
- struct sk_buff_head list;
- struct sk_buff *skb;
- __skb_queue_head_init(&list);
- while (ath10k_ce_completed_send_next(ce_state, (void **)&skb) == 0) {
- if (!skb)
- continue;
- __skb_queue_tail(&list, skb);
- }
- while ((skb = __skb_dequeue(&list)))
- ath10k_htc_tx_completion_handler(ar, skb);
- }
- static void ath10k_snoc_htt_tx_cb(struct ath10k_ce_pipe *ce_state)
- {
- struct ath10k *ar = ce_state->ar;
- struct sk_buff *skb;
- while (ath10k_ce_completed_send_next(ce_state, (void **)&skb) == 0) {
- if (!skb)
- continue;
- dma_unmap_single(ar->dev, ATH10K_SKB_CB(skb)->paddr,
- skb->len, DMA_TO_DEVICE);
- ath10k_htt_hif_tx_complete(ar, skb);
- }
- }
- static int ath10k_snoc_hif_tx_sg(struct ath10k *ar, u8 pipe_id,
- struct ath10k_hif_sg_item *items, int n_items)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- struct ath10k_ce *ce = ath10k_ce_priv(ar);
- struct ath10k_snoc_pipe *snoc_pipe;
- struct ath10k_ce_pipe *ce_pipe;
- int err, i = 0;
- snoc_pipe = &ar_snoc->pipe_info[pipe_id];
- ce_pipe = snoc_pipe->ce_hdl;
- spin_lock_bh(&ce->ce_lock);
- for (i = 0; i < n_items - 1; i++) {
- ath10k_dbg(ar, ATH10K_DBG_SNOC,
- "snoc tx item %d paddr %pad len %d n_items %d\n",
- i, &items[i].paddr, items[i].len, n_items);
- err = ath10k_ce_send_nolock(ce_pipe,
- items[i].transfer_context,
- items[i].paddr,
- items[i].len,
- items[i].transfer_id,
- CE_SEND_FLAG_GATHER);
- if (err)
- goto err;
- }
- ath10k_dbg(ar, ATH10K_DBG_SNOC,
- "snoc tx item %d paddr %pad len %d n_items %d\n",
- i, &items[i].paddr, items[i].len, n_items);
- err = ath10k_ce_send_nolock(ce_pipe,
- items[i].transfer_context,
- items[i].paddr,
- items[i].len,
- items[i].transfer_id,
- 0);
- if (err)
- goto err;
- spin_unlock_bh(&ce->ce_lock);
- return 0;
- err:
- for (; i > 0; i--)
- __ath10k_ce_send_revert(ce_pipe);
- spin_unlock_bh(&ce->ce_lock);
- return err;
- }
- static int ath10k_snoc_hif_get_target_info(struct ath10k *ar,
- struct bmi_target_info *target_info)
- {
- target_info->version = ATH10K_HW_WCN3990;
- target_info->type = ATH10K_HW_WCN3990;
- return 0;
- }
- static u16 ath10k_snoc_hif_get_free_queue_number(struct ath10k *ar, u8 pipe)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "hif get free queue number\n");
- return ath10k_ce_num_free_src_entries(ar_snoc->pipe_info[pipe].ce_hdl);
- }
- static void ath10k_snoc_hif_send_complete_check(struct ath10k *ar, u8 pipe,
- int force)
- {
- int resources;
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc hif send complete check\n");
- if (!force) {
- resources = ath10k_snoc_hif_get_free_queue_number(ar, pipe);
- if (resources > (host_ce_config_wlan[pipe].src_nentries >> 1))
- return;
- }
- ath10k_ce_per_engine_service(ar, pipe);
- }
- static int ath10k_snoc_hif_map_service_to_pipe(struct ath10k *ar,
- u16 service_id,
- u8 *ul_pipe, u8 *dl_pipe)
- {
- const struct service_to_pipe *entry;
- bool ul_set = false, dl_set = false;
- int i;
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc hif map service\n");
- for (i = 0; i < ARRAY_SIZE(target_service_to_ce_map_wlan); i++) {
- entry = &target_service_to_ce_map_wlan[i];
- if (__le32_to_cpu(entry->service_id) != service_id)
- continue;
- switch (__le32_to_cpu(entry->pipedir)) {
- case PIPEDIR_NONE:
- break;
- case PIPEDIR_IN:
- WARN_ON(dl_set);
- *dl_pipe = __le32_to_cpu(entry->pipenum);
- dl_set = true;
- break;
- case PIPEDIR_OUT:
- WARN_ON(ul_set);
- *ul_pipe = __le32_to_cpu(entry->pipenum);
- ul_set = true;
- break;
- case PIPEDIR_INOUT:
- WARN_ON(dl_set);
- WARN_ON(ul_set);
- *dl_pipe = __le32_to_cpu(entry->pipenum);
- *ul_pipe = __le32_to_cpu(entry->pipenum);
- dl_set = true;
- ul_set = true;
- break;
- }
- }
- if (WARN_ON(!ul_set || !dl_set))
- return -ENOENT;
- return 0;
- }
- static void ath10k_snoc_hif_get_default_pipe(struct ath10k *ar,
- u8 *ul_pipe, u8 *dl_pipe)
- {
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc hif get default pipe\n");
- (void)ath10k_snoc_hif_map_service_to_pipe(ar,
- ATH10K_HTC_SVC_ID_RSVD_CTRL,
- ul_pipe, dl_pipe);
- }
- static inline void ath10k_snoc_irq_disable(struct ath10k *ar)
- {
- ath10k_ce_disable_interrupts(ar);
- }
- static inline void ath10k_snoc_irq_enable(struct ath10k *ar)
- {
- ath10k_ce_enable_interrupts(ar);
- }
- static void ath10k_snoc_rx_pipe_cleanup(struct ath10k_snoc_pipe *snoc_pipe)
- {
- struct ath10k_ce_pipe *ce_pipe;
- struct ath10k_ce_ring *ce_ring;
- struct sk_buff *skb;
- struct ath10k *ar;
- int i;
- ar = snoc_pipe->hif_ce_state;
- ce_pipe = snoc_pipe->ce_hdl;
- ce_ring = ce_pipe->dest_ring;
- if (!ce_ring)
- return;
- if (!snoc_pipe->buf_sz)
- return;
- for (i = 0; i < ce_ring->nentries; i++) {
- skb = ce_ring->per_transfer_context[i];
- if (!skb)
- continue;
- ce_ring->per_transfer_context[i] = NULL;
- dma_unmap_single(ar->dev, ATH10K_SKB_RXCB(skb)->paddr,
- skb->len + skb_tailroom(skb),
- DMA_FROM_DEVICE);
- dev_kfree_skb_any(skb);
- }
- }
- static void ath10k_snoc_tx_pipe_cleanup(struct ath10k_snoc_pipe *snoc_pipe)
- {
- struct ath10k_ce_pipe *ce_pipe;
- struct ath10k_ce_ring *ce_ring;
- struct ath10k_snoc *ar_snoc;
- struct sk_buff *skb;
- struct ath10k *ar;
- int i;
- ar = snoc_pipe->hif_ce_state;
- ar_snoc = ath10k_snoc_priv(ar);
- ce_pipe = snoc_pipe->ce_hdl;
- ce_ring = ce_pipe->src_ring;
- if (!ce_ring)
- return;
- if (!snoc_pipe->buf_sz)
- return;
- for (i = 0; i < ce_ring->nentries; i++) {
- skb = ce_ring->per_transfer_context[i];
- if (!skb)
- continue;
- ce_ring->per_transfer_context[i] = NULL;
- ath10k_htc_tx_completion_handler(ar, skb);
- }
- }
- static void ath10k_snoc_buffer_cleanup(struct ath10k *ar)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- struct ath10k_snoc_pipe *pipe_info;
- int pipe_num;
- del_timer_sync(&ar_snoc->rx_post_retry);
- for (pipe_num = 0; pipe_num < CE_COUNT; pipe_num++) {
- pipe_info = &ar_snoc->pipe_info[pipe_num];
- ath10k_snoc_rx_pipe_cleanup(pipe_info);
- ath10k_snoc_tx_pipe_cleanup(pipe_info);
- }
- }
- static void ath10k_snoc_hif_stop(struct ath10k *ar)
- {
- ath10k_snoc_irq_disable(ar);
- ath10k_snoc_buffer_cleanup(ar);
- napi_synchronize(&ar->napi);
- napi_disable(&ar->napi);
- ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif stop\n");
- }
- static int ath10k_snoc_hif_start(struct ath10k *ar)
- {
- ath10k_snoc_irq_enable(ar);
- ath10k_snoc_rx_post(ar);
- ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif start\n");
- return 0;
- }
- static int ath10k_snoc_init_pipes(struct ath10k *ar)
- {
- int i, ret;
- for (i = 0; i < CE_COUNT; i++) {
- ret = ath10k_ce_init_pipe(ar, i, &host_ce_config_wlan[i]);
- if (ret) {
- ath10k_err(ar, "failed to initialize copy engine pipe %d: %d\n",
- i, ret);
- return ret;
- }
- }
- return 0;
- }
- static int ath10k_snoc_wlan_enable(struct ath10k *ar)
- {
- return 0;
- }
- static void ath10k_snoc_wlan_disable(struct ath10k *ar)
- {
- }
- static void ath10k_snoc_hif_power_down(struct ath10k *ar)
- {
- ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power down\n");
- ath10k_snoc_wlan_disable(ar);
- ath10k_ce_free_rri(ar);
- }
- static int ath10k_snoc_hif_power_up(struct ath10k *ar)
- {
- int ret;
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "%s:WCN3990 driver state = %d\n",
- __func__, ar->state);
- ret = ath10k_snoc_wlan_enable(ar);
- if (ret) {
- ath10k_err(ar, "failed to enable wcn3990: %d\n", ret);
- return ret;
- }
- ath10k_ce_alloc_rri(ar);
- ret = ath10k_snoc_init_pipes(ar);
- if (ret) {
- ath10k_err(ar, "failed to initialize CE: %d\n", ret);
- goto err_wlan_enable;
- }
- napi_enable(&ar->napi);
- return 0;
- err_wlan_enable:
- ath10k_snoc_wlan_disable(ar);
- return ret;
- }
- static const struct ath10k_hif_ops ath10k_snoc_hif_ops = {
- .read32 = ath10k_snoc_read32,
- .write32 = ath10k_snoc_write32,
- .start = ath10k_snoc_hif_start,
- .stop = ath10k_snoc_hif_stop,
- .map_service_to_pipe = ath10k_snoc_hif_map_service_to_pipe,
- .get_default_pipe = ath10k_snoc_hif_get_default_pipe,
- .power_up = ath10k_snoc_hif_power_up,
- .power_down = ath10k_snoc_hif_power_down,
- .tx_sg = ath10k_snoc_hif_tx_sg,
- .send_complete_check = ath10k_snoc_hif_send_complete_check,
- .get_free_queue_number = ath10k_snoc_hif_get_free_queue_number,
- .get_target_info = ath10k_snoc_hif_get_target_info,
- };
- static const struct ath10k_bus_ops ath10k_snoc_bus_ops = {
- .read32 = ath10k_snoc_read32,
- .write32 = ath10k_snoc_write32,
- };
- int ath10k_snoc_get_ce_id_from_irq(struct ath10k *ar, int irq)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- int i;
- for (i = 0; i < CE_COUNT_MAX; i++) {
- if (ar_snoc->ce_irqs[i].irq_line == irq)
- return i;
- }
- ath10k_err(ar, "No matching CE id for irq %d\n", irq);
- return -EINVAL;
- }
- static irqreturn_t ath10k_snoc_per_engine_handler(int irq, void *arg)
- {
- struct ath10k *ar = arg;
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- int ce_id = ath10k_snoc_get_ce_id_from_irq(ar, irq);
- if (ce_id < 0 || ce_id >= ARRAY_SIZE(ar_snoc->pipe_info)) {
- ath10k_warn(ar, "unexpected/invalid irq %d ce_id %d\n", irq,
- ce_id);
- return IRQ_HANDLED;
- }
- ath10k_snoc_irq_disable(ar);
- napi_schedule(&ar->napi);
- return IRQ_HANDLED;
- }
- static int ath10k_snoc_napi_poll(struct napi_struct *ctx, int budget)
- {
- struct ath10k *ar = container_of(ctx, struct ath10k, napi);
- int done = 0;
- ath10k_ce_per_engine_service_any(ar);
- done = ath10k_htt_txrx_compl_task(ar, budget);
- if (done < budget) {
- napi_complete(ctx);
- ath10k_snoc_irq_enable(ar);
- }
- return done;
- }
- void ath10k_snoc_init_napi(struct ath10k *ar)
- {
- netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_snoc_napi_poll,
- ATH10K_NAPI_BUDGET);
- }
- static int ath10k_snoc_request_irq(struct ath10k *ar)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- int irqflags = IRQF_TRIGGER_RISING;
- int ret, id;
- for (id = 0; id < CE_COUNT_MAX; id++) {
- ret = request_irq(ar_snoc->ce_irqs[id].irq_line,
- ath10k_snoc_per_engine_handler,
- irqflags, ce_name[id], ar);
- if (ret) {
- ath10k_err(ar,
- "failed to register IRQ handler for CE %d: %d",
- id, ret);
- goto err_irq;
- }
- }
- return 0;
- err_irq:
- for (id -= 1; id >= 0; id--)
- free_irq(ar_snoc->ce_irqs[id].irq_line, ar);
- return ret;
- }
- static void ath10k_snoc_free_irq(struct ath10k *ar)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- int id;
- for (id = 0; id < CE_COUNT_MAX; id++)
- free_irq(ar_snoc->ce_irqs[id].irq_line, ar);
- }
- static int ath10k_snoc_resource_init(struct ath10k *ar)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- struct platform_device *pdev;
- struct resource *res;
- int i, ret = 0;
- pdev = ar_snoc->dev;
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "membase");
- if (!res) {
- ath10k_err(ar, "Memory base not found in DT\n");
- return -EINVAL;
- }
- ar_snoc->mem_pa = res->start;
- ar_snoc->mem = devm_ioremap(&pdev->dev, ar_snoc->mem_pa,
- resource_size(res));
- if (!ar_snoc->mem) {
- ath10k_err(ar, "Memory base ioremap failed with physical address %pa\n",
- &ar_snoc->mem_pa);
- return -EINVAL;
- }
- for (i = 0; i < CE_COUNT; i++) {
- res = platform_get_resource(ar_snoc->dev, IORESOURCE_IRQ, i);
- if (!res) {
- ath10k_err(ar, "failed to get IRQ%d\n", i);
- ret = -ENODEV;
- goto out;
- }
- ar_snoc->ce_irqs[i].irq_line = res->start;
- }
- out:
- return ret;
- }
- static int ath10k_snoc_setup_resource(struct ath10k *ar)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- struct ath10k_ce *ce = ath10k_ce_priv(ar);
- struct ath10k_snoc_pipe *pipe;
- int i, ret;
- timer_setup(&ar_snoc->rx_post_retry, ath10k_snoc_rx_replenish_retry, 0);
- spin_lock_init(&ce->ce_lock);
- for (i = 0; i < CE_COUNT; i++) {
- pipe = &ar_snoc->pipe_info[i];
- pipe->ce_hdl = &ce->ce_states[i];
- pipe->pipe_num = i;
- pipe->hif_ce_state = ar;
- ret = ath10k_ce_alloc_pipe(ar, i, &host_ce_config_wlan[i]);
- if (ret) {
- ath10k_err(ar, "failed to allocate copy engine pipe %d: %d\n",
- i, ret);
- return ret;
- }
- pipe->buf_sz = host_ce_config_wlan[i].src_sz_max;
- }
- ath10k_snoc_init_napi(ar);
- return 0;
- }
- static void ath10k_snoc_release_resource(struct ath10k *ar)
- {
- int i;
- netif_napi_del(&ar->napi);
- for (i = 0; i < CE_COUNT; i++)
- ath10k_ce_free_pipe(ar, i);
- }
- static int ath10k_get_vreg_info(struct ath10k *ar, struct device *dev,
- struct ath10k_wcn3990_vreg_info *vreg_info)
- {
- struct regulator *reg;
- int ret = 0;
- reg = devm_regulator_get_optional(dev, vreg_info->name);
- if (IS_ERR(reg)) {
- ret = PTR_ERR(reg);
- if (ret == -EPROBE_DEFER) {
- ath10k_err(ar, "EPROBE_DEFER for regulator: %s\n",
- vreg_info->name);
- return ret;
- }
- if (vreg_info->required) {
- ath10k_err(ar, "Regulator %s doesn't exist: %d\n",
- vreg_info->name, ret);
- return ret;
- }
- ath10k_dbg(ar, ATH10K_DBG_SNOC,
- "Optional regulator %s doesn't exist: %d\n",
- vreg_info->name, ret);
- goto done;
- }
- vreg_info->reg = reg;
- done:
- ath10k_dbg(ar, ATH10K_DBG_SNOC,
- "snog vreg %s min_v %u max_v %u load_ua %u settle_delay %lu\n",
- vreg_info->name, vreg_info->min_v, vreg_info->max_v,
- vreg_info->load_ua, vreg_info->settle_delay);
- return 0;
- }
- static int ath10k_get_clk_info(struct ath10k *ar, struct device *dev,
- struct ath10k_wcn3990_clk_info *clk_info)
- {
- struct clk *handle;
- int ret = 0;
- handle = devm_clk_get(dev, clk_info->name);
- if (IS_ERR(handle)) {
- ret = PTR_ERR(handle);
- if (clk_info->required) {
- ath10k_err(ar, "snoc clock %s isn't available: %d\n",
- clk_info->name, ret);
- return ret;
- }
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc ignoring clock %s: %d\n",
- clk_info->name,
- ret);
- return 0;
- }
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc clock %s freq %u\n",
- clk_info->name, clk_info->freq);
- clk_info->handle = handle;
- return ret;
- }
- static int ath10k_wcn3990_vreg_on(struct ath10k *ar)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- struct ath10k_wcn3990_vreg_info *vreg_info;
- int ret = 0;
- int i;
- for (i = 0; i < ARRAY_SIZE(vreg_cfg); i++) {
- vreg_info = &ar_snoc->vreg[i];
- if (!vreg_info->reg)
- continue;
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc regulator %s being enabled\n",
- vreg_info->name);
- ret = regulator_set_voltage(vreg_info->reg, vreg_info->min_v,
- vreg_info->max_v);
- if (ret) {
- ath10k_err(ar,
- "failed to set regulator %s voltage-min: %d voltage-max: %d\n",
- vreg_info->name, vreg_info->min_v, vreg_info->max_v);
- goto err_reg_config;
- }
- if (vreg_info->load_ua) {
- ret = regulator_set_load(vreg_info->reg,
- vreg_info->load_ua);
- if (ret < 0) {
- ath10k_err(ar,
- "failed to set regulator %s load: %d\n",
- vreg_info->name,
- vreg_info->load_ua);
- goto err_reg_config;
- }
- }
- ret = regulator_enable(vreg_info->reg);
- if (ret) {
- ath10k_err(ar, "failed to enable regulator %s\n",
- vreg_info->name);
- goto err_reg_config;
- }
- if (vreg_info->settle_delay)
- udelay(vreg_info->settle_delay);
- }
- return 0;
- err_reg_config:
- for (; i >= 0; i--) {
- vreg_info = &ar_snoc->vreg[i];
- if (!vreg_info->reg)
- continue;
- regulator_disable(vreg_info->reg);
- regulator_set_load(vreg_info->reg, 0);
- regulator_set_voltage(vreg_info->reg, 0, vreg_info->max_v);
- }
- return ret;
- }
- static int ath10k_wcn3990_vreg_off(struct ath10k *ar)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- struct ath10k_wcn3990_vreg_info *vreg_info;
- int ret = 0;
- int i;
- for (i = ARRAY_SIZE(vreg_cfg) - 1; i >= 0; i--) {
- vreg_info = &ar_snoc->vreg[i];
- if (!vreg_info->reg)
- continue;
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc regulator %s being disabled\n",
- vreg_info->name);
- ret = regulator_disable(vreg_info->reg);
- if (ret)
- ath10k_err(ar, "failed to disable regulator %s\n",
- vreg_info->name);
- ret = regulator_set_load(vreg_info->reg, 0);
- if (ret < 0)
- ath10k_err(ar, "failed to set load %s\n",
- vreg_info->name);
- ret = regulator_set_voltage(vreg_info->reg, 0,
- vreg_info->max_v);
- if (ret)
- ath10k_err(ar, "failed to set voltage %s\n",
- vreg_info->name);
- }
- return ret;
- }
- static int ath10k_wcn3990_clk_init(struct ath10k *ar)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- struct ath10k_wcn3990_clk_info *clk_info;
- int ret = 0;
- int i;
- for (i = 0; i < ARRAY_SIZE(clk_cfg); i++) {
- clk_info = &ar_snoc->clk[i];
- if (!clk_info->handle)
- continue;
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc clock %s being enabled\n",
- clk_info->name);
- if (clk_info->freq) {
- ret = clk_set_rate(clk_info->handle, clk_info->freq);
- if (ret) {
- ath10k_err(ar, "failed to set clock %s freq %u\n",
- clk_info->name, clk_info->freq);
- goto err_clock_config;
- }
- }
- ret = clk_prepare_enable(clk_info->handle);
- if (ret) {
- ath10k_err(ar, "failed to enable clock %s\n",
- clk_info->name);
- goto err_clock_config;
- }
- }
- return 0;
- err_clock_config:
- for (; i >= 0; i--) {
- clk_info = &ar_snoc->clk[i];
- if (!clk_info->handle)
- continue;
- clk_disable_unprepare(clk_info->handle);
- }
- return ret;
- }
- static int ath10k_wcn3990_clk_deinit(struct ath10k *ar)
- {
- struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
- struct ath10k_wcn3990_clk_info *clk_info;
- int i;
- for (i = 0; i < ARRAY_SIZE(clk_cfg); i++) {
- clk_info = &ar_snoc->clk[i];
- if (!clk_info->handle)
- continue;
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc clock %s being disabled\n",
- clk_info->name);
- clk_disable_unprepare(clk_info->handle);
- }
- return 0;
- }
- static int ath10k_hw_power_on(struct ath10k *ar)
- {
- int ret;
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "soc power on\n");
- ret = ath10k_wcn3990_vreg_on(ar);
- if (ret)
- return ret;
- ret = ath10k_wcn3990_clk_init(ar);
- if (ret)
- goto vreg_off;
- return ret;
- vreg_off:
- ath10k_wcn3990_vreg_off(ar);
- return ret;
- }
- static int ath10k_hw_power_off(struct ath10k *ar)
- {
- int ret;
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "soc power off\n");
- ath10k_wcn3990_clk_deinit(ar);
- ret = ath10k_wcn3990_vreg_off(ar);
- return ret;
- }
- static const struct of_device_id ath10k_snoc_dt_match[] = {
- { .compatible = "qcom,wcn3990-wifi",
- .data = &drv_priv,
- },
- { }
- };
- MODULE_DEVICE_TABLE(of, ath10k_snoc_dt_match);
- static int ath10k_snoc_probe(struct platform_device *pdev)
- {
- const struct ath10k_snoc_drv_priv *drv_data;
- const struct of_device_id *of_id;
- struct ath10k_snoc *ar_snoc;
- struct device *dev;
- struct ath10k *ar;
- int ret;
- u32 i;
- of_id = of_match_device(ath10k_snoc_dt_match, &pdev->dev);
- if (!of_id) {
- dev_err(&pdev->dev, "failed to find matching device tree id\n");
- return -EINVAL;
- }
- drv_data = of_id->data;
- dev = &pdev->dev;
- ret = dma_set_mask_and_coherent(dev, drv_data->dma_mask);
- if (ret) {
- dev_err(dev, "failed to set dma mask: %d", ret);
- return ret;
- }
- ar = ath10k_core_create(sizeof(*ar_snoc), dev, ATH10K_BUS_SNOC,
- drv_data->hw_rev, &ath10k_snoc_hif_ops);
- if (!ar) {
- dev_err(dev, "failed to allocate core\n");
- return -ENOMEM;
- }
- ar_snoc = ath10k_snoc_priv(ar);
- ar_snoc->dev = pdev;
- platform_set_drvdata(pdev, ar);
- ar_snoc->ar = ar;
- ar_snoc->ce.bus_ops = &ath10k_snoc_bus_ops;
- ar->ce_priv = &ar_snoc->ce;
- ath10k_snoc_resource_init(ar);
- if (ret) {
- ath10k_warn(ar, "failed to initialize resource: %d\n", ret);
- goto err_core_destroy;
- }
- ath10k_snoc_setup_resource(ar);
- if (ret) {
- ath10k_warn(ar, "failed to setup resource: %d\n", ret);
- goto err_core_destroy;
- }
- ret = ath10k_snoc_request_irq(ar);
- if (ret) {
- ath10k_warn(ar, "failed to request irqs: %d\n", ret);
- goto err_release_resource;
- }
- ar_snoc->vreg = vreg_cfg;
- for (i = 0; i < ARRAY_SIZE(vreg_cfg); i++) {
- ret = ath10k_get_vreg_info(ar, dev, &ar_snoc->vreg[i]);
- if (ret)
- goto err_free_irq;
- }
- ar_snoc->clk = clk_cfg;
- for (i = 0; i < ARRAY_SIZE(clk_cfg); i++) {
- ret = ath10k_get_clk_info(ar, dev, &ar_snoc->clk[i]);
- if (ret)
- goto err_free_irq;
- }
- ret = ath10k_hw_power_on(ar);
- if (ret) {
- ath10k_err(ar, "failed to power on device: %d\n", ret);
- goto err_free_irq;
- }
- ret = ath10k_core_register(ar, drv_data->hw_rev);
- if (ret) {
- ath10k_err(ar, "failed to register driver core: %d\n", ret);
- goto err_hw_power_off;
- }
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc probe\n");
- ath10k_warn(ar, "Warning: SNOC support is still work-in-progress, it will not work properly!");
- return 0;
- err_hw_power_off:
- ath10k_hw_power_off(ar);
- err_free_irq:
- ath10k_snoc_free_irq(ar);
- err_release_resource:
- ath10k_snoc_release_resource(ar);
- err_core_destroy:
- ath10k_core_destroy(ar);
- return ret;
- }
- static int ath10k_snoc_remove(struct platform_device *pdev)
- {
- struct ath10k *ar = platform_get_drvdata(pdev);
- ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc remove\n");
- ath10k_core_unregister(ar);
- ath10k_hw_power_off(ar);
- ath10k_snoc_free_irq(ar);
- ath10k_snoc_release_resource(ar);
- ath10k_core_destroy(ar);
- return 0;
- }
- static struct platform_driver ath10k_snoc_driver = {
- .probe = ath10k_snoc_probe,
- .remove = ath10k_snoc_remove,
- .driver = {
- .name = "ath10k_snoc",
- .of_match_table = ath10k_snoc_dt_match,
- },
- };
- static int __init ath10k_snoc_init(void)
- {
- int ret;
- ret = platform_driver_register(&ath10k_snoc_driver);
- if (ret)
- pr_err("failed to register ath10k snoc driver: %d\n",
- ret);
- return ret;
- }
- module_init(ath10k_snoc_init);
- static void __exit ath10k_snoc_exit(void)
- {
- platform_driver_unregister(&ath10k_snoc_driver);
- }
- module_exit(ath10k_snoc_exit);
- MODULE_AUTHOR("Qualcomm");
- MODULE_LICENSE("Dual BSD/GPL");
- MODULE_DESCRIPTION("Driver support for Atheros WCN3990 SNOC devices");
|