Lines Matching refs:stdev

52 	struct switchtec_dev *stdev;  member
76 static int is_firmware_running(struct switchtec_dev *stdev) in is_firmware_running() argument
78 u32 device = ioread32(&stdev->mmio_sys_info->device_id); in is_firmware_running()
80 return stdev->pdev->device == device; in is_firmware_running()
83 static struct switchtec_user *stuser_create(struct switchtec_dev *stdev) in stuser_create() argument
91 get_device(&stdev->dev); in stuser_create()
92 stuser->stdev = stdev; in stuser_create()
96 stuser->event_cnt = atomic_read(&stdev->event_cnt); in stuser_create()
98 dev_dbg(&stdev->dev, "%s: %p\n", __func__, stuser); in stuser_create()
109 dev_dbg(&stuser->stdev->dev, "%s: %p\n", __func__, stuser); in stuser_free()
111 put_device(&stuser->stdev->dev); in stuser_free()
135 dev_dbg(&stuser->stdev->dev, "stuser state %p -> %s", in stuser_set_state()
139 static void mrpc_complete_cmd(struct switchtec_dev *stdev);
141 static void flush_wc_buf(struct switchtec_dev *stdev) in flush_wc_buf() argument
149 mmio_dbmsg = (void __iomem *)stdev->mmio_ntb + in flush_wc_buf()
154 static void mrpc_cmd_submit(struct switchtec_dev *stdev) in mrpc_cmd_submit() argument
160 if (stdev->mrpc_busy) in mrpc_cmd_submit()
163 if (list_empty(&stdev->mrpc_queue)) in mrpc_cmd_submit()
166 stuser = list_entry(stdev->mrpc_queue.next, struct switchtec_user, in mrpc_cmd_submit()
169 if (stdev->dma_mrpc) { in mrpc_cmd_submit()
170 stdev->dma_mrpc->status = SWITCHTEC_MRPC_STATUS_INPROGRESS; in mrpc_cmd_submit()
171 memset(stdev->dma_mrpc->data, 0xFF, SWITCHTEC_MRPC_PAYLOAD_SIZE); in mrpc_cmd_submit()
175 stdev->mrpc_busy = 1; in mrpc_cmd_submit()
176 memcpy_toio(&stdev->mmio_mrpc->input_data, in mrpc_cmd_submit()
178 flush_wc_buf(stdev); in mrpc_cmd_submit()
179 iowrite32(stuser->cmd, &stdev->mmio_mrpc->cmd); in mrpc_cmd_submit()
181 schedule_delayed_work(&stdev->mrpc_timeout, in mrpc_cmd_submit()
189 struct switchtec_dev *stdev = stuser->stdev; in mrpc_queue_cmd() local
195 list_add_tail(&stuser->list, &stdev->mrpc_queue); in mrpc_queue_cmd()
197 mrpc_cmd_submit(stdev); in mrpc_queue_cmd()
202 static void mrpc_cleanup_cmd(struct switchtec_dev *stdev) in mrpc_cleanup_cmd() argument
206 struct switchtec_user *stuser = list_entry(stdev->mrpc_queue.next, in mrpc_cleanup_cmd()
213 stdev->mrpc_busy = 0; in mrpc_cleanup_cmd()
215 mrpc_cmd_submit(stdev); in mrpc_cleanup_cmd()
218 static void mrpc_complete_cmd(struct switchtec_dev *stdev) in mrpc_complete_cmd() argument
224 if (list_empty(&stdev->mrpc_queue)) in mrpc_complete_cmd()
227 stuser = list_entry(stdev->mrpc_queue.next, struct switchtec_user, in mrpc_complete_cmd()
230 if (stdev->dma_mrpc) in mrpc_complete_cmd()
231 stuser->status = stdev->dma_mrpc->status; in mrpc_complete_cmd()
233 stuser->status = ioread32(&stdev->mmio_mrpc->status); in mrpc_complete_cmd()
245 if (stdev->dma_mrpc) in mrpc_complete_cmd()
246 stuser->return_code = stdev->dma_mrpc->rtn_code; in mrpc_complete_cmd()
248 stuser->return_code = ioread32(&stdev->mmio_mrpc->ret_value); in mrpc_complete_cmd()
252 if (stdev->dma_mrpc) in mrpc_complete_cmd()
253 memcpy(stuser->data, &stdev->dma_mrpc->data, in mrpc_complete_cmd()
256 memcpy_fromio(stuser->data, &stdev->mmio_mrpc->output_data, in mrpc_complete_cmd()
259 mrpc_cleanup_cmd(stdev); in mrpc_complete_cmd()
264 struct switchtec_dev *stdev; in mrpc_event_work() local
266 stdev = container_of(work, struct switchtec_dev, mrpc_work); in mrpc_event_work()
268 dev_dbg(&stdev->dev, "%s\n", __func__); in mrpc_event_work()
270 mutex_lock(&stdev->mrpc_mutex); in mrpc_event_work()
271 cancel_delayed_work(&stdev->mrpc_timeout); in mrpc_event_work()
272 mrpc_complete_cmd(stdev); in mrpc_event_work()
273 mutex_unlock(&stdev->mrpc_mutex); in mrpc_event_work()
276 static void mrpc_error_complete_cmd(struct switchtec_dev *stdev) in mrpc_error_complete_cmd() argument
282 if (list_empty(&stdev->mrpc_queue)) in mrpc_error_complete_cmd()
285 stuser = list_entry(stdev->mrpc_queue.next, in mrpc_error_complete_cmd()
290 mrpc_cleanup_cmd(stdev); in mrpc_error_complete_cmd()
295 struct switchtec_dev *stdev; in mrpc_timeout_work() local
298 stdev = container_of(work, struct switchtec_dev, mrpc_timeout.work); in mrpc_timeout_work()
300 dev_dbg(&stdev->dev, "%s\n", __func__); in mrpc_timeout_work()
302 mutex_lock(&stdev->mrpc_mutex); in mrpc_timeout_work()
304 if (!is_firmware_running(stdev)) { in mrpc_timeout_work()
305 mrpc_error_complete_cmd(stdev); in mrpc_timeout_work()
309 if (stdev->dma_mrpc) in mrpc_timeout_work()
310 status = stdev->dma_mrpc->status; in mrpc_timeout_work()
312 status = ioread32(&stdev->mmio_mrpc->status); in mrpc_timeout_work()
314 schedule_delayed_work(&stdev->mrpc_timeout, in mrpc_timeout_work()
319 mrpc_complete_cmd(stdev); in mrpc_timeout_work()
321 mutex_unlock(&stdev->mrpc_mutex); in mrpc_timeout_work()
327 struct switchtec_dev *stdev = to_stdev(dev); in device_version_show() local
330 ver = ioread32(&stdev->mmio_sys_info->device_version); in device_version_show()
339 struct switchtec_dev *stdev = to_stdev(dev); in fw_version_show() local
342 ver = ioread32(&stdev->mmio_sys_info->firmware_version); in fw_version_show()
370 struct switchtec_dev *stdev = to_stdev(dev); \
371 struct sys_info_regs __iomem *si = stdev->mmio_sys_info; \
372 if (stdev->gen == SWITCHTEC_GEN3) \
375 else if (stdev->gen == SWITCHTEC_GEN4) \
391 struct switchtec_dev *stdev = to_stdev(dev); in component_vendor_show() local
392 struct sys_info_regs __iomem *si = stdev->mmio_sys_info; in component_vendor_show()
395 if (stdev->gen != SWITCHTEC_GEN3) in component_vendor_show()
406 struct switchtec_dev *stdev = to_stdev(dev); in component_id_show() local
407 int id = ioread16(&stdev->mmio_sys_info->gen3.component_id); in component_id_show()
410 if (stdev->gen != SWITCHTEC_GEN3) in component_id_show()
420 struct switchtec_dev *stdev = to_stdev(dev); in component_revision_show() local
421 int rev = ioread8(&stdev->mmio_sys_info->gen3.component_revision); in component_revision_show()
424 if (stdev->gen != SWITCHTEC_GEN3) in component_revision_show()
434 struct switchtec_dev *stdev = to_stdev(dev); in partition_show() local
436 return sysfs_emit(buf, "%d\n", stdev->partition); in partition_show()
443 struct switchtec_dev *stdev = to_stdev(dev); in partition_count_show() local
445 return sysfs_emit(buf, "%d\n", stdev->partition_count); in partition_count_show()
467 struct switchtec_dev *stdev; in switchtec_dev_open() local
470 stdev = container_of(inode->i_cdev, struct switchtec_dev, cdev); in switchtec_dev_open()
472 stuser = stuser_create(stdev); in switchtec_dev_open()
479 dev_dbg(&stdev->dev, "%s: %p\n", __func__, stuser); in switchtec_dev_open()
493 static int lock_mutex_and_test_alive(struct switchtec_dev *stdev) in lock_mutex_and_test_alive() argument
495 if (mutex_lock_interruptible(&stdev->mrpc_mutex)) in lock_mutex_and_test_alive()
498 if (!stdev->alive) { in lock_mutex_and_test_alive()
499 mutex_unlock(&stdev->mrpc_mutex); in lock_mutex_and_test_alive()
510 struct switchtec_dev *stdev = stuser->stdev; in switchtec_dev_write() local
519 rc = lock_mutex_and_test_alive(stdev); in switchtec_dev_write()
550 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_write()
562 struct switchtec_dev *stdev = stuser->stdev; in switchtec_dev_read() local
569 rc = lock_mutex_and_test_alive(stdev); in switchtec_dev_read()
574 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_read()
580 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_read()
592 rc = lock_mutex_and_test_alive(stdev); in switchtec_dev_read()
597 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_read()
602 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_read()
624 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_read()
638 struct switchtec_dev *stdev = stuser->stdev; in switchtec_dev_poll() local
642 poll_wait(filp, &stdev->event_wq, wait); in switchtec_dev_poll()
644 if (lock_mutex_and_test_alive(stdev)) in switchtec_dev_poll()
647 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_poll()
652 if (stuser->event_cnt != atomic_read(&stdev->event_cnt)) in switchtec_dev_poll()
658 static int ioctl_flash_info(struct switchtec_dev *stdev, in ioctl_flash_info() argument
662 struct flash_info_regs __iomem *fi = stdev->mmio_flash_info; in ioctl_flash_info()
664 if (stdev->gen == SWITCHTEC_GEN3) { in ioctl_flash_info()
667 } else if (stdev->gen == SWITCHTEC_GEN4) { in ioctl_flash_info()
687 static int flash_part_info_gen3(struct switchtec_dev *stdev, in flash_part_info_gen3() argument
691 &stdev->mmio_flash_info->gen3; in flash_part_info_gen3()
692 struct sys_info_regs_gen3 __iomem *si = &stdev->mmio_sys_info->gen3; in flash_part_info_gen3()
757 static int flash_part_info_gen4(struct switchtec_dev *stdev, in flash_part_info_gen4() argument
760 struct flash_info_regs_gen4 __iomem *fi = &stdev->mmio_flash_info->gen4; in flash_part_info_gen4()
761 struct sys_info_regs_gen4 __iomem *si = &stdev->mmio_sys_info->gen4; in flash_part_info_gen4()
861 static int ioctl_flash_part_info(struct switchtec_dev *stdev, in ioctl_flash_part_info() argument
870 if (stdev->gen == SWITCHTEC_GEN3) { in ioctl_flash_part_info()
871 ret = flash_part_info_gen3(stdev, &info); in ioctl_flash_part_info()
874 } else if (stdev->gen == SWITCHTEC_GEN4) { in ioctl_flash_part_info()
875 ret = flash_part_info_gen4(stdev, &info); in ioctl_flash_part_info()
888 static int ioctl_event_summary(struct switchtec_dev *stdev, in ioctl_event_summary() argument
902 s->global = ioread32(&stdev->mmio_sw_event->global_summary); in ioctl_event_summary()
903 s->part_bitmap = ioread64(&stdev->mmio_sw_event->part_event_bitmap); in ioctl_event_summary()
904 s->local_part = ioread32(&stdev->mmio_part_cfg->part_event_summary); in ioctl_event_summary()
906 for (i = 0; i < stdev->partition_count; i++) { in ioctl_event_summary()
907 reg = ioread32(&stdev->mmio_part_cfg_all[i].part_event_summary); in ioctl_event_summary()
911 for (i = 0; i < stdev->pff_csr_count; i++) { in ioctl_event_summary()
912 reg = ioread32(&stdev->mmio_pff_csr[i].pff_event_summary); in ioctl_event_summary()
921 stuser->event_cnt = atomic_read(&stdev->event_cnt); in ioctl_event_summary()
928 static u32 __iomem *global_ev_reg(struct switchtec_dev *stdev, in global_ev_reg() argument
931 return (void __iomem *)stdev->mmio_sw_event + offset; in global_ev_reg()
934 static u32 __iomem *part_ev_reg(struct switchtec_dev *stdev, in part_ev_reg() argument
937 return (void __iomem *)&stdev->mmio_part_cfg_all[index] + offset; in part_ev_reg()
940 static u32 __iomem *pff_ev_reg(struct switchtec_dev *stdev, in pff_ev_reg() argument
943 return (void __iomem *)&stdev->mmio_pff_csr[index] + offset; in pff_ev_reg()
952 u32 __iomem *(*map_reg)(struct switchtec_dev *stdev,
992 static u32 __iomem *event_hdr_addr(struct switchtec_dev *stdev, in event_hdr_addr() argument
1004 index = stdev->partition; in event_hdr_addr()
1005 else if (index < 0 || index >= stdev->partition_count) in event_hdr_addr()
1008 if (index < 0 || index >= stdev->pff_csr_count) in event_hdr_addr()
1012 return event_regs[event_id].map_reg(stdev, off, index); in event_hdr_addr()
1015 static int event_ctl(struct switchtec_dev *stdev, in event_ctl() argument
1022 reg = event_hdr_addr(stdev, ctl->event_id, ctl->index); in event_ctl()
1071 static int ioctl_event_ctl(struct switchtec_dev *stdev, in ioctl_event_ctl() argument
1092 nr_idxs = stdev->partition_count; in ioctl_event_ctl()
1094 nr_idxs = stdev->pff_csr_count; in ioctl_event_ctl()
1101 ret = event_ctl(stdev, &ctl); in ioctl_event_ctl()
1106 ret = event_ctl(stdev, &ctl); in ioctl_event_ctl()
1117 static int ioctl_pff_to_port(struct switchtec_dev *stdev, in ioctl_pff_to_port() argument
1129 for (part = 0; part < stdev->partition_count; part++) { in ioctl_pff_to_port()
1130 pcfg = &stdev->mmio_part_cfg_all[part]; in ioctl_pff_to_port()
1164 static int ioctl_port_to_pff(struct switchtec_dev *stdev, in ioctl_port_to_pff() argument
1174 pcfg = stdev->mmio_part_cfg; in ioctl_port_to_pff()
1175 else if (p.partition < stdev->partition_count) in ioctl_port_to_pff()
1176 pcfg = &stdev->mmio_part_cfg_all[p.partition]; in ioctl_port_to_pff()
1206 struct switchtec_dev *stdev = stuser->stdev; in switchtec_dev_ioctl() local
1210 rc = lock_mutex_and_test_alive(stdev); in switchtec_dev_ioctl()
1216 rc = ioctl_flash_info(stdev, argp); in switchtec_dev_ioctl()
1219 rc = ioctl_flash_part_info(stdev, argp); in switchtec_dev_ioctl()
1222 rc = ioctl_event_summary(stdev, stuser, argp, in switchtec_dev_ioctl()
1226 rc = ioctl_event_ctl(stdev, argp); in switchtec_dev_ioctl()
1229 rc = ioctl_pff_to_port(stdev, argp); in switchtec_dev_ioctl()
1232 rc = ioctl_port_to_pff(stdev, argp); in switchtec_dev_ioctl()
1235 rc = ioctl_event_summary(stdev, stuser, argp, in switchtec_dev_ioctl()
1243 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_ioctl()
1260 struct switchtec_dev *stdev; in link_event_work() local
1262 stdev = container_of(work, struct switchtec_dev, link_event_work); in link_event_work()
1264 if (stdev->link_notifier) in link_event_work()
1265 stdev->link_notifier(stdev); in link_event_work()
1268 static void check_link_state_events(struct switchtec_dev *stdev) in check_link_state_events() argument
1275 for (idx = 0; idx < stdev->pff_csr_count; idx++) { in check_link_state_events()
1276 reg = ioread32(&stdev->mmio_pff_csr[idx].link_state_hdr); in check_link_state_events()
1277 dev_dbg(&stdev->dev, "link_state: %d->%08x\n", idx, reg); in check_link_state_events()
1280 if (count != stdev->link_event_count[idx]) { in check_link_state_events()
1282 stdev->link_event_count[idx] = count; in check_link_state_events()
1287 schedule_work(&stdev->link_event_work); in check_link_state_events()
1290 static void enable_link_state_events(struct switchtec_dev *stdev) in enable_link_state_events() argument
1294 for (idx = 0; idx < stdev->pff_csr_count; idx++) { in enable_link_state_events()
1297 &stdev->mmio_pff_csr[idx].link_state_hdr); in enable_link_state_events()
1301 static void enable_dma_mrpc(struct switchtec_dev *stdev) in enable_dma_mrpc() argument
1303 writeq(stdev->dma_mrpc_dma_addr, &stdev->mmio_mrpc->dma_addr); in enable_dma_mrpc()
1304 flush_wc_buf(stdev); in enable_dma_mrpc()
1305 iowrite32(SWITCHTEC_DMA_MRPC_EN, &stdev->mmio_mrpc->dma_en); in enable_dma_mrpc()
1310 struct switchtec_dev *stdev = to_stdev(dev); in stdev_release() local
1312 if (stdev->dma_mrpc) { in stdev_release()
1313 iowrite32(0, &stdev->mmio_mrpc->dma_en); in stdev_release()
1314 flush_wc_buf(stdev); in stdev_release()
1315 writeq(0, &stdev->mmio_mrpc->dma_addr); in stdev_release()
1316 dma_free_coherent(&stdev->pdev->dev, sizeof(*stdev->dma_mrpc), in stdev_release()
1317 stdev->dma_mrpc, stdev->dma_mrpc_dma_addr); in stdev_release()
1319 kfree(stdev); in stdev_release()
1322 static void stdev_kill(struct switchtec_dev *stdev) in stdev_kill() argument
1326 pci_clear_master(stdev->pdev); in stdev_kill()
1328 cancel_delayed_work_sync(&stdev->mrpc_timeout); in stdev_kill()
1331 mutex_lock(&stdev->mrpc_mutex); in stdev_kill()
1332 stdev->alive = false; in stdev_kill()
1335 list_for_each_entry_safe(stuser, tmpuser, &stdev->mrpc_queue, list) { in stdev_kill()
1342 mutex_unlock(&stdev->mrpc_mutex); in stdev_kill()
1345 wake_up_interruptible(&stdev->event_wq); in stdev_kill()
1350 struct switchtec_dev *stdev; in stdev_create() local
1356 stdev = kzalloc_node(sizeof(*stdev), GFP_KERNEL, in stdev_create()
1358 if (!stdev) in stdev_create()
1361 stdev->alive = true; in stdev_create()
1362 stdev->pdev = pdev; in stdev_create()
1363 INIT_LIST_HEAD(&stdev->mrpc_queue); in stdev_create()
1364 mutex_init(&stdev->mrpc_mutex); in stdev_create()
1365 stdev->mrpc_busy = 0; in stdev_create()
1366 INIT_WORK(&stdev->mrpc_work, mrpc_event_work); in stdev_create()
1367 INIT_DELAYED_WORK(&stdev->mrpc_timeout, mrpc_timeout_work); in stdev_create()
1368 INIT_WORK(&stdev->link_event_work, link_event_work); in stdev_create()
1369 init_waitqueue_head(&stdev->event_wq); in stdev_create()
1370 atomic_set(&stdev->event_cnt, 0); in stdev_create()
1372 dev = &stdev->dev; in stdev_create()
1388 cdev = &stdev->cdev; in stdev_create()
1392 return stdev; in stdev_create()
1395 put_device(&stdev->dev); in stdev_create()
1399 static int mask_event(struct switchtec_dev *stdev, int eid, int idx) in mask_event() argument
1405 hdr_reg = event_regs[eid].map_reg(stdev, off, idx); in mask_event()
1414 dev_dbg(&stdev->dev, "%s: %d %d %x\n", __func__, eid, idx, hdr); in mask_event()
1421 static int mask_all_events(struct switchtec_dev *stdev, int eid) in mask_all_events() argument
1427 for (idx = 0; idx < stdev->partition_count; idx++) in mask_all_events()
1428 count += mask_event(stdev, eid, idx); in mask_all_events()
1430 for (idx = 0; idx < stdev->pff_csr_count; idx++) { in mask_all_events()
1431 if (!stdev->pff_local[idx]) in mask_all_events()
1434 count += mask_event(stdev, eid, idx); in mask_all_events()
1437 count += mask_event(stdev, eid, 0); in mask_all_events()
1445 struct switchtec_dev *stdev = dev; in switchtec_event_isr() local
1450 reg = ioread32(&stdev->mmio_part_cfg->mrpc_comp_hdr); in switchtec_event_isr()
1452 dev_dbg(&stdev->dev, "%s: mrpc comp\n", __func__); in switchtec_event_isr()
1454 schedule_work(&stdev->mrpc_work); in switchtec_event_isr()
1455 iowrite32(reg, &stdev->mmio_part_cfg->mrpc_comp_hdr); in switchtec_event_isr()
1458 check_link_state_events(stdev); in switchtec_event_isr()
1465 event_count += mask_all_events(stdev, eid); in switchtec_event_isr()
1469 atomic_inc(&stdev->event_cnt); in switchtec_event_isr()
1470 wake_up_interruptible(&stdev->event_wq); in switchtec_event_isr()
1471 dev_dbg(&stdev->dev, "%s: %d events\n", __func__, in switchtec_event_isr()
1482 struct switchtec_dev *stdev = dev; in switchtec_dma_mrpc_isr() local
1487 &stdev->mmio_part_cfg->mrpc_comp_hdr); in switchtec_dma_mrpc_isr()
1488 schedule_work(&stdev->mrpc_work); in switchtec_dma_mrpc_isr()
1494 static int switchtec_init_isr(struct switchtec_dev *stdev) in switchtec_init_isr() argument
1504 nvecs = pci_alloc_irq_vectors(stdev->pdev, 1, nirqs, in switchtec_init_isr()
1510 event_irq = ioread16(&stdev->mmio_part_cfg->vep_vector_number); in switchtec_init_isr()
1514 event_irq = pci_irq_vector(stdev->pdev, event_irq); in switchtec_init_isr()
1518 rc = devm_request_irq(&stdev->pdev->dev, event_irq, in switchtec_init_isr()
1520 KBUILD_MODNAME, stdev); in switchtec_init_isr()
1525 if (!stdev->dma_mrpc) in switchtec_init_isr()
1528 dma_mrpc_irq = ioread32(&stdev->mmio_mrpc->dma_vector); in switchtec_init_isr()
1532 dma_mrpc_irq = pci_irq_vector(stdev->pdev, dma_mrpc_irq); in switchtec_init_isr()
1536 rc = devm_request_irq(&stdev->pdev->dev, dma_mrpc_irq, in switchtec_init_isr()
1538 KBUILD_MODNAME, stdev); in switchtec_init_isr()
1543 static void init_pff(struct switchtec_dev *stdev) in init_pff() argument
1547 struct part_cfg_regs __iomem *pcfg = stdev->mmio_part_cfg; in init_pff()
1550 reg = ioread16(&stdev->mmio_pff_csr[i].vendor_id); in init_pff()
1555 stdev->pff_csr_count = i; in init_pff()
1558 if (reg < stdev->pff_csr_count) in init_pff()
1559 stdev->pff_local[reg] = 1; in init_pff()
1562 if (reg < stdev->pff_csr_count) in init_pff()
1563 stdev->pff_local[reg] = 1; in init_pff()
1567 if (reg < stdev->pff_csr_count) in init_pff()
1568 stdev->pff_local[reg] = 1; in init_pff()
1572 static int switchtec_init_pci(struct switchtec_dev *stdev, in switchtec_init_pci() argument
1597 stdev->mmio_mrpc = devm_ioremap_wc(&pdev->dev, res_start, in switchtec_init_pci()
1599 if (!stdev->mmio_mrpc) in switchtec_init_pci()
1608 stdev->mmio = map - SWITCHTEC_GAS_TOP_CFG_OFFSET; in switchtec_init_pci()
1609 stdev->mmio_sw_event = stdev->mmio + SWITCHTEC_GAS_SW_EVENT_OFFSET; in switchtec_init_pci()
1610 stdev->mmio_sys_info = stdev->mmio + SWITCHTEC_GAS_SYS_INFO_OFFSET; in switchtec_init_pci()
1611 stdev->mmio_flash_info = stdev->mmio + SWITCHTEC_GAS_FLASH_INFO_OFFSET; in switchtec_init_pci()
1612 stdev->mmio_ntb = stdev->mmio + SWITCHTEC_GAS_NTB_OFFSET; in switchtec_init_pci()
1614 if (stdev->gen == SWITCHTEC_GEN3) in switchtec_init_pci()
1615 part_id = &stdev->mmio_sys_info->gen3.partition_id; in switchtec_init_pci()
1616 else if (stdev->gen == SWITCHTEC_GEN4) in switchtec_init_pci()
1617 part_id = &stdev->mmio_sys_info->gen4.partition_id; in switchtec_init_pci()
1621 stdev->partition = ioread8(part_id); in switchtec_init_pci()
1622 stdev->partition_count = ioread8(&stdev->mmio_ntb->partition_count); in switchtec_init_pci()
1623 stdev->mmio_part_cfg_all = stdev->mmio + SWITCHTEC_GAS_PART_CFG_OFFSET; in switchtec_init_pci()
1624 stdev->mmio_part_cfg = &stdev->mmio_part_cfg_all[stdev->partition]; in switchtec_init_pci()
1625 stdev->mmio_pff_csr = stdev->mmio + SWITCHTEC_GAS_PFF_CSR_OFFSET; in switchtec_init_pci()
1627 if (stdev->partition_count < 1) in switchtec_init_pci()
1628 stdev->partition_count = 1; in switchtec_init_pci()
1630 init_pff(stdev); in switchtec_init_pci()
1632 pci_set_drvdata(pdev, stdev); in switchtec_init_pci()
1637 if (ioread32(&stdev->mmio_mrpc->dma_ver) == 0) in switchtec_init_pci()
1640 stdev->dma_mrpc = dma_alloc_coherent(&stdev->pdev->dev, in switchtec_init_pci()
1641 sizeof(*stdev->dma_mrpc), in switchtec_init_pci()
1642 &stdev->dma_mrpc_dma_addr, in switchtec_init_pci()
1644 if (stdev->dma_mrpc == NULL) in switchtec_init_pci()
1653 struct switchtec_dev *stdev; in switchtec_pci_probe() local
1659 stdev = stdev_create(pdev); in switchtec_pci_probe()
1660 if (IS_ERR(stdev)) in switchtec_pci_probe()
1661 return PTR_ERR(stdev); in switchtec_pci_probe()
1663 stdev->gen = id->driver_data; in switchtec_pci_probe()
1665 rc = switchtec_init_pci(stdev, pdev); in switchtec_pci_probe()
1669 rc = switchtec_init_isr(stdev); in switchtec_pci_probe()
1671 dev_err(&stdev->dev, "failed to init isr.\n"); in switchtec_pci_probe()
1677 &stdev->mmio_part_cfg->mrpc_comp_hdr); in switchtec_pci_probe()
1678 enable_link_state_events(stdev); in switchtec_pci_probe()
1680 if (stdev->dma_mrpc) in switchtec_pci_probe()
1681 enable_dma_mrpc(stdev); in switchtec_pci_probe()
1683 rc = cdev_device_add(&stdev->cdev, &stdev->dev); in switchtec_pci_probe()
1687 dev_info(&stdev->dev, "Management device registered.\n"); in switchtec_pci_probe()
1692 stdev_kill(stdev); in switchtec_pci_probe()
1694 ida_free(&switchtec_minor_ida, MINOR(stdev->dev.devt)); in switchtec_pci_probe()
1695 put_device(&stdev->dev); in switchtec_pci_probe()
1701 struct switchtec_dev *stdev = pci_get_drvdata(pdev); in switchtec_pci_remove() local
1705 cdev_device_del(&stdev->cdev, &stdev->dev); in switchtec_pci_remove()
1706 ida_free(&switchtec_minor_ida, MINOR(stdev->dev.devt)); in switchtec_pci_remove()
1707 dev_info(&stdev->dev, "unregistered.\n"); in switchtec_pci_remove()
1708 stdev_kill(stdev); in switchtec_pci_remove()
1709 put_device(&stdev->dev); in switchtec_pci_remove()