u64 of_translate_dcr_address(struct device_node *dev, unsigned int dcr_n, unsigned int *out_stride) { struct device_node *dp; u32 *p; unsigned int stride; u64 ret; dp = find_dcr_parent(dev); if (dp == NULL) return OF_BAD_ADDR; /* Stride is not properly defined yet, default to 0x10 for Axon */ p = (u32 *)get_property(dp, "dcr-mmio-stride", NULL); stride = (p == NULL) ? 0x10 : *p; /* XXX FIXME: Which property name is to use of the 2 following ? */ p = (u32 *)get_property(dp, "dcr-mmio-range", NULL); if (p == NULL) p = (u32 *)get_property(dp, "dcr-mmio-space", NULL); if (p == NULL) return OF_BAD_ADDR; /* Maybe could do some better range checking here */ ret = of_translate_address(dp, p); if (ret != OF_BAD_ADDR) ret += (u64)(stride) * (u64)dcr_n; if (out_stride) *out_stride = stride; return ret; }
dcr_host_t dcr_map_generic(struct device_node *dev, unsigned int dcr_n, unsigned int dcr_c) { dcr_host_t host; struct device_node *dp; const char *prop; host.type = DCR_HOST_INVALID; dp = find_dcr_parent(dev); if (dp == NULL) return host; prop = of_get_property(dp, "dcr-access-method", NULL); pr_debug("dcr_map_generic(dcr-access-method = %s)\n", prop); if (!strcmp(prop, "native")) { host.type = DCR_HOST_NATIVE; host.host.native = dcr_map_native(dev, dcr_n, dcr_c); } else if (!strcmp(prop, "mmio")) { host.type = DCR_HOST_MMIO; host.host.mmio = dcr_map_mmio(dev, dcr_n, dcr_c); } of_node_put(dp); return host; }