Linux Audio

Check our new training course

Loading...
v6.2
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
  3 * Copyright IBM Corp. 2002, 2009
  4 *
  5 * Author(s): Arnd Bergmann <arndb@de.ibm.com>
  6 *
  7 * Interface for CCW device drivers
  8 */
  9#ifndef _S390_CCWDEV_H_
 10#define _S390_CCWDEV_H_
 11
 12#include <linux/device.h>
 13#include <linux/mod_devicetable.h>
 14#include <asm/chsc.h>
 15#include <asm/fcx.h>
 16#include <asm/irq.h>
 17#include <asm/schid.h>
 18
 19/* structs from asm/cio.h */
 20struct irb;
 21struct ccw1;
 22struct ccw_dev_id;
 23
 24/* simplified initializers for struct ccw_device:
 25 * CCW_DEVICE and CCW_DEVICE_DEVTYPE initialize one
 26 * entry in your MODULE_DEVICE_TABLE and set the match_flag correctly */
 27#define CCW_DEVICE(cu, cum) 						\
 28	.cu_type=(cu), .cu_model=(cum),					\
 29	.match_flags=(CCW_DEVICE_ID_MATCH_CU_TYPE			\
 30		   | (cum ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0))
 31
 32#define CCW_DEVICE_DEVTYPE(cu, cum, dev, devm)				\
 33	.cu_type=(cu), .cu_model=(cum), .dev_type=(dev), .dev_model=(devm),\
 34	.match_flags=CCW_DEVICE_ID_MATCH_CU_TYPE			\
 35		   | ((cum) ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0) 	\
 36		   | CCW_DEVICE_ID_MATCH_DEVICE_TYPE			\
 37		   | ((devm) ? CCW_DEVICE_ID_MATCH_DEVICE_MODEL : 0)
 38
 39/* scan through an array of device ids and return the first
 40 * entry that matches the device.
 41 *
 42 * the array must end with an entry containing zero match_flags
 43 */
 44static inline const struct ccw_device_id *
 45ccw_device_id_match(const struct ccw_device_id *array,
 46			const struct ccw_device_id *match)
 47{
 48	const struct ccw_device_id *id = array;
 49
 50	for (id = array; id->match_flags; id++) {
 51		if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_TYPE)
 52		    && (id->cu_type != match->cu_type))
 53			continue;
 54
 55		if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_MODEL)
 56		    && (id->cu_model != match->cu_model))
 57			continue;
 58
 59		if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_TYPE)
 60		    && (id->dev_type != match->dev_type))
 61			continue;
 62
 63		if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_MODEL)
 64		    && (id->dev_model != match->dev_model))
 65			continue;
 66
 67		return id;
 68	}
 69
 70	return NULL;
 71}
 72
 73/**
 74 * struct ccw_device - channel attached device
 75 * @ccwlock: pointer to device lock
 76 * @id: id of this device
 77 * @drv: ccw driver for this device
 78 * @dev: embedded device structure
 79 * @online: online status of device
 80 * @handler: interrupt handler
 81 *
 82 * @handler is a member of the device rather than the driver since a driver
 83 * can have different interrupt handlers for different ccw devices
 84 * (multi-subchannel drivers).
 85 */
 86struct ccw_device {
 87	spinlock_t *ccwlock;
 88/* private: */
 89	struct ccw_device_private *private;	/* cio private information */
 90/* public: */
 91	struct ccw_device_id id;
 92	struct ccw_driver *drv;
 93	struct device dev;
 94	int online;
 95	void (*handler) (struct ccw_device *, unsigned long, struct irb *);
 96};
 97
 98/*
 99 * Possible events used by the path_event notifier.
100 */
101#define PE_NONE				0x0
102#define PE_PATH_GONE			0x1 /* A path is no longer available. */
103#define PE_PATH_AVAILABLE		0x2 /* A path has become available and
104					       was successfully verified. */
105#define PE_PATHGROUP_ESTABLISHED	0x4 /* A pathgroup was reset and had
106					       to be established again. */
107#define PE_PATH_FCES_EVENT		0x8 /* The FCES Status of a path has
108					     * changed. */
109
110/*
111 * Possible CIO actions triggered by the unit check handler.
112 */
113enum uc_todo {
114	UC_TODO_RETRY,
115	UC_TODO_RETRY_ON_NEW_PATH,
116	UC_TODO_STOP
117};
118
119/**
120 * struct ccw_driver - device driver for channel attached devices
121 * @ids: ids supported by this driver
122 * @probe: function called on probe
123 * @remove: function called on remove
124 * @set_online: called when setting device online
125 * @set_offline: called when setting device offline
126 * @notify: notify driver of device state changes
127 * @path_event: notify driver of channel path events
128 * @shutdown: called at device shutdown
 
 
 
 
 
129 * @uc_handler: callback for unit check handler
130 * @driver: embedded device driver structure
131 * @int_class: interruption class to use for accounting interrupts
132 */
133struct ccw_driver {
134	struct ccw_device_id *ids;
135	int (*probe) (struct ccw_device *);
136	void (*remove) (struct ccw_device *);
137	int (*set_online) (struct ccw_device *);
138	int (*set_offline) (struct ccw_device *);
139	int (*notify) (struct ccw_device *, int);
140	void (*path_event) (struct ccw_device *, int *);
141	void (*shutdown) (struct ccw_device *);
 
 
 
 
 
142	enum uc_todo (*uc_handler) (struct ccw_device *, struct irb *);
143	struct device_driver driver;
144	enum interruption_class int_class;
145};
146
147extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
148					      const char *bus_id);
149
150/* devices drivers call these during module load and unload.
151 * When a driver is registered, its probe method is called
152 * when new devices for its type pop up */
153extern int  ccw_driver_register   (struct ccw_driver *driver);
154extern void ccw_driver_unregister (struct ccw_driver *driver);
 
 
 
155extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long);
156extern int ccw_device_set_options(struct ccw_device *, unsigned long);
157extern void ccw_device_clear_options(struct ccw_device *, unsigned long);
158int ccw_device_is_pathgroup(struct ccw_device *cdev);
159int ccw_device_is_multipath(struct ccw_device *cdev);
160
161/* Allow for i/o completion notification after primary interrupt status. */
162#define CCWDEV_EARLY_NOTIFICATION	0x0001
163/* Report all interrupt conditions. */
164#define CCWDEV_REPORT_ALL	 	0x0002
165/* Try to perform path grouping. */
166#define CCWDEV_DO_PATHGROUP             0x0004
167/* Allow forced onlining of boxed devices. */
168#define CCWDEV_ALLOW_FORCE              0x0008
169/* Try to use multipath mode. */
170#define CCWDEV_DO_MULTIPATH		0x0010
171
172extern int ccw_device_start(struct ccw_device *, struct ccw1 *,
173			    unsigned long, __u8, unsigned long);
174extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *,
175				    unsigned long, __u8, unsigned long, int);
176extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *,
177				unsigned long, __u8, __u8, unsigned long);
178extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *,
179					unsigned long, __u8, __u8,
180					unsigned long, int);
181
182
183extern int ccw_device_resume(struct ccw_device *);
184extern int ccw_device_halt(struct ccw_device *, unsigned long);
185extern int ccw_device_clear(struct ccw_device *, unsigned long);
186int ccw_device_tm_start_key(struct ccw_device *cdev, struct tcw *tcw,
187			    unsigned long intparm, u8 lpm, u8 key);
188int ccw_device_tm_start_key(struct ccw_device *, struct tcw *,
189			    unsigned long, u8, u8);
190int ccw_device_tm_start_timeout_key(struct ccw_device *, struct tcw *,
191			    unsigned long, u8, u8, int);
192int ccw_device_tm_start(struct ccw_device *, struct tcw *,
193			    unsigned long, u8);
194int ccw_device_tm_start_timeout(struct ccw_device *, struct tcw *,
195			    unsigned long, u8, int);
196int ccw_device_tm_intrg(struct ccw_device *cdev);
197
198int ccw_device_get_mdc(struct ccw_device *cdev, u8 mask);
199
200extern int ccw_device_set_online(struct ccw_device *cdev);
201extern int ccw_device_set_offline(struct ccw_device *cdev);
202
203
204extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
205extern __u8 ccw_device_get_path_mask(struct ccw_device *);
206extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
207
208#define get_ccwdev_lock(x) (x)->ccwlock
209
210#define to_ccwdev(n) container_of(n, struct ccw_device, dev)
211#define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
212
213extern struct ccw_device *ccw_device_create_console(struct ccw_driver *);
214extern void ccw_device_destroy_console(struct ccw_device *);
215extern int ccw_device_enable_console(struct ccw_device *);
216extern void ccw_device_wait_idle(struct ccw_device *);
217
218extern void *ccw_device_dma_zalloc(struct ccw_device *cdev, size_t size);
219extern void ccw_device_dma_free(struct ccw_device *cdev,
220				void *cpu_addr, size_t size);
221
222int ccw_device_siosl(struct ccw_device *);
223
224extern void ccw_device_get_schid(struct ccw_device *, struct subchannel_id *);
 
225
226struct channel_path_desc_fmt0 *ccw_device_get_chp_desc(struct ccw_device *, int);
227u8 *ccw_device_get_util_str(struct ccw_device *cdev, int chp_idx);
228int ccw_device_pnso(struct ccw_device *cdev,
229		    struct chsc_pnso_area *pnso_area, u8 oc,
230		    struct chsc_pnso_resume_token resume_token, int cnc);
231int ccw_device_get_cssid(struct ccw_device *cdev, u8 *cssid);
232int ccw_device_get_iid(struct ccw_device *cdev, u8 *iid);
233int ccw_device_get_chpid(struct ccw_device *cdev, int chp_idx, u8 *chpid);
234int ccw_device_get_chid(struct ccw_device *cdev, int chp_idx, u16 *chid);
235#endif /* _S390_CCWDEV_H_ */
v3.1
 
  1/*
  2 * Copyright  IBM Corp. 2002, 2009
  3 *
  4 * Author(s): Arnd Bergmann <arndb@de.ibm.com>
  5 *
  6 * Interface for CCW device drivers
  7 */
  8#ifndef _S390_CCWDEV_H_
  9#define _S390_CCWDEV_H_
 10
 11#include <linux/device.h>
 12#include <linux/mod_devicetable.h>
 
 13#include <asm/fcx.h>
 
 
 14
 15/* structs from asm/cio.h */
 16struct irb;
 17struct ccw1;
 18struct ccw_dev_id;
 19
 20/* simplified initializers for struct ccw_device:
 21 * CCW_DEVICE and CCW_DEVICE_DEVTYPE initialize one
 22 * entry in your MODULE_DEVICE_TABLE and set the match_flag correctly */
 23#define CCW_DEVICE(cu, cum) 						\
 24	.cu_type=(cu), .cu_model=(cum),					\
 25	.match_flags=(CCW_DEVICE_ID_MATCH_CU_TYPE			\
 26		   | (cum ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0))
 27
 28#define CCW_DEVICE_DEVTYPE(cu, cum, dev, devm)				\
 29	.cu_type=(cu), .cu_model=(cum), .dev_type=(dev), .dev_model=(devm),\
 30	.match_flags=CCW_DEVICE_ID_MATCH_CU_TYPE			\
 31		   | ((cum) ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0) 	\
 32		   | CCW_DEVICE_ID_MATCH_DEVICE_TYPE			\
 33		   | ((devm) ? CCW_DEVICE_ID_MATCH_DEVICE_MODEL : 0)
 34
 35/* scan through an array of device ids and return the first
 36 * entry that matches the device.
 37 *
 38 * the array must end with an entry containing zero match_flags
 39 */
 40static inline const struct ccw_device_id *
 41ccw_device_id_match(const struct ccw_device_id *array,
 42			const struct ccw_device_id *match)
 43{
 44	const struct ccw_device_id *id = array;
 45
 46	for (id = array; id->match_flags; id++) {
 47		if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_TYPE)
 48		    && (id->cu_type != match->cu_type))
 49			continue;
 50
 51		if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_MODEL)
 52		    && (id->cu_model != match->cu_model))
 53			continue;
 54
 55		if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_TYPE)
 56		    && (id->dev_type != match->dev_type))
 57			continue;
 58
 59		if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_MODEL)
 60		    && (id->dev_model != match->dev_model))
 61			continue;
 62
 63		return id;
 64	}
 65
 66	return NULL;
 67}
 68
 69/**
 70 * struct ccw_device - channel attached device
 71 * @ccwlock: pointer to device lock
 72 * @id: id of this device
 73 * @drv: ccw driver for this device
 74 * @dev: embedded device structure
 75 * @online: online status of device
 76 * @handler: interrupt handler
 77 *
 78 * @handler is a member of the device rather than the driver since a driver
 79 * can have different interrupt handlers for different ccw devices
 80 * (multi-subchannel drivers).
 81 */
 82struct ccw_device {
 83	spinlock_t *ccwlock;
 84/* private: */
 85	struct ccw_device_private *private;	/* cio private information */
 86/* public: */
 87	struct ccw_device_id id;
 88	struct ccw_driver *drv;
 89	struct device dev;
 90	int online;
 91	void (*handler) (struct ccw_device *, unsigned long, struct irb *);
 92};
 93
 94/*
 95 * Possible events used by the path_event notifier.
 96 */
 97#define PE_NONE				0x0
 98#define PE_PATH_GONE			0x1 /* A path is no longer available. */
 99#define PE_PATH_AVAILABLE		0x2 /* A path has become available and
100					       was successfully verified. */
101#define PE_PATHGROUP_ESTABLISHED	0x4 /* A pathgroup was reset and had
102					       to be established again. */
 
 
103
104/*
105 * Possible CIO actions triggered by the unit check handler.
106 */
107enum uc_todo {
108	UC_TODO_RETRY,
109	UC_TODO_RETRY_ON_NEW_PATH,
110	UC_TODO_STOP
111};
112
113/**
114 * struct ccw driver - device driver for channel attached devices
115 * @ids: ids supported by this driver
116 * @probe: function called on probe
117 * @remove: function called on remove
118 * @set_online: called when setting device online
119 * @set_offline: called when setting device offline
120 * @notify: notify driver of device state changes
121 * @path_event: notify driver of channel path events
122 * @shutdown: called at device shutdown
123 * @prepare: prepare for pm state transition
124 * @complete: undo work done in @prepare
125 * @freeze: callback for freezing during hibernation snapshotting
126 * @thaw: undo work done in @freeze
127 * @restore: callback for restoring after hibernation
128 * @uc_handler: callback for unit check handler
129 * @driver: embedded device driver structure
 
130 */
131struct ccw_driver {
132	struct ccw_device_id *ids;
133	int (*probe) (struct ccw_device *);
134	void (*remove) (struct ccw_device *);
135	int (*set_online) (struct ccw_device *);
136	int (*set_offline) (struct ccw_device *);
137	int (*notify) (struct ccw_device *, int);
138	void (*path_event) (struct ccw_device *, int *);
139	void (*shutdown) (struct ccw_device *);
140	int (*prepare) (struct ccw_device *);
141	void (*complete) (struct ccw_device *);
142	int (*freeze)(struct ccw_device *);
143	int (*thaw) (struct ccw_device *);
144	int (*restore)(struct ccw_device *);
145	enum uc_todo (*uc_handler) (struct ccw_device *, struct irb *);
146	struct device_driver driver;
 
147};
148
149extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
150					      const char *bus_id);
151
152/* devices drivers call these during module load and unload.
153 * When a driver is registered, its probe method is called
154 * when new devices for its type pop up */
155extern int  ccw_driver_register   (struct ccw_driver *driver);
156extern void ccw_driver_unregister (struct ccw_driver *driver);
157
158struct ccw1;
159
160extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long);
161extern int ccw_device_set_options(struct ccw_device *, unsigned long);
162extern void ccw_device_clear_options(struct ccw_device *, unsigned long);
163int ccw_device_is_pathgroup(struct ccw_device *cdev);
164int ccw_device_is_multipath(struct ccw_device *cdev);
165
166/* Allow for i/o completion notification after primary interrupt status. */
167#define CCWDEV_EARLY_NOTIFICATION	0x0001
168/* Report all interrupt conditions. */
169#define CCWDEV_REPORT_ALL	 	0x0002
170/* Try to perform path grouping. */
171#define CCWDEV_DO_PATHGROUP             0x0004
172/* Allow forced onlining of boxed devices. */
173#define CCWDEV_ALLOW_FORCE              0x0008
174/* Try to use multipath mode. */
175#define CCWDEV_DO_MULTIPATH		0x0010
176
177extern int ccw_device_start(struct ccw_device *, struct ccw1 *,
178			    unsigned long, __u8, unsigned long);
179extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *,
180				    unsigned long, __u8, unsigned long, int);
181extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *,
182				unsigned long, __u8, __u8, unsigned long);
183extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *,
184					unsigned long, __u8, __u8,
185					unsigned long, int);
186
187
188extern int ccw_device_resume(struct ccw_device *);
189extern int ccw_device_halt(struct ccw_device *, unsigned long);
190extern int ccw_device_clear(struct ccw_device *, unsigned long);
191int ccw_device_tm_start_key(struct ccw_device *cdev, struct tcw *tcw,
192			    unsigned long intparm, u8 lpm, u8 key);
193int ccw_device_tm_start_key(struct ccw_device *, struct tcw *,
194			    unsigned long, u8, u8);
195int ccw_device_tm_start_timeout_key(struct ccw_device *, struct tcw *,
196			    unsigned long, u8, u8, int);
197int ccw_device_tm_start(struct ccw_device *, struct tcw *,
198			    unsigned long, u8);
199int ccw_device_tm_start_timeout(struct ccw_device *, struct tcw *,
200			    unsigned long, u8, int);
201int ccw_device_tm_intrg(struct ccw_device *cdev);
202
203int ccw_device_get_mdc(struct ccw_device *cdev, u8 mask);
204
205extern int ccw_device_set_online(struct ccw_device *cdev);
206extern int ccw_device_set_offline(struct ccw_device *cdev);
207
208
209extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
210extern __u8 ccw_device_get_path_mask(struct ccw_device *);
211extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
212
213#define get_ccwdev_lock(x) (x)->ccwlock
214
215#define to_ccwdev(n) container_of(n, struct ccw_device, dev)
216#define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
217
218extern struct ccw_device *ccw_device_probe_console(void);
219extern int ccw_device_force_console(void);
 
 
 
 
 
 
220
221int ccw_device_siosl(struct ccw_device *);
222
223// FIXME: these have to go
224extern int _ccw_device_get_subchannel_number(struct ccw_device *);
225
226extern void *ccw_device_get_chp_desc(struct ccw_device *, int);
 
 
 
 
 
 
 
 
227#endif /* _S390_CCWDEV_H_ */