1
2 #ifndef _ASM_S390_EADM_H
3 #define _ASM_S390_EADM_H
4
5 #include <linux/types.h>
6 #include <linux/device.h>
7 #include <linux/blk_types.h>
8
9 struct arqb {
10 u64 data;
11 u16 fmt:4;
12 u16:12;
13 u16 cmd_code;
14 u16:16;
15 u16 msb_count;
16 u32 reserved[12];
17 } __packed;
18
19 #define ARQB_CMD_MOVE 1
20
21 struct arsb {
22 u16 fmt:4;
23 u32:28;
24 u8 ef;
25 u8:8;
26 u8 ecbi;
27 u8:8;
28 u8 fvf;
29 u16:16;
30 u8 eqc;
31 u32:32;
32 u64 fail_msb;
33 u64 fail_aidaw;
34 u64 fail_ms;
35 u64 fail_scm;
36 u32 reserved[4];
37 } __packed;
38
39 #define EQC_WR_PROHIBIT 22
40
41 struct msb {
42 u8 fmt:4;
43 u8 oc:4;
44 u8 flags;
45 u16:12;
46 u16 bs:4;
47 u32 blk_count;
48 u64 data_addr;
49 u64 scm_addr;
50 u64:64;
51 } __packed;
52
53 struct aidaw {
54 u8 flags;
55 u32 :24;
56 u32 :32;
57 u64 data_addr;
58 } __packed;
59
60 #define MSB_OC_CLEAR 0
61 #define MSB_OC_READ 1
62 #define MSB_OC_WRITE 2
63 #define MSB_OC_RELEASE 3
64
65 #define MSB_FLAG_BNM 0x80
66 #define MSB_FLAG_IDA 0x40
67
68 #define MSB_BS_4K 0
69 #define MSB_BS_1M 1
70
71 #define AOB_NR_MSB 124
72
73 struct aob {
74 struct arqb request;
75 struct arsb response;
76 struct msb msb[AOB_NR_MSB];
77 } __packed __aligned(PAGE_SIZE);
78
79 struct aob_rq_header {
80 struct scm_device *scmdev;
81 char data[0];
82 };
83
84 struct scm_device {
85 u64 address;
86 u64 size;
87 unsigned int nr_max_block;
88 struct device dev;
89 struct {
90 unsigned int persistence:4;
91 unsigned int oper_state:4;
92 unsigned int data_state:4;
93 unsigned int rank:4;
94 unsigned int release:1;
95 unsigned int res_id:8;
96 } __packed attrs;
97 };
98
99 #define OP_STATE_GOOD 1
100 #define OP_STATE_TEMP_ERR 2
101 #define OP_STATE_PERM_ERR 3
102
103 enum scm_event {SCM_CHANGE, SCM_AVAIL};
104
105 struct scm_driver {
106 struct device_driver drv;
107 int (*probe) (struct scm_device *scmdev);
108 int (*remove) (struct scm_device *scmdev);
109 void (*notify) (struct scm_device *scmdev, enum scm_event event);
110 void (*handler) (struct scm_device *scmdev, void *data,
111 blk_status_t error);
112 };
113
114 int scm_driver_register(struct scm_driver *scmdrv);
115 void scm_driver_unregister(struct scm_driver *scmdrv);
116
117 int eadm_start_aob(struct aob *aob);
118 void scm_irq_handler(struct aob *aob, blk_status_t error);
119
120 #endif