Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0018  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0019  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0020  * DEALINGS IN THE SOFTWARE.
0021  */
0022 #include "nouveau_platform.h"
0023 
0024 static int nouveau_platform_probe(struct platform_device *pdev)
0025 {
0026     const struct nvkm_device_tegra_func *func;
0027     struct nvkm_device *device = NULL;
0028     struct drm_device *drm;
0029     int ret;
0030 
0031     func = of_device_get_match_data(&pdev->dev);
0032 
0033     drm = nouveau_platform_device_create(func, pdev, &device);
0034     if (IS_ERR(drm))
0035         return PTR_ERR(drm);
0036 
0037     ret = drm_dev_register(drm, 0);
0038     if (ret < 0) {
0039         drm_dev_put(drm);
0040         return ret;
0041     }
0042 
0043     return 0;
0044 }
0045 
0046 static int nouveau_platform_remove(struct platform_device *pdev)
0047 {
0048     struct drm_device *dev = platform_get_drvdata(pdev);
0049     nouveau_drm_device_remove(dev);
0050     return 0;
0051 }
0052 
0053 #if IS_ENABLED(CONFIG_OF)
0054 static const struct nvkm_device_tegra_func gk20a_platform_data = {
0055     .iommu_bit = 34,
0056     .require_vdd = true,
0057 };
0058 
0059 static const struct nvkm_device_tegra_func gm20b_platform_data = {
0060     .iommu_bit = 34,
0061     .require_vdd = true,
0062     .require_ref_clk = true,
0063 };
0064 
0065 static const struct nvkm_device_tegra_func gp10b_platform_data = {
0066     .iommu_bit = 36,
0067     /* power provided by generic PM domains */
0068     .require_vdd = false,
0069 };
0070 
0071 static const struct of_device_id nouveau_platform_match[] = {
0072     {
0073         .compatible = "nvidia,gk20a",
0074         .data = &gk20a_platform_data,
0075     },
0076     {
0077         .compatible = "nvidia,gm20b",
0078         .data = &gm20b_platform_data,
0079     },
0080     {
0081         .compatible = "nvidia,gp10b",
0082         .data = &gp10b_platform_data,
0083     },
0084     { }
0085 };
0086 
0087 MODULE_DEVICE_TABLE(of, nouveau_platform_match);
0088 #endif
0089 
0090 struct platform_driver nouveau_platform_driver = {
0091     .driver = {
0092         .name = "nouveau",
0093         .of_match_table = of_match_ptr(nouveau_platform_match),
0094     },
0095     .probe = nouveau_platform_probe,
0096     .remove = nouveau_platform_remove,
0097 };