]>
Commit | Line | Data |
---|---|---|
4e43d779 | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
a3283d83 AD |
2 | /* |
3 | * Intel MIC Platform Software Stack (MPSS) | |
4 | * | |
5 | * Copyright(c) 2015 Intel Corporation. | |
6 | * | |
a3283d83 AD |
7 | * Intel MIC COSM Bus Driver |
8 | */ | |
9 | #ifndef _COSM_BUS_H_ | |
10 | #define _COSM_BUS_H_ | |
11 | ||
12 | #include <linux/scif.h> | |
13 | #include <linux/mic_common.h> | |
14 | #include "../common/mic_dev.h" | |
15 | ||
16 | /** | |
17 | * cosm_device - representation of a cosm device | |
18 | * | |
19 | * @attr_group: Pointer to list of sysfs attribute groups. | |
20 | * @sdev: Device for sysfs entries. | |
21 | * @state: MIC state. | |
f38e87e8 | 22 | * @prev_state: MIC state previous to MIC_RESETTING |
a3283d83 AD |
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 | |
43 | */ | |
44 | struct cosm_device { | |
45 | const struct attribute_group **attr_group; | |
46 | struct device *sdev; | |
47 | u8 state; | |
f38e87e8 | 48 | u8 prev_state; |
a3283d83 AD |
49 | u8 shutdown_status; |
50 | u8 shutdown_status_int; | |
51 | struct mutex cosm_mutex; | |
52 | struct work_struct reset_trigger_work; | |
53 | struct work_struct scif_work; | |
54 | char *cmdline; | |
55 | char *firmware; | |
56 | char *ramdisk; | |
57 | char *bootmode; | |
58 | void *log_buf_addr; | |
59 | int *log_buf_len; | |
60 | struct kernfs_node *state_sysfs; | |
61 | struct cosm_hw_ops *hw_ops; | |
62 | struct device dev; | |
63 | int index; | |
64 | struct dentry *dbg_dir; | |
65 | scif_epd_t newepd; | |
66 | scif_epd_t epd; | |
67 | bool heartbeat_watchdog_enable; | |
68 | bool sysfs_heartbeat_enable; | |
69 | }; | |
70 | ||
71 | /** | |
72 | * cosm_driver - operations for a cosm driver | |
73 | * | |
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. | |
77 | */ | |
78 | struct cosm_driver { | |
79 | struct device_driver driver; | |
80 | int (*probe)(struct cosm_device *dev); | |
81 | void (*remove)(struct cosm_device *dev); | |
82 | }; | |
83 | ||
84 | /** | |
85 | * cosm_hw_ops - cosm bus ops | |
86 | * | |
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 | |
91 | * @start: boot MIC | |
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 | |
96 | */ | |
97 | struct cosm_hw_ops { | |
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); | |
107 | }; | |
108 | ||
109 | struct cosm_device * | |
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); | |
115 | ||
116 | static inline struct cosm_device *dev_to_cosm(struct device *dev) | |
117 | { | |
118 | return container_of(dev, struct cosm_device, dev); | |
119 | } | |
120 | ||
121 | static inline struct cosm_driver *drv_to_cosm(struct device_driver *drv) | |
122 | { | |
123 | return container_of(drv, struct cosm_driver, driver); | |
124 | } | |
125 | #endif /* _COSM_BUS_H */ |