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 #include "hiir.h"
25
26 #define OSDRV_MODULE_VERSION_STRING "HISI_ir @HiMPP"
27
28 extern unsigned int g_ir_irq;
29 extern volatile void *g_ir_reg_base;
30
hi_ir_probe(struct platform_device * pdev)31 static int hi_ir_probe(struct platform_device *pdev)
32 {
33 struct resource *mem = NULL;
34
35 g_ir_irq = platform_get_irq(pdev, 0);
36 if (g_ir_irq <= 0) {
37 dev_err(&pdev->dev, "cannot find ir IRQ%d. \n", g_ir_irq);
38 }
39
40 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
41 g_ir_reg_base = (volatile void *)devm_ioremap_resource(&pdev->dev, mem);
42 if (IS_ERR((void *)g_ir_reg_base)) {
43 dev_err(&pdev->dev, "ir reg map failed. \n");
44 }
45
46 return hiir_init();
47 }
48
hi_ir_remove(struct platform_device * pdev)49 static int hi_ir_remove(struct platform_device *pdev)
50 {
51 hi_ir_unused(pdev);
52
53 hiir_exit();
54 return 0;
55 }
56
57 static const struct of_device_id g_hi_ir_match[] = {
58 { .compatible = "hisilicon,hi_ir" },
59 { .compatible = "hisilicon,hi-ir" },
60 {},
61 };
62
63 static struct platform_driver g_hi_ir_driver = {
64 .probe = hi_ir_probe,
65 .remove = hi_ir_remove,
66 .driver = {
67 .name = "hi_ir", /* hi-ir */
68 .of_match_table = g_hi_ir_match,
69 },
70 };
71
72 module_platform_driver(g_hi_ir_driver);
73 MODULE_LICENSE("GPL");
74 MODULE_AUTHOR("Hisilicon");
75 MODULE_DESCRIPTION("Hisilicon Infrared remoter(HIIR11) Device Driver");
76 MODULE_VERSION("HI_VERSION=" OSDRV_MODULE_VERSION_STRING);
77