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()
609 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_read()
617 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_read()
623 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_read()
637 struct switchtec_dev *stdev = stuser->stdev; in switchtec_dev_poll() local
641 poll_wait(filp, &stdev->event_wq, wait); in switchtec_dev_poll()
643 if (lock_mutex_and_test_alive(stdev)) in switchtec_dev_poll()
646 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_poll()
651 if (stuser->event_cnt != atomic_read(&stdev->event_cnt)) in switchtec_dev_poll()
657 static int ioctl_flash_info(struct switchtec_dev *stdev, in ioctl_flash_info() argument
661 struct flash_info_regs __iomem *fi = stdev->mmio_flash_info; in ioctl_flash_info()
663 if (stdev->gen == SWITCHTEC_GEN3) { in ioctl_flash_info()
666 } else if (stdev->gen == SWITCHTEC_GEN4) { in ioctl_flash_info()
686 static int flash_part_info_gen3(struct switchtec_dev *stdev, in flash_part_info_gen3() argument
690 &stdev->mmio_flash_info->gen3; in flash_part_info_gen3()
691 struct sys_info_regs_gen3 __iomem *si = &stdev->mmio_sys_info->gen3; in flash_part_info_gen3()
756 static int flash_part_info_gen4(struct switchtec_dev *stdev, in flash_part_info_gen4() argument
759 struct flash_info_regs_gen4 __iomem *fi = &stdev->mmio_flash_info->gen4; in flash_part_info_gen4()
760 struct sys_info_regs_gen4 __iomem *si = &stdev->mmio_sys_info->gen4; in flash_part_info_gen4()
860 static int ioctl_flash_part_info(struct switchtec_dev *stdev, in ioctl_flash_part_info() argument
869 if (stdev->gen == SWITCHTEC_GEN3) { in ioctl_flash_part_info()
870 ret = flash_part_info_gen3(stdev, &info); in ioctl_flash_part_info()
873 } else if (stdev->gen == SWITCHTEC_GEN4) { in ioctl_flash_part_info()
874 ret = flash_part_info_gen4(stdev, &info); in ioctl_flash_part_info()
887 static int ioctl_event_summary(struct switchtec_dev *stdev, in ioctl_event_summary() argument
901 s->global = ioread32(&stdev->mmio_sw_event->global_summary); in ioctl_event_summary()
902 s->part_bitmap = ioread64(&stdev->mmio_sw_event->part_event_bitmap); in ioctl_event_summary()
903 s->local_part = ioread32(&stdev->mmio_part_cfg->part_event_summary); in ioctl_event_summary()
905 for (i = 0; i < stdev->partition_count; i++) { in ioctl_event_summary()
906 reg = ioread32(&stdev->mmio_part_cfg_all[i].part_event_summary); in ioctl_event_summary()
910 for (i = 0; i < stdev->pff_csr_count; i++) { in ioctl_event_summary()
911 reg = ioread32(&stdev->mmio_pff_csr[i].pff_event_summary); in ioctl_event_summary()
920 stuser->event_cnt = atomic_read(&stdev->event_cnt); in ioctl_event_summary()
927 static u32 __iomem *global_ev_reg(struct switchtec_dev *stdev, in global_ev_reg() argument
930 return (void __iomem *)stdev->mmio_sw_event + offset; in global_ev_reg()
933 static u32 __iomem *part_ev_reg(struct switchtec_dev *stdev, in part_ev_reg() argument
936 return (void __iomem *)&stdev->mmio_part_cfg_all[index] + offset; in part_ev_reg()
939 static u32 __iomem *pff_ev_reg(struct switchtec_dev *stdev, in pff_ev_reg() argument
942 return (void __iomem *)&stdev->mmio_pff_csr[index] + offset; in pff_ev_reg()
951 u32 __iomem *(*map_reg)(struct switchtec_dev *stdev,
991 static u32 __iomem *event_hdr_addr(struct switchtec_dev *stdev, in event_hdr_addr() argument
1003 index = stdev->partition; in event_hdr_addr()
1004 else if (index < 0 || index >= stdev->partition_count) in event_hdr_addr()
1007 if (index < 0 || index >= stdev->pff_csr_count) in event_hdr_addr()
1011 return event_regs[event_id].map_reg(stdev, off, index); in event_hdr_addr()
1014 static int event_ctl(struct switchtec_dev *stdev, in event_ctl() argument
1021 reg = event_hdr_addr(stdev, ctl->event_id, ctl->index); in event_ctl()
1070 static int ioctl_event_ctl(struct switchtec_dev *stdev, in ioctl_event_ctl() argument
1091 nr_idxs = stdev->partition_count; in ioctl_event_ctl()
1093 nr_idxs = stdev->pff_csr_count; in ioctl_event_ctl()
1100 ret = event_ctl(stdev, &ctl); in ioctl_event_ctl()
1105 ret = event_ctl(stdev, &ctl); in ioctl_event_ctl()
1116 static int ioctl_pff_to_port(struct switchtec_dev *stdev, in ioctl_pff_to_port() argument
1128 for (part = 0; part < stdev->partition_count; part++) { in ioctl_pff_to_port()
1129 pcfg = &stdev->mmio_part_cfg_all[part]; in ioctl_pff_to_port()
1163 static int ioctl_port_to_pff(struct switchtec_dev *stdev, in ioctl_port_to_pff() argument
1173 pcfg = stdev->mmio_part_cfg; in ioctl_port_to_pff()
1174 else if (p.partition < stdev->partition_count) in ioctl_port_to_pff()
1175 pcfg = &stdev->mmio_part_cfg_all[p.partition]; in ioctl_port_to_pff()
1205 struct switchtec_dev *stdev = stuser->stdev; in switchtec_dev_ioctl() local
1209 rc = lock_mutex_and_test_alive(stdev); in switchtec_dev_ioctl()
1215 rc = ioctl_flash_info(stdev, argp); in switchtec_dev_ioctl()
1218 rc = ioctl_flash_part_info(stdev, argp); in switchtec_dev_ioctl()
1221 rc = ioctl_event_summary(stdev, stuser, argp, in switchtec_dev_ioctl()
1225 rc = ioctl_event_ctl(stdev, argp); in switchtec_dev_ioctl()
1228 rc = ioctl_pff_to_port(stdev, argp); in switchtec_dev_ioctl()
1231 rc = ioctl_port_to_pff(stdev, argp); in switchtec_dev_ioctl()
1234 rc = ioctl_event_summary(stdev, stuser, argp, in switchtec_dev_ioctl()
1242 mutex_unlock(&stdev->mrpc_mutex); in switchtec_dev_ioctl()
1259 struct switchtec_dev *stdev; in link_event_work() local
1261 stdev = container_of(work, struct switchtec_dev, link_event_work); in link_event_work()
1263 if (stdev->link_notifier) in link_event_work()
1264 stdev->link_notifier(stdev); in link_event_work()
1267 static void check_link_state_events(struct switchtec_dev *stdev) in check_link_state_events() argument
1274 for (idx = 0; idx < stdev->pff_csr_count; idx++) { in check_link_state_events()
1275 reg = ioread32(&stdev->mmio_pff_csr[idx].link_state_hdr); in check_link_state_events()
1276 dev_dbg(&stdev->dev, "link_state: %d->%08x\n", idx, reg); in check_link_state_events()
1279 if (count != stdev->link_event_count[idx]) { in check_link_state_events()
1281 stdev->link_event_count[idx] = count; in check_link_state_events()
1286 schedule_work(&stdev->link_event_work); in check_link_state_events()
1289 static void enable_link_state_events(struct switchtec_dev *stdev) in enable_link_state_events() argument
1293 for (idx = 0; idx < stdev->pff_csr_count; idx++) { in enable_link_state_events()
1296 &stdev->mmio_pff_csr[idx].link_state_hdr); in enable_link_state_events()
1300 static void enable_dma_mrpc(struct switchtec_dev *stdev) in enable_dma_mrpc() argument
1302 writeq(stdev->dma_mrpc_dma_addr, &stdev->mmio_mrpc->dma_addr); in enable_dma_mrpc()
1303 flush_wc_buf(stdev); in enable_dma_mrpc()
1304 iowrite32(SWITCHTEC_DMA_MRPC_EN, &stdev->mmio_mrpc->dma_en); in enable_dma_mrpc()
1309 struct switchtec_dev *stdev = to_stdev(dev); in stdev_release() local
1311 if (stdev->dma_mrpc) { in stdev_release()
1312 iowrite32(0, &stdev->mmio_mrpc->dma_en); in stdev_release()
1313 flush_wc_buf(stdev); in stdev_release()
1314 writeq(0, &stdev->mmio_mrpc->dma_addr); in stdev_release()
1315 dma_free_coherent(&stdev->pdev->dev, sizeof(*stdev->dma_mrpc), in stdev_release()
1316 stdev->dma_mrpc, stdev->dma_mrpc_dma_addr); in stdev_release()
1318 kfree(stdev); in stdev_release()
1321 static void stdev_kill(struct switchtec_dev *stdev) in stdev_kill() argument
1325 pci_clear_master(stdev->pdev); in stdev_kill()
1327 cancel_delayed_work_sync(&stdev->mrpc_timeout); in stdev_kill()
1330 mutex_lock(&stdev->mrpc_mutex); in stdev_kill()
1331 stdev->alive = false; in stdev_kill()
1334 list_for_each_entry_safe(stuser, tmpuser, &stdev->mrpc_queue, list) { in stdev_kill()
1341 mutex_unlock(&stdev->mrpc_mutex); in stdev_kill()
1344 wake_up_interruptible(&stdev->event_wq); in stdev_kill()
1349 struct switchtec_dev *stdev; in stdev_create() local
1355 stdev = kzalloc_node(sizeof(*stdev), GFP_KERNEL, in stdev_create()
1357 if (!stdev) in stdev_create()
1360 stdev->alive = true; in stdev_create()
1361 stdev->pdev = pdev; in stdev_create()
1362 INIT_LIST_HEAD(&stdev->mrpc_queue); in stdev_create()
1363 mutex_init(&stdev->mrpc_mutex); in stdev_create()
1364 stdev->mrpc_busy = 0; in stdev_create()
1365 INIT_WORK(&stdev->mrpc_work, mrpc_event_work); in stdev_create()
1366 INIT_DELAYED_WORK(&stdev->mrpc_timeout, mrpc_timeout_work); in stdev_create()
1367 INIT_WORK(&stdev->link_event_work, link_event_work); in stdev_create()
1368 init_waitqueue_head(&stdev->event_wq); in stdev_create()
1369 atomic_set(&stdev->event_cnt, 0); in stdev_create()
1371 dev = &stdev->dev; in stdev_create()
1387 cdev = &stdev->cdev; in stdev_create()
1391 return stdev; in stdev_create()
1394 put_device(&stdev->dev); in stdev_create()
1398 static int mask_event(struct switchtec_dev *stdev, int eid, int idx) in mask_event() argument
1404 hdr_reg = event_regs[eid].map_reg(stdev, off, idx); in mask_event()
1413 dev_dbg(&stdev->dev, "%s: %d %d %x\n", __func__, eid, idx, hdr); in mask_event()
1420 static int mask_all_events(struct switchtec_dev *stdev, int eid) in mask_all_events() argument
1426 for (idx = 0; idx < stdev->partition_count; idx++) in mask_all_events()
1427 count += mask_event(stdev, eid, idx); in mask_all_events()
1429 for (idx = 0; idx < stdev->pff_csr_count; idx++) { in mask_all_events()
1430 if (!stdev->pff_local[idx]) in mask_all_events()
1433 count += mask_event(stdev, eid, idx); in mask_all_events()
1436 count += mask_event(stdev, eid, 0); in mask_all_events()
1444 struct switchtec_dev *stdev = dev; in switchtec_event_isr() local
1449 reg = ioread32(&stdev->mmio_part_cfg->mrpc_comp_hdr); in switchtec_event_isr()
1451 dev_dbg(&stdev->dev, "%s: mrpc comp\n", __func__); in switchtec_event_isr()
1453 schedule_work(&stdev->mrpc_work); in switchtec_event_isr()
1454 iowrite32(reg, &stdev->mmio_part_cfg->mrpc_comp_hdr); in switchtec_event_isr()
1457 check_link_state_events(stdev); in switchtec_event_isr()
1464 event_count += mask_all_events(stdev, eid); in switchtec_event_isr()
1468 atomic_inc(&stdev->event_cnt); in switchtec_event_isr()
1469 wake_up_interruptible(&stdev->event_wq); in switchtec_event_isr()
1470 dev_dbg(&stdev->dev, "%s: %d events\n", __func__, in switchtec_event_isr()
1481 struct switchtec_dev *stdev = dev; in switchtec_dma_mrpc_isr() local
1485 &stdev->mmio_part_cfg->mrpc_comp_hdr); in switchtec_dma_mrpc_isr()
1486 schedule_work(&stdev->mrpc_work); in switchtec_dma_mrpc_isr()
1491 static int switchtec_init_isr(struct switchtec_dev *stdev) in switchtec_init_isr() argument
1501 nvecs = pci_alloc_irq_vectors(stdev->pdev, 1, nirqs, in switchtec_init_isr()
1507 event_irq = ioread16(&stdev->mmio_part_cfg->vep_vector_number); in switchtec_init_isr()
1511 event_irq = pci_irq_vector(stdev->pdev, event_irq); in switchtec_init_isr()
1515 rc = devm_request_irq(&stdev->pdev->dev, event_irq, in switchtec_init_isr()
1517 KBUILD_MODNAME, stdev); in switchtec_init_isr()
1522 if (!stdev->dma_mrpc) in switchtec_init_isr()
1525 dma_mrpc_irq = ioread32(&stdev->mmio_mrpc->dma_vector); in switchtec_init_isr()
1529 dma_mrpc_irq = pci_irq_vector(stdev->pdev, dma_mrpc_irq); in switchtec_init_isr()
1533 rc = devm_request_irq(&stdev->pdev->dev, dma_mrpc_irq, in switchtec_init_isr()
1535 KBUILD_MODNAME, stdev); in switchtec_init_isr()
1540 static void init_pff(struct switchtec_dev *stdev) in init_pff() argument
1544 struct part_cfg_regs __iomem *pcfg = stdev->mmio_part_cfg; in init_pff()
1547 reg = ioread16(&stdev->mmio_pff_csr[i].vendor_id); in init_pff()
1552 stdev->pff_csr_count = i; in init_pff()
1555 if (reg < stdev->pff_csr_count) in init_pff()
1556 stdev->pff_local[reg] = 1; in init_pff()
1559 if (reg < stdev->pff_csr_count) in init_pff()
1560 stdev->pff_local[reg] = 1; in init_pff()
1564 if (reg < stdev->pff_csr_count) in init_pff()
1565 stdev->pff_local[reg] = 1; in init_pff()
1569 static int switchtec_init_pci(struct switchtec_dev *stdev, in switchtec_init_pci() argument
1594 stdev->mmio_mrpc = devm_ioremap_wc(&pdev->dev, res_start, in switchtec_init_pci()
1596 if (!stdev->mmio_mrpc) in switchtec_init_pci()
1605 stdev->mmio = map - SWITCHTEC_GAS_TOP_CFG_OFFSET; in switchtec_init_pci()
1606 stdev->mmio_sw_event = stdev->mmio + SWITCHTEC_GAS_SW_EVENT_OFFSET; in switchtec_init_pci()
1607 stdev->mmio_sys_info = stdev->mmio + SWITCHTEC_GAS_SYS_INFO_OFFSET; in switchtec_init_pci()
1608 stdev->mmio_flash_info = stdev->mmio + SWITCHTEC_GAS_FLASH_INFO_OFFSET; in switchtec_init_pci()
1609 stdev->mmio_ntb = stdev->mmio + SWITCHTEC_GAS_NTB_OFFSET; in switchtec_init_pci()
1611 if (stdev->gen == SWITCHTEC_GEN3) in switchtec_init_pci()
1612 part_id = &stdev->mmio_sys_info->gen3.partition_id; in switchtec_init_pci()
1613 else if (stdev->gen == SWITCHTEC_GEN4) in switchtec_init_pci()
1614 part_id = &stdev->mmio_sys_info->gen4.partition_id; in switchtec_init_pci()
1618 stdev->partition = ioread8(part_id); in switchtec_init_pci()
1619 stdev->partition_count = ioread8(&stdev->mmio_ntb->partition_count); in switchtec_init_pci()
1620 stdev->mmio_part_cfg_all = stdev->mmio + SWITCHTEC_GAS_PART_CFG_OFFSET; in switchtec_init_pci()
1621 stdev->mmio_part_cfg = &stdev->mmio_part_cfg_all[stdev->partition]; in switchtec_init_pci()
1622 stdev->mmio_pff_csr = stdev->mmio + SWITCHTEC_GAS_PFF_CSR_OFFSET; in switchtec_init_pci()
1624 if (stdev->partition_count < 1) in switchtec_init_pci()
1625 stdev->partition_count = 1; in switchtec_init_pci()
1627 init_pff(stdev); in switchtec_init_pci()
1629 pci_set_drvdata(pdev, stdev); in switchtec_init_pci()
1634 if (ioread32(&stdev->mmio_mrpc->dma_ver) == 0) in switchtec_init_pci()
1637 stdev->dma_mrpc = dma_alloc_coherent(&stdev->pdev->dev, in switchtec_init_pci()
1638 sizeof(*stdev->dma_mrpc), in switchtec_init_pci()
1639 &stdev->dma_mrpc_dma_addr, in switchtec_init_pci()
1641 if (stdev->dma_mrpc == NULL) in switchtec_init_pci()
1650 struct switchtec_dev *stdev; in switchtec_pci_probe() local
1656 stdev = stdev_create(pdev); in switchtec_pci_probe()
1657 if (IS_ERR(stdev)) in switchtec_pci_probe()
1658 return PTR_ERR(stdev); in switchtec_pci_probe()
1660 stdev->gen = id->driver_data; in switchtec_pci_probe()
1662 rc = switchtec_init_pci(stdev, pdev); in switchtec_pci_probe()
1666 rc = switchtec_init_isr(stdev); in switchtec_pci_probe()
1668 dev_err(&stdev->dev, "failed to init isr.\n"); in switchtec_pci_probe()
1674 &stdev->mmio_part_cfg->mrpc_comp_hdr); in switchtec_pci_probe()
1675 enable_link_state_events(stdev); in switchtec_pci_probe()
1677 if (stdev->dma_mrpc) in switchtec_pci_probe()
1678 enable_dma_mrpc(stdev); in switchtec_pci_probe()
1680 rc = cdev_device_add(&stdev->cdev, &stdev->dev); in switchtec_pci_probe()
1684 dev_info(&stdev->dev, "Management device registered.\n"); in switchtec_pci_probe()
1689 stdev_kill(stdev); in switchtec_pci_probe()
1691 ida_free(&switchtec_minor_ida, MINOR(stdev->dev.devt)); in switchtec_pci_probe()
1692 put_device(&stdev->dev); in switchtec_pci_probe()
1698 struct switchtec_dev *stdev = pci_get_drvdata(pdev); in switchtec_pci_remove() local
1702 cdev_device_del(&stdev->cdev, &stdev->dev); in switchtec_pci_remove()
1703 ida_free(&switchtec_minor_ida, MINOR(stdev->dev.devt)); in switchtec_pci_remove()
1704 dev_info(&stdev->dev, "unregistered.\n"); in switchtec_pci_remove()
1705 stdev_kill(stdev); in switchtec_pci_remove()
1706 put_device(&stdev->dev); in switchtec_pci_remove()