Home | History | Annotate | Line # | Download | only in nouveau
      1  1.1  riastrad /*	$NetBSD: nouveau_platform.c,v 1.3 2021/12/18 23:45:32 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
      5  1.1  riastrad  *
      6  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      7  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
      8  1.1  riastrad  * to deal in the Software without restriction, including without limitation
      9  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     11  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     12  1.1  riastrad  *
     13  1.1  riastrad  * The above copyright notice and this permission notice shall be included in
     14  1.1  riastrad  * all copies or substantial portions of the Software.
     15  1.1  riastrad  *
     16  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  1.1  riastrad  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     20  1.1  riastrad  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     21  1.1  riastrad  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     22  1.1  riastrad  * DEALINGS IN THE SOFTWARE.
     23  1.1  riastrad  */
     24  1.1  riastrad #include <sys/cdefs.h>
     25  1.1  riastrad __KERNEL_RCSID(0, "$NetBSD: nouveau_platform.c,v 1.3 2021/12/18 23:45:32 riastradh Exp $");
     26  1.1  riastrad 
     27  1.1  riastrad #include "nouveau_platform.h"
     28  1.1  riastrad 
     29  1.1  riastrad static int nouveau_platform_probe(struct platform_device *pdev)
     30  1.1  riastrad {
     31  1.1  riastrad 	const struct nvkm_device_tegra_func *func;
     32  1.1  riastrad 	struct nvkm_device *device = NULL;
     33  1.1  riastrad 	struct drm_device *drm;
     34  1.1  riastrad 	int ret;
     35  1.1  riastrad 
     36  1.1  riastrad 	func = of_device_get_match_data(&pdev->dev);
     37  1.1  riastrad 
     38  1.1  riastrad 	drm = nouveau_platform_device_create(func, pdev, &device);
     39  1.1  riastrad 	if (IS_ERR(drm))
     40  1.1  riastrad 		return PTR_ERR(drm);
     41  1.1  riastrad 
     42  1.1  riastrad 	ret = drm_dev_register(drm, 0);
     43  1.1  riastrad 	if (ret < 0) {
     44  1.3  riastrad 		drm_dev_put(drm);
     45  1.1  riastrad 		return ret;
     46  1.1  riastrad 	}
     47  1.1  riastrad 
     48  1.1  riastrad 	return 0;
     49  1.1  riastrad }
     50  1.1  riastrad 
     51  1.1  riastrad static int nouveau_platform_remove(struct platform_device *pdev)
     52  1.1  riastrad {
     53  1.1  riastrad 	struct drm_device *dev = platform_get_drvdata(pdev);
     54  1.1  riastrad 	nouveau_drm_device_remove(dev);
     55  1.1  riastrad 	return 0;
     56  1.1  riastrad }
     57  1.1  riastrad 
     58  1.1  riastrad #if IS_ENABLED(CONFIG_OF)
     59  1.1  riastrad static const struct nvkm_device_tegra_func gk20a_platform_data = {
     60  1.1  riastrad 	.iommu_bit = 34,
     61  1.3  riastrad 	.require_vdd = true,
     62  1.3  riastrad };
     63  1.3  riastrad 
     64  1.3  riastrad static const struct nvkm_device_tegra_func gm20b_platform_data = {
     65  1.3  riastrad 	.iommu_bit = 34,
     66  1.3  riastrad 	.require_vdd = true,
     67  1.3  riastrad 	.require_ref_clk = true,
     68  1.3  riastrad };
     69  1.3  riastrad 
     70  1.3  riastrad static const struct nvkm_device_tegra_func gp10b_platform_data = {
     71  1.3  riastrad 	.iommu_bit = 36,
     72  1.3  riastrad 	/* power provided by generic PM domains */
     73  1.3  riastrad 	.require_vdd = false,
     74  1.1  riastrad };
     75  1.1  riastrad 
     76  1.1  riastrad static const struct of_device_id nouveau_platform_match[] = {
     77  1.1  riastrad 	{
     78  1.1  riastrad 		.compatible = "nvidia,gk20a",
     79  1.1  riastrad 		.data = &gk20a_platform_data,
     80  1.1  riastrad 	},
     81  1.1  riastrad 	{
     82  1.1  riastrad 		.compatible = "nvidia,gm20b",
     83  1.3  riastrad 		.data = &gm20b_platform_data,
     84  1.3  riastrad 	},
     85  1.3  riastrad 	{
     86  1.3  riastrad 		.compatible = "nvidia,gp10b",
     87  1.3  riastrad 		.data = &gp10b_platform_data,
     88  1.1  riastrad 	},
     89  1.1  riastrad 	{ }
     90  1.1  riastrad };
     91  1.1  riastrad 
     92  1.1  riastrad MODULE_DEVICE_TABLE(of, nouveau_platform_match);
     93  1.1  riastrad #endif
     94  1.1  riastrad 
     95  1.1  riastrad struct platform_driver nouveau_platform_driver = {
     96  1.1  riastrad 	.driver = {
     97  1.1  riastrad 		.name = "nouveau",
     98  1.1  riastrad 		.of_match_table = of_match_ptr(nouveau_platform_match),
     99  1.1  riastrad 	},
    100  1.1  riastrad 	.probe = nouveau_platform_probe,
    101  1.1  riastrad 	.remove = nouveau_platform_remove,
    102  1.1  riastrad };
    103  1.3  riastrad 
    104  1.3  riastrad #if IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC)
    105  1.3  riastrad MODULE_FIRMWARE("nvidia/gk20a/fecs_data.bin");
    106  1.3  riastrad MODULE_FIRMWARE("nvidia/gk20a/fecs_inst.bin");
    107  1.3  riastrad MODULE_FIRMWARE("nvidia/gk20a/gpccs_data.bin");
    108  1.3  riastrad MODULE_FIRMWARE("nvidia/gk20a/gpccs_inst.bin");
    109  1.3  riastrad MODULE_FIRMWARE("nvidia/gk20a/sw_bundle_init.bin");
    110  1.3  riastrad MODULE_FIRMWARE("nvidia/gk20a/sw_ctx.bin");
    111  1.3  riastrad MODULE_FIRMWARE("nvidia/gk20a/sw_method_init.bin");
    112  1.3  riastrad MODULE_FIRMWARE("nvidia/gk20a/sw_nonctx.bin");
    113  1.3  riastrad #endif
    114