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