2 * Intel MIC Platform Software Stack (MPSS)
4 * Copyright(c) 2015 Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 2, as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * The full GNU General Public License is included in this distribution in
16 * the file called "COPYING".
18 * Intel MIC COSM Bus Driver
23 #include <linux/scif.h>
24 #include <linux/mic_common.h>
25 #include "../common/mic_dev.h"
28 * cosm_device - representation of a cosm device
30 * @attr_group: Pointer to list of sysfs attribute groups.
31 * @sdev: Device for sysfs entries.
33 * @prev_state: MIC state previous to MIC_RESETTING
34 * @shutdown_status: MIC status reported by card for shutdown/crashes.
35 * @shutdown_status_int: Internal shutdown status maintained by the driver
36 * @cosm_mutex: Mutex for synchronizing access to data structures.
37 * @reset_trigger_work: Work for triggering reset requests.
38 * @scif_work: Work for handling per device SCIF connections
39 * @cmdline: Kernel command line.
40 * @firmware: Firmware file name.
41 * @ramdisk: Ramdisk file name.
42 * @bootmode: Boot mode i.e. "linux" or "elf" for flash updates.
43 * @log_buf_addr: Log buffer address for MIC.
44 * @log_buf_len: Log buffer length address for MIC.
45 * @state_sysfs: Sysfs dirent for notifying ring 3 about MIC state changes.
46 * @hw_ops: the hardware bus ops for this device.
47 * @dev: underlying device.
48 * @index: unique position on the cosm bus
49 * @dbg_dir: debug fs directory
50 * @newepd: new endpoint from scif accept to be assigned to this cdev
51 * @epd: SCIF endpoint for this cdev
52 * @heartbeat_watchdog_enable: if heartbeat watchdog is enabled for this cdev
53 * @sysfs_heartbeat_enable: sysfs setting for disabling heartbeat notification
56 const struct attribute_group
**attr_group
;
61 u8 shutdown_status_int
;
62 struct mutex cosm_mutex
;
63 struct work_struct reset_trigger_work
;
64 struct work_struct scif_work
;
71 struct kernfs_node
*state_sysfs
;
72 struct cosm_hw_ops
*hw_ops
;
75 struct dentry
*dbg_dir
;
78 bool heartbeat_watchdog_enable
;
79 bool sysfs_heartbeat_enable
;
83 * cosm_driver - operations for a cosm driver
85 * @driver: underlying device driver (populate name and owner).
86 * @probe: the function to call when a device is found. Returns 0 or -errno.
87 * @remove: the function to call when a device is removed.
90 struct device_driver driver
;
91 int (*probe
)(struct cosm_device
*dev
);
92 void (*remove
)(struct cosm_device
*dev
);
96 * cosm_hw_ops - cosm bus ops
98 * @reset: trigger MIC reset
99 * @force_reset: force MIC reset
100 * @post_reset: inform MIC reset is complete
101 * @ready: is MIC ready for OS download
103 * @stop: prepare MIC for reset
104 * @family: return MIC HW family string
105 * @stepping: return MIC HW stepping string
106 * @aper: return MIC PCIe aperture
109 void (*reset
)(struct cosm_device
*cdev
);
110 void (*force_reset
)(struct cosm_device
*cdev
);
111 void (*post_reset
)(struct cosm_device
*cdev
, enum mic_states state
);
112 bool (*ready
)(struct cosm_device
*cdev
);
113 int (*start
)(struct cosm_device
*cdev
, int id
);
114 void (*stop
)(struct cosm_device
*cdev
, bool force
);
115 ssize_t (*family
)(struct cosm_device
*cdev
, char *buf
);
116 ssize_t (*stepping
)(struct cosm_device
*cdev
, char *buf
);
117 struct mic_mw
*(*aper
)(struct cosm_device
*cdev
);
121 cosm_register_device(struct device
*pdev
, struct cosm_hw_ops
*hw_ops
);
122 void cosm_unregister_device(struct cosm_device
*dev
);
123 int cosm_register_driver(struct cosm_driver
*drv
);
124 void cosm_unregister_driver(struct cosm_driver
*drv
);
125 struct cosm_device
*cosm_find_cdev_by_id(int id
);
127 static inline struct cosm_device
*dev_to_cosm(struct device
*dev
)
129 return container_of(dev
, struct cosm_device
, dev
);
132 static inline struct cosm_driver
*drv_to_cosm(struct device_driver
*drv
)
134 return container_of(drv
, struct cosm_driver
, driver
);
136 #endif /* _COSM_BUS_H */