static int __devinit nvhost_probe(struct nvhost_device *dev, struct nvhost_device_id *id_table) { struct nvhost_master *host; struct resource *regs, *intr0, *intr1; int i, err; regs = nvhost_get_resource(dev, IORESOURCE_MEM, 0); intr0 = nvhost_get_resource(dev, IORESOURCE_IRQ, 0); intr1 = nvhost_get_resource(dev, IORESOURCE_IRQ, 1); if (!regs || !intr0 || !intr1) { dev_err(&dev->dev, "missing required platform resources\n"); return -ENXIO; } host = kzalloc(sizeof(*host), GFP_KERNEL); if (!host) return -ENOMEM; /* Register host1x device as bus master */ host->dev = dev; /* Copy host1x parameters */ memcpy(&host->info, dev->dev.platform_data, sizeof(struct host1x_device_info)); host->reg_mem = request_mem_region(regs->start, resource_size(regs), dev->name); if (!host->reg_mem) { dev_err(&dev->dev, "failed to get host register memory\n"); err = -ENXIO; goto fail; } host->aperture = ioremap(regs->start, resource_size(regs)); if (!host->aperture) { dev_err(&dev->dev, "failed to remap host registers\n"); err = -ENXIO; goto fail; } err = nvhost_alloc_resources(host); if (err) { dev_err(&dev->dev, "failed to init chip support\n"); goto fail; } host->memmgr = mem_op().alloc_mgr(); if (!host->memmgr) { dev_err(&dev->dev, "unable to create nvmap client\n"); err = -EIO; goto fail; } /* Register host1x device as bus master */ host->dev = dev; /* Give pointer to host1x via driver */ nvhost_set_drvdata(dev, host); nvhost_bus_add_host(host); err = nvhost_syncpt_init(dev, &host->syncpt); if (err) goto fail; err = nvhost_intr_init(&host->intr, intr1->start, intr0->start); if (err) goto fail; err = nvhost_user_init(host); if (err) goto fail; err = nvhost_module_init(dev); if (err) goto fail; for (i = 0; i < host->dev->num_clks; i++) clk_enable(host->dev->clk[i]); nvhost_syncpt_reset(&host->syncpt); for (i = 0; i < host->dev->num_clks; i++) clk_disable(host->dev->clk[0]); nvhost_debug_init(host); dev_info(&dev->dev, "initialized\n"); return 0; fail: nvhost_free_resources(host); if (host->memmgr) mem_op().put_mgr(host->memmgr); kfree(host); return err; }
static int __devinit nvhost_probe(struct platform_device *dev) { struct nvhost_master *host; struct resource *regs, *intr0, *intr1; int i, err; struct nvhost_device_data *pdata = (struct nvhost_device_data *)dev->dev.platform_data; regs = platform_get_resource(dev, IORESOURCE_MEM, 0); intr0 = platform_get_resource(dev, IORESOURCE_IRQ, 0); intr1 = platform_get_resource(dev, IORESOURCE_IRQ, 1); if (!regs || !intr0 || !intr1) { dev_err(&dev->dev, "missing required platform resources\n"); return -ENXIO; } host = kzalloc(sizeof(*host), GFP_KERNEL); if (!host) return -ENOMEM; nvhost = host; host->dev = dev; /* Copy host1x parameters. The private_data gets replaced * by nvhost_master later */ memcpy(&host->info, pdata->private_data, sizeof(struct host1x_device_info)); pdata->finalize_poweron = power_on_host; pdata->prepare_poweroff = power_off_host; pdata->prepare_clockoff = clock_off_host; pdata->finalize_clockon = clock_on_host; pdata->pdev = dev; /* set common host1x device data */ platform_set_drvdata(dev, pdata); /* set private host1x device data */ nvhost_set_private_data(dev, host); host->reg_mem = request_mem_region(regs->start, resource_size(regs), dev->name); if (!host->reg_mem) { dev_err(&dev->dev, "failed to get host register memory\n"); err = -ENXIO; goto fail; } host->aperture = ioremap(regs->start, resource_size(regs)); if (!host->aperture) { dev_err(&dev->dev, "failed to remap host registers\n"); err = -ENXIO; goto fail; } err = nvhost_alloc_resources(host); if (err) { dev_err(&dev->dev, "failed to init chip support\n"); goto fail; } host->memmgr = mem_op().alloc_mgr(); if (!host->memmgr) { dev_err(&dev->dev, "unable to create nvmap client\n"); err = -EIO; goto fail; } err = nvhost_syncpt_init(dev, &host->syncpt); if (err) goto fail; err = nvhost_intr_init(&host->intr, intr1->start, intr0->start); if (err) goto fail; err = nvhost_user_init(host); if (err) goto fail; err = nvhost_module_init(dev); if (err) goto fail; for (i = 0; i < pdata->num_clks; i++) clk_prepare_enable(pdata->clk[i]); nvhost_syncpt_reset(&host->syncpt); for (i = 0; i < pdata->num_clks; i++) clk_disable_unprepare(pdata->clk[i]); nvhost_device_list_init(); err = nvhost_device_list_add(dev); if (err) goto fail; nvhost_debug_init(host); dev_info(&dev->dev, "initialized\n"); return 0; fail: nvhost_free_resources(host); if (host->memmgr) mem_op().put_mgr(host->memmgr); kfree(host); return err; }