Lines Matching refs:stdev
51 struct switchtec_dev *stdev; member
69 static struct switchtec_user *stuser_create(struct switchtec_dev *stdev) in stuser_create() argument
77 get_device(&stdev->dev); in stuser_create()
78 stuser->stdev = stdev; in stuser_create()
82 stuser->event_cnt = atomic_read(&stdev->event_cnt); in stuser_create()
84 dev_dbg(&stdev->dev, "%s: %p\n", __func__, stuser); in stuser_create()
95 dev_dbg(&stuser->stdev->dev, "%s: %p\n", __func__, stuser); in stuser_free()
97 put_device(&stuser->stdev->dev); in stuser_free()
120 dev_dbg(&stuser->stdev->dev, "stuser state %p -> %s", in stuser_set_state()
124 static void mrpc_complete_cmd(struct switchtec_dev *stdev);
126 static void flush_wc_buf(struct switchtec_dev *stdev) in flush_wc_buf() argument
134 mmio_dbmsg = (void __iomem *)stdev->mmio_ntb + in flush_wc_buf()
139 static void mrpc_cmd_submit(struct switchtec_dev *stdev) in mrpc_cmd_submit() argument
145 if (stdev->mrpc_busy) in mrpc_cmd_submit()
148 if (list_empty(&stdev->mrpc_queue)) in mrpc_cmd_submit()
151 stuser = list_entry(stdev->mrpc_queue.next, struct switchtec_user, in mrpc_cmd_submit()
154 if (stdev->dma_mrpc) { in mrpc_cmd_submit()
155 stdev->dma_mrpc->status = SWITCHTEC_MRPC_STATUS_INPROGRESS; in mrpc_cmd_submit()
156 memset(stdev->dma_mrpc->data, 0xFF, SWITCHTEC_MRPC_PAYLOAD_SIZE); in mrpc_cmd_submit()
160 stdev->mrpc_busy = 1; in mrpc_cmd_submit()
161 memcpy_toio(&stdev->mmio_mrpc->input_data, in mrpc_cmd_submit()
163 flush_wc_buf(stdev); in mrpc_cmd_submit()
164 iowrite32(stuser->cmd, &stdev->mmio_mrpc->cmd); in mrpc_cmd_submit()
166 schedule_delayed_work(&stdev->mrpc_timeout, in mrpc_cmd_submit()
174 struct switchtec_dev *stdev = stuser->stdev; in mrpc_queue_cmd() local
180 list_add_tail(&stuser->list, &stdev->mrpc_queue); in mrpc_queue_cmd()
182 mrpc_cmd_submit(stdev); in mrpc_queue_cmd()
187 static void mrpc_complete_cmd(struct switchtec_dev *stdev) in mrpc_complete_cmd() argument
192 if (list_empty(&stdev->mrpc_queue)) in mrpc_complete_cmd()
195 stuser = list_entry(stdev->mrpc_queue.next, struct switchtec_user, in mrpc_complete_cmd()
198 if (stdev->dma_mrpc) in mrpc_complete_cmd()
199 stuser->status = stdev->dma_mrpc->status; in mrpc_complete_cmd()
201 stuser->status = ioread32(&stdev->mmio_mrpc->status); in mrpc_complete_cmd()
212 if (stdev->dma_mrpc) in mrpc_complete_cmd()
213 stuser->return_code = stdev->dma_mrpc->rtn_code; in mrpc_complete_cmd()
215 stuser->return_code = ioread32(&stdev->mmio_mrpc->ret_value); in mrpc_complete_cmd()
219 if (stdev->dma_mrpc) in mrpc_complete_cmd()
220 memcpy(stuser->data, &stdev->dma_mrpc->data, in mrpc_complete_cmd()
223 memcpy_fromio(stuser->data, &stdev->mmio_mrpc->output_data, in mrpc_complete_cmd()
230 stdev->mrpc_busy = 0; in mrpc_complete_cmd()
232 mrpc_cmd_submit(stdev); in mrpc_complete_cmd()
237 struct switchtec_dev *stdev; in mrpc_event_work() local
239 stdev = container_of(work, struct switchtec_dev, mrpc_work); in mrpc_event_work()
241 dev_dbg(&stdev->dev, "%s\n", __func__); in mrpc_event_work()
243 mutex_lock(&stdev->mrpc_mutex); in mrpc_event_work()
244 cancel_delayed_work(&stdev->mrpc_timeout); in mrpc_event_work()
245 mrpc_complete_cmd(stdev); in mrpc_event_work()
246 mutex_unlock(&stdev->mrpc_mutex); in mrpc_event_work()
251 struct switchtec_dev *stdev; in mrpc_timeout_work() local
254 stdev = container_of(work, struct switchtec_dev, mrpc_timeout.work); in mrpc_timeout_work()
256 dev_dbg(&stdev->dev, "%s\n", __func__); in mrpc_timeout_work()
258 mutex_lock(&stdev->mrpc_mutex); in mrpc_timeout_work()
260 if (stdev->dma_mrpc) in mrpc_timeout_work()
261 status = stdev->dma_mrpc->status; in mrpc_timeout_work()
263 status = ioread32(&stdev->mmio_mrpc->status); in mrpc_timeout_work()
265 schedule_delayed_work(&stdev->mrpc_timeout, in mrpc_timeout_work()
270 mrpc_complete_cmd(stdev); in mrpc_timeout_work()
272 mutex_unlock(&stdev->mrpc_mutex); in mrpc_timeout_work()
278 struct switchtec_dev *stdev = to_stdev(dev); in device_version_show() local
281 ver = ioread32(&stdev->mmio_sys_info->device_version); in device_version_show()
290 struct switchtec_dev *stdev = to_stdev(dev); in fw_version_show() local
293 ver = ioread32(&stdev->mmio_sys_info->firmware_version); in fw_version_show()
321 struct switchtec_dev *stdev = to_stdev(dev); \
322 struct sys_info_regs __iomem *si = stdev->mmio_sys_info; \
323 if (stdev->gen == SWITCHTEC_GEN3) \
326 else if (stdev->gen == SWITCHTEC_GEN4) \
342 struct switchtec_dev *stdev = to_stdev(dev); in component_vendor_show() local
343 struct sys_info_regs __iomem *si = stdev->mmio_sys_info; in component_vendor_show()
346 if (stdev->gen != SWITCHTEC_GEN3) in component_vendor_show()
357 struct switchtec_dev *stdev = to_stdev(dev); in component_id_show() local
358 int id = ioread16(&stdev->mmio_sys_info->gen3.component_id); in component_id_show()
361 if (stdev->gen != SWITCHTEC_GEN3) in component_id_show()
371 struct switchtec_dev *stdev = to_stdev(dev); in component_revision_show() local
372 int rev = ioread8(&stdev->mmio_sys_info->gen3.component_revision); in component_revision_show()
375 if (stdev->gen != SWITCHTEC_GEN3) in component_revision_show()
385 struct switchtec_dev *stdev = to_stdev(dev); in partition_show() local
387 return sprintf(buf, "%d\n", stdev->partition); in partition_show()
394 struct switchtec_dev *stdev = to_stdev(dev); in partition_count_show() local
396 return sprintf(buf, "%d\n", stdev->partition_count); in partition_count_show()
418 struct switchtec_dev *stdev; in switchtec_dev_open() local
421 stdev = container_of(inode->i_cdev, struct switchtec_dev, cdev); in switchtec_dev_open()
423 stuser = stuser_create(stdev); in switchtec_dev_open()
430 dev_dbg(&stdev->dev, "%s: %p\n", __func__, stuser); in switchtec_dev_open()
444 static int lock_mutex_and_test_alive(struct switchtec_dev *stdev) in lock_mutex_and_test_alive() argument
446 if (mutex_lock_interruptible(&stdev->mrpc_mutex)) in lock_mutex_and_test_alive()
449 if (!stdev->alive) { in lock_mutex_and_test_alive()
450 mutex_unlock(&stdev->mrpc_mutex); in lock_mutex_and_test_alive()
461 struct switchtec_dev *stdev = stuser->stdev; in switchtec_dev_write() local
470 rc = lock_mutex_and_test_alive(stdev); in switchtec_dev_write()
501 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_write()
513 struct switchtec_dev *stdev = stuser->stdev; in switchtec_dev_read() local
520 rc = lock_mutex_and_test_alive(stdev); in switchtec_dev_read()
525 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_read()
531 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_read()
543 rc = lock_mutex_and_test_alive(stdev); in switchtec_dev_read()
548 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_read()
570 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_read()
583 struct switchtec_dev *stdev = stuser->stdev; in switchtec_dev_poll() local
587 poll_wait(filp, &stdev->event_wq, wait); in switchtec_dev_poll()
589 if (lock_mutex_and_test_alive(stdev)) in switchtec_dev_poll()
592 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_poll()
597 if (stuser->event_cnt != atomic_read(&stdev->event_cnt)) in switchtec_dev_poll()
603 static int ioctl_flash_info(struct switchtec_dev *stdev, in ioctl_flash_info() argument
607 struct flash_info_regs __iomem *fi = stdev->mmio_flash_info; in ioctl_flash_info()
609 if (stdev->gen == SWITCHTEC_GEN3) { in ioctl_flash_info()
612 } else if (stdev->gen == SWITCHTEC_GEN4) { in ioctl_flash_info()
632 static int flash_part_info_gen3(struct switchtec_dev *stdev, in flash_part_info_gen3() argument
636 &stdev->mmio_flash_info->gen3; in flash_part_info_gen3()
637 struct sys_info_regs_gen3 __iomem *si = &stdev->mmio_sys_info->gen3; in flash_part_info_gen3()
702 static int flash_part_info_gen4(struct switchtec_dev *stdev, in flash_part_info_gen4() argument
705 struct flash_info_regs_gen4 __iomem *fi = &stdev->mmio_flash_info->gen4; in flash_part_info_gen4()
706 struct sys_info_regs_gen4 __iomem *si = &stdev->mmio_sys_info->gen4; in flash_part_info_gen4()
806 static int ioctl_flash_part_info(struct switchtec_dev *stdev, in ioctl_flash_part_info() argument
815 if (stdev->gen == SWITCHTEC_GEN3) { in ioctl_flash_part_info()
816 ret = flash_part_info_gen3(stdev, &info); in ioctl_flash_part_info()
819 } else if (stdev->gen == SWITCHTEC_GEN4) { in ioctl_flash_part_info()
820 ret = flash_part_info_gen4(stdev, &info); in ioctl_flash_part_info()
833 static int ioctl_event_summary(struct switchtec_dev *stdev, in ioctl_event_summary() argument
847 s->global = ioread32(&stdev->mmio_sw_event->global_summary); in ioctl_event_summary()
848 s->part_bitmap = ioread64(&stdev->mmio_sw_event->part_event_bitmap); in ioctl_event_summary()
849 s->local_part = ioread32(&stdev->mmio_part_cfg->part_event_summary); in ioctl_event_summary()
851 for (i = 0; i < stdev->partition_count; i++) { in ioctl_event_summary()
852 reg = ioread32(&stdev->mmio_part_cfg_all[i].part_event_summary); in ioctl_event_summary()
856 for (i = 0; i < stdev->pff_csr_count; i++) { in ioctl_event_summary()
857 reg = ioread32(&stdev->mmio_pff_csr[i].pff_event_summary); in ioctl_event_summary()
866 stuser->event_cnt = atomic_read(&stdev->event_cnt); in ioctl_event_summary()
873 static u32 __iomem *global_ev_reg(struct switchtec_dev *stdev, in global_ev_reg() argument
876 return (void __iomem *)stdev->mmio_sw_event + offset; in global_ev_reg()
879 static u32 __iomem *part_ev_reg(struct switchtec_dev *stdev, in part_ev_reg() argument
882 return (void __iomem *)&stdev->mmio_part_cfg_all[index] + offset; in part_ev_reg()
885 static u32 __iomem *pff_ev_reg(struct switchtec_dev *stdev, in pff_ev_reg() argument
888 return (void __iomem *)&stdev->mmio_pff_csr[index] + offset; in pff_ev_reg()
897 u32 __iomem *(*map_reg)(struct switchtec_dev *stdev,
937 static u32 __iomem *event_hdr_addr(struct switchtec_dev *stdev, in event_hdr_addr() argument
949 index = stdev->partition; in event_hdr_addr()
950 else if (index < 0 || index >= stdev->partition_count) in event_hdr_addr()
953 if (index < 0 || index >= stdev->pff_csr_count) in event_hdr_addr()
957 return event_regs[event_id].map_reg(stdev, off, index); in event_hdr_addr()
960 static int event_ctl(struct switchtec_dev *stdev, in event_ctl() argument
967 reg = event_hdr_addr(stdev, ctl->event_id, ctl->index); in event_ctl()
1013 static int ioctl_event_ctl(struct switchtec_dev *stdev, in ioctl_event_ctl() argument
1034 nr_idxs = stdev->partition_count; in ioctl_event_ctl()
1036 nr_idxs = stdev->pff_csr_count; in ioctl_event_ctl()
1043 ret = event_ctl(stdev, &ctl); in ioctl_event_ctl()
1048 ret = event_ctl(stdev, &ctl); in ioctl_event_ctl()
1059 static int ioctl_pff_to_port(struct switchtec_dev *stdev, in ioctl_pff_to_port() argument
1071 for (part = 0; part < stdev->partition_count; part++) { in ioctl_pff_to_port()
1072 pcfg = &stdev->mmio_part_cfg_all[part]; in ioctl_pff_to_port()
1106 static int ioctl_port_to_pff(struct switchtec_dev *stdev, in ioctl_port_to_pff() argument
1116 pcfg = stdev->mmio_part_cfg; in ioctl_port_to_pff()
1117 else if (p.partition < stdev->partition_count) in ioctl_port_to_pff()
1118 pcfg = &stdev->mmio_part_cfg_all[p.partition]; in ioctl_port_to_pff()
1148 struct switchtec_dev *stdev = stuser->stdev; in switchtec_dev_ioctl() local
1152 rc = lock_mutex_and_test_alive(stdev); in switchtec_dev_ioctl()
1158 rc = ioctl_flash_info(stdev, argp); in switchtec_dev_ioctl()
1161 rc = ioctl_flash_part_info(stdev, argp); in switchtec_dev_ioctl()
1164 rc = ioctl_event_summary(stdev, stuser, argp, in switchtec_dev_ioctl()
1168 rc = ioctl_event_ctl(stdev, argp); in switchtec_dev_ioctl()
1171 rc = ioctl_pff_to_port(stdev, argp); in switchtec_dev_ioctl()
1174 rc = ioctl_port_to_pff(stdev, argp); in switchtec_dev_ioctl()
1177 rc = ioctl_event_summary(stdev, stuser, argp, in switchtec_dev_ioctl()
1185 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_ioctl()
1202 struct switchtec_dev *stdev; in link_event_work() local
1204 stdev = container_of(work, struct switchtec_dev, link_event_work); in link_event_work()
1206 if (stdev->link_notifier) in link_event_work()
1207 stdev->link_notifier(stdev); in link_event_work()
1210 static void check_link_state_events(struct switchtec_dev *stdev) in check_link_state_events() argument
1217 for (idx = 0; idx < stdev->pff_csr_count; idx++) { in check_link_state_events()
1218 reg = ioread32(&stdev->mmio_pff_csr[idx].link_state_hdr); in check_link_state_events()
1219 dev_dbg(&stdev->dev, "link_state: %d->%08x\n", idx, reg); in check_link_state_events()
1222 if (count != stdev->link_event_count[idx]) { in check_link_state_events()
1224 stdev->link_event_count[idx] = count; in check_link_state_events()
1229 schedule_work(&stdev->link_event_work); in check_link_state_events()
1232 static void enable_link_state_events(struct switchtec_dev *stdev) in enable_link_state_events() argument
1236 for (idx = 0; idx < stdev->pff_csr_count; idx++) { in enable_link_state_events()
1239 &stdev->mmio_pff_csr[idx].link_state_hdr); in enable_link_state_events()
1243 static void enable_dma_mrpc(struct switchtec_dev *stdev) in enable_dma_mrpc() argument
1245 writeq(stdev->dma_mrpc_dma_addr, &stdev->mmio_mrpc->dma_addr); in enable_dma_mrpc()
1246 flush_wc_buf(stdev); in enable_dma_mrpc()
1247 iowrite32(SWITCHTEC_DMA_MRPC_EN, &stdev->mmio_mrpc->dma_en); in enable_dma_mrpc()
1252 struct switchtec_dev *stdev = to_stdev(dev); in stdev_release() local
1254 if (stdev->dma_mrpc) { in stdev_release()
1255 iowrite32(0, &stdev->mmio_mrpc->dma_en); in stdev_release()
1256 flush_wc_buf(stdev); in stdev_release()
1257 writeq(0, &stdev->mmio_mrpc->dma_addr); in stdev_release()
1258 dma_free_coherent(&stdev->pdev->dev, sizeof(*stdev->dma_mrpc), in stdev_release()
1259 stdev->dma_mrpc, stdev->dma_mrpc_dma_addr); in stdev_release()
1261 kfree(stdev); in stdev_release()
1264 static void stdev_kill(struct switchtec_dev *stdev) in stdev_kill() argument
1268 pci_clear_master(stdev->pdev); in stdev_kill()
1270 cancel_delayed_work_sync(&stdev->mrpc_timeout); in stdev_kill()
1273 mutex_lock(&stdev->mrpc_mutex); in stdev_kill()
1274 stdev->alive = false; in stdev_kill()
1277 list_for_each_entry_safe(stuser, tmpuser, &stdev->mrpc_queue, list) { in stdev_kill()
1284 mutex_unlock(&stdev->mrpc_mutex); in stdev_kill()
1287 wake_up_interruptible(&stdev->event_wq); in stdev_kill()
1292 struct switchtec_dev *stdev; in stdev_create() local
1298 stdev = kzalloc_node(sizeof(*stdev), GFP_KERNEL, in stdev_create()
1300 if (!stdev) in stdev_create()
1303 stdev->alive = true; in stdev_create()
1304 stdev->pdev = pdev; in stdev_create()
1305 INIT_LIST_HEAD(&stdev->mrpc_queue); in stdev_create()
1306 mutex_init(&stdev->mrpc_mutex); in stdev_create()
1307 stdev->mrpc_busy = 0; in stdev_create()
1308 INIT_WORK(&stdev->mrpc_work, mrpc_event_work); in stdev_create()
1309 INIT_DELAYED_WORK(&stdev->mrpc_timeout, mrpc_timeout_work); in stdev_create()
1310 INIT_WORK(&stdev->link_event_work, link_event_work); in stdev_create()
1311 init_waitqueue_head(&stdev->event_wq); in stdev_create()
1312 atomic_set(&stdev->event_cnt, 0); in stdev_create()
1314 dev = &stdev->dev; in stdev_create()
1331 cdev = &stdev->cdev; in stdev_create()
1335 return stdev; in stdev_create()
1338 put_device(&stdev->dev); in stdev_create()
1342 static int mask_event(struct switchtec_dev *stdev, int eid, int idx) in mask_event() argument
1348 hdr_reg = event_regs[eid].map_reg(stdev, off, idx); in mask_event()
1354 dev_dbg(&stdev->dev, "%s: %d %d %x\n", __func__, eid, idx, hdr); in mask_event()
1361 static int mask_all_events(struct switchtec_dev *stdev, int eid) in mask_all_events() argument
1367 for (idx = 0; idx < stdev->partition_count; idx++) in mask_all_events()
1368 count += mask_event(stdev, eid, idx); in mask_all_events()
1370 for (idx = 0; idx < stdev->pff_csr_count; idx++) { in mask_all_events()
1371 if (!stdev->pff_local[idx]) in mask_all_events()
1374 count += mask_event(stdev, eid, idx); in mask_all_events()
1377 count += mask_event(stdev, eid, 0); in mask_all_events()
1385 struct switchtec_dev *stdev = dev; in switchtec_event_isr() local
1390 reg = ioread32(&stdev->mmio_part_cfg->mrpc_comp_hdr); in switchtec_event_isr()
1392 dev_dbg(&stdev->dev, "%s: mrpc comp\n", __func__); in switchtec_event_isr()
1394 schedule_work(&stdev->mrpc_work); in switchtec_event_isr()
1395 iowrite32(reg, &stdev->mmio_part_cfg->mrpc_comp_hdr); in switchtec_event_isr()
1398 check_link_state_events(stdev); in switchtec_event_isr()
1405 event_count += mask_all_events(stdev, eid); in switchtec_event_isr()
1409 atomic_inc(&stdev->event_cnt); in switchtec_event_isr()
1410 wake_up_interruptible(&stdev->event_wq); in switchtec_event_isr()
1411 dev_dbg(&stdev->dev, "%s: %d events\n", __func__, in switchtec_event_isr()
1422 struct switchtec_dev *stdev = dev; in switchtec_dma_mrpc_isr() local
1427 &stdev->mmio_part_cfg->mrpc_comp_hdr); in switchtec_dma_mrpc_isr()
1428 schedule_work(&stdev->mrpc_work); in switchtec_dma_mrpc_isr()
1434 static int switchtec_init_isr(struct switchtec_dev *stdev) in switchtec_init_isr() argument
1444 nvecs = pci_alloc_irq_vectors(stdev->pdev, 1, nirqs, in switchtec_init_isr()
1450 event_irq = ioread16(&stdev->mmio_part_cfg->vep_vector_number); in switchtec_init_isr()
1454 event_irq = pci_irq_vector(stdev->pdev, event_irq); in switchtec_init_isr()
1458 rc = devm_request_irq(&stdev->pdev->dev, event_irq, in switchtec_init_isr()
1460 KBUILD_MODNAME, stdev); in switchtec_init_isr()
1465 if (!stdev->dma_mrpc) in switchtec_init_isr()
1468 dma_mrpc_irq = ioread32(&stdev->mmio_mrpc->dma_vector); in switchtec_init_isr()
1472 dma_mrpc_irq = pci_irq_vector(stdev->pdev, dma_mrpc_irq); in switchtec_init_isr()
1476 rc = devm_request_irq(&stdev->pdev->dev, dma_mrpc_irq, in switchtec_init_isr()
1478 KBUILD_MODNAME, stdev); in switchtec_init_isr()
1483 static void init_pff(struct switchtec_dev *stdev) in init_pff() argument
1487 struct part_cfg_regs __iomem *pcfg = stdev->mmio_part_cfg; in init_pff()
1490 reg = ioread16(&stdev->mmio_pff_csr[i].vendor_id); in init_pff()
1495 stdev->pff_csr_count = i; in init_pff()
1498 if (reg < stdev->pff_csr_count) in init_pff()
1499 stdev->pff_local[reg] = 1; in init_pff()
1502 if (reg < stdev->pff_csr_count) in init_pff()
1503 stdev->pff_local[reg] = 1; in init_pff()
1507 if (reg < stdev->pff_csr_count) in init_pff()
1508 stdev->pff_local[reg] = 1; in init_pff()
1512 static int switchtec_init_pci(struct switchtec_dev *stdev, in switchtec_init_pci() argument
1537 stdev->mmio_mrpc = devm_ioremap_wc(&pdev->dev, res_start, in switchtec_init_pci()
1539 if (!stdev->mmio_mrpc) in switchtec_init_pci()
1548 stdev->mmio = map - SWITCHTEC_GAS_TOP_CFG_OFFSET; in switchtec_init_pci()
1549 stdev->mmio_sw_event = stdev->mmio + SWITCHTEC_GAS_SW_EVENT_OFFSET; in switchtec_init_pci()
1550 stdev->mmio_sys_info = stdev->mmio + SWITCHTEC_GAS_SYS_INFO_OFFSET; in switchtec_init_pci()
1551 stdev->mmio_flash_info = stdev->mmio + SWITCHTEC_GAS_FLASH_INFO_OFFSET; in switchtec_init_pci()
1552 stdev->mmio_ntb = stdev->mmio + SWITCHTEC_GAS_NTB_OFFSET; in switchtec_init_pci()
1554 if (stdev->gen == SWITCHTEC_GEN3) in switchtec_init_pci()
1555 part_id = &stdev->mmio_sys_info->gen3.partition_id; in switchtec_init_pci()
1556 else if (stdev->gen == SWITCHTEC_GEN4) in switchtec_init_pci()
1557 part_id = &stdev->mmio_sys_info->gen4.partition_id; in switchtec_init_pci()
1561 stdev->partition = ioread8(part_id); in switchtec_init_pci()
1562 stdev->partition_count = ioread8(&stdev->mmio_ntb->partition_count); in switchtec_init_pci()
1563 stdev->mmio_part_cfg_all = stdev->mmio + SWITCHTEC_GAS_PART_CFG_OFFSET; in switchtec_init_pci()
1564 stdev->mmio_part_cfg = &stdev->mmio_part_cfg_all[stdev->partition]; in switchtec_init_pci()
1565 stdev->mmio_pff_csr = stdev->mmio + SWITCHTEC_GAS_PFF_CSR_OFFSET; in switchtec_init_pci()
1567 if (stdev->partition_count < 1) in switchtec_init_pci()
1568 stdev->partition_count = 1; in switchtec_init_pci()
1570 init_pff(stdev); in switchtec_init_pci()
1572 pci_set_drvdata(pdev, stdev); in switchtec_init_pci()
1577 if (ioread32(&stdev->mmio_mrpc->dma_ver) == 0) in switchtec_init_pci()
1580 stdev->dma_mrpc = dma_alloc_coherent(&stdev->pdev->dev, in switchtec_init_pci()
1581 sizeof(*stdev->dma_mrpc), in switchtec_init_pci()
1582 &stdev->dma_mrpc_dma_addr, in switchtec_init_pci()
1584 if (stdev->dma_mrpc == NULL) in switchtec_init_pci()
1593 struct switchtec_dev *stdev; in switchtec_pci_probe() local
1599 stdev = stdev_create(pdev); in switchtec_pci_probe()
1600 if (IS_ERR(stdev)) in switchtec_pci_probe()
1601 return PTR_ERR(stdev); in switchtec_pci_probe()
1603 stdev->gen = id->driver_data; in switchtec_pci_probe()
1605 rc = switchtec_init_pci(stdev, pdev); in switchtec_pci_probe()
1609 rc = switchtec_init_isr(stdev); in switchtec_pci_probe()
1611 dev_err(&stdev->dev, "failed to init isr.\n"); in switchtec_pci_probe()
1617 &stdev->mmio_part_cfg->mrpc_comp_hdr); in switchtec_pci_probe()
1618 enable_link_state_events(stdev); in switchtec_pci_probe()
1620 if (stdev->dma_mrpc) in switchtec_pci_probe()
1621 enable_dma_mrpc(stdev); in switchtec_pci_probe()
1623 rc = cdev_device_add(&stdev->cdev, &stdev->dev); in switchtec_pci_probe()
1627 dev_info(&stdev->dev, "Management device registered.\n"); in switchtec_pci_probe()
1632 stdev_kill(stdev); in switchtec_pci_probe()
1634 ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt)); in switchtec_pci_probe()
1635 put_device(&stdev->dev); in switchtec_pci_probe()
1641 struct switchtec_dev *stdev = pci_get_drvdata(pdev); in switchtec_pci_remove() local
1645 cdev_device_del(&stdev->cdev, &stdev->dev); in switchtec_pci_remove()
1646 ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt)); in switchtec_pci_remove()
1647 dev_info(&stdev->dev, "unregistered.\n"); in switchtec_pci_remove()
1648 stdev_kill(stdev); in switchtec_pci_remove()
1649 put_device(&stdev->dev); in switchtec_pci_remove()