1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Intel MIC Platform Software Stack (MPSS)
5 * Copyright(c) 2015 Intel Corporation.
7 * Intel MIC COSM Bus Driver
12 #include <linux/scif.h>
13 #include <linux/mic_common.h>
14 #include "../common/mic_dev.h"
17 * cosm_device - representation of a cosm device
19 * @attr_group: Pointer to list of sysfs attribute groups.
20 * @sdev: Device for sysfs entries.
22 * @prev_state: MIC state previous to MIC_RESETTING
23 * @shutdown_status: MIC status reported by card for shutdown/crashes.
24 * @shutdown_status_int: Internal shutdown status maintained by the driver
25 * @cosm_mutex: Mutex for synchronizing access to data structures.
26 * @reset_trigger_work: Work for triggering reset requests.
27 * @scif_work: Work for handling per device SCIF connections
28 * @cmdline: Kernel command line.
29 * @firmware: Firmware file name.
30 * @ramdisk: Ramdisk file name.
31 * @bootmode: Boot mode i.e. "linux" or "elf" for flash updates.
32 * @log_buf_addr: Log buffer address for MIC.
33 * @log_buf_len: Log buffer length address for MIC.
34 * @state_sysfs: Sysfs dirent for notifying ring 3 about MIC state changes.
35 * @hw_ops: the hardware bus ops for this device.
36 * @dev: underlying device.
37 * @index: unique position on the cosm bus
38 * @dbg_dir: debug fs directory
39 * @newepd: new endpoint from scif accept to be assigned to this cdev
40 * @epd: SCIF endpoint for this cdev
41 * @heartbeat_watchdog_enable: if heartbeat watchdog is enabled for this cdev
42 * @sysfs_heartbeat_enable: sysfs setting for disabling heartbeat notification
45 const struct attribute_group
**attr_group
;
50 u8 shutdown_status_int
;
51 struct mutex cosm_mutex
;
52 struct work_struct reset_trigger_work
;
53 struct work_struct scif_work
;
60 struct kernfs_node
*state_sysfs
;
61 struct cosm_hw_ops
*hw_ops
;
64 struct dentry
*dbg_dir
;
67 bool heartbeat_watchdog_enable
;
68 bool sysfs_heartbeat_enable
;
72 * cosm_driver - operations for a cosm driver
74 * @driver: underlying device driver (populate name and owner).
75 * @probe: the function to call when a device is found. Returns 0 or -errno.
76 * @remove: the function to call when a device is removed.
79 struct device_driver driver
;
80 int (*probe
)(struct cosm_device
*dev
);
81 void (*remove
)(struct cosm_device
*dev
);
85 * cosm_hw_ops - cosm bus ops
87 * @reset: trigger MIC reset
88 * @force_reset: force MIC reset
89 * @post_reset: inform MIC reset is complete
90 * @ready: is MIC ready for OS download
92 * @stop: prepare MIC for reset
93 * @family: return MIC HW family string
94 * @stepping: return MIC HW stepping string
95 * @aper: return MIC PCIe aperture
98 void (*reset
)(struct cosm_device
*cdev
);
99 void (*force_reset
)(struct cosm_device
*cdev
);
100 void (*post_reset
)(struct cosm_device
*cdev
, enum mic_states state
);
101 bool (*ready
)(struct cosm_device
*cdev
);
102 int (*start
)(struct cosm_device
*cdev
, int id
);
103 void (*stop
)(struct cosm_device
*cdev
, bool force
);
104 ssize_t (*family
)(struct cosm_device
*cdev
, char *buf
);
105 ssize_t (*stepping
)(struct cosm_device
*cdev
, char *buf
);
106 struct mic_mw
*(*aper
)(struct cosm_device
*cdev
);
110 cosm_register_device(struct device
*pdev
, struct cosm_hw_ops
*hw_ops
);
111 void cosm_unregister_device(struct cosm_device
*dev
);
112 int cosm_register_driver(struct cosm_driver
*drv
);
113 void cosm_unregister_driver(struct cosm_driver
*drv
);
114 struct cosm_device
*cosm_find_cdev_by_id(int id
);
116 static inline struct cosm_device
*dev_to_cosm(struct device
*dev
)
118 return container_of(dev
, struct cosm_device
, dev
);
121 static inline struct cosm_driver
*drv_to_cosm(struct device_driver
*drv
)
123 return container_of(drv
, struct cosm_driver
, driver
);
125 #endif /* _COSM_BUS_H */