blob: aa8fc30b780e70c4fa20f557ca0f89a9837f76f7 [file] [log] [blame]
developer1966afb2023-08-08 16:02:18 +08001// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (c) 2023 Mediatek Inc. All Rights Reserved.
4 *
5 * Author: Ren-Ting Wang <ren-ting.wang@mediatek.com>
6 */
7
8#include <linux/device.h>
9#include <linux/err.h>
10#include <linux/module.h>
11#include <linux/of.h>
12#include <linux/of_platform.h>
13#include <linux/platform_device.h>
14
15#include "pce/cdrt.h"
16#include "pce/cls.h"
17#include "pce/debugfs.h"
18#include "pce/dipfilter.h"
19#include "pce/internal.h"
20#include "pce/netsys.h"
21#include "pce/pce.h"
22
23struct device *pce_dev;
24
25static int mtk_pce_probe(struct platform_device *pdev)
26{
27 int ret = 0;
28
29 pce_dev = &pdev->dev;
30
31 ret = mtk_pce_netsys_init(pdev);
32 if (ret)
33 return ret;
34
35 ret = mtk_pce_cls_init(pdev);
36 if (ret)
37 goto netsys_deinit;
38
39 ret = mtk_pce_dipfilter_init(pdev);
40 if (ret)
41 goto cls_deinit;
42
43 ret = mtk_pce_cdrt_init(pdev);
44 if (ret)
45 goto dipfilter_deinit;
46
47 ret = mtk_pce_debugfs_init(pdev);
48 if (ret)
49 goto cdrt_deinit;
50
51 ret = mtk_pce_enable();
52 if (ret)
53 goto debugfs_deinit;
54
55 return ret;
56
57debugfs_deinit:
58 mtk_pce_debugfs_deinit(pdev);
59
60cdrt_deinit:
61 mtk_pce_cdrt_deinit(pdev);
62
63dipfilter_deinit:
64 mtk_pce_dipfilter_deinit(pdev);
65
66cls_deinit:
67 mtk_pce_cls_deinit(pdev);
68
69netsys_deinit:
70 mtk_pce_netsys_deinit(pdev);
71
72 return ret;
73}
74
75static int mtk_pce_remove(struct platform_device *pdev)
76{
77 mtk_pce_disable();
78
79 mtk_pce_debugfs_deinit(pdev);
80
81 mtk_pce_cdrt_deinit(pdev);
82
83 mtk_pce_dipfilter_deinit(pdev);
84
85 mtk_pce_cls_deinit(pdev);
86
87 mtk_pce_netsys_deinit(pdev);
88
89 return 0;
90}
91
92static const struct of_device_id mtk_pce_match[] = {
93 { .compatible = "mediatek,pce", },
94 { },
95};
96MODULE_DEVICE_TABLE(of, mtk_pce_match);
97
98static struct platform_driver mtk_pce_driver = {
99 .probe = mtk_pce_probe,
100 .remove = mtk_pce_remove,
101 .driver = {
102 .name = "mediatek,pce",
103 .owner = THIS_MODULE,
104 .of_match_table = mtk_pce_match,
105 },
106};
107
108static int __init mtk_pce_init(void)
109{
110 return platform_driver_register(&mtk_pce_driver);
111}
112
113static void __exit mtk_pce_exit(void)
114{
115 platform_driver_unregister(&mtk_pce_driver);
116}
117
118module_init(mtk_pce_init);
119module_exit(mtk_pce_exit);
120
121MODULE_LICENSE("GPL");
122MODULE_DESCRIPTION("MediaTek PCE Driver");
123MODULE_AUTHOR("Ren-Ting Wang <ren-ting.wang@mediatek.com>");