blob: f09e368c7040c5868f0c2a076df262c4be3b0ded [file] [log] [blame]
Tomas Winkler3395f6e2008-03-25 16:33:37 -07001/******************************************************************************
2 *
Johannes Bergcefec292018-10-24 09:04:36 +02003 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
Tomas Winkler3395f6e2008-03-25 16:33:37 -07005 *
Johannes Bergcefec292018-10-24 09:04:36 +02006 * GPL LICENSE SUMMARY
Tomas Winkler3395f6e2008-03-25 16:33:37 -07007 *
Shaul Triebitzea695b72019-01-01 14:03:23 +02008 * Copyright (C) 2018 - 2019 Intel Corporation
Johannes Bergc96b5ee2018-12-10 09:27:47 +01009 *
Tomas Winkler3395f6e2008-03-25 16:33:37 -070010 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
Tomas Winkler3395f6e2008-03-25 16:33:37 -070019 * The full GNU General Public License is included in this distribution in the
Johannes Bergcefec292018-10-24 09:04:36 +020020 * file called COPYING.
Tomas Winkler3395f6e2008-03-25 16:33:37 -070021 *
22 * Contact Information:
Emmanuel Grumbachd01c5362015-11-17 15:39:56 +020023 * Intel Linux Wireless <linuxwifi@intel.com>
Tomas Winkler3395f6e2008-03-25 16:33:37 -070024 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 *
Johannes Bergcefec292018-10-24 09:04:36 +020026 * BSD LICENSE
27 *
Shaul Triebitzea695b72019-01-01 14:03:23 +020028 * Copyright (C) 2018 - 2019 Intel Corporation
Johannes Bergcefec292018-10-24 09:04:36 +020029 * All rights reserved.
30 *
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
33 * are met:
34 *
35 * * Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * * Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in
39 * the documentation and/or other materials provided with the
40 * distribution.
41 * * Neither the name Intel Corporation nor the names of its
42 * contributors may be used to endorse or promote products derived
43 * from this software without specific prior written permission.
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
46 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
47 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
48 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
49 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
52 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
53 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 *
Tomas Winkler3395f6e2008-03-25 16:33:37 -070057 *****************************************************************************/
Tomas Winkler3395f6e2008-03-25 16:33:37 -070058#ifndef __iwl_io_h__
59#define __iwl_io_h__
60
Johannes Bergbe1a71a2009-10-02 13:44:02 -070061#include "iwl-devtrace.h"
Emmanuel Grumbach03905492012-01-03 13:48:07 +020062#include "iwl-trans.h"
Tomas Winkler3395f6e2008-03-25 16:33:37 -070063
Emmanuel Grumbacha73a2ce2015-08-23 13:29:36 +030064void iwl_write8(struct iwl_trans *trans, u32 ofs, u8 val);
65void iwl_write32(struct iwl_trans *trans, u32 ofs, u32 val);
Sara Sharon12a17452016-06-23 12:04:55 +030066void iwl_write64(struct iwl_trans *trans, u64 ofs, u64 val);
Emmanuel Grumbacha73a2ce2015-08-23 13:29:36 +030067u32 iwl_read32(struct iwl_trans *trans, u32 ofs);
Johannes Bergbe1a71a2009-10-02 13:44:02 -070068
Lilach Edelsteine139dc42013-01-13 13:31:10 +020069static inline void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask)
70{
71 iwl_trans_set_bits_mask(trans, reg, mask, mask);
72}
Tomas Winkler3395f6e2008-03-25 16:33:37 -070073
Lilach Edelsteine139dc42013-01-13 13:31:10 +020074static inline void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask)
75{
76 iwl_trans_set_bits_mask(trans, reg, mask, 0);
77}
Johannes Berg2baa2e572012-05-29 14:47:30 +020078
Emmanuel Grumbach1042db22012-01-03 16:56:15 +020079int iwl_poll_bit(struct iwl_trans *trans, u32 addr,
Johannes Berg02a7fa02011-04-05 09:42:12 -070080 u32 bits, u32 mask, int timeout);
Emmanuel Grumbach1042db22012-01-03 16:56:15 +020081int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask,
Johannes Berg02a7fa02011-04-05 09:42:12 -070082 int timeout);
Tomas Winkler3395f6e2008-03-25 16:33:37 -070083
Emmanuel Grumbach1042db22012-01-03 16:56:15 +020084u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg);
85void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value);
Sara Sharon12a17452016-06-23 12:04:55 +030086void iwl_write_direct64(struct iwl_trans *trans, u64 reg, u64 value);
Tomas Winkler3395f6e2008-03-25 16:33:37 -070087
Mohamed Abbasa8b50a02009-05-22 11:01:47 -070088
Golan Ben-Ami14ef1b42015-10-21 15:16:58 +030089u32 iwl_read_prph_no_grab(struct iwl_trans *trans, u32 ofs);
Emmanuel Grumbach6a06b6c2012-12-02 13:07:30 +020090u32 iwl_read_prph(struct iwl_trans *trans, u32 ofs);
Golan Ben-Ami14ef1b42015-10-21 15:16:58 +030091void iwl_write_prph_no_grab(struct iwl_trans *trans, u32 ofs, u32 val);
Sara Sharon12a17452016-06-23 12:04:55 +030092void iwl_write_prph64_no_grab(struct iwl_trans *trans, u64 ofs, u64 val);
Emmanuel Grumbach6a06b6c2012-12-02 13:07:30 +020093void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val);
Eran Harary189fa2f2014-01-23 16:26:32 +020094int iwl_poll_prph_bit(struct iwl_trans *trans, u32 addr,
95 u32 bits, u32 mask, int timeout);
Emmanuel Grumbach6a06b6c2012-12-02 13:07:30 +020096void iwl_set_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask);
97void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 ofs,
Johannes Berg02a7fa02011-04-05 09:42:12 -070098 u32 bits, u32 mask);
Emmanuel Grumbach6a06b6c2012-12-02 13:07:30 +020099void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask);
Liad Kaufman4c9706d2014-04-27 16:46:09 +0300100void iwl_force_nmi(struct iwl_trans *trans);
Mohamed Abbasa8b50a02009-05-22 11:01:47 -0700101
Luca Coelho79b6c8f2018-08-02 14:57:55 +0300102int iwl_finish_nic_init(struct iwl_trans *trans,
103 const struct iwl_cfg_trans_params *cfg_trans);
Johannes Bergc96b5ee2018-12-10 09:27:47 +0100104
Inbal Hacohen313b0a22013-06-24 10:35:53 +0300105/* Error handling */
106int iwl_dump_fh(struct iwl_trans *trans, char **buf);
107
Shaul Triebitzea695b72019-01-01 14:03:23 +0200108/*
109 * UMAC periphery address space changed from 0xA00000 to 0xD00000 starting from
110 * device family AX200. So peripheries used in families above and below AX200
111 * should go through iwl_..._umac_..._prph.
112 */
113static inline u32 iwl_umac_prph(struct iwl_trans *trans, u32 ofs)
114{
Luca Coelho1fee35d2019-08-08 13:52:50 +0300115 return ofs + trans->trans_cfg->umac_prph_offset;
Shaul Triebitzea695b72019-01-01 14:03:23 +0200116}
117
118static inline u32 iwl_read_umac_prph_no_grab(struct iwl_trans *trans, u32 ofs)
119{
Luca Coelho79b6c8f2018-08-02 14:57:55 +0300120 return iwl_read_prph_no_grab(trans, ofs +
Luca Coelho1fee35d2019-08-08 13:52:50 +0300121 trans->trans_cfg->umac_prph_offset);
Shaul Triebitzea695b72019-01-01 14:03:23 +0200122}
123
124static inline u32 iwl_read_umac_prph(struct iwl_trans *trans, u32 ofs)
125{
Luca Coelho1fee35d2019-08-08 13:52:50 +0300126 return iwl_read_prph(trans, ofs + trans->trans_cfg->umac_prph_offset);
Shaul Triebitzea695b72019-01-01 14:03:23 +0200127}
128
129static inline void iwl_write_umac_prph_no_grab(struct iwl_trans *trans, u32 ofs,
130 u32 val)
131{
Luca Coelho1fee35d2019-08-08 13:52:50 +0300132 iwl_write_prph_no_grab(trans, ofs + trans->trans_cfg->umac_prph_offset,
Luca Coelho79b6c8f2018-08-02 14:57:55 +0300133 val);
Shaul Triebitzea695b72019-01-01 14:03:23 +0200134}
135
136static inline void iwl_write_umac_prph(struct iwl_trans *trans, u32 ofs,
137 u32 val)
138{
Luca Coelho1fee35d2019-08-08 13:52:50 +0300139 iwl_write_prph(trans, ofs + trans->trans_cfg->umac_prph_offset, val);
Shaul Triebitzea695b72019-01-01 14:03:23 +0200140}
141
142static inline int iwl_poll_umac_prph_bit(struct iwl_trans *trans, u32 addr,
143 u32 bits, u32 mask, int timeout)
144{
Luca Coelho79b6c8f2018-08-02 14:57:55 +0300145 return iwl_poll_prph_bit(trans, addr +
Luca Coelho1fee35d2019-08-08 13:52:50 +0300146 trans->trans_cfg->umac_prph_offset,
Shaul Triebitzea695b72019-01-01 14:03:23 +0200147 bits, mask, timeout);
148}
149
Tomas Winkler3395f6e2008-03-25 16:33:37 -0700150#endif