xref: /openbmc/linux/drivers/s390/cio/cio.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds #ifndef S390_CIO_H
31da177e4SLinus Torvalds #define S390_CIO_H
41da177e4SLinus Torvalds 
56ab4879aSCornelia Huck #include <linux/mutex.h>
6e5854a58SPeter Oberparleiter #include <linux/device.h>
77e9db9eaSCornelia Huck #include <linux/mod_devicetable.h>
87ad6a249SPeter Oberparleiter #include <asm/chpid.h>
983262d63SPeter Oberparleiter #include <asm/cio.h>
1083262d63SPeter Oberparleiter #include <asm/fcx.h>
119d92a7e1SCornelia Huck #include <asm/schid.h>
12c63c473fSSven Schnelle #include <asm/tpi.h>
137ad6a249SPeter Oberparleiter #include "chsc.h"
141da177e4SLinus Torvalds 
151da177e4SLinus Torvalds /*
161da177e4SLinus Torvalds  * path management control word
171da177e4SLinus Torvalds  */
181da177e4SLinus Torvalds struct pmcw {
19cd6b4f27SCornelia Huck 	u32 intparm;		/* interruption parameter */
20cd6b4f27SCornelia Huck 	u32 qf	 : 1;		/* qdio facility */
21b3a686f4SCornelia Huck 	u32 w	 : 1;
22cd6b4f27SCornelia Huck 	u32 isc  : 3;		/* interruption sublass */
23cd6b4f27SCornelia Huck 	u32 res5 : 3;		/* reserved zeros */
24cd6b4f27SCornelia Huck 	u32 ena  : 1;		/* enabled */
25cd6b4f27SCornelia Huck 	u32 lm	 : 2;		/* limit mode */
26cd6b4f27SCornelia Huck 	u32 mme  : 2;		/* measurement-mode enable */
27cd6b4f27SCornelia Huck 	u32 mp	 : 1;		/* multipath mode */
28cd6b4f27SCornelia Huck 	u32 tf	 : 1;		/* timing facility */
29cd6b4f27SCornelia Huck 	u32 dnv  : 1;		/* device number valid */
30cd6b4f27SCornelia Huck 	u32 dev  : 16;		/* device number */
31cd6b4f27SCornelia Huck 	u8  lpm;		/* logical path mask */
32cd6b4f27SCornelia Huck 	u8  pnom;		/* path not operational mask */
33cd6b4f27SCornelia Huck 	u8  lpum;		/* last path used mask */
34cd6b4f27SCornelia Huck 	u8  pim;		/* path installed mask */
35cd6b4f27SCornelia Huck 	u16 mbi;		/* measurement-block index */
36cd6b4f27SCornelia Huck 	u8  pom;		/* path operational mask */
37cd6b4f27SCornelia Huck 	u8  pam;		/* path available mask */
38cd6b4f27SCornelia Huck 	u8  chpid[8];		/* CHPID 0-7 (if available) */
39cd6b4f27SCornelia Huck 	u32 unused1 : 8;	/* reserved zeros */
40cd6b4f27SCornelia Huck 	u32 st	    : 3;	/* subchannel type */
41cd6b4f27SCornelia Huck 	u32 unused2 : 18;	/* reserved zeros */
42cd6b4f27SCornelia Huck 	u32 mbfc    : 1;	/* measurement block format control */
43cd6b4f27SCornelia Huck 	u32 xmwme   : 1;	/* extended measurement word mode enable */
44cd6b4f27SCornelia Huck 	u32 csense  : 1;	/* concurrent sense; can be enabled ...*/
451da177e4SLinus Torvalds 				/*  ... per MSCH, however, if facility */
461da177e4SLinus Torvalds 				/*  ... is not installed, this results */
471da177e4SLinus Torvalds 				/*  ... in an operand exception.       */
481da177e4SLinus Torvalds } __attribute__ ((packed));
491da177e4SLinus Torvalds 
5013952ec1SSebastian Ott /* Target SCHIB configuration. */
5113952ec1SSebastian Ott struct schib_config {
5213952ec1SSebastian Ott 	u64 mba;
5313952ec1SSebastian Ott 	u32 intparm;
5413952ec1SSebastian Ott 	u16 mbi;
5513952ec1SSebastian Ott 	u32 isc:3;
5613952ec1SSebastian Ott 	u32 ena:1;
5713952ec1SSebastian Ott 	u32 mme:2;
5813952ec1SSebastian Ott 	u32 mp:1;
5913952ec1SSebastian Ott 	u32 csense:1;
6013952ec1SSebastian Ott 	u32 mbfc:1;
6113952ec1SSebastian Ott } __attribute__ ((packed));
6213952ec1SSebastian Ott 
631da177e4SLinus Torvalds /*
641da177e4SLinus Torvalds  * subchannel information block
651da177e4SLinus Torvalds  */
661da177e4SLinus Torvalds struct schib {
671da177e4SLinus Torvalds 	struct pmcw pmcw;	 /* path management control word */
6823d805b6SPeter Oberparleiter 	union scsw scsw;	 /* subchannel status word */
691da177e4SLinus Torvalds 	__u64 mba;               /* measurement block address */
701da177e4SLinus Torvalds 	__u8 mda[4];		 /* model dependent area */
711da177e4SLinus Torvalds } __attribute__ ((packed,aligned(4)));
721da177e4SLinus Torvalds 
73817e5000SSebastian Ott /*
74817e5000SSebastian Ott  * When rescheduled, todo's with higher values will overwrite those
75817e5000SSebastian Ott  * with lower values.
76817e5000SSebastian Ott  */
77390935acSPeter Oberparleiter enum sch_todo {
78390935acSPeter Oberparleiter 	SCH_TODO_NOTHING,
79817e5000SSebastian Ott 	SCH_TODO_EVAL,
80390935acSPeter Oberparleiter 	SCH_TODO_UNREG,
81390935acSPeter Oberparleiter };
82390935acSPeter Oberparleiter 
831da177e4SLinus Torvalds /* subchannel data structure used by I/O subroutines */
841da177e4SLinus Torvalds struct subchannel {
85a8237fc4SCornelia Huck 	struct subchannel_id schid;
862ec22984SCornelia Huck 	spinlock_t *lock;	/* subchannel lock */
876ab4879aSCornelia Huck 	struct mutex reg_mutex;
881da177e4SLinus Torvalds 	enum {
891da177e4SLinus Torvalds 		SUBCHANNEL_TYPE_IO = 0,
901da177e4SLinus Torvalds 		SUBCHANNEL_TYPE_CHSC = 1,
91b279a4f5SCornelia Huck 		SUBCHANNEL_TYPE_MSG = 2,
921da177e4SLinus Torvalds 		SUBCHANNEL_TYPE_ADM = 3,
931da177e4SLinus Torvalds 	} st;			/* subchannel type */
941da177e4SLinus Torvalds 	__u8 vpm;		/* verified path mask */
951da177e4SLinus Torvalds 	__u8 lpm;		/* logical path mask */
961da177e4SLinus Torvalds 	__u8 opm;               /* operational path mask */
971da177e4SLinus Torvalds 	struct schib schib;	/* subchannel information block */
98edf22096SCornelia Huck 	int isc; /* desired interruption subclass */
997ad6a249SPeter Oberparleiter 	struct chsc_ssd_info ssd_info;	/* subchannel description */
1001da177e4SLinus Torvalds 	struct device dev;	/* entry in device tree */
1011da177e4SLinus Torvalds 	struct css_driver *driver;
102390935acSPeter Oberparleiter 	enum sch_todo todo;
103390935acSPeter Oberparleiter 	struct work_struct todo_work;
10413952ec1SSebastian Ott 	struct schib_config config;
10505668e1dSHalil Pasic 	u64 dma_mask;
106*1e8ee512SKrzysztof Kozlowski 	/*
107*1e8ee512SKrzysztof Kozlowski 	 * Driver name to force a match.  Do not set directly, because core
108*1e8ee512SKrzysztof Kozlowski 	 * frees it.  Use driver_set_override() to set or clear it.
109*1e8ee512SKrzysztof Kozlowski 	 */
110*1e8ee512SKrzysztof Kozlowski 	const char *driver_override;
1111da177e4SLinus Torvalds } __attribute__ ((aligned(8)));
1121da177e4SLinus Torvalds 
113e91012eeSArnd Bergmann DECLARE_PER_CPU_ALIGNED(struct irb, cio_irb);
11463aef00bSMartin Schwidefsky 
1151da177e4SLinus Torvalds #define to_subchannel(n) container_of(n, struct subchannel, dev)
1161da177e4SLinus Torvalds 
117edf22096SCornelia Huck extern int cio_enable_subchannel(struct subchannel *, u32);
1181da177e4SLinus Torvalds extern int cio_disable_subchannel (struct subchannel *);
1191da177e4SLinus Torvalds extern int cio_cancel (struct subchannel *);
1201da177e4SLinus Torvalds extern int cio_clear (struct subchannel *);
1215434da4dSDong Jia Shi extern int cio_cancel_halt_clear(struct subchannel *, int *);
1221da177e4SLinus Torvalds extern int cio_resume (struct subchannel *);
1231da177e4SLinus Torvalds extern int cio_halt (struct subchannel *);
1241da177e4SLinus Torvalds extern int cio_start (struct subchannel *, struct ccw1 *, __u8);
1251da177e4SLinus Torvalds extern int cio_start_key (struct subchannel *, struct ccw1 *, __u8, __u8);
1261da177e4SLinus Torvalds extern int cio_set_options (struct subchannel *, int);
127cdb912a4SSebastian Ott extern int cio_update_schib(struct subchannel *sch);
12813952ec1SSebastian Ott extern int cio_commit_config(struct subchannel *sch);
129a8237fc4SCornelia Huck 
13083262d63SPeter Oberparleiter int cio_tm_start_key(struct subchannel *sch, struct tcw *tcw, u8 lpm, u8 key);
13183262d63SPeter Oberparleiter int cio_tm_intrg(struct subchannel *sch);
13283262d63SPeter Oberparleiter 
133b50623e5SHalil Pasic extern int __init airq_init(void);
134b50623e5SHalil Pasic 
1351da177e4SLinus Torvalds /* Use with care. */
1361da177e4SLinus Torvalds #ifdef CONFIG_CCW_CONSOLE
1371da177e4SLinus Torvalds extern struct subchannel *cio_probe_console(void);
138a8237fc4SCornelia Huck extern int cio_is_console(struct subchannel_id);
13914556b33SSebastian Ott extern void cio_register_early_subchannels(void);
140188561a4SSebastian Ott extern void cio_tsch(struct subchannel *sch);
1411da177e4SLinus Torvalds #else
142a8237fc4SCornelia Huck #define cio_is_console(schid) 0
cio_register_early_subchannels(void)14314556b33SSebastian Ott static inline void cio_register_early_subchannels(void) {}
1441da177e4SLinus Torvalds #endif
1451da177e4SLinus Torvalds 
1461da177e4SLinus Torvalds #endif
147