xref: /OK3568_Linux_fs/kernel/drivers/hwtracing/coresight/mali/coresight_mali_common.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
2 /*
3  *
4  * (C) COPYRIGHT 2022 ARM Limited. All rights reserved.
5  *
6  * This program is free software and is provided to you under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation, and any use by you of this program is subject to the terms
9  * of such GNU license.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you can access it online at
18  * http://www.gnu.org/licenses/gpl-2.0.html.
19  *
20  */
21 
22 #include <linux/device.h>
23 #include <linux/coresight.h>
24 
25 #include <coresight-priv.h>
26 #include "coresight_mali_common.h"
27 
coresight_mali_enable_component(struct coresight_device * csdev,u32 mode)28 int coresight_mali_enable_component(struct coresight_device *csdev, u32 mode)
29 {
30 	struct coresight_mali_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
31 	int res = 0;
32 
33 	if (mode != CS_MODE_SYSFS) {
34 		dev_err(drvdata->dev, "Unsupported Mali CS_MODE: %d, expected: %d\n", mode,
35 			CS_MODE_SYSFS);
36 		return -EINVAL;
37 	}
38 
39 	drvdata->mode = mode;
40 
41 	res = kbase_debug_coresight_csf_config_enable(drvdata->config);
42 	if (res) {
43 		dev_err(drvdata->dev, "Config failed to enable with error code %d\n", res);
44 		drvdata->mode = CS_MODE_DISABLED;
45 	}
46 
47 	return res;
48 }
49 
coresight_mali_disable_component(struct coresight_device * csdev)50 int coresight_mali_disable_component(struct coresight_device *csdev)
51 {
52 	struct coresight_mali_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
53 	int res = 0;
54 
55 	res = kbase_debug_coresight_csf_config_disable(drvdata->config);
56 	if (res)
57 		dev_err(drvdata->dev, "config failed to disable with error code %d\n", res);
58 
59 	drvdata->mode = CS_MODE_DISABLED;
60 
61 	return res;
62 }
63