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