blob: 144809a3f4f69e1a669441cd592307f1e83ea1cb [file] [log] [blame]
Sebastian Ottd2fc439b2012-08-28 16:44:51 +02001#ifndef _ASM_S390_EADM_H
2#define _ASM_S390_EADM_H
3
4#include <linux/types.h>
Sebastian Ott1d1c8f72012-08-28 16:46:26 +02005#include <linux/device.h>
Christoph Hellwig2a842ac2017-06-03 09:38:04 +02006#include <linux/blkdev.h>
Sebastian Ottd2fc439b2012-08-28 16:44:51 +02007
8struct arqb {
9 u64 data;
10 u16 fmt:4;
11 u16:12;
12 u16 cmd_code;
13 u16:16;
14 u16 msb_count;
15 u32 reserved[12];
16} __packed;
17
18#define ARQB_CMD_MOVE 1
19
20struct arsb {
21 u16 fmt:4;
22 u32:28;
23 u8 ef;
24 u8:8;
25 u8 ecbi;
26 u8:8;
27 u8 fvf;
28 u16:16;
29 u8 eqc;
30 u32:32;
31 u64 fail_msb;
32 u64 fail_aidaw;
33 u64 fail_ms;
34 u64 fail_scm;
35 u32 reserved[4];
36} __packed;
37
Sebastian Ott4fa3c012013-02-28 12:07:48 +010038#define EQC_WR_PROHIBIT 22
39
Sebastian Ottd2fc439b2012-08-28 16:44:51 +020040struct msb {
41 u8 fmt:4;
42 u8 oc:4;
43 u8 flags;
44 u16:12;
45 u16 bs:4;
46 u32 blk_count;
47 u64 data_addr;
48 u64 scm_addr;
49 u64:64;
50} __packed;
51
52struct aidaw {
53 u8 flags;
54 u32 :24;
55 u32 :32;
56 u64 data_addr;
57} __packed;
58
59#define MSB_OC_CLEAR 0
60#define MSB_OC_READ 1
61#define MSB_OC_WRITE 2
62#define MSB_OC_RELEASE 3
63
64#define MSB_FLAG_BNM 0x80
65#define MSB_FLAG_IDA 0x40
66
67#define MSB_BS_4K 0
68#define MSB_BS_1M 1
69
70#define AOB_NR_MSB 124
71
72struct aob {
73 struct arqb request;
74 struct arsb response;
75 struct msb msb[AOB_NR_MSB];
76} __packed __aligned(PAGE_SIZE);
77
Sebastian Ott1d1c8f72012-08-28 16:46:26 +020078struct aob_rq_header {
79 struct scm_device *scmdev;
80 char data[0];
81};
82
83struct scm_device {
84 u64 address;
85 u64 size;
86 unsigned int nr_max_block;
87 struct device dev;
Sebastian Ott1d1c8f72012-08-28 16:46:26 +020088 struct {
89 unsigned int persistence:4;
90 unsigned int oper_state:4;
91 unsigned int data_state:4;
92 unsigned int rank:4;
93 unsigned int release:1;
94 unsigned int res_id:8;
95 } __packed attrs;
96};
97
98#define OP_STATE_GOOD 1
99#define OP_STATE_TEMP_ERR 2
100#define OP_STATE_PERM_ERR 3
101
Sebastian Ottaebfa662013-02-28 12:07:55 +0100102enum scm_event {SCM_CHANGE, SCM_AVAIL};
Sebastian Ott93481c92013-02-28 12:07:38 +0100103
Sebastian Ott1d1c8f72012-08-28 16:46:26 +0200104struct scm_driver {
105 struct device_driver drv;
106 int (*probe) (struct scm_device *scmdev);
107 int (*remove) (struct scm_device *scmdev);
Sebastian Ott93481c92013-02-28 12:07:38 +0100108 void (*notify) (struct scm_device *scmdev, enum scm_event event);
Christoph Hellwig2a842ac2017-06-03 09:38:04 +0200109 void (*handler) (struct scm_device *scmdev, void *data,
110 blk_status_t error);
Sebastian Ott1d1c8f72012-08-28 16:46:26 +0200111};
112
113int scm_driver_register(struct scm_driver *scmdrv);
114void scm_driver_unregister(struct scm_driver *scmdrv);
115
Sebastian Ott605c3692013-11-14 10:44:56 +0100116int eadm_start_aob(struct aob *aob);
Christoph Hellwig2a842ac2017-06-03 09:38:04 +0200117void scm_irq_handler(struct aob *aob, blk_status_t error);
Sebastian Ott1d1c8f72012-08-28 16:46:26 +0200118
Sebastian Ottd2fc439b2012-08-28 16:44:51 +0200119#endif /* _ASM_S390_EADM_H */