Lines Matching refs:binfo
743 static int build_info_commit_dev(struct build_feature_devs_info *binfo) in build_info_commit_dev() argument
745 struct platform_device *fdev = binfo->feature_dev; in build_info_commit_dev()
761 pdata = kzalloc(struct_size(pdata, features, binfo->feature_num), GFP_KERNEL); in build_info_commit_dev()
766 pdata->num = binfo->feature_num; in build_info_commit_dev()
767 pdata->dfl_cdev = binfo->cdev; in build_info_commit_dev()
784 fdev->num_resources = binfo->feature_num; in build_info_commit_dev()
785 fdev->resource = kcalloc(binfo->feature_num, sizeof(*fdev->resource), in build_info_commit_dev()
791 list_for_each_entry_safe(finfo, p, &binfo->sub_features, node) { in build_info_commit_dev()
811 devm_ioremap_resource(binfo->dev, in build_info_commit_dev()
821 ctx = devm_kcalloc(binfo->dev, finfo->nr_irqs, in build_info_commit_dev()
828 binfo->irq_table[finfo->irq_base + i]; in build_info_commit_dev()
838 ret = platform_device_add(binfo->feature_dev); in build_info_commit_dev()
841 dfl_fpga_cdev_add_port_dev(binfo->cdev, in build_info_commit_dev()
842 binfo->feature_dev); in build_info_commit_dev()
844 binfo->cdev->fme_dev = in build_info_commit_dev()
845 get_device(&binfo->feature_dev->dev); in build_info_commit_dev()
853 binfo->feature_dev = NULL; in build_info_commit_dev()
860 build_info_create_dev(struct build_feature_devs_info *binfo, in build_info_create_dev() argument
876 binfo->feature_dev = fdev; in build_info_create_dev()
877 binfo->feature_num = 0; in build_info_create_dev()
879 INIT_LIST_HEAD(&binfo->sub_features); in build_info_create_dev()
885 fdev->dev.parent = &binfo->cdev->region->dev; in build_info_create_dev()
891 static void build_info_free(struct build_feature_devs_info *binfo) in build_info_free() argument
899 if (binfo->feature_dev && binfo->feature_dev->id >= 0) { in build_info_free()
900 dfl_id_free(feature_dev_id_type(binfo->feature_dev), in build_info_free()
901 binfo->feature_dev->id); in build_info_free()
903 list_for_each_entry_safe(finfo, p, &binfo->sub_features, node) { in build_info_free()
909 platform_device_put(binfo->feature_dev); in build_info_free()
911 devm_kfree(binfo->dev, binfo); in build_info_free()
937 static int parse_feature_irqs(struct build_feature_devs_info *binfo, in parse_feature_irqs() argument
941 void __iomem *base = binfo->ioaddr + ofst; in parse_feature_irqs()
984 dev_dbg(binfo->dev, "feature: 0x%x, irq_base: %u, nr_irqs: %u\n", in parse_feature_irqs()
987 if (ibase + inr > binfo->nr_irqs) { in parse_feature_irqs()
988 dev_err(binfo->dev, in parse_feature_irqs()
994 virq = binfo->irq_table[ibase + i]; in parse_feature_irqs()
996 dev_err(binfo->dev, in parse_feature_irqs()
1017 create_feature_instance(struct build_feature_devs_info *binfo, in create_feature_instance() argument
1027 v = readq(binfo->ioaddr + ofst); in create_feature_instance()
1035 if (binfo->len - ofst < size) in create_feature_instance()
1038 ret = parse_feature_irqs(binfo, ofst, fid, &irq_base, &nr_irqs); in create_feature_instance()
1048 finfo->mmio_res.start = binfo->start + ofst; in create_feature_instance()
1054 list_add_tail(&finfo->node, &binfo->sub_features); in create_feature_instance()
1055 binfo->feature_num++; in create_feature_instance()
1060 static int parse_feature_port_afu(struct build_feature_devs_info *binfo, in parse_feature_port_afu() argument
1063 u64 v = readq(binfo->ioaddr + PORT_HDR_CAP); in parse_feature_port_afu()
1068 return create_feature_instance(binfo, ofst, size, FEATURE_ID_AFU); in parse_feature_port_afu()
1071 #define is_feature_dev_detected(binfo) (!!(binfo)->feature_dev) argument
1073 static int parse_feature_afu(struct build_feature_devs_info *binfo, in parse_feature_afu() argument
1076 if (!is_feature_dev_detected(binfo)) { in parse_feature_afu()
1077 dev_err(binfo->dev, "this AFU does not belong to any FIU.\n"); in parse_feature_afu()
1081 switch (feature_dev_id_type(binfo->feature_dev)) { in parse_feature_afu()
1083 return parse_feature_port_afu(binfo, ofst); in parse_feature_afu()
1085 dev_info(binfo->dev, "AFU belonging to FIU %s is not supported yet.\n", in parse_feature_afu()
1086 binfo->feature_dev->name); in parse_feature_afu()
1092 static int build_info_prepare(struct build_feature_devs_info *binfo, in build_info_prepare() argument
1095 struct device *dev = binfo->dev; in build_info_prepare()
1111 binfo->start = start; in build_info_prepare()
1112 binfo->len = len; in build_info_prepare()
1113 binfo->ioaddr = ioaddr; in build_info_prepare()
1118 static void build_info_complete(struct build_feature_devs_info *binfo) in build_info_complete() argument
1120 devm_iounmap(binfo->dev, binfo->ioaddr); in build_info_complete()
1121 devm_release_mem_region(binfo->dev, binfo->start, binfo->len); in build_info_complete()
1124 static int parse_feature_fiu(struct build_feature_devs_info *binfo, in parse_feature_fiu() argument
1132 if (is_feature_dev_detected(binfo)) { in parse_feature_fiu()
1133 build_info_complete(binfo); in parse_feature_fiu()
1135 ret = build_info_commit_dev(binfo); in parse_feature_fiu()
1139 ret = build_info_prepare(binfo, binfo->start + ofst, in parse_feature_fiu()
1140 binfo->len - ofst); in parse_feature_fiu()
1145 v = readq(binfo->ioaddr + DFH); in parse_feature_fiu()
1149 ret = build_info_create_dev(binfo, dfh_id_to_type(id)); in parse_feature_fiu()
1153 ret = create_feature_instance(binfo, 0, 0, 0); in parse_feature_fiu()
1160 v = readq(binfo->ioaddr + NEXT_AFU); in parse_feature_fiu()
1164 return parse_feature_afu(binfo, offset); in parse_feature_fiu()
1166 dev_dbg(binfo->dev, "No AFUs detected on FIU %d\n", id); in parse_feature_fiu()
1171 static int parse_feature_private(struct build_feature_devs_info *binfo, in parse_feature_private() argument
1174 if (!is_feature_dev_detected(binfo)) { in parse_feature_private()
1175 dev_err(binfo->dev, "the private feature 0x%x does not belong to any AFU.\n", in parse_feature_private()
1176 feature_id(readq(binfo->ioaddr + ofst))); in parse_feature_private()
1180 return create_feature_instance(binfo, ofst, 0, 0); in parse_feature_private()
1189 static int parse_feature(struct build_feature_devs_info *binfo, in parse_feature() argument
1195 v = readq(binfo->ioaddr + ofst + DFH); in parse_feature()
1200 return parse_feature_afu(binfo, ofst); in parse_feature()
1202 return parse_feature_private(binfo, ofst); in parse_feature()
1204 return parse_feature_fiu(binfo, ofst); in parse_feature()
1206 dev_info(binfo->dev, in parse_feature()
1213 static int parse_feature_list(struct build_feature_devs_info *binfo, in parse_feature_list() argument
1221 ret = build_info_prepare(binfo, start, len); in parse_feature_list()
1228 dev_err(binfo->dev, "The region is too small to contain a feature.\n"); in parse_feature_list()
1232 ret = parse_feature(binfo, start - binfo->start); in parse_feature_list()
1236 v = readq(binfo->ioaddr + start - binfo->start + DFH); in parse_feature_list()
1245 build_info_complete(binfo); in parse_feature_list()
1247 if (is_feature_dev_detected(binfo)) in parse_feature_list()
1248 ret = build_info_commit_dev(binfo); in parse_feature_list()
1398 struct build_feature_devs_info *binfo; in dfl_fpga_feature_devs_enumerate() local
1425 binfo = devm_kzalloc(info->dev, sizeof(*binfo), GFP_KERNEL); in dfl_fpga_feature_devs_enumerate()
1426 if (!binfo) { in dfl_fpga_feature_devs_enumerate()
1431 binfo->dev = info->dev; in dfl_fpga_feature_devs_enumerate()
1432 binfo->cdev = cdev; in dfl_fpga_feature_devs_enumerate()
1434 binfo->nr_irqs = info->nr_irqs; in dfl_fpga_feature_devs_enumerate()
1436 binfo->irq_table = info->irq_table; in dfl_fpga_feature_devs_enumerate()
1443 ret = parse_feature_list(binfo, dfl->start, dfl->len); in dfl_fpga_feature_devs_enumerate()
1446 build_info_free(binfo); in dfl_fpga_feature_devs_enumerate()
1451 build_info_free(binfo); in dfl_fpga_feature_devs_enumerate()