162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2018-2021 Intel Corporation
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci#ifndef __iwl_io_h__
662306a36Sopenharmony_ci#define __iwl_io_h__
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include "iwl-devtrace.h"
962306a36Sopenharmony_ci#include "iwl-trans.h"
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_civoid iwl_write8(struct iwl_trans *trans, u32 ofs, u8 val);
1262306a36Sopenharmony_civoid iwl_write32(struct iwl_trans *trans, u32 ofs, u32 val);
1362306a36Sopenharmony_civoid iwl_write64(struct iwl_trans *trans, u64 ofs, u64 val);
1462306a36Sopenharmony_ciu32 iwl_read32(struct iwl_trans *trans, u32 ofs);
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_cistatic inline void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask)
1762306a36Sopenharmony_ci{
1862306a36Sopenharmony_ci	iwl_trans_set_bits_mask(trans, reg, mask, mask);
1962306a36Sopenharmony_ci}
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_cistatic inline void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask)
2262306a36Sopenharmony_ci{
2362306a36Sopenharmony_ci	iwl_trans_set_bits_mask(trans, reg, mask, 0);
2462306a36Sopenharmony_ci}
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciint iwl_poll_bit(struct iwl_trans *trans, u32 addr,
2762306a36Sopenharmony_ci		 u32 bits, u32 mask, int timeout);
2862306a36Sopenharmony_ciint iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask,
2962306a36Sopenharmony_ci			int timeout);
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciu32 iwl_read_direct32(struct iwl_trans *trans, u32 reg);
3262306a36Sopenharmony_civoid iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value);
3362306a36Sopenharmony_civoid iwl_write_direct64(struct iwl_trans *trans, u64 reg, u64 value);
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ciu32 iwl_read_prph_no_grab(struct iwl_trans *trans, u32 ofs);
3762306a36Sopenharmony_ciu32 iwl_read_prph(struct iwl_trans *trans, u32 ofs);
3862306a36Sopenharmony_civoid iwl_write_prph_no_grab(struct iwl_trans *trans, u32 ofs, u32 val);
3962306a36Sopenharmony_civoid iwl_write_prph64_no_grab(struct iwl_trans *trans, u64 ofs, u64 val);
4062306a36Sopenharmony_civoid iwl_write_prph_delay(struct iwl_trans *trans, u32 ofs,
4162306a36Sopenharmony_ci			  u32 val, u32 delay_ms);
4262306a36Sopenharmony_cistatic inline void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val)
4362306a36Sopenharmony_ci{
4462306a36Sopenharmony_ci	iwl_write_prph_delay(trans, ofs, val, 0);
4562306a36Sopenharmony_ci}
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ciint iwl_poll_prph_bit(struct iwl_trans *trans, u32 addr,
4862306a36Sopenharmony_ci		      u32 bits, u32 mask, int timeout);
4962306a36Sopenharmony_civoid iwl_set_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask);
5062306a36Sopenharmony_civoid iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 ofs,
5162306a36Sopenharmony_ci			    u32 bits, u32 mask);
5262306a36Sopenharmony_civoid iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask);
5362306a36Sopenharmony_civoid iwl_force_nmi(struct iwl_trans *trans);
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciint iwl_finish_nic_init(struct iwl_trans *trans);
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci/* Error handling */
5862306a36Sopenharmony_ciint iwl_dump_fh(struct iwl_trans *trans, char **buf);
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci/*
6162306a36Sopenharmony_ci * UMAC periphery address space changed from 0xA00000 to 0xD00000 starting from
6262306a36Sopenharmony_ci * device family AX200. So peripheries used in families above and below AX200
6362306a36Sopenharmony_ci * should go through iwl_..._umac_..._prph.
6462306a36Sopenharmony_ci */
6562306a36Sopenharmony_cistatic inline u32 iwl_umac_prph(struct iwl_trans *trans, u32 ofs)
6662306a36Sopenharmony_ci{
6762306a36Sopenharmony_ci	return ofs + trans->trans_cfg->umac_prph_offset;
6862306a36Sopenharmony_ci}
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_cistatic inline u32 iwl_read_umac_prph_no_grab(struct iwl_trans *trans, u32 ofs)
7162306a36Sopenharmony_ci{
7262306a36Sopenharmony_ci	return iwl_read_prph_no_grab(trans, ofs +
7362306a36Sopenharmony_ci				     trans->trans_cfg->umac_prph_offset);
7462306a36Sopenharmony_ci}
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_cistatic inline u32 iwl_read_umac_prph(struct iwl_trans *trans, u32 ofs)
7762306a36Sopenharmony_ci{
7862306a36Sopenharmony_ci	return iwl_read_prph(trans, ofs + trans->trans_cfg->umac_prph_offset);
7962306a36Sopenharmony_ci}
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_cistatic inline void iwl_write_umac_prph_no_grab(struct iwl_trans *trans, u32 ofs,
8262306a36Sopenharmony_ci					       u32 val)
8362306a36Sopenharmony_ci{
8462306a36Sopenharmony_ci	iwl_write_prph_no_grab(trans,  ofs + trans->trans_cfg->umac_prph_offset,
8562306a36Sopenharmony_ci			       val);
8662306a36Sopenharmony_ci}
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_cistatic inline void iwl_write_umac_prph(struct iwl_trans *trans, u32 ofs,
8962306a36Sopenharmony_ci				       u32 val)
9062306a36Sopenharmony_ci{
9162306a36Sopenharmony_ci	iwl_write_prph(trans,  ofs + trans->trans_cfg->umac_prph_offset, val);
9262306a36Sopenharmony_ci}
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_cistatic inline int iwl_poll_umac_prph_bit(struct iwl_trans *trans, u32 addr,
9562306a36Sopenharmony_ci					 u32 bits, u32 mask, int timeout)
9662306a36Sopenharmony_ci{
9762306a36Sopenharmony_ci	return iwl_poll_prph_bit(trans, addr +
9862306a36Sopenharmony_ci				 trans->trans_cfg->umac_prph_offset,
9962306a36Sopenharmony_ci				 bits, mask, timeout);
10062306a36Sopenharmony_ci}
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci#endif
103