Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Johannes Berg | cefec29 | 2018-10-24 09:04:36 +0200 | [diff] [blame] | 3 | * 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 Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 5 | * |
Johannes Berg | cefec29 | 2018-10-24 09:04:36 +0200 | [diff] [blame] | 6 | * GPL LICENSE SUMMARY |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 7 | * |
Shaul Triebitz | ea695b7 | 2019-01-01 14:03:23 +0200 | [diff] [blame] | 8 | * Copyright (C) 2018 - 2019 Intel Corporation |
Johannes Berg | c96b5ee | 2018-12-10 09:27:47 +0100 | [diff] [blame] | 9 | * |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 10 | * 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 Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 19 | * The full GNU General Public License is included in this distribution in the |
Johannes Berg | cefec29 | 2018-10-24 09:04:36 +0200 | [diff] [blame] | 20 | * file called COPYING. |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 21 | * |
| 22 | * Contact Information: |
Emmanuel Grumbach | d01c536 | 2015-11-17 15:39:56 +0200 | [diff] [blame] | 23 | * Intel Linux Wireless <linuxwifi@intel.com> |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 24 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 25 | * |
Johannes Berg | cefec29 | 2018-10-24 09:04:36 +0200 | [diff] [blame] | 26 | * BSD LICENSE |
| 27 | * |
Shaul Triebitz | ea695b7 | 2019-01-01 14:03:23 +0200 | [diff] [blame] | 28 | * Copyright (C) 2018 - 2019 Intel Corporation |
Johannes Berg | cefec29 | 2018-10-24 09:04:36 +0200 | [diff] [blame] | 29 | * 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 Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 57 | *****************************************************************************/ |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 58 | #ifndef __iwl_io_h__ |
| 59 | #define __iwl_io_h__ |
| 60 | |
Johannes Berg | be1a71a | 2009-10-02 13:44:02 -0700 | [diff] [blame] | 61 | #include "iwl-devtrace.h" |
Emmanuel Grumbach | 0390549 | 2012-01-03 13:48:07 +0200 | [diff] [blame] | 62 | #include "iwl-trans.h" |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 63 | |
Emmanuel Grumbach | a73a2ce | 2015-08-23 13:29:36 +0300 | [diff] [blame] | 64 | void iwl_write8(struct iwl_trans *trans, u32 ofs, u8 val); |
| 65 | void iwl_write32(struct iwl_trans *trans, u32 ofs, u32 val); |
Sara Sharon | 12a1745 | 2016-06-23 12:04:55 +0300 | [diff] [blame] | 66 | void iwl_write64(struct iwl_trans *trans, u64 ofs, u64 val); |
Emmanuel Grumbach | a73a2ce | 2015-08-23 13:29:36 +0300 | [diff] [blame] | 67 | u32 iwl_read32(struct iwl_trans *trans, u32 ofs); |
Johannes Berg | be1a71a | 2009-10-02 13:44:02 -0700 | [diff] [blame] | 68 | |
Lilach Edelstein | e139dc4 | 2013-01-13 13:31:10 +0200 | [diff] [blame] | 69 | static 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 Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 73 | |
Lilach Edelstein | e139dc4 | 2013-01-13 13:31:10 +0200 | [diff] [blame] | 74 | static 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 Berg | 2baa2e57 | 2012-05-29 14:47:30 +0200 | [diff] [blame] | 78 | |
Emmanuel Grumbach | 1042db2 | 2012-01-03 16:56:15 +0200 | [diff] [blame] | 79 | int iwl_poll_bit(struct iwl_trans *trans, u32 addr, |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 80 | u32 bits, u32 mask, int timeout); |
Emmanuel Grumbach | 1042db2 | 2012-01-03 16:56:15 +0200 | [diff] [blame] | 81 | int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask, |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 82 | int timeout); |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 83 | |
Emmanuel Grumbach | 1042db2 | 2012-01-03 16:56:15 +0200 | [diff] [blame] | 84 | u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg); |
| 85 | void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value); |
Sara Sharon | 12a1745 | 2016-06-23 12:04:55 +0300 | [diff] [blame] | 86 | void iwl_write_direct64(struct iwl_trans *trans, u64 reg, u64 value); |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 87 | |
Mohamed Abbas | a8b50a0 | 2009-05-22 11:01:47 -0700 | [diff] [blame] | 88 | |
Golan Ben-Ami | 14ef1b4 | 2015-10-21 15:16:58 +0300 | [diff] [blame] | 89 | u32 iwl_read_prph_no_grab(struct iwl_trans *trans, u32 ofs); |
Emmanuel Grumbach | 6a06b6c | 2012-12-02 13:07:30 +0200 | [diff] [blame] | 90 | u32 iwl_read_prph(struct iwl_trans *trans, u32 ofs); |
Golan Ben-Ami | 14ef1b4 | 2015-10-21 15:16:58 +0300 | [diff] [blame] | 91 | void iwl_write_prph_no_grab(struct iwl_trans *trans, u32 ofs, u32 val); |
Sara Sharon | 12a1745 | 2016-06-23 12:04:55 +0300 | [diff] [blame] | 92 | void iwl_write_prph64_no_grab(struct iwl_trans *trans, u64 ofs, u64 val); |
Emmanuel Grumbach | 6a06b6c | 2012-12-02 13:07:30 +0200 | [diff] [blame] | 93 | void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val); |
Eran Harary | 189fa2f | 2014-01-23 16:26:32 +0200 | [diff] [blame] | 94 | int iwl_poll_prph_bit(struct iwl_trans *trans, u32 addr, |
| 95 | u32 bits, u32 mask, int timeout); |
Emmanuel Grumbach | 6a06b6c | 2012-12-02 13:07:30 +0200 | [diff] [blame] | 96 | void iwl_set_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask); |
| 97 | void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 ofs, |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 98 | u32 bits, u32 mask); |
Emmanuel Grumbach | 6a06b6c | 2012-12-02 13:07:30 +0200 | [diff] [blame] | 99 | void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask); |
Liad Kaufman | 4c9706d | 2014-04-27 16:46:09 +0300 | [diff] [blame] | 100 | void iwl_force_nmi(struct iwl_trans *trans); |
Mohamed Abbas | a8b50a0 | 2009-05-22 11:01:47 -0700 | [diff] [blame] | 101 | |
Luca Coelho | 79b6c8f | 2018-08-02 14:57:55 +0300 | [diff] [blame] | 102 | int iwl_finish_nic_init(struct iwl_trans *trans, |
| 103 | const struct iwl_cfg_trans_params *cfg_trans); |
Johannes Berg | c96b5ee | 2018-12-10 09:27:47 +0100 | [diff] [blame] | 104 | |
Inbal Hacohen | 313b0a2 | 2013-06-24 10:35:53 +0300 | [diff] [blame] | 105 | /* Error handling */ |
| 106 | int iwl_dump_fh(struct iwl_trans *trans, char **buf); |
| 107 | |
Shaul Triebitz | ea695b7 | 2019-01-01 14:03:23 +0200 | [diff] [blame] | 108 | /* |
| 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 | */ |
| 113 | static inline u32 iwl_umac_prph(struct iwl_trans *trans, u32 ofs) |
| 114 | { |
Luca Coelho | 1fee35d | 2019-08-08 13:52:50 +0300 | [diff] [blame] | 115 | return ofs + trans->trans_cfg->umac_prph_offset; |
Shaul Triebitz | ea695b7 | 2019-01-01 14:03:23 +0200 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | static inline u32 iwl_read_umac_prph_no_grab(struct iwl_trans *trans, u32 ofs) |
| 119 | { |
Luca Coelho | 79b6c8f | 2018-08-02 14:57:55 +0300 | [diff] [blame] | 120 | return iwl_read_prph_no_grab(trans, ofs + |
Luca Coelho | 1fee35d | 2019-08-08 13:52:50 +0300 | [diff] [blame] | 121 | trans->trans_cfg->umac_prph_offset); |
Shaul Triebitz | ea695b7 | 2019-01-01 14:03:23 +0200 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | static inline u32 iwl_read_umac_prph(struct iwl_trans *trans, u32 ofs) |
| 125 | { |
Luca Coelho | 1fee35d | 2019-08-08 13:52:50 +0300 | [diff] [blame] | 126 | return iwl_read_prph(trans, ofs + trans->trans_cfg->umac_prph_offset); |
Shaul Triebitz | ea695b7 | 2019-01-01 14:03:23 +0200 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | static inline void iwl_write_umac_prph_no_grab(struct iwl_trans *trans, u32 ofs, |
| 130 | u32 val) |
| 131 | { |
Luca Coelho | 1fee35d | 2019-08-08 13:52:50 +0300 | [diff] [blame] | 132 | iwl_write_prph_no_grab(trans, ofs + trans->trans_cfg->umac_prph_offset, |
Luca Coelho | 79b6c8f | 2018-08-02 14:57:55 +0300 | [diff] [blame] | 133 | val); |
Shaul Triebitz | ea695b7 | 2019-01-01 14:03:23 +0200 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | static inline void iwl_write_umac_prph(struct iwl_trans *trans, u32 ofs, |
| 137 | u32 val) |
| 138 | { |
Luca Coelho | 1fee35d | 2019-08-08 13:52:50 +0300 | [diff] [blame] | 139 | iwl_write_prph(trans, ofs + trans->trans_cfg->umac_prph_offset, val); |
Shaul Triebitz | ea695b7 | 2019-01-01 14:03:23 +0200 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | static inline int iwl_poll_umac_prph_bit(struct iwl_trans *trans, u32 addr, |
| 143 | u32 bits, u32 mask, int timeout) |
| 144 | { |
Luca Coelho | 79b6c8f | 2018-08-02 14:57:55 +0300 | [diff] [blame] | 145 | return iwl_poll_prph_bit(trans, addr + |
Luca Coelho | 1fee35d | 2019-08-08 13:52:50 +0300 | [diff] [blame] | 146 | trans->trans_cfg->umac_prph_offset, |
Shaul Triebitz | ea695b7 | 2019-01-01 14:03:23 +0200 | [diff] [blame] | 147 | bits, mask, timeout); |
| 148 | } |
| 149 | |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 150 | #endif |