static int flcn_probe(struct platform_device *dev) { int err; struct nvhost_device_data *pdata = NULL; if (dev->dev.of_node) { const struct of_device_id *match; match = of_match_device(tegra_flcn_of_match, &dev->dev); if (match) pdata = (struct nvhost_device_data *)match->data; } else pdata = (struct nvhost_device_data *)dev->dev.platform_data; if (!pdata) { dev_err(&dev->dev, "no platform data\n"); return -ENODATA; } nvhost_dbg_fn("dev:%p pdata:%p", dev, pdata); pdata->pdev = dev; mutex_init(&pdata->lock); platform_set_drvdata(dev, pdata); err = nvhost_client_device_get_resources(dev); if (err) return err; dev->dev.platform_data = NULL; nvhost_module_init(dev); #ifdef CONFIG_PM_GENERIC_DOMAINS pdata->pd.name = kstrdup(dev->name, GFP_KERNEL); if (!pdata->pd.name) return -ENOMEM; err = nvhost_module_add_domain(&pdata->pd, dev); #endif err = nvhost_client_device_init(dev); if (err) { nvhost_dbg_fn("failed to init client device for %s", dev->name); pm_runtime_put(&dev->dev); return err; } return 0; }
static int msenc_probe(struct platform_device *dev) { int err = 0; struct nvhost_device_data *pdata = NULL; if (dev->dev.of_node) { const struct of_device_id *match; match = of_match_device(tegra_msenc_of_match, &dev->dev); if (match) pdata = (struct nvhost_device_data *)match->data; } else pdata = (struct nvhost_device_data *)dev->dev.platform_data; WARN_ON(!pdata); if (!pdata) { dev_info(&dev->dev, "no platform data\n"); return -ENODATA; } pdata->pdev = dev; mutex_init(&pdata->lock); platform_set_drvdata(dev, pdata); err = nvhost_client_device_get_resources(dev); if (err) return err; dev->dev.platform_data = NULL; /* get the module clocks to sane state */ nvhost_module_init(dev); #ifdef CONFIG_PM_GENERIC_DOMAINS pdata->pd.name = "msenc"; /* add module power domain and also add its domain * as sub-domain of MC domain */ err = nvhost_module_add_domain(&pdata->pd, dev); #endif err = nvhost_client_device_init(dev); return 0; }
static int gr3d_probe(struct platform_device *dev) { int err = 0; struct nvhost_device_data *pdata = NULL; if (dev->dev.of_node) { const struct of_device_id *match; match = of_match_device(tegra_gr3d_of_match, &dev->dev); if (match) pdata = (struct nvhost_device_data *)match->data; } else pdata = (struct nvhost_device_data *)dev->dev.platform_data; WARN_ON(!pdata); if (!pdata) { dev_info(&dev->dev, "no platform data\n"); return -ENODATA; } pdata->pdev = dev; mutex_init(&pdata->lock); platform_set_drvdata(dev, pdata); err = nvhost_client_device_get_resources(dev); if (err) return err; nvhost_module_init(dev); #ifdef CONFIG_PM_GENERIC_DOMAINS pdata->pd.name = "gr3d"; err = nvhost_module_add_domain(&pdata->pd, dev); #endif err = nvhost_client_device_init(dev); return err; }
static int vi_probe(struct platform_device *dev) { int err = 0; struct vi *tegra_vi; struct nvhost_device_data *pdata = NULL; if (dev->dev.of_node) { const struct of_device_id *match; match = of_match_device(tegra_vi_of_match, &dev->dev); if (match) { pdata = (struct nvhost_device_data *)match->data; dev->dev.platform_data = pdata; } /* DT initializes it to -1, use below WAR to set correct value. * TODO: Once proper fix for dev-id goes in, remove it. */ dev->id = dev->dev.id; } else pdata = (struct nvhost_device_data *)dev->dev.platform_data; WARN_ON(!pdata); if (!pdata) { dev_info(&dev->dev, "no platform data\n"); return -ENODATA; } pdata->pdev = dev; mutex_init(&pdata->lock); platform_set_drvdata(dev, pdata); dev_info(&dev->dev, "%s: ++\n", __func__); tegra_vi = devm_kzalloc(&dev->dev, sizeof(struct vi), GFP_KERNEL); if (!tegra_vi) { dev_err(&dev->dev, "can't allocate memory for vi\n"); return -ENOMEM; } err = nvhost_client_device_get_resources(dev); if (err) goto vi_probe_fail; tegra_vi->ndev = dev; /* call vi_intr_init and stats_work */ INIT_WORK(&tegra_vi->stats_work, vi_stats_worker); err = vi_intr_init(tegra_vi); if (err) goto vi_probe_fail; vi_create_debugfs(tegra_vi); i2c_ctrl = pdata->private_data; pdata->private_data = tegra_vi; /* Create I2C Devices according to settings from board file */ if (i2c_ctrl && i2c_ctrl->new_devices) i2c_ctrl->new_devices(dev); tegra_vi->reg = regulator_get(&tegra_vi->ndev->dev, "avdd_dsi_csi"); if (IS_ERR(tegra_vi->reg)) { err = PTR_ERR(tegra_vi->reg); if (err == -ENODEV) dev_info(&tegra_vi->ndev->dev, "%s: no regulator device\n", __func__); else dev_err(&tegra_vi->ndev->dev, "%s: couldn't get regulator\n", __func__); tegra_vi->reg = NULL; goto camera_i2c_unregister; } #ifdef CONFIG_TEGRA_CAMERA tegra_vi->camera = tegra_camera_register(dev); if (!tegra_vi->camera) { dev_err(&dev->dev, "%s: can't register tegra_camera\n", __func__); goto vi_regulator_put; } #endif nvhost_module_init(dev); #ifdef CONFIG_PM_GENERIC_DOMAINS pdata->pd.name = "ve"; /* add module power domain and also add its domain * as sub-domain of MC domain */ err = nvhost_module_add_domain(&pdata->pd, dev); #endif err = nvhost_client_device_init(dev); if (err) goto camera_unregister; return 0; camera_unregister: #ifdef CONFIG_TEGRA_CAMERA tegra_camera_unregister(tegra_vi->camera); vi_regulator_put: #endif regulator_put(tegra_vi->reg); tegra_vi->reg = NULL; camera_i2c_unregister: if (i2c_ctrl && i2c_ctrl->remove_devices) i2c_ctrl->remove_devices(dev); pdata->private_data = i2c_ctrl; vi_probe_fail: dev_err(&dev->dev, "%s: failed\n", __func__); return err; }
static int vhost_client_probe(struct platform_device *dev) { int err; struct nvhost_device_data *pdata = NULL; if (dev->dev.of_node) { const struct of_device_id *match; match = of_match_device(tegra_client_of_match, &dev->dev); if (!match) return -ENODEV; pdata = (struct nvhost_device_data *)match->data; #ifdef CONFIG_TEGRA_GRHOST_ISP /* If ISP, need to differentiate ISP.0 from ISP.1 */ if (!IS_ENABLED(CONFIG_ARCH_TEGRA_18x_SOC)) { int dev_id = 0; if (sscanf(dev->name, "%x.isp", &dev_id) == 1) { switch (tegra_get_chipid()) { case TEGRA_CHIPID_TEGRA12: if (dev_id == 0x54600000) pdata = &t124_isp_info; if (dev_id == 0x54680000) pdata = &t124_ispb_info; break; default: /* Only T124 is virtualized, for now */ return -EINVAL; } } } #endif } if (!pdata) { dev_err(&dev->dev, "no platform data\n"); return -ENODATA; } pdata->virtual_dev = true; nvhost_dbg_fn("dev:%p pdata:%p", dev, pdata); pdata->pdev = dev; mutex_init(&pdata->lock); platform_set_drvdata(dev, pdata); /* Disable power management when virtual */ pdata->can_powergate = false; pdata->busy = NULL; pdata->idle = NULL; pdata->scaling_init = NULL; pdata->finalize_poweron = nvhost_vhost_client_finalize_poweron; pdata->poweron_reset = false; pdata->engine_cg_regs = NULL; pdata->keepalive = false; pdata->hw_init = NULL; dev->dev.platform_data = NULL; nvhost_module_init(dev); #ifdef CONFIG_PM_GENERIC_DOMAINS pdata->pd.name = kstrdup(dev->name, GFP_KERNEL); if (!pdata->pd.name) return -ENOMEM; err = nvhost_module_add_domain(&pdata->pd, dev); #endif err = nvhost_virt_init(dev, pdata->moduleid); if (err) { dev_err(&dev->dev, "nvhost_virt_init failed for %s", dev->name); pm_runtime_put(&dev->dev); return err; } err = nvhost_client_device_init(dev); if (err) { dev_err(&dev->dev, "failed to init client device for %s", dev->name); pm_runtime_put(&dev->dev); return err; } return 0; }