Lines Matching refs:tdev

31 nvkm_device_tegra_power_up(struct nvkm_device_tegra *tdev)  in nvkm_device_tegra_power_up()  argument
35 if (tdev->vdd) { in nvkm_device_tegra_power_up()
36 ret = regulator_enable(tdev->vdd); in nvkm_device_tegra_power_up()
41 ret = clk_prepare_enable(tdev->clk); in nvkm_device_tegra_power_up()
44 if (tdev->clk_ref) { in nvkm_device_tegra_power_up()
45 ret = clk_prepare_enable(tdev->clk_ref); in nvkm_device_tegra_power_up()
49 ret = clk_prepare_enable(tdev->clk_pwr); in nvkm_device_tegra_power_up()
52 clk_set_rate(tdev->clk_pwr, 204000000); in nvkm_device_tegra_power_up()
55 if (!tdev->pdev->dev.pm_domain) { in nvkm_device_tegra_power_up()
56 reset_control_assert(tdev->rst); in nvkm_device_tegra_power_up()
64 reset_control_deassert(tdev->rst); in nvkm_device_tegra_power_up()
71 clk_disable_unprepare(tdev->clk_pwr); in nvkm_device_tegra_power_up()
73 if (tdev->clk_ref) in nvkm_device_tegra_power_up()
74 clk_disable_unprepare(tdev->clk_ref); in nvkm_device_tegra_power_up()
76 clk_disable_unprepare(tdev->clk); in nvkm_device_tegra_power_up()
78 if (tdev->vdd) in nvkm_device_tegra_power_up()
79 regulator_disable(tdev->vdd); in nvkm_device_tegra_power_up()
85 nvkm_device_tegra_power_down(struct nvkm_device_tegra *tdev) in nvkm_device_tegra_power_down() argument
89 clk_disable_unprepare(tdev->clk_pwr); in nvkm_device_tegra_power_down()
90 if (tdev->clk_ref) in nvkm_device_tegra_power_down()
91 clk_disable_unprepare(tdev->clk_ref); in nvkm_device_tegra_power_down()
92 clk_disable_unprepare(tdev->clk); in nvkm_device_tegra_power_down()
95 if (tdev->vdd) { in nvkm_device_tegra_power_down()
96 ret = regulator_disable(tdev->vdd); in nvkm_device_tegra_power_down()
105 nvkm_device_tegra_probe_iommu(struct nvkm_device_tegra *tdev) in nvkm_device_tegra_probe_iommu() argument
108 struct device *dev = &tdev->pdev->dev; in nvkm_device_tegra_probe_iommu()
121 if (!tdev->func->iommu_bit) in nvkm_device_tegra_probe_iommu()
124 mutex_init(&tdev->iommu.mutex); in nvkm_device_tegra_probe_iommu()
127 tdev->iommu.domain = iommu_domain_alloc(&platform_bus_type); in nvkm_device_tegra_probe_iommu()
128 if (!tdev->iommu.domain) in nvkm_device_tegra_probe_iommu()
136 pgsize_bitmap = tdev->iommu.domain->ops->pgsize_bitmap; in nvkm_device_tegra_probe_iommu()
138 tdev->iommu.pgshift = PAGE_SHIFT; in nvkm_device_tegra_probe_iommu()
140 tdev->iommu.pgshift = fls(pgsize_bitmap & ~PAGE_MASK); in nvkm_device_tegra_probe_iommu()
141 if (tdev->iommu.pgshift == 0) { in nvkm_device_tegra_probe_iommu()
145 tdev->iommu.pgshift -= 1; in nvkm_device_tegra_probe_iommu()
148 ret = iommu_attach_device(tdev->iommu.domain, dev); in nvkm_device_tegra_probe_iommu()
152 ret = nvkm_mm_init(&tdev->iommu.mm, 0, 0, in nvkm_device_tegra_probe_iommu()
153 (1ULL << tdev->func->iommu_bit) >> in nvkm_device_tegra_probe_iommu()
154 tdev->iommu.pgshift, 1); in nvkm_device_tegra_probe_iommu()
162 iommu_detach_device(tdev->iommu.domain, dev); in nvkm_device_tegra_probe_iommu()
165 iommu_domain_free(tdev->iommu.domain); in nvkm_device_tegra_probe_iommu()
168 tdev->iommu.domain = NULL; in nvkm_device_tegra_probe_iommu()
169 tdev->iommu.pgshift = 0; in nvkm_device_tegra_probe_iommu()
175 nvkm_device_tegra_remove_iommu(struct nvkm_device_tegra *tdev) in nvkm_device_tegra_remove_iommu() argument
178 if (tdev->iommu.domain) { in nvkm_device_tegra_remove_iommu()
179 nvkm_mm_fini(&tdev->iommu.mm); in nvkm_device_tegra_remove_iommu()
180 iommu_detach_device(tdev->iommu.domain, tdev->device.dev); in nvkm_device_tegra_remove_iommu()
181 iommu_domain_free(tdev->iommu.domain); in nvkm_device_tegra_remove_iommu()
195 struct nvkm_device_tegra *tdev = nvkm_device_tegra(device); in nvkm_device_tegra_resource() local
196 return platform_get_resource(tdev->pdev, IORESOURCE_MEM, bar); in nvkm_device_tegra_resource()
216 struct nvkm_device_tegra *tdev = arg; in nvkm_device_tegra_intr() local
217 struct nvkm_device *device = &tdev->device; in nvkm_device_tegra_intr()
228 struct nvkm_device_tegra *tdev = nvkm_device_tegra(device); in nvkm_device_tegra_fini() local
229 if (tdev->irq) { in nvkm_device_tegra_fini()
230 free_irq(tdev->irq, tdev); in nvkm_device_tegra_fini()
231 tdev->irq = 0; in nvkm_device_tegra_fini()
238 struct nvkm_device_tegra *tdev = nvkm_device_tegra(device); in nvkm_device_tegra_init() local
241 irq = platform_get_irq_byname(tdev->pdev, "stall"); in nvkm_device_tegra_init()
246 IRQF_SHARED, "nvkm", tdev); in nvkm_device_tegra_init()
250 tdev->irq = irq; in nvkm_device_tegra_init()
257 struct nvkm_device_tegra *tdev = nvkm_device_tegra(device); in nvkm_device_tegra_dtor() local
258 nvkm_device_tegra_power_down(tdev); in nvkm_device_tegra_dtor()
259 nvkm_device_tegra_remove_iommu(tdev); in nvkm_device_tegra_dtor()
260 return tdev; in nvkm_device_tegra_dtor()
281 struct nvkm_device_tegra *tdev; in nvkm_device_tegra_new() local
285 if (!(tdev = kzalloc(sizeof(*tdev), GFP_KERNEL))) in nvkm_device_tegra_new()
288 tdev->func = func; in nvkm_device_tegra_new()
289 tdev->pdev = pdev; in nvkm_device_tegra_new()
292 tdev->vdd = devm_regulator_get(&pdev->dev, "vdd"); in nvkm_device_tegra_new()
293 if (IS_ERR(tdev->vdd)) { in nvkm_device_tegra_new()
294 ret = PTR_ERR(tdev->vdd); in nvkm_device_tegra_new()
299 tdev->rst = devm_reset_control_get(&pdev->dev, "gpu"); in nvkm_device_tegra_new()
300 if (IS_ERR(tdev->rst)) { in nvkm_device_tegra_new()
301 ret = PTR_ERR(tdev->rst); in nvkm_device_tegra_new()
305 tdev->clk = devm_clk_get(&pdev->dev, "gpu"); in nvkm_device_tegra_new()
306 if (IS_ERR(tdev->clk)) { in nvkm_device_tegra_new()
307 ret = PTR_ERR(tdev->clk); in nvkm_device_tegra_new()
311 rate = clk_get_rate(tdev->clk); in nvkm_device_tegra_new()
313 ret = clk_set_rate(tdev->clk, ULONG_MAX); in nvkm_device_tegra_new()
317 rate = clk_get_rate(tdev->clk); in nvkm_device_tegra_new()
323 tdev->clk_ref = devm_clk_get(&pdev->dev, "ref"); in nvkm_device_tegra_new()
324 if (IS_ERR(tdev->clk_ref)) { in nvkm_device_tegra_new()
325 ret = PTR_ERR(tdev->clk_ref); in nvkm_device_tegra_new()
329 tdev->clk_pwr = devm_clk_get(&pdev->dev, "pwr"); in nvkm_device_tegra_new()
330 if (IS_ERR(tdev->clk_pwr)) { in nvkm_device_tegra_new()
331 ret = PTR_ERR(tdev->clk_pwr); in nvkm_device_tegra_new()
338 ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(tdev->func->iommu_bit)); in nvkm_device_tegra_new()
342 nvkm_device_tegra_probe_iommu(tdev); in nvkm_device_tegra_new()
344 ret = nvkm_device_tegra_power_up(tdev); in nvkm_device_tegra_new()
348 tdev->gpu_speedo = tegra_sku_info.gpu_speedo_value; in nvkm_device_tegra_new()
349 tdev->gpu_speedo_id = tegra_sku_info.gpu_speedo_id; in nvkm_device_tegra_new()
353 &tdev->device); in nvkm_device_tegra_new()
357 *pdevice = &tdev->device; in nvkm_device_tegra_new()
362 nvkm_device_tegra_power_down(tdev); in nvkm_device_tegra_new()
364 nvkm_device_tegra_remove_iommu(tdev); in nvkm_device_tegra_new()
366 kfree(tdev); in nvkm_device_tegra_new()