18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright (c) 2018, Intel Corporation. */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef _ICE_OSDEP_H_ 58c2ecf20Sopenharmony_ci#define _ICE_OSDEP_H_ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/types.h> 88c2ecf20Sopenharmony_ci#include <linux/io.h> 98c2ecf20Sopenharmony_ci#ifndef CONFIG_64BIT 108c2ecf20Sopenharmony_ci#include <linux/io-64-nonatomic-lo-hi.h> 118c2ecf20Sopenharmony_ci#endif 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define wr32(a, reg, value) writel((value), ((a)->hw_addr + (reg))) 148c2ecf20Sopenharmony_ci#define rd32(a, reg) readl((a)->hw_addr + (reg)) 158c2ecf20Sopenharmony_ci#define wr64(a, reg, value) writeq((value), ((a)->hw_addr + (reg))) 168c2ecf20Sopenharmony_ci#define rd64(a, reg) readq((a)->hw_addr + (reg)) 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define ice_flush(a) rd32((a), GLGEN_STAT) 198c2ecf20Sopenharmony_ci#define ICE_M(m, s) ((m) << (s)) 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistruct ice_dma_mem { 228c2ecf20Sopenharmony_ci void *va; 238c2ecf20Sopenharmony_ci dma_addr_t pa; 248c2ecf20Sopenharmony_ci size_t size; 258c2ecf20Sopenharmony_ci}; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#define ice_hw_to_dev(ptr) \ 288c2ecf20Sopenharmony_ci (&(container_of((ptr), struct ice_pf, hw))->pdev->dev) 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#ifdef CONFIG_DYNAMIC_DEBUG 318c2ecf20Sopenharmony_ci#define ice_debug(hw, type, fmt, args...) \ 328c2ecf20Sopenharmony_ci dev_dbg(ice_hw_to_dev(hw), fmt, ##args) 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \ 358c2ecf20Sopenharmony_ci print_hex_dump_debug(KBUILD_MODNAME " ", \ 368c2ecf20Sopenharmony_ci DUMP_PREFIX_OFFSET, rowsize, \ 378c2ecf20Sopenharmony_ci groupsize, buf, len, false) 388c2ecf20Sopenharmony_ci#else 398c2ecf20Sopenharmony_ci#define ice_debug(hw, type, fmt, args...) \ 408c2ecf20Sopenharmony_cido { \ 418c2ecf20Sopenharmony_ci if ((type) & (hw)->debug_mask) \ 428c2ecf20Sopenharmony_ci dev_info(ice_hw_to_dev(hw), fmt, ##args); \ 438c2ecf20Sopenharmony_ci} while (0) 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#ifdef DEBUG 468c2ecf20Sopenharmony_ci#define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \ 478c2ecf20Sopenharmony_cido { \ 488c2ecf20Sopenharmony_ci if ((type) & (hw)->debug_mask) \ 498c2ecf20Sopenharmony_ci print_hex_dump_debug(KBUILD_MODNAME, \ 508c2ecf20Sopenharmony_ci DUMP_PREFIX_OFFSET, \ 518c2ecf20Sopenharmony_ci rowsize, groupsize, buf, \ 528c2ecf20Sopenharmony_ci len, false); \ 538c2ecf20Sopenharmony_ci} while (0) 548c2ecf20Sopenharmony_ci#else 558c2ecf20Sopenharmony_ci#define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \ 568c2ecf20Sopenharmony_cido { \ 578c2ecf20Sopenharmony_ci struct ice_hw *hw_l = hw; \ 588c2ecf20Sopenharmony_ci if ((type) & (hw_l)->debug_mask) { \ 598c2ecf20Sopenharmony_ci u16 len_l = len; \ 608c2ecf20Sopenharmony_ci u8 *buf_l = buf; \ 618c2ecf20Sopenharmony_ci int i; \ 628c2ecf20Sopenharmony_ci for (i = 0; i < (len_l - 16); i += 16) \ 638c2ecf20Sopenharmony_ci ice_debug(hw_l, type, "0x%04X %16ph\n",\ 648c2ecf20Sopenharmony_ci i, ((buf_l) + i)); \ 658c2ecf20Sopenharmony_ci if (i < len_l) \ 668c2ecf20Sopenharmony_ci ice_debug(hw_l, type, "0x%04X %*ph\n", \ 678c2ecf20Sopenharmony_ci i, ((len_l) - i), ((buf_l) + i));\ 688c2ecf20Sopenharmony_ci } \ 698c2ecf20Sopenharmony_ci} while (0) 708c2ecf20Sopenharmony_ci#endif /* DEBUG */ 718c2ecf20Sopenharmony_ci#endif /* CONFIG_DYNAMIC_DEBUG */ 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci#endif /* _ICE_OSDEP_H_ */ 74