From d32b4667a5dce91be0e109cc22a4c4ed45a02d27 Mon Sep 17 00:00:00 2001 From: Santosh BS Date: Wed, 20 Nov 2024 13:42:55 +0000 Subject: [PATCH] drm/tegra: move legacy chip support under config option - Update Makefile to build the legacy chip related files only when any of the below configs are set. CONFIG_ARCH_TEGRA_2x_SOC CONFIG_ARCH_TEGRA_3x_SOC CONFIG_ARCH_TEGRA_114_SOC CONFIG_ARCH_TEGRA_124_SOC CONFIG_ARCH_TEGRA_132_SOC CONFIG_ARCH_TEGRA_210_SOC CONFIG_ARCH_TEGRA_186_SOC CONFIG_ARCH_TEGRA_194_SOC - Update drm.c/.h to build legacy chip specific code portions for the respective configs accordingly. Jira HOSTX-5727 Signed-off-by: Santosh BS Change-Id: I3d2235923011073d82dcfe6b1fd6618ae70d37bb Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3253132 Reviewed-by: mobile promotions Tested-by: mobile promotions Reviewed-by: Mikko Perttunen GVS: buildbot_gerritrpt --- drivers/gpu/drm/tegra/Makefile | 10 ++++++-- drivers/gpu/drm/tegra/drm.c | 47 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/tegra/drm.h | 21 +++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tegra/Makefile b/drivers/gpu/drm/tegra/Makefile index e8fd8a49..03726210 100644 --- a/drivers/gpu/drm/tegra/Makefile +++ b/drivers/gpu/drm/tegra/Makefile @@ -12,6 +12,12 @@ tegra-drm-y := \ firewall.o \ gem.o \ fb.o \ + virt.o + +ifneq ($(filter y, $(CONFIG_ARCH_TEGRA_2x_SOC) $(CONFIG_ARCH_TEGRA_3x_SOC) \ + $(CONFIG_ARCH_TEGRA_114_SOC) $(CONFIG_ARCH_TEGRA_124_SOC) $(CONFIG_ARCH_TEGRA_132_SOC) \ + $(CONFIG_ARCH_TEGRA_210_SOC) $(CONFIG_ARCH_TEGRA_186_SOC) $(CONFIG_ARCH_TEGRA_194_SOC)),) +tegra-drm-y += \ dp.o \ hub.o \ plane.o \ @@ -25,8 +31,8 @@ tegra-drm-y := \ sor.o \ dpaux.o \ gr2d.o \ - gr3d.o \ - virt.o + gr3d.o +endif ifeq ($(CONFIG_TEGRA_DRM_NATIVE_DIS),y) ccflags-y += -DCONFIG_TEGRA_DRM_NATIVE_DIS diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index b820d66c..c747b495 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -60,7 +60,13 @@ static int tegra_atomic_check(struct drm_device *drm, if (err < 0) return err; +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC) return tegra_display_hub_atomic_check(drm, state); +#else + return 0; +#endif } static const struct drm_mode_config_funcs tegra_drm_mode_config_funcs = { @@ -72,6 +78,9 @@ static const struct drm_mode_config_funcs tegra_drm_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit, }; +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC) static void tegra_atomic_post_commit(struct drm_device *drm, struct drm_atomic_state *old_state) { @@ -110,6 +119,12 @@ static const struct drm_mode_config_helper_funcs tegra_drm_mode_config_helpers = { .atomic_commit_tail = tegra_atomic_commit_tail, }; +#else +static const struct drm_mode_config_helper_funcs +tegra_drm_mode_config_helpers = { + .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm, +}; +#endif static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp) { @@ -1294,11 +1309,15 @@ static int host1x_drm_probe(struct host1x_device *dev) iova_cache_put(); } +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC) if (tegra->hub) { err = tegra_display_hub_prepare(tegra->hub); if (err < 0) goto device; } +#endif #if defined(NV_DRM_DRIVER_STRUCT_HAS_IRQ_ENABLED_ARG) /* Linux v5.15 */ /* @@ -1345,9 +1364,13 @@ static int host1x_drm_probe(struct host1x_device *dev) fb: tegra_drm_fb_exit(drm); hub: +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC) if (tegra->hub) tegra_display_hub_cleanup(tegra->hub); device: +#endif if (tegra->domain) { mutex_destroy(&tegra->mm_lock); drm_mm_takedown(&tegra->mm); @@ -1384,8 +1407,12 @@ static int host1x_drm_remove(struct host1x_device *dev) drm_atomic_helper_shutdown(drm); drm_mode_config_cleanup(drm); +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC) if (tegra->hub) tegra_display_hub_cleanup(tegra->hub); +#endif err = host1x_device_exit(dev); if (err < 0) @@ -1425,25 +1452,36 @@ static SIMPLE_DEV_PM_OPS(host1x_drm_pm_ops, host1x_drm_suspend, host1x_drm_resume); static const struct of_device_id host1x_drm_subdevs[] = { +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) { .compatible = "nvidia,tegra20-dc", }, { .compatible = "nvidia,tegra20-hdmi", }, { .compatible = "nvidia,tegra20-gr2d", }, { .compatible = "nvidia,tegra20-gr3d", }, +#endif +#if IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) { .compatible = "nvidia,tegra30-dc", }, { .compatible = "nvidia,tegra30-hdmi", }, { .compatible = "nvidia,tegra30-gr2d", }, { .compatible = "nvidia,tegra30-gr3d", }, +#endif +#if IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) { .compatible = "nvidia,tegra114-dc", }, { .compatible = "nvidia,tegra114-dsi", }, { .compatible = "nvidia,tegra114-hdmi", }, { .compatible = "nvidia,tegra114-gr2d", }, { .compatible = "nvidia,tegra114-gr3d", }, +#endif +#if IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) { .compatible = "nvidia,tegra124-dc", }, { .compatible = "nvidia,tegra124-sor", }, { .compatible = "nvidia,tegra124-hdmi", }, { .compatible = "nvidia,tegra124-dsi", }, { .compatible = "nvidia,tegra124-vic", }, +#endif +#if IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC) { .compatible = "nvidia,tegra132-dsi", }, +#endif +#if IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) { .compatible = "nvidia,tegra210-dc", }, { .compatible = "nvidia,tegra210-dsi", }, { .compatible = "nvidia,tegra210-sor", }, @@ -1452,6 +1490,8 @@ static const struct of_device_id host1x_drm_subdevs[] = { { .compatible = "nvidia,tegra210-nvdec", }, { .compatible = "nvidia,tegra210-nvenc", }, { .compatible = "nvidia,tegra210-nvjpg", }, +#endif +#if IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC) { .compatible = "nvidia,tegra186-display", }, { .compatible = "nvidia,tegra186-dc", }, { .compatible = "nvidia,tegra186-sor", }, @@ -1460,6 +1500,8 @@ static const struct of_device_id host1x_drm_subdevs[] = { { .compatible = "nvidia,tegra186-nvdec", }, { .compatible = "nvidia,tegra186-nvenc", }, { .compatible = "nvidia,tegra186-nvjpg", }, +#endif +#if IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC) { .compatible = "nvidia,tegra194-display", }, { .compatible = "nvidia,tegra194-dc", }, { .compatible = "nvidia,tegra194-sor", }, @@ -1467,6 +1509,7 @@ static const struct of_device_id host1x_drm_subdevs[] = { { .compatible = "nvidia,tegra194-nvdec", }, { .compatible = "nvidia,tegra194-nvenc", }, { .compatible = "nvidia,tegra194-nvjpg", }, +#endif #ifndef CONFIG_TEGRA_DRM_NATIVE_DIS { .compatible = "nvidia,tegra234-vic", }, { .compatible = "nvidia,tegra234-nvdec", }, @@ -1491,6 +1534,9 @@ static struct host1x_driver host1x_drm_driver = { }; static struct platform_driver * const drivers[] = { +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC) &tegra_display_hub_driver, &tegra_dc_driver, &tegra_hdmi_driver, @@ -1499,6 +1545,7 @@ static struct platform_driver * const drivers[] = { &tegra_sor_driver, &tegra_gr2d_driver, &tegra_gr3d_driver, +#endif #ifndef CONFIG_TEGRA_DRM_NATIVE_DIS &tegra_vic_driver, &tegra_nvdec_driver, diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index 1bc54fa3..db2cb55b 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -12,16 +12,24 @@ #include #include +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC) #include #include #include +#endif #include #include #include #include #include "gem.h" +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC) #include "hub.h" +#endif #include /* XXX move to include/uapi/drm/drm_fourcc.h? */ @@ -61,7 +69,11 @@ struct tegra_drm { unsigned int pitch_align; unsigned int num_crtcs; +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC) struct tegra_display_hub *hub; +#endif }; static inline struct host1x *tegra_drm_to_host1x(struct tegra_drm *tegra) @@ -150,6 +162,9 @@ void *tegra_drm_alloc(struct tegra_drm *tegra, size_t size, dma_addr_t *iova); void tegra_drm_free(struct tegra_drm *tegra, size_t size, void *virt, dma_addr_t iova); +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC) struct cec_notifier; struct tegra_output { @@ -200,6 +215,7 @@ int drm_dp_aux_attach(struct drm_dp_aux *aux, struct tegra_output *output); int drm_dp_aux_detach(struct drm_dp_aux *aux); int drm_dp_aux_enable(struct drm_dp_aux *aux); int drm_dp_aux_disable(struct drm_dp_aux *aux); +#endif /* from fb.c */ struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer, @@ -215,6 +231,9 @@ void tegra_drm_fb_free(struct drm_device *drm); int tegra_drm_fb_init(struct drm_device *drm); void tegra_drm_fb_exit(struct drm_device *drm); +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC) || \ + IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC) extern struct platform_driver tegra_display_hub_driver; extern struct platform_driver tegra_dc_driver; extern struct platform_driver tegra_hdmi_driver; @@ -223,6 +242,8 @@ extern struct platform_driver tegra_dpaux_driver; extern struct platform_driver tegra_sor_driver; extern struct platform_driver tegra_gr2d_driver; extern struct platform_driver tegra_gr3d_driver; +#endif + #ifndef CONFIG_TEGRA_DRM_NATIVE_DIS extern struct platform_driver tegra_vic_driver; extern struct platform_driver tegra_nvdec_driver;