Lines Matching refs:dev

46     SpaprVioDevice *dev = VIO_SPAPR_DEVICE(qdev);  in spapr_vio_get_dev_name()  local
47 SpaprVioDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev); in spapr_vio_get_dev_name()
50 return g_strdup_printf("%s@%x", pc->dt_name, dev->reg); in spapr_vio_get_dev_name()
71 SpaprVioDevice *dev = NULL; in spapr_vio_find_by_reg() local
74 dev = (SpaprVioDevice *)kid->child; in spapr_vio_find_by_reg()
75 if (dev->reg == reg) { in spapr_vio_find_by_reg()
76 return dev; in spapr_vio_find_by_reg()
83 static int vio_make_devnode(SpaprVioDevice *dev, in vio_make_devnode() argument
86 SpaprVioDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev); in vio_make_devnode()
96 dt_name = spapr_vio_get_dev_name(DEVICE(dev)); in vio_make_devnode()
103 ret = fdt_setprop_cell(fdt, node_off, "reg", dev->reg); in vio_make_devnode()
117 dt_compatible = pc->get_dt_compatible(dev); in vio_make_devnode()
130 if (dev->irq) { in vio_make_devnode()
133 spapr_dt_irq(ints_prop, dev->irq, false); in vio_make_devnode()
141 ret = spapr_tcet_dma_dt(fdt, node_off, "ibm,my-dma-window", dev->tcet); in vio_make_devnode()
147 ret = (pc->devnode)(dev, fdt, node_off); in vio_make_devnode()
165 SpaprVioDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg); in h_reg_crq() local
167 if (!dev) { in h_reg_crq()
186 if (!dev->crq.SendFunc) { in h_reg_crq()
192 if (dev->crq.qsize) { in h_reg_crq()
196 dev->crq.qladdr = queue_addr; in h_reg_crq()
197 dev->crq.qsize = queue_len; in h_reg_crq()
198 dev->crq.qnext = 0; in h_reg_crq()
204 static target_ulong free_crq(SpaprVioDevice *dev) in free_crq() argument
206 dev->crq.qladdr = 0; in free_crq()
207 dev->crq.qsize = 0; in free_crq()
208 dev->crq.qnext = 0; in free_crq()
210 trace_spapr_vio_free_crq(dev->reg); in free_crq()
219 SpaprVioDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg); in h_free_crq() local
221 if (!dev) { in h_free_crq()
226 return free_crq(dev); in h_free_crq()
235 SpaprVioDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg); in h_send_crq() local
238 if (!dev) { in h_send_crq()
245 if (dev->crq.SendFunc) { in h_send_crq()
246 return dev->crq.SendFunc(dev, (uint8_t *)crq_mangle); in h_send_crq()
256 SpaprVioDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg); in h_enable_crq() local
258 if (!dev) { in h_enable_crq()
267 int spapr_vio_send_crq(SpaprVioDevice *dev, uint8_t *crq) in spapr_vio_send_crq() argument
272 if (!dev->crq.qsize) { in spapr_vio_send_crq()
278 rc = spapr_vio_dma_read(dev, dev->crq.qladdr + dev->crq.qnext, &byte, 1); in spapr_vio_send_crq()
286 rc = spapr_vio_dma_write(dev, dev->crq.qladdr + dev->crq.qnext + 8, in spapr_vio_send_crq()
294 rc = spapr_vio_dma_write(dev, dev->crq.qladdr + dev->crq.qnext, crq, 8); in spapr_vio_send_crq()
299 dev->crq.qnext = (dev->crq.qnext + 16) % dev->crq.qsize; in spapr_vio_send_crq()
301 if (dev->signal_state & 1) { in spapr_vio_send_crq()
302 spapr_vio_irq_pulse(dev); in spapr_vio_send_crq()
310 static void spapr_vio_quiesce_one(SpaprVioDevice *dev) in spapr_vio_quiesce_one() argument
312 if (dev->tcet) { in spapr_vio_quiesce_one()
313 device_cold_reset(DEVICE(dev->tcet)); in spapr_vio_quiesce_one()
315 free_crq(dev); in spapr_vio_quiesce_one()
318 void spapr_vio_set_bypass(SpaprVioDevice *dev, bool bypass) in spapr_vio_set_bypass() argument
320 if (!dev->tcet) { in spapr_vio_set_bypass()
324 memory_region_set_enabled(&dev->mrbypass, bypass); in spapr_vio_set_bypass()
325 memory_region_set_enabled(spapr_tce_get_iommu(dev->tcet), !bypass); in spapr_vio_set_bypass()
327 dev->tcet->bypass = bypass; in spapr_vio_set_bypass()
336 SpaprVioDevice *dev; in rtas_set_tce_bypass() local
345 dev = spapr_vio_find_by_reg(bus, unit); in rtas_set_tce_bypass()
346 if (!dev) { in rtas_set_tce_bypass()
351 if (!dev->tcet) { in rtas_set_tce_bypass()
356 spapr_vio_set_bypass(dev, !!enable); in rtas_set_tce_bypass()
368 SpaprVioDevice *dev = NULL; in rtas_quiesce() local
376 dev = (SpaprVioDevice *)kid->child; in rtas_quiesce()
377 spapr_vio_quiesce_one(dev); in rtas_quiesce()
383 static SpaprVioDevice *reg_conflict(SpaprVioDevice *dev) in reg_conflict() argument
385 SpaprVioBus *bus = SPAPR_VIO_BUS(dev->qdev.parent_bus); in reg_conflict()
397 if (other != dev && other->reg == dev->reg) { in reg_conflict()
407 SpaprVioDevice *dev = VIO_SPAPR_DEVICE(qdev); in spapr_vio_busdev_reset() local
408 SpaprVioDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev); in spapr_vio_busdev_reset()
411 spapr_vio_quiesce_one(dev); in spapr_vio_busdev_reset()
413 dev->signal_state = 0; in spapr_vio_busdev_reset()
415 spapr_vio_set_bypass(dev, false); in spapr_vio_busdev_reset()
417 pc->reset(dev); in spapr_vio_busdev_reset()
473 SpaprVioDevice *dev = (SpaprVioDevice *)qdev; in spapr_vio_busdev_realize() local
474 SpaprVioDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev); in spapr_vio_busdev_realize()
477 if (dev->reg != -1) { in spapr_vio_busdev_realize()
484 SpaprVioDevice *other = reg_conflict(dev); in spapr_vio_busdev_realize()
490 dev->reg); in spapr_vio_busdev_realize()
495 SpaprVioBus *bus = SPAPR_VIO_BUS(dev->qdev.parent_bus); in spapr_vio_busdev_realize()
498 dev->reg = bus->next_reg++; in spapr_vio_busdev_realize()
499 } while (reg_conflict(dev)); in spapr_vio_busdev_realize()
503 if (!dev->qdev.id) { in spapr_vio_busdev_realize()
504 id = spapr_vio_get_dev_name(DEVICE(dev)); in spapr_vio_busdev_realize()
505 dev->qdev.id = id; in spapr_vio_busdev_realize()
508 dev->irq = spapr_vio_reg_to_irq(dev->reg); in spapr_vio_busdev_realize()
516 dev->irq = irq; in spapr_vio_busdev_realize()
519 if (spapr_irq_claim(spapr, dev->irq, false, errp) < 0) { in spapr_vio_busdev_realize()
524 uint32_t liobn = SPAPR_VIO_LIOBN(dev->reg); in spapr_vio_busdev_realize()
526 memory_region_init(&dev->mrroot, OBJECT(dev), "iommu-spapr-root", in spapr_vio_busdev_realize()
528 memory_region_init_alias(&dev->mrbypass, OBJECT(dev), in spapr_vio_busdev_realize()
531 memory_region_add_subregion_overlap(&dev->mrroot, 0, &dev->mrbypass, 1); in spapr_vio_busdev_realize()
532 address_space_init(&dev->as, &dev->mrroot, qdev->id); in spapr_vio_busdev_realize()
534 dev->tcet = spapr_tce_new_table(qdev, liobn); in spapr_vio_busdev_realize()
535 spapr_tce_table_enable(dev->tcet, SPAPR_TCE_PAGE_SHIFT, 0, in spapr_vio_busdev_realize()
537 dev->tcet->vdev = dev; in spapr_vio_busdev_realize()
538 memory_region_add_subregion_overlap(&dev->mrroot, 0, in spapr_vio_busdev_realize()
539 spapr_tce_get_iommu(dev->tcet), 2); in spapr_vio_busdev_realize()
542 pc->realize(dev, errp); in spapr_vio_busdev_realize()
551 SpaprVioDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg); in h_vio_signal() local
554 if (!dev) { in h_vio_signal()
558 pc = VIO_SPAPR_DEVICE_GET_CLASS(dev); in h_vio_signal()
564 dev->signal_state = mode; in h_vio_signal()
573 DeviceState *dev; in spapr_vio_bus_init() local
576 dev = qdev_new(TYPE_SPAPR_VIO_BRIDGE); in spapr_vio_bus_init()
579 qbus = qbus_new(TYPE_SPAPR_VIO_BUS, dev, "spapr-vio"); in spapr_vio_bus_init()
583 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); in spapr_vio_bus_init()
713 SpaprVioDevice *dev = (SpaprVioDevice *)(qdevs[i]); in spapr_dt_vdevice() local
714 SpaprVioDeviceClass *vdc = VIO_SPAPR_DEVICE_GET_CLASS(dev); in spapr_dt_vdevice()
716 ret = vio_make_devnode(dev, fdt); in spapr_dt_vdevice()
719 vdc->dt_name, dev->reg); in spapr_dt_vdevice()
729 SpaprVioDevice *dev; in spapr_vio_stdout_path() local
732 dev = spapr_vty_get_default(bus); in spapr_vio_stdout_path()
733 if (!dev) { in spapr_vio_stdout_path()
737 name = spapr_vio_get_dev_name(DEVICE(dev)); in spapr_vio_stdout_path()