static int __init gic_devtree_init(struct vmm_devtree_node *node, struct vmm_devtree_node *parent, bool eoimode) { int rc; u32 irq, irq_start = 0; physical_size_t cpu_sz; virtual_addr_t cpu_base; virtual_addr_t cpu2_base; virtual_addr_t dist_base; if (WARN_ON(!node)) { return VMM_ENODEV; } rc = vmm_devtree_request_regmap(node, &dist_base, 0, "GIC Dist"); WARN(rc, "unable to map gic dist registers\n"); rc = vmm_devtree_request_regmap(node, &cpu_base, 1, "GIC CPU"); WARN(rc, "unable to map gic cpu registers\n"); rc = vmm_devtree_request_regmap(node, &cpu2_base, 4, "GIC CPU2"); if (rc) { rc = vmm_devtree_regsize(node, &cpu_sz, 1); if (rc) { return rc; } if (cpu_sz >= 0x20000) { cpu2_base = cpu_base + 0x10000; } else if (cpu_sz >= 0x2000) { cpu2_base = cpu_base + 0x1000; } else { cpu2_base = 0x0; } } if (vmm_devtree_read_u32(node, "irq_start", &irq_start)) { irq_start = 0; } rc = gic_init_bases(node, gic_cnt, eoimode, irq_start, cpu_base, cpu2_base, dist_base); if (rc) { return rc; } if (parent) { if (vmm_devtree_read_u32(node, "parent_irq", &irq)) { irq = 1020; } gic_cascade_irq(gic_cnt, irq); } else { vmm_host_irq_set_active_callback(gic_active_irq); } gic_cnt++; return VMM_OK; }
static int rbd_driver_probe(struct vmm_device *dev, const struct vmm_devtree_nodeid *devid) { int rc; physical_addr_t pa; physical_size_t sz; rc = vmm_devtree_regaddr(dev->node, &pa, 0); if (rc) { return rc; } rc = vmm_devtree_regsize(dev->node, &sz, 0); if (rc) { return rc; } dev->priv = __rbd_create(dev, dev->node->name, pa, sz); if (!dev->priv) { return VMM_EFAIL; } return VMM_OK; }
static int sram_probe(struct vmm_device *dev, const struct vmm_devtree_nodeid *nodeid) { void *virt_base = NULL; struct sram_dev *sram = NULL; physical_addr_t start = 0; virtual_size_t size = 0; int ret = VMM_OK; ret = vmm_devtree_regaddr(dev->of_node, &start, 0); if (VMM_OK != ret) { vmm_printf("%s: Failed to get device base\n", dev->name); return ret; } ret = vmm_devtree_regsize(dev->of_node, &size, 0); if (VMM_OK != ret) { vmm_printf("%s: Failed to get device size\n", dev->name); goto err_out; } virt_base = (void *)vmm_host_iomap(start, size); if (NULL == virt_base) { vmm_printf("%s: Failed to get remap memory\n", dev->name); ret = VMM_ENOMEM; goto err_out; } sram = vmm_devm_zalloc(dev, sizeof(*sram)); if (!sram) { vmm_printf("%s: Failed to allocate structure\n", dev->name); ret = VMM_ENOMEM; goto err_out; } sram->clk = devm_clk_get(dev, NULL); if (VMM_IS_ERR(sram->clk)) sram->clk = NULL; else clk_prepare_enable(sram->clk); sram->pool = devm_gen_pool_create(dev, SRAM_GRANULARITY_LOG); if (!sram->pool) { vmm_printf("%s: Failed to create memory pool\n", dev->name); ret = VMM_ENOMEM; } ret = gen_pool_add_virt(sram->pool, (unsigned long)virt_base, start, size); if (ret < 0) { vmm_printf("%s: Failed to add memory chunk\n", dev->name); goto err_out; } vmm_devdrv_set_data(dev, sram); vmm_printf("%s: SRAM pool: %ld KiB @ 0x%p\n", dev->name, size / 1024, virt_base); return 0; err_out: if (sram->pool) gen_pool_destroy(sram->pool); #if 0 if (sram->clk) clk_disable_unprepare(sram->clk); #endif /* 0 */ if (sram) vmm_free(sram); sram = NULL; if (virt_base) vmm_host_iounmap((virtual_addr_t)virt_base); virt_base = NULL; return ret; }