xref: /linux/drivers/net/wireless/intel/iwlwifi/pcie/utils.h (revision 8be4d31cb8aaeea27bde4b7ddb26e28a89062ebf)
1e4efdfcaSRotem Kerem // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2e4efdfcaSRotem Kerem /*
3e4efdfcaSRotem Kerem  * Copyright (C) 2025 Intel Corporation
4e4efdfcaSRotem Kerem  */
5e4efdfcaSRotem Kerem 
6e4efdfcaSRotem Kerem #ifndef __iwl_pcie_utils_h__
7e4efdfcaSRotem Kerem #define __iwl_pcie_utils_h__
8e4efdfcaSRotem Kerem 
9*65d4df4eSMiri Korenblit #include "iwl-io.h"
10*65d4df4eSMiri Korenblit 
11e4efdfcaSRotem Kerem void iwl_trans_pcie_dump_regs(struct iwl_trans *trans, struct pci_dev *pdev);
12e4efdfcaSRotem Kerem 
_iwl_trans_set_bits_mask(struct iwl_trans * trans,u32 reg,u32 mask,u32 value)13dc6bc511SRotem Kerem static inline void _iwl_trans_set_bits_mask(struct iwl_trans *trans,
14dc6bc511SRotem Kerem 					    u32 reg, u32 mask, u32 value)
15dc6bc511SRotem Kerem {
16dc6bc511SRotem Kerem 	u32 v;
17dc6bc511SRotem Kerem 
18dc6bc511SRotem Kerem #ifdef CONFIG_IWLWIFI_DEBUG
19dc6bc511SRotem Kerem 	WARN_ON_ONCE(value & ~mask);
20dc6bc511SRotem Kerem #endif
21dc6bc511SRotem Kerem 
22dc6bc511SRotem Kerem 	v = iwl_read32(trans, reg);
23dc6bc511SRotem Kerem 	v &= ~mask;
24dc6bc511SRotem Kerem 	v |= value;
25dc6bc511SRotem Kerem 	iwl_write32(trans, reg, v);
26dc6bc511SRotem Kerem }
27dc6bc511SRotem Kerem 
iwl_trans_clear_bit(struct iwl_trans * trans,u32 reg,u32 mask)28dc6bc511SRotem Kerem static inline void iwl_trans_clear_bit(struct iwl_trans *trans,
29dc6bc511SRotem Kerem 				       u32 reg, u32 mask)
30dc6bc511SRotem Kerem {
31dc6bc511SRotem Kerem 	_iwl_trans_set_bits_mask(trans, reg, mask, 0);
32dc6bc511SRotem Kerem }
33dc6bc511SRotem Kerem 
iwl_trans_set_bit(struct iwl_trans * trans,u32 reg,u32 mask)34dc6bc511SRotem Kerem static inline void iwl_trans_set_bit(struct iwl_trans *trans,
35dc6bc511SRotem Kerem 				     u32 reg, u32 mask)
36dc6bc511SRotem Kerem {
37dc6bc511SRotem Kerem 	_iwl_trans_set_bits_mask(trans, reg, mask, mask);
38dc6bc511SRotem Kerem }
39dc6bc511SRotem Kerem 
40e4efdfcaSRotem Kerem #endif /* __iwl_pcie_utils_h__ */
41