Lines Matching refs:cdx_dev
87 static void cdx_destroy_res_attr(struct cdx_device *cdx_dev, int num);
97 struct cdx_device *cdx_dev = to_cdx_device(dev); in cdx_dev_reset() local
98 struct cdx_controller *cdx = cdx_dev->cdx; in cdx_dev_reset()
106 cdx_drv->reset_prepare(cdx_dev); in cdx_dev_reset()
109 ret = cdx->ops->dev_configure(cdx, cdx_dev->bus_num, in cdx_dev_reset()
110 cdx_dev->dev_num, &dev_config); in cdx_dev_reset()
116 cdx_drv->reset_done(cdx_dev); in cdx_dev_reset()
149 struct cdx_device *cdx_dev = to_cdx_device(dev); in cdx_unregister_device() local
150 struct cdx_controller *cdx = cdx_dev->cdx; in cdx_unregister_device()
152 if (cdx_dev->is_bus) { in cdx_unregister_device()
154 if (cdx_dev->enabled && cdx->ops->bus_disable) in cdx_unregister_device()
155 cdx->ops->bus_disable(cdx, cdx_dev->bus_num); in cdx_unregister_device()
157 cdx_destroy_res_attr(cdx_dev, MAX_CDX_DEV_RESOURCES); in cdx_unregister_device()
158 debugfs_remove_recursive(cdx_dev->debugfs_dir); in cdx_unregister_device()
159 kfree(cdx_dev->driver_override); in cdx_unregister_device()
160 cdx_dev->driver_override = NULL; in cdx_unregister_device()
167 device_del(&cdx_dev->dev); in cdx_unregister_device()
168 put_device(&cdx_dev->dev); in cdx_unregister_device()
225 int cdx_set_master(struct cdx_device *cdx_dev) in cdx_set_master() argument
227 struct cdx_controller *cdx = cdx_dev->cdx; in cdx_set_master()
234 ret = cdx->ops->dev_configure(cdx, cdx_dev->bus_num, in cdx_set_master()
235 cdx_dev->dev_num, &dev_config); in cdx_set_master()
241 int cdx_clear_master(struct cdx_device *cdx_dev) in cdx_clear_master() argument
243 struct cdx_controller *cdx = cdx_dev->cdx; in cdx_clear_master()
250 ret = cdx->ops->dev_configure(cdx, cdx_dev->bus_num, in cdx_clear_master()
251 cdx_dev->dev_num, &dev_config); in cdx_clear_master()
267 struct cdx_device *cdx_dev = to_cdx_device(dev); in cdx_bus_match() local
272 if (cdx_dev->is_bus) in cdx_bus_match()
278 if (cdx_dev->driver_override && strcmp(cdx_dev->driver_override, drv->name)) in cdx_bus_match()
281 found_id = cdx_match_id(ids, cdx_dev); in cdx_bus_match()
292 if (cdx_dev->driver_override) in cdx_bus_match()
296 found_id = cdx_match_id(ids, cdx_dev); in cdx_bus_match()
305 struct cdx_device *cdx_dev = to_cdx_device(dev); in cdx_probe() local
306 struct cdx_controller *cdx = cdx_dev->cdx; in cdx_probe()
314 error = msi_setup_device_data(&cdx_dev->dev); in cdx_probe()
319 error = cdx_drv->probe(cdx_dev); in cdx_probe()
331 struct cdx_device *cdx_dev = to_cdx_device(dev); in cdx_remove() local
334 cdx_drv->remove(cdx_dev); in cdx_remove()
340 struct cdx_device *cdx_dev = to_cdx_device(dev); in cdx_shutdown() local
341 struct cdx_controller *cdx = cdx_dev->cdx; in cdx_shutdown()
343 if (cdx_dev->is_bus && cdx_dev->enabled && cdx->ops->bus_disable) in cdx_shutdown()
344 cdx->ops->bus_disable(cdx, cdx_dev->bus_num); in cdx_shutdown()
346 cdx_drv->shutdown(cdx_dev); in cdx_shutdown()
352 struct cdx_device *cdx_dev = to_cdx_device(dev); in cdx_dma_configure() local
353 struct cdx_controller *cdx = cdx_dev->cdx; in cdx_dma_configure()
354 u32 input_id = cdx_dev->req_id; in cdx_dma_configure()
386 struct cdx_device *cdx_dev = to_cdx_device(dev); \
387 return sysfs_emit(buf, format_string, cdx_dev->field); \
425 struct cdx_device *cdx_dev = to_cdx_device(dev); in reset_store() local
435 if (cdx_dev->is_bus) in reset_store()
448 struct cdx_device *cdx_dev = to_cdx_device(dev); in modalias_show() local
450 return sprintf(buf, "cdx:v%04Xd%04Xsv%04Xsd%04Xc%06X\n", cdx_dev->vendor, in modalias_show()
451 cdx_dev->device, cdx_dev->subsystem_vendor, cdx_dev->subsystem_device, in modalias_show()
452 cdx_dev->class); in modalias_show()
460 struct cdx_device *cdx_dev = to_cdx_device(dev); in driver_override_store() local
466 ret = driver_set_override(dev, &cdx_dev->driver_override, buf, count); in driver_override_store()
476 struct cdx_device *cdx_dev = to_cdx_device(dev); in driver_override_show() local
480 len = sysfs_emit(buf, "%s\n", cdx_dev->driver_override); in driver_override_show()
489 struct cdx_device *cdx_dev = to_cdx_device(dev); in enable_store() local
490 struct cdx_controller *cdx = cdx_dev->cdx; in enable_store()
497 if (enable == cdx_dev->enabled) in enable_store()
501 ret = cdx->ops->bus_enable(cdx, cdx_dev->bus_num); in enable_store()
503 ret = cdx->ops->bus_disable(cdx, cdx_dev->bus_num); in enable_store()
508 cdx_dev->enabled = enable; in enable_store()
515 struct cdx_device *cdx_dev = to_cdx_device(dev); in enable_show() local
517 return sysfs_emit(buf, "%u\n", cdx_dev->enabled); in enable_show()
524 struct cdx_device *cdx_dev; in cdx_dev_attrs_are_visible() local
526 cdx_dev = to_cdx_device(dev); in cdx_dev_attrs_are_visible()
527 if (!cdx_dev->is_bus) in cdx_dev_attrs_are_visible()
536 struct cdx_device *cdx_dev; in cdx_bus_attrs_are_visible() local
538 cdx_dev = to_cdx_device(dev); in cdx_bus_attrs_are_visible()
539 if (cdx_dev->is_bus) in cdx_bus_attrs_are_visible()
583 struct cdx_device *cdx_dev = s->private; in cdx_debug_resource_show() local
587 struct resource *res = &cdx_dev->res[i]; in cdx_debug_resource_show()
596 static void cdx_device_debugfs_init(struct cdx_device *cdx_dev) in cdx_device_debugfs_init() argument
598 cdx_dev->debugfs_dir = debugfs_create_dir(dev_name(&cdx_dev->dev), cdx_debugfs_dir); in cdx_device_debugfs_init()
599 if (IS_ERR(cdx_dev->debugfs_dir)) in cdx_device_debugfs_init()
602 debugfs_create_file("resource", 0444, cdx_dev->debugfs_dir, cdx_dev, in cdx_device_debugfs_init()
694 struct cdx_device *cdx_dev = to_cdx_device(dev); in cdx_device_release() local
696 kfree(cdx_dev); in cdx_device_release()
721 struct cdx_device *cdx_dev = to_cdx_device(kobj_to_dev(kobj)); in cdx_mmap_resource() local
726 res = &cdx_dev->res[num]; in cdx_mmap_resource()
731 size = ((cdx_resource_len(cdx_dev, num) - 1) >> PAGE_SHIFT) + 1; in cdx_mmap_resource()
740 vma->vm_pgoff += (cdx_resource_start(cdx_dev, num) >> PAGE_SHIFT); in cdx_mmap_resource()
747 static void cdx_destroy_res_attr(struct cdx_device *cdx_dev, int num) in cdx_destroy_res_attr() argument
755 res_attr = cdx_dev->res_attr[i]; in cdx_destroy_res_attr()
757 sysfs_remove_bin_file(&cdx_dev->dev.kobj, res_attr); in cdx_destroy_res_attr()
764 static int cdx_create_res_attr(struct cdx_device *cdx_dev, int num) in cdx_create_res_attr() argument
778 cdx_dev->res_attr[num] = res_attr; in cdx_create_res_attr()
784 res_attr->size = cdx_resource_len(cdx_dev, num); in cdx_create_res_attr()
786 ret = sysfs_create_bin_file(&cdx_dev->dev.kobj, res_attr); in cdx_create_res_attr()
796 struct cdx_device *cdx_dev; in cdx_device_add() local
799 cdx_dev = kzalloc(sizeof(*cdx_dev), GFP_KERNEL); in cdx_device_add()
800 if (!cdx_dev) in cdx_device_add()
804 memcpy(cdx_dev->res, dev_params->res, sizeof(struct resource) * in cdx_device_add()
806 cdx_dev->res_count = dev_params->res_count; in cdx_device_add()
809 cdx_dev->req_id = dev_params->req_id; in cdx_device_add()
810 cdx_dev->msi_dev_id = dev_params->msi_dev_id; in cdx_device_add()
811 cdx_dev->vendor = dev_params->vendor; in cdx_device_add()
812 cdx_dev->device = dev_params->device; in cdx_device_add()
813 cdx_dev->subsystem_vendor = dev_params->subsys_vendor; in cdx_device_add()
814 cdx_dev->subsystem_device = dev_params->subsys_device; in cdx_device_add()
815 cdx_dev->class = dev_params->class; in cdx_device_add()
816 cdx_dev->revision = dev_params->revision; in cdx_device_add()
817 cdx_dev->bus_num = dev_params->bus_num; in cdx_device_add()
818 cdx_dev->dev_num = dev_params->dev_num; in cdx_device_add()
819 cdx_dev->cdx = dev_params->cdx; in cdx_device_add()
820 cdx_dev->dma_mask = CDX_DEFAULT_DMA_MASK; in cdx_device_add()
823 device_initialize(&cdx_dev->dev); in cdx_device_add()
824 cdx_dev->dev.parent = dev_params->parent; in cdx_device_add()
825 cdx_dev->dev.bus = &cdx_bus_type; in cdx_device_add()
826 cdx_dev->dev.dma_mask = &cdx_dev->dma_mask; in cdx_device_add()
827 cdx_dev->dev.release = cdx_device_release; in cdx_device_add()
828 cdx_dev->msi_write_pending = false; in cdx_device_add()
829 mutex_init(&cdx_dev->irqchip_lock); in cdx_device_add()
832 dev_set_name(&cdx_dev->dev, "cdx-%02x:%02x", in cdx_device_add()
833 ((cdx->id << CDX_CONTROLLER_ID_SHIFT) | (cdx_dev->bus_num & CDX_BUS_NUM_MASK)), in cdx_device_add()
834 cdx_dev->dev_num); in cdx_device_add()
837 cdx_dev->num_msi = dev_params->num_msi; in cdx_device_add()
838 dev_set_msi_domain(&cdx_dev->dev, cdx->msi_domain); in cdx_device_add()
841 ret = device_add(&cdx_dev->dev); in cdx_device_add()
843 dev_err(&cdx_dev->dev, in cdx_device_add()
850 if (cdx_resource_flags(cdx_dev, i) & IORESOURCE_MEM) { in cdx_device_add()
852 if (!cdx_resource_len(cdx_dev, i)) in cdx_device_add()
855 ret = cdx_create_res_attr(cdx_dev, i); in cdx_device_add()
857 dev_err(&cdx_dev->dev, in cdx_device_add()
864 cdx_device_debugfs_init(cdx_dev); in cdx_device_add()
868 cdx_destroy_res_attr(cdx_dev, i); in cdx_device_add()
869 device_del(&cdx_dev->dev); in cdx_device_add()
875 put_device(&cdx_dev->dev); in cdx_device_add()
883 struct cdx_device *cdx_dev; in cdx_bus_add() local
886 cdx_dev = kzalloc(sizeof(*cdx_dev), GFP_KERNEL); in cdx_bus_add()
887 if (!cdx_dev) in cdx_bus_add()
890 device_initialize(&cdx_dev->dev); in cdx_bus_add()
891 cdx_dev->cdx = cdx; in cdx_bus_add()
893 cdx_dev->dev.parent = cdx->dev; in cdx_bus_add()
894 cdx_dev->dev.bus = &cdx_bus_type; in cdx_bus_add()
895 cdx_dev->dev.release = cdx_device_release; in cdx_bus_add()
896 cdx_dev->is_bus = true; in cdx_bus_add()
897 cdx_dev->bus_num = bus_num; in cdx_bus_add()
899 dev_set_name(&cdx_dev->dev, "cdx-%02x", in cdx_bus_add()
902 ret = device_add(&cdx_dev->dev); in cdx_bus_add()
904 dev_err(&cdx_dev->dev, "cdx bus device add failed: %d\n", ret); in cdx_bus_add()
916 cdx_dev->enabled = true; in cdx_bus_add()
917 return &cdx_dev->dev; in cdx_bus_add()
920 device_del(&cdx_dev->dev); in cdx_bus_add()
922 put_device(&cdx_dev->dev); in cdx_bus_add()