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 * @shutdown_status: MIC status reported by card for shutdown/crashes.
34 * @shutdown_status_int: Internal shutdown status maintained by the driver
35 * @cosm_mutex: Mutex for synchronizing access to data structures.
36 * @reset_trigger_work: Work for triggering reset requests.
37 * @scif_work: Work for handling per device SCIF connections
38 * @cmdline: Kernel command line.
39 * @firmware: Firmware file name.
40 * @ramdisk: Ramdisk file name.
41 * @bootmode: Boot mode i.e. "linux" or "elf" for flash updates.
42 * @log_buf_addr: Log buffer address for MIC.
43 * @log_buf_len: Log buffer length address for MIC.
44 * @state_sysfs: Sysfs dirent for notifying ring 3 about MIC state changes.
45 * @hw_ops: the hardware bus ops for this device.
46 * @dev: underlying device.
47 * @index: unique position on the cosm bus
48 * @dbg_dir: debug fs directory
49 * @newepd: new endpoint from scif accept to be assigned to this cdev
50 * @epd: SCIF endpoint for this cdev
51 * @heartbeat_watchdog_enable: if heartbeat watchdog is enabled for this cdev
52 * @sysfs_heartbeat_enable: sysfs setting for disabling heartbeat notification
55 const struct attribute_group **attr_group;
59 u8 shutdown_status_int;
60 struct mutex cosm_mutex;
61 struct work_struct reset_trigger_work;
62 struct work_struct scif_work;
69 struct kernfs_node *state_sysfs;
70 struct cosm_hw_ops *hw_ops;
73 struct dentry *dbg_dir;
76 bool heartbeat_watchdog_enable;
77 bool sysfs_heartbeat_enable;
81 * cosm_driver - operations for a cosm driver
83 * @driver: underlying device driver (populate name and owner).
84 * @probe: the function to call when a device is found. Returns 0 or -errno.
85 * @remove: the function to call when a device is removed.
88 struct device_driver driver;
89 int (*probe)(struct cosm_device *dev);
90 void (*remove)(struct cosm_device *dev);
94 * cosm_hw_ops - cosm bus ops
96 * @reset: trigger MIC reset
97 * @force_reset: force MIC reset
98 * @post_reset: inform MIC reset is complete
99 * @ready: is MIC ready for OS download
101 * @stop: prepare MIC for reset
102 * @family: return MIC HW family string
103 * @stepping: return MIC HW stepping string
104 * @aper: return MIC PCIe aperture
107 void (*reset)(struct cosm_device *cdev);
108 void (*force_reset)(struct cosm_device *cdev);
109 void (*post_reset)(struct cosm_device *cdev, enum mic_states state);
110 bool (*ready)(struct cosm_device *cdev);
111 int (*start)(struct cosm_device *cdev, int id);
112 void (*stop)(struct cosm_device *cdev, bool force);
113 ssize_t (*family)(struct cosm_device *cdev, char *buf);
114 ssize_t (*stepping)(struct cosm_device *cdev, char *buf);
115 struct mic_mw *(*aper)(struct cosm_device *cdev);
119 cosm_register_device(struct device *pdev, struct cosm_hw_ops *hw_ops);
120 void cosm_unregister_device(struct cosm_device *dev);
121 int cosm_register_driver(struct cosm_driver *drv);
122 void cosm_unregister_driver(struct cosm_driver *drv);
123 struct cosm_device *cosm_find_cdev_by_id(int id);
125 static inline struct cosm_device *dev_to_cosm(struct device *dev)
127 return container_of(dev, struct cosm_device, dev);
130 static inline struct cosm_driver *drv_to_cosm(struct device_driver *drv)
132 return container_of(drv, struct cosm_driver, driver);
134 #endif /* _COSM_BUS_H */