Lines Matching refs:dev

162 static bool mei_txe_aliveness_set(struct mei_device *dev, u32 req)  in mei_txe_aliveness_set()  argument
165 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_aliveness_set()
168 dev_dbg(dev->dev, "Aliveness current=%d request=%d\n", in mei_txe_aliveness_set()
171 dev->pg_event = MEI_PG_EVENT_WAIT; in mei_txe_aliveness_set()
188 static u32 mei_txe_aliveness_req_get(struct mei_device *dev) in mei_txe_aliveness_req_get() argument
190 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_aliveness_req_get()
205 static u32 mei_txe_aliveness_get(struct mei_device *dev) in mei_txe_aliveness_get() argument
207 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_aliveness_get()
224 static int mei_txe_aliveness_poll(struct mei_device *dev, u32 expected) in mei_txe_aliveness_poll() argument
226 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_aliveness_poll()
232 hw->aliveness = mei_txe_aliveness_get(dev); in mei_txe_aliveness_poll()
234 dev->pg_event = MEI_PG_EVENT_IDLE; in mei_txe_aliveness_poll()
235 dev_dbg(dev->dev, "aliveness settled after %lld usecs\n", in mei_txe_aliveness_poll()
242 dev->pg_event = MEI_PG_EVENT_IDLE; in mei_txe_aliveness_poll()
243 dev_err(dev->dev, "aliveness timed out\n"); in mei_txe_aliveness_poll()
257 static int mei_txe_aliveness_wait(struct mei_device *dev, u32 expected) in mei_txe_aliveness_wait() argument
259 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_aliveness_wait()
265 hw->aliveness = mei_txe_aliveness_get(dev); in mei_txe_aliveness_wait()
269 mutex_unlock(&dev->device_lock); in mei_txe_aliveness_wait()
271 dev->pg_event == MEI_PG_EVENT_RECEIVED, timeout); in mei_txe_aliveness_wait()
272 mutex_lock(&dev->device_lock); in mei_txe_aliveness_wait()
274 hw->aliveness = mei_txe_aliveness_get(dev); in mei_txe_aliveness_wait()
278 dev_warn(dev->dev, "aliveness timed out = %ld aliveness = %d event = %d\n", in mei_txe_aliveness_wait()
279 err, hw->aliveness, dev->pg_event); in mei_txe_aliveness_wait()
281 dev_dbg(dev->dev, "aliveness settled after = %d msec aliveness = %d event = %d\n", in mei_txe_aliveness_wait()
283 hw->aliveness, dev->pg_event); in mei_txe_aliveness_wait()
285 dev->pg_event = MEI_PG_EVENT_IDLE; in mei_txe_aliveness_wait()
297 int mei_txe_aliveness_set_sync(struct mei_device *dev, u32 req) in mei_txe_aliveness_set_sync() argument
299 if (mei_txe_aliveness_set(dev, req)) in mei_txe_aliveness_set_sync()
300 return mei_txe_aliveness_wait(dev, req); in mei_txe_aliveness_set_sync()
311 static bool mei_txe_pg_in_transition(struct mei_device *dev) in mei_txe_pg_in_transition() argument
313 return dev->pg_event == MEI_PG_EVENT_WAIT; in mei_txe_pg_in_transition()
323 static bool mei_txe_pg_is_enabled(struct mei_device *dev) in mei_txe_pg_is_enabled() argument
336 static inline enum mei_pg_state mei_txe_pg_state(struct mei_device *dev) in mei_txe_pg_state() argument
338 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_pg_state()
348 static void mei_txe_input_ready_interrupt_enable(struct mei_device *dev) in mei_txe_input_ready_interrupt_enable() argument
350 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_input_ready_interrupt_enable()
390 static bool mei_txe_is_input_ready(struct mei_device *dev) in mei_txe_is_input_ready() argument
392 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_is_input_ready()
404 static inline void mei_txe_intr_clear(struct mei_device *dev) in mei_txe_intr_clear() argument
406 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_intr_clear()
419 static void mei_txe_intr_disable(struct mei_device *dev) in mei_txe_intr_disable() argument
421 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_intr_disable()
431 static void mei_txe_intr_enable(struct mei_device *dev) in mei_txe_intr_enable() argument
433 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_intr_enable()
450 static bool mei_txe_pending_interrupts(struct mei_device *dev) in mei_txe_pending_interrupts() argument
453 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_pending_interrupts()
460 dev_dbg(dev->dev, in mei_txe_pending_interrupts()
478 static void mei_txe_input_payload_write(struct mei_device *dev, in mei_txe_input_payload_write() argument
481 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_input_payload_write()
496 static u32 mei_txe_out_data_read(const struct mei_device *dev, in mei_txe_out_data_read() argument
499 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_out_data_read()
512 static void mei_txe_readiness_set_host_rdy(struct mei_device *dev) in mei_txe_readiness_set_host_rdy() argument
514 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_readiness_set_host_rdy()
526 static void mei_txe_readiness_clear(struct mei_device *dev) in mei_txe_readiness_clear() argument
528 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_readiness_clear()
541 static u32 mei_txe_readiness_get(struct mei_device *dev) in mei_txe_readiness_get() argument
543 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_readiness_get()
569 static bool mei_txe_hw_is_ready(struct mei_device *dev) in mei_txe_hw_is_ready() argument
571 u32 readiness = mei_txe_readiness_get(dev); in mei_txe_hw_is_ready()
583 static inline bool mei_txe_host_is_ready(struct mei_device *dev) in mei_txe_host_is_ready() argument
585 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_host_is_ready()
598 static int mei_txe_readiness_wait(struct mei_device *dev) in mei_txe_readiness_wait() argument
600 if (mei_txe_hw_is_ready(dev)) in mei_txe_readiness_wait()
603 mutex_unlock(&dev->device_lock); in mei_txe_readiness_wait()
604 wait_event_timeout(dev->wait_hw_ready, dev->recvd_hw_ready, in mei_txe_readiness_wait()
606 mutex_lock(&dev->device_lock); in mei_txe_readiness_wait()
607 if (!dev->recvd_hw_ready) { in mei_txe_readiness_wait()
608 dev_err(dev->dev, "wait for readiness failed\n"); in mei_txe_readiness_wait()
612 dev->recvd_hw_ready = false; in mei_txe_readiness_wait()
630 static int mei_txe_fw_status(struct mei_device *dev, in mei_txe_fw_status() argument
634 struct pci_dev *pdev = to_pci_dev(dev->dev); in mei_txe_fw_status()
660 static void mei_txe_hw_config(struct mei_device *dev) in mei_txe_hw_config() argument
663 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_hw_config()
666 dev->hbuf_depth = PAYLOAD_SIZE / 4; in mei_txe_hw_config()
668 hw->aliveness = mei_txe_aliveness_get(dev); in mei_txe_hw_config()
669 hw->readiness = mei_txe_readiness_get(dev); in mei_txe_hw_config()
671 dev_dbg(dev->dev, "aliveness_resp = 0x%08x, readiness = 0x%08x.\n", in mei_txe_hw_config()
686 static int mei_txe_write(struct mei_device *dev, in mei_txe_write() argument
689 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_write()
692 int slots = dev->hbuf_depth; in mei_txe_write()
702 dev_dbg(dev->dev, MEI_HDR_FMT, MEI_HDR_PRM(header)); in mei_txe_write()
712 mei_txe_input_ready_interrupt_enable(dev); in mei_txe_write()
714 if (!mei_txe_is_input_ready(dev)) { in mei_txe_write()
717 mei_fw_status_str(dev, fw_sts_str, MEI_FW_STATUS_STR_SZ); in mei_txe_write()
718 dev_err(dev->dev, "Input is not ready %s\n", fw_sts_str); in mei_txe_write()
722 mei_txe_input_payload_write(dev, 0, *((u32 *)header)); in mei_txe_write()
725 mei_txe_input_payload_write(dev, i + 1, reg_buf[i]); in mei_txe_write()
732 mei_txe_input_payload_write(dev, i + 1, reg); in mei_txe_write()
751 static size_t mei_txe_hbuf_max_len(const struct mei_device *dev) in mei_txe_hbuf_max_len() argument
763 static int mei_txe_hbuf_empty_slots(struct mei_device *dev) in mei_txe_hbuf_empty_slots() argument
765 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_hbuf_empty_slots()
777 static int mei_txe_count_full_read_slots(struct mei_device *dev) in mei_txe_count_full_read_slots() argument
791 static u32 mei_txe_read_hdr(const struct mei_device *dev) in mei_txe_read_hdr() argument
793 return mei_txe_out_data_read(dev, 0); in mei_txe_read_hdr()
804 static int mei_txe_read(struct mei_device *dev, in mei_txe_read() argument
808 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_read()
819 dev_dbg(dev->dev, "buffer-length = %lu buf[0]0x%08X\n", in mei_txe_read()
820 len, mei_txe_out_data_read(dev, 0)); in mei_txe_read()
824 reg = mei_txe_out_data_read(dev, i + 1); in mei_txe_read()
825 dev_dbg(dev->dev, "buf[%d] = 0x%08X\n", i, reg); in mei_txe_read()
830 reg = mei_txe_out_data_read(dev, i + 1); in mei_txe_read()
846 static int mei_txe_hw_reset(struct mei_device *dev, bool intr_enable) in mei_txe_hw_reset() argument
848 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_hw_reset()
857 aliveness_req = mei_txe_aliveness_req_get(dev); in mei_txe_hw_reset()
858 hw->aliveness = mei_txe_aliveness_get(dev); in mei_txe_hw_reset()
861 mei_txe_intr_disable(dev); in mei_txe_hw_reset()
869 if (mei_txe_aliveness_poll(dev, aliveness_req) < 0) { in mei_txe_hw_reset()
870 dev_err(dev->dev, "wait for aliveness settle failed ... bailing out\n"); in mei_txe_hw_reset()
878 mei_txe_aliveness_set(dev, 0); in mei_txe_hw_reset()
879 if (mei_txe_aliveness_poll(dev, 0) < 0) { in mei_txe_hw_reset()
880 dev_err(dev->dev, "wait for aliveness failed ... bailing out\n"); in mei_txe_hw_reset()
888 mei_txe_readiness_clear(dev); in mei_txe_hw_reset()
900 static int mei_txe_hw_start(struct mei_device *dev) in mei_txe_hw_start() argument
902 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_hw_start()
908 mei_txe_intr_enable(dev); in mei_txe_hw_start()
910 ret = mei_txe_readiness_wait(dev); in mei_txe_hw_start()
912 dev_err(dev->dev, "waiting for readiness failed\n"); in mei_txe_hw_start()
926 ret = mei_txe_aliveness_set_sync(dev, 1); in mei_txe_hw_start()
928 dev_err(dev->dev, "wait for aliveness failed ... bailing out\n"); in mei_txe_hw_start()
935 mei_txe_input_ready_interrupt_enable(dev); in mei_txe_hw_start()
943 mei_txe_readiness_set_host_rdy(dev); in mei_txe_hw_start()
957 static bool mei_txe_check_and_ack_intrs(struct mei_device *dev, bool do_ack) in mei_txe_check_and_ack_intrs() argument
959 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_check_and_ack_intrs()
974 aliveness = mei_txe_aliveness_get(dev); in mei_txe_check_and_ack_intrs()
992 mei_txe_intr_disable(dev); in mei_txe_check_and_ack_intrs()
1016 struct mei_device *dev = dev_id; in mei_txe_irq_quick_handler() local
1018 if (mei_txe_check_and_ack_intrs(dev, true)) in mei_txe_irq_quick_handler()
1034 struct mei_device *dev = (struct mei_device *) dev_id; in mei_txe_irq_thread_handler() local
1035 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_irq_thread_handler()
1040 dev_dbg(dev->dev, "irq thread: Interrupt Registers HHISR|HISR|SEC=%02X|%04X|%02X\n", in mei_txe_irq_thread_handler()
1047 mutex_lock(&dev->device_lock); in mei_txe_irq_thread_handler()
1050 if (pci_dev_msi_enabled(to_pci_dev(dev->dev))) in mei_txe_irq_thread_handler()
1051 mei_txe_check_and_ack_intrs(dev, true); in mei_txe_irq_thread_handler()
1054 mei_txe_pending_interrupts(dev); in mei_txe_irq_thread_handler()
1056 hw->aliveness = mei_txe_aliveness_get(dev); in mei_txe_irq_thread_handler()
1057 hw->readiness = mei_txe_readiness_get(dev); in mei_txe_irq_thread_handler()
1064 dev_dbg(dev->dev, "Readiness Interrupt was received...\n"); in mei_txe_irq_thread_handler()
1068 dev_dbg(dev->dev, "we need to start the dev.\n"); in mei_txe_irq_thread_handler()
1069 dev->recvd_hw_ready = true; in mei_txe_irq_thread_handler()
1071 dev->recvd_hw_ready = false; in mei_txe_irq_thread_handler()
1072 if (dev->dev_state != MEI_DEV_RESETTING) { in mei_txe_irq_thread_handler()
1074 dev_warn(dev->dev, "FW not ready: resetting.\n"); in mei_txe_irq_thread_handler()
1075 schedule_work(&dev->reset_work); in mei_txe_irq_thread_handler()
1080 wake_up(&dev->wait_hw_ready); in mei_txe_irq_thread_handler()
1091 dev_dbg(dev->dev, in mei_txe_irq_thread_handler()
1093 dev->pg_event = MEI_PG_EVENT_RECEIVED; in mei_txe_irq_thread_handler()
1102 slots = mei_count_full_read_slots(dev); in mei_txe_irq_thread_handler()
1105 rets = mei_irq_read_handler(dev, &complete_list, &slots); in mei_txe_irq_thread_handler()
1106 if (rets && dev->dev_state != MEI_DEV_RESETTING) { in mei_txe_irq_thread_handler()
1107 dev_err(dev->dev, in mei_txe_irq_thread_handler()
1110 schedule_work(&dev->reset_work); in mei_txe_irq_thread_handler()
1116 dev->hbuf_is_ready = true; in mei_txe_irq_thread_handler()
1117 hw->slots = dev->hbuf_depth; in mei_txe_irq_thread_handler()
1120 if (hw->aliveness && dev->hbuf_is_ready) { in mei_txe_irq_thread_handler()
1122 dev->hbuf_is_ready = mei_hbuf_is_ready(dev); in mei_txe_irq_thread_handler()
1123 rets = mei_irq_write_handler(dev, &complete_list); in mei_txe_irq_thread_handler()
1125 dev_err(dev->dev, "mei_irq_write_handler ret = %d.\n", in mei_txe_irq_thread_handler()
1127 dev->hbuf_is_ready = mei_hbuf_is_ready(dev); in mei_txe_irq_thread_handler()
1130 mei_irq_compl_handler(dev, &complete_list); in mei_txe_irq_thread_handler()
1133 dev_dbg(dev->dev, "interrupt thread end ret = %d\n", rets); in mei_txe_irq_thread_handler()
1135 mutex_unlock(&dev->device_lock); in mei_txe_irq_thread_handler()
1137 mei_enable_interrupts(dev); in mei_txe_irq_thread_handler()
1182 struct mei_device *dev; in mei_txe_dev_init() local
1185 dev = kzalloc(sizeof(struct mei_device) + in mei_txe_dev_init()
1187 if (!dev) in mei_txe_dev_init()
1190 mei_device_init(dev, &pdev->dev, &mei_txe_hw_ops); in mei_txe_dev_init()
1192 hw = to_txe_hw(dev); in mei_txe_dev_init()
1196 return dev; in mei_txe_dev_init()
1208 int mei_txe_setup_satt2(struct mei_device *dev, phys_addr_t addr, u32 range) in mei_txe_setup_satt2() argument
1210 struct mei_txe_hw *hw = to_txe_hw(dev); in mei_txe_setup_satt2()
1238 dev_dbg(dev->dev, "SATT2: SAP_SIZE_OFFSET=0x%08X, BRG_BA_LSB_OFFSET=0x%08X, CTRL_OFFSET=0x%08X\n", in mei_txe_setup_satt2()