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
343 cdx_drv->shutdown(cdx_dev); in cdx_shutdown()
349 struct cdx_device *cdx_dev = to_cdx_device(dev); in cdx_dma_configure() local
350 struct cdx_controller *cdx = cdx_dev->cdx; in cdx_dma_configure()
351 u32 input_id = cdx_dev->req_id; in cdx_dma_configure()
382 struct cdx_device *cdx_dev = to_cdx_device(dev); \
383 return sysfs_emit(buf, format_string, cdx_dev->field); \
421 struct cdx_device *cdx_dev = to_cdx_device(dev); in reset_store() local
431 if (cdx_dev->is_bus) in reset_store()
444 struct cdx_device *cdx_dev = to_cdx_device(dev); in modalias_show() local
446 return sprintf(buf, "cdx:v%04Xd%04Xsv%04Xsd%04Xc%06X\n", cdx_dev->vendor, in modalias_show()
447 cdx_dev->device, cdx_dev->subsystem_vendor, cdx_dev->subsystem_device, in modalias_show()
448 cdx_dev->class); in modalias_show()
456 struct cdx_device *cdx_dev = to_cdx_device(dev); in driver_override_store() local
462 ret = driver_set_override(dev, &cdx_dev->driver_override, buf, count); in driver_override_store()
472 struct cdx_device *cdx_dev = to_cdx_device(dev); in driver_override_show() local
474 return sysfs_emit(buf, "%s\n", cdx_dev->driver_override); in driver_override_show()
481 struct cdx_device *cdx_dev = to_cdx_device(dev); in enable_store() local
482 struct cdx_controller *cdx = cdx_dev->cdx; in enable_store()
489 if (enable == cdx_dev->enabled) in enable_store()
493 ret = cdx->ops->bus_enable(cdx, cdx_dev->bus_num); in enable_store()
495 ret = cdx->ops->bus_disable(cdx, cdx_dev->bus_num); in enable_store()
500 cdx_dev->enabled = enable; in enable_store()
507 struct cdx_device *cdx_dev = to_cdx_device(dev); in enable_show() local
509 return sysfs_emit(buf, "%u\n", cdx_dev->enabled); in enable_show()
516 struct cdx_device *cdx_dev; in cdx_dev_attrs_are_visible() local
518 cdx_dev = to_cdx_device(dev); in cdx_dev_attrs_are_visible()
519 if (!cdx_dev->is_bus) in cdx_dev_attrs_are_visible()
528 struct cdx_device *cdx_dev; in cdx_bus_attrs_are_visible() local
530 cdx_dev = to_cdx_device(dev); in cdx_bus_attrs_are_visible()
531 if (cdx_dev->is_bus) in cdx_bus_attrs_are_visible()
575 struct cdx_device *cdx_dev = s->private; in cdx_debug_resource_show() local
579 struct resource *res = &cdx_dev->res[i]; in cdx_debug_resource_show()
588 static void cdx_device_debugfs_init(struct cdx_device *cdx_dev) in cdx_device_debugfs_init() argument
590 cdx_dev->debugfs_dir = debugfs_create_dir(dev_name(&cdx_dev->dev), cdx_debugfs_dir); in cdx_device_debugfs_init()
591 if (IS_ERR(cdx_dev->debugfs_dir)) in cdx_device_debugfs_init()
594 debugfs_create_file("resource", 0444, cdx_dev->debugfs_dir, cdx_dev, in cdx_device_debugfs_init()
686 struct cdx_device *cdx_dev = to_cdx_device(dev); in cdx_device_release() local
688 kfree(cdx_dev); in cdx_device_release()
713 struct cdx_device *cdx_dev = to_cdx_device(kobj_to_dev(kobj)); in cdx_mmap_resource() local
718 res = &cdx_dev->res[num]; in cdx_mmap_resource()
723 size = ((cdx_resource_len(cdx_dev, num) - 1) >> PAGE_SHIFT) + 1; in cdx_mmap_resource()
732 vma->vm_pgoff += (cdx_resource_start(cdx_dev, num) >> PAGE_SHIFT); in cdx_mmap_resource()
739 static void cdx_destroy_res_attr(struct cdx_device *cdx_dev, int num) in cdx_destroy_res_attr() argument
747 res_attr = cdx_dev->res_attr[i]; in cdx_destroy_res_attr()
749 sysfs_remove_bin_file(&cdx_dev->dev.kobj, res_attr); in cdx_destroy_res_attr()
756 static int cdx_create_res_attr(struct cdx_device *cdx_dev, int num) in cdx_create_res_attr() argument
770 cdx_dev->res_attr[num] = res_attr; in cdx_create_res_attr()
776 res_attr->size = cdx_resource_len(cdx_dev, num); in cdx_create_res_attr()
778 ret = sysfs_create_bin_file(&cdx_dev->dev.kobj, res_attr); in cdx_create_res_attr()
788 struct cdx_device *cdx_dev; in cdx_device_add() local
791 cdx_dev = kzalloc(sizeof(*cdx_dev), GFP_KERNEL); in cdx_device_add()
792 if (!cdx_dev) in cdx_device_add()
796 memcpy(cdx_dev->res, dev_params->res, sizeof(struct resource) * in cdx_device_add()
798 cdx_dev->res_count = dev_params->res_count; in cdx_device_add()
801 cdx_dev->req_id = dev_params->req_id; in cdx_device_add()
802 cdx_dev->msi_dev_id = dev_params->msi_dev_id; in cdx_device_add()
803 cdx_dev->vendor = dev_params->vendor; in cdx_device_add()
804 cdx_dev->device = dev_params->device; in cdx_device_add()
805 cdx_dev->subsystem_vendor = dev_params->subsys_vendor; in cdx_device_add()
806 cdx_dev->subsystem_device = dev_params->subsys_device; in cdx_device_add()
807 cdx_dev->class = dev_params->class; in cdx_device_add()
808 cdx_dev->revision = dev_params->revision; in cdx_device_add()
809 cdx_dev->bus_num = dev_params->bus_num; in cdx_device_add()
810 cdx_dev->dev_num = dev_params->dev_num; in cdx_device_add()
811 cdx_dev->cdx = dev_params->cdx; in cdx_device_add()
812 cdx_dev->dma_mask = CDX_DEFAULT_DMA_MASK; in cdx_device_add()
815 device_initialize(&cdx_dev->dev); in cdx_device_add()
816 cdx_dev->dev.parent = dev_params->parent; in cdx_device_add()
817 cdx_dev->dev.bus = &cdx_bus_type; in cdx_device_add()
818 cdx_dev->dev.dma_mask = &cdx_dev->dma_mask; in cdx_device_add()
819 cdx_dev->dev.release = cdx_device_release; in cdx_device_add()
820 cdx_dev->msi_write_pending = false; in cdx_device_add()
821 mutex_init(&cdx_dev->irqchip_lock); in cdx_device_add()
824 dev_set_name(&cdx_dev->dev, "cdx-%02x:%02x", in cdx_device_add()
825 ((cdx->id << CDX_CONTROLLER_ID_SHIFT) | (cdx_dev->bus_num & CDX_BUS_NUM_MASK)), in cdx_device_add()
826 cdx_dev->dev_num); in cdx_device_add()
829 cdx_dev->num_msi = dev_params->num_msi; in cdx_device_add()
830 dev_set_msi_domain(&cdx_dev->dev, cdx->msi_domain); in cdx_device_add()
833 ret = device_add(&cdx_dev->dev); in cdx_device_add()
835 dev_err(&cdx_dev->dev, in cdx_device_add()
842 if (cdx_resource_flags(cdx_dev, i) & IORESOURCE_MEM) { in cdx_device_add()
844 if (!cdx_resource_len(cdx_dev, i)) in cdx_device_add()
847 ret = cdx_create_res_attr(cdx_dev, i); in cdx_device_add()
849 dev_err(&cdx_dev->dev, in cdx_device_add()
856 cdx_device_debugfs_init(cdx_dev); in cdx_device_add()
860 cdx_destroy_res_attr(cdx_dev, i); in cdx_device_add()
861 device_del(&cdx_dev->dev); in cdx_device_add()
867 put_device(&cdx_dev->dev); in cdx_device_add()
875 struct cdx_device *cdx_dev; in cdx_bus_add() local
878 cdx_dev = kzalloc(sizeof(*cdx_dev), GFP_KERNEL); in cdx_bus_add()
879 if (!cdx_dev) in cdx_bus_add()
882 device_initialize(&cdx_dev->dev); in cdx_bus_add()
883 cdx_dev->cdx = cdx; in cdx_bus_add()
885 cdx_dev->dev.parent = cdx->dev; in cdx_bus_add()
886 cdx_dev->dev.bus = &cdx_bus_type; in cdx_bus_add()
887 cdx_dev->dev.release = cdx_device_release; in cdx_bus_add()
888 cdx_dev->is_bus = true; in cdx_bus_add()
889 cdx_dev->bus_num = bus_num; in cdx_bus_add()
891 dev_set_name(&cdx_dev->dev, "cdx-%02x", in cdx_bus_add()
894 ret = device_add(&cdx_dev->dev); in cdx_bus_add()
896 dev_err(&cdx_dev->dev, "cdx bus device add failed: %d\n", ret); in cdx_bus_add()
908 cdx_dev->enabled = true; in cdx_bus_add()
909 return &cdx_dev->dev; in cdx_bus_add()
912 device_del(&cdx_dev->dev); in cdx_bus_add()
914 put_device(&cdx_dev->dev); in cdx_bus_add()