diff options
Diffstat (limited to 'drivers/hid/intel-ish-hid')
-rw-r--r-- | drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h | 8 | ||||
-rw-r--r-- | drivers/hid/intel-ish-hid/ipc/hw-ish.h | 12 | ||||
-rw-r--r-- | drivers/hid/intel-ish-hid/ipc/pci-ish.c | 38 | ||||
-rw-r--r-- | drivers/hid/intel-ish-hid/ishtp-hid.c | 2 | ||||
-rw-r--r-- | drivers/hid/intel-ish-hid/ishtp/bus.c | 2 | ||||
-rw-r--r-- | drivers/hid/intel-ish-hid/ishtp/hbm.c | 1 | ||||
-rw-r--r-- | drivers/hid/intel-ish-hid/ishtp/init.c | 1 | ||||
-rw-r--r-- | drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h | 3 |
8 files changed, 50 insertions, 17 deletions
diff --git a/drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h b/drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h index ab68afcba2a2..a5897b9c0956 100644 --- a/drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h +++ b/drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h @@ -111,6 +111,14 @@ #define IPC_ILUP_BIT (1<<IPC_ILUP_OFFS) /* + * ISH FW status bits in ISH FW Status Register + */ +#define IPC_ISH_FWSTS_SHIFT 12 +#define IPC_ISH_FWSTS_MASK GENMASK(15, 12) +#define IPC_GET_ISH_FWSTS(status) \ + (((status) & IPC_ISH_FWSTS_MASK) >> IPC_ISH_FWSTS_SHIFT) + +/* * FW status bits (relevant) */ #define IPC_FWSTS_ILUP 0x1 diff --git a/drivers/hid/intel-ish-hid/ipc/hw-ish.h b/drivers/hid/intel-ish-hid/ipc/hw-ish.h index 46615a03e78f..fd34307a7a70 100644 --- a/drivers/hid/intel-ish-hid/ipc/hw-ish.h +++ b/drivers/hid/intel-ish-hid/ipc/hw-ish.h @@ -61,6 +61,18 @@ struct ish_hw { void __iomem *mem_addr; }; +/* + * ISH FW status type + */ +enum { + FWSTS_AFTER_RESET = 0, + FWSTS_WAIT_FOR_HOST = 4, + FWSTS_START_KERNEL_DMA = 5, + FWSTS_FW_IS_RUNNING = 7, + FWSTS_SENSOR_APP_LOADED = 8, + FWSTS_SENSOR_APP_RUNNING = 15 +}; + #define to_ish_hw(dev) (struct ish_hw *)((dev)->hw) irqreturn_t ish_irq_handler(int irq, void *dev_id); diff --git a/drivers/hid/intel-ish-hid/ipc/pci-ish.c b/drivers/hid/intel-ish-hid/ipc/pci-ish.c index 20d647d2dd2c..8df81dc84529 100644 --- a/drivers/hid/intel-ish-hid/ipc/pci-ish.c +++ b/drivers/hid/intel-ish-hid/ipc/pci-ish.c @@ -24,7 +24,6 @@ #include <linux/sched.h> #include <linux/interrupt.h> #include <linux/workqueue.h> -#include <linux/miscdevice.h> #define CREATE_TRACE_POINTS #include <trace/events/intel_ish.h> #include "ishtp-dev.h" @@ -47,7 +46,8 @@ MODULE_DEVICE_TABLE(pci, ish_pci_tbl); * * Callback to direct log messages to Linux trace buffers */ -static void ish_event_tracer(struct ishtp_device *dev, char *format, ...) +static __printf(2, 3) +void ish_event_tracer(struct ishtp_device *dev, const char *format, ...) { if (trace_ishtp_dump_enabled()) { va_list args; @@ -205,12 +205,15 @@ static void ish_remove(struct pci_dev *pdev) #ifdef CONFIG_PM static struct device *ish_resume_device; +/* 50ms to get resume response */ +#define WAIT_FOR_RESUME_ACK_MS 50 + /** * ish_resume_handler() - Work function to complete resume * @work: work struct * * The resume work function to complete resume function asynchronously. - * There are two types of platforms, one where ISH is not powered off, + * There are two resume paths, one where ISH is not powered off, * in that case a simple resume message is enough, others we need * a reset sequence. */ @@ -218,20 +221,31 @@ static void ish_resume_handler(struct work_struct *work) { struct pci_dev *pdev = to_pci_dev(ish_resume_device); struct ishtp_device *dev = pci_get_drvdata(pdev); + uint32_t fwsts; int ret; - ishtp_send_resume(dev); + /* Get ISH FW status */ + fwsts = IPC_GET_ISH_FWSTS(dev->ops->get_fw_status(dev)); - /* 50 ms to get resume response */ - if (dev->resume_flag) - ret = wait_event_interruptible_timeout(dev->resume_wait, - !dev->resume_flag, - msecs_to_jiffies(50)); + /* + * If currently, in ISH FW, sensor app is loaded or beyond that, + * it means ISH isn't powered off, in this case, send a resume message. + */ + if (fwsts >= FWSTS_SENSOR_APP_LOADED) { + ishtp_send_resume(dev); + + /* Waiting to get resume response */ + if (dev->resume_flag) + ret = wait_event_interruptible_timeout(dev->resume_wait, + !dev->resume_flag, + msecs_to_jiffies(WAIT_FOR_RESUME_ACK_MS)); + } /* - * If no resume response. This platform is not S0ix compatible - * So on resume full reboot of ISH processor will happen, so - * need to go through init sequence again + * If in ISH FW, sensor app isn't loaded yet, or no resume response. + * That means this platform is not S0ix compatible, or something is + * wrong with ISH FW. So on resume, full reboot of ISH processor will + * happen, so need to go through init sequence again. */ if (dev->resume_flag) ish_init(dev); diff --git a/drivers/hid/intel-ish-hid/ishtp-hid.c b/drivers/hid/intel-ish-hid/ishtp-hid.c index 277983aa1d90..cd23903ddcf1 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid.c +++ b/drivers/hid/intel-ish-hid/ishtp-hid.c @@ -208,7 +208,7 @@ int ishtp_hid_probe(unsigned int cur_hid_dev, hid->version = le16_to_cpu(ISH_HID_VERSION); hid->vendor = le16_to_cpu(ISH_HID_VENDOR); hid->product = le16_to_cpu(ISH_HID_PRODUCT); - snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX", "hid-ishtp", + snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", "hid-ishtp", hid->vendor, hid->product); rv = hid_add_device(hid); diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c index f4cbc744e657..5f382fedc2ab 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.c +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c @@ -358,7 +358,7 @@ static void ishtp_cl_dev_release(struct device *dev) kfree(to_ishtp_cl_device(dev)); } -static struct device_type ishtp_cl_device_type = { +static const struct device_type ishtp_cl_device_type = { .release = ishtp_cl_dev_release, }; diff --git a/drivers/hid/intel-ish-hid/ishtp/hbm.c b/drivers/hid/intel-ish-hid/ishtp/hbm.c index 59460b66e689..b7213608ce43 100644 --- a/drivers/hid/intel-ish-hid/ishtp/hbm.c +++ b/drivers/hid/intel-ish-hid/ishtp/hbm.c @@ -19,7 +19,6 @@ #include <linux/sched.h> #include <linux/wait.h> #include <linux/spinlock.h> -#include <linux/miscdevice.h> #include "ishtp-dev.h" #include "hbm.h" #include "client.h" diff --git a/drivers/hid/intel-ish-hid/ishtp/init.c b/drivers/hid/intel-ish-hid/ishtp/init.c index ac364418e17c..d27e03526acd 100644 --- a/drivers/hid/intel-ish-hid/ishtp/init.c +++ b/drivers/hid/intel-ish-hid/ishtp/init.c @@ -16,7 +16,6 @@ #include <linux/export.h> #include <linux/slab.h> #include <linux/sched.h> -#include <linux/miscdevice.h> #include "ishtp-dev.h" #include "hbm.h" #include "client.h" diff --git a/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h b/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h index a94f9a8a96a0..6a6d927b78b0 100644 --- a/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h +++ b/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h @@ -238,7 +238,8 @@ struct ishtp_device { uint64_t ishtp_host_dma_rx_buf_phys; /* Dump to trace buffers if enabled*/ - void (*print_log)(struct ishtp_device *dev, char *format, ...); + __printf(2, 3) void (*print_log)(struct ishtp_device *dev, + const char *format, ...); /* Debug stats */ unsigned int ipc_rx_cnt; |