• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 #include "tde_init.h"
19 #include <linux/module.h>
20 #include <linux/kernel.h>
21 #include <linux/printk.h>
22 #include <linux/version.h>
23 #include <linux/of_platform.h>
24 #include "hi_type.h"
25 #include "hi_common.h"
26 #include "hi_osal.h"
27 
28 hi_u32 g_u32TdeTmpBuf = 1658880; /* 1658880 buffer size */
29 bool g_bResizeFilter = true;
30 hi_u32 g_u32TdeBuf = 0x20000; /* 0x20000 buffer size */
31 
32 module_param(g_u32TdeTmpBuf, uint, S_IRUGO);
33 module_param(g_bResizeFilter, bool, S_IRUGO);
34 module_param(g_u32TdeBuf, uint, S_IRUGO);
35 
hi35xx_tde_probe(struct platform_device * pdev)36 static int hi35xx_tde_probe(struct platform_device *pdev)
37 {
38     struct resource *mem = HI_NULL;
39     int tde_irq;
40     hi_u32 *base_vir_addr = HI_NULL;
41     mem = osal_platform_get_resource_byname(pdev, IORESOURCE_MEM, "tde");
42     base_vir_addr = devm_ioremap_resource(&pdev->dev, mem);
43     tde_hal_set_base_vir_addr(base_vir_addr);
44     if (IS_ERR(base_vir_addr)) {
45         return PTR_ERR(base_vir_addr);
46     }
47 
48     tde_irq = osal_platform_get_irq_byname(pdev, "tde_osr_isr");
49     if (tde_irq <= 0) {
50         dev_err(&pdev->dev, "cannot find tde IRQ\n");
51         return -1;
52     }
53     set_tde_irq((hi_u32)tde_irq);
54 
55     if (g_u32TdeBuf > 0) {
56         tde_init_set_buf(g_u32TdeBuf);
57     }
58     tde_set_resize_filter(g_bResizeFilter);
59     if (g_u32TdeTmpBuf > 0) {
60         tde_set_tde_tmp_buffer(g_u32TdeTmpBuf);
61     }
62 
63     if (tde_drv_mod_init() != HI_SUCCESS) {
64         osal_printk("load tde.ko for %s...FAILED!\n", CHIP_NAME);
65         return -1;
66     }
67     osal_printk("load tde.ko for %s...OK!\n", CHIP_NAME);
68     return 0;
69 }
70 
hi35xx_tde_remove(struct platform_device * pdev)71 static int hi35xx_tde_remove(struct platform_device *pdev)
72 {
73     hi_unused(pdev);
74     tde_drv_mod_exit();
75     osal_printk("unload tde.ko for %s...OK!\n", CHIP_NAME);
76     return 0;
77 }
78 
79 static const struct of_device_id g_hi35xx_tde_match[] = {
80     { .compatible = "hisilicon,hisi-tde" },
81     {},
82 };
83 MODULE_DEVICE_TABLE(of, g_hi35xx_tde_match);
84 
85 static struct platform_driver g_hi35xx_tde_driver = {
86     .probe = hi35xx_tde_probe,
87     .remove = hi35xx_tde_remove,
88     .driver = {
89         .name = "hi35xx_tde",
90         .of_match_table = g_hi35xx_tde_match,
91     },
92 };
93 
94 osal_module_platform_driver(g_hi35xx_tde_driver);
95 
96 MODULE_LICENSE("GPL");
97 
98