xref: /linux/drivers/net/wireless/intel/iwlwifi/iwl-scd.h (revision cdd38c5f1ce4398ec58fec95904b75824daab7b5)
1*8e99ea8dSJohannes Berg /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2*8e99ea8dSJohannes Berg /*
3*8e99ea8dSJohannes Berg  * Copyright (C) 2014 Intel Mobile Communications GmbH
4*8e99ea8dSJohannes Berg  */
5e705c121SKalle Valo #ifndef __iwl_scd_h__
6e705c121SKalle Valo #define __iwl_scd_h__
7e705c121SKalle Valo 
8e705c121SKalle Valo #include "iwl-trans.h"
9e705c121SKalle Valo #include "iwl-io.h"
10e705c121SKalle Valo #include "iwl-prph.h"
11e705c121SKalle Valo 
12e705c121SKalle Valo 
iwl_scd_txq_set_chain(struct iwl_trans * trans,u16 txq_id)13e705c121SKalle Valo static inline void iwl_scd_txq_set_chain(struct iwl_trans *trans,
14e705c121SKalle Valo 					 u16 txq_id)
15e705c121SKalle Valo {
16e705c121SKalle Valo 	iwl_set_bits_prph(trans, SCD_QUEUECHAIN_SEL, BIT(txq_id));
17e705c121SKalle Valo }
18e705c121SKalle Valo 
iwl_scd_txq_enable_agg(struct iwl_trans * trans,u16 txq_id)19e705c121SKalle Valo static inline void iwl_scd_txq_enable_agg(struct iwl_trans *trans,
20e705c121SKalle Valo 					  u16 txq_id)
21e705c121SKalle Valo {
22e705c121SKalle Valo 	iwl_set_bits_prph(trans, SCD_AGGR_SEL, BIT(txq_id));
23e705c121SKalle Valo }
24e705c121SKalle Valo 
iwl_scd_txq_disable_agg(struct iwl_trans * trans,u16 txq_id)25e705c121SKalle Valo static inline void iwl_scd_txq_disable_agg(struct iwl_trans *trans,
26e705c121SKalle Valo 					   u16 txq_id)
27e705c121SKalle Valo {
28e705c121SKalle Valo 	iwl_clear_bits_prph(trans, SCD_AGGR_SEL, BIT(txq_id));
29e705c121SKalle Valo }
30e705c121SKalle Valo 
iwl_scd_disable_agg(struct iwl_trans * trans)31e705c121SKalle Valo static inline void iwl_scd_disable_agg(struct iwl_trans *trans)
32e705c121SKalle Valo {
33e705c121SKalle Valo 	iwl_set_bits_prph(trans, SCD_AGGR_SEL, 0);
34e705c121SKalle Valo }
35e705c121SKalle Valo 
iwl_scd_activate_fifos(struct iwl_trans * trans)36e705c121SKalle Valo static inline void iwl_scd_activate_fifos(struct iwl_trans *trans)
37e705c121SKalle Valo {
38e705c121SKalle Valo 	iwl_write_prph(trans, SCD_TXFACT, IWL_MASK(0, 7));
39e705c121SKalle Valo }
40e705c121SKalle Valo 
iwl_scd_deactivate_fifos(struct iwl_trans * trans)41e705c121SKalle Valo static inline void iwl_scd_deactivate_fifos(struct iwl_trans *trans)
42e705c121SKalle Valo {
43e705c121SKalle Valo 	iwl_write_prph(trans, SCD_TXFACT, 0);
44e705c121SKalle Valo }
45e705c121SKalle Valo 
iwl_scd_enable_set_active(struct iwl_trans * trans,u32 value)46e705c121SKalle Valo static inline void iwl_scd_enable_set_active(struct iwl_trans *trans,
47e705c121SKalle Valo 					     u32 value)
48e705c121SKalle Valo {
49e705c121SKalle Valo 	iwl_write_prph(trans, SCD_EN_CTRL, value);
50e705c121SKalle Valo }
51e705c121SKalle Valo 
SCD_QUEUE_WRPTR(unsigned int chnl)52e705c121SKalle Valo static inline unsigned int SCD_QUEUE_WRPTR(unsigned int chnl)
53e705c121SKalle Valo {
54e705c121SKalle Valo 	if (chnl < 20)
55e705c121SKalle Valo 		return SCD_BASE + 0x18 + chnl * 4;
56e705c121SKalle Valo 	WARN_ON_ONCE(chnl >= 32);
57e705c121SKalle Valo 	return SCD_BASE + 0x284 + (chnl - 20) * 4;
58e705c121SKalle Valo }
59e705c121SKalle Valo 
SCD_QUEUE_RDPTR(unsigned int chnl)60e705c121SKalle Valo static inline unsigned int SCD_QUEUE_RDPTR(unsigned int chnl)
61e705c121SKalle Valo {
62e705c121SKalle Valo 	if (chnl < 20)
63e705c121SKalle Valo 		return SCD_BASE + 0x68 + chnl * 4;
64e705c121SKalle Valo 	WARN_ON_ONCE(chnl >= 32);
65e705c121SKalle Valo 	return SCD_BASE + 0x2B4 + chnl * 4;
66e705c121SKalle Valo }
67e705c121SKalle Valo 
SCD_QUEUE_STATUS_BITS(unsigned int chnl)68e705c121SKalle Valo static inline unsigned int SCD_QUEUE_STATUS_BITS(unsigned int chnl)
69e705c121SKalle Valo {
70e705c121SKalle Valo 	if (chnl < 20)
71e705c121SKalle Valo 		return SCD_BASE + 0x10c + chnl * 4;
72e705c121SKalle Valo 	WARN_ON_ONCE(chnl >= 32);
73e705c121SKalle Valo 	return SCD_BASE + 0x334 + chnl * 4;
74e705c121SKalle Valo }
75e705c121SKalle Valo 
iwl_scd_txq_set_inactive(struct iwl_trans * trans,u16 txq_id)76e705c121SKalle Valo static inline void iwl_scd_txq_set_inactive(struct iwl_trans *trans,
77e705c121SKalle Valo 					    u16 txq_id)
78e705c121SKalle Valo {
79e705c121SKalle Valo 	iwl_write_prph(trans, SCD_QUEUE_STATUS_BITS(txq_id),
80e705c121SKalle Valo 		       (0 << SCD_QUEUE_STTS_REG_POS_ACTIVE)|
81e705c121SKalle Valo 		       (1 << SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN));
82e705c121SKalle Valo }
83e705c121SKalle Valo 
84e705c121SKalle Valo #endif
85