• 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 
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 
25 #include "hi_type.h"
26 #include "hi_adc.h"
27 
28 #define OSDRV_MODULE_VERSION_STRING "HISI_adc @HiMPP"
29 
30 extern unsigned int g_lsadc_irq;
31 extern volatile void *g_lsadc_reg_base;
32 
hi_adc_probe(struct platform_device * pdev)33 static int hi_adc_probe(struct platform_device *pdev)
34 {
35     struct resource *mem = NULL;
36 
37     g_lsadc_irq = platform_get_irq(pdev, 0);
38     if (g_lsadc_irq <= 0) {
39             dev_err(&pdev->dev, "cannot find lsadc IRQ%d. \n", g_lsadc_irq);
40     }
41 
42     mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
43     g_lsadc_reg_base = (volatile void *)devm_ioremap_resource(&pdev->dev, mem);
44     if (IS_ERR((void*)g_lsadc_reg_base)) {
45         dev_err(&pdev->dev, "lsadc reg map failed. \n");
46     }
47 
48     return lsadc_init();
49 }
50 
hi_adc_remove(struct platform_device * pdev)51 static int hi_adc_remove(struct platform_device *pdev)
52 {
53     hi_adc_unused(pdev);
54 
55     lsadc_exit();
56     return 0;
57 }
58 
59 static const struct of_device_id g_hi_adc_match[] = {
60     { .compatible = "hisilicon,hisi-lsadc" },
61     {},
62 };
63 
64 static struct platform_driver g_hi_lsadc_driver = {
65     .probe  = hi_adc_probe,
66     .remove = hi_adc_remove,
67     .driver =  { .name = "hi_lsadc",
68                  .of_match_table = g_hi_adc_match,
69                },
70 };
71 
72 module_platform_driver(g_hi_lsadc_driver);
73 
74 MODULE_LICENSE("GPL");
75 MODULE_AUTHOR("Digital Media Team ,Hisilicon crop ");
76 MODULE_DESCRIPTION("HISI ADC Driver");
77 MODULE_VERSION("HI_VERSION=" OSDRV_MODULE_VERSION_STRING);
78 
79