fw_type == PCI_CFG_HFS_3_FW_SKU_SPS;
}
-#define MEI_CFG_KIND_ITOUCH \
- .kind = "itouch"
+#define MEI_CFG_FW_SPS_IGN \
+ .quirk_probe = mei_me_fw_type_sps_ign
-#define MEI_CFG_TYPE_GSC \
- .kind = "gsc"
+static enum mei_dev_kind mei_cfg_kind_mei(const struct device *parent)
+{
+ return MEI_DEV_KIND_MEI;
+}
-#define MEI_CFG_TYPE_GSCFI \
- .kind = "gscfi"
+#define MEI_CFG_KIND_MEI \
+ .get_kind = mei_cfg_kind_mei
-#define MEI_CFG_FW_SPS_IGN \
- .quirk_probe = mei_me_fw_type_sps_ign
+static enum mei_dev_kind mei_cfg_kind_itouch(const struct device *parent)
+{
+ return MEI_DEV_KIND_ITOUCH;
+}
+
+#define MEI_CFG_KIND_ITOUCH \
+ .get_kind = mei_cfg_kind_itouch
+
+static enum mei_dev_kind mei_cfg_kind_gsc(const struct device *parent)
+{
+ return MEI_DEV_KIND_GSC;
+}
+
+#define MEI_CFG_KIND_GSC \
+ .get_kind = mei_cfg_kind_gsc
+
+static enum mei_dev_kind mei_cfg_kind_gscfi(const struct device *parent)
+{
+ return MEI_DEV_KIND_GSCFI;
+}
+
+#define MEI_CFG_KIND_GSCFI \
+ .get_kind = mei_cfg_kind_gscfi
#define MEI_CFG_FW_VER_SUPP \
.fw_ver_supported = 1
/* ICH Legacy devices */
static const struct mei_cfg mei_me_ich_cfg = {
+ MEI_CFG_KIND_MEI,
MEI_CFG_ICH_HFS,
};
/* ICH devices */
static const struct mei_cfg mei_me_ich10_cfg = {
+ MEI_CFG_KIND_MEI,
MEI_CFG_ICH10_HFS,
};
/* PCH6 devices */
static const struct mei_cfg mei_me_pch6_cfg = {
+ MEI_CFG_KIND_MEI,
MEI_CFG_PCH_HFS,
};
/* PCH7 devices */
static const struct mei_cfg mei_me_pch7_cfg = {
+ MEI_CFG_KIND_MEI,
MEI_CFG_PCH_HFS,
MEI_CFG_FW_VER_SUPP,
};
/* PCH Cougar Point and Patsburg with quirk for Node Manager exclusion */
static const struct mei_cfg mei_me_pch_cpt_pbg_cfg = {
+ MEI_CFG_KIND_MEI,
MEI_CFG_PCH_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_FW_NM,
/* PCH8 Lynx Point and newer devices */
static const struct mei_cfg mei_me_pch8_cfg = {
+ MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
};
/* PCH8 Lynx Point with quirk for SPS Firmware exclusion */
static const struct mei_cfg mei_me_pch8_sps_4_cfg = {
+ MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_FW_SPS_4,
/* LBG with quirk for SPS (4.0) Firmware exclusion */
static const struct mei_cfg mei_me_pch12_sps_4_cfg = {
+ MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_FW_SPS_4,
/* Cannon Lake and newer devices */
static const struct mei_cfg mei_me_pch12_cfg = {
+ MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_DMA_128,
/* Cannon Lake with quirk for SPS 5.0 and newer Firmware exclusion */
static const struct mei_cfg mei_me_pch12_sps_cfg = {
+ MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_DMA_128,
/* Tiger Lake and newer devices */
static const struct mei_cfg mei_me_pch15_cfg = {
+ MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_DMA_128,
/* Tiger Lake with quirk for SPS 5.0 and newer Firmware exclusion */
static const struct mei_cfg mei_me_pch15_sps_cfg = {
+ MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_DMA_128,
/* Graphics System Controller */
static const struct mei_cfg mei_me_gsc_cfg = {
- MEI_CFG_TYPE_GSC,
+ MEI_CFG_KIND_GSC,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
};
/* Graphics System Controller Firmware Interface */
static const struct mei_cfg mei_me_gscfi_cfg = {
- MEI_CFG_TYPE_GSCFI,
+ MEI_CFG_KIND_GSCFI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
};
/* Chassis System Controller Firmware Interface */
static const struct mei_cfg mei_me_csc_cfg = {
- MEI_CFG_TYPE_GSCFI,
+ MEI_CFG_KIND_GSCFI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
};
dev->fw_f_fw_ver_supported = cfg->fw_ver_supported;
- dev->kind = cfg->kind;
+ dev->kind = cfg->get_kind(parent);
return dev;
}
}
}
+static const char * const mei_kind_names[] = {
+ "mei",
+ "itouch",
+ "gsc",
+ "gscfi",
+ "ivsc",
+};
+static_assert(ARRAY_SIZE(mei_kind_names) == MEI_DEV_KIND_MAX);
+
/**
* kind_show - display device kind
*
struct device_attribute *attr, char *buf)
{
struct mei_device *dev = dev_get_drvdata(device);
- ssize_t ret;
- if (dev->kind)
- ret = sprintf(buf, "%s\n", dev->kind);
- else
- ret = sprintf(buf, "%s\n", "mei");
+ if (dev->kind < MEI_DEV_KIND_MEI || dev->kind >= MEI_DEV_KIND_MAX)
+ return -EINVAL;
- return ret;
+ return sysfs_emit(buf, "%s\n", mei_kind_names[dev->kind]);
}
static DEVICE_ATTR_RO(kind);
unsigned long link_reset_wait; /* link reset wait timeout, in jiffies */
};
+/**
+ * enum mei_dev_kind - device type
+ *
+ * @MEI_DEV_KIND_MEI: basic device
+ * @MEI_DEV_KIND_ITOUCH: itouch support
+ * @MEI_DEV_KIND_GSC: discete graphics content protection
+ * @MEI_DEV_KIND_GSCFI: discete graphics chassis controller
+ * @MEI_DEV_KIND_IVSC: visual sensing controller
+ * @MEI_DEV_KIND_MAX: sentinel
+ */
+enum mei_dev_kind {
+ MEI_DEV_KIND_MEI,
+ MEI_DEV_KIND_ITOUCH,
+ MEI_DEV_KIND_GSC,
+ MEI_DEV_KIND_GSCFI,
+ MEI_DEV_KIND_IVSC,
+ MEI_DEV_KIND_MAX
+};
+
/**
* struct mei_device - MEI private device struct
*
struct list_head device_list;
struct mutex cl_bus_lock;
- const char *kind;
+ enum mei_dev_kind kind;
#if IS_ENABLED(CONFIG_DEBUG_FS)
struct dentry *dbgfs_dir;
*/
static inline bool kind_is_gsc(struct mei_device *dev)
{
- /* check kind for NULL because it may be not set, like at the fist call to hw_start */
- return dev->kind && (strcmp(dev->kind, "gsc") == 0);
+ return dev->kind == MEI_DEV_KIND_GSC;
}
/**
*/
static inline bool kind_is_gscfi(struct mei_device *dev)
{
- /* check kind for NULL because it may be not set, like at the fist call to hw_start */
- return dev->kind && (strcmp(dev->kind, "gscfi") == 0);
+ return dev->kind == MEI_DEV_KIND_GSCFI;
}
#endif