drivers/gpu/drm/nouveau/nouveau_platform.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nouveau_platform.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/nouveau/nouveau_platform.c
Extension
.c
Size
3060 bytes
Lines
108
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

#include "nouveau_platform.h"

#include <nvkm/subdev/clk/gk20a_devfreq.h>

static int nouveau_platform_probe(struct platform_device *pdev)
{
	const struct nvkm_device_tegra_func *func;
	struct nvkm_device *device = NULL;
	struct drm_device *drm;

	func = of_device_get_match_data(&pdev->dev);

	drm = nouveau_platform_device_create(func, pdev, &device);
	return PTR_ERR_OR_ZERO(drm);
}

static void nouveau_platform_remove(struct platform_device *pdev)
{
	struct nouveau_drm *drm = platform_get_drvdata(pdev);

	nouveau_drm_device_remove(drm);
}

#ifdef CONFIG_PM_SLEEP
static int nouveau_platform_suspend(struct device *dev)
{
	return gk20a_devfreq_suspend(dev);
}

static int nouveau_platform_resume(struct device *dev)
{
	return gk20a_devfreq_resume(dev);
}

static SIMPLE_DEV_PM_OPS(nouveau_pm_ops, nouveau_platform_suspend,
			 nouveau_platform_resume);
#endif

#if IS_ENABLED(CONFIG_OF)
static const struct nvkm_device_tegra_func gk20a_platform_data = {
	.iommu_bit = 34,
	.require_vdd = true,
};

static const struct nvkm_device_tegra_func gm20b_platform_data = {
	.iommu_bit = 34,
	.require_vdd = true,
	.require_ref_clk = true,
};

static const struct nvkm_device_tegra_func gp10b_platform_data = {
	.iommu_bit = 36,
	/* power provided by generic PM domains */
	.require_vdd = false,
};

static const struct of_device_id nouveau_platform_match[] = {
	{
		.compatible = "nvidia,gk20a",
		.data = &gk20a_platform_data,
	},
	{
		.compatible = "nvidia,gm20b",
		.data = &gm20b_platform_data,
	},
	{
		.compatible = "nvidia,gp10b",
		.data = &gp10b_platform_data,
	},
	{ }
};

MODULE_DEVICE_TABLE(of, nouveau_platform_match);
#endif

struct platform_driver nouveau_platform_driver = {
	.driver = {
		.name = "nouveau",
		.of_match_table = of_match_ptr(nouveau_platform_match),
#ifdef CONFIG_PM_SLEEP
		.pm = &nouveau_pm_ops,
#endif
	},
	.probe = nouveau_platform_probe,
	.remove = nouveau_platform_remove,
};

Annotation

Implementation Notes