Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 1 | #ifndef S390_IO_SCH_H |
| 2 | #define S390_IO_SCH_H |
| 3 | |
Cornelia Huck | 9d92a7e | 2008-07-14 09:59:05 +0200 | [diff] [blame] | 4 | #include <asm/schid.h> |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 5 | |
| 6 | /* |
Peter Oberparleiter | 83262d6 | 2008-07-14 09:58:51 +0200 | [diff] [blame] | 7 | * command-mode operation request block |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 8 | */ |
Peter Oberparleiter | 83262d6 | 2008-07-14 09:58:51 +0200 | [diff] [blame] | 9 | struct cmd_orb { |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 10 | u32 intparm; /* interruption parameter */ |
| 11 | u32 key : 4; /* flags, like key, suspend control, etc. */ |
| 12 | u32 spnd : 1; /* suspend control */ |
| 13 | u32 res1 : 1; /* reserved */ |
| 14 | u32 mod : 1; /* modification control */ |
| 15 | u32 sync : 1; /* synchronize control */ |
| 16 | u32 fmt : 1; /* format control */ |
| 17 | u32 pfch : 1; /* prefetch control */ |
| 18 | u32 isic : 1; /* initial-status-interruption control */ |
| 19 | u32 alcc : 1; /* address-limit-checking control */ |
| 20 | u32 ssic : 1; /* suppress-suspended-interr. control */ |
| 21 | u32 res2 : 1; /* reserved */ |
| 22 | u32 c64 : 1; /* IDAW/QDIO 64 bit control */ |
| 23 | u32 i2k : 1; /* IDAW 2/4kB block size control */ |
| 24 | u32 lpm : 8; /* logical path mask */ |
| 25 | u32 ils : 1; /* incorrect length */ |
| 26 | u32 zero : 6; /* reserved zeros */ |
| 27 | u32 orbx : 1; /* ORB extension control */ |
| 28 | u32 cpa; /* channel program address */ |
| 29 | } __attribute__ ((packed, aligned(4))); |
| 30 | |
Peter Oberparleiter | 83262d6 | 2008-07-14 09:58:51 +0200 | [diff] [blame] | 31 | /* |
| 32 | * transport-mode operation request block |
| 33 | */ |
| 34 | struct tm_orb { |
| 35 | u32 intparm; |
| 36 | u32 key:4; |
| 37 | u32 :9; |
| 38 | u32 b:1; |
| 39 | u32 :2; |
| 40 | u32 lpm:8; |
| 41 | u32 :7; |
| 42 | u32 x:1; |
| 43 | u32 tcw; |
| 44 | u32 prio:8; |
| 45 | u32 :8; |
| 46 | u32 rsvpgm:8; |
| 47 | u32 :8; |
| 48 | u32 :32; |
| 49 | u32 :32; |
| 50 | u32 :32; |
| 51 | u32 :32; |
| 52 | } __attribute__ ((packed, aligned(4))); |
| 53 | |
| 54 | union orb { |
| 55 | struct cmd_orb cmd; |
| 56 | struct tm_orb tm; |
| 57 | } __attribute__ ((packed, aligned(4))); |
| 58 | |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 59 | struct io_subchannel_private { |
Peter Oberparleiter | 83262d6 | 2008-07-14 09:58:51 +0200 | [diff] [blame] | 60 | union orb orb; /* operation request block */ |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 61 | struct ccw1 sense_ccw; /* static ccw for sense command */ |
| 62 | } __attribute__ ((aligned(8))); |
| 63 | |
| 64 | #define to_io_private(n) ((struct io_subchannel_private *)n->private) |
Cornelia Huck | db6a642 | 2008-01-26 14:10:46 +0100 | [diff] [blame] | 65 | #define sch_get_cdev(n) (dev_get_drvdata(&n->dev)) |
| 66 | #define sch_set_cdev(n, c) (dev_set_drvdata(&n->dev, c)) |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 67 | |
| 68 | #define MAX_CIWS 8 |
| 69 | |
| 70 | /* |
| 71 | * sense-id response buffer layout |
| 72 | */ |
| 73 | struct senseid { |
| 74 | /* common part */ |
| 75 | u8 reserved; /* always 0x'FF' */ |
| 76 | u16 cu_type; /* control unit type */ |
| 77 | u8 cu_model; /* control unit model */ |
| 78 | u16 dev_type; /* device type */ |
| 79 | u8 dev_model; /* device model */ |
| 80 | u8 unused; /* padding byte */ |
| 81 | /* extended part */ |
| 82 | struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */ |
| 83 | } __attribute__ ((packed, aligned(4))); |
| 84 | |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 85 | enum cdev_todo { |
| 86 | CDEV_TODO_NOTHING, |
| 87 | CDEV_TODO_ENABLE_CMF, |
| 88 | CDEV_TODO_REBIND, |
| 89 | CDEV_TODO_REGISTER, |
| 90 | CDEV_TODO_UNREG, |
| 91 | CDEV_TODO_UNREG_EVAL, |
| 92 | }; |
| 93 | |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 94 | struct ccw_device_private { |
| 95 | struct ccw_device *cdev; |
| 96 | struct subchannel *sch; |
| 97 | int state; /* device state */ |
| 98 | atomic_t onoff; |
| 99 | unsigned long registered; |
| 100 | struct ccw_dev_id dev_id; /* device id */ |
| 101 | struct subchannel_id schid; /* subchannel number */ |
| 102 | u8 imask; /* lpm mask for SNID/SID/SPGID */ |
| 103 | int iretry; /* retry counter SNID/SID/SPGID */ |
| 104 | struct { |
| 105 | unsigned int fast:1; /* post with "channel end" */ |
| 106 | unsigned int repall:1; /* report every interrupt status */ |
| 107 | unsigned int pgroup:1; /* do path grouping */ |
| 108 | unsigned int force:1; /* allow forced online */ |
| 109 | } __attribute__ ((packed)) options; |
| 110 | struct { |
| 111 | unsigned int pgid_single:1; /* use single path for Set PGID */ |
| 112 | unsigned int esid:1; /* Ext. SenseID supported by HW */ |
| 113 | unsigned int dosense:1; /* delayed SENSE required */ |
| 114 | unsigned int doverify:1; /* delayed path verification */ |
| 115 | unsigned int donotify:1; /* call notify function */ |
| 116 | unsigned int recog_done:1; /* dev. recog. complete */ |
| 117 | unsigned int fake_irb:1; /* deliver faked irb */ |
| 118 | unsigned int intretry:1; /* retry internal operation */ |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 119 | unsigned int resuming:1; /* recognition while resume */ |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 120 | } __attribute__((packed)) flags; |
| 121 | unsigned long intparm; /* user interruption parameter */ |
| 122 | struct qdio_irq *qdio_data; |
| 123 | struct irb irb; /* device status */ |
| 124 | struct senseid senseid; /* SenseID info */ |
| 125 | struct pgid pgid[8]; /* path group IDs per chpid*/ |
| 126 | struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */ |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 127 | struct work_struct todo_work; |
| 128 | enum cdev_todo todo; |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 129 | wait_queue_head_t wait_q; |
| 130 | struct timer_list timer; |
| 131 | void *cmb; /* measurement information */ |
| 132 | struct list_head cmb_list; /* list of measured devices */ |
| 133 | u64 cmb_start_time; /* clock value of cmb reset */ |
| 134 | void *cmb_wait; /* deferred cmb enable/disable */ |
| 135 | }; |
| 136 | |
Peter Oberparleiter | f9c9fe3 | 2008-10-10 21:33:15 +0200 | [diff] [blame] | 137 | static inline int ssch(struct subchannel_id schid, union orb *addr) |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 138 | { |
| 139 | register struct subchannel_id reg1 asm("1") = schid; |
Peter Oberparleiter | 83262d6 | 2008-07-14 09:58:51 +0200 | [diff] [blame] | 140 | int ccode = -EIO; |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 141 | |
| 142 | asm volatile( |
| 143 | " ssch 0(%2)\n" |
Peter Oberparleiter | 83262d6 | 2008-07-14 09:58:51 +0200 | [diff] [blame] | 144 | "0: ipm %0\n" |
| 145 | " srl %0,28\n" |
| 146 | "1:\n" |
| 147 | EX_TABLE(0b, 1b) |
Peter Oberparleiter | f9c9fe3 | 2008-10-10 21:33:15 +0200 | [diff] [blame] | 148 | : "+d" (ccode) |
| 149 | : "d" (reg1), "a" (addr), "m" (*addr) |
| 150 | : "cc", "memory"); |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 151 | return ccode; |
| 152 | } |
| 153 | |
| 154 | static inline int rsch(struct subchannel_id schid) |
| 155 | { |
| 156 | register struct subchannel_id reg1 asm("1") = schid; |
| 157 | int ccode; |
| 158 | |
| 159 | asm volatile( |
| 160 | " rsch\n" |
| 161 | " ipm %0\n" |
| 162 | " srl %0,28" |
Peter Oberparleiter | f9c9fe3 | 2008-10-10 21:33:15 +0200 | [diff] [blame] | 163 | : "=d" (ccode) |
| 164 | : "d" (reg1) |
| 165 | : "cc", "memory"); |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 166 | return ccode; |
| 167 | } |
| 168 | |
| 169 | static inline int csch(struct subchannel_id schid) |
| 170 | { |
| 171 | register struct subchannel_id reg1 asm("1") = schid; |
| 172 | int ccode; |
| 173 | |
| 174 | asm volatile( |
| 175 | " csch\n" |
| 176 | " ipm %0\n" |
| 177 | " srl %0,28" |
Peter Oberparleiter | f9c9fe3 | 2008-10-10 21:33:15 +0200 | [diff] [blame] | 178 | : "=d" (ccode) |
| 179 | : "d" (reg1) |
| 180 | : "cc"); |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 181 | return ccode; |
| 182 | } |
| 183 | |
| 184 | static inline int hsch(struct subchannel_id schid) |
| 185 | { |
| 186 | register struct subchannel_id reg1 asm("1") = schid; |
| 187 | int ccode; |
| 188 | |
| 189 | asm volatile( |
| 190 | " hsch\n" |
| 191 | " ipm %0\n" |
| 192 | " srl %0,28" |
Peter Oberparleiter | f9c9fe3 | 2008-10-10 21:33:15 +0200 | [diff] [blame] | 193 | : "=d" (ccode) |
| 194 | : "d" (reg1) |
| 195 | : "cc"); |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 196 | return ccode; |
| 197 | } |
| 198 | |
| 199 | static inline int xsch(struct subchannel_id schid) |
| 200 | { |
| 201 | register struct subchannel_id reg1 asm("1") = schid; |
| 202 | int ccode; |
| 203 | |
| 204 | asm volatile( |
| 205 | " .insn rre,0xb2760000,%1,0\n" |
| 206 | " ipm %0\n" |
| 207 | " srl %0,28" |
Peter Oberparleiter | f9c9fe3 | 2008-10-10 21:33:15 +0200 | [diff] [blame] | 208 | : "=d" (ccode) |
| 209 | : "d" (reg1) |
| 210 | : "cc"); |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 211 | return ccode; |
| 212 | } |
| 213 | |
| 214 | #endif |