18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci* Filename: rsxx_priv.h 48c2ecf20Sopenharmony_ci* 58c2ecf20Sopenharmony_ci* Authors: Joshua Morris <josh.h.morris@us.ibm.com> 68c2ecf20Sopenharmony_ci* Philip Kelleher <pjk1939@linux.vnet.ibm.com> 78c2ecf20Sopenharmony_ci* 88c2ecf20Sopenharmony_ci* (C) Copyright 2013 IBM Corporation 98c2ecf20Sopenharmony_ci*/ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef __RSXX_PRIV_H__ 128c2ecf20Sopenharmony_ci#define __RSXX_PRIV_H__ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/version.h> 158c2ecf20Sopenharmony_ci#include <linux/semaphore.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <linux/fs.h> 188c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 198c2ecf20Sopenharmony_ci#include <linux/mutex.h> 208c2ecf20Sopenharmony_ci#include <linux/pci.h> 218c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 228c2ecf20Sopenharmony_ci#include <linux/sysfs.h> 238c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 248c2ecf20Sopenharmony_ci#include <linux/bio.h> 258c2ecf20Sopenharmony_ci#include <linux/vmalloc.h> 268c2ecf20Sopenharmony_ci#include <linux/timer.h> 278c2ecf20Sopenharmony_ci#include <linux/ioctl.h> 288c2ecf20Sopenharmony_ci#include <linux/delay.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#include "rsxx.h" 318c2ecf20Sopenharmony_ci#include "rsxx_cfg.h" 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistruct proc_cmd; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_FS70_FLASH 0x04A9 368c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_FS80_FLASH 0x04AA 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define RS70_PCI_REV_SUPPORTED 4 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define DRIVER_NAME "rsxx" 418c2ecf20Sopenharmony_ci#define DRIVER_VERSION "4.0.3.2516" 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* Block size is 4096 */ 448c2ecf20Sopenharmony_ci#define RSXX_HW_BLK_SHIFT 12 458c2ecf20Sopenharmony_ci#define RSXX_HW_BLK_SIZE (1 << RSXX_HW_BLK_SHIFT) 468c2ecf20Sopenharmony_ci#define RSXX_HW_BLK_MASK (RSXX_HW_BLK_SIZE - 1) 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#define MAX_CREG_DATA8 32 498c2ecf20Sopenharmony_ci#define LOG_BUF_SIZE8 128 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define RSXX_MAX_OUTSTANDING_CMDS 255 528c2ecf20Sopenharmony_ci#define RSXX_CS_IDX_MASK 0xff 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define STATUS_BUFFER_SIZE8 4096 558c2ecf20Sopenharmony_ci#define COMMAND_BUFFER_SIZE8 4096 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define RSXX_MAX_TARGETS 8 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistruct dma_tracker_list; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci/* DMA Command/Status Buffer structure */ 628c2ecf20Sopenharmony_cistruct rsxx_cs_buffer { 638c2ecf20Sopenharmony_ci dma_addr_t dma_addr; 648c2ecf20Sopenharmony_ci void *buf; 658c2ecf20Sopenharmony_ci u32 idx; 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistruct rsxx_dma_stats { 698c2ecf20Sopenharmony_ci u32 crc_errors; 708c2ecf20Sopenharmony_ci u32 hard_errors; 718c2ecf20Sopenharmony_ci u32 soft_errors; 728c2ecf20Sopenharmony_ci u32 writes_issued; 738c2ecf20Sopenharmony_ci u32 writes_failed; 748c2ecf20Sopenharmony_ci u32 reads_issued; 758c2ecf20Sopenharmony_ci u32 reads_failed; 768c2ecf20Sopenharmony_ci u32 reads_retried; 778c2ecf20Sopenharmony_ci u32 discards_issued; 788c2ecf20Sopenharmony_ci u32 discards_failed; 798c2ecf20Sopenharmony_ci u32 done_rescheduled; 808c2ecf20Sopenharmony_ci u32 issue_rescheduled; 818c2ecf20Sopenharmony_ci u32 dma_sw_err; 828c2ecf20Sopenharmony_ci u32 dma_hw_fault; 838c2ecf20Sopenharmony_ci u32 dma_cancelled; 848c2ecf20Sopenharmony_ci u32 sw_q_depth; /* Number of DMAs on the SW queue. */ 858c2ecf20Sopenharmony_ci atomic_t hw_q_depth; /* Number of DMAs queued to HW. */ 868c2ecf20Sopenharmony_ci}; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_cistruct rsxx_dma_ctrl { 898c2ecf20Sopenharmony_ci struct rsxx_cardinfo *card; 908c2ecf20Sopenharmony_ci int id; 918c2ecf20Sopenharmony_ci void __iomem *regmap; 928c2ecf20Sopenharmony_ci struct rsxx_cs_buffer status; 938c2ecf20Sopenharmony_ci struct rsxx_cs_buffer cmd; 948c2ecf20Sopenharmony_ci u16 e_cnt; 958c2ecf20Sopenharmony_ci spinlock_t queue_lock; 968c2ecf20Sopenharmony_ci struct list_head queue; 978c2ecf20Sopenharmony_ci struct workqueue_struct *issue_wq; 988c2ecf20Sopenharmony_ci struct work_struct issue_dma_work; 998c2ecf20Sopenharmony_ci struct workqueue_struct *done_wq; 1008c2ecf20Sopenharmony_ci struct work_struct dma_done_work; 1018c2ecf20Sopenharmony_ci struct timer_list activity_timer; 1028c2ecf20Sopenharmony_ci struct dma_tracker_list *trackers; 1038c2ecf20Sopenharmony_ci struct rsxx_dma_stats stats; 1048c2ecf20Sopenharmony_ci struct mutex work_lock; 1058c2ecf20Sopenharmony_ci}; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_cistruct rsxx_cardinfo { 1088c2ecf20Sopenharmony_ci struct pci_dev *dev; 1098c2ecf20Sopenharmony_ci unsigned int halt; 1108c2ecf20Sopenharmony_ci unsigned int eeh_state; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci void __iomem *regmap; 1138c2ecf20Sopenharmony_ci spinlock_t irq_lock; 1148c2ecf20Sopenharmony_ci unsigned int isr_mask; 1158c2ecf20Sopenharmony_ci unsigned int ier_mask; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci struct rsxx_card_cfg config; 1188c2ecf20Sopenharmony_ci int config_valid; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci /* Embedded CPU Communication */ 1218c2ecf20Sopenharmony_ci struct { 1228c2ecf20Sopenharmony_ci spinlock_t lock; 1238c2ecf20Sopenharmony_ci bool active; 1248c2ecf20Sopenharmony_ci struct creg_cmd *active_cmd; 1258c2ecf20Sopenharmony_ci struct workqueue_struct *creg_wq; 1268c2ecf20Sopenharmony_ci struct work_struct done_work; 1278c2ecf20Sopenharmony_ci struct list_head queue; 1288c2ecf20Sopenharmony_ci unsigned int q_depth; 1298c2ecf20Sopenharmony_ci /* Cache the creg status to prevent ioreads */ 1308c2ecf20Sopenharmony_ci struct { 1318c2ecf20Sopenharmony_ci u32 stat; 1328c2ecf20Sopenharmony_ci u32 failed_cancel_timer; 1338c2ecf20Sopenharmony_ci u32 creg_timeout; 1348c2ecf20Sopenharmony_ci } creg_stats; 1358c2ecf20Sopenharmony_ci struct timer_list cmd_timer; 1368c2ecf20Sopenharmony_ci struct mutex reset_lock; 1378c2ecf20Sopenharmony_ci int reset; 1388c2ecf20Sopenharmony_ci } creg_ctrl; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci struct { 1418c2ecf20Sopenharmony_ci char tmp[MAX_CREG_DATA8]; 1428c2ecf20Sopenharmony_ci char buf[LOG_BUF_SIZE8]; /* terminated */ 1438c2ecf20Sopenharmony_ci int buf_len; 1448c2ecf20Sopenharmony_ci } log; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci struct workqueue_struct *event_wq; 1478c2ecf20Sopenharmony_ci struct work_struct event_work; 1488c2ecf20Sopenharmony_ci unsigned int state; 1498c2ecf20Sopenharmony_ci u64 size8; 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci /* Lock the device attach/detach function */ 1528c2ecf20Sopenharmony_ci struct mutex dev_lock; 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci /* Block Device Variables */ 1558c2ecf20Sopenharmony_ci bool bdev_attached; 1568c2ecf20Sopenharmony_ci int disk_id; 1578c2ecf20Sopenharmony_ci int major; 1588c2ecf20Sopenharmony_ci struct request_queue *queue; 1598c2ecf20Sopenharmony_ci struct gendisk *gendisk; 1608c2ecf20Sopenharmony_ci struct { 1618c2ecf20Sopenharmony_ci /* Used to convert a byte address to a device address. */ 1628c2ecf20Sopenharmony_ci u64 lower_mask; 1638c2ecf20Sopenharmony_ci u64 upper_shift; 1648c2ecf20Sopenharmony_ci u64 upper_mask; 1658c2ecf20Sopenharmony_ci u64 target_mask; 1668c2ecf20Sopenharmony_ci u64 target_shift; 1678c2ecf20Sopenharmony_ci } _stripe; 1688c2ecf20Sopenharmony_ci unsigned int dma_fault; 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci int scrub_hard; 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci int n_targets; 1738c2ecf20Sopenharmony_ci struct rsxx_dma_ctrl *ctrl; 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci struct dentry *debugfs_dir; 1768c2ecf20Sopenharmony_ci}; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_cienum rsxx_pci_regmap { 1798c2ecf20Sopenharmony_ci HWID = 0x00, /* Hardware Identification Register */ 1808c2ecf20Sopenharmony_ci SCRATCH = 0x04, /* Scratch/Debug Register */ 1818c2ecf20Sopenharmony_ci RESET = 0x08, /* Reset Register */ 1828c2ecf20Sopenharmony_ci ISR = 0x10, /* Interrupt Status Register */ 1838c2ecf20Sopenharmony_ci IER = 0x14, /* Interrupt Enable Register */ 1848c2ecf20Sopenharmony_ci IPR = 0x18, /* Interrupt Poll Register */ 1858c2ecf20Sopenharmony_ci CB_ADD_LO = 0x20, /* Command Host Buffer Address [31:0] */ 1868c2ecf20Sopenharmony_ci CB_ADD_HI = 0x24, /* Command Host Buffer Address [63:32]*/ 1878c2ecf20Sopenharmony_ci HW_CMD_IDX = 0x28, /* Hardware Processed Command Index */ 1888c2ecf20Sopenharmony_ci SW_CMD_IDX = 0x2C, /* Software Processed Command Index */ 1898c2ecf20Sopenharmony_ci SB_ADD_LO = 0x30, /* Status Host Buffer Address [31:0] */ 1908c2ecf20Sopenharmony_ci SB_ADD_HI = 0x34, /* Status Host Buffer Address [63:32] */ 1918c2ecf20Sopenharmony_ci HW_STATUS_CNT = 0x38, /* Hardware Status Counter */ 1928c2ecf20Sopenharmony_ci SW_STATUS_CNT = 0x3C, /* Deprecated */ 1938c2ecf20Sopenharmony_ci CREG_CMD = 0x40, /* CPU Command Register */ 1948c2ecf20Sopenharmony_ci CREG_ADD = 0x44, /* CPU Address Register */ 1958c2ecf20Sopenharmony_ci CREG_CNT = 0x48, /* CPU Count Register */ 1968c2ecf20Sopenharmony_ci CREG_STAT = 0x4C, /* CPU Status Register */ 1978c2ecf20Sopenharmony_ci CREG_DATA0 = 0x50, /* CPU Data Registers */ 1988c2ecf20Sopenharmony_ci CREG_DATA1 = 0x54, 1998c2ecf20Sopenharmony_ci CREG_DATA2 = 0x58, 2008c2ecf20Sopenharmony_ci CREG_DATA3 = 0x5C, 2018c2ecf20Sopenharmony_ci CREG_DATA4 = 0x60, 2028c2ecf20Sopenharmony_ci CREG_DATA5 = 0x64, 2038c2ecf20Sopenharmony_ci CREG_DATA6 = 0x68, 2048c2ecf20Sopenharmony_ci CREG_DATA7 = 0x6c, 2058c2ecf20Sopenharmony_ci INTR_COAL = 0x70, /* Interrupt Coalescing Register */ 2068c2ecf20Sopenharmony_ci HW_ERROR = 0x74, /* Card Error Register */ 2078c2ecf20Sopenharmony_ci PCI_DEBUG0 = 0x78, /* PCI Debug Registers */ 2088c2ecf20Sopenharmony_ci PCI_DEBUG1 = 0x7C, 2098c2ecf20Sopenharmony_ci PCI_DEBUG2 = 0x80, 2108c2ecf20Sopenharmony_ci PCI_DEBUG3 = 0x84, 2118c2ecf20Sopenharmony_ci PCI_DEBUG4 = 0x88, 2128c2ecf20Sopenharmony_ci PCI_DEBUG5 = 0x8C, 2138c2ecf20Sopenharmony_ci PCI_DEBUG6 = 0x90, 2148c2ecf20Sopenharmony_ci PCI_DEBUG7 = 0x94, 2158c2ecf20Sopenharmony_ci PCI_POWER_THROTTLE = 0x98, 2168c2ecf20Sopenharmony_ci PERF_CTRL = 0x9c, 2178c2ecf20Sopenharmony_ci PERF_TIMER_LO = 0xa0, 2188c2ecf20Sopenharmony_ci PERF_TIMER_HI = 0xa4, 2198c2ecf20Sopenharmony_ci PERF_RD512_LO = 0xa8, 2208c2ecf20Sopenharmony_ci PERF_RD512_HI = 0xac, 2218c2ecf20Sopenharmony_ci PERF_WR512_LO = 0xb0, 2228c2ecf20Sopenharmony_ci PERF_WR512_HI = 0xb4, 2238c2ecf20Sopenharmony_ci PCI_RECONFIG = 0xb8, 2248c2ecf20Sopenharmony_ci}; 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_cienum rsxx_intr { 2278c2ecf20Sopenharmony_ci CR_INTR_DMA0 = 0x00000001, 2288c2ecf20Sopenharmony_ci CR_INTR_CREG = 0x00000002, 2298c2ecf20Sopenharmony_ci CR_INTR_DMA1 = 0x00000004, 2308c2ecf20Sopenharmony_ci CR_INTR_EVENT = 0x00000008, 2318c2ecf20Sopenharmony_ci CR_INTR_DMA2 = 0x00000010, 2328c2ecf20Sopenharmony_ci CR_INTR_DMA3 = 0x00000020, 2338c2ecf20Sopenharmony_ci CR_INTR_DMA4 = 0x00000040, 2348c2ecf20Sopenharmony_ci CR_INTR_DMA5 = 0x00000080, 2358c2ecf20Sopenharmony_ci CR_INTR_DMA6 = 0x00000100, 2368c2ecf20Sopenharmony_ci CR_INTR_DMA7 = 0x00000200, 2378c2ecf20Sopenharmony_ci CR_INTR_ALL_C = 0x0000003f, 2388c2ecf20Sopenharmony_ci CR_INTR_ALL_G = 0x000003ff, 2398c2ecf20Sopenharmony_ci CR_INTR_DMA_ALL = 0x000003f5, 2408c2ecf20Sopenharmony_ci CR_INTR_ALL = 0xffffffff, 2418c2ecf20Sopenharmony_ci}; 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_cistatic inline int CR_INTR_DMA(int N) 2448c2ecf20Sopenharmony_ci{ 2458c2ecf20Sopenharmony_ci static const unsigned int _CR_INTR_DMA[] = { 2468c2ecf20Sopenharmony_ci CR_INTR_DMA0, CR_INTR_DMA1, CR_INTR_DMA2, CR_INTR_DMA3, 2478c2ecf20Sopenharmony_ci CR_INTR_DMA4, CR_INTR_DMA5, CR_INTR_DMA6, CR_INTR_DMA7 2488c2ecf20Sopenharmony_ci }; 2498c2ecf20Sopenharmony_ci return _CR_INTR_DMA[N]; 2508c2ecf20Sopenharmony_ci} 2518c2ecf20Sopenharmony_cienum rsxx_pci_reset { 2528c2ecf20Sopenharmony_ci DMA_QUEUE_RESET = 0x00000001, 2538c2ecf20Sopenharmony_ci}; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_cienum rsxx_hw_fifo_flush { 2568c2ecf20Sopenharmony_ci RSXX_FLUSH_BUSY = 0x00000002, 2578c2ecf20Sopenharmony_ci RSXX_FLUSH_TIMEOUT = 0x00000004, 2588c2ecf20Sopenharmony_ci}; 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_cienum rsxx_pci_revision { 2618c2ecf20Sopenharmony_ci RSXX_DISCARD_SUPPORT = 2, 2628c2ecf20Sopenharmony_ci RSXX_EEH_SUPPORT = 3, 2638c2ecf20Sopenharmony_ci}; 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_cienum rsxx_creg_cmd { 2668c2ecf20Sopenharmony_ci CREG_CMD_TAG_MASK = 0x0000FF00, 2678c2ecf20Sopenharmony_ci CREG_OP_WRITE = 0x000000C0, 2688c2ecf20Sopenharmony_ci CREG_OP_READ = 0x000000E0, 2698c2ecf20Sopenharmony_ci}; 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_cienum rsxx_creg_addr { 2728c2ecf20Sopenharmony_ci CREG_ADD_CARD_CMD = 0x80001000, 2738c2ecf20Sopenharmony_ci CREG_ADD_CARD_STATE = 0x80001004, 2748c2ecf20Sopenharmony_ci CREG_ADD_CARD_SIZE = 0x8000100c, 2758c2ecf20Sopenharmony_ci CREG_ADD_CAPABILITIES = 0x80001050, 2768c2ecf20Sopenharmony_ci CREG_ADD_LOG = 0x80002000, 2778c2ecf20Sopenharmony_ci CREG_ADD_NUM_TARGETS = 0x80003000, 2788c2ecf20Sopenharmony_ci CREG_ADD_CRAM = 0xA0000000, 2798c2ecf20Sopenharmony_ci CREG_ADD_CONFIG = 0xB0000000, 2808c2ecf20Sopenharmony_ci}; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_cienum rsxx_creg_card_cmd { 2838c2ecf20Sopenharmony_ci CARD_CMD_STARTUP = 1, 2848c2ecf20Sopenharmony_ci CARD_CMD_SHUTDOWN = 2, 2858c2ecf20Sopenharmony_ci CARD_CMD_LOW_LEVEL_FORMAT = 3, 2868c2ecf20Sopenharmony_ci CARD_CMD_FPGA_RECONFIG_BR = 4, 2878c2ecf20Sopenharmony_ci CARD_CMD_FPGA_RECONFIG_MAIN = 5, 2888c2ecf20Sopenharmony_ci CARD_CMD_BACKUP = 6, 2898c2ecf20Sopenharmony_ci CARD_CMD_RESET = 7, 2908c2ecf20Sopenharmony_ci CARD_CMD_deprecated = 8, 2918c2ecf20Sopenharmony_ci CARD_CMD_UNINITIALIZE = 9, 2928c2ecf20Sopenharmony_ci CARD_CMD_DSTROY_EMERGENCY = 10, 2938c2ecf20Sopenharmony_ci CARD_CMD_DSTROY_NORMAL = 11, 2948c2ecf20Sopenharmony_ci CARD_CMD_DSTROY_EXTENDED = 12, 2958c2ecf20Sopenharmony_ci CARD_CMD_DSTROY_ABORT = 13, 2968c2ecf20Sopenharmony_ci}; 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_cienum rsxx_card_state { 2998c2ecf20Sopenharmony_ci CARD_STATE_SHUTDOWN = 0x00000001, 3008c2ecf20Sopenharmony_ci CARD_STATE_STARTING = 0x00000002, 3018c2ecf20Sopenharmony_ci CARD_STATE_FORMATTING = 0x00000004, 3028c2ecf20Sopenharmony_ci CARD_STATE_UNINITIALIZED = 0x00000008, 3038c2ecf20Sopenharmony_ci CARD_STATE_GOOD = 0x00000010, 3048c2ecf20Sopenharmony_ci CARD_STATE_SHUTTING_DOWN = 0x00000020, 3058c2ecf20Sopenharmony_ci CARD_STATE_FAULT = 0x00000040, 3068c2ecf20Sopenharmony_ci CARD_STATE_RD_ONLY_FAULT = 0x00000080, 3078c2ecf20Sopenharmony_ci CARD_STATE_DSTROYING = 0x00000100, 3088c2ecf20Sopenharmony_ci}; 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_cienum rsxx_led { 3118c2ecf20Sopenharmony_ci LED_DEFAULT = 0x0, 3128c2ecf20Sopenharmony_ci LED_IDENTIFY = 0x1, 3138c2ecf20Sopenharmony_ci LED_SOAK = 0x2, 3148c2ecf20Sopenharmony_ci}; 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_cienum rsxx_creg_flash_lock { 3178c2ecf20Sopenharmony_ci CREG_FLASH_LOCK = 1, 3188c2ecf20Sopenharmony_ci CREG_FLASH_UNLOCK = 2, 3198c2ecf20Sopenharmony_ci}; 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_cienum rsxx_card_capabilities { 3228c2ecf20Sopenharmony_ci CARD_CAP_SUBPAGE_WRITES = 0x00000080, 3238c2ecf20Sopenharmony_ci}; 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_cienum rsxx_creg_stat { 3268c2ecf20Sopenharmony_ci CREG_STAT_STATUS_MASK = 0x00000003, 3278c2ecf20Sopenharmony_ci CREG_STAT_SUCCESS = 0x1, 3288c2ecf20Sopenharmony_ci CREG_STAT_ERROR = 0x2, 3298c2ecf20Sopenharmony_ci CREG_STAT_CHAR_PENDING = 0x00000004, /* Character I/O pending bit */ 3308c2ecf20Sopenharmony_ci CREG_STAT_LOG_PENDING = 0x00000008, /* HW log message pending bit */ 3318c2ecf20Sopenharmony_ci CREG_STAT_TAG_MASK = 0x0000ff00, 3328c2ecf20Sopenharmony_ci}; 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_cienum rsxx_dma_finish { 3358c2ecf20Sopenharmony_ci FREE_DMA = 0x0, 3368c2ecf20Sopenharmony_ci COMPLETE_DMA = 0x1, 3378c2ecf20Sopenharmony_ci}; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_cistatic inline unsigned int CREG_DATA(int N) 3408c2ecf20Sopenharmony_ci{ 3418c2ecf20Sopenharmony_ci return CREG_DATA0 + (N << 2); 3428c2ecf20Sopenharmony_ci} 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci/*----------------- Convenient Log Wrappers -------------------*/ 3458c2ecf20Sopenharmony_ci#define CARD_TO_DEV(__CARD) (&(__CARD)->dev->dev) 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_ci/***** config.c *****/ 3488c2ecf20Sopenharmony_ciint rsxx_load_config(struct rsxx_cardinfo *card); 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_ci/***** core.c *****/ 3518c2ecf20Sopenharmony_civoid rsxx_enable_ier(struct rsxx_cardinfo *card, unsigned int intr); 3528c2ecf20Sopenharmony_civoid rsxx_disable_ier(struct rsxx_cardinfo *card, unsigned int intr); 3538c2ecf20Sopenharmony_civoid rsxx_enable_ier_and_isr(struct rsxx_cardinfo *card, 3548c2ecf20Sopenharmony_ci unsigned int intr); 3558c2ecf20Sopenharmony_civoid rsxx_disable_ier_and_isr(struct rsxx_cardinfo *card, 3568c2ecf20Sopenharmony_ci unsigned int intr); 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ci/***** dev.c *****/ 3598c2ecf20Sopenharmony_ciint rsxx_attach_dev(struct rsxx_cardinfo *card); 3608c2ecf20Sopenharmony_civoid rsxx_detach_dev(struct rsxx_cardinfo *card); 3618c2ecf20Sopenharmony_ciint rsxx_setup_dev(struct rsxx_cardinfo *card); 3628c2ecf20Sopenharmony_civoid rsxx_destroy_dev(struct rsxx_cardinfo *card); 3638c2ecf20Sopenharmony_ciint rsxx_dev_init(void); 3648c2ecf20Sopenharmony_civoid rsxx_dev_cleanup(void); 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci/***** dma.c ****/ 3678c2ecf20Sopenharmony_citypedef void (*rsxx_dma_cb)(struct rsxx_cardinfo *card, 3688c2ecf20Sopenharmony_ci void *cb_data, 3698c2ecf20Sopenharmony_ci unsigned int status); 3708c2ecf20Sopenharmony_ciint rsxx_dma_setup(struct rsxx_cardinfo *card); 3718c2ecf20Sopenharmony_civoid rsxx_dma_destroy(struct rsxx_cardinfo *card); 3728c2ecf20Sopenharmony_ciint rsxx_dma_init(void); 3738c2ecf20Sopenharmony_ciint rsxx_cleanup_dma_queue(struct rsxx_dma_ctrl *ctrl, 3748c2ecf20Sopenharmony_ci struct list_head *q, 3758c2ecf20Sopenharmony_ci unsigned int done); 3768c2ecf20Sopenharmony_ciint rsxx_dma_cancel(struct rsxx_dma_ctrl *ctrl); 3778c2ecf20Sopenharmony_civoid rsxx_dma_cleanup(void); 3788c2ecf20Sopenharmony_civoid rsxx_dma_queue_reset(struct rsxx_cardinfo *card); 3798c2ecf20Sopenharmony_ciint rsxx_dma_configure(struct rsxx_cardinfo *card); 3808c2ecf20Sopenharmony_ciblk_status_t rsxx_dma_queue_bio(struct rsxx_cardinfo *card, 3818c2ecf20Sopenharmony_ci struct bio *bio, 3828c2ecf20Sopenharmony_ci atomic_t *n_dmas, 3838c2ecf20Sopenharmony_ci rsxx_dma_cb cb, 3848c2ecf20Sopenharmony_ci void *cb_data); 3858c2ecf20Sopenharmony_ciint rsxx_hw_buffers_init(struct pci_dev *dev, struct rsxx_dma_ctrl *ctrl); 3868c2ecf20Sopenharmony_ciint rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card); 3878c2ecf20Sopenharmony_ciint rsxx_eeh_remap_dmas(struct rsxx_cardinfo *card); 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci/***** cregs.c *****/ 3908c2ecf20Sopenharmony_ciint rsxx_creg_write(struct rsxx_cardinfo *card, u32 addr, 3918c2ecf20Sopenharmony_ci unsigned int size8, 3928c2ecf20Sopenharmony_ci void *data, 3938c2ecf20Sopenharmony_ci int byte_stream); 3948c2ecf20Sopenharmony_ciint rsxx_creg_read(struct rsxx_cardinfo *card, 3958c2ecf20Sopenharmony_ci u32 addr, 3968c2ecf20Sopenharmony_ci unsigned int size8, 3978c2ecf20Sopenharmony_ci void *data, 3988c2ecf20Sopenharmony_ci int byte_stream); 3998c2ecf20Sopenharmony_ciint rsxx_read_hw_log(struct rsxx_cardinfo *card); 4008c2ecf20Sopenharmony_ciint rsxx_get_card_state(struct rsxx_cardinfo *card, 4018c2ecf20Sopenharmony_ci unsigned int *state); 4028c2ecf20Sopenharmony_ciint rsxx_get_card_size8(struct rsxx_cardinfo *card, u64 *size8); 4038c2ecf20Sopenharmony_ciint rsxx_get_num_targets(struct rsxx_cardinfo *card, 4048c2ecf20Sopenharmony_ci unsigned int *n_targets); 4058c2ecf20Sopenharmony_ciint rsxx_get_card_capabilities(struct rsxx_cardinfo *card, 4068c2ecf20Sopenharmony_ci u32 *capabilities); 4078c2ecf20Sopenharmony_ciint rsxx_issue_card_cmd(struct rsxx_cardinfo *card, u32 cmd); 4088c2ecf20Sopenharmony_ciint rsxx_creg_setup(struct rsxx_cardinfo *card); 4098c2ecf20Sopenharmony_civoid rsxx_creg_destroy(struct rsxx_cardinfo *card); 4108c2ecf20Sopenharmony_ciint rsxx_creg_init(void); 4118c2ecf20Sopenharmony_civoid rsxx_creg_cleanup(void); 4128c2ecf20Sopenharmony_ciint rsxx_reg_access(struct rsxx_cardinfo *card, 4138c2ecf20Sopenharmony_ci struct rsxx_reg_access __user *ucmd, 4148c2ecf20Sopenharmony_ci int read); 4158c2ecf20Sopenharmony_civoid rsxx_eeh_save_issued_creg(struct rsxx_cardinfo *card); 4168c2ecf20Sopenharmony_civoid rsxx_kick_creg_queue(struct rsxx_cardinfo *card); 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_ci#endif /* __DRIVERS_BLOCK_RSXX_H__ */ 421