1e705c121SKalle Valo /****************************************************************************** 2e705c121SKalle Valo * 3cefec29eSJohannes Berg * This file is provided under a dual BSD/GPLv2 license. When using or 4cefec29eSJohannes Berg * redistributing this file, you may do so under either license. 5e705c121SKalle Valo * 6cefec29eSJohannes Berg * GPL LICENSE SUMMARY 7e705c121SKalle Valo * 8c96b5eecSJohannes Berg * Copyright (C) 2018 Intel Corporation 9c96b5eecSJohannes Berg * 10e705c121SKalle Valo * This program is free software; you can redistribute it and/or modify it 11e705c121SKalle Valo * under the terms of version 2 of the GNU General Public License as 12e705c121SKalle Valo * published by the Free Software Foundation. 13e705c121SKalle Valo * 14e705c121SKalle Valo * This program is distributed in the hope that it will be useful, but WITHOUT 15e705c121SKalle Valo * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16e705c121SKalle Valo * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 17e705c121SKalle Valo * more details. 18e705c121SKalle Valo * 19e705c121SKalle Valo * The full GNU General Public License is included in this distribution in the 20cefec29eSJohannes Berg * file called COPYING. 21e705c121SKalle Valo * 22e705c121SKalle Valo * Contact Information: 23d01c5366SEmmanuel Grumbach * Intel Linux Wireless <linuxwifi@intel.com> 24e705c121SKalle Valo * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25e705c121SKalle Valo * 26cefec29eSJohannes Berg * BSD LICENSE 27cefec29eSJohannes Berg * 28c96b5eecSJohannes Berg * Copyright (C) 2018 Intel Corporation 29cefec29eSJohannes Berg * All rights reserved. 30cefec29eSJohannes Berg * 31cefec29eSJohannes Berg * Redistribution and use in source and binary forms, with or without 32cefec29eSJohannes Berg * modification, are permitted provided that the following conditions 33cefec29eSJohannes Berg * are met: 34cefec29eSJohannes Berg * 35cefec29eSJohannes Berg * * Redistributions of source code must retain the above copyright 36cefec29eSJohannes Berg * notice, this list of conditions and the following disclaimer. 37cefec29eSJohannes Berg * * Redistributions in binary form must reproduce the above copyright 38cefec29eSJohannes Berg * notice, this list of conditions and the following disclaimer in 39cefec29eSJohannes Berg * the documentation and/or other materials provided with the 40cefec29eSJohannes Berg * distribution. 41cefec29eSJohannes Berg * * Neither the name Intel Corporation nor the names of its 42cefec29eSJohannes Berg * contributors may be used to endorse or promote products derived 43cefec29eSJohannes Berg * from this software without specific prior written permission. 44cefec29eSJohannes Berg * 45cefec29eSJohannes Berg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 46cefec29eSJohannes Berg * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 47cefec29eSJohannes Berg * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 48cefec29eSJohannes Berg * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 49cefec29eSJohannes Berg * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 50cefec29eSJohannes Berg * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 51cefec29eSJohannes Berg * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 52cefec29eSJohannes Berg * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 53cefec29eSJohannes Berg * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 54cefec29eSJohannes Berg * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 55cefec29eSJohannes Berg * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56cefec29eSJohannes Berg * 57e705c121SKalle Valo *****************************************************************************/ 58e705c121SKalle Valo #ifndef __iwl_io_h__ 59e705c121SKalle Valo #define __iwl_io_h__ 60e705c121SKalle Valo 61e705c121SKalle Valo #include "iwl-devtrace.h" 62e705c121SKalle Valo #include "iwl-trans.h" 63e705c121SKalle Valo 64e705c121SKalle Valo void iwl_write8(struct iwl_trans *trans, u32 ofs, u8 val); 65e705c121SKalle Valo void iwl_write32(struct iwl_trans *trans, u32 ofs, u32 val); 6612a17458SSara Sharon void iwl_write64(struct iwl_trans *trans, u64 ofs, u64 val); 67e705c121SKalle Valo u32 iwl_read32(struct iwl_trans *trans, u32 ofs); 68e705c121SKalle Valo 69e705c121SKalle Valo static inline void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask) 70e705c121SKalle Valo { 71e705c121SKalle Valo iwl_trans_set_bits_mask(trans, reg, mask, mask); 72e705c121SKalle Valo } 73e705c121SKalle Valo 74e705c121SKalle Valo static inline void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask) 75e705c121SKalle Valo { 76e705c121SKalle Valo iwl_trans_set_bits_mask(trans, reg, mask, 0); 77e705c121SKalle Valo } 78e705c121SKalle Valo 79e705c121SKalle Valo int iwl_poll_bit(struct iwl_trans *trans, u32 addr, 80e705c121SKalle Valo u32 bits, u32 mask, int timeout); 81e705c121SKalle Valo int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask, 82e705c121SKalle Valo int timeout); 83e705c121SKalle Valo 84e705c121SKalle Valo u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg); 85e705c121SKalle Valo void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value); 8612a17458SSara Sharon void iwl_write_direct64(struct iwl_trans *trans, u64 reg, u64 value); 87e705c121SKalle Valo 88e705c121SKalle Valo 8914ef1b43SGolan Ben-Ami u32 iwl_read_prph_no_grab(struct iwl_trans *trans, u32 ofs); 90e705c121SKalle Valo u32 iwl_read_prph(struct iwl_trans *trans, u32 ofs); 9114ef1b43SGolan Ben-Ami void iwl_write_prph_no_grab(struct iwl_trans *trans, u32 ofs, u32 val); 9212a17458SSara Sharon void iwl_write_prph64_no_grab(struct iwl_trans *trans, u64 ofs, u64 val); 93e705c121SKalle Valo void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val); 94e705c121SKalle Valo int iwl_poll_prph_bit(struct iwl_trans *trans, u32 addr, 95e705c121SKalle Valo u32 bits, u32 mask, int timeout); 96e705c121SKalle Valo void iwl_set_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask); 97e705c121SKalle Valo void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 ofs, 98e705c121SKalle Valo u32 bits, u32 mask); 99e705c121SKalle Valo void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask); 100e705c121SKalle Valo void iwl_force_nmi(struct iwl_trans *trans); 101e705c121SKalle Valo 102c96b5eecSJohannes Berg int iwl_finish_nic_init(struct iwl_trans *trans); 103c96b5eecSJohannes Berg 104e705c121SKalle Valo /* Error handling */ 105e705c121SKalle Valo int iwl_dump_fh(struct iwl_trans *trans, char **buf); 106e705c121SKalle Valo 107e705c121SKalle Valo #endif 108